akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
using namespace std;


int h, w;
string mat1[50];
string mat2[50];


int get_count(int x, int y)
{
  int cnt=0;

  for ( int i=x-1; i<x+2; i++ ) {
    if ( i < 0 || i > h-1 ) continue;
    for ( int j=y-1; j<y+2; j++) {
      if ( j < 0 || j > w-1 ) continue;
      if ( mat1[i][j] == '#' ) cnt++;
    }
  }
  return cnt;
}


int main()
{
  cin >> h >> w;
  for ( int i=0; i<h; i++ ){
    string tmp;
    cin >> tmp;
    mat1[i] = tmp;
    mat2[i] = tmp;
  }

  for ( int i=0; i<h; i++ ) {
    for ( int j=0; j<w; j++ ) {
      if ( mat1[i][j] == '.' ) {
	int cnt = get_count(i, j);
	mat2[i][j] = char(cnt + '0');
      } else {
	mat2[i][j] = '#';
      }
    }
  }

  for ( int i=0; i<h; i++ ) cout << mat2[i] << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 0x7fffffff
using namespace std;
typedef long long ll;
inline ll min(ll x,ll y) {return x<y?x:y;}
inline ll max(ll x,ll y) {return x>y?x:y;}
const int Maxn=1e5+5;
int n,x,sv,cnt;
ll ans;
vector< vector<int> >a(Maxn);
int main()
{
	cin>>n;
	sv=sqrt(1+8*n);
	if(sv*sv!=1+8*n)
	{
		puts("No");
		return 0;
	}
	x=(1+sv)/2;
	printf("Yes\n%d\n",x);
	for(int i=1;i<=x;i++)
	{
		printf("%d ",x-1);
		for(int j=0;j<i-1;j++)
			printf("%d ",a[i][j]);
		for(int j=1;j<=x-i;j++)
		{
			printf("%d ",++cnt);
			a[i+j].push_back(cnt);
		}
		puts("");
	}
 	return 0;
}


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
//const int mod=998244353;
using P = pair<int,int>;
using Pll = pair<ll,ll>;
using ld=long double;

int main() {
    int n,x;cin >>n>>x;
    vector<int>a(n);
    for (int i = 0; i < n; ++i) {
        cin >>a[i];
    }
    sort(all(a));
    ll sum=0;
    int ans=0;
    for (int i = 0; i < n; ++i) {
        sum+=a[i];
        if(sum<=x){
            ans++;
        }
    }
    if(sum<x){
        ans--;
    }
    cout <<ans <<endl;
}

Measured memory_bytes: 3600
module ABC095

	! <module>s to import
	use, intrinsic :: iso_fortran_env


	! require all variables to be explicitly declared
	implicit none


	! accessibility of <subroutine>s and <function>s in this <module>
	public  :: ABC095_A


	! constants for this <module>
	integer( kind=INT32 ), parameter, private :: num_topped = 3
	integer( kind=INT32 ), parameter, private :: val_base   = 700
	integer( kind=INT32 ), parameter, private :: val_topped = 100


	! contained <subroutine>s and <function>s are below
	contains


	subroutine ABC095_A

		! variables for this <subroutine>
		character(len=num_topped, kind=1) :: buffer
		integer( kind=INT16 )             :: itr, val_total

		! STEP.01
		! read out the target positive integers
		read *, buffer

		! STEP.02
		! count the number of the `1`
		val_total = val_base

		do itr = 1, num_topped, 1
			if( ichar( buffer(itr:itr) ) .eq. ichar('o') ) val_total = val_total+val_topped
		end do

		! STEP.03
		! output the result
		write( unit=OUTPUT_UNIT, fmt='(I0)', advance='yes' ) val_total

		! STEP.END
		return

	end subroutine ABC095_A

end module ABC095


program main

	! <module>s to import
	use, non_intrinsic :: ABC095

	! require all variables to be explicitly declared
	implicit none

	call ABC095_A

end program main


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define MOD 1000000007 //S(vector).size()
using namespace std;
typedef long long ll;

int main(void){
  int n;
  cin >> n;
  int a[n], b[n];
  rep(i, n) {
    cin >> a[i];
    b[i] = a[i];
  }

  sort(a, a + n);
  int right = a[n / 2];
  int left = a[n / 2 - 1];
  rep(i, n){
    if(b[i] < right) cout << right << endl;
    else cout << left << endl;
  }

  return 0;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int n = N;
  int d = 0;
  while (n > 0) {
    d += n % 10;
    n /= 10;
  }
  if (N % d == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
n = input()
a = int(n[0])
b = int(n[1])
c = int(n[2])
d = int(n[3])
e = [b,c,d]
l = [[0,0,0],[0,0,1],[0,1,0],[0,1,1],[1,0,0],[1,0,1],[1,1,0],[1,1,1]]
for i in range(8):
  ll = l[i]
  now = a
  for j in range(3):
    if ll[j] == 0:
      now += e[j]
    else:
      now -= e[j]
  if now == 7:
    f = []
    for j in range(3):
      if ll[j] == 0:
        f.append('+')
      else:
        f.append('-')
    print( str(a) + f[0] + str(b) + f[1] + str(c) + f[2] + str(d) + '=7' )
    break

Measured memory_bytes: 3064
a=[]
n=int(input());s=n**.5
while n%2==0 and n>3:a+=[2];n//=2
d=3
while s>d and n>d:
 if n%d>0:d+=2
 else:a+=[d];n//=d
a+=[n]
p=1
for f in set(a):
 p*=f**a.count(f)*(1-1/f)
print(int(p))


Measured memory_bytes: 5636
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll dp[100005];

int main()
{
    ll n,k,ind;
    cin>>n>>k;
    ll a[n+5];
    for(int i=0; i<n; i++)
        cin>>a[i];
    for(int i=0; i<=n; i++)
        dp[i]=LLONG_MAX;
    dp[0]=0;
    dp[1]=abs(a[1]-a[0]);
    for(int i=2; i<n; i++)
    {
        if(i<=k)
            ind=0;
        else
            ind=i-k;
        for(int j=ind; j<=i-1; j++)
        {
            dp[i]=min(dp[i],(dp[j]+abs(a[i]-a[j])));
        }
        //cout<<dp[i]<<endl;
    }
    cout<<dp[n-1]<<endl;
    return 0;
}



Measured memory_bytes: 5132
a, b, c, x, y = map(int, input().split())
#a, b, c, x, y = 1500, 2000, 500, 90000, 100000
#na, nb, nc = x, y, 0
mx = 10**18
for i in range(0, max(x,y)*2+1):
  if i%2==1: continue
  total = max(a*(x-i//2), 0) + max(b*(y-i//2), 0) + c*i
  if total<mx:
    mx=total

print(mx)


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
const int INF = 1e9;

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

	ll N;
	ll ans = 0;

	cin >> N;
	vector<ll> d(N);
	rep(i, N) cin >> d[i];

	sort(d.begin(), d.end());

	ll m1 = d[N / 2 - 1];
	ll m2 = d[N / 2];

	ans = m2 - m1;


	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ALL(V) V.begin(), V.end()
using namespace std;
using ll = __int128_t;
template <typename T> using V = vector<T>;
template <typename T> using VV = vector<V<T>>;

istream& operator >>(istream &s, ll &v) {
    int64_t a;
    s >> a;
    v = a;
    return s;
}

ostream& operator <<(ostream &s, ll v) {
    auto a = static_cast<int64_t>(v);
    s << a;
    return s;
}

template <typename T>
class Bit{
    private:
        V<T> data;
        T identity_ele;

    public:

        Bit(ll size, T identity_ele) {
            ll newsize = 1;
            while(newsize < size)  newsize = newsize << 1;
            this->identity_ele = identity_ele;
            data = V<T>(newsize + 1, identity_ele);
        }

        /*
         * 0-origin
         */
        T sum(ll pos) {
            T ret = identity_ele;
            pos++;
            while(pos > 0) {
                ret += data[pos];
                pos -= pos & -pos;
            }
            return ret;
        }

        /*
         * 0-origin
         */
        void add(ll pos, T delta) {
            pos++;
            while(pos <= data.size()) {
                data[pos] += delta;
                pos += pos & -pos;
            }
        }
};

struct Ball {
    ll a, c;
};

const ll INF = 5e15;
VV<ll> dp(2010, V<ll>(2010, INF));
V<Ball> VB;
ll N;
V<ll> winv(2010), binv(2010);
VV<ll> lbcnt(2010, V<ll>(2010)), lwcnt(2010, V<ll>(2010));

void calc() {
    Bit<ll> BB(N + 20, 0), WB(N + 20, 0);
    for(const Ball &e : VB) {
        ll a = e.a, c = e.c;
        auto &B = (c == 0 ? WB : BB);
        auto &Bi = (c == 0 ? BB : WB);
        auto &cnt = (c == 0 ? lbcnt : lwcnt);
        auto &inv = (c == 0 ? winv : binv);
        B.add(a, 1);
        inv[a] = B.sum(N + 10) - B.sum(a);
        for(ll i = 0; i <= N; i++) cnt[a][i] = Bi.sum(i);
    }
}

int main() {
    cin >> N;
    V<Ball> v;
    V<ll> wv, bv;
    dp[0][0] = 0;
    for(ll i = 0; i < 2 * N; i++) {
        char c;
        ll a;
        cin >> c >> a;
        VB.push_back(Ball{a, c == 'B'});
        (c == 'W' ? wv : bv).push_back(a);
    }
    calc();
    for(ll i = 1; i <= 2 * N; i++) {
        for(ll w = 0; w <= N; w++) {
            ll b = i - w;
            if(!(0 <= w && w <= N &&
                 0 <= b && b <= N)) continue;
            ll val = dp[w][b];
            if(0 < w && w <= N) {
                ll tmp = dp[w - 1][b];
                tmp += winv[w];
                tmp += b - lbcnt[w][b];
                val = min(val, tmp);
            }
            if(0 < b && b <= N) {
                ll tmp = dp[w][b - 1];
                tmp += binv[b];
                tmp += w - lwcnt[b][w];
                val = min(val, tmp);
            }
            dp[w][b] = val;
        }
    }
    //for(ll i = 0; i <= N; i++) for(ll j = 0; j <= N; j++) cout << "dp[" << i << "][" << j << "] = " << dp[i][j] << endl;
    cout << dp[N][N] << endl;
    return 0;
}


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


long MAX = 100005;
long INF = 1234567890;
class DisjointSet{
public:
  vector<int> rank, p;

  DisjointSet(){}
  DisjointSet(int size){
    rank.resize(size, 0);
    p.resize(size, 0);
    for(int i=0;i<size;i++) makeSet(i);
  }

  void makeSet(int x){
    p[x]=x;
    rank[x]=0;
  }
  bool same(int x, int y){
    return findSet(x)==findSet(y);
  }

  void unite(int x, int y) {
    link(findSet(x),findSet(y));
  }

  void link(int x, int y){
    if(rank[x]>rank[y]){
      p[y]=x;
    }else{
      p[x]=y;
      if(rank[x]==rank[y]){
        rank[y]++;
      }
    }
  }

  int findSet(int x){
    if(x!=p[x]){
      p[x]=findSet(p[x]);
    }
    return p[x];
  }
};

class Edge{
public:
  long source, target, cost;
  Edge(int source=0,int target=0, long cost=0):
  source(source),target(target),cost(cost){}
  bool operator<(const Edge &e) const{
    return cost<e.cost;
  }
};

long Kruskal(int N,vector<Edge> edges){
  long totalCost=0;
  sort(edges.begin(),edges.end());
  DisjointSet dset = DisjointSet(N+1);
  for(int i=0;i<N;i++) dset.makeSet(i);
  double source, target;
  for(int i=0;i<edges.size();i++){
    Edge e =edges[i];
    if(!dset.same(e.source,e.target)){
      totalCost+=e.cost;
      dset.unite(e.source,e.target);
    }
  }
  return totalCost;
}

int main(){
  double N,cost;
  double source,target;
  cin>>N;

  vector<Edge> edges;

  vector<vector<long>> a(N, vector<long>(3));
  vector<vector<long>> b(N, vector<long>(3));
  for(int i=0;i<N;i++){
    int x,y;
    cin>>x>>y;
    a[i][0]=x,a[i][1]=y,a[i][2]=i;
    b[i][0]=y;b[i][1]=x,b[i][2]=i;
  }
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());

  for(int i=0;i<N-1;i++){
    edges.push_back(Edge(a[i][2],a[i+1][2],abs(a[i+1][0]-a[i][0])));
    edges.push_back(Edge(b[i][2],b[i+1][2],abs(b[i+1][0]-b[i][0])));
    //cout<<a[i][2]<<" "<<a[i+1][2]<<" "<<abs(a[i+1][0]-a[i][0])<<endl;;
    //cout<<b[i][2]<<" "<<b[i+1][2]<<" "<<abs(b[i+1][0]-b[i][0])<<endl;;
  }
  //cout<<edges.size()<<endl;
  /*
  for(int i=0;i<M;i++){
    cin>>source>>target>>cost;
    edges.push_back(Edge(source,target,cost));
  }
  */
  cout<<Kruskal(N,edges)<<endl;
}


Measured memory_bytes: 22764
#include<iostream>
#include<fstream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<string>
#include<cstring>
using namespace std;
string st;
char ch,ch1;
int s;
int main()
{
	cin>>st;
	ch=st[0];
	ch1=st[st.size()-1];
	s=st.size()-2;
	cout<<ch;
	cout<<s;
	cout<<ch1<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll               long long
#define dl               double
#define ull              unsigned long long
#define ft               first
#define sd               second
#define pi               acos(-1)
#define ct(tc)           scanf("%lld",&tc)
#define scnm(n,m)        scanf("%lld %lld",&n,&m);
#define max3(a,b,c)      max(a,max(b,c))
#define max4(a,b,c,d)    max(a,max(b,max(c,d)))
#define min3(a,b,c)      min(a,min(b,c))
#define min4(a,b,c,d)    min(a,min(b,min(c,d)))
#define pb               push_back
#define srt              sort(v.begin(),v.end())
#define rsrt             reverse(v.begin(),v.end())
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    ll n,m;
    scnm(n,m);
    if(n>8||m>8)
    {
        printf(":(\n");
    }
    else
    {
        printf("Yay!\n");
    }
    return 0;

}


Measured memory_bytes: 3696
#include<bits/stdc++.h>
    #define ll long long
    #define rep(i,a,b) for(i=a;i<b;i++)
    #define pb push_back
    #define all(v) v.begin(),v.end()
    #define F first
    #define S second
    #define CLR(a) memset((a),0,sizeof(a))
    #define mp make_pair
    #define hell 1000000007

    using namespace std;
     //int g[105][105];
    //vector < int > wt(100004);
   // vector < int > a;
    //vector < int > v(30500);
    //int cst[102][100005];
    //int ansr[100005];
 //ll int sum,x=0,c=0,n,m,flag=0,a1,a2,flag1=0,flag2=0;
    //vector < vector < int > > adj(5000, vector < int > (5000));
 //int  dp[1000006];
   // int level[500];

    void solve()
    {
         ll int i,j=0,r=200,p,q,y=0,ans=0,d,h,flag=0,n,m,a,b,c;
         cin>>n;
         vector < pair < ll int , ll int > >v(n);
         rep(i,0,n)
          {
            cin>>v[i].S>>v[i].F;
          }
          sort(all(v));
          rep(i,0,n)
            {
                y+=v[i].S;
                if(y<=v[i].F)
                    continue;
                else
                {
                    cout<<"No"; return;
                }
            }
            cout<<"Yes";

    }



    int main()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        int t=1;
        //cin>>t;
        while(t--)
        solve();
    }

       /*

  void bfs( int i , int j)
       {
           vis[i][j]= true;
         queue < int > que;
         que.push(k);
         while(!que.empty())
         {
            int x= que.front();
            que.pop();
             for ( int i=1;i<=n;i++)
             {
                 if((!g[1][n] and g[x][i] ) or (g[1][n] and ! g[x][i]))
                 {
                   if(!vis[i])
                   {
                       que.push(i);
                       level[i]=level[x]+1;
                       vis[i]= true;
                   }
                 }
             }
         }
       }

      ll int por(ll int a,ll int b)
         {
            ll int k=1;
            while(b>0)
            {
                if(b%2) k=k*a,k%=hell;
                b/=2;
                a*=a; a%=hell;
            }
            return k;
         } */


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

int main() {

	int N = 0;
	int W = 0;
	cin >> N >> W;

	int * weights = new int[N+1];
	int * values = new int[N+1];
	int ** C = new int*[N+1];
	for(int i = 0; i < N+1; i++){
	    C[i] = new int[W+1];
	}
	
	for(int n = 1; n <= N; n++){
	    cin >> values[n] >> weights[n];
	}
	
	for(int w = 0; w < W+1; w++){
	    C[0][w] = 0;
	}
	
	for(int i = 1; i < N+1; i++){
	    C[i][0] = 0;
	}
     
    for(int i = 1; i < N+1; i++){
        for(int w = 0; w < W+1; w++){
            if(weights[i] <= w){
                if(values[i] + C[i-1][w-weights[i]] > C[i-1][w]){
                    C[i][w] = values[i] + C[i-1][w-weights[i]];
                }else{
                    C[i][w] = C[i-1][w];
                }
            }else{
                C[i][w] = C[i-1][w];
            }
            
        }
    }
    
   
    cout << C[N][W] << endl;
	
	
}

Measured memory_bytes: 5136
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	int ans = 0, left = INF, right = -INF;
	for(int i = 0; i < s.size(); i++)
	{
		if(s[i] == 'A') left = min(i, left);
		if(s[i] == 'Z') right = max(i, right);
	}
	cout << right - left + 1<< endl;
	return 0;
}



Measured memory_bytes: 720
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <cstring>

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

using namespace std;
typedef long long ll;



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

    
    ll A[N];
    rep(i,N)cin>>A[i];
    
    ll mx=A[0];
    ll ans=0;
    
    
    rep(i,N){
        mx=max(A[i],mx);
        ans+=mx-A[i];
    }
    
    cout<<ans<<endl;
   

}

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

#include <iostream>
using namespace std;

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

    set<int> a;
    int n;
    cin >> n;

    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        if (!a.count(x)) {
            a.insert(x);
        }
        else {
            cout << "NO";
            return 0;
        }
    }

    cout << "YES";
}

Measured memory_bytes: 9600
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define tarce(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define pb push_back
#define inf 2e18
#define scan() int n; cin>>n ; int a[n+1]; for(int i = 1 ; i<=n ; i++) cin>>a[i]
#define scan2() int n,k; cin>>n>>k ; int a[n+1]; for(int i = 1 ; i<=n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
#define mem(a,v) memset(a,v,sizeof(a))
#define pii pair<int,int>
#define mkp make_pair
using namespace std;
#define N 200005



int32_t main(){
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);

        int a,b;
        cin >> a >> b;
        int ans=max({a+b,2*a-1,2*b-1});
        cout << ans;
        

}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

	String fileName = "prizes";

	public void solve() throws IOException {
		int n = nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		Arrays.sort(a);
		int al = 0;
		int bo = 0;
		for (int i = n - 1; i >= 0; i -= 2) {
			al += a[i];
			if (i - 1 >= 0)
				bo += a[i - 1];
		}
		out.print(al - bo);
	}

	public void run() {
		try {
			br = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out, true);
			solve();
			out.close();
		} catch (IOException e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

	BufferedReader br;
	StringTokenizer in;
	static PrintWriter out;

	public String nextToken() throws IOException {
		while (in == null || !in.hasMoreTokens()) {
			in = new StringTokenizer(br.readLine());
		}
		return in.nextToken();
	}

	public int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	public double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	public long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

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

}

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);  
	
	int n, m, q; cin >> n >> m >> q;
	vector<vector<int>> trains(n + 1,vector<int>(n + 1));
	for(int i = 0; i < m; i++){
		int a, b; cin >> a >> b;
		trains[a][b]++;
	}                
	for(int i = 0; i <= n; i++){
		for(int j = 1; j <= n; j++) trains[i][j] = trains[i][j] + trains[i][j - 1];
	}
	for(int i = 0; i < q; i++){
		int l, r; cin >> l >> r;
		int ans = 0;
		for(int j = l; j <= r; j++) ans += trains[j][r] - trains[j][l -1];
		cout << ans << endl;                     
	}
		
	return 0;	
}





  

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

int main(void) {
  int N;
  cin >> N;

  int S[MAX_N];
  int SUM = 0;
  int MIN = INT32_MAX;
  rep(i, N) {
    cin >> S[i];
    SUM += S[i];
    if (S[i] % 10) {
      MIN = min(MIN, S[i]);
    }
  }

  if (SUM % 10) {
    cout << SUM << endl;
  } else if (MIN == INT32_MAX) {
    cout << "0" << endl;
  } else {
    cout << (SUM - MIN) << endl;
  }

  return 0;
}

Measured memory_bytes: 256
N = int(raw_input())

for i in range(N):

  Ball = map(int, raw_input().split())

  left, right = [], []

  for i in Ball:
    if len(left) == 0 or left[len(left) - 1] < i:
      left.append(i)

    elif len(right) == 0 or right[len(right) - 1] < i:
      right.append(i)

    else:
      break

  if len(right) + len(left) == 10:
    print "YES"

  else:
    print "NO"

Measured memory_bytes: 6276
#include <bits/stdc++.h>
#define log(x) cout<<x<<endl
#define pb push_back
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
using Graph=vector<vector<int>>;

int gcd(lint x, lint y){
  return y==0 ? x:gcd(y,x % y);
}

int digsum(int n) {
  int res = 0;
  while(n > 0) {
    res += n%10;
    n /= 10;
  }
  return res;
}

int dignum(int n) {
  int res = 0;
  while(n > 0) {
    res++;
    n /= 10;
  }
  return res;
}

int stringcount(string s, char c) {
  return count(s.cbegin(), s.cend(), c);
}

int lcm(lint x, lint y){
  return x/ gcd(x, y) * y;
}

int combi(int n, int r){
  int num = 1;
  for(int i = 1; i <= r; i++){
    num = num * (n - i + 1) / i;
  }
  return num;
}

int main(){
  for(int i=1;i<=5;i++){
    int j=0;
    cin>>j;
    if(j==0){
      cout<<i<<endl;
      break;
    }
  }
}

Measured memory_bytes: 3584
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
#include <iomanip>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

void f(int s)
{
	printf("%02d:%02d:%02d\n", s / 3600, int(s / 60) % 60, s % 60);
}

int main()
{
	int h, m, s;
	while(cin >> h >> m >> s && (h + 1 && m + 1 && s + 1))
	{
		s = 120 * 60 - (h * 3600 + m * 60 + s);
		f(s);
		f(s * 3);
	}
}

Measured memory_bytes: 0
import bisect
N = int(input())
d = list(map(int, input().split()))
d = sorted(d)
mn = min(d)
mx = max(d)
ans = 0
for i in range(mn, mx+1):
  idx = bisect.bisect_left(d, i)
  if idx == N//2:
    ans += 1
print(ans)

Measured memory_bytes: 53036
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main() {  
	string vals[3] = {"Sunny", "Cloudy", "Rainy"};
	string S; cin >> S;
    for(int i=0;i<3;i++){
		if (S == vals[i]) {
			cout << vals[(i+1)%3] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
r,m,y,s;v(int*a,int*b){r=*a,*a=*b,*b=7-r;}main(t,c){s=!scanf("%d",&c),c?:exit(0);for(m=2,y=3;c--;s+=t)scanf("%s",&r),r%=8,r-2?r-3?r-4?r-5?r-6?r-7?:v(&t,&y):v(&t,&m):v(&y,&t):v(&y,&m):v(&m,&t):v(&m,&y);main(1,printf("%d\n",s+1));}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
 
using lli = long long int;
using ll = long long ;
using ld=long double;
using d= double;

int main() {
	lli k;
	cin>>k;
	ll a=100;
	ll ans=0;
	while(a<=k){
	    a+=a/100;
	    ans++;
	    if(a>=k){
	        cout<<ans;
	        return 0;
	    }
	}
	return 0;
}

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

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#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)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {

	int n, k, q; cin >> n >> k >> q;
	vector<int> tb(n);

	for (int i = 0; i < q; i++) {
		int val; cin >> val; val--;
		tb[val]++;
	}

	for (int i = 0; i < n; i++) {
		if (k-(q - tb[i]) > 0) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1024
while True:
    a, op, b = input().split()
    
    a = int(a)
    b = int(b)
    
    if op == "+":
        x = a + b
        print(x)
    elif op == "-":
        x = a - b
        print(x)
    elif op == "*":
        x = a * b
        print(x)
    elif op == "/":
        x = a // b
        print(x)
    elif op == "?":
        break


Measured memory_bytes: 5596
K = int(input())
arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 
       14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(arr[K-1])

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <functional>
#include <iomanip>
#include <bitset>
#include <numeric>
#include <queue>
#include <map>
#include <cstdint>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
const long long mod = 1000000007;
typedef long long int ll;
typedef pair<int, int> P;
const vector<int> di = { -1, 0, 1, 0 };
const vector<int> dj = { 0, 1, 0, -1 };


int main() {

	string s;
	cin >> s;

	bool ans = false;
	rep(i, 2) {
		if (s.at(i) != s.at(i + 1)) {
			ans = true;
			break;
		}
	}
	if (ans) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
{-# LANGUAGE FlexibleInstances    #-}
{-# LANGUAGE TypeSynonymInstances #-}

import           Control.Applicative
import           Control.DeepSeq
import           Control.Monad
import           Control.Monad.ST
import qualified Data.Array                  as A
import qualified Data.Array.IArray           as IA
import qualified Data.Array.IO               as AI
import qualified Data.Array.MArray           as MA
import qualified Data.Array.ST               as STA
import qualified Data.Array.Unboxed          as AU
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import qualified Data.Graph                  as G
import           Data.Int
import qualified Data.IntMap                 as IM
import qualified Data.IntSet                 as IS
import           Data.List
import qualified Data.Map.Strict             as M
import           Data.Maybe
import           Data.Ord
import qualified Data.Sequence               as SQ
import qualified Data.Set                    as S
import           Data.Time
import qualified Data.Tree                   as T
import qualified Data.Vector                 as V
import qualified Data.Vector.Mutable         as VM
import qualified Data.Vector.Unboxed         as VU
import qualified Data.Vector.Unboxed.Mutable as VUM

readInt :: IO [Int]
readInt = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

readInts :: Int -> IO [[Int]]
readInts n = replicateM n readInt

readInteger :: IO [Integer]
readInteger = map (fst . fromJust . BS.readInteger) . BS.words <$> BS.getLine

readIntegers :: Int -> IO [[Integer]]
readIntegers n = replicateM n readInteger

readString :: IO [String]
readString = map BS.unpack . BS.words <$> BS.getLine

readStrings :: Int -> IO [[String]]
readStrings n = replicateM n <$> readString

toPair :: [a] -> (a, a)
toPair [x, y] = (x, y)

count :: Eq a => a -> [a] -> Int
count a as = length $ filter (== a) as

put :: Show a => a -> IO ()
put = putStr . show

putLn :: Show a => a -> IO ()
putLn = print

putList :: Show a => [a] -> IO ()
putList [n] = put n
putList (n:ns) = do
  put n
  putStr " "
  putList ns

putStrList :: [String] -> IO ()
putStrList [n] = putStr n
putStrList (n:ns) = do
  putStr n
  putStr " "
  putStrList ns

yesNoUpper b
  | b = putStrLn "YES"
  | otherwise = putStrLn "NO"

yesNo b
  | b = putStrLn "Yes"
  | otherwise = putStrLn "No"

main = do
  [x, a, b] <- readInt
  if abs (a - x) < abs (b - x)
    then putStrLn "A"
    else putStrLn "B"


Measured memory_bytes: 380
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(){
    int N, x; cin >> N >> x;
    vector<ll> a(N);
    for(int i=0; i<N; i++) cin >> a[i];

    ll ans = 0;
    if(a[0] > x){
        ans = a[0]-x;
        a[0] = x;
    }

    for(int i=1; i<N; i++){
        if(a[i-1] + a[i] > x){
            ans += a[i-1] + a[i] - x;
            a[i] = x - a[i-1];
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
#define w(x) int x; cin>>x; while(x--)

long long int give(long long int n)
{
    long long int ans=0;
    for(int i=1;i<=sqrt(n);i++)
    {
        if(n%i==0)
        {
            ans++;
            if(n/i !=i)
                ans++;
        }

    }
    return ans;
}

int main()
{
  #ifndef ONLINE_JUDGE
       freopen("input.txt","r",stdin);
       freopen("output3.txt","w",stdout);
   #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
string str;
cin>>str;
int n=str.length();
if(str[n-1]=='s')
    cout<<str+"es";
else
    cout<<str+'s';
}

Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <string>
using namespace std;

int main() {
	int N; cin >> N;
	int X = N / 1.08;
	int price = X * 1.08, price2 = (X + 1) * 1.08, price3 = (X - 1) * 1.08;
	if (price == N) cout << X << endl;
	else if (price2 == N) cout << X + 1 << endl;
	else if (price3 == N) cout << X - 1 << endl;
	else cout << ":(" << endl;
}

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

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
#define clr(a,v) memset(a, v, sizeof(a))

#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)
#define reflex ios_base::sync_with_stdio(false)

#define nl '\n'
#define ioi exit(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int N= (int)2e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
const ll linf = (ll)1e18 + 7;

const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int kx[] = {-1,1,2,2,1,-1,-2,-2};
const int ky[] = {2,2,1,-1,-2,-2,-1,1};

string conv(int a){
	stringstream ss;
	ss << a;
	string str = ss.str();
	return str;
}


string conv(char a){
	stringstream ss;
	ss << a;
	string str = ss.str();
	return str;
}

int conv(string a){
    stringstream geek(a); 
    int x = 0; 
    geek >> x;   
	return x;
}

pll v[N];
int main(){
	int n, m; cin>> n>> m;
	ll a, b;
	rep(i,1,n){
		cin>> a >> b;
		v[i] = mp(a,b);
	}
	sort(v+1,v+1+n);
	ll sum = 0;
	ll cust = 0;
	int i = 1; 
	while(sum + v[i].s < m){
		sum += v[i].s;
		cust += v[i].f*v[i].s;
		i++;
	}
	
	if(sum + v[i].s == m){
		sum += v[i].s;
		cust += v[i].f*v[i].s;
	}
	else{
		ll k = m - sum;
		cust += k*v[i].f;
	}
	
	cout<<cust;
	return 0;
}


//Problem A
/*
 int v[100010];
int x1[100010];
int x2[100010];

int main(){
	clr(x1,0);
	clr(x2,0);
	int n; cin>> n;
	rep(i,1,n)
		cin>> v[i];
	rep(i,1,n){
		if(v[i] == 2)
			x2[i] = x2[i-1] + 1;
	}
	per(i,n,1){
		if(v[i] == 1)
			x1[i] = x1[i+1] + 1;
	}
	int maxi = 0;
	rep(i,1,n-1){
		if(v[i] != v[i+1]){
			//~ cout<<i<<":"<<x2[i]<<" "<<i+1<<":"<<x1[i+1]<<endl;
			maxi = max(maxi, min(x2[i],x1[i+1]));
		}
	}
	//~ rep(i,1,n)
		//~ cout<<x2[i]<<" "; 
	//~ cout<< endl;
	//~ rep(i,1, n)
		//~ cout<<x1[i]<<" ";
	//~ cout<<endl;
	//~ cout<<endl;
	clr(x1,0);
	clr(x2,0);
	rep(i,1,n){
		if(v[i] == 1)
			x1[i] = x1[i-1] + 1;
	}
	per(i,n,1){
		if(v[i] == 2)
			x2[i] = x2[i+1] + 1;
	}
	
	rep(i,1,n-1){
		if(v[i] != v[i+1]){
			//~ cout<<i<<":"<<x2[i]<<" "<<i+1<<":"<<x1[i+1]<<endl;
			maxi = max(maxi, min(x1[i],x2[i+1]));
		}
	}
	
	//~ cout<< maxi<<endl;
	cout<<2*maxi<<endl;
	//~ rep(i,1,n)
		//~ cout<<x2[i]<<" "; 
	//~ cout<< endl;
	//~ rep(i,1, n)
		//~ cout<<x1[i]<<" ";
	//~ cout<<endl;
	return 0;
}

 */


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

#define REP(i, n) for(int (i) = 0; (i) < (n); ++(i))
#define REPR(i, n) for(int (i) = (n); (i) >= 0; --(i))
#define FOR(i, n, m) for(int (i) = (n); (i) < (m); ++(i))

// constexpr int INF = 1e9;
// constexpr ll INF = 1LL<<61;
constexpr ll mod = 1e9+7;



int main(){
  int A, B, C;
  cin >> A >> B >> C;
  int K;
  cin >> K;
  int cnt = 0;
  while(A >= B){
    B*=2;
    cnt++;
  }
  while(B>=C){
    C*=2;
    cnt++;
  }
  if(cnt <= K){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

// メモ化再帰用DPテーブル
vector<vector<vector<double>>> dp(301, vector<vector<double>>(302, vector<double>(302, -1.0)));

// 寿司が1個置かれた皿がi枚、2個置かれた皿がj枚、3個置かれた皿がk枚
double evalue(const long long n, long long i, long long j, long long k){
    // すでに計算済みならその結果を返す
    if(dp[i][j][k] > -1.0) return dp[i][j][k];
    // 全て0なら期待値は0.0を返す
    if(i == 0 && j == 0 && k == 0) return 0.0;
    
    double eval = 1.0*n;
    if(i > 0) eval += i*evalue(n, i-1, j, k);
    if(j > 0) eval += j*evalue(n, i+1, j-1, k);
    if(k > 0) eval += k*evalue(n, i, j+1, k-1);
    return dp[i][j][k] = (eval*(1.0/(i+j+k)));
}

int main(){
    Init();
    ll n; cin >> n;
    vector<long long> cnt(4);
    for(long long i=0; i<n; i++){
        long long tmp;
        cin >> tmp;
        cnt[tmp]++;
    }
    cout << evalue(n, cnt[1], cnt[2], cnt[3]) << endl;
}

Measured memory_bytes: 219008
#include<bits/stdc++.h>
using namespace std;
const int INF = 1 << 30;
 
bool cmp(pair< int, int > a, pair< int, int > b)
{
  if(a.first != b.first) return(a.first > b.first);
  return(a.second < b.second);
}
int main()
{
  int N, p[100];
   
  while(scanf("%d", &N), N) {
    for(int i = 0; i < N; i++) {
      scanf("%d", &p[i]);
    }
     
    pair< int, int > dp[2][50001];
    fill_n(*dp, 2 * 50001, make_pair(-INF, INF));
    pair< int, int > *now = dp[0], *nxt = dp[1];
     
    now[0] = {0, 0};
    int reach = 0;
    for(int i = 0; i < N; i++) {
      int mod = p[i] % 1000;
      if(1 <= mod && mod <= 500) {
        int rev = 1000 - mod - 500;
        reach += rev;
        for(int j = reach; j >= rev; j--) {
          nxt[j] = min(nxt[j], {now[j - rev].first + 1, now[j - rev].second + p[i]}, cmp);
        }
      } else {
        int rev = (1000 - mod) % 1000;
        int need = (mod + 500) % 1000;
        reach += max(rev, need);
        for(int j = reach; j >= 0; j--) {
          nxt[j] = min(nxt[j], now[j], cmp);
        }
        for(int j = reach; j >= rev; j--) {
          nxt[j] = min(nxt[j], {now[j - rev].first, now[j - rev].second + p[i]}, cmp);
        }
        for(int j = need; j <= reach; j++) {
          nxt[j - need] = min(nxt[j - need], {now[j].first + 1, now[j].second + p[i]}, cmp);
        }
      }
      swap(now, nxt);
    }
    auto p = *min_element(now, now + 50000, cmp);
    printf("%d %d\n", p.first, p.second);
  }
}

Measured memory_bytes: 3972
#include <bits/stdc++.h>
#define REPZ(i, z, n) for(int i = (z); i < (n); i++)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(all(v)))
#define MIN(v) (*min_element(all(v)))
#define INF 1000000000000 //1E+12
#define MOD 1000000007    //合同式の法

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair

typedef long long ll;
typedef unsigned long long ul;
// 1s間で可能なループ回数2E+8回
// intの最大値2147483647~2E+9
// long longの最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<> push_back
// 連想配列map<key,value> insert,
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 setprecision()
// to_string<->stoi
// stoll(longlong)
// stod(double)
// 大文字65-90(-32)
// 小文字97-122(+32)
ll res=0LL;
using namespace std;
void dfs(ll d, ll v, int flag,ll n){ 
  if(v>n) return;
  if(flag==(1<<3 | 1<<5 | 1<<7)){
    res++;
  }
  
  dfs(d+1, 10*v+3, flag | 1<<3, n);
  dfs(d+1, 10*v+5, flag | 1<<5, n);
  dfs(d+1, 10*v+7, flag | 1<<7, n);
  return;
}
int main(){
  // faster
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  ll n; cin >> n;
  dfs(0,0,0, n);
  cout << res << endl;
  
  
  return 0;
}


Measured memory_bytes: 256
a, b = map(int, input().split())

x, y = '.', '#'
if a > b:
    a, b = b, a
    x, y = y, x

space = [[x for _ in range(100)] for _ in range(100)]

for z in range(b):
    i, j = divmod(z, 25)
    for di in range(3):
        for dj in range(3):
            space[i*4+di][j*4+dj] = y

for z in range(a-1):
    i, j = divmod(z, 25)
    space[i*4+1][j*4+1] = x

print("100 100")
print('\n'.join((''.join(row)) for row in space))

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

int main()
{
    string S; cin >> S;
    int changeNum = 0;
    for (int i=0; i<S.size()/2; i++) {
        int j = S.size() - 1 - i;
        if (S[i] != S[j]) {
            changeNum++;
        }
    }
    cout << changeNum << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int x,y;
    cin>>x>>y;
    for(int i=0;i<=1000000000;i++){
        if(abs(x-i)==abs(y-i)){
        cout<<i;
        return 0;}}
        cout<<"IMPOSSIBLE";

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int N;
  cin>>N;
  int A[N];
  REP(i,N)cin>>A[i];
  sort(A,A+N);
  set<int> s;
  int ans=0;
  REP(i,N){
    bool f=true;
    if(i+1<N and A[i]==A[i+1])f=false;
    FOR(j,1,sqrt(A[i])+1){
      if(A[i]%j==0){
        if(s.find(j)!=s.end())f=false;
        if(s.find(A[i]/j)!=s.end())f=false;
      }
    }
    if(f){
      // cout<<A[i]<<endl;
      ans++;
    }
    s.insert(A[i]);
  }
  cout<<ans<<endl;
  return 0;
}


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

using namespace std;

int main() {
	unordered_set <int> st;
	st.insert(1); st.insert(2); st.insert(3);

	int a, b; cin >> a >> b; st.erase(a); st.erase(b);

	cout << *begin(st); 
}

Measured memory_bytes: 3596
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <cstring>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <math.h>
using namespace std;

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

int main() {
  int A, B; cin >> A >> B;
  string S; cin >> S;
  bool flag = true;
  if (S[A] != '-') flag = false;
  for (int i = 0; i < A; i++) {
    if (!isdigit(S[i])) flag = false;
  }
  for (int i = A+1; i < A+B+1; i++) {
    if (!isdigit(S[i])) flag = false;
  }
  if (flag) cout << "Yes" << endl;
  else cout << "No" << endl;
}




Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            solve(in);
        }
    }

    private static void solve(Scanner in) {
        for (int i = 1, x = in.nextInt(); 
                x != 0; 
                i++, x = in.nextInt()) {
            System.out.printf("Case %d: %d\n", i, x);
        }
    }
}

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


int main(){
    double a,b;
    cin>>a>>b;

    cout<< ceil((a+b)/2)<<endl; 


    return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	n := nextInt()
	s := nextStr()

	cnt := 0
	for i := 0; i < n-2; i++ {
		if s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C' {
			cnt++
		}
	}

	fmt.Println(cnt)

}

// ---- readfunc
func scanInit() {
	const cap = 200 * 1024 // Default=64
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1788
#include <iostream>

#include <vector>
#include <map>
#include <algorithm>
#include <fstream>
#include<cstdio>
#include<iomanip>

#define REP(i, n) for(int i=0;i<n;i++)
#define REP2(i, s, n) for(int i=s;i<n;i++)
#define REP_1(i, n) for(int i=1;i<n+1;i++)
#define bitSearch(bit, n) for(int bit = 0; bit < (1 << N); bit++)
using namespace std;

void printAns(int a) { cout << a << endl; }

void yesno(bool a) { if (a)cout << "Yes" << endl; else cout << "No" << endl; }

void YESNO(bool a) { if (a)cout << "YES" << endl; else cout << "NO" << endl; }

typedef long long ll;
typedef unsigned long ul;
typedef long double ld;

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;
}

ll INF = 10000000;
ll mod = 1000000007;//10^9+7



//番号ズレ注意！！
int main() {
    int A, B, T;
    cin >> A >> B >> T;
    cout << T / A * B << endl;
}

Measured memory_bytes: 256
unsigned short C[331][1024];count(n,s,U){int i,c=C[s][U];if(c==65535&&(c=s==0,n))for(c=0,i=10;i--;)U&1<<i||n*i>s||(c+=count(n-1,s-n*i,U|1<<i));return C[s][U]=c;}n;main(s){for(;~scanf("%d%d",&n,&s);printf("%d\n",s<331?count(n,s,0):0))memset(C,-1,677888);exit(0);}

Measured memory_bytes: 1076
from collections import defaultdict
import math
N, X, Y = map(int, input().split(' '))
d = defaultdict(int)
for i in range(1, N):
    for k in range(i+1, N+1):
        if(k < X):
            ans = k-i
            d[ans] += 1
        else:
            ans = min(k-i, abs(Y-k)+1+abs(i-X))
            d[ans] += 1

for i in range(1, N):
    print(d[i])


Measured memory_bytes: 49884
//Awwawa! Dis cold yis ratten buy tEMMIE!
#include <bits/stdc++.h>
#define ll long long
#define maxn 400005 /*rem*/
#define mod 998244353
#define db double
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define pi pair<int, int>
#define fi first
#define se second

template <typename T> bool chkmax(T &x,T y){return x<y?x=y,true:false;}
template <typename T> bool chkmin(T &x,T y){return x>y?x=y,true:false;}

using namespace std;
ll ksm(ll a, ll b) {
   if (!b) return 1;
   ll ns = ksm(a, b >> 1);
   ns = ns * ns % mod;
   if (b & 1) ns = ns * a % mod;
   return ns;
}
ll a[maxn];
int b[maxn];
db s[maxn];
struct pt {
	db x, y;
	pt(){;}
	pt (db a, db b) {
		x = a, y = b;
	}
	db operator * (pt u) {
		return x * u.y - y * u.x;
	}
	pt operator - (pt u) {
		return pt(x - u.x, y - u.y);
	}
};
int st[maxn], top = 0; 
db ans[maxn];
pt r[maxn];
db ea[maxn];
int main() {
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++)
		scanf("%lld", &a[i]);
	for (int i = 1; i <= n; i++)
		scanf("%d", &b[i]);
	int pl = 0;
	for (int i = 1; i <= n; i++)
		if (a[i] >= a[pl]) pl = i;
	for (int i = pl; i <= n + pl; i++) 
		if (i > n) a[i] = a[i - n], b[i] = b[i - n];
	s[pl] = 0;
	s[pl + 1] = 0;
	for (int i = pl + 2; i <= n + pl; i++) {
		s[i] = 2 * s[i - 1] - s[i - 2] - 2 * b[i - 1];
	//	cout << i << ' ' << s[i] << endl;
	}
	for (int i = pl; i <= n + pl; i++)	
		r[i] = pt(i, a[i] + s[i]);
	for (int i = pl; i <= n + pl; i++) {
		while (top >= 2 && (r[st[top - 1]] - r[st[top - 2]]) * (r[i] - r[st[top - 1]]) >= 0) top--;
		st[top++] = i;
 	}
 //	for (int i = 0; i < top; i++)
 //		cout << st[i] << ' ';
 	for (int i = 0; i < top - 1; i++) {
 		pt cur = r[st[i + 1]] - r[st[i]];
 		for (int j = st[i]; j <= st[i + 1]; j++)
 			ans[j] = cur.y / (st[i + 1] - st[i]) * (j - st[i]) + r[st[i]].y;
	}
	db fn = 0;
	for (int i = pl; i < n + pl; i++) fn += ans[i] - s[i];
	fn /= n;
	printf("%.10lf\n", fn);
	return 0;
}


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

int main() {
ll h,n;
ll sum =0;
int t;
std::vector<int> A;
scanf("%lld%lld",&h,&n);
rep(i,n){
	scanf("%d",&t);
	sum += t;
}

if(sum>=h)printf("Yes");
else printf("No");

	return 0;
}

Measured memory_bytes: 256