akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, a, b) for(int i = (a); i <= (b); i++)
#define PER(i, a, b) for(int i = (a); i >= (b); i--)
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define all(S) (S).begin(), (S).end()
#define pb push_back
#define mk make_pair
#define S second
#define F first
typedef long long ll;
typedef long double lf;
typedef pair<int, int> ii;
const int MAX = 55;
int N, K, a[MAX];
ll pd[MAX][MAX][MAX*MAX];
ll ans;

ll solve(int i, int k, int s) {
    if(s < 0 || k < 0) return 0;
    if(i == N && s|k) return 0;
    if(i == N) return 1;
    ll &ans = pd[i][k][s];
    if(ans != -1) return ans;
    return ans = solve(i+1, k-1, s-a[i]) + solve(i+1, k, s);
}

int main(int argc, char ** argv) {
    scanf("%d%d", &N, &K);
    rep(i, 0, N) scanf("%d", a+i);
    memset(pd, -1, sizeof pd);
    REP(i, 1, N) ans += solve(0, i, i*K);
    printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 75320
/*input
2
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=505;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}

ll g[maxn][maxn];

vector<int> a,b;

ll lcm(ll a,ll b){
	if(a==0||b==0) return a+b;
	return a*b/__gcd(a,b);
}
bool isp[300000]={0};
vector<int> p;

int main()
{
	IOS;


	for(int i=2;i<300000;i++){
		if(!isp[i]) p.pb(i);
		for(int j=0;i*p[j]<300000;j++){
			isp[i*p[j]]=1;
			if(i%p[j]==0) break;
		}
	}
	REP(i,500) a.pb(p[i]);
	REP(i,500) b.pb(p[i+500]);

	REP(i,500) REP(j,500) if((i+j)%2==0){
		g[i][j]=1;
		g[i][j]*=a[(i+j)/2];
		g[i][j]*=b[(i-j+499)/2];
	}

	REP(i,500) REP(j,500) if((i+j)%2){
		g[i][j]=1;
		g[i][j]*=a[(i+j-1)/2];
		g[i][j]*=a[(i+j+1)/2];
		if(i-j+499+1<1000)g[i][j]*=b[(i-j+499+1)/2];
		if(i-j+499-1>=0) g[i][j]*=b[(i-j+499-1)/2];
		g[i][j]++;
		//assert(g[i][j]<1e15);
	}
	int n;
	cin>>n;
	REP(i,n) REP(j,n) cout<<g[i][j]<<" \n"[j==n-1];

	REP(i,n) REP(j,n-1) assert(max(g[i][j],g[i][j+1])%min(g[i][j],g[i][j+1])==1);

	return 0;
}


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

int main(){
    int N;
    int R;
    int X;
    cin >> N >> R;

    if(N > 9){
        cout << R;
    }
    else{
        X = R + 100 * (10 - N);
        cout << X;
    }


}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

const ll mod = 1e9+7;
struct mint {
    ll x;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};

int main(){
    int N;
    string S;
    cin >> N >> S;
    mint ans = 1;
    vector<bool> is_left(2*N,false);
    is_left[0] = true;
    for(int i=1;i<2*N;i++){
        if(S[i]!=S[i-1]) is_left[i] = is_left[i-1];
        else is_left[i] = !is_left[i-1];
    }
    ll cnt = 0;
    for(ll i=0;i<2*N;i++){
        if(is_left[i]) cnt++;
        else ans *= 2*cnt-i;
    }
    mint fact = 1;
    for(ll i=2;i<=N;i++) fact *= i;
    cerr << cnt << endl;
    if(S[0]=='W' || S[2*N-1]=='W' || cnt!=N) cout << 0 << endl;
    else cout << (ans*fact).x << endl;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF 999999999

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if( (a==0&&b==0&&c==1) || (a==1&&b==1&&c==0) )cout<<"Open"<<endl;
    else cout<<"Close"<<endl;
    
}

/*
 
 ??\???	?????\??¶???	?????\????????????????????????
 1 0 0	??????????????????????????\	Close
 0 1 0	????????\?????????????????\	Close
 1 1 0	?????????????????¨????????\???????????\	Open
 0 0 1	?????????????????\???????????\	Open
 0 0 0	?????\??????	Close

 */

Measured memory_bytes: 1160
#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;

int main() {
  
  int a,b,c,d,x;
  string s,ss,sss;
  
  int ans = 0;
  string anss = "";
  
  cin >> a;
  
  int ab [] = {0 , 1 , 3 , 1 , 2 , 1 , 2 , 1 , 1 , 2 , 1 , 2 , 1};
  int result3 = std::max({a, b, c});
//--------------------------------------------------------------------------------

  if(a/10 == 9 || a%10 == 9) anss = "Yes";
  else anss = "No";
  
  cout << anss << endl;

}

Measured memory_bytes: 256
N = int(input())
ex_t, ex_x, ex_y = 0, 0, 0
count = 0
for i in range(N):
    t, x, y = map(int, input().split())
    if abs(x-ex_x) + abs(y-ex_y) <= abs(t-ex_t) and t%2 == (x+y)%2:
        count += 1
    ex_t, ex_x, ex_y = t, x, y
print("Yes" if count == N else "No")

Measured memory_bytes: 9100
#include <stdio.h>
int main (){
	char a,b;
	scanf ("%c %c", &a, &b); getchar();
	if (a=='H'&&b=='H'){
		printf ("H\n");
	}else if (a=='D'&&b=='D'){
		printf ("H\n");
	}else printf ("D\n");
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

#define _GLIBCXX_DEBUG

#include <iostream>
#include <vector>

using namespace std;

#define REP(i, n) for(int i=0;i<(int)n;++i)
#define FOR(i, c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef int Weight;

struct Edge {
    int src, dst;
    Weight weight;

    Edge(int src, int dst) :
            src(src), dst(dst) {}
};

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

typedef vector<Weight> Array;
typedef vector<Array> Matrix;

bool augment(const Graph &g, int u,
             vector<int> &matchTo, vector<bool> &visited) {
    if (u < 0) return true;
    FOR(e, g[u]) if (!visited[e->dst]) {
            visited[e->dst] = true;
            if (augment(g, matchTo[e->dst], matchTo, visited)) {
                matchTo[e->src] = e->dst;
                matchTo[e->dst] = e->src;
                return true;
            }
        }
    return false;
}

int bipartiteMatching(const Graph &g, int L, Edges &matching) {
    const int n = g.size();
    vector<int> matchTo(n, -1);
    int match = 0;
    REP(u, L) {
        vector<bool> visited(n);
        if (augment(g, u, matchTo, visited)) ++match;
    }
    REP(u, L) if (matchTo[u] >= 0) // make explicit matching
            matching.push_back(Edge(u, matchTo[u]));
    return match;
}

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

    vector<P> reds(n), blues(n);
    rep(i, n) cin >> reds[i].first >> reds[i].second;
    rep(i, n) cin >> blues[i].first >> blues[i].second;

    Graph g(2 * n);

    rep(i, n) {
        rep(j, n) {
            P red = reds[i], blue = blues[j];
            if (red.first < blue.first && red.second < blue.second) {
                g[i].push_back(Edge(i, j + n));
                g[j + n].push_back(Edge(j + n, i));
            }
        }
    }
    Edges _;
    int ans = bipartiteMatching(g, n, _);
    cout << ans << endl;

}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,v,c,ans;cin>>n;ans=0;
  int jew[n];int cost[n];
  for(int i=0;i<n;i++){
    cin>>v;jew[i]=v;
  }
  for(int j=0;j<n;j++){
    cin>>c;cost[j]=c;
  }
  for(int k=0;k<n;k++){
    if(jew[k]-cost[k]>0){
      ans+=jew[k]-cost[k];
    }
  }
  cout<<ans;
}

Measured memory_bytes: 256
n,w = map(int,input().split())
ls = [[int(x) for x in input().split()] for _ in range(n)]

dp = [[0]*(w+1) for _ in range(n+1)]

for i in range(1,n+1):
    for j in range(w+1):
        if ls[i-1][0]>j:
            dp[i][j]=dp[i-1][j]
        else:
            dp[i][j] = max(dp[i-1][j],dp[i-1][j-ls[i-1][0]]+ls[i-1][1])

print(max(dp[n]))
        


Measured memory_bytes: 120172
#include<bits/stdc++.h>
const int N=4005;
const int mo=1000000007;
using namespace std;
int n,m,K,p,ans;
int f[N][N];
int main(){
	scanf("%d%d%d",&n,&m,&K);
	f[0][0]=1; p=(n+m-1)/(K-1);
	for (int i=1;i<=p;i++)
		for (int j=0;j<=m;j++)
			if (f[i-1][j])
				for (int k=0;k<K&&j+k<=m;k++)
					f[i][j+k]=(f[i][j+k]+f[i-1][j])%mo;
	for (int i=1;i<=p;i++)
		for (int j=1;j<=m;j++)
			if (j%(K-1)==m%(K-1)&&(K-1)*i-j<=n-1)
				ans=(ans+(f[i][j]-f[i-1][j]))%mo;
	printf("%d",(ans+mo)%mo);
}

Measured memory_bytes: 61056
def gcm(a,b):
  while b:
    a,b=b,a%b
  return a
def lcm(c,d):
  return c*d//gcm(c,d)
N=int(input())
j=int(input())
for i in range(N-1):
  k=int(input())
  j=lcm(j,k)
print(j)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(int i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
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 dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int ddx[6]={0,1,0,-1,1,-1},ddy[6]={-1,0,1,0,1,-1};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

string s;
int a,b,c,d;
vector<string> vv;

int main(){
	while(1){
		cin>>s;
		if(s=="#")break;
		cin>>a>>b>>c>>d;
		int w=0,h=0;
		char s1[10][10];
		REP(i,s.size()){
			if(s[i]=='/')h++;
		}
		h++;
		REP(i,s.size()){
			if(s[i]=='/')break;
			if(s[i]=='b')w++;
			if(isdigit(s[i]))w+=(s[i]-'0');
		}
		int hj=1;
		int wj=1;
		for(int i=0;i<s.size();i++){
			if(s[i]=='/'){
				hj++;
				wj=1;
				continue;
			}else if(s[i]=='b'){
				s1[hj][wj]='b';
				wj++;
			}else{
				for(int k=0;k<s[i]-'0';k++){
					s1[hj][wj]=' ';
					wj++;
				}
			}
		}
		s1[a][b]=' ';
		s1[c][d]='b';
		string ans="";
		int co=0;
		for(int i=1;i<=h;i++){
			for(int j=1;j<=w;j++){
				if(s1[i][j]=='b'){
					if(co!=0){
						ans+=(char)co+'0';
					}
					ans+='b';
					co=0;
				}else{
					co++;
					if(j==w){
						ans+=(char)co+'0';
						co=0;
					}
				}
			}
			if(i!=h)
			ans+='/';
		}
		vv.push_back(ans);
	}
	REP(i,vv.size())
		cout<<vv[i]<<endl;
	return 0;
}


Measured memory_bytes: 3168
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

import java.io.*;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.HashSet;



/**
 *
 * @author allegea
 */
public class Main {

    public static long gcd(long a,long b){
        if(b==0)return a;
        return gcd(b,a%b);
    }
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws IOException{
        
        //BufferedReader in   = new BufferedReader(new FileReader("pruebas.txt"));
        
         BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
         
           String line;
           StringBuilder out = new StringBuilder();

            while ((line = in.readLine())!=null) 
            {
               long x = Integer.parseInt(line);
               
               BigInteger LCM = BigInteger.ONE;
               BigInteger GCD = BigInteger.ONE;
               BigInteger aux = BigInteger.ONE;
               String oo;
               for(long i=1;i<=x;i++){
               oo = in.readLine();
                   aux = new BigInteger(String.valueOf(oo));
                   GCD = LCM.gcd(aux);
                   LCM = (LCM.multiply(aux)).divide(GCD);
               }
               
               //System.out.println(Arrays.toString(numbers));
               System.out.println(LCM);
            }

        in.close();
        System.exit(0);
        
    }
}

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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long  ll; typedef vector<int> VI; typedef pair<int,int> pii; typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){cerr<<"\n";} template <class F,class ...S> void dbg(const F& f, const S&...s){cerr <<f <<": "; dbg(s...);}

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int h,w, ch,cw, dh, dw;
	cin >>h >>w >>ch >>cw >>dh >>dw;
	vector<string> ba(h);
	rep(i, h) cin >>ba[i];
	ch--;cw--;dh--;dw--;
	
	vector<VI> tr(h*w);
	
	const int dr[]={0,1,0,-1,0};
	const int INF= 1<<28;
	vector<VI> dd(h, VI(w, INF));
	deque< pair<int, int> > que;
	que.emplace_front(ch, cw); dd[ch][cw]=0;
	while(!que.empty()){
		int cy,cx; tie(cy,cx) = que.front();
		que.pop_front();
		rep(i,4){
			int ny=cy+dr[i], nx=cx+dr[i+1];
			if(ny<0 || ny>=h || nx<0 || nx>=w) continue;
			if(dd[ny][nx] > dd[cy][cx] && ba[ny][nx] =='.'){
				que.emplace_front(ny, nx);
				dd[ny][nx] = dd[cy][cx];
			}
		}
		rep2(yy, -2,3) rep2(xx, -2,3){
			//if(abs(yy)+abs(xx)==1) continue;
			int ny=cy+yy, nx=cx+xx;
			if(ny<0 || ny>=h || nx<0 || nx>=w) continue;
			if(dd[ny][nx] > dd[cy][cx] +1 && ba[ny][nx] =='.'){
				que.emplace_back(ny, nx);
				dd[ny][nx] = dd[cy][cx] + 1;
			}
		}
	}
	ll ans = dd[dh][dw];
	cout << (ans!=INF? ans: -1) <<"\n";
	return 0;
}



Measured memory_bytes: 31588
#include<stdio.h>
int main(void){
	int water;
	int sum = 1150;
	while(scanf("%d",&water)){
		if(water == -1){
			break;
		}
		if(water <= 10){
			sum = sum;
		}
		else if(water > 10 && water <= 20){
			sum += 125 * (water - 10);
		}
		else if(water > 20 && water <= 30){
			sum = sum + 140 * (water - 20) + 1250;
		}
		else{
			sum = sum + 160 * (water - 30) + 1250 + 1400;
		}
		printf("%d\n",4280 - sum);
		sum = 1150;
	}
	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

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

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


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

    int n;
    cin >> n;
    map<int, int> m;
    int a;
    rep (i, n)
    {
        cin >> a;
        ++m[a];
    }

    bool ans;
    if (m.size() == 1)
    {
        ans = m[0] > 0;
    }
    else if (m.size() == 2)
    {
        if (n % 3 != 0)
        {
            ans = false;
        }
        else
        {
            vs32 b(2), c(2);
            int cnt = 0;
            for (auto& x : m)
            {
                b[cnt] = x.first;
                c[cnt] = x.second;
                ++cnt;
            }
            if (c[0] * 2 == c[1])
            {
                ans = b[0] == 0;
            }
            else if (c[1] * 2 == c[0])
            {
                ans = b[1] == 0;
            }
            else
            {
                ans = false;
            }
        }
    }
    else if (m.size() == 3)
    {
        if (n % 3 != 0)
        {
            ans = false;
        }
        else
        {
            vs32 b(3), c(3);
            int cnt = 0;
            for (auto& x : m)
            {
                b[cnt] = x.first;
                c[cnt] = x.second;
                ++cnt;
            }
            if (c[0] == c[1] && c[1] == c[2] && c[2] == c[0])
            {
                ans = (b[0] ^ b[1]) == b[2];
            }
            else
            {
                ans = false;
            }
        }
    }
    else
    {
        ans = false;
    }

    cout << (ans ? "Yes\n" : "No\n");
    return 0;
}



Measured memory_bytes: 3840
import java.util.Scanner;
import java.io.PrintWriter;
import java.util.Stack;

class Main {
    static boolean isStrongAnagram(String s) {
        int length = s.length();
        int mid = (length - 1) / 2;
        boolean isMidOdd = mid % 2 == 1;
        int mid1 = (mid - 1) / 2;
        if (!isMidOdd) mid1 ++;
        int start2 = (length + 1) / 2;
        int mid2 = start2 + mid1;
        Stack<Character> stackAll = new Stack<>();
        Stack<Character> stackSub = new Stack<>();
        char c, tmp;
        for (int i = 0; i < length; i ++) {
            c = s.charAt(i);
            if (i < mid) {
                stackAll.push(c);
                if (i < mid1) {
                    stackSub.push(c);
                } else if (!isMidOdd || i > mid1) {
                    tmp = stackSub.pop();
                    if (c != tmp) return false;
                }
            } else if (i == mid) {
                if (!stackSub.isEmpty()) return false;
            } else {
                tmp = stackAll.pop();
                if (c != tmp) return false;
                if (i >= start2) {
                    if (i < mid2) {
                        stackSub.push(c);
                    } else if (!isMidOdd || i > mid2) {
                        tmp = stackSub.pop();
                        if (c != tmp) return false;
                    }
                }
            }
        }
        if (!stackAll.isEmpty() || !stackSub.isEmpty()) return false;
        return true;
    }


    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        String s = sc.next();

        if (isStrongAnagram(s)) {
            out.println("Yes");
        } else {
            out.println("No");
        }
        out.flush();
    }
}


Measured memory_bytes: 21716
while True:
  n, l, r = map(int, input().split())
  if n == 0 and l == 0 and r == 0:
    break
  else:
    a = [0 for i in range(n)]
    for i in range(n):
      aa = int(input())
      a[i] = aa
    cnt = 0
    for x in range(l, r + 1):
      flag = False
      for i in range(n):
        if x % a[i] == 0:
          flag = True
          break
      if (i+1) % 2 == 1 and flag == True:
        cnt += 1
      elif flag == False:
        if n % 2 == 0:
          cnt += 1
  print(cnt)


Measured memory_bytes: 5604
#include<stdio.h>
int main()
{
    long long int n,m,a,sum = 0;
    scanf("%lld %lld",&n,&m);
    int i;
    for(i = 1; i<=m; i++)
    {
        scanf("%lld",&a);
        sum+=a;
    }
    long long ans = n-sum;
    if(ans<0) printf("-1\n");
    else printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 1708
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>

using namespace std;

int main (int argc, char *argv[]) 
{
    int A, B;

    cin >> A >> B;

    int ans = A + B;
    ans = max(ans, A-B);
    ans = max(ans, A*B);

    cout << ans << endl;

    return 0;
}

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

#define rep(i, n) for (int i = 0; i < n; i = i + 1)
#define array(N, t) (t*)calloc(N, sizeof(t))
#define ll long long
#define INF ((1LL << 62) - (1LL << 31))
#define max(p, q)((p) > (q) ? (p) : (q))
#define min(p, q)((p) < (q) ? (p) : (q))
#define swap(type, a, b) { type temp = a; a = b; b = temp; }

int main() {
  char S[1010];
  scanf("%s", S);

  int cnt = 0;
  rep(i, 1010) {
    if (S[i] == '\0') {
      cnt = i;
      break;
    }
  }



  if (S[cnt - 1] == 's') {
    S[cnt] = 'e';
    S[cnt + 1] = 's';
    S[cnt + 2] = '\0';
  } else {
    S[cnt] = 's';
    S[cnt + 1] = '\0';
  }

  puts(S);

  return 0;
}


Measured memory_bytes: 1648
n,m = map(int,input().split())
s=set([int(input()) for i in range(m)])
l=[1]+[0]*n
INF=1000000007
if n ==1:
    print(1)
    exit()
if len(s)!=0 and 1 in s:l[1]=0
else:l[1]=1
for i in range(2,n+1):
    if i in s: l[i]=0
    else:l[i] = (l[i-2]+l[i-1])%INF
print(l[-1])

Measured memory_bytes: 13192
import math
a,b,x = map(int,input().split())
h = x/a/a
area = h*a
aa = area*2/b
tan = b/aa
deg = math.degrees(math.atan(tan))

area2 = a*b-area
bbb =area2*2/a
tan2 = bbb/a
deg2 = math.degrees(math.atan(tan2))

deg_s = math.degrees(math.atan(b/a))

if deg<deg_s and deg2<deg_s:
  print(min((deg,deg2)))
elif deg>=deg_s:
  print(deg)
else:
  print(deg2)
  

Measured memory_bytes: 3064
n = int(input())
a=b=c=d=0
for i in range(n):
  e = input()
  if e == 'AC':
    a+=1
  elif e == 'WA':
    b +=1
  elif e == 'TLE':
    c+=1
  else:
    d+=1

    

print('AC x '+str(a)+'\n'+'WA x ' +str(b) + '\n'
      +'TLE x '+str(c) +'\n' + 'RE x '+str(d))
  


Measured memory_bytes: 9144
#include <bits/stdc++.h>
using namespace std;
const int M=2e5+10;
int a[M];

int main(int argc, char const *argv[])
{
	int n;cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	int mn=a[1];
	int ans=0;
	for(int i=2;i<=n;i++){
		if(mn<a[i])ans++;
		mn=min(mn,a[i]);
	}
	cout<<n-ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <numeric>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
#define int long long
#define vint vector<int>
#define pint pair<int,int>
#define pb(a) push_back(a)
#define all(v) v.begin(),v.end()
#define dbg(x) cerr << #x << " = " << (x) << endl
#define yn(b) cout << ((b) ? "Yes" : "No") << endl
#define YN(b) cout << ((b) ? "YES" : "NO") << endl

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

struct sushi{
	int x, v;
};

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

	int A,B;
	cin>>A>>B;
	cout << A * A - B << endl;

	return 0;
}

Measured memory_bytes: 256
n = int(input())
A = [int(i) for i in input().split()]

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 A, i + 1

A, x = partition(A, 0, len(A)-1)

outputs = [ "["+str(A[i]) + "]" if i == x else str(A[i]) for i in range(len(A))]
print(" ".join(outputs))


Measured memory_bytes: 16588
#include<bits/stdc++.h>
#define int long long
typedef long long LL;
#define lowbit(x) (x)&(-(x))
using namespace std;
const int maxn=110000;
const int maxm=210000;
int a[maxn],san[maxn],b[maxn],op[maxn];
int n;
struct BIT
{
	int t[maxm];
	void add(int x,int v)
	{
		for(int i=x;i<=maxm;i+=lowbit(i)) t[i]+=v;
		return;
	}
	int ca(int x)
	{
		int res=0;
		for(int i=x;i>0;i-=lowbit(i)) res+=t[i];
		return res;
	}
}ch;
void Init()
{
	for(int i=1;i<=n;i++) san[i]=a[i];
	sort(san+1,san+n+1);
	int tot=unique(san+1,san+n+1)-(san+1);
	for(int i=1;i<=n;i++) a[i]=lower_bound(san+1,san+tot+1,a[i])-san;
	return;
}
LL check(int va)
{
	for(int i=1;i<=n;i++)
	{
		if(a[i]<va) op[i]=-1;
		else op[i]=1;
	}
	op[0]=0;
	for(int i=1;i<=n;i++) op[i]=op[i-1]+op[i];
	LL cnt=0;
	for(int i=n;i>=0;i--)
	{
		cnt+=ch.ca(2*(n+1))-ch.ca(n+1+op[i]-1);
		ch.add(op[i]+n+1,1);
	}
	for(int i=0;i<=n;i++) ch.add(op[i]+n+1,-1);
	return cnt;
}
signed main()
{
	scanf("%lld",&n);
	for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
	Init();
	for(int i=1;i<=n;i++) b[i]=a[i];
	sort(b+1,b+n+1);
	int l=1,r=n,best=-1;
	LL all=n*(n-1)/2+n;
	LL pos=all/2+1;
	while(l<=r)
	{
		int mid=(l+r)/2;
		if(check(b[mid])>all-pos) best=mid,l=mid+1;
		else r=mid-1;
	}
	printf("%lld\n",san[b[best]]);
	return 0;
}

Measured memory_bytes: 4352
n = int(input())
a = [int(x) for x in input().split()]
d = {}

for i in range(len(a)):
    if a[i] - 1 not in d:
        d[a[i]-1] = 1
    else:
        d[a[i]-1] += 1
    if a[i] not in d:
        d[a[i]] = 1
    else:
        d[a[i]] += 1
    if a[i] + 1 not in d:
        d[a[i] + 1] = 1
    else:
        d[a[i] + 1] += 1

ans = sorted(d.values(),reverse = True)
print(ans[0])


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

template<typename T, typename U>
using pv=vector<pair<T,U>>;
template<typename T>
using matrix=vector<vector<T>>;
template<typename T>
using pque=priority_queue<T>;
template<typename T>
using lpque=priority_queue<T,vector<T>,greater<T>>;

using ll=long long;
using intpair=pair<int,int>;
using llpair=pair<ll,ll>;
using ilpair=pair<int,ll>;
using lipair=pair<ll,int>;
using intvec=vector<int>;
using llvec=vector<ll>;
using intq=queue<int>;
using llq=queue<ll>;
using intmat=vector<intvec>;
using llmat=vector<llvec>;

#define PI 3.141592653589793
#define INTINF ((1<<30)-1)
#define LLINF ((1LL<<62)-1)
#define MPRIME 1000000007
#define MPRIME9 998244353
#define MMPRIME ((1ll<<61)-1)

#define len length()
#define pushb push_back
#define fi first
#define se second

#define setpr fixed<<setprecision(15)
#define all(name) name.begin(),name.end()
#define rall(name) name.rbegin(),name.rend()
#define gsort(vbeg,vend) sort(vbeg,vend,greater<>())

template<class T>
inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

template<class T>
inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

template<class T>
inline void init(T& v) {
	for(auto &a: v) cin>>a;
}
template<class T, class U>
inline void init(vector<pair<T,U>>& v) {
	for(auto &a: v) cin>>a.first>>a.second;
}
template<class T, class N>
inline void init(T& v, N n) {
	v.resize(n);
	for(auto &a: v) cin>>a;
}
template<class T, class U, class N>
inline void init(vector<pair<T,U>>& v, N n) {
	v.resize(n);
	for(auto &a: v) cin>>a.first>>a.second;
}

inline void out() {
	cout<<endl;
}
template<class T, class... U>
inline void out(T a, U... alist) {
	cout<<a<<" ";
	out(forward<U>(alist)...);
}

template<class N>
void resiz(N n) {
	//empty
}
template<class N, class T, class... U>
void resiz(N n, T&& hd, U&&... tl) {
	hd.resize(n);
	resiz(n,forward<U>(tl)...);
}

bool isout(int h, int w, int H, int W) {
	return ( h<0 || h>=H || w<0 || w>=W );
}

ll binpow(ll a, ll ex, ll p) {
	ll result=1;
	while(ex>0) {
		if(ex&1) result=result*a%p;
		ex>>=1;
		a=a*a%p;
	}
	return result;
}


string S;
ll dp[100001][13];

void input() {
	cin>>S;
}

void solve() {
	dp[0][0]=1;
	for(int i=0; i<S.len; i++) {
		if(S[i]=='?') {
			for(int j=0; j<13; j++) for(int k=0; k<10; k++) {
				int x=(j*10+k)%13;
				dp[i+1][x] = (dp[i+1][x]+dp[i][j])%MPRIME;
			}
			continue;
		}

		int k=int(S[i]-'0');
		for(int j=0; j<13; j++) {
			int x=(j*10+k)%13;
			dp[i+1][x] = (dp[i+1][x]+dp[i][j])%MPRIME;
		}
	}

	cout<<dp[S.len][5]<<endl;
}

int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(15);
	int t=1;
	while(t) {
		input();
		solve();
		t--;
	}
}


Measured memory_bytes: 13916
#include <bits/stdc++.h>  // clang-format off
using Int = long long;
#define REP_(i, a_, b_, a, b, ...) for (Int i = (a), lim##i = (b); i < lim##i; i++)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
struct SetupIO { SetupIO() { std::cin.tie(nullptr), std::ios::sync_with_stdio(false), std::cout << std::fixed << std::setprecision(13); } } setup_io;
#ifndef dump
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Sat Jun 13 21:41:36 JST 2020
 **/

template <class T, class S> T make_vec(S x) { return x; }
template <class T, class... Ts> auto make_vec(size_t n, Ts... ts) {
    return std::vector<decltype(make_vec<T>(ts...))>(n, make_vec<T>(ts...));
}

template <class T = long long> struct PascalTriangle {
    std::vector<std::vector<T>> binom;
    PascalTriangle(int n) : binom(n + 1, std::vector<T>(n + 1)) {
        for (int i = 0; i < n + 1; i++) {
            binom[i][0] = 1;
            for (int j = 1; j < i + 1; j++) {
                binom[i][j] = binom[i - 1][j - 1] + binom[i - 1][j];
            }
        }
    }
    // nCr
    T operator()(int n, int r) {
        assert(0 <= n && 0 <= r && r <= n && n <= binom.size());
        return binom[n][r];
    }
};

const Int B = 19;
signed main() {
    PascalTriangle<Int> comb(50);
    auto acc = make_vec<Int>(52, 52, 0);
    REP(i, 51) {
        REP(j, i + 1) { acc[i][j + 1] = acc[i][j] + comb(i, j); }
    }
    auto calc = [&](Int n, Int r) { return std::max(0LL, acc[n][std::min(n, r) + 1] - 1); };
    Int n, K, s, t;
    std::cin >> n >> K >> s >> t;
    std::vector<Int> a(n);
    REP(i, n) std::cin >> a[i];
    std::vector<Int> bits;
    REP(k, B) {
        Int x = s >> k & 1, y = t >> k & 1;
        if (x == 1) {
            for (Int i = (Int)a.size() - 1; i >= 0; i--) {
                if ((a[i] >> k & 1) == 0) a.erase(a.begin() + i);
            }
        } else if (y == 0) {
            for (Int i = (Int)a.size() - 1; i >= 0; i--) {
                if ((a[i] >> k & 1) == 1) a.erase(a.begin() + i);
            }
        } else {
            bits.push_back(k);
        }
    }

    Int m = bits.size();
    std::vector<Int> b(a.size());
    REP(i, a.size()) {
        REP(j, m) { b[i] |= (a[i] >> bits[j] & 1) << j; }
    }

    Int ans = 0;
    REP(S, 1 << m) {
        std::unordered_map<Int, Int> mp;
        for (Int x : b) mp[x & S]++;
        Int cnt = 0;
        for (auto& p : mp) cnt += calc(p.second, K);
        ans += cnt * (__builtin_popcount(S) % 2 ? -1 : 1);
    }
    std::cout << ans << std::endl;
}


Measured memory_bytes: 3708
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath> //abs();
using namespace std;

int main(void)
{
    long long int a,b,c,d,i,j,k,n,x[10];
    string s,s2;
    char C[5];

    cin >> s;

    for(i=0;i<s.size()/2;i++){
        if( s.at(i)!=s.at(s.size()-i-1) ){
            cout << "No";
            return 0;
        }
    }

    cout << "Yes";  

    return 0;
}

Measured memory_bytes: 256
a, b, c, d = map(int, input().split())
l = [0 for _ in range(101)]
for i in range(a, b):
  l[i] += 1
for i in range(c, d):
  l[i] += 1
ans = 0
for i in range(0, 101):
  if l[i] == 2:
    ans += 1
print(ans)

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

using namespace std;

typedef long long int ll;

#define FOR(i,l,r) for(i=l;i<r;i++)

#define REP(i,n) FOR(i,0,n)

#define ALL(x) x.begin(),x.end()

#define P pair<ll,ll>

#define F first

#define S second

signed main(){

  ll K,i;string S;cin>>K>>S;
  if(S.size()<=K)cout<<S<<endl;
  else{
    REP(i,K)cout<<S.at(i);
    cout<<"..."<<endl;
  }

  return 0;

}

Measured memory_bytes: 3632
#include <iostream>
#define rep(i,q) for(int i = 0; q > i; i++)
using namespace std;
int main(void){
  int N,M,X;
  cin >> N >> M >> X;
  int A[M];
  rep(i,M) cin >> A[i];
  int mx = 0;
  rep(i,X){
    for(int j = 0; M > j; j++){
      if(A[j] == i){
        mx++;
        break;
      }
    }
  }
  int tmp = 0;
  for(int i = X; N > i; i++){
    for(int j = 0; M > j; j++){
      if(A[j] == i){
        tmp++;
        break;
      }
    }
  }
  cout << (mx > tmp ? tmp : mx) << endl;
  return 0;
}

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

public class Main{
  public static void main(String[] args){
    try {
      Scanner sc = new Scanner(System.in);
      int a, b;
      a=Integer.parseInt(sc.next());
      b=Integer.parseInt(sc.next());
      
      if(a*b%2==0){
        System.out.println("No");
      }else{
        System.out.println("Yes");
      }
      

      }catch (Exception e) {
      System.out.println("out");
    }
  }
}


Measured memory_bytes: 21844
from collections import deque

S=deque(str((input())))
Q=int(input())
t=0
for _ in range(Q):
    T=list(map(str,input().split()))
    if T[0]=="1":
        t+=1
    else:
        if (T[1]=="1" and t%2 == 0) or (T[1]=="2" and t%2 != 0):
            S.appendleft(T[2])
        else:
            S.append(T[2])


if t%2 != 0:
    S.reverse()

print("".join(S))

Measured memory_bytes: 75608
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf=0x3f3f3f3f;
const int N=2e5+5;
int a[N],dp[N],n,k;
int main(){
	cin>>n>>k;
	for(int i=1;i<=n;++i)
		cin>>a[i];
	dp[1]=0;
    dp[0]=0;
    for(int i=2;i<=n;++i)
    	dp[i]=inf;
    for(int i=2;i<=n;++i)
      for(int j=i-1;j>=max(1,i-k);j--)
            dp[i]=min(dp[i],dp[j]+abs(a[i]-a[j]));	
		cout<<dp[n];
	return 0;
} 

Measured memory_bytes: 1024
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws Exception{
		Scanner stdIn=new Scanner(System.in);
		int N=stdIn.nextInt();
		int A[]=new int[N];
		int z=0,y=1,n=0;
		while(z<N){
			A[z]=stdIn.nextInt();
			z++;
		}z=1;
		Arrays.sort(A);
		while(z<N){
			if(A[z]!=A[z-1]){
				if(y%2==1)
					n++;
				y=1;
			}
			else
				y++;
			z++;
		}
		if(y%2==1)
			n++;
		System.out.println(n);
	}
}


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

using namespace std;

int main(){
	int n;
	cin >> n;
	priority_queue<int, vector<int>, greater<int>> que;
	while(n > 0){
		int t;
		cin >> t;
		que.push(t);
		n = n - 1;
	}
	int a = 0, b = 0;
	while(que.size()){
		int t = que.top();que.pop();
		if(que.size() % 2) a += t;
		else b += t;
	}
	cout << abs(a - b) << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <ctype.h>
#include <ios> 
#include <iomanip>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)
#define INF 1e7

typedef long long ll;
typedef long long int lli;

int main() {
	int A, B, ans; cin >> A >> B;
    ans = 0;
    for (int i = A; i <= B; i++)
    {
        string s = to_string(i);
        if (s[0] == s[4] && s[1] == s[3]) ans++;
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
 
int main(){
        long long a,b,c,k;
        cin >> a >> b >> c >>k;
 
        long long ans;
        switch(k%2){
                case 0:
                        ans=a-b;
                        break;
                case 1:
                        ans=-a+b;
                        break;
}
 
 
        cout << ans << endl;
 
        return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
using namespace std;
typedef pair<int,int>P;
#define F first
#define S second

int n;
int sum[100009];
int dp[100009];
int a[100009];
int p;
signed main(){
	cin>>n;
	r(i,n)cin>>a[i],p=max(p,a[i]);

	int s=1;
	dp[0]=0;
	r(i,n){

		sum[a[i]]++;
		
		if(sum[a[i]]>=4){
			cout<<0<<endl;
			return 0;
		}

		if(a[i] && sum[a[i]] > sum[a[i]-1]){
			cout<<0<<endl;
			return 0;
		}

		if(!a[i]) s *= 4-sum[a[i]];
		else{
			int A=sum[a[i]]-1;
			int B=sum[a[i]-1];
			s *= (B-A);
		}
		s%=1000000007;
	}
	cout<<s<<endl;

}

Measured memory_bytes: 1792
#include <algorithm>
#include <utility>
#include <cstdio>
#include <vector>
#define pb push_back
#define MOD 1000000007
typedef long long ll;
std::vector<std::pair<ll, ll> > seq[105];
ll F[105];
int main()
{
	// freopen("AGC015-F.in", "r", stdin);
	F[0] = F[1] = 1;
	int len = 1;
	while (true)
	{
		F[len + 1] = F[len] + F[len - 1];
		if (F[len + 1] > 1e18)
			break;
		len++;
	}
	seq[1].pb({1, 2});
	seq[1].pb({1, 3});
	for (int i = 1; i <= len - 3; i++)
	{
		for (auto it : seq[i])
		{
			ll x = it.first, y = it.second;
			while (x + y <= F[i + 3])
			{
				x += y;
				seq[i + 1].pb({y, x});
			}
		}
	}
	int t; 
	scanf("%d", &t);
	while (t--)
	{
		ll n, m;
		scanf("%lld%lld", &n, &m);
		if (n > m)
			std::swap(n, m);
		int ans = 1;
		while (F[ans + 1] <= n && F[ans + 2] <= m)
			ans++;
		printf("%d ", ans);
		if (ans == 1)
			printf("%lld\n", n * m % MOD);
		else
		{
			ll cnt = 0;
			for (auto it : seq[ans - 1])
			{
				ll x = it.first, y = it.second;
				if (y <= n)
					(cnt += (m - x) / y) %= MOD;
				if (y <= m)
					(cnt += (n - x) / y) %= MOD;
			}
			printf("%lld\n", cnt);
		}
	}
	return 0;
}


Measured memory_bytes: 4224
#include<stdio.h>
#include<stdlib.h>
 
#define MAX 2000
 
int combi(int,int);
int n,A[MAX],q,M[MAX];
 
int main(void){
  int i;
 
  scanf("%d", &n);
  for(i=0;i<n;i++) scanf("%d", &A[i]);
 
  scanf("%d", &q);
  for(i=0;i<q;i++) scanf("%d", &M[i]);
 
  for(i=0;i<q;i++){
    if(combi(0,M[i])) printf("yes\n");
    else printf("no\n");
  }
 
  return 0;
}
 
int combi(int m,int i){
  int x;
  if(i==0) return 1;
  if(n<=m) return 0;
  x= combi(m+1,i) || combi(m+1,i-A[m]);
  return x;
}

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

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  int x[n + 1], y[n + 1];
  for (int i = 0; i < n + 1; i++) {
    x[i] = 0;
    y[i] = 0;
  }
  int a = 0, b = 0;
  for (int i = 0; i < m; i++) {
    int p;
    char s[3];
    scanf("%d%s", &p, s);
    if (strcmp(s, "AC") == 0) {
      y[p] = 1;
    } else if (y[p] == 0) {
      x[p]++;
    }
  }
  for (int i = 1; i < n + 1; i++) {
    a += y[i];
    if (y[i] == 1) {
      b += x[i];
    }
  }
  printf("%d %d\n", a, b);
  return 0;
}

Measured memory_bytes: 896
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
def resolve():
    n, m, d = map(int, input().split())
    ans = (m - 1) / n
    if d > 0 and 2 * d + 1 <= n:
        ans *= 1 + (n - 2 * d) / n
    print(ans) 
resolve()

Measured memory_bytes: 61868
#include <bits/stdc++.h>
using namespace std;
#pragma region
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << (#x) << "] = [", _print(x)
#else
#define debug(x...)
#endif
#pragma endregion
typedef long long ll;
#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define sz(v) int((v).size())
#define int ll
#pragma region
#define f first
#define s second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#pragma endregion

int MOD = 1e9+7;
int fact[111'111];
int power(int a, int n)
{
    int res = 1;
    int now = a;
    while(n)
    {
        if (n&1)
        {
            res  = (res*now) %MOD;
        }
        n>>=1;
        now = (now*now)%MOD;
    }
    return res;
}
int inv(int a)
{
    return power(a, MOD-2);
}
int C(int n, int r)
{
    if (n < r) return 0;
    return fact[n] %MOD * inv(fact[n-r])%MOD * inv(fact[r])%MOD;
}

//

int n, k;
vector<int> a;
void solve()
{
    fact[0] = 1;
    for(int i= 1; i < 111'111; ++i)
        fact[i] = fact[i-1] * i % MOD;

    //

    cin>>n>>k;
    a.resize(n);
    forn(i, n) cin>>a[i];
    sort(a.begin(), a.end());
    if (k == 1)
    {
        cout << "0\n";
        return;
    }
    //
    vector<int> sm = a;
    forn(i, n-1) sm[i+1] += sm[i];
    //
    int ans = 0;
    for(int i = k-2; i <= n-2; ++i)
    {

        int delta = i + 1;
        //if (n - delta - 2 < 0 || delta < 0) continue;
        int mx_sum = sm[n-1] - sm[delta - 1];
        int mn_sum = sm[n - delta - 1];
        int all = mx_sum - mn_sum;
        all%=MOD;

        //debug(delta, mx_sum, mn_sum);
        ans = (ans + C(i, k-2) * all%MOD)%MOD;
    }
    cout << ans << '\n';
}

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


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

vector<int> prefix_function( vector<int> a ){
	int n = a.size();
	vector<int> ret(n,0);

	for(int i=1 ; i<n ; ++i){
		int j = ret[i-1];
		while( j>0 && a[i] != a[j] )
			j = ret[j-1];

		if( a[i] == a[j] ) j++;
		ret[i] = j;
	}

	return ret;
}

int main(){

	ios_base::sync_with_stdio(0);
	cout.tie(0);
	cin.tie(0);

	int n;
	cin>>n;

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

	for(int i=0 ; i<n ; ++i)
		c.push_back( b[i]^b[(i+1)%n] );

	c.push_back(-1);
	for(int i=0 ; i<n ; ++i)
		c.push_back( a[i]^a[(i+1)%n] );
	
	for(int i=0 ; i<n-1 ; ++i)
		c.push_back( a[i]^a[(i+1)%n] );

	vector<int> k = prefix_function(c);
	for(int i=0 ; i<k.size() ; ++i){
		if( k[i] == n ){
			int x = i - 2*n;
			cout<<x<<" "<<(b[0]^a[x])<<'\n';
		}
	}
}



Measured memory_bytes: 10052
#include<stdio.h>
#include<string.h>
#include<math.h>
#define rep(i,N) for(int i=0;i<(int)N;i++)
#define SWAPCP(a,b) (a=Add(a,b),b=Add(a,Minus(b)),a=Add(a,Minus(b)))
typedef struct complex complex;
static inline char GET(void)
{
  static char buf[1<<15],*ptr=buf,*end=buf;
  if(ptr==end){ptr=buf,end=buf+fread(buf,1,1<<15,stdin);}return *ptr++;
}
static inline void PUT(char c)
{
  static char buf[1<<15],*ptr=buf;
  if(ptr==buf+strlen(buf)||c==0){fwrite(buf,1,ptr-buf,stdout),ptr=buf;}*ptr++=c;
}
static inline int IN(void)
{
  int x=0,f=0;char c=GET();while(c<48||c>57){f^=c==45,c=GET();}
  while(c>47&&c<58){x=x*10+c-48,c=GET();}return f?-x:x;
}
static inline void OUT(long a)
{
  if(a<0)PUT('-'),a=-a;
  int d[40],i=0;do{d[i++]=a%10;}while(a/=10);
  while(i--){PUT(d[i]+48);}PUT('\n');
}
struct complex{double real,imag;}A[524288]={{0.0},{0}};
static inline complex Add(complex x,complex y){complex z;z.real=x.real+y.real;z.imag=x.imag+y.imag;return z;}
static inline complex Minus(complex x){x.real=-x.real;x.imag=-x.imag;return x;}
static inline complex Mul(complex x,complex y)
{
  complex z;z.real=x.real*y.real-x.imag*y.imag;
  z.imag=x.real*y.imag+x.imag*y.real;return z;
}
static inline int Min(const int x,const int y){return x<y?x:y;}
const int Mod=200003,len=524288,bit=19;const double pi=3.141592653589793238462643383;
int rev[600000];
void fft(int t)
{
  for(int i=0;i<len;++i)if(rev[i]>i){SWAPCP(A[rev[i]],A[i]);}
  for(int i=1;i<len;i<<=1)
  {
    complex wn;wn.real=cos(pi/i),wn.imag=t*sin(pi/i);
    for(int j=0;j<len;j+=i<<1)
    {
      complex w;w.real=1;w.imag=0;
      for(int k=0;k<i;++k)
      {
        complex x=A[k+j];
        complex y=Mul(w,A[k+j+i]);
        A[j+k]=Add(x,y);
        A[k+j+i]=Add(x,Minus(y));
        w=Mul(w,wn);
      }
    }
  }
  if(t==-1)for(int i=0;i<len;++i){A[i].real/=len;A[i].imag/=len;}
} 
int main(void)
{
  int n,g[200003],to[200003];
  g[0]=1;
  for(int i=1;i<Mod-1;++i){g[i]=2*g[i-1]%Mod;to[g[i]]=i;}
  long Ans=0;
  if(!scanf("%d",&n))return -1;
  int x;
  for(int i=1;i<=n;++i)
  {
    if(!scanf("%d",&x))return -1;
    Ans-=1l*x*x%Mod;
    if(!x)continue;
    x=to[x];
    A[x].real+=1.0;
    A[x].imag=0.0;
  }
  for(int i=0;i<len;++i)rev[i]=(rev[i>>1]>>1)|((i&1)<<(bit-1));
  fft(1);
  for(int i=0;i<len;++i)A[i]=Mul(A[i],A[i]);
  fft(-1);
  int num=1%Mod;
  for(int i=0;i<400004;++i){Ans+=(long)(A[i].real+0.5)*num;num=2*num%Mod;}
  return printf("%ld\n",Ans/2),0;
}

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

string S ;

int Calc( int k ){
	int j , p=1 , num=0 ;
	for( j=k  ; '0' <= S[j] && S[j] <= '9' ; j++ ){}
	for( j-=1 ; '0' <= S[j] && S[j] <= '9' ; j-- ){
		num += (S[j]-'0')*p ;
		p *= 10 ;
		S[j] = '*' ;
	}
	return (num+1) ;
}

int Func( int k ){
	int ans = 0 ;
	vector<int> V ;
	for( int i=k ; i<S.size() ; i++ ){
		if( S[i] == ']' ){
			S[i] = '|' ;
			break ;
		}
		else if( S[i] == '[' ){
			S[i] = '/' ;
			V.push_back( Func(i+1) ) ;
		}
		else if( '1' <= S[i] && S[i] <= '9' ){
			V.push_back( Calc(i) ) ;
		}
	}
	sort( V.begin() , V.end() ) ;
	for( int i=0 ; i<(V.size()+1)/2 ; i++ ) ans += V[i] ;
	return ans ;
}

main(){
	int n,Ans ;
	cin >> n ;
	while(n--){
		cin >> S ;
		Ans = Func(0)/2 ;
		cout << Ans << endl ;
	}
}

Measured memory_bytes: 1276
#include <cstdio>
#include <cstdlib>
#include <algorithm>

const int maxn = 1005;

int n;
int a[maxn];
int ans;

bool check(int x)
{
	static int str[20];
	int sl = 0;
	
	while(x)
	{
		str[++sl] = x % 10;
		x /= 10;
	}
	
	for(int i = 1; i < sl; i++)
	{
		if(str[i] - str[i + 1] != 1) return false;
	}
	
	return true;
}
int main()
{
	scanf("%d", &n);
	for(int i = 1; i <= n; i++)
	{
		scanf("%d", &a[i]);
	}
	
	ans = -1;
	
	for(int i = 1; i <= n; i++)
		for(int j = i + 1; j <= n; j++)
			if(check(a[i] * a[j]))
			{
				ans = std::max(ans, a[i] * a[j]);
//				printf("%d\n", a[i] * a[j]);
			}
			
	printf("%d\n", ans);
	
	return 0;
}

Measured memory_bytes: 2716
//設定言語check
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <limits.h>
#include <algorithm>
#include <iomanip>
#include <math.h>
using namespace std;

int main(){
  int N, ans = 0 ;
  cin >> N ;
  ans = 1000 - (N % 1000) ;
  ans %= 1000 ;
  cout << ans << endl ;
  
  return 0 ;
}  

Measured memory_bytes: 3616