akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<sstream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<cfloat>
#include<functional>
#include<map>
#include<string>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<deque>
#include<set>
#include<bitset>
#include<list>
#include<numeric>
#include<complex>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<long long, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<long long, long long> ll_ll;
typedef pair<double, double> d_d;
typedef vector<int> Vint;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define rep2d(i, j, n) for(i = 0;i < n;++i)for(j = i + 1;j < n;++j)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define int4(v, x, y, z) int v, x, y, z; scanf("%d%d%d%d", &v, &x, &y, &z)
#define int5(v, w, x, y, z) int v, w, x, y, z; scanf("%d%d%d%d%d", &v, &w, &x, &y, &z)
#define scn(n, a) rep(i, n)cin >> a[i]
#define sc2n(n, a, b) rep(i, n)cin >> a[i] >> b[i]
#define pri(x) cout << x << "\n"
#define pri2(x, y) cout << x << " " << y << "\n"
#define pri3(x, y, z) cout << x << " " << y << " " << z << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define endl "\n"
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << x << "\n"
#define debug2(x, y) cout << " --- " << x << " " << y << "\n"
#define debug3(x, y, z) cout << " --- " << x << " " << y << " " << z << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)


int f[5] = {5, 7, 5, 7, 7};

signed main(void){
  int i, j, k;
  for(int testcase = 0;testcase >= 0;testcase++){
    int(n); if(!n)break;
    vector<string> s;
    s.resize(n); scn(n, s);

    bool fl = false;
    rep(i, n){
      int sum = 0, sp = 0;
      for(j = i;j < n;++j){
        sum += s[j].size();
        if(sum == f[sp]){
          sp++; sum = 0;
        }else if(sum > f[sp]){
          sum = 0; break;
        }
        if(sp >= 5){ fl = true; break; }
      }
      if(fl)break;
    }
    pri(i + 1);

//*/

//*/ break;
  }
  return 0;
}

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



int main()
{
  long long int n,k,i,j;
  cin>>n>>k;
  long long int h[n+1];
  vector <long long int>dp(n+1,100000000000);
  for(i=0;i<n;i++)
    cin>>h[i];
  dp[0]=0;
  dp[1]=abs(h[1]-h[0]);
  for(i=2;i<n;i++)
    if(i<k)
      for(j=0;j<i;j++)
        dp[i]=min(dp[i],dp[j]+abs(h[i]-h[j]));
    else
      for(j=0;j<=k;j++)
        dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
  cout<<dp[n-1]; 
}

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

typedef long long ll;
const int XD = 1002;
const ll mod = 1e9 + 7;
bool tab[ XD ][ XD ];
ll dp[ XD ][ XD ];

int main()
{
    ios_base::sync_with_stdio( false );
    int n, m; cin >> n >> m;
    for( int i = 1; i <= n; i++ )
    {
        for( int j = 1; j <= m; j++ )
        {
            char x; cin >> x;
            if( x == '.' ) tab[ i ][ j ] = true;
        }
    }
    dp[ 1 ][ 1 ] = 1;
    for( int i = 1; i <= n; i++ )
    {
        for( int j = 1; j <= m; j++ )
            if( tab[ i ][ j ] ) dp[ i ][ j ] += ( dp[ i ][ j - 1 ] + dp[ i - 1 ][ j ] ) % mod;
    }
    cout << dp[ n ][ m ];
    return 0;
}


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

int main(){
  while(1){
    int n;
    int a[100][100];
    cin>>n;
    if(n==0) break;
    lp(i,100){
      lp(k,100){
	a[i][k]=0;
      }
    }
    int w,h;
    cin>>w>>h;
    lp(i,n){
      int x,y;
      cin>>x>>y;
      a[x-1][y-1]=1;
    }
    int aw,ah;
    cin>>aw>>ah;
    w-=aw;
    h-=ah;
    int sum=0,ans=0;
    lp(i,w+1){
      lp(j,h+1){
	sum=0;
	lp(k,aw){
	  lp(l,ah){
	    sum+=a[i+k][j+l];
	  }
	}
	if(sum>ans) ans=sum;
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}



Measured memory_bytes: 3096
#include <cstdio>
#include <string>
#include <cmath>
#include <string>
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>
#include <iomanip>
#include <tuple>
#include <queue>
using namespace std;
typedef long long ll;
#define rep(i, a, n) for (int i=a;i<n;++i)
#define repeq(i, a, n) for(int i=a;i<=n;++i)
#define repi(m, itr) for (auto itr = m.begin();itr != m.end();++itr)
#define per(i, a, n) for (int i=n-1; i>=a;--i)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()

// 
int N, M, X, Y;
int x[110], y[110];
string ans = "War";

int main(){
    cin >> N >> M >> X >> Y;

    rep(i, 0, N){
        cin >> x[i];
    }
    rep(i, 0, M){
        cin >> y[i];
    }

    rep(i, X+1, Y+1){
        bool flg = false;
        rep(j, 0, N){
            if(x[j]>=i){
                flg = true;
            }
        }
        rep(j, 0, M){
            if(y[j]<i){
                flg = true;
            }
        }
        if(!flg){
            ans = "No War";
            break;
        }
    }

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




Measured memory_bytes: 256
W, H, N = gets.split.map(&:to_i)
xya_list = N.times.map { gets.split.map(&:to_i) }
min_x = 0
max_x = W
min_y = 0
max_y = H
xya_list.each do |(x, y, a)|
  case a
  when 1
    min_x = x if x > min_x
  when 2
    max_x = x if x < max_x
  when 3
    min_y = y if y > min_y
  when 4
    max_y = y if y < max_y
  end
end
ans = [max_x - min_x, 0].max * [max_y - min_y, 0].max
puts ans


Measured memory_bytes: 1788
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	k := getNextInt64(scanner)
	m := k % 50

	fmt.Fprintln(writer, 50)
	for i := int64(50); i > 0; i-- {
		if i+m == 50 {
			fmt.Fprint(writer, i+k/50-1)
		} else {
			fmt.Fprint(writer, i+k/50)
		}
		if i > 1 {
			fmt.Fprint(writer, " ")
		}
	}

	fmt.Fprintln(writer, "")

	writer.Flush()
}


Measured memory_bytes: 640
N, M, Q = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(Q)]


def dfs(x):
    if len(x) == N + 1:
        tmp = 0
        for i in range(Q):
            if x[X[i][1]] - x[X[i][0]] == X[i][2]:
                tmp += X[i][3]
        return tmp

    x.append(x[-1])
    res = 0
    while x[-1] <= M:
        res = max(res, dfs(x))
        x[-1] += 1
    x.pop()

    return res

print(dfs([1]))


Measured memory_bytes: 80036
def partition(A, p, r):
  x = A[r]
  i = p-1
  for j in range(p, r):
    if A[j] <= x:
      i += 1
      A[i], A[j] = A[j], A[i]
  A[i+1], A[r] = A[r], A[i+1]
  return i+1

n = int(input())
A = list(map(int, input().split()))
idx = partition(A, 0, n-1)

for i in range(n-1):
  if i != idx:
    print(A[i], end=" ")
  else:
    print("[%d]" %A[i], end=" ")
print(A[n-1])


Measured memory_bytes: 16388
function main(input) {
  input = input.trim().split("\n");
  const n = Number(input[0]);
  const as = input.slice(1).map(n => Number(n));
  const sortedAs = as.slice();
  sortedAs.sort((a, b) => a - b);
  const max = sortedAs[sortedAs.length - 1];
  const nextMax = sortedAs[sortedAs.length - 2];
  const result = [];
  for (const a of as) {
    if (a === max) {
      result.push(nextMax);
    } else {
      result.push(max);
    }
  }
  console.log(result.join("\n");
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 50520
#include<bits/stdc++.h>
#define ll long long
#define inf 0x3f3f3f3f
#define fi first
#define se second
#define pb push_back
#define mkp make_pair
#define pa pair<int,int>
const int N=1e6+10; 
const int mod=998244353;
using namespace std;

int dir[4][2]={0,1,1,0,0,-1,-1,0};
char a[1010][1010];
int vis[1010][1010]; 
int n,m;
int ok(int x,int y)
{
    if(x<1||x>n||y<1||y>m||vis[x][y]||a[x][y]=='#') return 0;
    return 1;
}
int main()
{
    cin>>n>>m;
    for(int i=1;i<=n;++i) scanf("%s",a[i]+1);
    queue<pa> q,qq; 
    int cc=0;
    for(int i=1;i<=n;++i)
        for(int j=1;j<=m;++j)
        {
            if(a[i][j]=='#') q.push(mkp(i,j)),++cc,vis[i][j]=1;
        }
    int ans=0;
    while(cc<n*m)
    {
        ans++;
        while(!q.empty())
        {
            int x=q.front().fi,y=q.front().se; q.pop();
            for(int i=0;i<4;++i)
            {
                int xx=x+dir[i][0];
                int yy=y+dir[i][1];
                if(ok(xx,yy))
                {
                    vis[xx][yy]=1;
                    a[xx][yy]='#';
                    cc++;
                    qq.push(mkp(xx,yy));
                }
            }
        }
        while(!qq.empty()) q.push(qq.front()),qq.pop();
    }
    printf("%d\n",ans);
return 0;
}
/*
*/

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


int main()
{
	ll K,A,B;
	cin>>K>>A>>B;
	if(A>=B-1||K<A+1) cout<<K+1<<endl;
	else
	{
		K-=A-1;
		cout<<B+(K/2-1)*(B-A)+K%2<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1000000000000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}

int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    ll n,l;cin>>n>>l;
    ll num=-1;
    ll ma=l-1;
    ll a[n];
    rep(i,0,n){
        cin>>a[i];
        if(i==0)continue;
        if(ma<a[i]+a[i-1]){
            ma=a[i]+a[i-1];
            num=i-1;
        }
    }
    if(num==-1){
        cout<<"Impossible"<<endl;
        return 0;
    }
    cout<<"Possible"<<endl;
    vector<ll> v;
    rep(i,num,n-1){
        v.push_back(i+1);
    }
    rrep(i,num,1)v.push_back(i);
    rep(i,0,v.size())cout<<v[v.size()-1-i]<<endl;
    
}


Measured memory_bytes: 2548
#include <stdio.h>
#include <assert.h>
int n,i,j,x,a[10][10],list[200][3],size;
void push(int x,int y,int s){list[size][0]=i;list[size][1]=j;list[size][2]=s;size++;}

int check(int x,int y,int s){
	int d;
	if(s<3 && (x<1 || x>9 || y<1 || y>9)) return 0;
	if(s==3 && (x<2 || x>8 || y<2 || y>8)) return 0;
	d=a[x][y];
	if(a[x-1][y]<d)d=a[x-1][y];
	if(a[x+1][y]<d)d=a[x+1][y];
	if(a[x][y-1]<d)d=a[x][y-1];
	if(a[x][y+1]<d)d=a[x][y+1];
	if(s==1 || d==0)return d;
	if(a[x-1][y-1]<d)d=a[x-1][y-1];
	if(a[x+1][y+1]<d)d=a[x+1][y+1];
	if(a[x+1][y-1]<d)d=a[x+1][y-1];
	if(a[x-1][y+1]<d)d=a[x-1][y+1];
	if(s==2 || d==0)return d;
	if(a[x-2][y]<d)d=a[x-2][y];
	if(a[x+2][y]<d)d=a[x+2][y];
	if(a[x][y-2]<d)d=a[x][y-2];
	if(a[x][y+2]<d)d=a[x][y+2];
	return d;
}

void draw(int x,int y,int s,int d){
	if(size==3 && (x<2 || x>8 || y<2 || y>8)) return;
	a[x][y]+=d;
	a[x-1][y]+=d;
	a[x+1][y]+=d;
	a[x][y-1]+=d;
	a[x][y+1]+=d;
	if(s==1)return;
	a[x-1][y-1]+=d;
	a[x+1][y+1]+=d;
	a[x+1][y-1]+=d;
	a[x-1][y+1]+=d;
	if(s==2)return;
	a[x-2][y]+=d;
	a[x+2][y]+=d;
	a[x][y-2]+=d;
	a[x][y+2]+=d;
}

int search(int nn,int from){
	int i,x,y,s,t;
	for(i=from;i>=0;i--){
		x=list[i][0];y=list[i][1];s=list[i][2];
		if(a[x][y]==0 && a[x+1][y]>0)return 0;
		if(x<8){if(s<3 && a[x+2][y]>0)return 0;}
		if(y==1 && s<2 && a[x+1][y-1]>0)return 0;
        if(y==8 && s<2 && a[x+1][y+1])return 0;
		t=check(x,y,s);
		if(t>0){
			draw(x,y,s,-t);
			for(;t>0;t--){
				//if(s==1 && a[x+1][y+1]>0 && check(x-1,y+1,3)==0){draw(x,y,s,+1);return 0;}
				if(nn-t>0){
					if(search(nn-t,i-1)>0){goto answer;}
				}else{
					int p,q;
					for(p=0;p<10;p++)for(q=0;q<10;q++){{if(a[p][q]!=0)goto miss;}}
					goto answer;
					miss:;
				}
				draw(x,y,s,+1);
			}
		}
	}
	return 0;

	answer:
	for(;t>0;t--)printf("%d %d %d\n",y,x,s);
	return 1;
}

int main(void){
	scanf("%d",&n);size=0;
	for(i=0;i<10;i++){for(j=0;j<10;j++){scanf("%d",&a[i][j]);}}
	for(i=1;i<9;i++){
		for(j=1;j<9;j++){
			x=check(i,j,1); if(x==0)continue; push(i,j,1);
			x=check(i,j,2); if(x==0)continue; push(i,j,2);
			x=check(i,j,3); if(x==0)continue; push(i,j,3);
		}
	}
	/*
	 if(a[i][j]>5){
	 fprintf(stderr,"%3d\n",n);
	 for(i=0;i<10;i++){for(j=0;j<10;j++){fprintf(stderr,"%3d",a[i][j]);}fprintf(stderr,"\n");}fprintf(stderr,"\n");
	 assert(0);
	 }*/
	//for(i=0;i<size;i++)printf("%d %d %d\n",list[i][0],list[i][1],list[i][2]);
	search(n,size-1);
	return 0;
}

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

using namespace std;

#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORD(i, m, n) for (int i = m; i >= n; --i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REP1(i, n) for (int i = 0; i <= n; ++i)
#define REPR(i, n) for (int i = n; i >= 0; --i)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

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

	string w;
	cin >> w;
	vector<int> sum(26, 0);
	REP(i, w.length())
	{
		sum[w[i] - 97]++;
	}
	bool ans = true;
	REP(i, 26)
	{
		if (sum[i] % 2 != 0)
			ans = false;
	}
	if (ans)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}


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

int MOD=1000000007;
int modpow(int a,int x){
  if(a<0)a+=MOD;
  int ans=1;
  while(x>0){
    if(x&1) ans=ans*a%MOD;
      a=a*a%MOD;
      x>>=1;
  }
  return ans;
}

int gyaku(int n){
    return modpow(n,MOD-2);
}

auto factor(int n){
  map<int,int>res;
  for(int i=2;i*i<=n;i++){
      for(; n%i==0;n/=i) res[i]++;
  }
  if(n>1)res[n]++;
  return res;
}
////////////////////////////////////////////////////////////
signed main() {
  int n;cin>>n;
  string a;
  cin>>a;
  vector<int>la(1+n);
  vector<int>lb(1+n);
  rep(i,n){
    if(a[i]==')'){la[i+1]=la[i]+1;lb[i+1]=lb[i];}
    else {lb[i+1]=lb[i]+1;la[i+1]=la[i];}
  }
  int l=0;
  rep(i,n+1)l=max(la[i]-lb[i],l);

  vector<int>ra(1+n);
  vector<int>rb(1+n);
  rep(i,n){
    if(a[n-1-i]==')'){ra[i+1]=ra[i]+1;rb[i+1]=rb[i];}
    else {rb[i+1]=rb[i]+1;ra[i+1]=ra[i];}
  }
  int r=0;
  rep(i,n+1)r=max(rb[i]-ra[i],r);
  rep(i,l)cout<<'(';
  cout<<a;
  rep(i,r)cout<<')';
}


Measured memory_bytes: 3616
#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 <set>
#include <cassert>
#include <string.h>

using namespace std;

int main()
{
	string s;
	cin >> s;
	
	int t1 = ((s[0] - 48) * 10) + (s[1]-48);
	int t2 = ((s[2] - 48) * 10) + (s[3]-48);
	
	int a = -1;
	int b = -1;
	
	if (t1>0 && t1<13) a = 1;
	else if ((t1>12 && t1<100) || (t1 == 0)) a = 0;
	
	if (t2>0 && t2<13) b = 1;
		else if ((t2>12 && t2<100) || (t2 == 0)) b = 0;
		
		
	if (a == 1 && b == 0) cout << "MMYY" <<endl;
	else if ((a == 0) && (b == 1)) cout<< "YYMM" <<endl;
	else if((a == 1) && (b == 1)) cout<<"AMBIGUOUS" <<endl;
	else cout<<"NA" <<endl;
	
	
	
	
	
	
	
	
	
	
		
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;
const int N = 10;
int g[N][N];
char g2[N][N];
int  ans1=0;
int  ans2=0;
int ans3=0;
int u[N][N];
int main()
{
	ans1=ans2=ans3=0;
	int h, w, k;
	scanf("%d%d%d", &h, &w, &k);
ans1=ans2=ans3=0;
	for (int i = 0; i < h; ++i) scanf("%s", g2 + i);
ans1=ans2=ans3=0;
	int sum = 0;
	for(int i = 0; i < h; ++i)
		for (int j = 0; j < w; ++j)
		{ans1=ans2=ans3=0;
			if (g2[i][j] == '#')
			{ans1=ans2=ans3=0;
				g[i][j] = 1;ans1=ans2=ans3=0;
				++sum;ans1=ans2=ans3=0;
			}
			else
				g[i][j] = 0;
		}
ans1=ans2=ans3=0;
	int res = 0;
	for (int i = 0; i < (1 << h); ++i)
	{ans1=ans2=ans3=0;
		vector<int> v1;
		for (int k = 0; k < h; ++k)
		{ans1=ans2=ans3=0;
			if ((i >> k) & 1)
				v1.push_back(k);
		}
		for (int j = 0; j < (1 << w); ++j)
		{ans1=ans2=ans3=0;
			vector<int> v2;
			for (int k = 0; k < w; ++k)
			{ans1=ans2=ans3=0;
				if ((j >> k) & 1)
					v2.push_back(k);
			}
ans1=ans2=ans3=0;
			for (int i = 0; i < h; ++i)
				for (int j = 0; j < w; ++j)
				{ans1=ans2=ans3=0;
					u[i][j] = g[i][j];
				}
			for (int i = 0; i < v1.size(); ++i)
			{ans1=ans2=ans3=0;
				for (int j = 0; j < w; ++j)
					u[v1[i]][j] = 0;
			}
ans1=ans2=ans3=0;
			for (int i = 0; i < v2.size(); ++i)
			{ans1=ans2=ans3=0;
				for (int j = 0; j < h; ++j)
					u[j][v2[i]] = 0;
			}
			ans1=ans2=ans3=0;
			int c = 0;
			for(int i = 0; i < h; ++i)
				for (int j = 0; j < w; ++j)
				{ans1=ans2=ans3=0;
					if (u[i][j] == 1)
						++c;
				}
			if (c == k)
			{ans1=ans2=ans3=0;
				++res;
			}
		}
	}
ans1=ans2=ans3=0;
	printf("%d\n", res);


	return 0;
}


Measured memory_bytes: 3780
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <utility>
#include <string>
#include <cmath>
#include <set>
#include <functional>
#include <map>
#include <queue>
#include <stack>
#include <iomanip>
#include <climits>
#include <unordered_map>
#include <numeric>
#include <cstring>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; ++i)
#define show(x) cout << #x << " = " << x << endl;
typedef long long ll;
typedef pair<int,int> pii;
int main(){
    int h,w;
    cin >> h >> w;
    int a[500][500];
    int cnt = 0;
    vector<pii>c,d;
    rep(i,h)rep(j,w)cin >> a[i][j];
    rep(i,h)rep(j,w-1){
        if(a[i][j]%2){
            cnt++;
            c.push_back(pii(i,j));
            d.push_back(pii(i,j+1));
            a[i][j+1]++;
        }
    }
    rep(i,h-1){
        if(a[i][w-1]%2){
            cnt++;
            c.push_back(pii(i,w-1));
            d.push_back(pii(i+1,w-1));
            a[i+1][w-1]++;
        }
    }
    cout << cnt << endl;
    rep(i,cnt){
        cout << c[i].first+1 << " " << c[i].second+1 << " " << d[i].first+1 << " " << d[i].second+1 << endl;
    }
}


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

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

using namespace std;

using ll = long long;
using P = pair<int, int>;

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

  string s = to_string(n);
  char first = s[0];
  int result = 9 * (s.size() - 1);
  bool all9 = true;
  for (int i = 1; i < s.size(); i++) {
    if ((s[i] - '0') != 9) {
      all9 = false;
      break;
    }
  }
  if (all9) {
    result += (first - '0');
  } else {
    result += (first - '0') - 1;
  }
  cout << result << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 
 using namespace std;
 
 int main()
 {
   int arr[3];
   cin>>arr[0]>>arr[1]>>arr[2];
   sort(arr,arr+3);
   cout<<arr[0]<<" "<<arr[1]<<" "<<arr[2]<<endl;
   //while(1);
   return 0;
 }
 

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

using namespace std;
#define MP make_pair
typedef pair<string, string> SP;
set<SP> st;
multiset<SP> s;
string t[100][10];
vector<SP> v;
int k[100];

int main() {
	int n, f;

	cin >> n >> f;
	for (int i = 0; i < n; i++) {
		cin >> k[i];
		for (int j = 0; j < k[i]; j++) {
			cin >> t[i][j];
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < k[i] - 1; j++) {
			for (int l = j + 1; l < k[i]; l++) {
				SP a;
				if (t[i][j] > t[i][l]) a = MP(t[i][l], t[i][j]);
				else a = MP(t[i][j], t[i][l]);
				s.insert(a);
				st.insert(a);
			}
		}
	}

	int ans = 0;
	set<SP>::iterator si;
	for (si = st.begin(); si != st.end(); si++) {
		SP key = *si;
		if (s.count(key) >= f) {
			v.push_back(key);
			ans++;
		}
	}

	cout << v.size() << endl;
	for (int i = 0; i < v.size(); i++) {
		cout << v[i].first << ' ' << v[i].second << endl;
	}
	return 0;
}


Measured memory_bytes: 3860
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const double PI=acos(-1);

template<typename T>
istream& operator>> (istream& is, vector<T> &vec){
    for(T& x: vec) is >> x;
    return is;
}

char field[300][300];
ll flist[300][300];

int main(){
    ll h, w, k; cin >> h >> w >> k;
    rep(i, h) rep(j, w) cin >> field[i][j];
    fill(flist[0], flist[100], 0);
    ll cnt = 0;
    rep(i, h){
        rep(j, w){
            if(field[i][j] == '#'){
                cnt++;
                flist[i][j] = cnt;
                continue;
            }
            if(j != 0 && flist[i][j-1] != 0) flist[i][j] = flist[i][j-1];
        }
        for(ll j = w-1; j >= 0; --j){
            if(j != w-1 && flist[i][j] == 0 && flist[i][j+1] != 0) {
                flist[i][j] = flist[i][j+1];
            }
        }
    }
    rep(j, w){
        rep(i, h){
            if(i != 0 && flist[i][j] == 0 && flist[i-1][j] != 0){
                flist[i][j] = flist[i-1][j];
            }
        }
        for(ll i = h-1; i >= 0; --i){
            if(i != h-1 && flist[i][j] == 0 && flist[i+1][j] != 0){
                flist[i][j] = flist[i+1][j];
            }
        }
    }
    rep(i, h){
        rep(j, w){
            if(j > 0) cout << " ";
            cout << flist[i][j];
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 4460
#include <bits/stdc++.h>
#define ll long long
#define EPS 1e-9
#define rank asadf
using namespace std;

const int MAXN = 3e5 + 111;
const int MOD = 1e9 + 7;



int main() {
#ifdef LOCAL
    freopen("xxx.in", "r", stdin);
    freopen("xxx.out", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, x, t;
    cin >> n >> x >> t;
    cout << ((n + x - 1) / x) * t;
    return 0;
}

Measured memory_bytes: 3648
#include <stdio.h>
#include <string.h>

int main(void)
{
	int i, m, h, len;
	char cards[201], temp[201];
	
	while(1) {
		scanf("%s",cards);
		if(strcmp(cards,"-") == 0) break;
		len = strlen(cards);
		scanf("%d",&m);
		for (i=0; i<m; i++) {
			scanf("%d",&h);
			strcpy(temp,cards);
			strcpy(cards,&temp[h]);
			strncpy(&cards[len - h],temp,h);
			cards[len] = '\0';
		}
		printf("%s\n",cards);
	}
	return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
/*
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds; 
//order_of_key(k)= # of items strictly smaller than 'k'  //find_by_order(x)= iterator to x'th largest element (counting from ZERO) //erase("iterator") [log(n)] //end(<name>)
//os.find_by_order(os.order_of_key(x)=iterator to 'x' in the rb tree
template<class T> using ordered_set = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/
//#pragma GCC optimization ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC target ("avx2")
//#pragma GCC optimize ("O3")
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);

typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef pair<ll,ll> pi;
typedef priority_queue<ll> pq;                                        //min-heap-> multiply the values by '-1'
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define forr(i,a,b) for (ll i = a; i < b; i++)
#define test ll t;cin>>t;while(t--)
#define summ(a,n) accumulate(a,a+n,0)
#define bsrch(v,n) lower_bound(v.begin(), v.end(), n)
#define minindex(v) distance(v.begin(),min_element(v.begin(),v.end()))         //returns index of minimum(/max) element in the vector
#define bp(x) _builtin_popcount(x)
#define inf 1000000000000
#define PI = 3.1415926535897932384626
#define mod 1000000007

ll dp[101][100001];

int main()
{
    ll n,w; cin>>n>>w;
    ll v[n+1], wt[n+1];
    forr(i,1,n+1) cin>>wt[i]>>v[i];
    
    forr(i,1,n+1)
        forr(j,1,w+1)
        {
            if(j<wt[i]) dp[i][j]=dp[i-1][j];
            else dp[i][j]=max(v[i]+dp[i-1][j-wt[i]],dp[i-1][j]);
        }
    cout<<dp[n][w];
}

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

#define INF ((1<<30)-1)
#define LLINF (1LL<<60)
#define EPS (1e-10)

int main() {
    vector<int> a(5);
    rep(i, 5) cin >> a[i];
    rep(i, 5) {
        if (a[i] == 0) {
            cout << i+1 << endl;
        }
    }
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  vector<long long> v(n);
  for(int i=0;i<n;i++)
    cin>>v[i];
    vector<vector<long long> > v1(n,vector<long long>(n));
    for(int i=0;i<n-1;i++)
    {
        v1[i][i]=v[i];
        v1[i][i+1]=max(v[i]-v[i+1],v[i+1]-v[i]);
    }
    v1[n-1][n-1]=v[n-1];
    for(int i=2;i<n;i++)
    {
        for(int j=0;j<n-i;j++)
        {
            v1[j][j+i]=max(v[j]-v1[j+1][j+i],v[j+i]-v1[j][j+i-1]);
        }
    }
    cout<<v1[0][n-1]<<endl;
  return 0;
}


Measured memory_bytes: 73728
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"

bool solve(string st) {
	int sum = 0;
	for (int i = 0; i < 11; ++i) {
		int n = 11 - i;
		if (n >= 7) {
			sum += (st[i] - '0')*(n - 5);
		}
		else {
			sum += (st[i] - '0')*(n + 1);
		}
	}
	sum %= 11;
	sum = 11 - sum;
	if (sum ==10||sum==11)sum = 0;
	return sum==st[11]-'0';
}

int main() {
	string st; cin >> st;
	int a = st.find('?');
	vector<int>anss;
	for (int i = 0; i < 10; ++i) {
		st[a] = '0' + i;
		if (solve(st))anss.push_back(i);
		st[a] = '?';
	}
	if (anss.size() >= 2)cout << "MULTIPLE" << endl;
	else cout << anss[0] << endl;
	return 0;
}

Measured memory_bytes: 3184
*D, = open(0)
n, k = map(int, D[0].split())
s = D[1]
ret = []
for i, it in enumerate(s):
    if i == k-1:
        c = s[i].lower()
    else:
        c = s[i]
    ret.append(c)
print(''.join(ret))

Measured memory_bytes: 3060
n=int(input())
c=list(input())
 
rj=c.count('R')
wj=0
mini=rj
for i in range(n):
  if c[i]=='R':
    rj-=1
  else:
    wj+=1
  mini=min(mini,max(rj,wj))
  
print(mini)

Measured memory_bytes: 81632
#include<stdio.h>

int main(void)
{
	long n,k,copy;
	int i;

	scanf("%ld %ld",&n,&k);

	copy=n%k;

	if(copy<k-copy){
		printf("%ld\n",copy);
	}
	else printf("%ld\n",k-copy);

	return 0;
}



Measured memory_bytes: 1660
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stdio.h>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <math.h>
#include <iomanip>
using namespace std;
#define Would
#define you
const int INF = 999999999;
const int MOD = 1e9 + 7;
const double pi = 3.141592653589793238;

int main() {
	int cou = 1;
	while (1) {
		int n;
		cin >> n;
		if (n == 0) { break; }
		cout << "Case " << cou << ": " << n << endl;
		++cou;
	}
}


Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
#include <math.h>


int main(void) {
  int n, i, j;
  int pn[200000];
  char str_n[7];
  char str_pn[7];
  int min=200000;
  int ans=0;
  int dig;
  int top, middle, bottom;
  int temp;
  int dig_a, dig_b;
  int i_dig;
  int c[10][10];
  
  
  
  //printf("%d", (int)log10(9));
  scanf("%s", str_n);
  n = atoi(str_n);
  dig = (int)log10(n);


  bottom = n%10;
  top=n;
  for(i=0; i<dig; i++) {
    top = top/10;
  }  
  middle = (n - bottom - top*(int)pow(10,dig))/10;

  if(dig==0) {
    printf("%d\n", n);
  } else {
    for(i=1; i<10; i++) {
      for(j=1; j<=i; j++) {
        //printf("i: %d j: %d", i, j);
        c[i][j] = 0;
        c[j][i] = 0;
        if(i==j) {
          c[i][j] += 1;
          c[j][i] += 1;
        }
        //printf(" ; %d", c[i][j]);
        for(i_dig=1; i_dig<dig; i_dig++) {
          c[i][j] += (int)pow(10, i_dig-1);
          c[j][i] += (int)pow(10, i_dig-1);
        }
        //printf(" ; %d", c[i][j]);
        temp = top*10+bottom;
        if(top > i) {
          c[i][j] += (int)pow(10, (dig-1));
        } else if(top < i) {
          c[i][j] += 0;
        } else if(bottom > j) {
          c[i][j] += middle+1;
        } else if(bottom < j){
          c[i][j] += middle;
        } else {
          c[i][j] += middle+1;
        }
        if(top > j) {
          c[j][i] += (int)pow(10, (dig-1));
        } else if(top < j) {
          c[j][i] += 0;
        } else if(bottom > i) {
          c[j][i] += middle+1;
        } else if(bottom < i){
          c[j][i] += middle;
        } else {
          c[j][i] += middle+1;
        }
        //printf(" ; %d\n", c[i][j]);
        if(i==j) {
          c[i][j] /= 2;
        }
      }
    }
    for(i=1; i<10; i++) {
      for(j=1; j<10; j++) {
        ans += c[i][j] * c[j][i];
       }
    }  
    printf("%d\n", ans);
  }

  return 0;

}

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

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		int matrix[][] = new int[n + 1][n + 1];

		for(int i = 0; i <= n; i++){
			Arrays.fill(matrix[i], 1);
		}

		for(int i = 0; i < (n + 1) / 2; i++){
			if(n % 2 == 1){
				matrix[i + 1][n - i - 1] = 0;
			}
			else{
				matrix[i + 1][n - i] = 0;
			}
		}

		int count = 0;
		String result = "";
		for(int i = 1; i <= n; i++){
			for(int j = i + 1; j <= n; j++){
				if(matrix[i][j] != 0){
					count++;
					result += i+" "+j + "\n";
				}
			}
		}

		System.out.println(count);
		System.out.print(result);
	}
}


Measured memory_bytes: 45276
package main

import (
	"fmt"
)

func main() {

	var N, K int
	fmt.Scanf("%d %d", &N, &K)

	A := make([]int, N)

	for i := 0; i < N; i++ {
		fmt.Scanf("%d", &A[i])
		if i >= K {
			if A[i-K] < A[i] {
				fmt.Println("Yes")
			} else {
				fmt.Println("No")
			}
		}
	}

}


Measured memory_bytes: 6496
import java.util.*;
import java.io.*;

public class Main {
   public static void main(String[]abc) {
      Main ans = new Main();
      long solution = ans.solve();
      System.out.println(solution);
   }
  
   private long solve() {
      Scanner sc = new Scanner(System.in);
      int N = sc.nextInt();
      int [] dp = new int[3];
      int best_a=0, best_b=0, best_c=0;
      for(int i=0;i<N;i++){
		    best_a = sc.nextInt();
            best_b = sc.nextInt();
            best_c = sc.nextInt(); 
         if (i!=0) {
            best_a = best_a+ Math.max(dp[1], dp[2]);
            best_b = best_b+ Math.max(dp[0], dp[2]);
            best_c = best_c+ Math.max(dp[1], dp[0]);
         }
         dp[0] = best_a;
         dp[1] = best_b;
         dp[2] = best_c;        
      }
      return Math.max(dp[0], Math.max(dp[1], dp[2]));
      
   }
}


Measured memory_bytes: 58880
#include<bits/stdc++.h>
typedef long long i64;
const int N=2e5+7;
int n,m;
int col[N],t[5],odd=0,p1,p2,s1[N],on[N];
i64 abs(i64 x){return x>0?x:-x;}
struct edge{
	int to,nx;
}e[N*2];
int e0[N],ep=2,fa[N];
void f1(int w,int c){
	++t[col[w]=c];
	s1[w]=3-c*2;
	for(int i=e0[w];i;i=e[i].nx){
		int u=e[i].to;
		if(!u)continue;
		if(!col[u]){
			fa[u]=w;
			e[i^1].to=0;
			f1(u,c^3);
			s1[w]+=s1[u];
		}else{
			e[i].to=e[i^1].to=0;
			odd=col[w]==col[u];
			p1=w,p2=u;
		}
	}
}
i64 s=0;
int ps[N],pp=0;
void tree_cal(){
	for(int i=2;i<ep;++i){
		int u=e[i].to;
		if(u)s+=abs(s1[u]);
	}
}
i64 solve(){
	scanf("%d%d",&n,&m);
	if(n&1)return -1;
	for(int i=1,a,b;i<=m;++i){
		scanf("%d%d",&a,&b);
		e[ep]=(edge){b,e0[a]};e0[a]=ep++;
		e[ep]=(edge){a,e0[b]};e0[b]=ep++;
	}
	f1(1,1);
	if(n>m){
		if(t[1]!=t[2])return -1;
		tree_cal();
	}else if(odd){
		int a=(t[2]-t[1])/2;
		s+=abs(a);
		for(int w=p1;w;w=fa[w])s1[w]+=a;
		for(int w=p2;w;w=fa[w])s1[w]+=a;
		tree_cal();
	}else{
		if(t[1]!=t[2])return -1;
		for(int w=p1;w!=p2;w=fa[w])on[w]=1;
		ps[pp++]=0;
		for(int i=2;i<ep;++i){
			int u=e[i].to;
			if(u){
				if(on[u])ps[pp++]=s1[u];
				else s+=abs(s1[u]);
			}
		}
		std::nth_element(ps,ps+pp/2,ps+pp);
		for(int i=0;i<pp;++i)s+=abs(ps[i]-ps[pp/2]);
	}
	return s;
}
int main(){
	printf("%lld\n",solve());
	return 0;
}

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

int main() {
  int N,A,Min,num;
  cin >> N;
  Min = 30;
  
  rep(i, N){
    cin >> A;
    num = 0;
    rep(j,30){
      if(A % 2 == 0){
        A /= 2;
        num += 1;
      }
      else
        break;
    }
    if(num < Min)
      Min = num;
  }
  cout << Min << endl;
}


Measured memory_bytes: 3608
import java.util.*;
import java.lang.*;

public class Main {

    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int ans = 0;

        Dice dice = new Dice(sc.nextInt(),
                             sc.nextInt(),
                             sc.nextInt(),
                             sc.nextInt(),
                             sc.nextInt(),
                             sc.nextInt());
        
        //String s = sc.next();
        int qnum = sc.nextInt();
        
        
        
        for (int i = 0; i < qnum; i++) {
            ans = dice.identify(sc.nextInt(), sc.nextInt());
            System.out.println(ans);
        }
    }
}

class Dice {
    //int[] newsurf = new int[6];
    String commands;
    int[] surface = new int[6];
    Dice(int a, int b, int c, int d, int e, int f) {
        //commands = s;
        surface[0] = a;
        surface[1] = b;
        surface[2] = c;
        surface[3] = d;
        surface[4] = e;
        surface[5] = f;
    }
    
    /*
    int step() {
        for (int i = 0; i < commands.length(); i++) {
            char command = commands.charAt(i);
            if (command == 'N') {
                int[] array = {1, 5, 2, 3, 0, 4};
                setNew(array);
            } else if (command == 'S') {
                int[] array = {4, 0, 2, 3, 5, 1};
                setNew(array);
            } else if (command == 'E') {
                int[] array = {3, 1, 0, 5, 4, 2};
                setNew(array);
            } else if (command == 'W') {
                int[] array = {2, 1, 5, 0, 4, 3};
                setNew(array);
            }
            
            for(int j = 0; j < 6; j++) {
                oldsurf[j] = newsurf[j];
            }
        }
        return newsurf[0];
    }
    
    
    void setNew(int[] array) {
        for (int i = 0; i < 6; i++) {
            newsurf[i] = oldsurf[array[i]];
        }
    }
     */
    
    int identify(int t, int f) {
        
        int[][] ring = {{3, 1, 2, 4, 3},
                        {0, 3, 5, 2, 0},
                        {0, 1, 5, 4, 0},
                        {0, 4, 5, 1, 0},
                        {0, 2, 5, 3, 0},
                        {2, 1, 3, 4, 2}};
        
        for (int i = 0; i < 6; i++) {
            for (int j = 0; j < 4; j++) {
                if (surface[ring[i][j]] == t &&
                    surface[ring[i][j + 1]] == f) {
                    return surface[i];
                }
            }
        }
        return -1;
    }
}



Measured memory_bytes: 26180
x, k, d = gets.chomp.split(' ').map(&:to_i)

if x < 0
  x = -x
end

if x / d > k
  x -= k * d
  puts x
else
  s = x / d
  x -= d * s
  k -= s

  if k % 2 == 0
    puts x
  else
    puts (x - d).abs
  end
end


Measured memory_bytes: 14376
void main()
{
    auto S = rs;
    auto ltarr = new int[](S.length); // <
    auto gtarr = new int[](S.length); // >

    ltarr[0] = S[0] == '<' ? 1 : 0;
    foreach (i; 1 .. S.length)
    {
        if (S[i] == '<')
            ltarr[i] = ltarr[i - 1] + 1;
        else
            ltarr[i] = 0;
    }

    gtarr[$ - 1] = S[$ - 1] == '>' ? 1 : 0;
    foreach_reverse (i; 0 .. S.length - 1)
    {
        if (S[i] == '>')
            gtarr[i] = gtarr[i + 1] + 1;
        else
            gtarr[i] = 0;
    }
    debug gtarr.writeln;
    debug ltarr.writeln;

    ulong res;
    res += gtarr[0];
    foreach (i; 1 .. S.length)
    {
        res += max(ltarr[i - 1], gtarr[i]);
    }
    res += ltarr[$ - 1];
    res.writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T)
{
    return readln.chomp.to!T;
}

T readAs(T)() if (isArray!T)
{
    return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T)
{
    auto res = new T[][](height, width);
    foreach (i; 0 .. height)
    {
        res[i] = readAs!(T[]);
    }
    return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T)
{
    auto res = new T[][](height, width);
    foreach (i; 0 .. height)
    {
        auto s = rs;
        foreach (j; 0 .. width)
            res[i][j] = s[j].to!T;
    }
    return res;
}

int ri()
{
    return readAs!int;
}

long rl()
{
    return readAs!long;
}

double rd()
{
    return readAs!double;
}

string rs()
{
    return readln.chomp;
}


Measured memory_bytes: 7440
#include <bits/stdc++.h>
using namespace std;
 
#define FOR(i,l,r) for(int i = (int) (l);i < (int) (r);i++)
#define ALL(x) x.begin(),x.end()
template<typename T> bool chmax(T& a,const T& b){ return a < b ? (a = b,true) : false; }
template<typename T> bool chmin(T& a,const T& b){ return b < a ? (a = b,true) : false; }
typedef long long ll;
 
struct FenwickTree{
	int n;
	vector<ll> dat;
	FenwickTree(int _n) :n(_n),dat(_n + 1,0ll){}
	FenwickTree(int _n,ll val) :n(_n),dat(_n + 1,0ll){
		for(int i = 0;i < n;i++) update(i,val);
	}
	void update(int idx,ll val){
		for(idx++;idx <= n;idx += idx & -idx) dat [idx] += val;
	}
	ll query(int l,int r){
		ll res = 0;
		for(;r;r -= r & -r) res += dat [r];
		for(;l;l -= l & -l) res -= dat [l];
		return res;
	}
};
 
int N,M;
 
bool comp(const pair<int,int>& a,const pair<int,int>& b)
{
	return a.second - a.first < b.second - b.first;
}
 
int main()
{
	scanf("%d%d",&N,&M);
	vector< pair<int,int> > A(N);
	FOR(i,0,N){
		scanf("%d%d",&A [i].first,&A [i].second);
	}
	sort(ALL(A),comp);
 
	FenwickTree ft(M + 1);
	int idx = 0;
	FOR(i,1,M + 1){
		while(idx < N && A [idx].second - A [idx].first < i){
			ft.update(A [idx].first,1);
			ft.update(A [idx].second + 1,-1);
			idx++;
		}
		int ans = N - idx;
		for(int j = 0;j <= M;j += i){
			ans += ft.query(0,j + 1);
		}
		printf("%d\n",ans);
	}
 
	return 0;
}

Measured memory_bytes: 4096
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<numeric>
#include<algorithm>
#include<tuple>
#include<cmath>

typedef unsigned long long ll;

ll DENOM = 1000000000LL + 7LL;
using namespace std;

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    ll al = 0;
    for (int i=0; i<n; ++i){
        cin >> a[i];
        al = al ^ a[i];
    }
    for (int i=0; i<n; ++i){
        cout << (al ^ a[i]) << ' ';
    }
    cout << endl; 
}

Measured memory_bytes: 4348
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();
    if((A==B & A!=C) || (A==C & A!=B) || (C==B & B!=A)){
      System.out.println("Yes");
    }else{
       System.out.println("No");
    }
  }
}


Measured memory_bytes: 35888
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

void _main() {
  string S, T;
  cin >> S >> T;
  int ssize = S.size();

  rep(i, 0, ssize) {
    bool f_ok = true;
    rep(j, 0, ssize) {
      if (S[i+j] != T[j]) {
        f_ok = false;
        break;
      }
    }
    if (f_ok) {
      cout << "Yes" << "\n";
      return;
    }
    S += S[i];
  }

  cout << "No" << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define iter(it,a) for(auto it=a.begin();it!=a.end();it++)
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define endl '\n'
#define preturn(X) cout<<X<<endl; return 0
typedef long long ll;



int count1[51]; 

int main(){
    cin.tie(0);ios_base::sync_with_stdio(0);
    int n,m;
    cin>>n>>m;
    int a,b;    
    rep(i,0,m){
        cin>>a>>b;
        count1[a]++;
        count1[b]++;
    }
    rep(i,1,n+1){
        cout<<count1[i]<<" ";
    }
    cout<<endl;
}


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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> void chmax(t&a,u b){if(a<b)a=b;};
template<class t, class u> void chmin(t&a,u b){if(a>b)a=b;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  vll f(1E4+10, 0);

  for(ll x=1; x<=1E2; ++x){
    for(ll y=1; y<=1E2; ++y){
      for(ll z=1; z<=1E2; ++z){
        ll tmp = x*x + y*y + z*z + x*y + y*z + z*x;
        if(tmp<1E4+10){
          f[tmp]++;
        }
      }
    }
  }

  ll N;
  IN(N);

  for(ll i=1; i<=N; ++i){
    printf("%lld\n", f[i]);
  }


  return 0;
}

Measured memory_bytes: 3824
#include <bits/stdc++.h>
#define _for(i,a,b) for(int i=(a),_b=(b);i<_b;++i)

using namespace std;
typedef long long ll;
const ll mod=1000000007;

const int maxn=21;
int a[maxn][maxn];
int n;
int _log[(1<<maxn)];
void enter()
{
    cin>>n;
    _for(i,0,n)
        _for(j,0,n) cin>>a[i][j];
    _for(i,0,n)
        _log[(1<<i)]=i;
}
ll f[maxn][(1<<maxn)];
bool _d[maxn][(1<<maxn)];
ll qhd(int i,int j)
{
    if (i==0 )
    {
        if (j!=0 && a[i][_log[j]]==1)
            return ll(1);
        else return ll(0);
    }
    else if (_d[i][j]==true) return f[i][j];
    else
    {
        _for(z,0,n)
        {
            if ( a[i][z]==1 && ((1<<z)&j)!=0)
                f[i][j]+=qhd(i-1, j^(1<<z));
            f[i][j]=f[i][j]%mod;
        }
        _d[i][j]=true;
        return f[i][j];
    }
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie();
    cout.tie();
    enter();
    cout<<qhd(n-1, (1<<n)-1);
}


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

int main() {
    ll N, A, B;
    cin >> N >> A >> B;
    ll ans = 0;
    if (A + B <= N)
    {
        ans = (N / (A + B)) * A + ((N % (A + B)) >= A ? A: (N % (A + B)));
    } else
    {
        ans = (A >= N ? N: A);
    }
    cout << ans << endl;
    
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
    string a,b;
    cin >> a;
    cin >> b;
    int count = 0;
    for (int i=0;i<=a.size();i++){
        if (a[i]!=b[i]){
            count++;

        }

    }
    cout << count;
}


Measured memory_bytes: 3416
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#define my_abs(x) ((x) < 0 ? -(x) : (x))
#define mp std::make_pair
#define pb push_back
#define MOD 998244353
typedef long long ll;
ll C[4005][4005];
int main()
{
	// freopen("ARC102-E.in", "r", stdin);
	for (int i = 0; i <= 4000; i++)
	{
		C[i][0] = 1;
		for (int j = 1; j <= i; j++)
			C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % MOD;
	}
	int k, n;
	scanf("%d%d", &k, &n);
	for (int i = 2; i <= k << 1; i++)
	{
		ll ans = 0, cur = 1;
		int cnt = std::max(std::min(i >> 1, k) - std::max(i - k, 1) + 1, 0), x = k - (cnt << 1);
		// printf("%d %d %d\n", i, cnt, x);
		// fflush(stdout);
		for (int j = 0; j <= cnt; j++)
		{
			(ans += C[cnt][j] * cur % MOD * C[n + x - 1][x + j - 1]) %= MOD;
			cur = cur * 2 % MOD;
		}
		printf("%lld\n", ans);
	}
	return 0;
}


Measured memory_bytes: 123776
import bisect
from operator import itemgetter
import math
import functools
import itertools
import numpy as np
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N,M = IL()
a = [I() for i in range(M)]

dp = [0]*(N+1)
dp[0] = 1

for i in a:
  dp[i] = -1

for i in range(N+1):
  if dp[i] == -1:
    continue
  if i+1 <= N:
     if dp[i+1] != -1:
      dp[i+1] += dp[i]%mod
  if i+2 <= N:
    if dp[i+2] != -1:
      dp[i+2] += dp[i]%mod

print(dp[N]%mod)

Measured memory_bytes: 17144