akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 300005

struct Info{
	int in_ch,out_ch;
};

int N;
ll table[26],dp[NUM];
int nearest_next[26];
char buf[NUM];
Info info[NUM];


int main(){

	scanf("%d",&N);

	scanf("%s",buf);

	for(int i = 0; i < N; i++){
		info[i].in_ch = buf[i]-'a';
	}

	scanf("%s",buf);

	for(int i = 0; i < N; i++){
		info[i].out_ch = buf[i]-'a';
	}

	for(int i = 0; i < 26; i++){
		table[i] = 0;
		nearest_next[i] = -1;
	}

	dp[N-1] = 1;
	nearest_next[info[N-1].out_ch] = N-1;
	table[info[N-1].out_ch] = 1;

	for(int loc = N-2; loc >= 0; loc--){

		if(nearest_next[info[loc].in_ch] == -1){ //該当する出口なし

			dp[loc] = 0;

		}else{

			dp[loc] = table[info[loc].in_ch]; //直近の接続先の累積和を引き継ぐ
			table[info[loc].out_ch] += dp[loc];
			table[info[loc].out_ch] %= MOD;
		}
		nearest_next[info[loc].out_ch] = loc;
	}

	printf("%lld\n",dp[0]);

	return 0;
}



Measured memory_bytes: 4880
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
#include <bitset>
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}




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

    ll N, K ;
    cin >> N >> K ;

    ll num = N / 2 + N % 2;
    if(num >= K ){
        cout << "YES" << endl;
    }
    else cout << "NO" << endl;

    //cout << fixed << setprecision(16) << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <string>
using namespace std;
int w,h;
string ans;
string ptn[30];
int di[] = {0,1,0,-1, 1,1,-1,-1};
int dj[] = {1,0,-1,0, 1,-1,-1,1};

int main(){
  string s;
  while( cin >> h >> w && (h|w) ){
    for( int i=0;i<h;i++ ){
      cin >> ptn[i];
    }
    ans="";
    map<string,int> mp;
    for( int st=0;st<h;st++ ){
      for( int en=0;en<w;en++ ){
	for( int lp=0;lp<8;lp++ ){
	  int i=st, j=en;
	  //	  cout << ptn[i][j] << endl;
	  string s = ptn[i].substr(j,1);
	  while( true ){
	    i+=di[lp]; j+=dj[lp];
	    if( i==h ) i=0;
	    else if( i==-1) i=h-1;
	    if( j==w ) j=0;
	    else if( j==-1 ) j=w-1;
	    if( i==st && j==en )
	      break;
	    s += ptn[i][j];
	    if( s.length() < ans.length() )
	      continue;
	    mp[s]++;
	    if( mp[s]==2 ){
	      if( s.length() > ans.length() )
		ans = s;
	      else if( s.length()==ans.length() && s < ans )
		ans = s;
	    }
	  }
	}	  
      }
    }
    if( ans.length()<2 )
      cout << 0 << endl;
    else
      cout << ans << endl;
  }
  return 0;
}

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

#define vs vector<string>

int main() {

    int N;
    cin >> N;

    string S;
    int count_a = 0;
    int count_b = 0;
    int count_ab = 0;
    int count = 0;
    for (int i=0; i<N; i++) {
        cin >> S;
        if (S[0] == 'B') {
            if (S[S.length() - 1] == 'A') count_ab++;
            else count_b++;
        }
        else if (S[S.length() - 1] == 'A') count_a++;

        for (int j = 0; j < S.length() - 1; j++) {
            if (S.substr(j, 2) == "AB") count++;
        }
    }

    if (count_a == 0 && count_b == 0) {
        if (count_ab) {
            cout << count + count_ab - 1 << endl;
        } else {
            cout << count << endl;
        }
    }
    else {
        cout << count + count_ab + min(count_a, count_b) << endl;
    }

    return 0;
}


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

int main() {
  string s; cin >> s;
  string _s(s.size(), 'x');
  cout << _s << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <stdio.h>
#include <algorithm>
int main()
{
	int a[105],i;
	for(i=0;i<3;i++){
		scanf("%d",&a[i]);
	}
	sort(a,a+3);
	if(a[0]+a[1]==a[2]){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	return 0;
}

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

int main()
{
    const double PI=3.14159265358979323846;
    double r;
    cin>>r;
    cout<<2.0*PI*r;
    return 0;
}

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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    vl a(3);
    rep(i,3)cin >> a[i];
    ll res = 0;
    sort(all(a));
    while (1)
    {
        if(a[0] == a[1] && a[1] == a[2])break;
        if(a[2]-a[1]>=1){
            a[0]++;a[1]++;
        }
        else{
            a[0]+=2;
        }
        sort(all(a));
        res++;
    }
    cout << res << endl;
}

Measured memory_bytes: 256
N=int(input())
if N%2==1:
  print(0)
else:
  out = N//10
  cur = 10
  #while N//cur > 0:
  #  out += N//cur
  #  cur *= 10
  N //= 10
  cur = 5
  while N//cur > 0:
    out += N//cur
    cur *= 5
  print(out)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <istream>
#include <map>
#include <set>
#include <queue>
#define rep0(i,n) for (int i = 0; i <= (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)
#define REP(a,b) for (int i = a; i <= (b); ++i) 
#define mREP(a,b) for (int i = a; i == (b); --i) 
typedef long long ll;
using namespace std;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
/*
	　　　  　 ,ﾍ／L──- 、
	　　　   　Lﾆ)r_」=＝= ｲ
	　　 　,ﾍ、i ﾉノλﾉﾊﾉﾍ
	　　   ,'　｀(ﾊﾘ ﾟ ヮﾟﾉi)　',
	　　 .i　　 >〈(つ,i!と)　　i
	　　  vﾍγk´_/___i,ゝﾍノ
	　　　　　 ｀ﾞr_,ｨ_ｧﾞ´
*/
int a, b, c;
cin >> a >> b >> c;
cout << ((a + b) * c) / 2 << endl;
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;
typedef pair<int,int> P;


int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a+b+c >=22){
    cout<<"bust"<<endl;
    return 0;
  }
  cout <<"win"<<endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
using ll = long long;

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; }
template<class T> inline void dump(vector<T> v) { for (auto& x : v) cerr << x << " "; cerr << endl; }
template<class T> inline void dump(vector<pair<T, T>> v) { for (auto& p : v) cerr << p.first << " " << p.second << endl; }
template<class T> inline void dump(vector<vector<T>> vv) { for (auto& v : vv) {for (auto& x : v) cerr << x << " "; cerr << endl;} }

constexpr int INF = 1001001001;
constexpr long long INFL = (1LL<<60);
constexpr double eps = (1e-9);

using P = pair<int, int>;

// Sieve of Eratosthenes
// https://youtu.be/UTVg7wzMWQc?t=2774
struct Sieve {
  int n;
  vector<int> f, primes;
  Sieve(int n=1):n(n), f(n+1) {
    f[0] = f[1] = -1;
    for (ll i = 2; i <= n; ++i) {
      if (f[i]) continue;
      primes.push_back(i);
      f[i] = i;
      for (ll j = i*i; j <= n; j += i) {
        if (!f[j]) f[j] = i;
      }
    }
  }
  bool isPrime(int x) { return f[x] == x;}
  vector<int> factorList(int x) {
    vector<int> res;
    while (x != 1) {
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }
  vector<P> factor(int x) {
    vector<int> fl = factorList(x);
    if (fl.size() == 0) return {};
    vector<P> res(1, P(fl[0], 0));
    for (int p : fl) {
      if (res.back().first == p) {
        res.back().second++;
      } else {
        res.emplace_back(p, 1);
      }
    }
    return res;
  }
  vector<pair<ll,int>> factor(ll x) {
    vector<pair<ll,int>> res;
    for (int p : primes) {
      int y = 0;
      while (x%p == 0) x /= p, ++y;
      if (y != 0) res.emplace_back(p,y);
    }
    if (x != 1) res.emplace_back(x,1);
    return res;
  }
};

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

  ll n;
  cin >> n;
  vector<ll> f(n+1, 0);

  Sieve sieve(n+1);
  f[1] = 1;

  for (int i = 2; i <= n; i++) {
    if (f[i] != 0) {
      f[i] += 2;
    } else {
      f[i] = 2;
    }
    for (int j = 2; j * i <= n; j++) {
      f[i * j] ++;
    }
  }

  ll ans = 0;
  for (int k = 1; k <= n; k++) {
    ans += k * f[k];
  }

  cout << ans << endl;

  return 0;
}


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

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = ReadInt();
            var h = ReadArrayInt();
            var ans = Enumerable.Repeat(int.MaxValue, N).ToArray();
            ans[0] = 0;
            for (int i = 0; i < N - 1; i++)
            {
                if (ans[i] + Math.Abs(h[i] - h[i + 1]) < ans[i + 1]) ans[i + 1] = ans[i] + Math.Abs(h[i] - h[i + 1]);
                if (i < N - 2 && ans[i] + Math.Abs(h[i] - h[i + 2]) < ans[i + 2]) ans[i + 2] = ans[i] + Math.Abs(h[i] - h[i + 2]);
            }

            Console.WriteLine(ans[N - 1]);
            Console.ReadLine();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

Measured memory_bytes: 19168
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int n; cin >> n;
    for (int seven = 0; seven <= n; seven += 7) {
        for(int four = 0; seven + four <= n; four += 4) {
            if (seven + four == n) {
                ATYN(true)
                return 0;
            }
        }
    }

    ATYN(false)

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define int long long int
#define endl "\n"
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(c) c.begin(), c.end()
 
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
 
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
 
typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int dp[100001][4];

int totalHappiness(int n, int a[], int b[], int c[], int prev = 4) {
	if (n == 0)
		return 0;
	if (prev != -1 && dp[n][prev] != 0)
		return dp[n][prev];
	if (prev != 1) {
		dp[n][prev] = max(dp[n][prev], a[n-1] + totalHappiness(n-1, a, b, c, 1));
	}
	if (prev != 2) {
		dp[n][prev] = max(dp[n][prev], b[n-1] + totalHappiness(n-1, a, b, c, 2));
	}
	if (prev != 3) {
		dp[n][prev] = max(dp[n][prev], c[n-1] + totalHappiness(n-1, a, b, c, 3));
	}
	return dp[n][prev];
}
 
void solve() {
    int n;
    cin >> n;
    int a[n], b[n], c[n];
    for (int i = 0; i < n; i++) {
    	cin >> a[i] >> b[i] >> c[i];
    }
    cout << totalHappiness(n, a, b, c);
}
 
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	int t = 1;
	// cin >> t;
	while (t--) {
		solve();
	}
	
	return 0;
}

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

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

  int a[N -1], color[8];
  int min = 0;
  int max = 0;

  for(int t = 0;t < 9;t++){
    color[t] = 0;
  }

  for(int c = 0;c < N ;c++){
    cin >> a[c];
    if(a[c] < 400){
      color[0]++;
    }else if(a[c] < 800){
      color[1]++;
    }else if(a[c] < 1200){
      color[2]++;
    }else if(a[c] < 1600){
      color[3]++;
    }else if(a[c] < 2000){
      color[4]++;
    }else if(a[c] < 2400){
      color[5]++;
    }else if(a[c] < 2800){
      color[6]++;
    }else if(a[c] < 3200){
      color[7]++;
    }else{
      color[8]++;
    }
  }

  for(int v = 0;v < 8;v++){
    if(color[v] != 0){
      min++;
    }
  }

  max = min + color[8];
  if(min ==0)min = 1;
  cout << min <<" "<< max <<"\n";

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,d,o=0,i,e=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&d);
    d%2?(o++):(e++);
  }
  printf("%d\n",o&&e?n-2+o%2:0);
  return 0;
}



Measured memory_bytes: 2104
#include <iostream>
#include <unordered_map>

int main()
{
    int n = 0;
    std::cin >> n;
    
	std::unordered_map<int, int> numArray;
    long long sum = 0;
    
    for(int count = 0; count < n; ++count)
    {
        int element = 0;
        std::cin >> element;
        ++numArray[element];
        sum += element;
    }
    
    int q = 0;
    std::cin >> q;
    
    for(int count = 0; count < q; ++count)
    {
        int b = 0;
        int c = 0;
        std::cin >> b >> c;
        if(numArray.find(b) != numArray.end())
        {
            int const changedNum = numArray.at(b);
            numArray.at(b) = 0;
            numArray[c] += changedNum;
            sum += (c - b) * changedNum;
        }
        std::cout << sum << std::endl;
    }
}

Measured memory_bytes: 6144
#include <stdio.h>

int main(void) {
	int a,b,c,d,p,am,bm;
	scanf("%d%d%d%d%d", &a, &b, &c, &d, &p);
	am = a * p;
	if (p <= c){
		bm = b;
	}
	else{
		bm = b + d * (p - c); 
	}
	if (am > bm){
		printf("%d\n", bm);
	}
	else {
		printf("%d\n", am);
	}
	return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <queue>
 
using namespace std;
 
#define pb(n)	push_back(n)
#define mp(n,m) make_pair(n,m)
#define fi 	first
#define se 	second
#define all(r) (r).begin(),(r).end()

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
const int IMAX=((1<<30)-1)*2+1;
const double EPS=1e-10;
//int mod=1000000007

int h;
int ans;
vector<vi> v(11,vi(5,0));
vector<vi> f(11,vi(5,0));



bool serch(){
	bool ret=false;
	rep(i,h){
		rep(j,5)f[i][j]=0;
	}
	rep(i,h){
		for(int j=0; j<3; j++){
			if(v[i][j]>0&&v[i][j]==v[i][j+1]&&v[i][j]==v[i][j+2]){
				f[i][j]=f[i][j+1]=f[i][j+2]=1;
				if(!ret)ret=true;
			}
		}
	}
	return ret;
}

void fall(){
	rep(i,h){
		rep(j,5){
			if(f[i][j]==1){
				ans+=v[i][j];
				for(int k=i; k>0; k--){
					v[k][j]=v[k-1][j];
				}
				v[0][j]=-1;
			}
		}
	}
}

int main(){
	while(cin>>h && h>0){
		ans=0;
		rep(i,h){
			rep(j,5)cin>>v[i][j];
		}
		while(serch()){
			fall();
		}
		cout<<ans<<endl;
		// rep(i,h){
		// 	rep(j,5){
		// 		cout<<(v[i][j]==-1?' ':(char)('0'+v[i][j]));
		// 	}
		// 	cout<<endl;
		// }
	}
}

Measured memory_bytes: 1212
n=int(input())
a=list(map(int,input().split()))

b4=0
b2=0
b1=0
for i in range(n):
    if a[i]%4==0:
        b4+=1
    elif a[i]%2==0:
        b2+=1
    else:
        b1+=1
        
if b2==0:
    if b1<=b4+1:
        print("Yes")
    else:
        print("No")
else:
    if b1<=b4:
        print("Yes")
    else:
        print("No")
        

Measured memory_bytes: 14252
/*
digu_J - Digvijay Janartha
NIT Hamirpur - INDIA
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

template < typename T > using ordered_set = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
    cout << name << " : " << arg1 << std :: endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    int len = comma - names;
    for (int i = 0; i < len; ++i) {
        cout << names[i];
    }
    cout <<  " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
#else
#define trace(...)
#endif

typedef double db;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < ll, ll > pll;
typedef pair < int, int > pii;
typedef vector < ll > vll;
typedef vector < int > vi;

#define eb emplace_back
#define pb push_back
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define unique_sort(x) (sort(x.begin(), x.end()), x.resize(distance(x.begin(), unique(x.begin(), x.end()))))
#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)

const ll LINF = LLONG_MAX, base = 1e9, MOD = 1e9 + 7, N = 2e3 + 5, M = 1e3 + 5;
const int INF = INT_MAX;
const db PI = acos(-1);

namespace ModFunctions {
	inline void add(ll &a, ll b) {
		a += b;
		if (a >= MOD) {
			a -= MOD;
		}
	}

	inline void sub(ll &a, ll b) {
		a -= b;
		if (a < 0) {
			a += MOD;
		}
	}

	inline int mul(int a, int b) {
		return int((1ll * a * b) % MOD);
	}

	inline int power(int a, ll b) {
		int res = 1;
		while (b > 0) {
			if (b & 1) {
				res = mul(res, a);
			}
			a = mul(a, a);
			b >>= 1;
		}
		return res;
	}

	inline int inv(int a) {
		a %= MOD;
		if (a < 0) {
			a += MOD;
		}
		int b = MOD, u = 0, v = 1;
		while (a) {
			int t = b / a;
			b -= t * a;
			swap(a, b);
			u -= t * v;
			swap(u, v);
		}
		assert(b == 1);
		if (u < 0) {
			u += MOD;
		}
		return u;
	}
}

using namespace ModFunctions;

ll dp[N][N];

void test();

int main() {
    fast_io();
    cout << fixed << setprecision(15);
    test();
    return 0;
}

void test() {
    int n, m;
    cin >> n >> m;
    int a[n + 1], b[m + 1];
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
    }
    for (int i = 1; i <= m; ++i) {
        cin >> b[i];
    }
    for (int i = 1; i <= n; ++i){
        for (int j = 1; j <= m; ++j) {
            ll &ans = dp[i][j];
            add(ans, dp[i - 1][j]);
            add(ans, dp[i][j - 1]);
            if (a[i] == b[j]) {
                add(ans, 1);
            } else {
                sub(ans, dp[i - 1][j - 1]);
            }
        }
    }
    cout << (dp[n][m] + 1) % MOD << "\n";
}


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

int main() {
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int d = abs(x1 - x2 + y1 - y2);
    cout << y1 - y2 + x2 << " " << -x1 + x2 + y2 << " " << -y2 + y1 + x1 << " " << x2 - x1 + y1 << endl;
}


Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <algorithm>

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

#define pb push_back

const int INF = 100100100;
const int MOD = (int)1e9 + 7;

using ll = long long;

using namespace std;

int main(){
  int n,k;
  int tmp;
  int s;
  std::vector<int> c;

  cin >> n >> k;
  c.resize(n);
  for( int i = 0; i < n; ++i){
      cin >> tmp;
      ++c[tmp-1];
  }
  sort( c.begin(), c.end());
  reverse( c.begin(), c.end());
  while( c.back() == 0){
    c.pop_back();
  }
  int ans = 0;
  while( c.size() > k){
    ans += c.back();
    c.pop_back();
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include <stdio.h>

#define SIZE 100

int main() {
    int i, n, v[SIZE], c[SIZE], sum = 0;
    
    scanf("%d", &n);
    
    for (i = 0; i < n; i++) {
        scanf("%d", &v[i]);
    }
    for (i = 0; i < n; i++) {
        scanf("%d", &c[i]);
        if (v[i] - c[i] > 0)
            sum += v[i]-c[i];
    }
    printf("%d\n", sum);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#pragma GCC optimize ("Ofast")
#define ll long long int
#define FOR(i,a,b) for(ll (i)=(a);i<(ll)(b);i++)
#define rep(i,n) FOR(i,0,n)
#define rep1(i,n) FOR(i,1,n)
#define outi(a) printf("%lld\n",(a))
#define pb push_back
using namespace std;
inline ll read()
{
    ll x=0; static int p; p=1; static char c; c=getchar();
    while (!isdigit(c)) { if (c=='-') p=-1; c=getchar(); }
    while ( isdigit(c)) { x=(x<<1)+(x<<3)+(c-48); c=getchar(); }
    x*=p;
    return x;
}
//****************************
 ll mod = 1000000007;
ll power(ll x, ll y)  
{  
    ll res = 1; 
    x = x % mod;
    if (x == 0) return 0; 
    while (y > 0)  
    {  
        if (y & 1) res%=mod, 
            res = (res*x) % mod;  
        y = y>>1;
        x%=mod;
        x = (x*x) % mod;  
    }  
    return res;  
} 
ll inverse_mod(ll a)
{
    return power(a, mod-2)%mod;
}
ll ncr(ll a, ll b)
{
    //cout << "in ncr" << endl;
    ll uporer_ta = 1;
    FOR(i,0,b)
    uporer_ta = uporer_ta*(a-i) %mod,
    //cout << "in first loop" << endl;
    uporer_ta %= mod;
    ll nicher_ta = 1;
    FOR(i,2, b+1)
    //cout << "1st0 " << endl,
    nicher_ta = nicher_ta*i%mod,
    //cout << "in 2nd lop " << i << endl,
    nicher_ta %= mod;
    //cout << "last of mod " << endl; 
    //cout << "lop " << endl;
   // cout << nicher_ta << endl;
    ll aqr = uporer_ta*inverse_mod(nicher_ta);
aqr %= mod;
    return aqr;
}

//****************************
void solve();
int main()
{
    ll n = read(), a = read(), b = read();
    ll total = power(2, n) -1;
    //cout << total << endl;
    total -= ncr(n,a) + ncr(n,b) ;
    //cout << total << endl;
    while(total < 0)
    total+= mod;
    cout << total%mod << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <string>
#include <iomanip>
#include <math.h>

typedef long long int ll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;

using namespace std;

int W[3 * 100005];
int E[3 * 100005];

int main()
{
	int N;
	string S;
	cin >> N >> S;
	int w_c = 0, e_c = 0;
	int ans = 3 * 100005;
	REP(i, N)
	{
		W[i] = w_c;
		if (S[i] == 'W')
		{
			w_c++;
		}
	}
	IREP(i, N - 1)
	{
		E[i] = e_c;
		if (S[i] == 'E')
		{
			e_c++;
		}
	}

	REP(i, N)
	{
		ans = std::min(ans, W[i] + E[i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3076
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <string>
#include <set>
#include <map>
#include <cassert>
#include <cmath>
#define SIZE 100005
#define MX 62

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int cnt[MX];

int main()
{
	int n;
	ll K;
	scanf("%d %lld",&n,&K);
	for(int i=0;i<n;i++)
	{
		ll a;
		scanf("%lld",&a);
		for(int j=0;j<MX;j++)
		{
			if(a%2==1) cnt[j]++;
			a/=2;
		}
	}
	ll ret=0;
	for(int i=-1;i<MX;i++)
	{
		if(i!=-1&&!(K>>i&1)) continue;
		ll now=0;
		for(int j=0;j<i;j++)
		{
			now+=(1LL<<j)*(ll) max(cnt[j],n-cnt[j]);
		}
		for(int j=i;j<MX;j++)
		{
			if(j<0) continue;
			if(j==i||!(K>>j&1))
			{
				now+=(1LL<<j)*(ll) cnt[j];
			}
			else
			{
				now+=(1LL<<j)*(ll) (n-cnt[j]);
			}
		}
		ret=max(ret,now);
	}
	printf("%lld\n",ret);
	return 0;
}


Measured memory_bytes: 128
INF = 0xffffffff
$cnt = 0

def merge(a, left, mid, right)
  n1 = mid - left
  n2 = right - mid
  l = Array.new(n1)
  r = Array.new(n2)
  (0...n1).each do |i|
    l[i] = a[left + i]
  end
  (0...n2).each do |i|
    r[i] = a[mid + i]
  end
  l[n1] = INF
  r[n2] = INF
  i = 0
  j = 0
  (left...right).each do |k|
    if l[i] <= r[j] 
      a[k] = l[i]
      i += 1
      $cnt += 1
    else
      a[k] = r[j]
      j += 1
      $cnt += 1
    end
  end
end


def merge_sort(a, left, right) 
  if left+1 < right
    mid = (left + right) / 2
    merge_sort(a, left, mid)
    merge_sort(a, mid, right)
    merge(a, left, mid, right)
  end
end

n = gets.to_i
a = gets.split.map(&:to_i)

merge_sort(a, 0, n)

puts a.join(" ")
puts $cnt

Measured memory_bytes: 73452
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a, b;
    cin >> a >> b;
    if(a<=9 && b<=9){
        std::cout << a*b << std::endl;
    }
    else{
        std::cout << -1 << std::endl;
    }
    
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stack>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <cmath>
#include <iomanip>
#include <map>
#include <unordered_set>

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

using namespace std;
using ll = long long;
using P = pair<int,int>;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

template <class T>
inline bool chmin(T& a, T b)
{
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T& a, T b)
{
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <typename T>
T GCD(T x, T y)
{
    return (y ? GCD<T>(y, x % y) : x);
}

struct Item{
    Item(ll A, ll B) : A(A), B(B){};
    ll A;
    ll B;
    bool operator<(const Item& another) const {
        return A < another.A;
    }
};
int main() {
    ll N, M;
    vector<Item> items;
    cin >> N >> M;
    rep(i,N){
        ll A, B;
        cin >> A >> B;
        items.push_back(Item(A,B));
    }

    std::sort(items.begin(), items.end());
    ll answer=0;
    rep(i,N){
        if(M==0)
            break;

        ll num = std::min(M, items[i].B);
        answer+=items[i].A*num;
        M-=num;
    }

    cout<<answer<<endl;
}



Measured memory_bytes: 2420
#include<iostream>
#include<bits/stdc++.h>
#define db(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,n) for(int i=0;i<(n);++i)
#define fr(i,a,n) for(int i=a;i<=(n);++i)
#define rf(i,a,n) for(int i=a;i>=(n);--i)
#define mod 1000000007
#define eps 1e-9
#define PI 3.14159265358979323846
#define F first
#define S second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pll pair<ll,ll>
#define _ <<" "<<
using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef pair<int,pair<int,int>> iii;
typedef vector<ii> vii;
typedef vector<iii> viii;

vvi dp;

// int words(set<string> a, int n, string s){
// 	// db2(s,n);
// 	if(n==0)
// 		if(s.length()==0)
// 			return 1;
// 		else
// 			return 0;
// 	if(dp[n][s.length()]!=-1)
// 		return dp[n][s.length()];
// 	if(a.find(s.substr(n-1))!=a.end()){
// 		dp[n][s.length()]= max(words(a,n-1,s.substr(0,n-1)),words(a,n-1,s));
// 	}
// 	else
// 		dp[n][s.length()]= words(a,n-1,s);
// 	return dp[n][s.length()];
// }

int main(){
	int t=1;
	//cin>>t;
	while(t--){
		ll n;
		cin>>n;
		vi a(n),b(n),c(n);
		rep(i,n) cin>>a[i]>>b[i]>>c[i];
		// db(n);
		dp.clear();
		dp.resize(3,vi(n+1));
		// cout<<words(a,s.length(),s)<<endl;
		for(int i=1;i<=n;i++){
			dp[0][i]=a[i-1]+max(dp[1][i-1],dp[2][i-1]);
			dp[1][i]=b[i-1]+max(dp[0][i-1],dp[2][i-1]);
			dp[2][i]=c[i-1]+max(dp[1][i-1],dp[0][i-1]);
			// db3(dp[0][idp[0][i]],dp[1][i],dp[2][i]);
		}
		cout<<max(dp[0][n],max(dp[1][n],dp[2][n]))<<endl;
	}
	return 0;
}

Measured memory_bytes: 5760
fun main(args: Array<String>) {
    val N = readLine()!!.toLong()

    println(f(N, 0))
}

fun f(N: Long, x: Long): Int {
    if (N < x) {
        return 0
    }

    var ret = 1
    for (c in "357") {
        if (!x.toString().contains(c.toString())) {
            ret = 0
            break
        }
    }

    for (c in "357") {
        ret += f(N, x * 10 + (c - '0'))
    }

    return ret
}

Measured memory_bytes: 36640
#include<stdio.h>
int main(){
	int a,i=0,u=0,e=0,o,yama[10];
	for(a=0;a<10;a++){
		scanf("%d",&yama[a]);
		if(yama[a]>i){i=yama[a];}
	}
	for(a=0;a<10;a++){
		if(yama[a]==i){yama[a]=0;break;}
	}
	for(a=0;a<10;a++){
		if(yama[a]>u){u=yama[a];}
	}
	for(a=0;a<10;a++){
		if(yama[a]==u){yama[a]=0;break;}
	}
	for(a=0;a<10;a++){
		if(yama[a]>e)e=yama[a];
	}
	printf("%d\n%d\n%d\n",i,u,e);
	
	
	return 0;
	
	
}

Measured memory_bytes: 600
n = gets.to_i
a = gets.split.map(&:to_i)

b = []
count = 0
x = Array.new(n)
(n).downto(1) {|i|
    sum = 0
    k = 2 * i
    while k <= n
        sum += x[k - 1]
        k += i
    end
    if sum % 2 == a[i - 1] then
        x[i - 1] = 0
    else
        x[i - 1] = 1
        b.push(i)
        count += 1
    end
}

puts count
puts b.join(' ')


Measured memory_bytes: 22076
/**
  * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_6_C
  * Array - Official House
  */
object Main {
  def main(args: Array[String]): Unit = {
    val n = io.StdIn.readInt()
    val operations = Iterator.continually(io.StdIn.readLine()).takeWhile(_ != null).take(n).map(_.split(" ").map(_.toInt))
      .map { case Array(b, f, r, v) => (b, f, r, v) }
      .toSeq
    val initialHouse = OfficialHouse((1 to 4).map(Building(_, (1 to 3).map(Floor(_, (1 to 10).map(Room(_, 0)))))))
    val currentHouse = operations.foldLeft(initialHouse) {
      (house, operation) => {
        operation match {
          case (b, f, r, v) =>
            house.inout(b, f, r, v)
        }
      }
    }
    print(currentHouse)
  }

  case class Room(roomNumber: Int, residents: Int) {
    override def toString: String = s" $residents"

    def inout(inoutResidents: Int): Room = {
      Room(roomNumber, residents + inoutResidents)
    }
  }

  case class Floor(floorNumber: Int, rooms: Seq[Room]) {
    override def toString: String = rooms.foldLeft("")(_ + _)

    def inout(roomNumber: Int, inoutResidents: Int): Floor = {
      Floor(floorNumber, rooms.updated(roomNumber - 1, rooms(roomNumber - 1).inout(inoutResidents)))
    }
  }

  case class Building(buildingNumber: Int, floors: Seq[Floor]) {
    override def toString: String = floors.foldLeft("")(_ + _ + "\n")

    def inout(floorNumber: Int, roomNumber: Int, inoutResidents: Int): Building = {
      Building(buildingNumber, floors.updated(floorNumber - 1, floors(floorNumber - 1).inout(roomNumber, inoutResidents)))
    }
  }

  case class OfficialHouse(buildings: Seq[Building]) {
    override def toString: String = buildings.mkString("#" * 20 + "\n")

    def inout(buildingNumber: Int, floorNumber: Int, roomNumber: Int, inoutResidents: Int): OfficialHouse = {
      OfficialHouse(buildings.updated(buildingNumber - 1, buildings(buildingNumber - 1).inout(floorNumber, roomNumber, inoutResidents)))
    }
  }

}

Measured memory_bytes: 46244
#include"stdio.h"
#include"iostream"
#include"string.h"
#include"string"
#include"algorithm"
using namespace std;
int main(){
	int N,K;
	while(scanf("%d%d",&N,&K)!=EOF)
	{
	int i=0,sum=0,a[55];
	memset(a,0,sizeof(a));
	for(i=0;i<N;i++)
	{
	scanf("%d",&a[i]);	
		}
	for(i=0;i<N;i++)
	{
	sum=sum+a[i];	
		}
	sort(a,a+N);
	for(i=0;i<N-K;i++)
		sum=sum-a[i];
		printf("%d\n",sum);	
		
	}
	
	
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define ordered_set tree<long long, null_type,less<long long>, rb_tree_tag,tree_order_statistics_node_update>
//s.find_by_order(index) returns iterator to the index-th element
//in O(logn) time.



typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vii;
typedef vector<string> vss;
typedef vector<pair<ll, ll> > vpll;
typedef unordered_map<ll ,ll> mpll;
typedef unordered_map<int ,int> mpii;
typedef unordered_map<char ,ll> mpcl;
typedef pair<ll , ll> pll;
typedef complex<double> cd;
typedef vector< complex<double> > vcd;


#define fore(i,n) for(i=0;i<n;i++)
#define forz(i,s,f) for(i=s;i<f;i++)
#define forer(i,n) for(i=n-1;i>=0;i--)
#define forzr(i,s,f) for(i=s;i>=f;i--)
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define ff first
#define ss second
#define pvec(i,vec) fore(i,vec.size())cout<<vec[i]<<" ";cout<<"\n";

const ll mod=1e9+7;
const ll modulo=998244353;
const double pi = 3.14159265358979323846;


ll power(ll x,ll y,ll m)//gives (x^y)%m
{
    ll ans=1;
    while (y>0)
    {
        if(y & 1)
        {
            ans=(ans*x)%m;
        }
        y=y/2;
        x=(x*x)%m;
    }
    return ans;
}

bool sortbysec(pll &a,pll &b)
{
    return(a.ss<b.ss);
}

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

ll lcm(ll a,ll b)
{
	ll ans=(a*b)/gcd(a,b);
	return ans;
}

long double logn(long double a,long double n)
{
	return(log(n)/log(a));
}

int main(int argc, char const *argv[])
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);
    
	ll te=1,test,i,j,n,m,flag,k,p,temp;
	//cin>>te;
	for(test=1;test<=te;test++)
	{
		cin>>n;

		vll a(n);
		fore(i,n)
		{
			cin>>a[i];
		}
		
		ll  ans=0;
		fore(i,n)
		{
			if((i+1)%2==1 && a[i]%2==1)
				ans++;
		}

		cout<<ans<<"\n";
		//cout<<"hello\n";
		//cout<<"Case #"<<test<<": ";
	}

	return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cctype>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<algorithm>
#include<functional>
#include<bits/stdc++.h>
using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	
	int n;
	cin>>n;
	int a[n+1], b[n+1], c[n];
	for(int i=1; i<=n; i++)cin>>a[i];
	for(int i=1; i<=n; i++)cin>>b[i];
	for(int i=1; i<n; i++)cin>>c[i];
	int s=0, e=-1;
	for(int i=1; i<=n; i++)
	{
		s+=b[a[i]];
		if(a[i]-e==1)s+=c[e];
		e=a[i];
	}
	cout<<s<<endl;
	    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


template<typename T>
struct Kruskal{
  
  struct edge{
    Int from,to;
    T cost;
    Int used;
    edge(){}
    edge(Int from,Int to,T cost):
      from(from),to(to),cost(cost),used(0){}
    bool operator<(const edge& e) const{
      return cost<e.cost;
    }
  };

  Int n;
  vector<Int> p,r;
  vector<edge> edges;

  Kruskal(){}
  Kruskal(Int n):n(n){}

  void init(Int n){
    r.assign(n,1);
    p.resize(n);
    iota(p.begin(),p.end(),0);
  }
  
  Int find(Int x){
    return (x==p[x]?x:p[x]=find(p[x]));
  }

  bool same(Int x,Int y){
    return find(x)==find(y);
  }

  void unite(Int x,Int y){
    x=find(x);y=find(y);
    if(x==y) return;
    if(r[x]<r[y]) swap(x,y);
    r[x]+=r[y];
    p[y]=x;
  }

  void add_edge(Int u,Int v,T c){
    edges.emplace_back(u,v,c);
  }
  
  T build(){
    sort(edges.begin(),edges.end());
    init(n);
    T res=0;
    for(auto &e:edges){
      if(!same(e.from,e.to)){
        res+=e.cost;
        unite(e.from,e.to);
        e.used=1;
      }
    }
    return res;
  }
};

//INSERT ABOVE HERE
signed main(){
  Int n,d;
  cin>>n>>d;
  vector<Int> a(n);
  for(Int i=0;i<n;i++) cin>>a[i];
  Kruskal<Int> ks(n);
  using P = pair<Int, Int>;
  using PP = pair<P, P>;
  auto add_edge=
    [&](Int x,Int y){
      Int c=abs(x-y)*d+a[x]+a[y];
      ks.add_edge(x,y,c);
    };
  
  function<PP(Int, Int)> dfs=
    [&](Int l,Int r)->PP{
      if(l+1==r) return PP(P(a[l]-l*d,l),P(a[l]+l*d,l));
      Int m=(l+r)>>1;      
      PP x=dfs(l,m),y=dfs(m,r);
      
      for(Int i=l;i<m;i++)
        add_edge(i,y.second.second);
      for(Int i=m;i<r;i++)
        add_edge(x.first.second,i);

      return PP(min(x.first,y.first),min(x.second,y.second));
    };  
  dfs(0,n);

  cout<<ks.build()<<endl;
  return 0;
}


Measured memory_bytes: 135004
#include<cstdio>

int main(){
  int data[10],order[10];

  //入力＆初期化
  for(int i=0;i<10;i++){
    scanf("%d",&data[i]);
    order[i]=1;
  }

  //順位付け
  for(int i=1;i<10;i++)
    for(int j=0;j<i;j++)
      data[j]<data[i] ? order[j]++ : order[i]++;

  //表示
  for(int i=1;i<=3;i++)
    for(int j=0;j<10;j++)
      if(order[j]==i)
	printf("%d\n",data[j]);
   
  return 0;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  
  vector<int> a(M);
  vector<int> b(M);
  
  for (int i = 0; i < M; i++) {
  	int ai, bi;
    cin >> ai >> bi;
    a.at(i) = ai;
    b.at(i) = bi;    
  }
  for(int i = 1; i <= N; i++) {
  	int ans = 0;
    for (int j = 0; j < M; j++) {
    	if (a.at(j) == i || b.at(j) == i) {
        	ans++;
        }
    }
  	cout << ans << endl;
  }  	
}


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

int main() {
    int r_0, w, c, r;
    while (true) {
        cin >> r_0 >> w >> c >> r;
        if (r_0 + w + c + r == 0) break;
        int ans = 0;
        while ((r_0 + ans * r) / w < c) ans++;
        cout << ans << endl;
    }
}



Measured memory_bytes: 3116
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
typedef long long ll;
int N,M;
const int MN=100000;
vector<int> G[MN],rG[MN];
bool vis[MN][3];
ll cnt[3];
ll use;
void dfs(int v,int c){
	if(vis[v][c]) return;
	vis[v][c]=1;
	cnt[c]++;
	for(int u:G[v]) dfs(u,(c+1)%3),use++;
	for(int u:rG[v]) dfs(u,(c+2)%3),use++;
}

int main(){
	cin>>N>>M;
	ll ans=0;
	rep(i,M){
		int x,y;
		cin>>x>>y;
		x--,y--;
		G[x].pb(y);
		rG[y].pb(x);
	}
	rep(v,N) if(!(vis[v][0]||vis[v][1]||vis[v][2])){
		rep(j,3) cnt[j]=0;
		use=0;
		dfs(v,0);
		if(vis[v][0]&&vis[v][1]&&vis[v][2]){
			ans+=cnt[0]*cnt[0];
		}else if(cnt[0]==0||cnt[1]==0||cnt[2]==0){
			ans+=use/2;
		}else{
			ans+=cnt[0]*cnt[1]+cnt[1]*cnt[2]+cnt[2]*cnt[0];
		}
	}
	cout<<ans<<endl;
}


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

int main(){
    string S; cin >> S;
    string c = "";
    char s;
    for (int i=0; i<S.length(); i++){
        s = S[i];
        if (s == '0' || s == '1'){
            c += s;
        }
        else if (c != ""){
            c.pop_back();
        }
    }
    cout << c << endl;

}

Measured memory_bytes: 256
import java.util.*;

public class Main {

	static final long MOD = 1000000007L;
	static final int[] PRIME = new int[]{2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71 , 73, 79, 83, 89, 97,101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173 , 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281 , 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409 , 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541 , 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659 , 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809 , 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941 , 947, 953, 967, 971, 977, 983, 991, 997 };
	static int[] counts = new int[PRIME.length];
	
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		for (int i = 1; i <= n; i++) {
			int x = i;
			while(x > 1) {
				for (int j = 0; j < PRIME.length; j++) {
					while (x % PRIME[j] == 0) {
						x /= PRIME[j];
						counts[j]++;
					}
				}
			}
		}
		long ans = 1;
		for (int i = 0; i < counts.length; i++) {
			ans *= counts[i] + 1;
			ans %= MOD;
		}
		System.out.println(ans);
	}
}


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

int main() {
  string S, T;
  cin >> S >> T;

  sort(S.begin(), S.end());
  sort(T.begin(), T.end());
  reverse(T.begin(), T.end());

  cout << (S < T ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
# include"stdio.h"
int main(){
    char s[100001];
    scanf("%s",s);
    int f[26];
    for(int i=0;i<26;i++)
        f[i]=0;
    int cnt=0;
    while(s[cnt]!='\0'){
        f[s[cnt]-'a']++;
        cnt++;
    }
    for(int i=0;i<26;i++)
        if(f[i]==0){
            printf("%c\n",'a'+i);
            return 0;
        }
    printf("None\n");
}


Measured memory_bytes: 1776
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define INF 100000000000
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using P = pair<int, int>;

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

int main()
{
    int n, a, b;
    cin >> n >> a >> b;
    string s;
    cin >> s;

    int pass = 0;
    int foreign = 0;
    rep(i,s.length()) {
        if (s[i] == 'a' && pass < a + b) {
            cout << "Yes" << endl; pass++; continue;
        }
        if (s[i] == 'b' && pass < a + b && foreign < b) {
            cout << "Yes" << endl; 
            pass++;
            foreign++; 
            continue;
        }
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 896
import java.util.Scanner;

public class Main {

	// given n times, and R, an array of currencies/rates
	static int compute_maxprofit(int n, int[] R) {
		int max_profit = -999999999;
		int minprofit = R[0];

		for (int i = 1; i < n; i++) {
			max_profit = Math.max(max_profit, R[i] - minprofit);
			minprofit = Math.min(minprofit, R[i]);

		}
		return max_profit;
	}

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int[] R = new int[n];

		for (int i = 0; i < n; i++) {
			R[i] = in.nextInt();
		}
		System.out.println(compute_maxprofit(n, R));
		in.close();
	}
}


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

#define Nmax 100000 + 10

int N;
char s[Nmax];
char round[Nmax];
char animaltype[2] = {'S', 'W'}; 

int DP();

int main(){
	scanf("%d", &N);
	scanf("%s", s);
	int check = -1;
	for(int i = 0; i < 4; i++){
		round[0] = animaltype[i / 2];
		round[1] = animaltype[i % 2];
		check = DP();
		if(check == 0){
			break;
		}
	}
	if(check == 0){
		for(int i = 0; i < N; i++){
			printf("%c", round[i]);
		}
	}else{
		printf("-1");
	}
	system("pause");
	return 0;
}

int DP(){
	int buff;
	for(int i = 1; i < N; i++){
		buff = 0;
		if(round[i] == animaltype[1]){
			buff = 1;
		}
		if(round[i - 1] == animaltype[1]){
			buff = (buff + 1) % 2;
		}
		if(s[i] == 'x'){
			buff = (buff + 1) % 2;
		}
		if(i < N - 1){
			round[i + 1] = animaltype[buff];
		}else{
			if(round[0] != animaltype[buff]){
				return -1;
			}
		}
	}
	buff = 0;
	if(round[0] == animaltype[1]){
		buff = 1;
	}
	if(round[N - 1] == animaltype[1]){
		buff = (buff + 1) % 2;
	}
	if(s[0] == 'x'){
		buff = (buff + 1) % 2;
	}
	if(round[1] == animaltype[buff]){
		return 0;
	}else{
		return -1;
	}
}

Measured memory_bytes: 640
#include<iostream>

using namespace std;

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

	bool flagNine = false;
	for (int i = 0; i < N.length(); i++) {
		if (N[i] == '9') {
			flagNine = true;
		}
	}

	if (flagNine) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

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


using namespace std;

void solve1() {
	int A, B, C;
	cin >> A >> B >> C;
	vector<int> v;
	v.push_back(A);
	v.push_back(B);
	v.push_back(C);
	sort(v.begin(), v.end());
	if (v[0] == 5 && v[1] == 5 && v[2] == 7)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}

int main() {
	solve1();
	return 0;
}

Measured memory_bytes: 256