akhauriyash/Code-Regression huggingface dataset:
import itertools

N, M, Q = map(int, input().split())
x1 = [0]*Q
x2 = [0]*Q
x3 = [0]*Q
x4 = [0]*Q

for i in range(Q):
    x1[i], x2[i], x3[i], x4[i] = map(int, input().split())
score = 0
tmp = 0
lis = range(1, M+1)
A = []

for i in itertools.combinations_with_replacement(lis, N):
    A.append(list(i))

for i in range(len(A)):
  for j in range(Q):
    if(A[i][x2[j]-1] - A[i][x1[j]-1] == x3[j]): tmp += x4[j]
  if(tmp>=score): score = tmp
  tmp = 0

print(score)


Measured memory_bytes: 23064
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("inline")
//#pragma GCC optimize("-ffast-math")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("inline-small-functions")
//#pragma GCC optimize("-finline-small-functions")
//#pragma GCC optimize("-fexpensive-optimizations")
//#pragma GCC optimize("-funsafe-loop-optimizations")
//#pragma GCC optimize("inline-functions-called-once")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
using namespace std;
using ll = long long;
using vi = vector<ll>;
using pi = pair<ll, ll>;
using vpi = vector<pi>;
using oset = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;
const int maxn = 2e5 + 33, mod = 1e9 + 7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, m, p = 0, c = 0;
    cin >> n >> m;
    map<int, int>  q, z;
    for(int i =0; i <m ;i++) {
    	int x;
    	string t;
    	cin >> x >> t;
    	if(t=="WA") {
    		if(!q[x]) z[x]++;
    	} else if(!q[x])
    		q[x] = 1, c++, p += z[x];
    }

    cout << c << " " << p;
}


Measured memory_bytes: 9600
n, m = map(int, raw_input().split())
a = []
c = []
for i in range(n):
	a.append(map(int, raw_input().split()))
for j in range(m):
	c.append(map(int, raw_input().split()))

for i in range(n):
	dist0 = 999999999
	j0 = 999
	for j in range(m):
		dist = abs(a[i][0]-c[j][0]) + abs(a[i][1]-c[j][1])
		if dist < dist0:
			dist0 = dist
			j0 = j
	print j0 + 1

Measured memory_bytes: 2692
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int64_t i = 0; i < n; ++i)
using namespace std;

int main() {
  string s;
  cin >> s;
  int a;
  rep(i, (s.size()-1) / 2){
    bool b = 1;
    rep(j, i+1){
      if(s[j] != s[i+1+j]){
        b = 0;
        break;
      }
    }
    if(b) a = (i+1) * 2;
  }
  cout << a << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <cstdio>
using namespace std;
int x, c=0;
void dfs(int pos) {
	if (pos == 1) {
		c++;
		return;
	}else if (pos == 2) {
		c = c + 2;
		return;
	}
	else if (pos == 3) {
		c = c + 4;
		return;
	}
	else {
		dfs(pos - 1);
		dfs(pos - 2);
		dfs(pos - 3);
	}


}

int main() {
	while (1) {
	int	days = 0, years = 0;
	c = 0;
	cin >> x;
	if (x == 0) {
		break;
	}
	dfs(x);
	days = c / 10;
	if (c % 10 != 0) {
		days++;
	}
	years = days / 365;
	if (days % 365 != 0) {
		years++;
	}
	cout << years << endl;
	}
	

}

Measured memory_bytes: 3008
def main():
    k = int(input())

    n = 50
    a = [None for _ in range(n)]
    for i in range(n):
        a[i] = i + (k + i) // n

    print(n)
    print(' '.join([str(x) for x in a]))

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<cstring>
using namespace std;
 
int main(){
	int n,tot = 0; 
	int l,r;
	scanf("%d",&n);
	for(int i = 0; i < n; i ++)
	{
		scanf("%d%d",&l,&r);
		tot += (r-l+1);
	}
	printf("%d",tot);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[2]={-1,-1};
	for(int i=0;i<n;i++){
		int b,c;
		cin>>b>>c;
		if(c==a[1])
			a[0]=min(a[0],b);
		if(c>a[1]){
			a[0]=b;
			a[1]=c;
		}
	}
	cout<<a[0]<<" "<<a[1]<<endl;
}

Measured memory_bytes: 3080
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define ll long long
using namespace std;
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') {x = (x << 3) + (x << 1) + (ch ^ 48); ch = getchar();}
	return x * f;
}
const int N = 5100;
ll n,l,r,f[N],a[N];
int main()
{
	memset(f,0x3f,sizeof(f)); cin >> n >> r >> l;
	for(int i = 1;i <= n;i ++) a[i] = read() + 1;
	a[0] = 1; f[0] = 0; a[n + 1] = n + 2;
	for(int i = 1;i <= n + 1;i ++)
	{
		ll sr = 0,sl = 0;
		for(int j = i - 1;j >= 0;j --)
		{
			if(a[j] < a[i]) f[i] = min(f[i],f[j] + r * sr + l * sl);
			if(a[j] > a[i]) sr ++; else sl ++;
		}
	}
	cout << f[n + 1] << "\n";
	return 0;
}


Measured memory_bytes: 384
n, m = map(int, input().split())

def cumXOR(k):
    if k % 4 == 0:
        return k
    elif k % 4 == 1:
        return 1
    elif k % 4 == 2:
        return k + 1
    else:
        return 0

print(cumXOR(n-1)^cumXOR(m))


Measured memory_bytes: 2940
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N=in(),D=in();
	
	cout << (ceil((double)N/(2*D+1))) << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl "\n"
#define int long long
#define vi vector<int> 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define B begin()
#define E end()
 
 
int32_t main()
{
IOS;
int n;
cin >> n;
int a[n+1];
a[0]=100000;
for(int i=1;i<=n;i++)
{
    cin >> a[i];
}
int i=n,dp[n+1];
dp[0]=100000;
dp[1]=0;


for(int i=2;i<=n;i++)
{ 
  dp[i]=min(abs(a[i]-a[i-1])+dp[i-1],abs(a[i]-a[i-2])+dp[i-2]);
}
cout << dp[n] << endl;







return 0;
}

Measured memory_bytes: 5212
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <set>

using namespace std;

typedef pair<int, int> P;

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	P p;
	p.first = a[0];
	p.second = 1;
	int k = 0;
	int kk = 0;
	for (int i = 1; i < n; i++) {
		if (a[i] == p.first) {
			p.second++;
		} else {
			p.second %= 2;
			if (p.second == 0) {
				kk++;
			} else {
				k++;
			}
			p.first = a[i];
			p.second = 1;
		}
	}
	p.second %= 2;
	if (p.second == 0) {
		kk++;
	} else {
		k++;
	}
	k += kk;
	if (kk % 2 == 1) {
		k--;
	}
	cout << k << endl;
	return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int before=-1;
		int get;
		boolean isStraight = false;
		String str = "";
		while(n!=0){
			for(int i=0;i<n;i++){
				get = sc.nextInt();
				if(get-before!=1){
					if(before==-1){
						str += String.valueOf(get);
					} else if(isStraight){
						str += "-"+String.valueOf(before)+" "+String.valueOf(get);

					} else {
						str += " "+String.valueOf(get);
					}
					isStraight = false;
				} else {
					if(i==n-1){
						str += "-"+String.valueOf(get);
					}
					isStraight = true;
				}
				before = get;
			}
			System.out.println(str);
			n = sc.nextInt();
			str = "";
			before = -1;
		}
	}

}

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

int main(){
  int64_t N;
  cin >> N;
  string s=to_string(N);
  if(s.size()==1){
    cout << N << endl;
    return 0;
  }
  s=string(s.size()-1,'9');
  for(int i=9;i>=0;i--){
    if(stoll((char)(i+'0')+s)<=N){
      cout << s.size()*9+i << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define to_s to_string
#define len(v) (int)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
ll MOD = 1e9 + 7;
ll devc(ll x, ll y) { return 1 + (x - 1) / y; }

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);

    ll N, A, B;
    cin >> N >> A >> B;

    print((N / (A + B)) * A + min(N % (A + B), A));

    return 0;
}

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

int main() {
  int N, Y;
  cin >> N >> Y;

  if (Y > 20000000 || Y < 1000 || (Y % 1000) != 0) {
    cout << "-1 -1 -1";
    return 0;
  }

  int x = 0, y = 0, z = 0;

  for (x = 0; x < N + 1; x++) {
    for (y = 0; y < N + 1; y++) {
      int z = N - x - y;
        if (10000 * x + 5000 * y + 1000 * z == Y && z >= 0) {
          cout << x << " " << y << " " << z << endl;
          return 0;

      }
    }
  }

  cout << "-1 -1 -1";
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	int n;
	cin >> n;
	if (n == 1) {
		cout << "Hello World" << "\n";
	}
	else {
		int a, b;
		cin >> a >> b;
		cout << a + b << "\n";
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int mod=1e9+7;
const int INF=1001001001;

int main() {
  string s,t;
  cin>>s>>t;
  int S=s.size(),T=t.size();
  int MIN=INF;
  for(int i=0;i<=S-T;i++){
    int cnt=0;
    for(int j=0;j<T;j++){
      if(s[i+j]!=t[j]){
        cnt++;
      }
    }
    chmin(MIN,cnt);
  }
  cout<<MIN<<endl;
  return 0;  
}

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

using namespace std;

int main()
{
    int a, b, c;
    while(cin>>a>>b>>c)
    {
        if(a<b && a<c)
        {
            if(b<c)
               printf("%d %d %d\n", a, b, c);
            else
                printf("%d %d %d\n", a, c, b);
        }
        else if(b<a && b<c)
        {
            if(a<c)
                printf("%d %d %d\n", b, a, c);
            else
                printf("%d %d %d\n", b, c, a);
        }
        else
        {
            if(a<b)
                printf("%d %d %d\n", c, a, b);
            else
                printf("%d %d %d\n", c, b, a);
        }
    }
    return 0;
}





Measured memory_bytes: 3188
#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
#include<stack>
#include<cmath>
#include<algorithm>
#include<map>
typedef long long ll;
using namespace std;
#define INF 0x3f3f3f3f
int main()
{
	int n,i,j,t;
	string a,s;
	a="hi";
	cin>>s;
	if(s==a||s==a+a||s==a+a+a||s==a+a+a+a||s==a+a+a+a+a)
	cout<<"Yes";
	else cout<<"No";
 } 

Measured memory_bytes: 256
#include<stdio.h>
	#include<string.h>
	int main(){
	char a[100000]={0};
	int num=0,i,n;
  scanf("%s",a);
	for(i=0;i<strlen(a)-1;i++){
		if(a[i]!=a[i+1])
			num++;
	}
	printf("%d",num);
	return 0;
}

Measured memory_bytes: 256
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True  and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n,p = inm()
acc = [0]*(n+1)
a = [0]*(n+1)
ss = ins()
s = ss[::-1]
if p in [2,5]:
    x = 0
    for i in range(n):
        if int(s[i])%p==0:
            x += n-i
    print(x)
    exit()

q = 1
for i in range(n):
    x = int(s[i])
    r = q*x
    acc[i+1] = (acc[i]+r)%p
    #ddprint(f"i {i} x {x} r {r} q {q} ai {acc[i+1]}")
    q = (q*10)%p
ddprint(acc)
h = [0]*p
for i in range(n+1):
    h[acc[i]] += 1
ddprint(h)
sm = 0
for i in range(p):
    x = h[i]
    sm = (sm+x*(x-1)//2)
print(sm)


Measured memory_bytes: 45132
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const double PI = acos(-1);
const ll MOD = 1000000007;
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 Graph = vector<vector<int>>;

const vector<int> dy = {-1,0,0,1};
const vector<int> dx = {0,-1,1,0};

Graph G;
int play;

void dfs(int n, int y, int x) {
    if (n == 10) return;
    rep(i,4) {
        int yy = y + dy[i];
        int xx = x + dx[i];
        if (G[yy][xx] == 1) continue;
        while (G[yy][xx] == 0) {
            yy += dy[i];
            xx += dx[i];
        }
        if (G[yy][xx] == 3) {
            chmin(play,n+1);
            return;
        }
        if (G[yy][xx] == 9) continue;
        G[yy][xx] = 0;
        dfs(n+1,yy - dy[i], xx - dx[i]);
        G[yy][xx] = 1;
    }
    return;
}

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr); //入出力高速化
    while (true) {
        int H,W; cin >> W >> H;
        if (W == 0 && H == 0) break;
        G.assign(H+2, vector<int>(W+2,9));
        rep(i,H) rep(j,W) cin >> G[i+1][j+1];

        play = INF;
        int sy,sx;
        rep(i,H) {
            rep(j,W) {
                if (G[i+1][j+1] == 2) {
                    sy = i+1;
                    sx = j+1;
                    G[i+1][j+1] = 0;
                }
            }
        }
        dfs(0,sy,sx);
        if (play == INF) cout << -1 << endl;
        else cout << play << endl;
    }
}


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

using namespace std;

typedef long long ll;

#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x
#define bit(n) (1<<(n))

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

int main(){
	int a,b;
	cin>>a>>b;
	cout<<(a>12?b:(a>5?b/2:0))<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;

int main(){
	string S, T;
	cin >> S >> T;
	int count=0;
	rep(i, 3) {
		if (S.at(i) == T.at(i))++count;
	}
	cout << count << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	static boolean[] vis = new boolean[60];

    public static void main(String[] args) throws Exception {

    	Scanner sc = new Scanner(System.in);
    	int N = sc.nextInt();
    	int sum = 0;
    	int[] ary = new int[N];
    	for(int i = 0; i < N; i++){
    		ary[i] = sc.nextInt();
    	}
    	sc.close();
    	int id = 0;
    	int max = ary[0];
    	for(int i = 0; i < N; i++){
    		if(ary[i] > max){
    			max = ary[i];
    			id = i;
    		}
    	}
    	for(int i = 0; i < N; i++){
    		if(i == id){
    			sum += ary[i] / 2;
    		}else{
    			sum += ary[i];
    		}
    	}
    	System.out.println(sum);
    }
}


Measured memory_bytes: 21716
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define PB push_back
#define MP make_pair
#define FST first
#define SND second
#define SZ(a) (signed)((a).size())
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

const int MOD = 1000000007;

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

signed main(void) {
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed, ios::floatfield);
    cout.precision(10);
    cin.tie(0);

    int n,m;
    cin >> n >> m;
    VI x(n);
    REP(i,n){
        cin >> x[i];
    }

    int maxx = *max_element(ALL(x));
    VI xl(maxx+1,0);
    VI xm(m,0);
    VI xmp(m,0);
    VI xml(m,0);
    REP(i,n){
        xl[x[i]]++;
        xm[x[i]%m]++;
    }

    FOR(i,1,maxx+1){
        xmp[i%m] += xl[i]/2;
        xml[i%m] += xl[i]%2;
    }

    int ans = 0;

    FOR(i,1,(m-1)/2+1){
        int t = min(xm[i],xm[m-i]);
        if(xml[i]<t){
            xmp[i] -= (t-xml[i]+1)/2;
        }
        if(xml[m-i]<t){
            xmp[m-i] -= (t-xml[m-i]+1)/2;
        }
        ans += t;
    }

    ans += xmp[0] + xml[0]/2;
    if(m%2==0){
        ans += xmp[m/2] + xml[m/2]/2;
        FOR(i,1,m){
            if(i!=m/2){
                ans+=xmp[i];
            }
        }
    }else{
        FOR(i,1,m){
            ans+=xmp[i];
        }
    }





    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 4224
import itertools
n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))

a = [i for i in range(1, n+1)]
b = list(itertools.permutations(a, n))
c = []
for i in range(len(b)):
    c.append(list(b[i]))


ans_p = 0
ans_q = 0
for i in range(len(c)):
    if c[i] == p:
        ans_p = i+1
    if c[i] == q:
        ans_q = i+1

print(abs(ans_p-ans_q))

Measured memory_bytes: 15092
#include<algorithm>
#include<iostream>
#include<cstring>
#include<string>
#include<vector>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
const int MAXN=1e5+5;
int read()
{
    int s=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();}
    return s*f;
}
int main()
{
    int n,k;
    while(cin>>n>>k)
    {
        if(n>=10)cout<<k<<endl;
        else {
            cout<<k+(100*(10-n))<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
import heapq
n = int(input())
a_list = [int(input()) for _ in range(n)]
a_list_heap = list(map(lambda x:(-1)*x,a_list))
heapq.heapify(a_list_heap)
max_num = a_list_heap[0]*(-1)

for i in range(len(a_list)):
    if a_list[i] != max_num:
        print(max_num)
    else:
        tmp = heapq.heappop(a_list_heap)
        print(a_list_heap[0]*(-1))
        heapq.heappush(a_list_heap,tmp)

Measured memory_bytes: 20536
#include<bits/stdc++.h>
#include<atcoder/dsu> 

using namespace std;
using namespace atcoder;

int main(){
 
  int n;
  cin>>n;
  
  int q;
  cin>>q;
  dsu d(n);
  while(q--){
   
    int a,b,c;
    cin>>a>>b>>c;
    
    if(a==0){
      d.merge(b,c);
      
    }
    else{
     
      if(d.same(b,c)){
        cout<<1<<endl;
      }
      else cout<<0<<endl;
      
    }
    
  }
  
  
  
}

Measured memory_bytes: 3828
#include <iostream>
#include <array>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <utility>

#include <atcoder/math>

using namespace std;
using namespace atcoder;
#define rep(i,l,r) for(int i = l; i < r; ++i)

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

    rep(i,0,t) {
        int n, m, a, b;
        cin >> n >> m >> a >> b;
        cout << floor_sum(n, m, a, b) << endl;
    }
}


Measured memory_bytes: 3144
#include<cstdio>
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<set>
#include<complex>

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

#define pb push_back

using namespace std;


const int MV = 500;
const int INF = 1000000007;

class edge{
	public:
	int to,cap,cost,rev;
	edge(int to, int cap, int cost, int rev):to(to),cap(cap),cost(cost),rev(rev){}
};

int V;
vector<edge> G[MV];
int dist[MV];
int prevv[MV], preve[MV];

void add_edge(int from, int to, int cap, int cost){
	G[from].push_back(edge(to,cap,cost, G[to].size()));
	G[to].push_back(edge(from,0,-cost,G[from].size()-1));
}

int min_cost_flow(int s, int t, int f){
	int res = 0;
	while(f>0){
		fill(dist,dist+V,INF);
		dist[s]=0;
		bool update = true;
		while(update){
			update=false;
			for(int v=0;v<V;v++){
				if(dist[v]==INF)continue;
				for(int i=0;i<G[v].size();i++){
					edge &e = G[v][i];
					if(e.cap>0 && dist[e.to] > dist[v]+e.cost){
						dist[e.to] = dist[v] + e.cost;
						prevv[e.to] = v;
						preve[e.to] = i;
						update = true;
					}
				}
			}
		}
	
		if(dist[t]==INF){
			return -1;
		}
		
		int d = f;
		for(int v=t; v!=s; v=prevv[v]){
			d = min(d, G[prevv[v]][preve[v]].cap);
			f -= d;
			res += d*dist[t];
			for(int v=t; v!=s; v=prevv[v]){
				edge &e = G[prevv[v]][preve[v]];
				e.cap -= d;
				G[v][e.rev].cap += d;
			}
		}
	}
	return res;
}




const int W = 100;

int n;
int w[W][W];
int e[W][W];

vector<string> board;

bool input(){
	cin>>n;
	rep(i,n)rep(j,n)cin>>w[i][j];
	rep(i,n)rep(j,n)cin>>e[i][j];
	
	board.clear();
	rep(i,n){
		string a;
		cin>>a;
		board.pb(a);
	}
	return true;
}

class P{
	public:
	int i,j;
	string str;
	P(int i,int j,string str):i(i),j(j),str(str){}
};

void solve(){
	rep(i,n){
		rep(j,n){
			int cost = 0;
			rep(k,n){
				if(j==k){
					if(board[i][k]=='o'){}
					else cost += w[i][k];
				}else{
					if(board[i][k]=='o')cost += e[i][k];
				}
			}
			add_edge(i, n+j, 1, cost);
		}
	}
	
	V = 2*n+2;
	int snum = 2*n;
	int tnum = 2*n+1;
	
	rep(i,n){
		add_edge(snum, i, 1, 0);
		add_edge(i+n, tnum, 1, 0);
	}
	
	int ans = min_cost_flow(snum, tnum, n);
	
	
	int hoge[W][W]={0};
	
	rep(i,n){
		rep(j,G[i].size()){
			if(G[i][j].cap==0){
				hoge[i][G[i][j].to-n] = 1;
			}
		}
	}
	
	vector<P> res;
	string wstr = "write";
	string estr = "erase";
	rep(i,n){
		rep(j,n){
			if(hoge[i][j] == 1 && board[i][j]=='.')res.pb(P(i,j,wstr));
			if(hoge[i][j] == 0 && board[i][j]=='o')res.pb(P(i,j,estr));
		}
	}
	
	
	cout<<ans<<endl;
	cout<<res.size()<<endl;
	
	rep(i,res.size()){
		cout<<res[i].i+1<<" "<<res[i].j+1<<" "<<res[i].str<<endl;
	}
}

int main(){
	input();
	solve();
}

Measured memory_bytes: 1896
h,w=map(int,input().split())
alphabets=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]
for i in range(h):
  a=list(input().split())
  for j in range(w):
    if a[j]=="snuke":
      print(alphabets[j]+str(i+1))
      break

Measured memory_bytes: 3064
s = int(input())

l = [s]
N = s
count = 1

while 1:
  count += 1
  if N % 2 == 0:
    N = N // 2
  else:
    N = 3 * N + 1
    
  if N in l:
    print(count)
    break
  else:
    l.append(N)
    

Measured memory_bytes: 2940
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <set>
#include <string>
#include <math.h> //算術演算子
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

int gcd(int a, int b)
{
        return b ? gcd(b, a % b) : a;
}

int main()
{
        //input->compute->output//
        string S;
        cin >> S;
        int cnt = 0;
        for (int i = 0; i < 4; i++)
        {
                for (int j = i + 1; j < 4; j++)
                {
                        if (S[i] == S[j])
                        {
                                cnt++;
                        }
                }
        }
        if (cnt == 2)
        {
                cout << "Yes" << endl;
        }
        else
        {
                cout << "No" << endl;
        }

        return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define FI first.first
#define SE first.second
#define TH second
#define fi first
#define se second
#define th second

using namespace std;

template<typename T>
string to_string(const vector<T>& vc, int w) {
	if(vc.empty()) return "";
	if(w + 1 == vc.size()) return to_string(vc[w]);
	return to_string(vc[w]) + "," + to_string(vc, w + 1);
}

template<typename T>
string to_string(const vector<T>& vc) {
	return "{" + to_string(vc, 0) + "}";
}

void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef DEBUG
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

class DebugStream {}LOG;
template <typename T>DebugStream &operator<<(DebugStream &s, const T&) { return s; }
#ifdef DEBUG
#define LOG clog
#endif

typedef long long ll;
typedef pair<ll, ll> ii;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

const int maxN = 1e5 + 9, maxV = 1e6 + 9, MOD = 1e9 + 7, SQ = 335, lg = 20, bs = 29;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifdef DEBUG
	freopen("input.txt", "r", stdin);
	#endif

	int n;
	cin >> n;
	n %= 10;
	if(n == 3) {
		cout << "bon\n";
	} else if(n <= 1 || n == 6 || n == 8) {
		cout << "pon\n";
	} else {
		cout << "hon\n";
	}
}



Measured memory_bytes: 3656
#include <cstdio>
#include <set>
using namespace std;

int main(){
	multiset<int> S;
	int N, M, D;
	scanf("%d", &N);
	while(N--){
		scanf("%d", &D);
		S.insert(D);
	}
	scanf("%d", &M);
	while(M--){
		scanf("%d", &D);
		if(S.find(D) == S.end()){
			printf("NO\n");
			return 0;
		}
		S.erase(S.find(D));
	}
	printf("YES\n");
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"
#define fcout cout << fixed << setprecision(18)

#define MOD 1000000007 // 1e9+7
#define PI 3.1415926535
/*
3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
*/
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1
#define LINF 1000000000000000001 // 1e18+1

int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
//---------------------------
ll gcd(ll a, ll b)
{
  for (;;)
  {
    if (a == 0) return b;
    b %= a;
    if (b == 0) return a;
    a %= b;
  }
}
ll lcm(ll a, ll b)
{
    ll temp = gcd(a, b);

    return temp ? (a / temp * b) : 0;
}
int main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  ll a,b,gc=0,n,x;cin>>n>>x;
  REP(i,n){
    cin>>a;
    b = x - a;
    if(gc==0){
      gc=b;
    }else{
      gc = gcd(gc, b);
    }
    x = a;
  }
  if(gc<0){
    P(-gc);
  }else{
    P(gc);
  }
  return 0;
}


Measured memory_bytes: 256
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        m: usize,
        a: [usize; n],
    }

    let lcm = a
        .iter()
        .map(|ai| ai / 2)
        .fold(1, |acc, ai| acc * ai / gcd(acc, ai));

    let ans = if a.iter().map(|ai| ai / 2).all(|ai| (lcm / ai) % 2 != 0) {
        ((m / lcm) + 1) / 2
    } else {
        0
    };
    println!("{}", ans);
}

fn gcd(a: usize, b: usize) -> usize {
    if a % b == 0 {
        b
    } else {
        gcd(b, a % b)
    }
}


Measured memory_bytes: 6396
package main

import "fmt"

func divs(n int) []int {
	ans := make([]int, 0)
	for i := 2; i*i <= n; i++ {
		for n%i == 0 {
			ans = append(ans, i)
			n /= i
		}
	}
	if n != 1 {
		ans = append(ans, n)
	}
	return ans
}

func main() {
	var n int
	fmt.Scan(&n)

	l := make([]int, 0)
	for i := 2; i <= n; i++ {
		l = append(l, divs(i)...)
	}

	counter := make(map[int]int)
	for _, d := range l {
		counter[d]++
	}

	ans := 1
	for _, cnt := range counter {
		ans = (cnt + 1) * ans % 1000000007
	}
	fmt.Println(ans)
}


Measured memory_bytes: 768
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))

using namespace std;
typedef pair<llint, llint> P;

llint n;
llint d[105], e[105];

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> d[i] >> e[i];
	
	llint ans = 0, cnt = 0;
	for(int i = 1; i <= n; i++){
		if(d[i] == e[i]) cnt++;
		else cnt = 0;
		ans = max(ans, cnt);
	}
	if(ans >= 3) cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}

Measured memory_bytes: 3644
N, Ma, Mb = map(int, input().split())
ABC = [tuple(map(int, input().split())) for _ in range(N)]
INF = float("inf")
DP = [[[INF] * (11*N+1) for _ in range(11*N+1)] for _ in range(N+1)]
DP[0][0][0] = 0
for i, (a, b, c) in enumerate(ABC):
    for j in range(10*N+1):
        for k in range(10*N+1):
            if DP[i][j][k] == INF: continue
            DP[i+1][j][k] = min(DP[i+1][j][k], DP[i][j][k])
            DP[i+1][j+a][k+b] = min(DP[i+1][j+a][k+b], DP[i][j][k] + c)
ans = INF
for j in range(1,10*N+1):
    for k in range(1,10*N+1):
        if Ma * k == Mb * j:
            ans = min(ans, DP[N][j][k])
if ans == INF:
    ans = -1
print(ans)

Measured memory_bytes: 70440
import math

n=int(input())
p=list(map(int,input().split()))
q=list(map(int,input().split()))


def fun(x):
    
    count=0
    
    for k in range(len(x)-1):
        count+=math.factorial(len(x)-1)*sum(i<x[0] for i in x)
        del x[0]
        
    return count+1

a=fun(p)
b=fun(q)

print(int(abs(a-b)))

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main{
  public static void main(String[] args){

    Scanner sc = new Scanner(System.in);

    int A = sc.nextInt();
    int B = sc.nextInt();
    B = B * 2;
    
    if(A > B){
      System.out.println(A - B);
    }else{
      System.out.println(0);
    }


  }
}

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

int main()
{
	int a[5][14],i,j,n,rank,k;
	char s;
	for(i=1;i<=4;i++)
	{
		for(j=1;j<=13;j++)
			a[i][j]=0;
	}
	cin>>n;
	for(k=1;k<=n;k++)
	{
		cin>>s>>rank;
		switch(s){
			case 'S' :
				a[1][rank]=1;
				break;
			case 'H' :
				a[2][rank]=1;
				break;
			case 'C' :
				a[3][rank]=1;
				break;
			case 'D' :
				a[4][rank]=1;
				break;
			}
	}
	for(i=1;i<=4;i++)
	{
		for(j=1;j<=13;j++)
		{
			if(a[i][j]==0)
			{
				if(i==1) cout<<'S'<<' '<<j<<endl;
				else if(i==2) cout<<'H'<<' '<<j<<endl;
				else if(i==3) cout<<'C'<<' '<<j<<endl;
				else cout<<'D'<<' '<<j<<endl;
			}
		}
			
	}
	return 0;
 } 


Measured memory_bytes: 3108
import math
X,K,D=map(int,input().split())

if abs(X)>=K*D:
    if X>=0:
        print(abs(X-K*D))
    else:
        print(abs(X+K*D))
else:
    a=math.ceil(X/D)
    b=X-a*D
    K-=a
    if K%2==0:
        print(abs(b))
    else:
        print(abs(b+D))


Measured memory_bytes: 62052
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);i++)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;i--)
#define lb lower_bound
#define ub upper_bound
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
const ll LINF = (ll)(1e18 +99);
vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T>T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T>T mpow(T a, T n) {
   T res = 1;
   for(;n;n>>=1) {
      if (n & 1) res = res * a;
      a = a * a;
   }
   return res;
}

//cin.tie(0);ios::sync_with_stdio(false);



signed main(){
   int n,m;cin>>n>>m;
   int ans=0;
   vector<int> v(m,0);
   rep(i,0,n){
      int k;cin>>k;
      rep(j,0,k){
         int x;cin>>x;
         x--;
         v[x]++;
      }
   }

   rep(i,0,m){
      if(v[i]==n)ans++;
   }
   cout<<ans<<endl;
}

Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(unused_variables)]

fn main() {
    let S: Vec<char> = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().chars().collect()
    };

    let ans = {
        let mut T = S.clone();
        T.sort();
        if T[0] == T[1] && T[1] != T[2] && T[2] == T[3] {
            "Yes"
        } else {
            "No"
        }
    };

    println!("{}", ans);
}


Measured memory_bytes: 4352
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long sum = 0;
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= n; j++) {
                for (int k = 1; k <= n; k++) {
                    sum += gcd(gcd(i, j), k);
                }
            }
        }
        System.out.println(sum);
    }
    
    public static int gcd(int a, int b) {
        if (b == 0) return a;
        
        return gcd(b, a % b);
    }
}


Measured memory_bytes: 35852
# -*- coding: utf-8 -*-
import itertools
import sys
import math
from functools import lru_cache

# 1整数
# n = int(input())

# 空白区切り2変数
from queue import Queue
from operator import mul
from functools import reduce
from queue import Queue
from operator import mul
from functools import reduce
from functools import lru_cache

# input = sys.stdin.readline

# N個整数
#n= list(map(int, input().split()))

# 1整数
n = int(input())

# 空白区切りリスト整数
# b = list(map(int, input().split()))

# 空白区切り文字列
# t, d = input().split()
s = input()

ret = 9999999
count = 0

##全黒から
for i in range(n):
    ##白なら変更
    if s[i] == '.':
        count += 1
ret = min(ret,count)

#i個目を白にしたとしての距離
for i in range(n):
    if s[i] =='.':
        count -= 1
    else:
        count += 1
    ret = min(ret,count)

print(ret)


Measured memory_bytes: 4620
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <climits>
#include <iomanip>
#include <sstream>

using namespace std;

using ll = long long;
using ld = long double;
using ull = unsigned long long;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

template <typename T>
T gcd(T a, T b) {
	while (b != 0) {
		T temp = a;
		a = b;
		b = temp % b;
	}

	return a;
}

// cout << setfill('0') << setw(5) << number < endl;
// while(getline(cin, s)) { .. } | `s` is a string

void solve() {
	int n, x;
	cin >> n >> x;
	vector<int> h(n);
	vector<ll> dp(n, INT_MAX);
	for (auto &it : h)
		cin >> it;

	dp[0] = 0;
	for (int i = 1; i < n; ++i) {
		for (int k = 1; k <= min(i, x); ++k)
			dp[i] = min(dp[i], dp[i - k] + abs(h[i] - h[i-k]));
	}

	cout << dp[n-1] << endl;
}


int main(){
	IOS;
	int t = 1;
	// cin >> t;
	while(t--)
		solve();

	return 0;
}



























 

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

typedef long long ll;

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; }
const ll INF = 1e9;
const long long INFL = 1LL<<60;

// n = 12: [(2, 2), (3, 1)]
vector<pair<ll, int>> factorize(ll n) {
  vector<pair<ll, int>> res;
  for (ll i = 2; i * i <= n; i++) {
    if (n % i) continue;
    res.emplace_back(i, 0);
    while (n % i == 0) {
      n /= i;
      res.back().second++;
    }
  }
  if (n != 1) res.emplace_back(n, 1);
  return res;
}

int main() {
  ll n, p;
  cin >> n >> p;

  if (n == 1) {
    cout << p << endl;
    return 0;
  }

  // ans ** n <= p

  auto f = factorize(p);
//  rep(i, f.size()) {
//    cerr << f[i].first << " " << f[i].second << endl;
//  }
  sort(ALL(f));
  ll ans = 1;
  for (int i = f.size() - 1; i >= 0; i--) {
    if (f[i].second >= n) {
      ans *= pow(f[i].first, (f[i].second / n));
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,a,n) for(int i = (a);i < (n);i++)
typedef unsigned long long ull;
typedef long long ll;
using namespace std;

int main(){
  	string s1,s2;
  	char memo1[26],memo2[26];
  	cin >> s1 >> s2;
  
  	rep(i,0,26){
		memo1[i] = '-';
      	memo2[i] = '-';
    }
  
  	rep(i,0,s1.size()){
    	if(memo1[s1[i]-97] == '-'){
			memo1[s1[i]-97] = s2[i];
        }
      	else if(memo1[s1[i]-97] != s2[i]){
          cout << "No" << endl;
          return 0;
        }
    }
  
  	rep(i,0,s2.size()){
    	if(memo2[s2[i]-97] == '-'){
			memo2[s2[i]-97] = s1[i];
        }
      	else if(memo2[s2[i]-97] != s1[i]){
          cout << "No" << endl;
          return 0;
        }
    }
  
  	cout << "Yes" << endl;
 	return 0; 
}

Measured memory_bytes: 776
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  int N, K;
  cin >> N >> K;
  vector<int> v;
  rep(i,N){
    int a;
    cin >> a;
    v.push_back(a);
  }

  ll ret = 0;
  rep(l,v.size()+1){
    REP(r,l,v.size()+1){
      vector<int> tmp;
      rep(i,l) tmp.push_back(v[i]);
      REP(i,r,v.size()) tmp.push_back(v[i]);
      sort(ALLOF(tmp));
      
      if(tmp.size() > K) continue;
      int k = K-tmp.size();
      rep(i,tmp.size()){
        if(k>0 && tmp[i]<0){
          tmp[i] = 0;
          k--;
        }
      }
      ll sum = 0;
      rep(i,tmp.size()) sum += tmp[i];
      ret = max(ret, sum);
    }
  }

  cout << ret << endl;
  
  return 0;
}

Measured memory_bytes: 256
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
      return Array.new(size1){init}
  else
      return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

N=gets.to_i
x=1000
while x<N
    x+=1000
end
puts x-N

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    int n, m;
    cin >> n >> m;
    int d[n][n];
    int a[m], b[m], c[m];

    int INF = 1e7;

    rep(i, n) rep(j, n) d[i][j] = (i == j ? 0 : 1e7);

    rep(i, m)
    {
        cin >> a[i] >> b[i] >> c[i];
        a[i]--, b[i]--;
        d[a[i]][b[i]] = c[i];
        d[b[i]][a[i]] = c[i];
    }

    rep(k, n)
    {
        rep(i, n)
        {
            rep(j, n)
            {
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }

    int cnt = 0;

    rep(t, m) if (d[a[t]][b[t]] != c[t]) cnt++;

    OP(cnt);

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Numerics;

class Program {
    static void Main(string[] args) {
        int n = int.Parse(Console.ReadLine());
        var s = new string[n];
        for (int i = 0; i < n; i++) {
            s[i] = Console.ReadLine();
        }
        int m = int.Parse(Console.ReadLine());
        var t = new string[m];
        for (int i = 0; i < m; i++)
        {
            t[i] = Console.ReadLine();
        }

        Array.Sort(s);
        Array.Sort(t);
        var a = new Dictionary<string, int>();
        a.Add(s[0], 1);
        for (int i = 1; i < n; i++) {
            if (s[i - 1] == s[i]) {
                a[s[i]]++;
            } else {
                a.Add(s[i], 1);
            }

        }
        for (int i = 0; i < m; i++) {
            if (a.ContainsKey(t[i])) {
                a[t[i]]--;
            }
        }
        int count = 0;
        foreach (var i in a) {
            count = count > i.Value ? count : i.Value;
        }
        Console.WriteLine(count);
    }
}

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

ll ara[mxx+5];
ll ara2[mxx+5];
ll cnt[mxx+5];
ll cnt2[mxx+5];


int main()
{
    ll n,m,a,b,i,j,x,y,t,sum,flag,mx;

    while(scanf("%lld %lld %lld",&n,&m,&t)==3)
    {
        mx = -99;
        ara[0] = 0;
        ara2[0] = 0;
        for(i=1;i<=n;i++)
        {
            scanf("%lld",&ara[i]);
        }
        for(i=1;i<=m;i++)
        {
            scanf("%lld",&ara2[i]);
        }

        for(i=2;i<=n;i++)
        {
            ara[i] = ara[i]+ara[i-1];
        }

        for(i=2;i<=m;i++)
        {
            ara2[i] = ara2[i]+ara2[i-1];
        }

        sum = -1;
        j = m;
        for(i=0;i<=n;i++)
        {
            if(ara[i]>t)break;

            while(ara[i]+ara2[j]>t&&j>=0)
            {
                j--;
            }
            sum = max(sum,i+j);

        }

        printf("%lld\n",sum);




    }









return 0;
}


Measured memory_bytes: 6956
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> P;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 1e+9+7;
ll n,m,l;
string s,t;
ll d[100000],dp[100][100];

int main(){
  cin >> n;
  m = 1;
  lep(i,1,n){
    m *= i;
    m %= INF;
  }
  print(m);
  return 0;
}

Measured memory_bytes: 256
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func upperBound(a []int, x int) int {
	l := 0
	r := len(a)
	for l <= r {
		m := (l + r) / 2
		if len(a) == m {
			break
		}
		if a[m] <= x {
			l = m + 1
		} else {
			r = m - 1
		}
	}
	return l
}

func lowerBound(a []int, x int) int {
	l := 0
	r := len(a)
	for l <= r {
		m := (l + r) / 2
		if len(a) == m {
			break
		}
		if a[m] >= x {
			r = m - 1
		} else {
			l = m + 1
		}
	}
	return l
}

func main() {
	sc.Split(bufio.ScanWords)
	N := getInt()
	l := make([]int, N)
	for i := 0; i < N; i++ {
		l[i] = getInt()
		// l[i] = rand.Intn(1000 + 10)
	}

	sort.Ints(l)

	// out(l)

	ans := 0
	// ans1 := 0
	for i := 0; i < N; i++ {
		for j := i + 1; j < N; j++ {
			a := l[i]
			b := l[j]
			//			m := upperBound(l, b)
			n := lowerBound(l, a+b)
			// out(a, b, i, j, n, l[j+1:n])
			ans += n - (j + 1)
			//ans1 = 0
			// for k := j + 1; k < n; k++ {
			// 	c := l[k]
			// 	// out(a, b, c)
			// 	if a < b+c && b < c+a && c < a+b {
			// 		// out("pass")
			// 		ans1++
			// 	}
			// }
			// out(ans, ans1)
		}
	}
	out(ans)
	// out(ans1)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
	using namespace std;
	int main() { 
	    
	    string str;
	    getline(cin,str);

	    
	   for(int i=0; i<str.size() ;i++){
		    	if(str[i] >= 'A' && str[i] <= 'Z' ){
		    		str[i] += 'a' - 'A';
		    	}else if(str[i] >= 'a' && str[i] <= 'z' ){
		    		str[i] += 'A' - 'a';
		    	}
	    }

	    cout << str << endl;
	    return 0;
	}


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

#define int long long
using pii = pair<int, int>;
const int MOD = 1e9 + 7;
const int INF = 1 << 29;
const int N = 1e5 + 10;

struct IOsetup{
  IOsetup(){
   ios_base::sync_with_stdio(false);
   cin.tie(nullptr);
   cout.tie(nullptr);
   cout << fixed << setprecision(20);
  }
}IO;

int32_t main(){
  int a, b;
  cin >> a >> b;
  string s1 = "", s2 = "";
  for (int i = 0; i < a; i++) s1 += b + '0';
  for (int i = 0; i < b; i++) s2 += a + '0';
  cout << min(s1, s2) << endl; 
}

Measured memory_bytes: 256
input()
a=sorted(list(map(int,input().split())))
e={}
r=[]
for i in a:
  if not e.get(i):
    e[i]=1
  else:
    e[i]=0
    r.append(i)
print(0 if len(r) < 2 else r[-1] * r[-2])

Measured memory_bytes: 18088