akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(ll I = int((B)-1); I >= int(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;

int main(){
	string S;
	cin >> S;
	string s1,s2,s3;
	s1 = S.substr(0,4);
	s2 = S.substr(5,2);
	s3 = S.substr(7,2);
	if(s1<="2018"){
		cout << "Heisei" << endl;
	}else if(s1>="2020"){
		cout << "Heisei" << endl;
	}else if(s2<="04" && s3<="30"){
		cout << "Heisei" << endl;
	}else{
		cout << "TBD" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int,int> Pi;
typedef unsigned long long ULL;
int gcd(int a,int b){if (b == 0) return a; return gcd(b , a%b);}
int lcm(int a, int b){ return a/gcd(a,b)*b;}
inline int read(){
    int f = 1, x = 0;char ch = getchar();
    while (ch > '9' || ch < '0'){if (ch == '-')f = -f;ch = getchar();}
    while (ch >= '0' && ch <= '9'){x = x * 10 + ch - '0';ch = getchar();}
    return x * f;
}
const int maxn = 1e5 + 10;
struct _node {
    int a,b;
}node[maxn];
int cmp(_node c,_node k){
    return c.a < k.a;
}
int main(){
   // freopen("/Users/chutong/data.txt", "r", stdin);
    int n = read(),m = read();
    for (int i=1; i<=n; i++) {
        node[i].a = read();
        node[i].b = read();
    }
    sort(node+1, node+n+1,cmp);
    int tot = m;
    LL yen = 0;
    for (int i=1; i<=n; i++) {
        LL need = min(tot,node[i].b);
        tot -= need;
        yen += need*node[i].a;
        if (tot == 0) break;
    }
    printf("%lld\n",yen);
    return 0;
}


Measured memory_bytes: 1024
import math
s = list(map(int, list(input())))
k = int(input())
for i in range(len(s)):
    n = 5.0e+15 * math.log10(s[i])
    if n >= math.log10(k):
        print(s[i])
        exit()
    else:
        k -= 10**n

Measured memory_bytes: 3060
#include <cstdio>
#include <algorithm>
#include <tr1/unordered_set>
using namespace std;

int n , v[20] , ans = 0;

tr1::unordered_set<int> memo[20];

int X[421] , Y[421] , top;
 
int main(){
	while(scanf("%d\n",&n)&& n){
		int dp2[21] = {0};
		for(int i = 0 ; i < n ; i++) scanf("%d",&v[i]) , memo[i].clear();
		for(int i = n-1 ; i >= 0 ; i--) dp2[i] = dp2[i+1] + v[i];
		ans = 99999999;
		top = 0;
		X[top] = 0;
		Y[top] = 0;
		while(~top){
			int pos = X[top] , sum = Y[top]; top--;
			if(pos==n) ans = min(ans,sum);
			else{
				if( memo[pos].count(sum)) continue;
				else memo[pos].insert(sum);
				X[++top] = pos+1;
				Y[top]   = sum+v[pos];
				X[++top] = pos+1;
				Y[top]   = abs(sum-v[pos]);
			}
		}
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 0
// counting sort

import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int k = 0;
		int[] A = new int[n];
		int[] B = new int[n];
		for (int i = 0; i < n; i++) {
			A[i] = scanner.nextInt();
			if (A[i] > k) {
				k = A[i];
			}
		}
		countingSort(A, B, k, n);
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < n; i++) {
			sb.append(B[i]).append((i != n - 1) ? " " : "\n");
		}
		System.out.print(sb);
	}
	public static void countingSort(int[] A, int[] B, int k, int n) {
		int[] C = new int[k + 1];
		for (int i = 0; i < n; i++) {
			C[A[i]]++;
		}
		for (int i = 1; i < k + 1; i++) {
			C[i] += C[i - 1];
		}
		for (int i = n - 1; i >= 0; i--) {
			B[--C[A[i]]] = A[i];
		}
	}	
}

Measured memory_bytes: 517836
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <iostream>
#include <algorithm>

using namespace std;

#define MAX(x,y) (x>y?x:y)
#define MIN(x,y) (x<y?x:y)
#define ABS(x) (x>0?x:-(x))

#define INF 1000000000

void swap(int* a, int* b)
{
	int tmp;
	tmp = *a;
	*a = *b;
	*b = tmp;
}

int gcd(int a, int b)
{
	if (a < b)
		swap(&a, &b);

	if (a % b == 0)
		return b;
	else
		return gcd(b, a % b);
}

int lcm(int a, int b)
{
	return a * b / gcd(a, b);
}

int main()
{
	int N;
	int M;
	//int a[100000];
	int a, b;
	int a2=0, b2=0;
	int ans = 0;

	scanf("%d%d",&a,&b);

	for (int i = 0; i < b; i++)
	{
		a2 += pow(10, i) * a;
	}
	for (int i = 0; i < a; i++)
	{
		b2 += pow(10, i) * b;
	}

	if (a < b)
		printf("%d", a2);
	else
		printf("%d", b2);

}
		

Measured memory_bytes: 760
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <stack>
#include <queue>
#include <set>

#define mod 1000000007
#define mp make_pair
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll k;
    string s;
    ll ans = 0;
    cin >> k >> s;
    if(k>=s.size()) cout << s;
    else {
        for(int i = 0; i < k; i++)   cout << s[i];
        cout << "...";
    }
    return 0;
}

Measured memory_bytes: 3640
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] A = new long[n];
		long[] B = new long[n];
		for(int i = 0; i < n; i++){
			A[i] = sc.nextInt();
		}
		PriorityQueue<Pair> q = new PriorityQueue<>();
		for(int i = 0; i < n; i++){
			B[i] = sc.nextInt();
			q.add(new Pair(i, B[i]));
		}
		long res = 0;
		while(!q.isEmpty()){
			Pair p = q.remove();
			int u = p.ind;
			if(B[u] == A[u]) continue;
			long sides = B[(u+1)%n] + B[(u+n-1)%n];
			if(sides >= B[u]){
				System.out.println("-1"); return;
			}
			long newb = B[u] % sides;
			if(newb <= A[u]){
				if((A[u] - newb) % sides == 0){
					res += (B[u] - A[u]) / sides;
					B[u] = A[u];
				}
				else{
					System.out.println("-1"); return;
				}
			}
			else{
				res += (B[u] - newb) / sides;
				B[u] = newb;
				q.add(new Pair(u, B[u]));
			}
		}
		System.out.println(res);
	}
	static class Pair implements Comparable<Pair>{
		int ind; long val;
		public Pair(int ind, long val){
			this.ind = ind; this.val = val;
		}
		@Override
		public int compareTo(Pair p) {
			if(val < p.val) return 1;
			else if(val > p.val) return -1;
			else return 0;
		}
		public String toString(){
			return ind+" "+val;
		}
	}

}


Measured memory_bytes: 136896
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCorder
{
    class Program
    {
        static void Main(string[] args)
        {
            // 標準入力:K,S
            int k = int.Parse(Console.ReadLine());
            string s = Console.ReadLine();

            if (s.Length <= k)
                Console.WriteLine(s);
            else
                Console.WriteLine(s.Substring(0, k) + "...");
        }
    }
}


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

int A[1000000], n;

int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    scanf("%d", &A[i]);
  }

  int q, k, sum = 0;
  cin >> q;
  for (int i = 0; i < q; i++) {
    scanf("%d", &k);
    // 標準ライブラリの lower_bound を使用
    if ( *lower_bound(A, A + n, k) == k ) sum++;
  }

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 3512
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
#include<iostream>
#include<stack>
#include<vector>
#include<cmath>
#include<map>
#include<queue>
#include<iomanip>
#include<unordered_map>
#include<set>
using namespace std;
typedef long long ll;
const int maxn=20005;

int n,p[maxn];
int a[maxn],b[maxn];

int main() {
    //freopen("in.cpp","r",stdin);
    cin>>n;
    for(int i=1;i<=n;i++)cin>>p[i];
    for(int i=1;i<=n;i++){
        a[i]=1+(i-1)*n;
        b[i]=1+(n-i)*n;
    }
    for(int i=1;i<=n;i++){
        b[p[i]] +=i-1;
    }
    for(int i=1;i<n;i++)cout<<a[i]<<" ";
    cout<<a[n]<<endl;
    for(int i=1;i<n;i++)cout<<b[i]<<" ";
    cout<<b[n]<<endl;
    return 0;
}


Measured memory_bytes: 896
import java.util.*;
public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        

        int n = sc.nextInt();
        int[] A = new int[n];
        for(int i =0; i < n; i++){
            A[i] = sc.nextInt();
        }
         

         int[] help = new int[n];
         help[0] = A[0];
         for(int i = 1; i < n; i++){
            if(A[i-1] >= A[i] )
               help[i] = help[i-1];

            else if(A[i] > A[i-1] && A[i] > help[i-1])
               help[i] = A[i];
             else if(A[i] > A[i-1] && A[i] < help[i-1])
               help[i] = help[i-1];
         }
         long minH = 0L;
         for(int j = 0; j < n; j++){
             minH += Math.abs(A[j] - help[j]);
         }
         System.out.println(minH);
    }
}

Measured memory_bytes: 59904
#include <iostream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <bitset>

using namespace std;

int main()
{
    bitset<64> state;

    int n;
    cin >> n;
    vector< bitset<64> > mask(n);

    int j = 0;
    while (n--)
    {
 
        int k;
        cin >> k;

        while (k--)
        {
            int b;
            cin >> b;

            mask[j].set(b);
        }
        j++;
    }


    int q;
    cin >> q;

    int cmd, i;
    while (q--)
    {
        cin >> cmd >> i;
        switch (cmd)
        {
            case 0: 
                cout << state.test(i) << endl;
                break;
            case 1: 
                state |= mask[i];
                break;
            case 2: 
                state &= ~mask[i];
                break;
            case 3: 
                state ^= mask[i];
                break;
            case 4: 
                cout << (state | ~mask[i]).all() << endl;
                break;
            case 5: 
                cout << (state & mask[i]).any() << endl;
                break;
            case 6: 
                cout << (state & mask[i]).none() << endl;
                break;
            case 7: 
                cout << (state & mask[i]).count() << endl;
                break;
            case 8: 
                cout << (state & mask[i]).to_ulong() << endl;
                break;

        }

    }
}


void input(bitset<64> mask, int n)
{

}


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

int main() {
  int a,b,c,x;
  cin >> a >> b >> c;

  int max,min, mid;

  if(a<=b){
    max = b;
    min = a;
    if(max<=c){
      mid = max;
      max = c;
    }
    else{
      mid = c;
    }
  }
  else{
    max = a;
    min = b;
    if(max<=c){
      mid = max;
      max = c;
    }
    else{
      mid = c;
    }
  }
  

  if(mid<=min){
    x = min;
    min = mid;
    mid = x;
  }

  cout << min << " " << mid << " " << max << endl;


  
}

Measured memory_bytes: 1168
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

string N;
int K;

void solve() {
	int i,j,k,l,r,x,y,z; string s;
	
	cin>>N>>K;
	while(N.size()<100) N="0"+N;
	string S(100,'0');
	
	ll ret=0;
	FOR(x,100) {
		for(S[x]='1';S[x]<='9';S[x]++) {
			if(K==1 && S<=N) ret++;
			FOR(y,x) {
				for(S[y]='1';S[y]<='9';S[y]++) {
					if(K==2 && S<=N) ret++;
					FOR(z,y) {
						for(S[z]='1';S[z]<='9';S[z]++) {
							if(K==3 && S<=N) ret++;
						}
						S[z]='0';
					}
				}
				S[y]='0';
			}
		}
		S[x]='0';
	}
	cout<<ret<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 105,inf=0x3f3f3f3f;
int dp[2][N][N][N];char s[N][N];
int qz1[N][N],qz2[N][N],x,y,n,m;
int main() {
	read(n);read(m);
	rep(i,1,n)scanf("%s",s[i]+1);
	rep(i,1,n)rep(j,1,m){
		qz1[i][j]=qz2[i][j]=s[i][j]=='o';
		if(s[i][j]=='E')x=i,y=j;
	}
	//qz1[][]:line qz2[][]:colume
	rep(i,1,n)rep(j,1,m)qz1[i][j+1]+=qz1[i][j];
	rep(i,1,n)rep(j,1,m)qz2[i+1][j]+=qz2[i][j];
	int mx=max(n,m),res=0;
	rep(i,0,1)rep(j,0,mx)rep(k,0,mx)rep(l,0,mx)dp[i][j][k][l]=-inf;
	dp[0][0][0][0]=0;
	rep(l,0,m){
		int p=l&1,q=p^1;
		rep(r,0,m)rep(u,0,n)rep(d,0,n-u)dp[q][r][u][d]=-inf;
		rep(r,0,m-l)rep(u,0,n)rep(d,0,n-u)if(dp[p][r][u][d]>=0&&x-u>=1&&x+d<=n&&y-l>=1&&y+r<=m){
		//	printf("%d %d %d %d:%d\n",l,r,u,d,dp[p][r][u][d]);
			umax(res,dp[p][r][u][d]);
			int tmp=0;
			tmp=(y-l-1>=r+1&&y-l-1<=m-l&&max(x-u,d+1)<=min(x+d,n-u))?qz2[min(x+d,n-u)][y-l-1]-qz2[max(x-u,d+1)-1][y-l-1]:0;
		//	printf("[%d] %d %d %d\n",(y-l-1>=r+1&&y-l-1<=m-l&&max(x-u,d+1)<=min(x+d,n-u)),max(x-u,d+1),min(x+d,n-u),dp[p][r][u][d]+tmp);
			umax(dp[q][r][u][d],dp[p][r][u][d]+tmp);
			tmp=(y+r+1>=r+1&&y+r+1<=m-l&&max(x-u,d+1)<=min(x+d,n-u))?qz2[min(x+d,n-u)][y+r+1]-qz2[max(x-u,d+1)-1][y+r+1]:0;
			umax(dp[p][r+1][u][d],dp[p][r][u][d]+tmp);
			tmp=(x-u-1>=d+1&&x-u-1<=n-u&&max(y-l,r+1)<=min(y+r,m-l))?qz1[x-u-1][min(y+r,m-l)]-qz1[x-u-1][max(y-l,r+1)-1]:0;
			umax(dp[p][r][u+1][d],dp[p][r][u][d]+tmp);
			tmp=(x+d+1>=d+1&&x+d+1<=n-u&&max(y-l,r+1)<=min(y+r,m-l))?qz1[x+d+1][min(y+r,m-l)]-qz1[x+d+1][max(y-l,r+1)-1]:0;
			umax(dp[p][r][u][d+1],dp[p][r][u][d]+tmp);
		}
	}
	cout<<res;
	return 0;
}


Measured memory_bytes: 9216
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) ((x < 0)?-(x):x)
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

typedef long long cat;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	string S;
	int N, K;
	cin >> S >> K;
	N = S.length();

	vector<string> V;
	for(int i = 0; i < N; i++) for(int j = 1; j <= min(K, N-i); j++)
		V.push_back(S.substr(i, j));
	sort(begin(V), end(V));
	for(int i = 0; i < (int)V.size(); i++) if(i == 0 || V[i] != V[i-1]) {
		K--;
		if(K == 0) {
			cout << V[i] << "\n";
			return 0;
		}
	}
	return 0;}

// look at my code
// my code is amazing


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

#define IOS                               \
	ios_base::sync_with_stdio(false); \
	cin.tie(0);                       \
	cout.tie(0);                      \
	cout.precision(20);               \
	cout << fixed;
#define pb push_back
#define endl "\n"
#define all(a) a.begin(), a.end()
#define N 500009
#define M 1000009
#define mod 1000000007
int powi(int a,int b){if (b == 0)return 1;int see = powi(a, b / 2);see *= see;see %= mod;if (b % 2)see *= a;see %= mod;return see;}

int n,k;

void pre(){
}

int32_t main()
{
	IOS;
	pre();
	cin>>n>>k;
	int a[N];
	int ans = 0;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		if(a[i]>=k)
			ans++;
	}
	cout<<ans<<endl;
	
}

Measured memory_bytes: 640
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("O2")
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
////
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
#include <bits/stdc++.h>

#define all(x) (x).begin(), (x).end()
#define allp(x) (x)->begin(), (x)->end()

#define pb push_back


using namespace std;
void dout() { cerr << endl; }
//typedef long long ll;
template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

using ll = long long;
//#ifdef __int128
//using hll = __int128;
//#endif
using pii = pair<ll, ll>;
using ld = long double;
using pll = pair<long long, long long>;

template <typename T>
void do_uniq(vector<T> vec){
    sort(all(vec));
    vec.resize(unique(all(vec)) - vec.begin());
}

clock_t timestamp_start = clock();
void time_calc()
{
    cerr << (ld)(clock() - timestamp_start) / CLOCKS_PER_SEC << "\n";
}


#ifdef _getchar_nolock
#else
#define _getchar_nolock getchar_unlocked
#endif

//#define solvsh
//#define multi

#ifdef solvsh
#else

ll mod = 1e9 + 7;

ll add(ll a, ll b){
    return (a + b) % mod;
}
ll ml(ll a, ll b) {
    return (a * b) % mod;
}

ll b_p(ll b, ll p) {
    if (p == 0) return 1;
    if (p & 1) return ml(b, b_p(b, p ^ 1));
    ll v = b_p(b, p >> 1);
    return ml(v, v);
}

const int MAXN = 2000 + 25;

ll sub(ll a, ll b) {
    return add(a, mod - b);
}

ll dp[MAXN];

void solve() {


    int n;
    cin >> n;

    vector<pair<int, int>> v;

    for (int i = 0; i < n; ++ i) {
        int x, y;
        cin >> x >> y;
        v.push_back({x, y});
    }
    int answr = 0;
    for (int sx = -1; sx <= 1; sx += 2) {
        for (int sy = -1; sy <= 1; sy += 2) {

            vector<int> nums;

            for (int k = 0; k < n; ++k) {
                nums.push_back(v[k].first * sx + v[k].second * sy);
            }

            sort(all(nums));
            answr = max(answr, nums.back() - nums[0]);
        }
    }

    cout << answr << "\n";
}

#endif

void multisolve() {
    int t;
    cin >> t;

    int i = 1;
    while (t--) {
        solve();
        i++;
    }
}

#define int int
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    cout << fixed << setprecision(20);

#ifndef ONLINE_JUDGE
#else
#endif
#ifdef multi
    //        gen();
    multisolve();
#else
    solve();
//    gen();
#endif
//    time_calc();
}


Measured memory_bytes: 6684
#include <stdio.h>
#include <stdlib.h>

char list[100]; //n < 50, so char is ok.

int main(){
  int n, q, m, a, x, i;

  for(;scanf("%d%d",&n,&q),n||q;){
    q--;
    for(i=0;i<n;i++){
      scanf("%d",&m);
      for(a=0;a<m;a++){
        scanf("%d", &x);
        list[x]++;
      }
    }

    a=0;
    for(i=0;i<100;i++){
	  if(list[i]>q){
	    a=i;q=list[i];
	  }
	  list[i]=0;
    }
    printf("%d\n", a);
  }
}

Measured memory_bytes: 600
_ = int(input())
hoge = [int(x) for x in input().split()]
_ = int(input())

def exSearch(i, m):
    if m == 0:
        return True
    if i >= len(hoge) or m > sum(hoge):
        return False
    res = exSearch(i+1, m) or exSearch(i+1, m-hoge[i])
    return res

if __name__ == '__main__':
    
    for val in (int(x) for x in input().split()):
        if exSearch(0, val):
            print ('yes')
        else:
            print ('no')


Measured memory_bytes: 5628
package main
import (
  "fmt"
  "sort"
)
func main() {
  var n,x,m int
  var a []int
  fmt.Scan(&n,&x)
  a = make([]int,n)
  for i:=0;i<n;i++ {
    fmt.Scan(&a[i])
  }
  sort.Ints(a)
  m = 0
  for i:=0;i<n;i++ {
    x -= a[i]
    if x < 0 {
      m = i
      break
    }
  }
  if x == 0 {
    m = n
  } else if x > 0 {
    m = n-1
  }
  fmt.Println(m)
}

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

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; }
#define rep(i, n) for(int i = 0; i < n; i++)

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

const int INF = 1 << 29;
const ll LINF = 1LL << 60;

int main()
{
	vector<int>a(3);
	rep(i, 3)  cin >> a[i];
	sort(a.begin(), a.end());
	
	int x, y;
	x = a[2] - a[0];
	y = a[2] - a[1];

	int cnt = y;
	if ((x - y) % 2 == 1) {
		cnt += (x - y) / 2;
		cnt += 2;
	}
	else {
		cnt += (x - y) / 2;
	}
	cout << cnt << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>

using namespace std;
using llong = long long;
const int MOD=1000000007;

int main(int argc, char**argv){
    int n;
    cin >> n;
    int a, b;
    cin >> a >> b;

    if ((b-a) % 2 == 0){
        cout << "Alice" << endl;
    }else{
        cout << "Borys" << endl;
    }

    return 0;
}







Measured memory_bytes: 256
n,m=map(int,input().split())
l=list(input().split() for _ in range(m))
l=sorted(l,key=lambda x:x[0])
import itertools
lll=[]
for (k,g) in itertools.groupby(l,key=lambda x:x[0]):
    lll.append(list(g))
a=0
w=0
for i in range(len(lll)):
    for j in lll[i]:
        if j[1]=="AC":
            a+=1
            w+=lll[i].index(j)
            break
print(a,w)

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

int main() {
    long N, M;
    cin>>N>>M;
    long A[N];
    for(int i=0;i<N;++i){
        cin>>A[i];
    }

    long mod[N];
    long sum = 0;
    for(int i=0;i<N;++i){
        sum += A[i]%M;
        sum %= M;
        mod[i] = sum;
    }
    
    vector<long> numarr;
    map<long, long>nummap;
    for(int i=0;i<N;++i){
        if(nummap[mod[i]]==0) numarr.push_back(mod[i]);
        nummap[mod[i]]++;
    }

    /**
    for(int i=0;i<M;++i){
        cout<<i<<" "<<num[i]<<endl;
    }
    **/
    long ans = 0;
    for(int i=0;i<numarr.size();++i){
        if(numarr[i]==0){
            ans += nummap[numarr[i]];
        }
        if(nummap[numarr[i]]>1){
            ans += nummap[numarr[i]]*(nummap[numarr[i]]-1)/2;
        }
    }
    cout<<ans<<endl;
}


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

int dp[100005][4];
int main(){
int t;
cin>>t;
int a,b,c;
for(int i=0;i<t;i++)
{
	cin>>a>>b>>c;
	if(i==0)
	{
		dp[i][0]=a;
		dp[i][1]=b;
		dp[i][2]=c;
	}
	else
	{
		dp[i][0]=max(dp[i-1][1]+a,dp[i-1][2]+a);
        dp[i][1]=max(dp[i-1][0]+b,dp[i-1][2]+b);
        dp[i][2]=max(dp[i-1][1]+c,dp[i-1][0]+c);	
	}
}
int ans = max(dp[t-1][0],max(dp[t-1][1],dp[t-1][2]));
cout<<ans;
}


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

struct UnionFind {
  vector<int> parent, size;

  UnionFind(int n) {
    parent.resize(n);
    size.resize(n, 1);

    for (int i = 0; i < n; ++i) parent[i] = i;
  }

  int root(int x) {
    while (parent[x] != x) x = parent[x] = parent[parent[x]];
    return x;
  }

  bool unite(int x, int y) {
    x = root(x);
    y = root(y);

    if (x == y) return false;

    if (size[x] < size[y]) swap(x, y);
    size[x] += size[y];
    parent[y] = x;

    return true;
  }

  bool same(int x, int y) {
    return root(x) == root(y);
  }

  int getSize(int x) {
    return size[root(x)];
  }
};

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

  int n, m, k;
  cin >> n >> m >> k;

  UnionFind uf(n);

  vector<vector<int>> block(n);
  vector<vector<int>> direct(n);

  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;

    uf.unite(a-1, b-1);
    direct[a-1].emplace_back(b-1);
    direct[b-1].emplace_back(a-1);
  }

  for (int i = 0; i < k; ++i) {
    int a, b;
    cin >> a >> b;

    block[a-1].emplace_back(b-1);
    block[b-1].emplace_back(a-1);
  }

  for (int i = 0; i < n; ++i) {
    int all = uf.getSize(i) - 1;
    all -= direct[i].size();
    for (auto p : block[i]) all -= uf.same(i, p);
    
    cout << all << (i == n-1 ? '\n' : ' ');
  }

  return (0);
}


Measured memory_bytes: 15012
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m;
    cin>>n>>m;
    char a[n][m];
    long long mod = 1000000007;
    int i;
    for(i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            cin>>a[i][j];
        }
    }
    long long int dp[n][m];
    dp[0][0] = 0;
    for(i=1;i<m;i++)
    {
        if(a[0][i] == '.')
            dp[0][i] = 1;
        else
        {
            break;
        }
    }
    for(int j=i;j<m;j++)
        dp[0][j] = 0;
    for(i=1;i<n;i++)
    {
        if(a[i][0] == '.')
            dp[i][0] = 1;
        else
        {
            break;
        }
    }
    for(int j=i;j<n;j++)
        dp[j][0] = 0;
    for(int i=1;i<n;i++)
    {
        for(int j=1;j<m;j++)
        {
            if(a[i][j] == '#')
                dp[i][j] = 0;
            else
                dp[i][j] = (dp[i-1][j] + dp[i][j-1])%mod;
        }
    }
    // for(int i=0;i<n;i++)
    // {
    //     for(int j=0;j<m;j++)
    //         cout<<dp[i][j]<<" ";
    //     cout<<endl;    
    // }
    cout<<dp[n-1][m-1]%mod;
        
}

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

int main(){
    int n; string s; cin >> n >> s;
    int cnt = 0;
    rep(i,n-2){
        if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C') cnt++;
    }
    cout << cnt;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
#define all(v) v.begin(), v.end()
using P = pair<int, int>;

signed main() {

    int n, k;
    cin >> n >> k;
    
    vector<int> a(n);
    rep(i, n){
        cin >> a[i];
    }
    
    int ans = LLONG_MAX;
    rep(bit, 1<<n){
        int cnt = 0;
        vector<int> used(n);
        rep(i, n){
            if(bit & (1 << i)){
                cnt++;
                used[i] = true;
            }
        }
        
        if(cnt < k){
            continue;
        } 
      
        int base = a[0];
        int tmp = 0;
        REP(i, 1, n){
            if(used[i] && a[i] <= base){
                tmp += base - a[i] + 1;
                base += 1;
            }
            base = max(base, a[i]);
        }
        ans = min(ans, tmp);
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(void){

char ch[210],ch2[110],*ch3="A";
int a=0,b=0,c=0,d=0,e=0,chc=0;


//////////読み込み/////////
for(a=0;a<=101;a++){
ch[a] = getchar();
if(ch[a]=='\n'){
e=a;
break;}
}
//////////////////////////


/*for(b=0;b<=a;b++){
printf("b=%d %c\n",b,ch[b]);
}*/

/////////読み込み２/////////
/*for(a=0;a<=101;a++){
ch2[a] = getchar();
if(ch2[a]=='\n'){
break;
}
}*/

scanf("%s",ch2);

///////////////////////////

/*for(b=0;b<=a;b++){
printf("b=%d %c\n",b,ch2[b]);
}*/

////////判定//////////////

for(a=0;a<=e;a++){
ch[e+a]=ch[a];
}

/*for(a=0;a<2*e;a++){
printf("ch[%d] = %c\n",a,ch[a]);
}*/

/*
b=0;

for(a=0;a<=2*e+1;a++){

	if(ch[a]!=ch2[b]){
	b=0;
		if(ch[a]==ch2[b]){
		b++;
		}
	}
	
	if(ch[a]==ch2[b]){
	b++;
	//printf("!\n");
		if(ch2[b]=='\n'){
		printf("Yes\n");
		break;
		}
	}

	if(a==2*e){
	printf("No\n");
	break;
	}

}*/

ch3= strstr(ch,ch2);

if(ch3==NULL){
printf("No\n");
}
else{
printf("Yes\n");
}

//printf("end");
return 0;
}

Measured memory_bytes: 524
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace C
{
    public class Program

    {
        public static void Main(string[] args)
        {
            int[] line = ReadIntAr();
            int n = line[0];
            int k = line[1];

            List<int> items = new List<int>();

            for (int i = 0 ; i < n ; i++)
            {
                items.Add(ReadInt());
            }

            items.Sort();

            int res = int.MaxValue;
            for (int i = 0 ; i < n - (k - 1) ; i++)
            {
                res = Math.Min(res, items[i + (k - 1)] - items[i]);
            }

            Console.WriteLine(res.ToString());
        }

        static string ReadSt() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Console.ReadLine()); }
        static long ReadLong() { return long.Parse(Console.ReadLine()); }
        static double ReadDouble() { return double.Parse(Console.ReadLine()); }
        static string[] ReadStAr(char sep = ' ') { return Console.ReadLine().Split(sep); }
        static int[] ReadIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => int.Parse(e)); }
        static long[] ReadLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => long.Parse(e)); }
        static double[] ReadDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => double.Parse(e)); }

    }

}


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

int main() {

  int A,B,C,D,E,F; cin >> A >> B >> C >> D >> E >> F;
  double maxp = -1.0;
  int ansa,ansb;
  for ( int i = 0; 100*A*i <= F; i++ ) {
    for ( int j = 0; 100*A*i + 100*B*j<=F; j++ ) {
      if ( i == 0 && j == 0 ) continue;
      for ( int k = 0; 100*A*i + 100*B*j+ C*k <= F; k++ ) {
	for ( int l = 0; 100*A*i + 100*B*j + C*k + l*D <= F; l++ ) {
	  if ( i == 0 && j == 0 && k == 0 && l == 0 ) continue;
	  int x = 100 * A * i + 100 * B * j;
	  int y = C*k + D * l;
	  double p = 100.0*y/(x+y);
	  if (p <=100.0*E/(100.0+E) && maxp < p ) {
	      maxp = p;
	      ansa = x+y;
	      ansb = y;
	    }
	  }
	}
      }
    }
  

  cout << ansa << " " << ansb << endl;
  return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (N, M) = readInputLine().split(" ").map { it.toInt() }
    val ans = CharArray(N) { '*' }

    for (i in 0 until M) {
        val (s, c) = readInputLine().split(" ").let { Pair(it[0].toInt(), it[1].first()) }
        if (ans[s - 1] != '*' && ans[s - 1] != c) {
            println(-1)
            return
        }
        ans[s - 1] = c
    }

    if (N != 1 && ans[0] == '0') {
        println(-1)
        return
    }

    if (ans[0] == '*') {
        if (N == 1) {
            ans[0] = '0'
        } else {
            ans[0] = '1'
        }
    }

    for (i in 1 until N) {
        if (ans[i] == '*') {
            ans[i] = '0'
        }
    }

    println(ans.joinToString(""))
}

fun readInputLine(): String {
    return readLine()!!
}


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

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<ld> vd;
typedef bool bl;
typedef vector<bl> vb;
typedef vector<vl> mt;
typedef unordered_map<ll,unordered_map<ll,ll>> graph;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef vector<string> vs;
typedef vector<vs> table;
typedef vector<vl> v2;
typedef vector<v2> v3;
typedef vector<v3> v4;


const ll e5 = 1 << 20;
const ll mod = 1000000007;
const ll e3 = 1 << 13;
const ll INF = 1ll << 50;

ll a;
string s;

int main(){
  cin >> a;
  cin >> s;
  if(a >= 3200) cout << s << endl;
  else cout << "red" << endl;
}


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


void solve(long long N, std::string S, std::string T){
    string ans;
    for(int i = 0;i < N;i++){
        ans.push_back(S[i]);
        ans.push_back(T[i]);
    }
    cout<<ans<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::string S;
    std::cin >> S;
    std::string T;
    std::cin >> T;
    solve(N, S, T);
    return 0;
}


Measured memory_bytes: 256
"""
https://atcoder.jp/contests/abc118/tasks/abc118_b
"""

import numpy as np


def parse():
    N, M = list(map(int, input().split()))
    K = np.ones((N, ), dtype=np.int32) * -1
    A = np.ones((N, M), dtype=np.int32) * -1
    for i in range(N):
        tmp = list(map(int, input().split()))
        K[i] = tmp[0]
        A[i, 0:K[i]] = tmp[1:]
    return N, M, K, A


def solve(N, M, K, A):
    nlikes = np.zeros((M + 1,), dtype=np.int32)
    for i in range(N):
        nlikes[A[i, 0:K[i]]] += 1
    print(np.size(np.where(nlikes == N)))


if __name__ == '__main__':
    inputs = parse()
    solve(*inputs)


Measured memory_bytes: 21360
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned int u32;
typedef pair<int, int> p;
int Inf = 1000000000;
ll inf = 1000000000000;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main(){
	int h,n;
	cin >> h >> n;
	int i, a[110000];
	int sum = 0;
	for (i = 0; i < n; i++) {
		cin >> a[i];
		sum += a[i];
	}
	if (sum >= h) cout << "Yes";
	else cout << "No";
	return(0);
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  int N;
  cin >> N;
  int A;
  
  int max = 0;
  int min = 1000000000;
  
  for (int i = 0; i < N; i++) {
    cin >> A;
    if (A > max) {
      max = A;
    }
    if (A < min) {
      min = A;
    }
 
  }
  cout << max - min << endl;
}

Measured memory_bytes: 256
n = int(input())
s = input()

wn = s.count('.')
bn = n - wn
ans = min(wn,bn)

lw = 0
lb = 0
for i in range(n):
  if s[i]=='.':
    lw += 1
  else:
    lb += 1      
  ans = min(ans, lb + (wn - lw))
  
print(ans)

Measured memory_bytes: 3500
# -*- coding: utf-8 -*-

def main():
    N=int(input())  #数値入力 「N」だけの入力のとき
    a = range(1, N+1)
    ans = 0
    for i in range(1, N):
        ans += i
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 38768
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(V) V.begin(),V.end()
const ll MOD = 1000000007;

ll F[500010], I[500010];

ll modpow(ll x, ll y) {
	ll ans = 1;
	while (y) {
		if (y & 1) 
			ans = ans * x % MOD;
		x = x * x % MOD;
		y /= 2;
	}
	return ans;
}

ll moddiv(ll x, ll y) {
	return x * modpow(y, MOD - 2) % MOD;
}

ll nCr(ll n, ll r) {
	return F[n] * I[r] % MOD * I[n - r] % MOD;
}

ll nPr(ll n, ll r) {
	return F[n] * I[n - r] % MOD;
}

int main() {
	F[0] = I[0] = 1;
	for (ll i = 1;i < 500010;i++) {
		F[i] = F[i - 1] * i % MOD;
		I[i] = modpow(F[i], MOD - 2);
	}
	ll N, M;
	cin >> N >> M;
	ll ans = 0;
	for (ll i = 0;i <= N;i++) {
		if (i & 1) {
			ans -= nCr(N, i) * nPr(M - i, N - i);
		}
		else {
			ans += nCr(N, i) * nPr(M - i, N - i);
		}
		ans %= MOD;
	}
	if (ans < 0)ans += MOD;
	cout << ans * nPr(M, N) % MOD << endl;
}

Measured memory_bytes: 11444
#include <iostream>
#include <vector>

using namespace std;

int main() {
	int H, W, K; cin >> H >> W >> K;
	vector<vector<char> > c(H, vector<char>(W));
	for (auto& e : c)
		for (auto& f : e)
			cin >> f;
	int ans = 0;
	for (int i = 0; i < (1 << H); ++i) {
		for (int j = 0; j < (1 << W); ++j) {
			int tmp = 0;
			for (int k = 0; k < H; ++k) {
				for (int l = 0; l < W; ++l) {
					if (c[k][l] == '#' && !(i & (1 << k)) && !(j & (1 << l))) ++tmp;
				}
			}
			if (tmp == K) ++ans;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
# define    all(a)              a.begin(), a.end()
#define forn(i, a, b) for (int i=a; i<b; i++)
#define pb push_back
#define mp make_pair
#define MOD int(1e9+7)
using namespace std;

typedef long long int ll;

bool cmp(int a, int b) {
    return a < b;
}

void printV(vector<int> nums) {
    for (int i: nums) {
        printf("%d ", i);// << " ";
    }
    printf("\n");
}

// void printV(vector<ll> nums) {
//     for (ll i: nums) {
//         printf("%lld ", i);// << " ";
//     }
//     printf("\n");
// }



int dir[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};

bool valid(int i, int j, int n, int m) {
    if (i >= 0 && i < n && j >=0 && j < m)
        return true;
    else 
        return false;
}

int main() {
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    for (int i=0; i<n; i++) {
        cin >> a[i] >> b[i];
    }
    for (int i=0; i<n-2; i++) {
        if (a[i] == b[i] && a[i+1] == b[i+1] && a[i+2] == b[i+2]) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}      

Measured memory_bytes: 3632
#include<bits/stdc++.h>
const int N=1e6+9,mo=998244353;
int f[N/2],f2[N/2],G[N/2],mi[N],vf[N],inv[N],fac[N],i,n,m,z,ans;
inline int C(int x,int y){return x<y?0:1ll*vf[y]*vf[x-y]%mo*fac[x]%mo;}
int main(){
	*f=*f2=1;
	for(i=*mi=*vf=*fac=1;i<N;++i)mi[i]=4ll*mi[i-1]%mo,inv[i]=i==1?1:1ll*(mo-mo/i)*inv[mo%i]%mo,
		fac[i]=1ll*i*fac[i-1]%mo,vf[i]=1ll*vf[i-1]*inv[i]%mo;
	scanf("%d%d",&n,&m);if(n>m)std::swap(n,m);
	for(i=0;i<n;++i)f[i+1]=1ll*inv[i+1]*(4*i+2)%mo*f[i]%mo;
	for(i=0;i<n;++i)f2[i+1]=1ll*inv[2*i+2]%mo*(8*i+12)%mo*f2[i]%mo;
	for(i=1;i<=n;++i)G[i]=(1ll*inv[2]*(mi[i]+mo-f[i])+f2[i-1]*2)%mo;
	if(n==m)ans=G[n];else for(i=0,z=m-n;i<=n;++i)ans=(ans+1ll*(G[n-i]+
		1ll*(i+z)*C(n*2-i*2,n-i))%mo*(C(z-1+i*2,i)+mo-C(z-1+i*2,i+z)))%mo;
	ans=1ll*fac[n]*fac[m]%mo*vf[n+m]%mo*ans%mo;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 21760
#include <unordered_set>
#include <string>
#include <iostream>

using namespace std;

int main() {
  typedef unordered_set<string> set_t;
  set_t dict;
  int n;
  string cmd; //command
  string word; //word to store
  unordered_set<string>::const_iterator got; //for find

  cin >> n; // number of inputs
  for (int i = 0; i < n; ++i) {
    cin >> cmd >> word;

    if (cmd == "insert") { // if insert
      dict.insert(word);
    } else {
      got = dict.find(word);
      if (got == dict.end()) {
	cout << "no" << endl;
      } else {
	cout << "yes" << endl;
      }
    }
  }
}
	 

Measured memory_bytes: 30568
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
			
		final int L = sc.nextInt();
		final int N = sc.nextInt();
		
		long sum = 0;
		for(int i = 0; i < N; i++){
			sum += (sc.nextLong() * sc.nextLong());
		}
		
		if(sum == 0){
			System.out.println(0);
		}else{
			System.out.println(1);
			System.out.println((sum < 0 ? 1 : -1) + " " + (Math.abs(sum)));
		}
		
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() {
			try {
				while (!hasNext()) {
					tok = new StringTokenizer(br.readLine());
				}
			} catch (IOException e) { /* ignore */
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public void close() {
			try {
				br.close();
			} catch (IOException e) { /* ignore */
			}
		}
	}
}

Measured memory_bytes: 24376
let rec take n = function
  | [] -> []
  | x :: xs ->
      if n = 0 then []
      else x :: take (n - 1) xs

let () = Scanf.scanf "%d\n" @@ fun n ->
  let as_ = Array.init (1 lsl n) @@ fun _ ->
    Scanf.scanf "%d " @@ fun a -> a in
  let dp = Array.init (1 lsl n) (fun i -> [i]) in
  for i = 0 to (1 lsl n) - 1 do
    for j = 0 to n - 1 do
      if 0 < i land (1 lsl j) then
        dp.(i) <-
          take 2 @@
          List.sort (fun i j -> compare as_.(j) as_.(i)) @@
          List.sort_uniq compare @@
          dp.(i) @ dp.(i land (lnot (1 lsl j)))
    done
  done;
  let a = Array.map (fun is ->
    List.fold_left ( + ) 0 @@
    List.map (Array.get as_) is) dp in
  for i = 1 to (1 lsl n) - 1 do
    a.(i) <- max a.(i) a.(i - 1);
    Printf.printf "%d\n" a.(i)
  done


Measured memory_bytes: 31616
n, k = map(int, input().split())
p = [int(x) - 1 for x in input().split()]
c = [int(x) for x in input().split()]
pow_num = 31
point = [[0] * n for i in range(pow_num)]
point_max = [[0] * n for i in range(pow_num)]
posi = [[0] * n for i in range(pow_num)]

c_set = set(c)
if all([i < 0 for i in c_set]):
    print(max(c_set))
else:
    for i in range(pow_num):
        if i == 0:
            for j in range(n):
                posi[i][j] = p[j]
                point[i][j] = c[p[j]]
            continue
        for j in range(n):
            posi[i][j] = posi[i-1][posi[i-1][j]]
            point[i][j] = point[i-1][j] + point[i-1][posi[i-1][j]]
    for i in range(pow_num):
        if i == 0:
            for j in range(n):
                point_max[i][j] = point[i][j]
            continue
        for j in range(n):
            point_max[i][j] = max(point_max[i-1][j], \
                point[i-1][j] + point_max[i-1][posi[i-1][j]])

    power_count = list()
    for i in range(pow_num):
        if k & (1 << i):
            power_count.append(i)

        ans = 0
        for i in range(n):
            next_posi = i
            cumsum_point = 0
            for posi_idx in power_count:
                if ans < cumsum_point + point_max[posi_idx][next_posi]:
                    ans = cumsum_point + point_max[posi_idx][next_posi]
                cumsum_point += point[posi_idx][next_posi]
                next_posi = posi[posi_idx][next_posi]

    print(ans)

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)

template<int64 mod>
struct ModInt{
  int64 x;
  constexpr ModInt(int64 y = 0):x((y%mod+mod)%mod){}
  constexpr ModInt& operator+=(const ModInt& a){
    if((x += a.x) >= mod) x -= mod;
    return *this;
  }
  constexpr ModInt& operator-=(const ModInt& a){
    if((x -= a.x) < 0)x += mod;
    return *this;
  }
  constexpr ModInt& operator*=(const ModInt& a){
    x = x * a.x % mod;
    return *this;
  }
  constexpr ModInt& operator/=(const ModInt& a){
    *this *= a.inv();
    return *this;
  }
  constexpr ModInt operator-() const {
    return ModInt(-x);
  }
  constexpr ModInt operator+(const ModInt& a) const {
    return ModInt(*this) += a;
  }
  constexpr ModInt operator-(const ModInt& a) const {
    return ModInt(*this) -= a;
  }
  constexpr ModInt operator*(const ModInt& a) const {
    return ModInt(*this) *= a;
  }
  constexpr ModInt operator/(const ModInt& a) const {
    return ModInt(*this) /= a;
  }
  constexpr ModInt operator++(){
    *this += ModInt(1);
    return *this;
  }
  constexpr ModInt operator++(int){
    ModInt old = *this;
    ++*this;
    return old;
  }
  constexpr ModInt operator--(){
    *this -= ModInt(1);
    return *this;
  }
  constexpr ModInt operator--(int){
    ModInt old = *this;
    --*this;
    return old;
  }
  constexpr bool operator==(const ModInt& a) const {
    return x == a.x;
  }
  constexpr bool operator!=(const ModInt& a) const {
    return x != a.x;
  }
  constexpr ModInt pow(int64 r) const {
    if(!r)return 1;
    ModInt res = pow(r>>1);
    res *= res;
    if(r & 1) res *= *this;
    return res;
  }
  constexpr ModInt inv() const {
    return pow(mod-2);
  }
  friend istream& operator>>(istream& is, ModInt& a){
    int64 t;
    is >> t;
    a = ModInt(t);
    return is;
  }
  friend ostream& operator<<(ostream& os, const ModInt& a){
    return os << a.x;
  }
};
using mint = ModInt<MOD>;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int64 n,k;
  cin >> n >> k;
  mint ans = 0;
  FOR(i,k,n+2){
    int64 l = (i - 1) * i / 2;
    int64 r = (2 * n - i + 1) * i / 2;
    ans += r - l + 1;
    // cout << i << " " << l << " " << r << endl;
  }
  ANS(ans);
  return 0;
}

Measured memory_bytes: 3648
#include <iostream>
using namespace std;
#include<string.h>
#include<set>
#include<stdio.h>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
#include <cstdio>
#include <cstdlib>
#include<stack>
#include<vector>
#define LL long long
const int MAX = 1e5+10;
LL n,m,x,y;
char a[55][55];
int main ()
{
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i]+1;
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            if(a[i][j]=='#')
            {
                if(a[i-1][j]=='.'&&a[i+1][j]=='.'&&a[i][j-1]=='.'&&a[i][j+1]=='.')
                {
                    cout<<"No"<<endl;
                    return 0;
                }
            }
        }
    }
    cout<<"Yes"<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <iostream>

using namespace std;
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

int main() {

	int n, k; cin >> n >> k;
	vector<int> a(n); for (int i = 0; i <= n - 1; i++) cin >> a[i];

	vector<bool> dp(k + 1, false);

	for (int i = 1; i <= k; i++) {
		for (auto j : a) {
			if (i - j >= 0) dp[i] = (dp[i] or !dp[i - j]);
		}
	}
	cout << ((dp[k]) ? "First" : "Second");

	return 0;
}

Measured memory_bytes: 3140
#include <iostream>

using namespace std;

int main()
{
 int a , b ;
 char op ;
 cin >> a>>op>>b ;
 if (a>=1 && a<= 1000000000)
  if (op!= '+' && op!='-')
    cout <<"Error " ;
  else if (op == '+')
    cout << a+b ;
  else if (op == '-')
    cout << a-b ;

  return 0 ;
}


Measured memory_bytes: 256