akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <map>

using namespace std;


vector<string> vs;
bool used[1010][100];

int search(int x,int y){
  // 0->E,1->º,2->¶,3->ã
  int sit=0;
  int cx=x;
  int cy=y;
  int over=1;
  int under=1;

  int high=0;

  int dx=1;
  int dy=0;

  int miny=10000000;
  int maxy=-1000000;
  while(1){
    used[cy][cx]=true;
    if(sit==0){
      int nx=cx+dx;
      int ny=cy+dy;
      if(nx>=0&&ny>=0&&ny<vs.size()&&nx<vs[ny].size()
	 &&vs[ny][nx]=='*'){
	cx=nx;
	cy=ny;
	miny=min(miny,ny);
	maxy=max(maxy,ny);
	over++;
      }
      // ºÖÚ®·éBÚ®ûüàT·
      else{
	for(int i = -1; i <=1; i++){
	  int nnx=cx+i;
	  int nny=cy+1;
	  int nnnx=nnx+i;
	  int nnny=nny+1;
	  if(nnx>=0&&nny<vs.size()&&nny>=0&&nnx<vs[nny].size()
	     &&vs[nny][nnx]=='*'
	     &&nnnx>=0&&nnny<vs.size()&&nnny>=0&&nnnx<vs[nnny].size()
	     &&vs[nnny][nnnx]=='*'
	     ){
	    dy=1;
	    dx=i;
	    break;
	  }
	}
	sit=1;
      }
    }
    else if(sit==1){
      int nx=cx+dx;
      int ny=cy+dy;
      if(nx>=0&&ny<vs.size()&&ny>=0&&nx<vs[ny].size()
	 &&vs[ny][nx]=='*'){
	cx=nx;
	cy=ny;
	miny=min(miny,ny);
	maxy=max(maxy,ny);
      }
      else{
	// ¶ÖÚ®
	dx=-1;
	dy=0;
	sit=2;
      }
    }
    else if(sit==2){
      int nx=cx+dx;
      int ny=cy+dy;
      if(nx>=0&&ny<vs.size()&&ny>=0&&nx<vs[ny].size()
	 &&vs[ny][nx]=='*'){
	under++;
	cx=nx;
	cy=ny;
	miny=min(miny,ny);
	maxy=max(maxy,ny);
      }
      else{
	// ãÖÚ®
	for(int i = -1; i <=1; i++){
	  int nnx=cx+i;
	  int nny=cy-1;
	  int nnnx=nnx+i;
	  int nnny=nny-1;
	  if(nnx>=0&&nny<vs.size()&&nny>=0&&nnx<vs[nny].size()
	     &&vs[nny][nnx]=='*'
	     &&nnnx>=0&&nnny<vs.size()&&nnny>=0&&nnnx<vs[nnny].size()
	     &&vs[nnny][nnnx]=='*'
	     ){
	    // if(nnx>=0&&nny>=0&&nny<vs.size()&&nnx<vs[nny].size()
	    //  &&vs[nny][nnx]=='*'){
	    dy=-1;
	    dx=i;
	    break;
	  }
	}
	sit=3;
      }
    }
    else{
      int nx=cx+dx;
      int ny=cy+dy;
      //cout<<ny<<" "<<nx<<" "<<y<<" "<<x<<endl;
      cx=nx;
      cy=ny;
      if(ny==y&&nx==x)
	break;
    }
  }
  int res=(over+under)*(abs(miny-maxy)+1)/2;
  return res;
}

int main(){

  int n;
  bool b=false;
  while(cin>>n&&n!=0){
    if(b){
      cout<<"----------"<<endl;
    }
    b=true;
    memset(used,0,sizeof(used));
    int maxLength=0;
    string str;
    getline(cin,str);
    for(int i = 0; i < n; i++){
      getline(cin,str);
      vs.push_back(str);
      maxLength=max(maxLength,(int)str.size());
    }
    for(int i = 0; i < n; i++){
      int diff=maxLength-vs[i].size();
      for(int j = 0; j < diff; j++){
	vs[i]+=' ';
      }
    }
    map<int,int> mii;
    int res=0;
    for(int i = 0; i < vs.size(); i++){
      for(int j= 0;j<vs[i].size();j++){
	if(vs[i][j]=='*'&&!used[i][j]){
	  //cout<<i<<" "<<j<<endl;
	  //cout<<search(j,i)<<endl;
	  mii[search(j,i)]++;
	}
      }
    }
    for(map<int,int>::iterator it=mii.begin();it!=mii.end();it++){
      cout<<it->first<<" "<<it->second<<endl;
    }
    vs.clear();
  }
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    if(s=="Sunny")
    {
        cout<<"Cloudy";
    }
    else if(s=="Cloudy")
    {
        cout<<"Rainy";
    }
    else if(s=="Rainy")
    {
        cout<<"Sunny";
    }



  return 0;
}


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


int main() {
  ll K,T;
  cin>>K>>T;
  vector<ll> a(K);
  for(int i=0;i<K;i++){
    cin>>a[i];
  }
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  if(2*a[0]-K-1<0){
    cout<<0;
  }
  else{
    cout<<2*a[0]-K-1;
  }
  
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t H,W;
  cin>>H>>W;
  vector<vector<int64_t>>A(H,vector<int64_t>(W));
  for(int i=0;i<H;i++)
    for(int j=0;j<W;j++)
      cin>>A[i][j];
  vector<vector<int64_t>>B(H,vector<int64_t>(W));
  for(int i=0;i<H;i++)
    for(int j=0;j<W;j++)
      cin>>B[i][j];
  for(int i=0;i<H;i++)
    for(int j=0;j<W;j++)
      A[i][j]=abs(A[i][j]-B[i][j]);
  vector<vector<bitset<13000>>>dp(H,vector<bitset<13000>>(W));
  dp[0][0][A[0][0]+6400]=1;
  for(int j=1;j<W;j++)
    dp[0][j]=(dp[0][j-1]<<A[0][j])|(dp[0][j-1]>>A[0][j]);
  for(int i=1;i<H;i++)
    dp[i][0]=(dp[i-1][0]<<A[i][0])|(dp[i-1][0]>>A[i][0]);
  for(int i=1;i<H;i++)
    for(int j=1;j<W;j++)
      dp[i][j]=(dp[i-1][j]<<A[i][j])|(dp[i-1][j]>>A[i][j])|
      (dp[i][j-1]<<A[i][j])|(dp[i][j-1]>>A[i][j]);
  int64_t ans=0;
  for(int i=6400;i<=13000;i++)
    if(dp[H-1][W-1][i]){ans=i;break;}
  cout<<ans-6400<<endl;
  return 0;
}
 

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

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

using namespace std;

typedef double Weight;
Weight INF = 1000000000;
struct Edge{
  int src, dest; Weight weight;
  bool operator < (const Edge &rhs) const {return weight > rhs.weight;}
};

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;

void add_edge(Graph &g, int src, int dest, Weight weight) {
  g[src].push_back((Edge){src, dest, weight});
}

// Dijkstra (Verified: AOJ2005)
void dijkstra(Graph &g, Array &d, int s) {
  d.assign(g.size(), INF);
  d[s] = 0;
  typedef pair<Weight,int> P;
  priority_queue<P, vector<P>, greater<P> > que;
  que.push(P(0, s));
  while (!que.empty()) {
    Weight dist = que.top().first;
    int v = que.top().second;
    que.pop();
    if (d[v] < dist) continue;
    REP(i, g[v].size()) {
      Edge e = g[v][i];
      if (d[e.dest] > d[v] + e.weight) {
        d[e.dest] = d[v] + e.weight;
        que.push(P(d[e.dest], e.dest));
      }
    }
  }
}

int cnv(int now, int prev, int speed, int n) {
  return now*(n+1)*31+prev*31+speed;
}

int main() {
  while(1){
    int n,m;
    cin>>n>>m;
    if(!n) break;
    int s,t;
    cin>>s>>t;
    --s;--t;
    Graph g(n*(n+1)*31);
    REP(i,m){
      int x,y,d,c;
      cin>>x>>y>>d>>c;
      --x;--y;
      REP(j,c){
        double v = j+1;
        int ct[2] = {x,y};
        REP(k,n+1) {
          REP(l,2) {
            int src = ct[l], dest = ct[1-l];
            if (dest!=k) {
              add_edge(g, cnv(src,k,v,n), cnv(dest,src,v,n), d/v);
              add_edge(g, cnv(src,k,v-1,n), cnv(dest,src,v,n), d/v);
              if (v<30)
                add_edge(g, cnv(src,k,v+1,n), cnv(dest,src,v,n), d/v);
            }
          }
        }
      }
    }
    Array d(n*(n+1)*31);
    dijkstra(g, d, cnv(s,n,0,n));
    double mnt = INF;
    REP(i,n+1){
      mnt = min(mnt, d[cnv(t,i,1,n)]);
    }
    if (mnt < INF)
      cout << setprecision(10) << fixed << mnt << endl;
    else
      cout << "unreachable" << endl;
  }
  return 0;
}

Measured memory_bytes: 60752
import sys

N, W = map(int, input().split())
WV = [list(map(int, sys.stdin.readline().split())) for i in range(N)]
'''
w = [0]*N
v = [0]*N
for i in range(N):
        w[i], v[i] = map(int, sys.stdin.readline().split())
'''
INF = 10**11+1
dp = [[INF]*(N+1) for j in range(N*(10**3)+10)]
i = 0
ans = INF
while(True):
        for j in range(1, N+1):
                #print(i, j)
                w = WV[j-1][1]
                if i-w >= 0:
                        dp[i][j] = min(dp[i][j-1], dp[i-w][j-1]+WV[j-1][0])
                        #dp[i][j] = max(dp[i-WV[j-1][0]][j-1]+WV[j-1][1], dp[i][j-1])
                else:
                        dp[i][j] = min(dp[i][j-1], WV[j-1][0])
        #print(dp[i][N])
        #print(i, dp[i][N])
        if dp[i][N] > W and ans <= W:
                print(i)
                exit()
        ans = dp[i][N]
        '''
        if dp[i][N] >= W:
                if ans == 0:
                        ans = dp[i][N]
                elif ans < dp[i][N]:
                        print(i)
                        exit()
                print(i, ans)
        '''
        i += 1

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

using namespace std;

int main(){
    long long n, m, ans = 0;
    cin >> n >> m;
    if(m < 2)cout << 0;
    else{
        if(m >= 2 * n){
            ans += n;
            m = m - n * 2;
            if(m >= 4){
                ans += m / 4;
            }
            cout << ans;
        }else cout << m / 2;
    }
    return 0;
}


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

int main() {
  int s;
  cin >> s;
  vector<int> a;
  a.push_back(s);
  bool a_count[1110000] = {false};
  a_count[s] = true;
  int i;
  for (i = 1; i < 100000000; i++) {
    if (a[i - 1] % 2 == 0) {
      a.push_back(a[i - 1] / 2);
    } else {
      a.push_back(3 * a[i - 1] + 1);
    }
    if (a_count[a[i]] == true) {
      cout << i + 1 << endl;
      break;
    }
    a_count[a[i]] = true;
  }
  return 0;
}


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

using namespace std;

int n,m;
int p[200010];
int c[200010];
void init() {for (int i = 0; i < 200010; ++i) p[i] = i;}
int find(int x) { return p[x] == x ? x : p[x] = find(p[x]);}
void merge(int x,int y) {p[find(y)] = find(x);}

int main() {
    
    init();

    cin >> n >> m;


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

    for (int i = 1; i <= n; ++i) {
        c[find(i)]++;
    }

    int ans = 0;

    for (int i = 1; i <= n ;++i)
        ans = max(c[i], ans);

    cout << ans << "\n";


    return 0;
}


Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
 
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ld;
 
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;
 
const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;
 
#define _  %  MOD
#define __ %= MOD
 
#define      each(it,s)        for(auto it = s.begin(); it != s.end(); ++it)
#define      sortA(v)          sort(v.begin(), v.end())
#define      sortD(v)          sort(v.begin(), v.end(), greater<auto>())
#define      fill(a)           memset(a, 0, sizeof (a))
 
#define      swap(a,b)        {a=a+b;b=a-b;a=a-b;}
#define      rep(i, n)         for(ll i = 0; i < (n); ++i)
#define      repA(i, a, n)     for(ll i = a; i <= (n); ++i)
#define      repD(i, a, n)     for(ll i = a; i >= (n); --i)
#define watch(x) cout << (#x) << " is " << (x) <<endl
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
#define fbo find_by_order
#define ook order_of_key
 
ll gcd(ll a,ll b){if(b==0) return a; else return gcd(b,a%b);}
ll power(ll x,ll y){ll res=1; while(y>0){if(y&1) res=res*x;y=y>>1;x=x*x;}return res;} // modular exponent
const int maxn=1e6+1;
ll sieve[maxn];
map<ll,ll> pfq;
int main()
{
    ios_base::sync_with_stdio(false); // don't use printf and scanf
    cin.tie(NULL); // cout<<fixed<<setprecision
   	ll n;
   	cin>>n;
	vector<ll> a(n+1);
	repA(i,1,n) cin>>a[i];
	ll gd=0;
	for(ll i=2;i<maxn;i++)
	{
		if(sieve[i]==0)
		{
			sieve[i]=i; // largest prime factor of a number
			for(ll j=2;j*i<maxn;j++)
			{	
				sieve[j*i]=i;
			}
		}
	}
	repA(i,1,n)
	{
		ll val=a[i];
		gd=gcd(gd,val);
		set<ll> st;
		while(val>1)
		{
			if(st.count(sieve[val])==0)	pfq[sieve[val]]++;
			st.insert(sieve[val]);
			val/=sieve[val];
		}
	}
	int flag=1;
	for(auto it:pfq)
	{
		if(it.se>1)
		{
			flag=0;
			break;
		}
	}
	if(flag)
	{
		cout<<"pairwise coprime\n";
		return 0;
	}
	else
	{
		if(gd==1)
		{
			cout<<"setwise coprime\n";
			return 0;
		}
		else
		{
			cout<<"not coprime\n";
			return 0;
		}
	}
	return 0;
}
// JUST ASK YOURSELF DID YOU GIVE YOUR BEST ? ISSE ZYADA
// KUCH KAR BHI NAHI SAKTE !! ENJOY AND GIVE YOUR BEST!!



Measured memory_bytes: 23676
a=list(input())
b=list(input())
c=list(input())

start="a"
for i in range(10000):
  if start=="a":
    if not a:
      print("A")
      break
    start=a.pop(0)
  elif start=="b":
    if not b:
      print("B")
      break
    start=b.pop(0)
  elif start=="c":
    if not c:
      print("C")
      break
    start=c.pop(0)
  
  

Measured memory_bytes: 3060
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)


def solve(N: int, K: int):
    NL = list(map(int, N))

    useMaxDigits = [[0 for i in range(K+1)] for j in range((len(N)+1))]
    noUseMaxDigits = [[0 for i in range(K+1)]
                      for j in range((len(N)+1))]
    useMaxDigits[0][0] = 1
    for digit in range(1, len(N)+1):
        D = NL[digit-1]
        # Use Max continueingly
        if D != 0:
            for i in range(1, K+1):
                useMaxDigits[digit][i] = useMaxDigits[digit-1][i-1]
            for i in range(0, K+1):
                noUseMaxDigits[digit][i] = useMaxDigits[digit-1][i]
        else:
            for i in range(0, K+1):
                useMaxDigits[digit][i] = useMaxDigits[digit-1][i]

        # Use non max
        for i in range(0, K+1):
            # if use zero
            noUseMaxDigits[digit][i] += noUseMaxDigits[digit-1][i]
        for i in range(1, K+1):
            noUseMaxDigits[digit][i] += noUseMaxDigits[digit-1][i-1]*9
        for i in range(1, K+1):
            noUseMaxDigits[digit][i] += useMaxDigits[digit -
                                                     1][i-1]*max(0, D-1)
    print(useMaxDigits[-1][-1]+noUseMaxDigits[-1][-1])
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = next(tokens)  # type: int
    K = int(next(tokens))  # type: int
    solve(N, K)


if __name__ == '__main__':
    main()


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

int n, x, y, cnt[3005];

int get(int i, int j) {
	return min(abs(j - y) + abs(x - i) + 1, abs(y - i) + abs(j - x) + 1);
}

int main() {
	cin>>n>>x>>y;
	for(int i = 1; i < n; i++)
	    cnt[i] = n - i;
	for(int i = 1; i < n; i++)
	    for(int j = i + 1; j <= n; j++) 
	    	if(j - i > get(i, j))
	    	    cnt[j - i]--, cnt[get(i, j)]++;
	for(int i = 1; i < n; i++)
	    cout<<cnt[i]<<endl;
}

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

int main(){
  long long N;
  long long M;
  cin>>N>>M;
  if((N==1)&&(M==1)){
    cout<<1<<endl;
    return 0;
  }
  if(N==1){
    cout<<M-2<<endl;
    return 0;
  }
  if(M==1){
    cout<<N-2<<endl;
    return 0;
  }
  cout<<setprecision(20)<<(N-2)*(M-2)<<endl;

  return 0;
}

    
  

Measured memory_bytes: 256
Option Infer On
Imports System.Collections.Generic
Imports System.Console
Imports System.Math

Module Program
    Sub Main()
        Dim N As Integer = NextInt()
        Dim M As Integer = NextInt()

        Dim students = New Integer(N - 1, 1) {}
        Dim checkPoints = New Integer(M - 1, 1) {}

        For i = 0 To N - 1
            students(i, 0) = NextInt()
            students(i, 1) = NextInt()
        Next

        For j = 0 To M - 1
            checkPoints(j, 0) = NextInt()
            checkPoints(j, 1) = NextInt()
        Next

        For i = 0 To N - 1
            Dim index = -1
            Dim value = Integer.MaxValue
            For j = 0 To M - 1
                Dim x1 = students(i, 0)
                Dim y1 = students(i, 1)
                Dim x2 = checkPoints(j, 0)
                Dim y2 = checkPoints(j, 1)
                Dim Calc_result = Calc(x1, x2, y1, y2)

                If Calc_result < value Then
                    index = j
                    value = Calc_result
                End If
            Next
            WriteLine(index + 1)
        Next
    End Sub

    Function Calc(x1 As Integer, x2 As Integer,
                  y1 As Integer, y2 As Integer) As Integer
        Return Abs(x1 - x2) + Abs(y1 - y2)
    End Function

    Function NextInt() As Integer
        Return CInt(NextString())
    End Function

    Function NextString() As String
        Dim result As New List(Of Char)
        Do
            Dim tmp = Read()
            If tmp < 0 Then Exit Do
            Dim nextChar = Chr(tmp)

            If Not Char.IsWhiteSpace(nextChar) Then
                result.Add(nextChar)
            ElseIf nextChar <> vbCr Then
                Exit Do
            End If
        Loop
        Return New String(result.ToArray())
    End Function

End Module


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

using namespace std;

#define gc getchar_unlocked
#define foi(i,n) for(int i=0;i<n;i++)
#define Foi(i,k,n) for(int i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define fol(i,n) for(ll i=0;i<n;i++)
#define Fol(i,k,n) for(ll i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)   scanf("%d",&x)
#define sl(x)   scanf("%lld",&x)
#define ss(s)   scanf("%s",s)
#define pi(x)   printf("%d\n",x)
#define pl(x)   printf("%lld\n",x)
#define ps(s)   printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pl;
typedef vector<int>     vi;
typedef vector<ll>      vl;
typedef vector<pii>     vpii;
typedef vector<pl>      vpl;
typedef vector<vi>      vvi;
typedef vector<vl>      vvl;
int mpow(int base, int exp); 
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================

vi g[N];
int a[N];

int mpow(int base, int exp) {
    base %= mod;
    int result = 1;
    while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
    }
    return result;
}

void ipgraph(int n, int m){
    int i, u, v;
    while(m--){
        cin>>u>>v;
        g[u-1].pb(v-1);
        g[v-1].pb(u-1);
    }
}

void dfs(int u, int par){
    for(int v:g[u]){
        if (v == par) continue;
        dfs(v, u);
    }
}


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin>>n;
    vector<ll> sides(n);
    for(int i=0;i<n;i++)
        cin>>sides[i];
    int count=0;
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            for(int z=j+1;z<n;z++)
            {
                if(sides[i]!=sides[j]&&sides[j]!=sides[z]&&sides[i]!=sides[z])
                {
                    if(sides[i]+sides[j]>sides[z]&&sides[i]+sides[z]>sides[j]&&sides[z]+sides[j]>sides[i])
                        count++;
                }
            }
        }
    }   
    cout<<count;
    return 0;
}

Measured memory_bytes: 10680
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <stack>
#include <cmath>
#include <queue>
#include <numeric>


int main()
{
	std::string s;

	std::cin >> s;

	std::cout << s.substr(0, s.length() - 8) << std::endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
#define int long long
//#define return 0; while(1);
const int N=200010,Mod=1e9+7,inf=1e9+5;
int Min[N],c[N],w[N],cnt[N],jc[N],inv[N];
int n,A,B,ans;
int power(int x,int k)
{
	int res=1;
	while(k)
	{
		if(k&1)res=(res*x)%Mod;
		x=(x*x)%Mod;
		k>>=1;
	}
	return res;
}
int C(int n,int m)
{
    if (n<m||m<0) return 0;
    return jc[n]*inv[m]%Mod*inv[n-m]%Mod;
}
signed main()
{
//	freopen("keep.in","r",stdin);
//	freopen("keep.out","w",stdout);
	scanf("%lld%lld%lld",&n,&A,&B);
	for(int i=1;i<=n;i++)Min[i]=inf;
	jc[0]=1;
	for(int i=1;i<=n;i++)jc[i]=jc[i-1]*i%Mod;
	inv[n]=power(jc[n],Mod-2);//printf("%lld\n",inv[n]);
	for(int i=n-1;i>=0;i--)inv[i]=inv[i+1]*(i+1)%Mod;
	for(int i=1;i<=n;i++)
	{
		scanf("%lld%lld",&c[i],&w[i]);
		Min[c[i]]=min(Min[c[i]],w[i]);
		cnt[c[i]]++;
	}
	int Minn=1,t=1e9;
	for(int i=2;i<=n;i++)
		if(Min[i]!=inf)
			if(Min[Minn]>Min[i])
				Minn=i;
	for(int i=1;i<=n;i++)
		if(Min[i]!=inf&&i!=Minn)t=min(t,Min[i]);
	for(int i=1;i<=n;i++)
	{
		if(w[i]!=Min[c[i]]&&w[i]+Min[c[i]]<=A) continue;
        if(c[i]!=Minn&&w[i]+Min[Minn]<=B) continue;
        if(c[i]==Minn&&w[i]+t<=B) continue;
        cnt[c[i]]--;
    }
    int num=cnt[Minn];
    for(int i=1;i<=n;i++)
        if(Min[i]!=inf&&i!=Minn)
            if (Min[i]+Min[Minn]<=B)num+=cnt[i];
    ans=1;
   // printf("%lld\n",num);
    for(int i=1;i<=n;i++)
        if(Min[i]!=inf&&(i==Minn||Min[i]+Min[Minn]<=B))
            ans=ans*inv[cnt[i]]%Mod;
    for(int i=1;i<=num;i++)ans=ans*i%Mod;
    printf("%lld\n",ans);
    return 0;
}

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T> void operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) cin >> e; }

typedef long long ll;
int const inf = 1<<29;

int main() {

  ll N; cin >> N;
  ll a = 1;
  for (ll i = 1; i * i <= N; i++) {
    if (N % i == 0) {
      a = std::max(a, i);
    }
  }

  auto b = N / a;
  std::stringstream ss; ss << b;
  std::cout << ss.str().size() << "\n";
  
  return 0;
}

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

int group(int num){
    if(num==2) return 2;
    if(num==4 || num==6 || num==9 || num==11) return 1;
    return 0;
}

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

    int x, y;
    cin >> x >> y;

    if(group(x)==group(y)) puts("Yes");
    else puts("No");
}

Measured memory_bytes: 256
#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 <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst<<": "; dbg(rst...); }

int main()
{
	const double PI = acos(-1);
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >>n;
	VL a(n);
	rep(i, n) cin >>a[i];
	
	ll z=0;
	rep(i, n) z ^= a[i];
	//dbg(z);
	VL p(n);
	rep(i, n)  p[i] = z ^a[i];
	for(auto x :p) cout<<x<<" ";
	cout <<"\n";
	return 0;
}


Measured memory_bytes: 6352
s_list = list(input())
n = len(s_list)
c_count = 0
if s_list[0] == "A":
    for s in s_list[2:-1]:
        if s == "C":
            c_count += 1
    if c_count == 1:
        if all([(s_list[i] == "C" and 2 <= i <= n - 2) or s_list[i].islower() for i in range(1, n)]):
            print("AC")
            exit()
print("WA")

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

public class Main {

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

  private void solve() {
    try(InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out)) {

      final int A = in.nextInt();
      final int B = in.nextInt();
      final int Q = in.nextInt();

      long[] s = new long[A+1];
      for (int i = 0; i < A; i++) {
        s[i] = in.nextLong();
      }
      s[A] = 1L << 40;

      long[] t = new long[B+1];
      for (int i = 0; i < B; i++) {
        t[i] = in.nextLong();
      }
      t[B] = 1L << 40;

      for (int q = 0; q < Q; q++) {
        long x = in.nextLong();
        long dist = 1L << 50;

        for (int c = 0; c < 2; c++) {
          long[] af = c == 0 ? s : t;
          long[] as = c == 0 ? t : s;

          for (int i = 0; i < 2; i++) {
            int posF = binarySearch(af, x) + i;
            long df = af[posF];

            for (int j = 0; j < 2; j++) {
              int posS = binarySearch(as, x) + j;
              long ds = as[posS];
              
              long d = Math.abs(x - df);
              d += Math.abs(df - ds);
              dist = Math.min(dist, d);
            }
          }
        }

        out.println(dist);
      }
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }

  private int binarySearch(long[] arr, long x) {
    int left = 0;
    int right = arr.length;

    return loop(arr, x, left, right);
  }

  private int loop(long[] arr, long x, int left, int right) {
    if(right - left < 2) return left;
    else {
      int mid = (left + right) / 2;
      if(arr[mid] <= x) return loop(arr, x, mid, right);
      else return loop(arr, x, left, mid);
    }
  }

  static class InputReader extends BufferedReader {
    // public BufferedReader reader;
    public StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
      super(new InputStreamReader(stream), 32768);
      tokenizer = null;
    }

    public String next() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(this.readLine());
        } catch (IOException e) {
          throw new UncheckedIOException(e);
        }
      }
      return tokenizer.nextToken();
    }

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

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

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

int main(){
    int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;
    if (x >= r and x <= W - r and y >= r and y <= H - r){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}



Measured memory_bytes: 3116
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cctype>

#define div 1000000000+7

typedef long long ll;

using namespace std;


int main() {
    char a[2], b[2];

    cin >> a[0] >> b[0];
    if(a[0] == 'H'){
        if(b[0] == 'H'){
            cout << 'H' << endl;
        }else{
            cout << 'D' << endl;
        }
    }else{
        if(b[0] == 'H'){
            cout << 'D' << endl;
        }else{
            cout << 'H' << endl; 
        }
    }
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 101
#define WHITE 0
#define BLACK 1
#define GRAY 2
typedef struct{
  int k;
  int d;
  int color;
  int v[N];
} Graph;
Graph g[N];
int n,head=0,tail=0,q[N];
 
void enqueue(int x)
{
  q[tail] = x;
  if(tail+1 == N-1) tail = 0;
  else tail++;
}
 
int dequeue()
{
  int x;
  x = q[head];
  if(head+1 == N-1) head=0;
  else head++;
  return x;
}
 
void bfs()
{
  int i,u,v;
  for(i=2; i<=n; i++) {
    g[i].color = WHITE;
    g[i].d = N+1;
  }
  g[1].color = GRAY;
  g[1].d = 0;
  enqueue(1);
  while(head!=tail) {
    u = dequeue();
    for(i=0; i<g[u].k; i++){
      v=g[u].v[i];
      if(g[v].color == WHITE){
        g[v].color = GRAY;
        g[v].d = g[u].d +1;
        enqueue(v);
      }
    }
    g[u].color = BLACK;
  }
}
 
int main()
{
  int u,i,j,k;
  scanf("%d",&n);
  for(i=0; i<n; i++) {
    scanf("%d%d",&u,&k);
    g[u].k = k;
    for(j=0; j<g[u].k; j++) {
      scanf("%d",&g[u].v[j]);
    }
  }
  bfs();
  for(i=1; i<=n; i++) {
    if(g[i].d == N+1) g[i].d = -1;
  }
  for(i=1; i<=n; i++){
    printf("%d %d\n",i,g[i].d);
  }
  return 0;
}

Measured memory_bytes: 632
n = gets.to_i
tasks = []
n.times do
  a, b = gets.chomp.split(' ').map(&:to_i)
  tasks.push([a, b])
end
tasks.sort_by!{ |i| i[1] }
current_time, is_ok = 0, true
tasks.each do |i|
  current_time += i[0]
  is_ok &= current_time <= i[1]
end
puts is_ok ? 'Yes' : 'No'

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

int main(){
    using namespace std;
    unsigned long N, K;
    cin >> N >> K;
    vector<unsigned long> P(N);
    deque<unsigned long> mn(N - K), mx(N - K);
    deque<unsigned long> mnq, mxq;
    vector<unsigned long> uf(N), sz(N, 1);
    iota(uf.begin(), uf.end(), 0UL);
    unsigned long ans{N - K + 1};
    auto root = [&uf](auto i){
        while(uf[i] != i)i = uf[i] = uf[uf[i]];
        return i;
    };
    auto unite = [&uf, &sz, &ans, &root](auto i, auto j){
        i = root(i);
        j = root(j);
        if(i == j)return;
        --ans;
        if(sz[i] < sz[j])swap(i, j);
        sz[i] += sz[j];
        uf[j] = i;
    };
    unsigned long sorted{N};
    for(unsigned long i = 0; i < N; ++i){
        cin >> P[i];
        while(!mnq.empty() && mnq.back() > P[i])mnq.pop_back();
        while(!mxq.empty() && mxq.back() < P[i])mxq.pop_back();
        mnq.push_back(P[i]);
        mxq.push_back(P[i]);
        if(i + 1 >= K){
            if(mnq.size() == K){
                if(sorted < N)unite(i - K + 1, sorted);
                sorted = i - K + 1;
            }
            if(P[i - K + 1] == mnq.front())mnq.pop_front();
            if(P[i - K + 1] == mxq.front())mxq.pop_front();
            mn[i - K + 1] = mnq.front();
            mx[i - K + 1] = mxq.front();
        }
    }
    for(unsigned long i = 0; i + K < N; ++i)if(P[i] < mn[i] && mx[i] < P[i + K])unite(i, i + 1);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i=0; i < n; i++)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x, y, z) max((x), max((y), (z)))
#define tmin(x, y, z) min((x), min((y), (z)))
ll MM = 1000000000; ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
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;}
const ll INF = 1LL << 60;
//cout << fixed << setprecision(10);

int main(){
    ll ans=0, n, m; cin>>n>>m;
    vector<set<ll>> v(n+1);
    ll a, b;
    rep(i,m) cin>>a>>b, v[a].insert(b), v[b].insert(a);
    vector<ll> s(n-1);
    rep(i,n-1) s[i]=i+2;
    do{
        bool ok=1;
        if(!v[1].count(s[0])) continue;
        rep(i,n-2){
            if(!v[s[i]].count(s[i+1])){
                ok=0;
                break;
            }
        }
        if(ok) ans++;
    }while(next_permutation(all(s)));

    cout<<ans<<endl;
}

Measured memory_bytes: 256
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    x <- getIntList
    let [a, b, c] = sort x
    putStrLn $ if a + b == c then "Yes" else "No"

Measured memory_bytes: 380
#include <stdio.h>

int main(void){
	double ave = 0.0;

	while(1){
		int n;
		scanf("%d", &n);
		if(n==0) break;

		static int a[10001];
		for(int i=0; i<n; i++){
			scanf("%d", &a[i]);
		}

		ave = 0.0;
		for(int i=0; i<n; i++){
			ave += a[i];
		}
		ave = ave/(double)n;

		int count = 0;
		for(int i=0; i<n; i++){
			if(a[i] <= ave) count++;
		}

		printf("%d\n", count);
	}

	return 0;
}


Measured memory_bytes: 2032
#include <iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<string>
#include<cstdlib>
#include<stack>
#include<queue>
#include <map>
#include<cmath>
#include<vector>
#define MAX_N 1000000
#define INF 0x3f3f3f3f
#define SIZE 1000
using namespace std;



struct note
{
    int x, y;
}start, ende;
typedef pair<int, int> P;
int H, W, N;
char a[1003][1003];
int sum;
int d[1003][1003];
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
void bfs(note h, note m)
{
    memset(d, -1, sizeof(d));
    queue<P> que;
    que.push(P(h.x, h.y));
    d[h.x][h.y] = 0;
    while (!que.empty())
    {
        P p = que.front();
        que.pop();
        for (int i = 0; i < 4; i++)
        {
            int xx = p.first + dx[i];
            int yy = p.second + dy[i];
            if (xx >= 0 && xx < H && yy >= 0 && yy < W && a[xx][yy] != 'X' && d[xx][yy] == -1)
            {
                d[xx][yy] = d[p.first][p.second] + 1;
                que.push(P(xx, yy));
            }
        }
    }
    sum += d[m.x][m.y];
    start = ende;
}
void solve()
{
    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            if (a[i][j] == 'S')
            {
                start.x = i;
                start.y = j;
                i = H;
                j = W;
            }
        }
    }
    for (int k = 0; k < N; k++)
    {
        for (int i = 0; i < H; i++)
        {
            for (int j = 0; j < W; j++)
            {
                if (a[i][j] == k + 49)
                {
                    ende.x = i;
                    ende.y = j;
                    bfs(start, ende);
                    i = H;
                    j = W;
                }
            }
        }
    }
    cout << sum << endl;
}
int main()
{
    cin >> H >> W >> N;
    for (int i = 0; i < H; i++)
    {
        cin >> a[i];
    }
    sum = 0;
    solve();
    return 0;
}

Measured memory_bytes: 6136
#include<iostream>
using namespace std;
int main(void){
	long long a,b,c,k,i,ao,bo,co;
	cin>>a>>b>>c>>k;
	if(k%2==1){
		cout<<(b-a)<<endl;
	}
	else{
		cout<<(a-b)<<endl;
	}
}

Measured memory_bytes: 256
import sys
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))
MIIZ = lambda: list(map(lambda x: x-1, MII()))

def main():
    n = II()
    ss = [II() for _ in range(n)]
    ss.sort()
    total = sum(ss)
    if total%10 == 0:
        d = total
        for s in ss:
            if s%10!=0:
                d = s
                break
        total -= d
    print(total)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define All(V) V.begin(), V.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main()
{
    ll n; cin >> n;
    ll a = 100;
    int cnt = 0;
    while(n > a){
        a += (a/100);
        cnt++;
    }
    cout << cnt << endl;
    system("pause");
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

ll gcd(ll a, ll b) {return (!b ? a : gcd(b, a % b));}
bool cmp(int a,int b){return a>b;}

const ll mod = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;
const ld pi = 3.141592653589793;


void solve(){
    vector<int>a(3);
    for(int i = 0;i<3;i++) cin >> a[i];
    sort(a.rbegin(),a.rend());
    cout <<a[0]*10+a[1]+a[2]<<endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    solve();
    return 0;
}

Measured memory_bytes: 3648
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		while (true) {
			Integer x = sc.nextInt();
			Integer y = sc.nextInt();

			if (x == 0 && y == 0) {
				return;
			}

			if (x > y) {
				System.out.println(y + " " + x);
			} else {
				System.out.println(x + " " + y);
			}

		}

	}

}



Measured memory_bytes: 36136
#include <cstdio>
#include <cstring>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#define INF 100000000000LL
using namespace std;

int main()
{
	int n;
	long long int x[200000], x1[200000];
	scanf("%d", &n);
	for(int i=0; i<n; i++){
		scanf("%lld", &x[i]);
		x1[i]=x[i];
	}
	sort(x1, x1+n);
	for(int i=0; i<n; i++){
		if(x[i]<=x1[n/2-1]){
			printf("%lld\n", x1[n/2]);
		}else{
			printf("%lld\n", x1[n/2-1]);
		}
	}
	return 0;
}

Measured memory_bytes: 5248
#include <bits/stdc++.h>
#define int long long

using namespace std;

constexpr int MAXN = 5e3 + 5;

template <typename T>
inline void read(T& x, T f = 1, char ch = getchar()) {
    x = 0;
    while (!isdigit(ch)) f = (ch == '-') ? -1 : 1, ch = getchar();
    while (isdigit(ch)) x = x * 10 + ch - 48, ch = getchar();
    x *= f;
}

int n, k, to[MAXN], c[MAXN], vis[MAXN], pre[MAXN];
int stc, ed, ans = -1e18, mx[MAXN];
vector<int> node;

inline void dfs(int cur) {
    vis[cur] = true;
    node.push_back(cur);
    if (vis[to[cur]]) {
        ed = node.size() - 1;
        for (int i = 0; i < node.size(); i++) {
            if (node[i] == to[cur]) {
                stc = i;
                break;
            }
        }
    }
    else dfs(to[cur]);
}

inline void search(int st) {
    memset(vis, 0, sizeof(vis));
    memset(pre, 0, sizeof(pre));
    for (int i = 0; i <= n; i++) mx[i] = -1e18;
    ed = stc = -1;
    node.clear();
    dfs(st);
    for (int i = 1; i < node.size(); i++)
        pre[i] = pre[i - 1] + c[node[i]], mx[i] = max(mx[i - 1], pre[i]);
    ans = max(ans, mx[min(k, (int)node.size() - 1)]);
    if (k <= ed || stc == - 1 || ed == -1) return;
    if (stc == 0) { //一开始就有环
        int valC = pre[ed] + c[node[stc]];
        if (valC < 0) return;
        int tim = k / node.size(), res = k % node.size();
        ans = max(ans, tim * valC + max(0LL, mx[res]));
        if (tim > 1)
        ans = max(ans, (tim - 1) * valC + max(0LL, mx[ed]));
        return;
    }
    int tmp = pre[stc - 1];
    memset(pre, 0, sizeof(pre));
    for (int i = 0; i <= n; i++) mx[i] = -1e18;
    int valC = 0, csize = ed - stc + 1;
    for (int i = stc; i <= ed; i++) {
        valC += c[node[i]];
        pre[i] = pre[i - 1] + c[node[i]];
        mx[i] = max(mx[i - 1], pre[i]);
    }
    k -= stc - 1;
    if (valC < 0) return;
    int tim = k / csize, res = k % csize;
    ans = max(ans, tmp + valC * tim + max(0LL, mx[stc + res - 1]));
    if (tim > 1)
        ans = max(ans, tmp + valC * (tim - 1) + max(0LL, mx[ed]));
}

signed main() {
    std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cin >> n >> k;
    for (int i = 1; i <= n; i++) cin >> to[i];
    for (int i = 1; i <= n; i++) cin >> c[i];
    for (int i = 1; i <= n; i++) search(i);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4104
#include<iostream>
#include<algorithm>
using namespace std;
int dp[2][1000001];
int odd[2][1000001];
int Odd(int n,int w){
  for(int i=0;i<2;i++)
    for(int j=0;j<=n;j++){
      odd[i][j]=99999999;
      if(i==0)odd[i][j]=j;
      if(j==0)odd[i][j]=0;
    }

    for(int i=1;i<=w;i++){
      for(int j=1;j<=n;j++){
	if((i*(i+1)*(i+2)/6)%2==0){
	  odd[i&1][j]=odd[i&1^1][j];
	}else if(j<i*(i+1)*(i+2)/6){
	  odd[i&1][j]=odd[i&1^1][j];
	}else{
	  odd[i&1][j]=min(odd[i&1^1][j],odd[i&1][j-i*(i+1)*(i+2)/6]+1);
	}
      }
    }
    return 1;
}

int main(){
  int n=1000000;
  int w=300;
    for(int i=0;i<2;i++)
      for(int j=0;j<=n;j++){
	dp[i][j]=99999999;
	if(i==0)dp[i][j]=j;
	if(j==0)dp[i][j]=0;
      }
    for(int i=1;i<=w;i++){
      for(int j=1;j<=n;j++){
	if(j<i*(i+1)*(i+2)/6){
	  dp[i&1][j]=dp[i&1^1][j];
	}else{
	  dp[i&1][j]=min(dp[i&1^1][j],dp[i&1][j-i*(i+1)*(i+2)/6]+1);
	}
	//cout << "dp[" << i << "][" << j <<"]:"<< dp[i][j] << endl;
      }
    }
    int a;
    Odd(n,w);
    while(cin>>a,a){
      int b=0;
      while(b*(b+1)*(b+2)/6<a)b++;
      cout << dp[b%2][a] << " " << odd[b%2][a] << endl;
    }
  return 0;
}

Measured memory_bytes: 16784
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <numeric>
#include <queue>
#include <stack>
#define mod 1000000007
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define srep(i,s,t) for (ll i = s; i < t; i++)
#define drep(i,n) for(ll i = (n)-1; i >= 0; i--)
using namespace std;
typedef long long ll;
typedef vector<vector<char>> field_t;
typedef unsigned long long ull;
typedef pair<ll, ll> point_t;


int main()
{
    ll k;
    cin >> k;
    ll Z=8;
    Z=Z-(k-400)/200;
    cout<<Z<<endl;
    return 0;
}

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

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cout << #a << " = " << a << endl;

const double PI = acos(-1.0);
const LL INF = 1e9 + 47;
const LL LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

namespace IntModulo
{
	const int mod = 1e9 + 7;

	inline int add(int x, int y, int m = mod)
	{
		if (x + y < m)
			return x + y;
		return x + y - m;
	}

	inline int sub(int x, int y, int m = mod)
	{
		if (x >= y)
			return x - y;
		return x - y + m;
	}

	inline int mult(int x, int y, int m = mod)
	{
		return x * (LL) y % m;
	}

	inline int power(int x, int y, int m = mod)
	{
		int r = 1;
		while(y)
		{
			if (y & 1)
				r = mult(r, x, m);
			x = mult(x, x, m);
			y >>= 1;
		}
		
		return r;
	}
	
	inline int inverse(int x, int m = mod)
	{
		return power(x, m - 2, m);
	}
	
	inline void ADD(int& x, int y, int m = mod)
	{
		x += y;
		if (x >= m) x -= m;
	}
};

using namespace IntModulo;

namespace Combinatorics
{
	using namespace IntModulo;
	
	const int N = 1 << 20;
	int fact[N];
	int inv[N];
	int invFact[N];
	bool inited = false;
	
	inline int C(int n, int k) // binomial C(n, k)
	{
		return n < k ? 0 : mult(fact[n], mult(invFact[k], invFact[n - k]));
	}
	
	inline int H(int n, int k) // number of solution x1 + .. + xn = k
	{
		return C(n + k - 1, k);
	}
	
	void init()
	{
		inited = true;
		inv[1] = 1;
		FOR(i, 2, N)
			inv[i] = mult(mod - mod / i, inv[mod % i]);
		
		invFact[0] = fact[0] = 1;
		FOR(i, 1, N)
		{
			fact[i] = mult(i, fact[i - 1]);
			invFact[i] = mult(invFact[i - 1], inv[i]);
		}
	}	
};

const int N = 1 << 10;
int n, k;
int dp[N];
int dp_new[N];

void go(int x)
{
	FOR(i, 0, n + 1)
	{
		FOR(j, 0, min(n - i, x) + 1)
		{
			int koef = Combinatorics::C(n - j, x - j);
			koef = mult(koef, Combinatorics::C(n - i, j));
			ADD(dp_new[i + j], mult(koef, dp[i]));
		}
	}
	
	FOR(i, 0, n + 1) dp[i] = dp_new[i];
	FILL(dp_new, 0);
}

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	Combinatorics::init();
	cin >> n >> k;
	dp[0] = 1;
	while(k--)
	{
		int x;
		cin >> x;
		go(x);
	}
	
	cout << dp[n] << endl;
	
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
	return 0;
}



Measured memory_bytes: 12544
#coding:utf-8
n, x, y = map(int, input().split())
anslist = []
for i in range(n-1):
    anslist.append(0)

for s in range(1,n):
    for p in range(s+1,n+1):
        distance = min(abs(p - s),abs(x - s) + 1 + abs(p - y),abs(y - s) + 1 + abs(p - x))
        anslist[distance - 1] += 1

for k in range(len(anslist)):
    print("{}".format(anslist[k]))

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

int main() {
  int N = 0;
  int result = 0;
  long long int num = 0;
  cin >> N;
  map<int, int> dic;
  for (int i = 0; i < N; i++) {
    cin >> num;
    dic[num]++;
  }
  for (auto itr = dic.begin(); itr != dic.end(); ++itr) {
    if (itr->second % 2 == 1) {
      result += 1;
    }
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 4864
#include <iostream>
#include <string>
#include <queue>


struct ProcessInfo
{
	ProcessInfo() : name(), time()
	{
	}
	
	ProcessInfo(std::string n, int t) : name(n), time(t)
	{
	}
	
	std::string name;
	int time;
};


int main()
{
	int clock = 0;
	int n, q;
	std::cin >> n >> q;
	
	std::queue<ProcessInfo> pq;
	
	for (int i = 0; i < n; ++i) {
		ProcessInfo pi;
		std::cin >> pi.name >> pi.time;
		pq.push(pi);
	}
	
	while (!pq.empty()) {
		ProcessInfo pi = pq.front();
		pq.pop();
		
		if (pi.time > q) {
			pq.push(ProcessInfo(pi.name, pi.time - q));
			clock += q;
		} else {
			clock += pi.time;
			std::cout << pi.name << " " << clock << std::endl;
		}
		
	}
	
	return 0;
}

Measured memory_bytes: 4404
N, M=map(int, input().split())
ac=[0]*N
wa=[0]*N

for i in range(M):
    p, S=input().split()
    p=int(p)
    if ac[p-1]==0:
        if S=="AC":
            ac[p-1]=1
        elif S=="WA":
            wa[p-1]+=1
            
wacnt=0
for i in range(N):
	if ac[i]>=1:
		wacnt+=wa[i]
		
print(sum(ac), wacnt)

Measured memory_bytes: 4596
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    String s = scan.next();
    if (n<3200){
    	System.out.println("red");
    }
    else{
      System.out.println(s);
    }
  }
}

Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>

using namespace std;

int n, k, m[256];
bool know[256][256];
bool leak[256];

int main(){

	while(cin>>n, n){
		
		memset(know, 0, sizeof(know));
		memset(leak, 0, sizeof(leak));

		for(int i=0; i<n; ++i){
				
			int m;
			cin>>m;
			
			for(int j=0; j<m; ++j){
				
				int p;
				cin>>p;
				know[i][--p] = true;
			}
		}

		cin>>k;

		for(int i=0; i<k; ++i){
			
			int l;
			cin>>l;
			leak[--l]=true;
		}

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

			bool f = true;
			int cnt = 0;

			for(int j=0; j<n; ++j){
				
				if( i != j && !know[i][j] && leak[j] ){
					f = false;
					break;
				}

				if( know[i][j] && leak[j] ){
					cnt++;
				}
			}
			
			if(f&&cnt==k){
				if(spy==-1)
					spy = i;
				else
					spy = -2;
			}
		}

		cout << (spy>=0?++spy:-1) << endl;
	}

	return 0;
}

Measured memory_bytes: 1232
n=gets.to_i


array1=gets.split

array1=array1.map{|s| s.to_i}.sort

array2=gets.split

array2=array2.map{|s| s.to_i}.sort


array3=gets.split.sort.reverse

array3=array3.map{|s| s.to_i}.sort



j=0
ss=0
tt=0
answer=0
n.times{
    
     loop{if ss<n  &&  array1[ss]<array2[j]

        ss+=1
     else
         break
    end
    
    if ss==n
        break
    end
     }
     loop{if tt<n && array3[tt]<=array2[j]
       
        tt+=1
     else
         break
    end
    
    if tt==n
        break
    end
     }
     
     
     answer+=ss*(n-tt)
     
     
     
   j+=1
   
    
}

puts answer










Measured memory_bytes: 32624
A,B,C,X,Y = map(int,input().split())
cmin = 10**10
for k in range(max(X,Y)+1):
    n = max(X-k,0)
    m = max(Y-k,0)
    cmin = min(cmin,n*A+m*B+2*k*C)
print(cmin)

Measured memory_bytes: 39408
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <set>

#define lowbit(x) (x&(-x))
#define MAX(a,b) (a<b?b:a)
#define MIN(a,b) ((a)<(b)?(a):(b))
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int N = 2e5;
const int maxn = 2e5 + 5;
ll mod = 1e9 + 7;

int n,k, a[maxn];
ll s[maxn],pre[maxn], suf[maxn];

int main()
{
	scanf("%d%d", &n,&k);
	for (int i = 1; i <= n; i++)
	{
		scanf("%d", a + i);
		s[i] = s[i - 1] + a[i];
		pre[i] = pre[i - 1];
		if(a[i]>0) pre[i] += a[i];
	}
	for (int i = n; i > 0; i--)
	{
		suf[i] = suf[i + 1];
		if (a[i] > 0) suf[i] += a[i];
	}

	ll ans = 0;
	for (int i = k; i <= n; i++)
	{
		ans = max(ans, max(0LL,s[i] - s[i - k]) + pre[i - k] + suf[i + 1]);
	}
	printf("%lld", ans);
}

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

int main(void) {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int64_t> A(N);
  rep(i, N) cin >> A[i];

  int64_t answer = 0;
  rep(i, N - 1) {
    if (A[i] > A[i + 1]) {
      int64_t add = (A[i] - A[i + 1]);
      answer += add;
      A[i + 1] += add;
    }
  }
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 4836