akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<cstring>
using namespace std;

typedef unsigned long long ull;

#define MAX 2100

#define  B  (ull)((int)1e9+7)
#define  B2  (ull)((int)1e9+9)

int H, W, R, C;
string hw[MAX], rc[MAX];

void solve(){
	ull bm = 1, bm2 = 1, hhw = 0, hrc = 0, temph[MAX] = {}, temp = 0;
	
	for(int i = 0; i < C; i++) bm *= B;
	for(int i = 0; i < R; i++) bm2 *= B2;
	
	for(int i = 0; i < R; i++){
		for(int j = 0; j < C; j++) temph[i] = temph[i]*B + hw[i][j];
		hhw = hhw*B2 + temph[i];
		// for(int j = C; j < W; j++) temp = temp*B + hw[i][j];
	}
	
	for(int i = 0; i < R; i++){
		temp = 0;
		for(int j = 0; j < C; j++) temp = temp*B + rc[i][j];
		hrc = hrc*B2 + temp;
	}
	// cout<<hhw<<" "<<hrc<<endl;
	for(int i = 0; i + R <= H; i++){
		for(int j = 0; j + C <= W; j++){
			// cout<<i<<" "<<j<<" "<<hhw<<" "<<hrc<<endl;
			if(hhw == hrc) cout<<i<<" "<<j<<endl;
			if(j+C>W)continue;
			hhw = 0;
			for(int k = 0; k < R; k++){
				temph[i+k] = temph[i+k]*B + hw[i+k][j+C] - hw[i+k][j]*bm;
				// temph[i+k] = 0;
				// for(int l = j; l < C+j; l++) temph[i+k] = temph[i+k]*B + hw[i+k][j];
				hhw = hhw*B2 + temph[i+k];
				// cout<<i<<" "<<j<<" "<<k<<" "<<temph[i+k]<<endl;
			}
			// cout<<hhw<<" +++ "<<endl<<endl;
		}
		if(i+R>H)continue;
		hhw = 0;
		for(int j = 1; j <= R; j++){
			temph[i+j] = 0;
			for(int k = 0; k < C; k++) temph[i+j] = temph[i+j]*B + hw[i+j][k];
			hhw = hhw*B2 + temph[i+j];
		}
		// for(int j = 0; j < C; j++) temph[i+R] = temph[i+R]*B + hw[i+R][j];
		// hhw = hhw*B2 + temph[i+R] - temph[i]*bm2;		
	}
}

int main(){
	cin>>H>>W;
	
	for(int i = 0; i < H; i++){
		cin>>hw[i];
	}
	
	cin>>R>>C;
	
	for(int i = 0; i < R; i++){
		cin>>rc[i];
	}
	
	solve();
	
	return 0;
}


Measured memory_bytes: 5136
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		char[] str = sc.next().toCharArray();

		int i = 0;
		int ans = 0;
		while (true) {
			int J = 0;
			int O = 0;
			int I = 0;
			while (str[i] == 'J') {
				i++;
				J++;
				if (i == str.length)
					break;
			}
			if (i == str.length) {
				break;
			}
			while (str[i] == 'O') {
				i++;
				O++;
				if (i == str.length)
					break;
			}
			if (i == str.length)
				break;
			while (str[i] == 'I') {
				i++;
				I++;
				if (i == str.length)
					break;
			}if(O<=J&&O<=I)
			ans = Math.max(ans, Math.min(I, Math.min(O, J)));
			if (i == str.length)
				break;
		//	System.out.println(J + " " + O + " " + I);
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 18000
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define fst first
#define scd second
using namespace std;

inline ll read() {
	ll f=1,x=0;
	char ch=getchar();
	
	while(!isdigit(ch)){
	   if(ch=='-')
	      f=-1;
	   ch=getchar();
	}
	
	while(isdigit(ch)){
	   x=x*10+ch-'0';
	   ch=getchar();
	}
	
	return x*f;
}

const int MAXN=1e5+5;
int n,m,fa[MAXN];

struct EDGE {
	int u,v;
}e[MAXN];

ll ans[MAXN],sz[MAXN];

int get_fa(int x) {
	if(x==fa[x]) return x;
	return fa[x]=get_fa(fa[x]);
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	n=read();
	m=read();
	
	for(int i=1;i<=m;++i) {
		e[i].u=read(); 
		e[i].v=read();
	}
	
	for(int i=1;i<=n;++i) 
	   fa[i]=i,sz[i]=1;
	
	ans[m]=(ll)n*(n-1)/2;
	
	for(int i=m;i>=1;--i) {
		int u=get_fa(e[i].u),v=get_fa(e[i].v);
		if(u==v) 
		    ans[i-1]=ans[i];
		else {
			ans[i-1]=ans[i]-sz[v]*sz[u];
			sz[v]+=sz[u]; fa[u]=v;
		}
	}
	
	for(int i=1;i<=m;++i) 
	   cout<<ans[i]<<endl;
	return 0;
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector <ll> vi;
typedef vector <pi> vpi;
#define f first
#define s second
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0)
int ans = 0;
int N;
int main(){
	fast;
	cin>>N;
  
  	ans += (N / 500) * 1000;
    N %= 500;
  ans += (N / 5) * 5;
    cout<<ans;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int w = sc.nextInt();
		ArrayList<Integer>[] all = new ArrayList[4];
		for (int i = 0; i < 4; i++) {
			all[i] = new ArrayList<Integer>();
		}
		int w1 = sc.nextInt();
		int v1 = sc.nextInt();
		all[0].add(v1);
		for (int i = 1; i < n; i++) {
			int ww = sc.nextInt();
			int vv = sc.nextInt();
			all[ww - w1].add(vv);
		}
		for (int i = 0; i < 4; i++) {
			Collections.sort(all[i]);
		}
		int max = 0;
		int va = 0;
		for (int a = 0; a <= all[0].size() && w1 * a <= w; a++) {
			if (a > 0) {
				va += all[0].get(all[0].size() - a);
			}
			int vb = 0;
			for (int b = 0; b <= all[1].size() && w1 * a + (w1 + 1) * b <= w; b++) {
				if (b > 0) {
					vb += all[1].get(all[1].size() - b);
				}
				int vc = 0;
				for (int c = 0; c <= all[2].size() && w1 * a + (w1 + 1) * b + (w1 + 2) * c <= w; c++) {
					if (c > 0) {
						vc += all[2].get(all[2].size() - c);
					}
					int vd = 0;
					for (int d = 0; d <= all[3].size() && w1 * a + (w1 + 1) * b + (w1 + 2) * c + (w1 + 3) * d <= w; d++) {
						if (d > 0) {
							vd += all[3].get(all[3].size() - d);
						}
						int sum = va + vb + vc + vd;
						if (max < sum) {
							max = sum;
						}
					}
				}
			}
		}
		System.out.println(max);
	}
}


Measured memory_bytes: 22740
#include <bits/stdc++.h>
using namespace std;

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long

int main() {
    fastio;
    int n;
    cin >> n;
    int* a = new int[n];
    int* b = new int[n];

    for (int i = 0; i < n; ++i) cin >> a[i], b[i] = a[i];

    /*int m = *max_element(a, a + n), count = 0;
    for (int i = 0; i < n; ++i) {
        if (a[i] == m) count++;
        if (count > 1) break;
    }

    for (int i = 0; i < n; ++i) {
        if (a[i] == m && count > 1) {
            cout << m << "\n";
        }
        else {
            int t = a[i];
            a[i] = 0;
            cout << *max_element(a, a + n) << "\n";
            a[i] = t;
        }
    }*/

    sort(b, b + n);
    for (int i = 0; i < n - 1; ++i) {
        if (a[i] != b[n - 1]) cout << b[n - 1] << "\n";
        else cout << b[n - 2] << "\n";
    }
    cout << (a[n - 1] == b[n - 1] ? b[n - 2] : b[n - 1]);

    return 0;
}

Measured memory_bytes: 3200
// abc141_f
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;


ull func(vector<ull> a){
    int n = a.size();
    int rank = 0;
    REP_REV(i, 60) {
        int j;
        for (j = rank; j < n; j++) {
            if (a[j] & (1ull << i)) break;
        }
        if (j == n) continue;

        if (j > rank) a[rank] ^= a[j];

        for (j = 0; j < n; j++) {
            if (j == rank) continue;
            if (a[j] & (1ull << i)) a[j] ^= a[rank];
        }

        rank++;
    }
    ull x = 0;
    REP(i, n) {
        x ^= a[i];
    }

    return x;
}

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N;
    cin >> N;
    vector<ull> A(N);
    REP(i, N) cin >> A[i];

    ull allxor = 0;
    REP(i, N) allxor ^= A[i];
    REP(i, N) A[i] &= ~allxor;

    ull res = allxor + 2 * func(A);
    print(res);

    return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>

int main(void)
{
	long long int a,b=0;
	scanf("%lld", &a);
	for (int i = 1; i <= a;i++) {

		if (i%3!=0&&i%5!=0) {
			//printf("%d\n", i);
			b += i;
		}
	}
	printf("%lld",b);

	return 0;
}

Measured memory_bytes: 1732
# import math
import fractions


a, b, c, d = map(int, input().split())


def lcm(x, y):
    # DeprecationWarning: fractions.gcd() is deprecated. Use math.gcd() instead.
    return x * y // fractions.gcd(x, y)


a1 = a - 1
div_a = (a1 // c) + (a1 // d) - (a1 // lcm(c, d))
div_b = (b // c) + (b // d) - (b // lcm(c, d))

print((b - a + 1) - (div_b - div_a))


Measured memory_bytes: 5600
#include <algorithm>
#include <string.h>
#include <iostream>
#include <stdio.h>

using namespace std;

typedef long long ll;                            
ll x[6];

int main() {
	for (ll i = 1; i <= 5; i++) cin >> x[i];
	for (ll i = 1; i <= 5; i++) if (x[i] == 0) cout << i << endl;



	return 0;
}

Measured memory_bytes: 3632
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	t, _ := strconv.Atoi(sc.Text())
	return t
}

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	for i := 0; i < n; i++ {
		a[i] = nextInt(sc)
	}
	cnt := ssort(a)
	printarray(a)
	fmt.Println(cnt)
}
func printarray(a []int) {
	for i := 0; i < len(a); i++ {
		fmt.Printf("%d", a[i])
		if i != len(a)-1 {
			fmt.Printf(" ")
		}
	}
	fmt.Println()
}

func ssort(a []int) int {
	rcnt := 0
	for i := 0; i < len(a); i++ {
		minv := a[i]
		mini := i
		j := i + 1
		for j < len(a) {
			if minv > a[j] {
				minv = a[j]
				mini = j
			}
			j++
		}
		if i != mini {
			a[i], a[mini] = a[mini], a[i]
			rcnt++
		}
	}
	return rcnt
}



Measured memory_bytes: 1192
#include <iostream>
using namespace std;
 
int main(){
  int K,S;
   cin >> K >> S;
  int ans = 0;
  for(int i=0;i<=K;i++){
    for(int j=0;j<=K;j++){
      if(S-i-j<=K && (S-i-j>=0))
	   ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
int n=0;
bool flag=true;
vector<string> v;
cin>>n;
string a[n];
for(int i=0;i<n;i++){
cin>>a[i];
}
v.push_back(a[0]);
for(int i=0;i<n-1;i++){
if(a[i][a[i].length()-1] != a[i+1][0] || find(v.begin(), v.end(), a[i+1]) != v.end())
flag = false;
v.push_back(a[i+1]);
}
cout<< (flag ? "Yes" : "No") << endl;
return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<iomanip>
using namespace std;
int main()
{
    int n,m,ans,temp,total=0;
    vector<int> all;
    int tachi[200006]={0};
    cin>>n;
    for(int i = 2;i<=n;i++)
    {
        cin>>temp;
        tachi[temp]++;
    }
    
    for(int i = 1;i<=n;i++)
    {
        cout<<tachi[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 4428
#include "iostream"
#include "string"

int main()
{
	int temp = 1;
	int Num[10240];
	int i = 0;

	while (temp != 0){
		std::cin >> temp;
		Num[i] = temp;
		i++;
	}

	i = 0;
	while (Num[i] != 0){
		std::cout << "Case " << i + 1 << ": " << Num[i] << std::endl;
		i++;
	}
    return 0;
}

Measured memory_bytes: 3144
#include <stdio.h>
#include <string.h>
int MAX(int a,int b){
    return a>b?a:b;
}
int main()
{   int n;
    scanf("%d",&n);
    int a[n],x[n][n-1],y[n][n-1];
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
        for(int j=0;j<a[i];j++){
            scanf("%d%d",&x[i][j],&y[i][j]);
            x[i][j]--;
        }
    }
   
    
    int ans=0;
    for(int i=0;i<(1<<n);i++){
        int flag=0;
        for(int j=0;j<n;j++){
            if(i&(1<<j)){
                for(int k=0;k<a[j];k++){
                    if(i&(1<<x[j][k])){
                        if(y[j][k]==0){
                        flag=1;
                        }
                    }else{
                        if(y[j][k]==1){
                            flag=1;
                        }
                    }
                }
            }
        }
        if(flag==0){
            //printf("%d\n",i);
            ans=MAX(ans,__builtin_popcount(i));
        }
    }
    printf("%d",ans);

    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
using Graph=vector<vector<int>>;
using edge= struct{int to;ll cost;};


template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}


int main()
{
  int N;
  cin>>N;
  string s;
  cin>>s;
  int count=0;
  REP(i,N-1)
  {
    if(s[i]==s[i+1])
    {
      count=count+1;
    }
  }
  cout<<N-count<<endl;

}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL MOD = 1e9 + 7;
int n;
LL ans = 1, cnt_ver = 0, cnt_hor = 0;
string s1, s2;
vector<int> type;
int main() {
    cin >> n;
    cin >> s1 >> s2;
    s1 += '\0';
    for(int i = 0; i < s1.size() - 1; i++) {
        if(s1[i] == s1[i + 1]) {
            i++;
            type.push_back(1);
        }else {
            type.push_back(0);
        }
    }
    if(type[0] == 1) {
        ans = 6;
    }else {
        ans = 3;
    }
    int last = type[0];
    for(int i = 1; i < type.size(); i++) {
        if(last == 1) {
            if(type[i] == 1) {
                ans = (ans * 3) % MOD;
            }
        }else {
            ans = (ans * 2) % MOD;
        }
        last = type[i];
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;

struct Dimension {
    int N;
    vector< LL >basis;
    Dimension(int N) : N(N), basis(N, 0) { }

    bool add(LL x) {
        for (int i = 0; i < N; i++) {
            if (x&(1LL<<i)) {
                if (basis[i]) x ^= basis[i];
                else {
                    basis[i] = x;
                    return true;
                }
            }
        }
        return false;
    }
};

char solve() {
    int n;
    cin >> n;

    vector< LL >A(n);
    for (int i = 0; i < n; i++) cin >> A[i];

    string s;
    cin >> s;

    Dimension d(60);
    for (int i = n-1; i >= 0; i--) {
        if (d.add(A[i])) {
            if (s[i]=='1') return '1';
        }
    }
    return '0';
}


int main() {
    int t;
    cin >> t;

    while (t--) {
        cout << solve() << "\n";
    }


    return 0;
}


Measured memory_bytes: 3604
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a=scan.nextInt();
		int b=scan.nextInt();
		int c=scan.nextInt();
		if(Math.abs(a-b)>Math.abs(a-c)) {
			System.out.println("B");
		}
		else {
			System.out.println("A");
		}
	}
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;

const int mod = 1e9 + 7;

const int MAXN = 2e3 + 10, MAXL = 4e6 + 10;

int n, m, L;
int dp[MAXN][MAXN], fac[MAXL], inv[MAXL];

int C(int n, int m) {
	if (n < m) return 0;
	return (long long)fac[n] * inv[m] % mod * inv[n - m] % mod;
}

int main() {
	scanf("%d%d", &n, &m);
	if (m <= 1) {
		puts("1");
		return 0;
	}
	L = n * m;
	fac[0] = fac[1] = inv[0] = inv[1] = 1;
	for (int i = 2; i <= L; ++i) {
		fac[i] = (long long)fac[i - 1] * i % mod;
		inv[i] = (long long)(mod - mod / i) * inv[mod % i] % mod;
	}
	for (int i = 2; i <= L; ++i)
		inv[i] = (long long)inv[i - 1] * inv[i] % mod;
	dp[0][0] = 1;
	for (int i = 1; i <= n; ++i)
		for (int j = i; ~j; --j) {
			dp[i][j] = dp[i][j + 1]; // put white
			if (j) (dp[i][j] += (long long)dp[i - 1][j - 1] * C(i * m - j - 1, m - 2) % mod) %= mod;
		}
	printf("%d\n", static_cast<int>((long long)dp[n][0] * fac[n] % mod));
}

Measured memory_bytes: 47232
#include<bits/stdc++.h>

std::map <int, int> Hash;

int n;

int main(){
	scanf("%d", &n);
	for (int i = 0, x; i < n; ++ i){
		scanf("%d", &x);
		if (x > 3200){
			x = 3200;
		}
		++ Hash[x / 400];
	}
	int min = Hash.size(), max = min;
	if (Hash.count(8)){
		min = std::max(min - 1, 1);
		max = max - 1 + Hash[8];
	}
	printf("%d %d\n", min, max), 0;
}

Measured memory_bytes: 256
def main():
	S = input()
	ans = 0
	while(len(S) > 0):
		l = len(S) - 1
		S = S[0:l]

		if(l%2 == 0):
			left = S[0:l//2]
			right = S[l//2:]

			if(left == right):
				ans = l
				break

	print(ans)

if __name__ == "__main__":
	main()

Measured memory_bytes: 2940
/*            AUTHOR - SHIVAM GUPTA
                       Jalpaiguri Govt. Engg College             */
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

void solve()
{
    ll a[1005][1005]={0},n,m;
    string s[1005],t;
    ll i=0,j=0,k=0,c=0,l=0,r=0,p=1e9+7,q=0,x=0,y=0,z=0,flag=0,sum=0;
    cin>>n>>m;
    for(i=1;i<=n;i++){
        s[i]=" ";
        cin>>t;
        s[i]+=t;
    }
    a[1][1]=1;
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=m;j++)
        {
            if(i==1 and j==1)
            a[i][j]=1;
            else{
                if(s[i][j]=='.')
                    a[i][j] = (a[i-1][j] + a[i][j-1])%p;
            }
        }
    }
    cout<<a[n][m]<<endl;
}
bool imp=false;int main()
{
    fio;
    int t=1;
    if(imp)
	cin>>t;
	ll j=t;
    while(t--){
    // cout<<"Case #"<<j-t<<": ";
    solve();}
    return 0;
}

Measured memory_bytes: 9216
#include <cmath>
#include <iostream>

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

int insertionSort(int *a, int n, int g) {
  int cnt = 0;
  for (int i = g; i < n; ++i) {
    int v = a[i];
    int j = i - g;
    while (j >= 0 && v < a[j]) {
      a[j + g] = a[j];
      j -= g;
      cnt++;
    }
    a[j + g] = v;
  }
  return cnt;
}

int shellSort(int *a, int n) {
  int cnt = 0;
  int m = (int)(std::log(n) / std::log(2));
  if (m <= 0)
    m = 1;
  int g[m];

  rep(i, m) { g[i] = std::pow(2, i); }

  std::cout << m << '\n';
  rep(i, m) {
    std::cout << g[m - 1 - i];
    if (i == m - 1)
      std::cout << '\n';
    else
      std::cout << ' ';
  }

  rep(i, m) { cnt += insertionSort(a, n, g[m - i - 1]); }

  return cnt;
}

int main() {
  int n;
  std::cin >> n;
  int a[n];
  rep(i, n) std::cin >> a[i];

  int cnt = shellSort(a, n);

  std::cout << cnt << '\n';

  rep(i, n) std::cout << a[i] << '\n';

  return 0;
}


Measured memory_bytes: 7300
import fractions
a = list(map(int,input().split()))
N = a[0]
b = []
x = list(map(int,input().split()))
x.append(a[1])
x.sort()
flag = 0
for i in range(N):
    c = x[i+1] - x[i]
    if flag == 1:
        ans = fractions.gcd(c, ans) # 最大公約数を求める
    else:
        ans = c # 数列が一つの場合は差が答え
    b.append(c)
    flag = 1
print(ans)

Measured memory_bytes: 16240
#include <bits/stdc++.h>  // g++ -std=c++14 -o a a.cpp

using namespace std;

typedef pair<int, int> P;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

__attribute__((constructor))
void initial() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

bool isEven(ll n) {
    return n % 2 == 0;
}

bool isOdd(ll n) {
    return n % 2 == 1;
}

int main() {
    ll X, K, D;
    cin >> X >> K >> D;
    if (X < 0) {
        X = -X;
    }
    ll A = X / D;
    ll B = X % D;
    ll result;
    if (A > K) {
        result = X - (K * D);
    } else if (K == A) {
        result = B;
    } else {
        if ((isEven(A) && isEven(K)) || (isOdd(A) && isOdd(K))) {
            result = min(abs(B), abs(B - 2 * D));
        } else {
            result = B - D;
        }
    }
    cout << abs(result) << endl;
}


Measured memory_bytes: 3668
#include <bits/stdc++.h>

using namespace std;

#define TEMP_T template<typename T>
TEMP_T void sort(T& v){ sort(v.begin(), v.end()); }
TEMP_T void revs(T& v){ reverse(v.begin(), v.end()); }
TEMP_T void uniq(T& v){ sort(v); v.erase(unique(v.begin(), v.end()), v.end()); }
TEMP_T T    cums(T& v){ T r(v.size()); partial_sum(v.begin(), v.end(), r.begin()); return r; }
TEMP_T void show(T& v, char delim=' ', char end='\n'){ for(int i=0; i<v.size()-1; i++) cout << v[i] << delim; cout << v[v.size()-1] << end; }
TEMP_T T    acum(vector<T>& v, T b=0){ return accumulate(v.begin(), v.end(), b); }
TEMP_T vector<T> inpt(int n){ vector<T> v(n); for (int i=0; i<n; i++) cin >> v[i]; return v; }

static inline int in(){ int x; scanf("%d", &x); return x; }

int main()
{
  int n, r;
  while (n = in(), r = in(), n || r){
    deque<int> d(n);
    for (int i = 0; i < n; i++) d[i] = i;
    revs(d);
    for (int i = 0; i < r; i++){
      int p, c;
      p = in() - 1;
      c = in();
      deque<int> buf;
      for (int i = 0; i < c; i++){
        buf.push_front(d[p + i]);
      }
      d.erase(d.begin() + p, d.begin() + p + c);
      for (int i = 0; i < c; i++){
        d.push_front(buf[i]);
      }
    }
    cout << d[0] + 1 << endl;
  }
  return (0);
}

Measured memory_bytes: 1236
#include<bits/stdc++.h>
using namespace std;
#define ll long long

int main(void){
    int n; cin >> n;
    int d[n];
    for(int i=0;i<n;i++) cin >> d[i];
    sort(d,d+n);
    int half = (n-1)/2;
    int diff = d[half+1]-d[half];
    int ans = 0;
    if(diff != 0){
        int cnt = 0;
        for(int i=half+1;i<n;i++){
            cnt++;
        }
        if(n/2 == cnt) ans = diff;
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>

using namespace std;

#define F first
#define S second
#define modulo ll (1e9 + 7)

typedef long long ll;
typedef pair<int,int> pii;

void init(){
    cin.tie(0);
    cin.sync_with_stdio(0);
}

const int N = 109, M = 509, OO = 0x3f3f3f3f;
const ll llOO = 0x3f3f3f3f3f3f3f3f;

int main(){
    init();

    int n, cap, f; cin >> n >> cap;

    vector<int> v[4];
    for(int i = 0;i < 4;i++)    v[i].push_back(0);

    for(int i = 0;i < n;i++){
        int w, val;   cin >> w >> val;
        if(!i)  f = w;
        v[w - f].push_back(val);
    }

    for(int i = 0;i < 4;i++)    sort(v[i].rbegin(), v[i].rend() - 1);
    for(int i = 0;i < 4;i++)    partial_sum(v[i].begin(), v[i].end(), v[i].begin());

    ll ans = 0;
    for(int i = 0;i < v[0].size();i++){
        for(int j = 0;j < v[1].size();j++){
            for(int k = 0;k < v[2].size();k++){
                for(int l = 0;l < v[3].size();l++){
                    ll vals = v[0][i] + v[1][j] + v[2][k] + v[3][l];
                    ll w = (ll)f * (i + j + k + l) + j + 2 * k + 3 * l;
                    if(w <= cap)    ans = max(ans, vals);
                }
            }
        }
    }

    cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_map>
typedef long long ll;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(ll i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;
bool comp(string s1, string s2){
    if(s1.size() == s2.size()){
        return s1 > s2;
    }
    return s1.size() > s2.size();
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,M;
    ll A[10];
    cin >> N >> M;
    rep(i,0,M) cin >> A[i];
    ll cnt[10] = {0,2,5,5,4,5,6,3,7,6};
    vector<lpair> lp;
    rep(i,0,M){
        lp.push_back(make_pair(A[i], cnt[A[i]]));
    }
    sort(lp.begin(), lp.end(), greater<lpair>());
    ll dp[10010] = {};
    rep(i,0,N+1){
        dp[i] = -INF;
    }
    dp[0] = 0;
    rep(i,1,N+1){
        rep(j,0,M){
            if(i - cnt[A[j]] >= 0){
                dp[i] = max(dp[i], dp[i - cnt[A[j]]] + 1);
            }
        }
    }
    // printa(dp, N+1);
    string ans = "";
    ll tt = N;
    rep(i,0,dp[N]){
        // print(tt);
        rep(j,0,M){
            ll num = lp[j].first;
            ll v = lp[j].second;
            // print(v);
            if(i == dp[N]-1){
                if(tt == v){
                    ans += to_string(num);
                    break;
                }
            }else if(dp[tt - v] + 1 == dp[tt]){
                tt -= v;
                ans += to_string(num);
                // print(ans);
                break;
            }
        }
    }
    print(ans);

}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int dx[4] = {1, 0};
int dy[4] = {0, 1};

int main() {
  int h, w, cnt = 0;
  cin >> h >> w;
  char c;
  rep(i, h) rep(j, w) {
    cin >> c;
    if (c == '#') cnt++;
  }
  cout << (cnt == h + w - 1 ? "Possible" : "Impossible") << endl;
  return 0;
}


Measured memory_bytes: 256
/*************************
author : coldbeer
2019-05-26 06:57:38 PM IST
*************************/
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"

typedef long long ll;
vector<ll> arr;
ll n,k;
ll cache[51][51][1000];

ll solve(ll i,ll j,ll step = 0){
	if(step >= k)
		return 0;
	if(i > j)
		return 0;
	if(cache[i][j][step] != -1)
		return cache[i][j][step];
	cache[i][j][step] = max({cache[i][j][step],arr[i] + solve(i + 1,j,step + 1),arr[j] + solve(i,j - 1,step + 1),solve(i + 1,j - 1,step + 4),solve(i + 1,j,step + 2),solve(i,j - 1,step + 2)});
	return cache[i][j][step];
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> k;
	arr.assign(n,0);
	for(int i = 0;i < n;i++) cin >> arr[i];
	memset(cache,-1,sizeof(cache));
	cout << solve(0,n - 1,0) << endl;
	return 0;
}


Measured memory_bytes: 20608
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _0025
{
    class Program
    {
        static void Main(string[] args)
        {
            string cardsA = "";
            while ((cardsA = Console.ReadLine()) != null)
            {
                string[] numA = cardsA.Split(' ');
                string[] numB = Console.ReadLine().Split(' ');
                int hitCount = 0;
                for (int i = 0; i < 4; ++i)
                {
                    if (numA[i] == numB[i])
                    {
                        ++hitCount;
                    }
                }
                int blowCount = 0;
                for (int a = 0; a < 4; ++a)
                {
                    for (int b = 0; b < 4; ++b)
                    {
                        if (numA[a] == numB[b] && a != b)
                        {
                            ++blowCount;
                        }
                    }
                }
                Console.WriteLine(hitCount + " " + blowCount);
            }
        }
    }
}



Measured memory_bytes: 15884
#include <bits/stdc++.h>

using namespace std;

const int MX = 200000, md = 1000000007;

int c[MX], f[MX], g[MX];

int main() {
	int n;
	ignore = scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		ignore = scanf("%d", c + i);
		c[i]--;
	}
	
	g[c[0]]++;
	for (int i = 0; i < n; i++) {
		f[i] = g[c[i]];
		if (i + 1 < n && c[i] != c[i + 1]) {
			g[c[i + 1]] += f[i];
			g[c[i + 1]] %= md;
		}
	}
	
	printf("%d\n", f[n - 1]);
	
	return 0;
}


Measured memory_bytes: 3068
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define FOR(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
const long long dx[4]={1,0,-1,0};
const long long dy[4]={0,1,0,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int n; cin >> n;
    rep(i,100000){
        if(i*1000>=n){
            cout<<i*1000-n<<endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;


int main() {
    int n;
    string s,t;
    cin >> n >> s >> t;
    vector <char> ans;
    for(int i = 0; i < n; i++){
        ans.push_back(s.at(i));
        ans.push_back(t.at(i));
    }
    for(int i = 0; i < n*2; i++){
        cout << ans.at(i);
    }

}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <fstream>
#include <vector>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <list>
#include <bitset>

using namespace std;
typedef long long ll;

// #define DEBUG

class Unionfind
{
    vector<int> p;

public:
    Unionfind(int n);
    int find(int x);
    void unite(int x, int y);
    bool match(int x, int y);
};

Unionfind::Unionfind(int n)
{
    for (int i = 0; i < n; i++)
    {
        p.push_back(i);
    }
}

int Unionfind::find(int x)
{
    while (p[x] != x)
    {
        p[x] = p[p[x]];
        x = p[x];
    }
    return x;
}

bool Unionfind::match(int x, int y)
{
    return (find(x) == find(y)) ? true : false;
}

void Unionfind::unite(int x, int y)
{
    x = Unionfind::find(x);
    y = Unionfind::find(y);
    if (x != y)
    {
        p[x] = y;
    }
}

int main()
{
#ifdef DEBUG
    cout << "DEBUG MODE" << endl;
    ifstream in("input.txt"); //for debug
    cin.rdbuf(in.rdbuf());    //for debug
#endif
    int n, x, t;
cin >> n;
    for (int i = 0; i < pow(2, n); i++){
        cout << i << ":";
        x = i;
        t = 0;
        while (x > 0){
            if (x % 2 == 1)
                cout << " " << t;
            x /= 2;
            t++;
        }
        cout << endl;
    }

    return 0;
}

// getline(cin,s);
// a = strtok(s, ",");  ","で分解
// for (int i = 0; i < n; i++)


Measured memory_bytes: 3292
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
   int n, m, x; cin >> n >> m >> x;
   vector<int >cost(n);
   vector<vector<int>>v(n, vector<int>(m));
   for (int i = 0; i < n; i++)
   {
       cin >> cost[i];
       for (int j = 0; j < m; j++)
       {
           cin >> v[i][j];
       }
   }int ans = 1e9;
   for (int mask = 0; mask < (1 << n); mask++)
   {
       int cur = 0;
       vector<int>sk(m);
       for (int i = 0; i < n; i++)
       {
           if ((mask >> i) & 1)
           {
               cur += cost[i];
               for (int j = 0; j < m; j++)
               {
                   sk[j] += v[i][j];
               }
           }
       }
       int f = 1;
       for (int i = 0; i < m; i++)
       {
           if (sk[i] < x)
           {
               f = 0; break;
           }
       }
       if (f) {
           ans = min(ans, cur);
       }
       
   }if (ans == 1e9)cout << -1 << endl;
   else cout << ans << endl;

}

Measured memory_bytes: 3608
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	static class Pair implements Comparable<Pair> {
		long a, b;

		public Pair(long a, long b) {
			this.a = a;
			this.b = b;
		}

		public int compareTo(Pair p) {
			if (a > p.a)
				return 1;
			else if (a < p.a)
				return -1;
			else
				return 0;
		}
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int m = Integer.parseInt(sc.next());
		long[] a = new long[n];
		long[] b = new long[n];

		Pair[] p = new Pair[n];
		for (int i = 0; i < n; i++) {
			a[i] = Long.parseLong(sc.next());
			b[i] = Long.parseLong(sc.next());
			p[i] = new Pair(a[i], b[i]);
		}

		Arrays.sort(p);

		long ans = 0;
		long sum = 0;

		for (int i = 0; i < n; i++) {

			if (sum + p[i].b >= m) {
				ans += p[i].a * (m - sum);
				break;
			} else {
				ans += p[i].a * p[i].b;
				sum += p[i].b;
			}
		}

		System.out.println(ans);

	}

}


Measured memory_bytes: 67328
#include <bits/stdc++.h>
#include<list>
#include<algorithm>
#define ll long long int
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define rep(a,b,c) for(a=b;a<c;a++)
#define repr for(i=n-1;i>=0;i--)
#define pll pair<ll, ll>
#define inf 100000001
#define mod 1000000007
#define lb lower_bound
#define up upper_bound
#define rep1 for(i=1;i<=n;i++)
#define vr vector
#define ef else if
#define all(x) (x).begin(), (x).end()
#define SORT(A) sort(A.begin(), A.end());
#define REVERSE(A) reverse(A.begin(), A.end());
#define MAX LLONG_MIN
#define MIN LLONG_MIN
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
ll myXOR(unsigned long long int x, unsigned long long int y)
{
    return (x|y)&(~x|~y);   
}
ll powerLL(ll x, ll n) 
{ 
    ll result = 1; 
    while (n) { 
        if (n & 1) 
            result = result * x % mod; 
        n = n / 2; 
        x = x * x % mod; 
    }
    return result; 
}
int main()
{
    // fastio
    ll a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r, t,u,w,x,y,z;
    string str, s, ss, str1;
    cin>>n;
   	map<ll,ll>mp;
    rep(i,0,n-1)
    {
    	cin>>a;
    	mp[a]++;
    }
    rep(i,1,n+1)
    {
    	cout<<mp[i]<<endl;
    }
}

Measured memory_bytes: 16096
'use strict';
(function(input){
  input=input.trim().split(/\s+/).map(x=>x-0);
  const N=Math.min(input[0],input[1]);
  const M=Math.max(input[0],input[1]);
  const K=input[2];
  const E=1e9+7;
  
  function check(num){
    if(!Number.isSafeInteger(num)){
      console.log(num,'overFlow!');
    }
  }
  
  function multiply(a,b){
    var A=[(a-a%100000)/100000,a%100000];
    A[0]=(((A[0]*b)%E)*100000)%E;
    A[1]=(A[1]*b)%E
    return Math.round((((A[0]+A[1])%E)+E)%E);
  }
  
  var ans=0;
  
  for(let d=1;d<=N-1;d++){
    let A=(1/6)*(d+1)*(d+2)*(d+3);
    let B=((N-d-1)+(M-d-1))*(1/2)*(d+1)*(d+2);
    let C=(N-d-1)*(M-d-1)*(d+1);
    let D=(N-d)*M+(M-d)*N;
    A%=E;
    B%=E;
    C%=E;
    D%=E;
    ans+=multiply(((A+B+C)*2-D),d);
    //check(ans);
    ans=((ans%E)+E)%E;
  }
  
  for(let d=N;d<=M-1;d++){
    let A=(1/6)*(N)*(N+1)*(N+2);
    let B=(M-d-1)*(1/2)*(N)*(N+1);
    let C=0;
    let D=(M-d)*N;
    A%=E;
    B%=E;
    C%=E;
    D%=E;
    ans+=multiply(((A+B+C)*2-D),d);
    check(ans);
    ans=((ans%E)+E)%E;
  }
  
  for(let d=M;d<=N+M-2;d++){
    let a=N+M-1-d;
    let A=(1/6)*(a)*(a+1)*(a+2);
    let B=0;
    let C=0;
    let D=0;
    A%=E;
    B%=E;
    C%=E;
    D%=E;
    ans+=multiply(((A+B+C)*2-D),d);
    ans=((ans%E)+E)%E;
  }
  //console.log(ans);
  
  //ansに(N*M-2)C(K-2)をかける↓
  for(let i=0;i<K-2;i++){//まず分子のかけ算
    ans=multiply(ans,(N*M-2-i));
  }
  //console.log(ans);
  
  var denominator=1;
  for(let i=1;i<=K-2;i++){
    denominator=multiply(denominator,i);
  }
  //合同式でansをdenominatorで割る(ユークリッドの互除法の応用)↓
  const r=[E,denominator];
  //console.log(r);
  while(r[r.length-1]!==0){
    let A=r[r.length-2],B=r[r.length-1];
    let R=A%B;
    r.push(R);
  }
  r.pop();
  //console.log(r);
  const x=[1],y=[0];
  while(r.length>2){
    let q=(r[r.length-3]-r[r.length-1])/r[r.length-2];
    
    //r[-3]-q*r[-2]=r[-1]を1=x*r[-1]+y*r[-2]に代入。
    //1=x*(r[-3]-q*r[-2])+y*r[-2]=(y-qx)*r[-2]+x*r[-3];
    x.push((((y[y.length-1]-q*x[x.length-1])%E)+E)%E);
    y.push(x[x.length-2]);
    r.pop();
  }
  //console.log(x,y);
  const F=((x[x.length-1])%E+E)%E;
  //Fはdenominator*F+整数*E=1の解、すなわちmod.Eの世界でのdenominatorの「逆数」
  //2^53以内に計算を抑えるために10^5で割った商と余りに分けて計算
  ans=multiply(ans,F);
  console.log(ans);
})(require('fs').readFileSync('/dev/stdin','utf8'));

Measured memory_bytes: 10184
#include<stdio.h>
#include<climits>
#include<iostream>
#define FOR(i,ii,n) for(int i=ii; i<n; i++)

using namespace std;

long A[2000];
long Amin[2000][2000];
int main(){
	long N,x;
	scanf("%ld",&N);
	scanf("%ld",&x);
	FOR(i,0,N){
		scanf("%ld",&A[i]);
	}
	FOR(j,0,N){
		Amin[0][j] = A[j];
	}
	FOR(i,1,N){
		FOR(j,0,N){
			Amin[i][j] = Amin[i-1][j] < A[(j-i+N)%N] ? Amin[i-1][j] : A[(j-i+N)%N];
		}
	}
	long min=0;
	FOR(j,0,N){
		min += A[j];
	}
	FOR(i,1,N){
		long tmpmin = 0;
		FOR(j,0,N){
			tmpmin += Amin[i][j];
		}
		tmpmin += i*x;
		if(min > tmpmin)
			min = tmpmin;
	}
	cout << min;
}


Measured memory_bytes: 31488
#include<iostream>
#include<vector>
using namespace std;

int h, w;

int main(){
    cin >> h >> w;
    vector< vector<char> > m(h, vector<char>(w, 'a'));
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> m[i][j];
        }
    }
    for (int i = 0; i < h; i++)
    {
        bool f = true;
        for (int j = 0; j < w; j++)
        {
            if(m[i][j] == '#'){
                f = false;
                break;
            }
        }
        if(f){
            for (int j = 0; j < w; j++)
            {
                m[i][j] = 'a';
            }
        }
    }
    for (int i = 0; i < w; i++)
    {
        bool f = true;
        for (int j = 0; j < h; j++)
        {
            if (m[j][i] == '#')
            {
                f = false;
                break;
            }
        }
        if (f)
        {
            for (int j = 0; j < h; j++)
            {
                m[j][i] = 'a';
            }
        }
    }
    for (int i = 0; i < h; i++)
    {
        bool f = false;
        for (int j = 0; j < w; j++)
        {
            if(m[i][j] != 'a'){
                cout << m[i][j];
                f = true;
            }
        }
        if(f) cout << endl;
    }
    return 0;
}

Measured memory_bytes: 888
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
#include <vector>
#include <limits.h>
const long long INF = LLONG_MAX / 2;
#define FOR(i, r, n) for(int i=(r); i<(n); i++) 
#define REP(i, n) FOR(i, (0), n)
#define ll long long int
template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
	vector.erase(vector.begin() + index);
}

using namespace std;
ll ans = 0, sum = 0, n, k, t;
string s;

vector<ll> v;

int main() {
	cin >> n;
	v.resize(n);
	REP(i, n) {
		cin >> v[i];
		sum += v[i];
	}
	sum = sum * 10 / n;
	ll mod = sum % 10;
	ll ave = mod >= 5 ? sum / 10 + 1 : sum / 10;
	REP(i, n) {
		ans += abs(ave - v[i])*abs(ave - v[i]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
from collections import Counter

N = int(input())
D = list(map(int, input().split()))
M = int(input())
T = list(map(int, input().split()))

Dc = Counter(D)
Tc = Counter(T)

for k, v in Tc.items():
    if Dc[k] < v:
        print("NO")
        break
else:
    print("YES")

Measured memory_bytes: 57128
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;

int main(void) {
    ll n,m;
    cin>>n>>m;
    vector<pair<int,int> > targets[n];
    ll d[n];
    bool negflg[n]={};
    d[0]=0;
    rep(i,n-1){d[i+1]=1LL<<60;}
    rep(i,m){
        int ta,tt,tc;
        cin>>ta>>tt>>tc;
        ta--;tt--;
        targets[ta].push_back(make_pair(tt,-tc));
    }
    rep(i,n){
        rep(j,n){
            for(auto x:targets[j]){
                if(d[x.first] > d[j] + x.second){
                    d[x.first] = d[j] + x.second;
                    if(i==n-1){
                        negflg[x.first]=true;
                    }
                }
            }
        }
    }
    queue<int> neg;
    rep(i,n){if(negflg[i])neg.push(i);}
    while(!neg.empty()){
        int cur=neg.front();
        neg.pop();
        for(auto x:targets[cur]){
            if(!negflg[x.first]){
                negflg[x.first]=true;
                neg.push(x.first);
            }
        }
    }
    cout << (negflg[n-1] ? "inf" : to_string(-d[n-1])) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

int main(){
	ll K, A, B;
	cin >> K >> A >> B;
	if(B<=A+2){
		cout << 1 + K << endl;
		return 0;
	}
	ll now = 1;
	ll en = 0;
	REP(i, K){
		if(en>0){
			now += B;
			en -= 1;
		}
		else if(now>=A && i<K-1){
			now -= A;
			en += 1;
		}else{
			now++;
		}
	}
	cout << now << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define MAX 100
#define MIN 0
int GetNumEqual( int *pNum );
void Compare3Num( int numA, int numB, int getNumC );

int main( void )
{
    int getNumA , getNumB, getNumC;
    
    if( 0 == GetNumEqual( &getNumA ) )
    {
        if( 0 == GetNumEqual( &getNumB ) )
        {
            if( 0 == GetNumEqual( &getNumC ) )
            {
                Compare3Num( getNumA , getNumB, getNumC );
            }
        }
    }
    return 0;
}

int GetNumEqual( int *pNum )
{
    int getNum;
    
    scanf( "%d" , &getNum );
    
    if( ( getNum >= MIN ) && ( getNum <= MAX ) )
    {
        *pNum = getNum;
        return 0;
    }
    
    return -1;
}

void Compare3Num( int numA, int numB, int numC )
{
    if( numA < numB )
    {
        if( numB < numC )
        {
            printf( "Yes\n" );
            return;
        }
    }
    printf( "No\n" );
}

Measured memory_bytes: 1808
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	void run() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int count = 0;
		for(int i = 0; i < n; i++) {
			int a = sc.nextInt();
			boolean b = isPrime(a);	
			if(b == true) {
				count++;
			}
		}
		System.out.println(count);
		
				
		sc.close();
	}
	
	boolean isPrime(int x) {
		if(x == 2) return true;
		else if(x < 2 || x % 2 == 0) return false;
		else {
			for(int i = 3; i <= Math.sqrt(x); i += 2) {
				if(x%i==0) {
					return false;
				}
			}
			return true;
		}
	}

	void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().run();
	}
}


Measured memory_bytes: 41116
import sys
input=lambda: sys.stdin.readline().rstrip()
n,k=map(int,input().split())
mod=10**9+7
A=[0]*(k+1)
for i in range(1,k+1)[::-1]:
  cur=pow(k//i,n,mod)
  for j in range(2,k+1):
    if i*j>k:
      break
    else:
      cur-=A[i*j]
  A[i]=cur
ans=0
for i in range(1,k+1):
  ans=(ans+i*A[i])%mod
print(ans)


Measured memory_bytes: 11300
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args)
	{
		Scanner s=new Scanner(System.in);
		
		double d=s.nextDouble();
		double t=s.nextDouble();
		double ss=s.nextDouble();
		
		if(d/ss<=t)
		{
			System.out.println("Yes");
		}
		else
		{
			System.out.println("No");
		}
		
	}
	
}

Measured memory_bytes: 37200
#include <bits/stdc++.h>
using namespace std;

#define LL long long
#define hell 1000000007
#define PI acos(-1.0)



int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout << fixed << showpoint;
cout << setprecision(11);

int n, x;cin>>x>>n;
int ar[n];for(int i=0;i<n;i++) cin>>ar[i];
sort(ar, ar+n);
int ans;
int i=0;
while(1)
{
  
  if(!binary_search(ar, ar+n, x-i)){
    ans = x-i;break;
  } 
  else if(!binary_search(ar, ar+n, x+i)){
    ans = x+i;break;
  }
  i++;
}
cout<<ans;

return 0;
} 

Measured memory_bytes: 3588
#include<iostream>
#include<cmath>
using namespace std;
int x,y,z;
int e;
int solve(){
	int minnum = 1000000;
	for(int z = 0; pow(z, 3) <= e; z++)
	{
		y = (int)sqrt(e - pow(z, 3));
		minnum = min(minnum,(int)(e - pow(z, 3)-pow(y, 2))+y+z); 
	}
	return minnum;
};
int main(){
	int A[100000];
    int k = 0;
	while( cin>>e && e>0 )
	{
		A[k]=solve();
        k++;
	}
	for(int l = 0;l < k; l++)
    {
        cout<<A[l]<<endl;
    }
	return 0;
}

Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
	long long n,ans=0;
	cin>>n;
	int c[n][n];
	for (int i = 0; i < n; ++i) for (int j = 0; j < n; ++j) cin>>c[i][j];
	for (int i = 0; i < n; ++i) for (int j = i+1; j < n; ++j) ans+=min(c[i][j],c[j][i]);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3124
x = int(input())
if x >= 400 and x <= 599:
  print('8')
elif x >= 600 and x <= 799:
  print('7')
elif x >= 800 and x <= 999:
  print('6')
elif x >= 1000 and x <= 1199:
  print('5')
elif x >= 1200 and x <= 1399:
  print('4')
elif x >= 1400 and x <= 1599:
  print('3')
elif x >= 1600 and x <=1799:
  print('2')
else:
  print('1')

Measured memory_bytes: 9180
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define all(x) x.begin(),x.end()
#define LOL cout<<'\n';
#define MOD 1000000007
#define sz(x) ((int)x.size())
#define INF LONG_LONG_MAX
#define NINF LONG_LONG_MIN

void solve(){
	int n,k; cin>>n>>k;
	int a[n];
	for(int i=0 ; i<n ; i++) cin>>a[i];
	int s=0;
	int next=k;
	int loop=n-k;
	while(loop>0){
        //cout<<a[next]<<' '<<a[s];LOL
		if(a[next]>a[s]){
			cout<<"Yes";
		}
		else{
			cout<<"No";
		}
        next++,s++;
		LOL
		loop--;
	}
	
}

signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  int _=1;// cin>>_;
  for(int i=1 ; i<=_ ; i++){
		//cout<<"Case #"<<i<<": ";
		solve();
	}
  return 0;
}

Measured memory_bytes: 5220
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int d=sc.nextInt();
		
		int x[][] = new int[n][d];
		
		for(int i=0;i<n;i++) {
			for(int j=0;j<d;j++) {
				x[i][j]=sc.nextInt();
			}
		}
		
		int ichiji = 0;
		int count = 0;
		
		for(int i=0;i<n;i++) {
			for(int j=i+1;j<n;j++) {
				ichiji = 0;
				for(int k=0;k<d;k++) {
					ichiji+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
				}
				if(isheiho(ichiji))
					count++;
			}
		}
		
		System.out.print(count);
		
	}
	
	public static boolean isheiho(int k) {
		int i=0;
		while(i*i<=k) {
			if(i*i==k)
				return true;
			else
				i++;
		}
		return false;
	}

}

Measured memory_bytes: 21844