akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
using namespace __gnu_pbds;
typedef tree<pair<ll,pair<ll,ll> >, null_type, less<pair<ll,pair<ll,ll> > >, rb_tree_tag, tree_order_statistics_node_update>ordered_set;
#define me BOSS
#define bug() cout<<"AIkahne aise"<<endl
#define PI acos(-1)
/* Precode Start Here *\
     Sieve
void sieve()
{
    for(ll i=3; i<=2000; i+=2)
    {
        for(ll j=i*i; j<=4000000; j+=i)
            A[j]=1;
    }
    v.push_back(2);
    for(ll i=3; i<=4000000; i+=2)
        if(A[i]==0)
            v.push_back(i);
}

     Power Function Modulo P

ll modPow(ll a, ll x, ll p) {
    //calculates a^x mod p in logarithmic time.
    long res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}


   factorial

ll fact(ll n)
{
    ll ans=1;
    for(ll i=1;i<=n;i++)
    {
        ans=(ans*i)%mod;
    }
    return ans;
}
     Calculating nCr using Fermats law Theorem

ll modInverse(ll a, ll p) {
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return modPow(a, p-2, p);
}


ll modBinomial(ll n, ll k, ll p) {
// calculates C(n,k) mod p (assuming p is prime).

    ll numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (ll i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    ll denominator = 1; // k!
    for (ll i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

    // numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p;
}
     num of divisor and euler totient

ll phi[1000001],mark[1000001],divi[1000001];;
void divisorPhi(ll n)
{
    for(int i=1;i<=n;i++)
        phi[i]=i;
    for(int i=2;i<=n;i++)
    {
        if(!mark[i])
        {
            for(int j=i;j<=n;j+=i)
            {
                mark[j]=1;
                phi[j]*=(1-1/(double)i);
            }
        }
    }
    for(ll i=1;i<=n;i++)
    {
        for(ll j=i;j<=n;j+=i)
            divi[j]++;
    }
}
/* Precode Ends */
#define mod 1000000007
ll A[5000001],vis[5000001];
vector<ll>v;
map<ll,ll>myMap;
set<ll>mySet;
vector<pair<ll,ll> >vp;
priority_queue<ll> pq;
priority_queue<ll, vector<ll>, std::greater<ll> > first;
ll po(ll a,ll n)
{
    ll ans=1;
    for(int i=1; i<=n; i++)
        ans*=a;
    return ans;
}

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

    ll n,k;
    cin>>n>>k;
    for(int i=1; i<=n; i++)
    {
        cin>>A[i];
    }
    ll start=1;
    ll l,r;
    while(1)
    {
        if(vis[start]==1)
        {
            l=start;
            break;
        }
        vis[start]=1;
        start=A[start];
        k--;
        if(k==0)
        {
            cout<<start<<endl;
                return 0;
        }
    }
    ll cnt=0;
    for(int i=l;;)
    {
        if(i==l&&cnt!=0)
            break;
        v.push_back(i);
        i=A[i];
        cnt++;
    }
    ll d=v.size();
    cout<<v[k%d]<<endl;
    return 0;
}



Measured memory_bytes: 7316
#include<stdio.h>
int main(){
  int unused __attribute__((unused));
  int i;
  char s[20];

  unused = scanf("%s", s);
  for(i=0; i<19; i++){
    if(s[i]==',') s[i] = ' ';
  }
  printf("%s", s);

  return 0;
}

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

int n;
int res;

int main()
{
    scanf("%d", &n);
    int mn = n + 1;
    for (int i = 1; i <= n; i++) {
        int a; scanf("%d", &a);
        if (a < mn) { res++; mn = a; }
    }
    printf("%d\n", res);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<utility>
#include<cmath>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long int ll;
#define rep(i,n) for(int i=0;i<(int)n;i++)

int main(void) {
	int a, b;
	char x; cin >> a >> x >> b;
	if (x == '+')cout << a + b << endl;
	else cout << a - b << endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

ll N,W;
ll w[109],v[109];
map<ll,ll> now;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>N>>W;
    rep(i,N) cin>>w[i]>>v[i];
    
    now[0]=0;
    rep(i,N){
        map<ll,ll> nxt;
        for(auto m:now){
            ll ww=m.first;
            ll vv=m.second;
            chmax(nxt[ww],vv);
            if(ww+w[i]>W) continue;
            chmax(nxt[ww+w[i]],vv+v[i]);
        }
        swap(now,nxt);
    }
    
    ll ans=0;
    for(auto m:now){
        chmax(ans,m.second);
    }
    cout1(ans)
}

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


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

using namespace std;

#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(nullptr)
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define REP(n) FOR(z, 1, (n))
#define pb push_back
#define INF 1000000000000000000
#define f first
#define s second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;

const int MAXN = 100100;

int main()
{
    FAST_IO;

    ll w, h;
    cin >> w >> h;
    ll x, y;
    cin >> x >> y;
    ld tempW = w, tempH = h;
    cout << fixed << (tempW*tempH)/2 << " ";
    if ( (w%2==0) && (x==w/2) && (h%2==0) && (y==h/2)  )
        cout << 1 << endl;
    else cout << 0 << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <math.h>
using namespace std;
int main(){
	string a("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ");
	int n,m,q;
	while(cin>>n>>m>>q){
		if(n==0&&m==0&&q==0) break;
		else if(q==0){
			if(n==1&&m==1) cout<<0<<endl;
			else{
				for(int i=0;i<m;i++){
					cout<<"?";
				}
				cout<<endl;
			}
		}
		else{
			string s[q],b[q];
			int ss[q][n],bb[q][m];
			cin>>s[0]>>b[0];
			for(int j=0;j<n;j++){
				if(s[0][j]=='0'){
					ss[0][j]=0;
				}
				else{
					ss[0][j]=1;
				}
			}
			for(int j=0;j<m;j++){
				if(b[0][j]=='0'){
					bb[0][j]=0;
				}
				else{
					bb[0][j]=1;
				}
			}
			for(int i=1;i<q;i++){
				cin>>s[i]>>b[i];
				for(int j=0;j<n;j++){
					if(s[i][j]=='0'){
						ss[i][j]=ss[i-1][j];
					}
					else{
						ss[i][j]=(ss[i-1][j]+1)%2;
					}
				}
				for(int j=0;j<m;j++){
					if(b[i][j]=='0'){
						bb[i][j]=0;
					}
					else{
						bb[i][j]=1;
					}
				}
			}
			int hyou[m][n];
			for(int i=0;i<n;i++){
				for(int j=0;j<m;j++){
					hyou[j][i]=0;
				}
			}
			for(int i=0;i<q;i++){
				for(int j=0;j<m;j++){
					if(bb[i][j]==1){
						for(int k=0;k<n;k++){
							if(ss[i][k]==0){
								hyou[j][k]=-1;
							}
							else if(hyou[j][k]==0){
								hyou[j][k]=1;
							}
						}
					}
					else{
						for(int k=0;k<n;k++){
							if(ss[i][k]==1){
								hyou[j][k]=-1;
							}
							else if(hyou[j][k]==0){
								hyou[j][k]=1;
							}
						}
					}
				}
			}
			for(int i=0;i<m;i++){
				int ct=0,out;
				for(int j=0;j<n;j++){
					if(hyou[i][j]>=0){
						ct++;
						if(hyou[i][j]==1) out=j;
					}
				}
				if(ct==1) cout<<a[out];
				else cout<<"?";
			}
			cout<<endl;
		}
	}
    return 0;
}

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

int main(){
    int n,d[100];
    int difficult = 0;
    int dan = 1;
    cin >> n;
    for(int i=0; i!=n; i++){
        cin >> d[i];
        for(int j=0; j!=i; j++){
            if(d[i] != d[j]){
                difficult = 1;
            }else{
                difficult = 0;
                break;
            }
        }
        if(difficult == 1){
            dan += 1;
        }
    }
    cout << dan << '\n';
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
const int mod = 1000000007;
int n, dp[1000009], sum[1000009];
int main() {
	dp[0] = 1; sum[1] = 1;
	for (int i = 1; i <= 1000000; i++) {
		dp[i] = dp[i - 1];
		if (i >= 2) dp[i] += sum[i - 2];
		if (dp[i] >= mod) dp[i] -= mod;
		sum[i + 1] = sum[i] + dp[i];
		if (sum[i + 1] >= mod) sum[i + 1] -= mod;
	}
	cin >> n;
	int ret = (dp[n] + 1LL * dp[n - 1] * (n - 1)) % mod;
	for (int i = 0; i <= n - 2; i++) {
		int res = (1LL * (n - 1) * (n - 1) + i + 1) % mod;
		ret = (ret + 1LL * dp[i] * res) % mod;
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 8064
import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.typecons;
T[][] combinations(T)(T[] s, in int m) {   if (!m) return [[]];   if (s.empty) return [];   return s[1 .. $].combinations(m - 1).map!(x => s[0] ~ x).array ~ s[1 .. $].combinations(m); }

void main() {
  auto H = readln.chomp.to!(int);
  auto W = readln.chomp.to!(int);
  auto N = readln.chomp.to!(int);

  auto sizePerPaint = H > W ? H : W;
  writeln(N / sizePerPaint + (N % sizePerPaint == 0 ? 0 : 1));
}


Measured memory_bytes: 256
#include <iostream>
#include <iterator>
#include <sstream>
#include <vector>

template <typename T>
std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
  if(!v.empty()) {
    std::copy(v.begin(), v.end() - 1, std::ostream_iterator<T>(out, " "));
    out << v.back();
  } else {
    out << "";
  }
  return out;
}

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

  std::vector<int> xs;
  int x;
  for(int i = 0; i != n; ++i) {
    std::cin >> x;
    xs.push_back(x);
  }

  std::cout << xs << std::endl;

  for(int i = 1; i < n; ++i) {
    int key = xs.at(i);
    int j = i - 1;
    while(j >= 0 && xs.at(j) > key) {
      std::swap(xs.at(j), xs.at(j + 1));
      --j;
    }
    std::cout << xs << std::endl;
  }

  return 0;
}

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

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

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

struct Point{
    ll x;
    ll y;
    Point(ll x, ll y): x(x), y(y) {}
    Point(){}
};

ll field[21][21];

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

    // input
    for(;;){
        // jewel num
        ll N;
        cin >> N;

        if(N==0) return 0;

        Point p = Point(10, 10);

        FOR(i, 0, 21){
            FOR(j, 0, 21){
                field[i][j] = 0;
            }
        }

        // jewel position
        FOR(i, 0, N){
            ll x, y;
            cin >> x >> y;
            field[y][x] = 1;
        }

        // move
        ll count = 0;
        ll M; cin >> M;
        FOR(i, 0, M){
            char c; cin >> c;
            ll len; cin >> len;

            FOR(j, 0, len){
                if(c=='N') p.y++;
                if(c=='S') p.y--;
                if(c=='E') p.x++;
                if(c=='W') p.x--;
                if(field[p.y][p.x]==1){
                    field[p.y][p.x] = 0;
                    count++;
                }
            }
        }
        if(count==N){
            p_yes();
        }else{
            p_no();
        }
    }

    
    return 0;
}


Measured memory_bytes: 3108
n=int(input())
lists=[]
for i in range(n):
    a,b=map(int,input().split())
    lists.append((a,b))
lists=sorted(lists,key=lambda x:x[1])
flag=True
counter=0
for i in range(n):
    counter+=lists[i][0]
    if counter>lists[i][1]:
        flag=False
        break
if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 33396
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>
#include<string.h>
#include<math.h>

typedef int32_t i32;
typedef int64_t i64;

#define MAX(a,b) ((a) > (b) ? (a) : (b))
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#define ABS(a) ((a) > (0) ? (a) : -(a))

void run (void) {
  i32 n;
  scanf("%" SCNi32, &n);
  i32 *a = (i32 *) calloc (n + 1, sizeof (i32));
  i32 i,j;
  for (i = 1; i <= n; ++i) {
    scanf("%" SCNi32, a + i);
  }
  i32 ans[100];
  for(i = 0; i < n; ++i) {
    for (j = n - i; j >= 1; --j) {
      if (a[j] == j) {
	ans[i] = j;
	a[j] = -1;
	break;
      }
    }
    if (j < 1) {
      puts ("-1");
      return;
    }
    for (; j + 1 <= n - i; ++j) {
      a[j] = a[j + 1];
    }
  }
  for (i = n - 1; i >= 0; --i) {
    printf("%" PRIi32 "\n", ans[i]);
  }
}

int main (void) {
  run ();
  return 0;
}


Measured memory_bytes: 128
//mOzis_
/////*31022618*/////
//****//MONU KUMAR\****//
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ull unsigned long long
#define p1(x) cout <<x
#define p2(x,y) cout <<x <<" " <<y
#define p3(x,y,z) cout <<x <<" " <<y <<" " <<z
#define nL cout<<"\n"
#define lp(i,l,r) for (long long int i = l; i < r; i++)
#define mem(a,x) memset(a,x,sizeof(a))              //set elements of array to some value
#define pi 3.1415926535897932384626
#define mod 1000000007
#define pb(x) push_back(x)
#define ff first
#define ss second
#define siz 256                        //characters are stored using 8 bit and there can be
bool anagram(char *s1, char *s2)     //256 possible characters only in lowercase alphabet
{
	ll count[siz];
    mem(count,0) ;
    ll i;
    for (i = 0; s1[i] && s2[i];  i++)
    {
        count[s1[i]]++;
        count[s2[i]]--;
    }
    if (s1[i] || s2[i])
    {
      return false;
    }
    lp(i,0,siz)
    {
    	 if (count[i])
    	 {
    	 	 return false;
    	 }
    }
     return true;

}
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);

	//ll t;
	//cin>>t;
	clock_t launch=clock();
	ll a,b,c;
	cin>>a>>b>>c;
  if((a-b)>=c)
  {
    cout<<0<<"\n";
  }
  else
  {
    cout<<c-(a-b)<<"\n";
  }



	clog<<((long double)(clock()-launch)/CLOCKS_PER_SEC)<<"\n";
	return 0;
}
//////////*********************end of program*********************//////////



Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int n,m,a[6][2],b[3]={-1,-1,-1},i,f[3]={0};
    scanf("%d %d",&n,&m);
    for(i=0;i<m;i++){
        scanf("%d %d",&a[i][0],&a[i][1]);
    }
    for(i=0;i<m;i++){
        if(b[a[i][0]-1]!=a[i][1]) f[a[i][0]]++;
        b[a[i][0]-1]=a[i][1];
    }
    if(n==1){
        if(f[0]>1 || f[1]>1 || f[2]>1){
            printf("-1");
        }else if(b[0]==-1){
            printf("0");
        }else{
            printf("%d",b[0]);
        }
    }
    if(n==2){
        if(f[0]>1 || f[1]>1 || f[2]>1){
            printf("-1");
        }else if(b[0]==0){
            printf("-1");
        }else{
            if(b[0]==-1){
                printf("1");
            }else{
                printf("%d",b[0]);
            }
            if(b[1]==-1){
                printf("0");
            }else{
                printf("%d",b[1]);
            }
        }
    }
    if(n==3){
       if(f[0]>1 || f[1]>1 || f[2]>1){
            printf("-1");
        }else if(b[0]==0){
            printf("-1");
        }else{
            if(b[0]==-1){
                printf("1");
            }else{
                printf("%d",b[0]);
            }
            if(b[1]==-1){
                printf("0");
            }else{
                printf("%d",b[1]);
            }
            if(b[2]==-1){
                printf("0");
            }else{
                printf("%d",b[2]);
            }
        } 
    }
    printf("\n");
    //printf("%d %d %d\n",f[0],f[1],f[2]);
    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#define rep(i,l,r) for(ll i=l;i<r;i++)

typedef long long ll;

int main() {
	ll h,w,k;
	scanf("%lld%lld%lld", &h, &w,&k);
	char map[7][7];
	rep(i, 0, h) {
		scanf("%s", map[i]);
	}
	ll ans = 0;
	rep(i, 0, 1<<h) {
		rep(j, 0, 1<<w) {
			ll sum = 0;
			rep(k, 0, h) {
				rep(l, 0, w) {
					if (!(i & (1 << k)) && !(j & (1 << l)) && map[k][l] == '#') sum++;
				}
			}
			if (sum == k) ans++;
		}
	}
	printf("%lld", ans);

	return 0;
}

Measured memory_bytes: 2152
#include <bits/stdc++.h>
#include <set>
#include <map> 

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++) 
#define ll long long
#define ld long double
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++) 
#define repvec(i, v) for(auto i = v.begin(); i != v.end(); ++i)

void calc(int n, int now, map<int, vector<int>>* tree, vector<int>vis, int& ans)
{
 
  auto list = (*tree)[now];
  vis.push_back(now);
  
    if(vis.size() == n)
  {
    ans++;
    return;
  }
  
  for(auto iter = list.begin(); iter != list.end(); ++iter)
  {
    int next = *iter;
    if(find(vis.begin(), vis.end(), next) != vis.end())
    {
      continue;
    }
    calc(n, next, tree, vis, ans);
  }
}

int main()
{
  int n,m;
  cin >> n >> m;
  
  map<int, vector<int>> tree;
  
  rep(i, m)
  {
    int a, b;
    cin >> a >> b;
    tree[a].push_back(b);
    tree[b].push_back(a);
  }
  
  int ans = 0;
  vector<int> vis;
  calc(n, 1, &tree, vis, ans);
  
  cout << fixed << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long a,b;
  cin >> a>> b ;
  
  if((a+b)%2==0) {
    cout <<(a+b)/2 << endl;
  }
  else{ 
    cout <<"IMPOSSIBLE" <<endl; 
  }
  
}

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

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define int ll
typedef vector<int> vi;
typedef pair<int,int> pii;

signed main(void) {
  int i,j;
  int a,b;
  while(1){
    cin>>a>>b;
    if(a==0 && b==0)break;
    vector<vi> dp(a,vi(b,0));
    int n;
    cin>>n;
    rep(i,n){
      int x,y;
      cin>>x>>y;
      x--;y--;
      dp[x][y]=-1;
    }
    rep(i,a)rep(j,b)if(dp[i][j]>=0){
      if(i==0 && j==0)
	dp[i][j]=1;
      else if(i==0){
	if(dp[i][j-1]==-1)dp[i][j]=0;
	else dp[i][j]=dp[i][j-1];
      }else if(j==0){
	if(dp[i-1][j]==-1)dp[i][j]=0;
	else dp[i][j]=dp[i-1][j];
      }else{
	dp[i][j]=0;
	if(dp[i][j-1]>0)dp[i][j]+=dp[i][j-1];
	if(dp[i-1][j]>0)dp[i][j]+=dp[i-1][j];
      }
 
    }
    cout<<dp[a-1][b-1]<<endl;
  }
}

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

const long long int MOD = 1e9+7;
#define pb push_back
typedef long long ll;
const long long int N = 1e5;

int main(){
    string s,t;
    cin>>s>>t;
    int n=s.length(),m=t.length();
    vector<vector<int>> dp(n+5,vector<int>(m+5,0));
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            dp[i][j]=max({dp[i][j],dp[i-1][j],dp[i][j-1]});
            if(s[i-1]==t[j-1]){
                dp[i][j]=max(dp[i][j],dp[i-1][j-1]+1);
            }
            else{
                dp[i][j]=max(dp[i][j],dp[i-1][j-1]);
            }
        }
    }
    string ans="";
    int i=n,j=m;
    int len=0;
    while(len!=dp[n][m]){

        if(dp[i][j]==dp[i-1][j-1]){
            i--;
            j--;
        }
        else if(dp[i][j-1]==dp[i][j]){
            j--;
        }
        else if(dp[i][j]==dp[i-1][j]){
            i--;
        }
        else if(dp[i][j]==dp[i-1][j-1]+1){
            ans+=s[i-1];
            len++;
            i--;
            j--;
        }
    }
    reverse(ans.begin(),ans.end());
    cout<<ans;
    return 0;
}

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

int main(){
  int N;
  string S;
  cin >> N >> S;
  int count = 0;
  for(int i = 0; i < N-2; i++){
    if(S.substr(i,3) == "ABC") count += 1;
  }
  cout << count << endl;
}


Measured memory_bytes: 3560
#include<bits/stdc++.h>
using namespace std;
const int inf=1e9;
const int mx=1e6;
int n,a[mx][3],dp[mx][3];
bool vis[mx][3];

int solve(int i ,int x)
{
    if(i==n)
        return 0;
    if(vis[i][x])
        return dp[i][x];
    int ans=0,j;
    for(j=0;j<3;j++)
    {
        if(j==x)
            continue;
        ans=max(ans,a[i][x]+solve(i+1,j));
    }
    vis[i][x]=1;
   return dp[i][x]=ans;
}

int main()
{
int i,j,k,ans;
cin>>n;
for(i=0;i<n;i++)
    for(j=0;j<3;j++)
    cin>>a[i][j];

cout<<max(max(solve(0,0),solve(0,1)),solve(0,2))<<endl;




return 0;}


Measured memory_bytes: 14464
#include<cmath>
#include<cstdio>
#include<vector>
#include<cstring>
#include<algorithm>

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

using namespace std;

typedef long long ll;

const ll INF=1<<29;

ll knapsack(const vector<ll> &w,const vector<ll> &p,ll W){
	ll dp[10001];
	rep(j,W+1) dp[j]=(j==0?0:-INF);
	rep(i,w.size()) rep(j,W-w[i]+1) dp[j+w[i]]=max(dp[j+w[i]],dp[j]+p[i]);
	return *max_element(dp,dp+W+1);
}

ll TSP(ll n,const ll d0[7],const ll d[7][7],ll S_tar){
	if(S_tar==0) return 0;

	ll dp[1<<7][7];
	rep(S,1<<n) rep(i,n) dp[S][i]=INF;
	rep(i,n) dp[1<<i][i]=d0[i];
	rep(S,1<<n) rep(i,n) if(S&1<<i) {
		rep(j,n) if(!(S&1<<j)) dp[S|1<<j][j]=min(dp[S|1<<j][j],dp[S][i]+d[i][j]);
	}
	ll res=INF;
	rep(i,n) res=min(res,dp[S_tar][i]+d0[i]);
	return res;
}

int main(){
	ll n,m,W,T; scanf("%lld%lld%lld%lld",&n,&m,&W,&T);
	char s_sell[7][8];
	ll weight[7],sell[7];
	rep(i,m) scanf("%s%lld%lld",s_sell[i],weight+i,sell+i);

	ll num[7],x[7],y[7];
	char s_buy[7][7][8];
	ll buy[7][7];
	rep(i,n){
		scanf("%lld%lld%lld",num+i,x+i,y+i);
		rep(j,num[i]) scanf("%s%lld",s_buy[i][j],buy[i]+j);
	}

	ll value[1<<7]; // value[S] := ( 町の集合 S を回るとき, 重さ<=W となる価値の総和の最大値 )
	rep(S,1<<n){
		vector<ll> w,p;
		rep(i,n) if(S&1<<i) rep(j,num[i]) {
			ll k;
			for(k=0;strcmp(s_sell[k],s_buy[i][j])!=0;k++);
			if(sell[k]>buy[i][j]){
				w.push_back(weight[k]);
				p.push_back(sell[k]-buy[i][j]);
			}
		}
		value[S]=knapsack(w,p,W);
	}

	ll d0[7]; // 市場との距離
	rep(i,n) d0[i]=abs(x[i])+abs(y[i]);
	ll d[7][7]; // 町と町との距離
	rep(i,n) rep(j,n) d[i][j]=abs(x[i]-x[j])+abs(y[i]-y[j]);

	ll dist[1<<7]; // dist[S] := ( 市場からスタートして, 町の集合 S をすべて回って市場に戻ってくる最短距離 )
	rep(S,1<<n) dist[S]=TSP(n,d0,d,S);

	// 今度は距離をコストだと思って, 品物の数 2^n の非有界ナップザック問題を解く
	vector<ll> w,p;
	rep(S,1<<n){
		w.push_back(dist[S]);
		p.push_back(value[S]);
	}
	printf("%lld\n",knapsack(w,p,T));

	return 0;
}

Measured memory_bytes: 1148
import collections

s = input()
v = collections.deque(s)
c = 0
while len(v) > 1:
    x = v[0]
    y = v[-1]
    if x == y:
        v.popleft()
        v.pop()
    else:
        if x == 'x':
            c += 1
            v.popleft()
        elif y == 'x':
            c += 1
            v.pop()
        else:
            print(-1)
            exit()

print(c)

Measured memory_bytes: 4212
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <climits>
using namespace std;

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

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

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

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, m;
    string s, t;
    cin >> n >> m >> s >> t;
    ll l = lcm(n, m);
    map<ll, int> x;
    REP(i, n) x[l / n * i] = s[i];
    REP(i, m) {
        if(x.count(l / m * i) == 0) continue;
        if(x[l / m * i] != t[i]) {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << l << endl;
    return 0;
}


Measured memory_bytes: 6144
#include<stdio.h>

int main(){
	long long int n, k;
	scanf("%lld %lld", &n, &k);
	
	long long int a[n+1];
	for(long long int i=0; i<n; i++){
		scanf("%lld", &a[i]);
	}
	
	for(long long int i=k; i<n; i++){
		if(a[i] > a[i-k]){
			printf("Yes\n");
		}
		else{
			printf("No\n");
		}
	}
	
	return 0;
}

Measured memory_bytes: 3160
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
#define TABLE_SIZE 16777216
#define ORDER_LENGTH 7
#define STR_LENGTH 13
 
using namespace std;
 
int array[128];
 
int translateStr(char buf[]){
    int sum = -1,mult = 1;
    for(int i = 0; buf[i] != '\0'; i++){
        sum += array[buf[i]]*mult;
        mult *= 4;
    }
    return sum;
}
 
int main(){
 
    array['A']=1,array['C']=2,array['G']=3,array['T']=4;
 
    int n;
    scanf("%d",&n);
    char order[ORDER_LENGTH],str[STR_LENGTH];
 
    char* check_table = new char[TABLE_SIZE];
 
    for(int i = 0; i < n; i++){
        scanf("%s %s",order,str);
        if(order[0] == 'i'){
            check_table[translateStr(str)] = 'Y';
        }else{
            if(check_table[translateStr(str)] == 'Y'){
                printf("yes\n");
            }else{
                printf("no\n");
            }
        }
    }
}


Measured memory_bytes: 4452
# ABC151 D
def solve_maze(sx, sy, maze):
    distance = [[None for _ in range(w)] for _ in range(h)]
    queue = [(sx, sy)]
    distance[sy][sx] = 0
    max_distance = 0

    while queue:
        x, y = queue.pop()

        for i in range(4):
            nx, ny = x + [1, 0, -1, 0][i], y + [0, 1, 0, -1][i]
            try:
                if (0 <= nx <= w and 0 <= ny <= h and maze[ny][nx] == "." and distance[ny][nx] is None):
                    queue.insert(0, (nx, ny))
                    dis = distance[y][x] + 1
                    distance[ny][nx] = dis
                    max_distance = max(max_distance, dis)
            except IndexError:
                pass

    return max_distance
    

h, w = list(map(int, input().split())) # h, w = y, x
maze = [input() for _ in range(h)]

result = 0
for j in range(h):
    for k in range(w):
        if maze[j][k] == ".":
            result = max(result, solve_maze(k, j, maze))

print(result)

Measured memory_bytes: 3188
#include<stdio.h>

int main(void)
{
	int N;
	scanf("%d", &N);
	for(int i = 1; i <= 9; i++)
		if((N%i == 0) && (1<=N/i && N/i<=9))
		{
			printf("Yes\n");
			return 0;
		}
	printf("No\n");
	return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#define N 500000

int H,A[N + 1];

int left(int j){
  return 2 * j;
}

int right(int k){
  return 2 * k + 1;
}

void maxHeapify(int A[],int i){
  int l,r,t;
  int biggest = 0;
  l = left(i);
  r = right(i);
  if(l <= H && A[l] > A[i]){
    biggest = l;
  }
  else biggest = i;

  if(r <= H && A[r] > A[biggest]){
    biggest = r;
  }

  if(biggest != i){
    t = A[i];
    A[i] = A[biggest];
    A[biggest] = t;
    maxHeapify(A,biggest);
  }
}


int main(){
  int i;
  scanf("%d",&H);
  
  for(i = 1;i <= H;i++){
    scanf("%d",&A[i]);
  }

  for(i = H / 2;i >= 1;i--){
    maxHeapify(A,i);
  }

  for(i = 1;i <= H;i++){
    
    printf(" %d",A[i]);
  }
  printf("\n");

  return 0;
}



Measured memory_bytes: 3752
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	string s;
	cin >> s;
	int n = s.size();
	int ans = 0, change = 0;
	for(int i = 1; i < n; ++i){
		if(s[i] != '9')
			change++;
		ans += 9;
	}
	ans += s[0]-'0';
	if(change)
		cout << ans-1 << '\n';
	else
		cout << ans << '\n';

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int k;
const int N=1e5+10;
int f[N][3];
int memo[N][3];
 
int dp(int pos, int now){
    if(pos==k) return 0;
    if(memo[pos][now]!=-1) return memo[pos][now];
    else{
        for(int i=0;i<3;i++){
            if(now==i) continue;
            else{
            memo[pos][now]=max(memo[pos][now],dp(pos+1,i)+f[pos][i]);
            }
        }
    }
    return memo[pos][now];
    
}
 
int main(){
    cin>>k;
    memset(memo,-1,sizeof(memo));
    for(int i=0;i<k;i++){
        for(int j=0;j<3;j++){
            cin>>f[i][j];
        }
    }
    int ans=0;
    for(int i=0;i<3;i++){
        ans=max(ans,dp(0,i));
    }
    cout<<ans<<'\n';
}

Measured memory_bytes: 13752
use std::io::*;
use std::str::FromStr;

const MOD: usize = 1_000_000_007;
/*
fn mod_pow(x: usize, n: usize) -> usize {
    if n > 0 {
        mod_pow(x * x % MOD, n >> 1) * if n & 1 == 1 { x } else { 1_usize } % MOD
    } else {
        1_usize
    }
}*/

fn main() {
    let l: Vec<char> = read::<String>().chars().collect();

    let mut vec: Vec<usize> = vec![1; l.len()+1];
    for i in 1..l.len() {
        vec[i] *= vec[i-1] * 3;
        vec[i] %= MOD;
    }
    let mut ans = vec[l.len()-1];
    let mut po = 2;
    for i in 1..l.len() {
        if l[i] == '1' {
            ans += po * vec[l.len() - i - 1];
            ans %= MOD;
            po *= 2;
            po %= MOD;
        }
    }
    ans += po;
    ans %= MOD;
    println!("{}", ans);
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
//by Top1
#include <bits/stdc++.h>
          
#define f first
#define s second
#define int long long
#define ld long double
#define ull unsigned long long
#define pii pair <int, int>
#define pll pair <long, long>
#define mp make_pair
#define pb push_back
#define pf push_front
#define pp pop_back
#define cerr cout
#define rev reverse
#define all(s) s.begin(), s.end()
#define sz(s) (int)s.size()
#define forn(i, a, b) for (int i = a; i <= b; i++)
#define boost ios_base::sync_with_stdio(false); cin.tie(0),cout.tie(0);
#define nxtp next_permutation
#define pvtp prev_permutation
#define KZ return 
#define x1 x21212121
#define y1 y21212121
#define sqr(x) x * x 
      
const int inf = (1e9) + 1;
const int mod = 479001599;
const int maxn = 1e6 + 111;
        
using namespace std;          

int n, m;

void solve(){
	double l;

	cin >> l;

	l = l / 3;

	cout << fixed << setprecision(6) << l * l * l;
}                              
      
main(){
    boost;
    
    int q = 1;
 
    //cin >> q;
    
    while (q--){
        solve();
    }
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <queue>
#include <map>  
#include <algorithm>
using namespace std;
void judge(int sx, int sy, int cnt) {
	
}
int main() {
	int x;
	cin >> x;
	cout << x*x*x << endl;
	return 0;
	}

Measured memory_bytes: 1160
N = int(input())
S = [input() for __ in range(N)]
M = int(input())
T = [input() for __ in range(M)]

dic_S = {x:0 for x in set(S)}
dic_T = {x:0 for x in set(T)}
ans = list(range(len(set(S))))
for s in S:
    dic_S[s] += 1
for t in T:
    dic_T[t] += 1
for i,key in enumerate(dic_S):
    if key in list(dic_T.keys()):
        ans[i] = dic_S[key]-dic_T[key]
    else:
        ans[i] = dic_S[key]
if max(ans) > 0:
    print(max(ans))
else:
    print(0)

Measured memory_bytes: 3064
var obj = init();
Main();
function nextInt(){return myconv(next(),1);}
function nextStrArray(){return myconv(next(),2);}//半角スペース分割
function nextIntArray(){return myconv(next(),4);}//半角スペース + 数値化
function nextCharArray(){return myconv(next(),6);}//1文字分割
function next(){return obj.next();}
function hasNext(){return obj.hasNext();}
function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");}
function init(){
  var inputFile = myin();
  var returnObj = {
    "list" : inputFile, "index" : 0, "max" : inputFile.length,
    "hasNext" : function(){return (this.index < this.max);},
    "next" : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(t){console.log(t);}//標準出力
function myerr(t){console.error(t);}//標準エラー出力
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  var N = nextInt();
	var list = new Array(N);
	for(var i = 0; i < N; i++){
		list[i] = {
			accessed : false,
			children : {},
			kyori : 0
		};
	}
	for(var i = 0; i < N - 1; i++){
		var tmp = nextIntArray();
		list[tmp[0] - 1]["children"][tmp[1] - 1] = tmp[2];
		list[tmp[1] - 1]["children"][tmp[0] - 1] = tmp[2];
	}
	var two = nextIntArray();
	var Q = two[0];
	var K = two[1] - 1;
	list[K]["accessed"] = true;
	var queue = [K];
	while(queue.length > 0){
		var tmp = queue.shift();
		var keys = Object.keys(list[tmp]["children"]);
		for(var i = 0; i < keys.length; i++){
			if(list[keys[i]]["accessed"]){continue;}
			list[keys[i]]["accessed"] = true;
			list[keys[i]]["kyori"] += list[tmp]["children"][keys[i]] + list[tmp]["kyori"];
			queue.push(keys[i]);
		}
	}
	var output = new Array(Q);
	for(var i = 0; i < Q; i++){
		var tmp = nextIntArray();
		tmp[0]--;
		tmp[1]--;
		output[i] = list[tmp[0]]["kyori"] + list[tmp[1]]["kyori"];
	}
	myout(myconv(output,9));
}

Measured memory_bytes: 101552
#include <bits/stdc++.h>
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << '\n'
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef double db;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a; }
//head
 
void solve(){
    int n;
    cin >> n;
    vector<int> h(n);
    for (int i = 0; i < n; i++) cin >> h[i];
    h[0]--;
    for (int i = 1; i < n; i++){
        if (h[i] > h[i-1]) h[i]--;
        else if (h[i] < h[i-1]){
            cout << "No\n";
            return;
        }
    }
    cout << "Yes\n";
}

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

    //int t; cin >> t; while (t--)
        solve();
}

Measured memory_bytes: 3680
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define mem(i,a) memset(i,a,sizeof(i))
#define PI acos(-1.0)
#define DMAX 100005
#define MOD 20190823
#define eps 1e-8
#define bl bool
#define INF 1e+9
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
template<class T> inline void read(T &f){
	f=0;
    T x=1;
    char ch=getchar();
    while(ch<48 || ch>57) {
        if(ch=='-') {
            x=-1;
        }
        ch=getchar();
    }
    while(ch<=57 && ch>=48) {
        f=f*10+ch-'0';
        ch=getchar();
    }
    f*=x;
}
struct student{
	ll id;
	ll people;
};
student a[DMAX];
bool Cmp(const student &x,const student &y){
	return x.people<y.people;
}
int main(){
	ll n;
	read(n);
	for(ll i=1;i<=n;i++){
		read(a[i].people);
		a[i].id=i;
	}
	sort(a+1,a+n+1,Cmp);
	for(ll i=1;i<=n;i++){
		cout<<a[i].id<<" ";
	}
	return 0;
}

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

typedef struct{
	int pid;
	long long sell;
}people;

int main(){
	while(1){
		long n;
		people p[4000];
		
		scanf(" %ld", &n);
		if(n==0) break;
		
		int now=0;
		
		for(long i=0; i<n; ++i){
			int num;
			long t, u;
			scanf(" %d %ld %ld", &num, &t, &u);
			
			bool find=false;
			for(int j=0; j<now; ++j){
				if(p[j].pid==num){
					p[j].sell+=t*u;	
					find=true;
				}
			}
			if(!find){
				p[now].pid=num;
				p[now].sell=t*u;
				now++;
			}
		}		
		
		int count=0;
		for(int i=0; i<now; ++i){
			if(p[i].sell>=1000000){
				printf("%d\n", p[i].pid);
				++count;
			}		
		}
		
		if(count==0) printf("NA\n");
	}	
}

Measured memory_bytes: 1220
let n = Scanf.scanf " %d" (+) 0
let rec f n = if n mod 2 <> 0 then 0 else 1 + f (n / 2)
let a_s = Array.init n @@ fun _ -> Scanf.scanf " %d" f
let _ = Printf.printf "%d\n" @@ Array.fold_left min a_s.(0) a_s

Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
inline int read(){
    int x=0,f=1;
    char c=getchar();
    while(c<'0'||c>'9'){
        if(c=='-')f=-1;
        c=getchar();
    }
    while(c>='0'&&c<='9'){
        x=(x<<3)+(x<<1)+c-'0';
        c=getchar();
    }
    return x*f;
}
int n,r;
int main(){
	n=read(),r=read();
	if(n>=10){
		printf("%d\n",r);
	}
	else{
		printf("%d\n",r+100*(10-n));
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
   int i, h, m, s;
   cin >> i;
   h = i / 3600;
   m = (i / 60) % 60;
   s = i % 60;
   cout << h << ":" << m << ":" << s << endl; 
   
   return 0;
}


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

using namespace std;

void go(int cx, int cy, const vector<pair<int, int>> &xy,
        vector<int> &taken, double &res) {
    double cur = sqrt(1LL * cx * cx + 1LL * cy * cy);
    res = max(res, cur);
    for (int i = 0; i < (int)xy.size(); ++i) {
        if (!taken[i]) {
            int nx = cx + xy[i].first, ny = cy + xy[i].second;
            double ncur = sqrt(1LL * nx * nx + 1LL * ny * ny);
            if (ncur > cur) {
                taken[i] = 1;
                go(nx, ny, xy, taken, res);
                return;
            }
        }
    }
}

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

    auto now = chrono::system_clock::now();
    auto now_ms = chrono::time_point_cast<chrono::milliseconds>(now);
    auto epoch = now_ms.time_since_epoch();
    auto value = chrono::duration_cast<chrono::milliseconds>(epoch);
    mt19937 gen(value.count());

    int N;
    cin >> N;
    vector<pair<int, int>> xy(N);
    for (int i = 0; i < N; ++i) {
        cin >> xy[i].first >> xy[i].second;
    }
    double res = 0;
    for (int r = 0; r < 2000; ++r) {
        for (int i = 0; i < N; ++i) {
            vector<int> taken(N, 0);
            taken[i] = 1;
            go(xy[i].first, xy[i].second, xy, taken, res);
        }
        shuffle(begin(xy), end(xy), gen);
    }
    cout.precision(17);
    cout << fixed << res << "\n";

    return 0;
}

Measured memory_bytes: 384
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a=sc.nextInt(),b=sc.nextInt(),c=sc.nextInt(),cnt=0;
        for(int i=a;i<=b;i++){
            if(c%i==0)cnt++;
        }
        System.out.println(cnt);
    }
}


Measured memory_bytes: 26356
#include<bits/stdc++.h>
using namespace std; 
#define all(c) c.begin(),c.end()
#define REP(i,a,b) for(int i=a;i<=b;++i)
#define tr(container,it) \
for(auto it=container.begin();it!=container.end();++it)
typedef long long ll ; 
typedef vector<int> vi;
#define mod 1000000007 

int main()
{
  //  freopen("input.txt","r",stdin);
   ios::sync_with_stdio(0);
   // cin.tie(0);
   
string s,t;
cin>>s>>t;
int best=10000;
for(int i=0;i<=s.size()-t.size();++i){
  string tmp=s.substr(i,t.size());
  int ans=0;
  for(int j=0;j<tmp.size();++j){
    if(tmp[j]!=t[j])
    ++ans;

  }
  best=min(ans,best);
}
cout<<best;

    return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()
#define fsp(x) cout << fixed << setprecision(x)
const ll inf = LLONG_MAX;
const long double pi = acos(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
	ll n, m;
	cin >> n >> m;
	vll v(n, 1);
	vector<bool> w(n, false);
	w[0] = true;
	for (ll i = 0; i < m; i++) {
		ll x, y;
		cin >> x >> y;
		x--;
		y--;
		if (w[x]) {
			if (v[x] == 1) w[x] = false;
			w[y] = true;
		}
		v[x]--;
		v[y]++;
	}
	ll ans = 0;
	for (ll i = 0; i < n; i++) if (w[i]) ans++;
	cout << ans << endl;
}


Measured memory_bytes: 1024
N = int(input())
L = sorted(list(map(int, input().split())))
ans = 0
for i in range(N):
    for j in range(i+1, N):
        if L[i] == L[j]:
            continue
        for k in range(j+1, N):
            if L[i] == L[k] or L[j] == L[k]:
                continue
            if L[i] + L[j] > L[k]:
                ans += 1
print(ans)

Measured memory_bytes: 9188
import java.util.Scanner;

public class Main {

    private static final String YES = "Yay!";
    private static final String NO = ":(";

    public static String process(int a, int b, int c, int d, int e, int k) {
        return ((e - a) <= k) ? YES : NO;
    }

    // Util func

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

        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        int e = sc.nextInt();
        int k = sc.nextInt();

        final String result = process(a, b, c, d, e, k);

        output(result);
    }

    private static void output(String result) {
        System.out.println(result);
    }
}


Measured memory_bytes: 21716
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
#include <deque>
#include <functional>
#include <sstream>
using namespace std;

// 정답이 ll 이상일 경우 INF를 98765432100000 정도까지 크게 해야함
// 입력받는 값이 10^9 이고 답이 뭔가 그것들을 더하는 연산이라면 답은 ll 일수 있다
// priority_queue 는 기본적으로 내림차순 정렬이다. 오름차순으로 하고 싶다면 priority_queue<int, vector<int>, greater<int>>
// queue에서 pop하기 전에는 반드시 empty인 경우를 체크하고 예외처리 해줘라


#define INF 9876543210
#define mod 1000000007
#define mt make_tuple
#define mp make_pair
typedef long long ll;

int n;
int arr[100011];

int main() {

	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &arr[i]);
	}
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		if (arr[arr[i]] == i) ans++;
	}
	printf("%d\n", ans/2);


	return 0;
}

Measured memory_bytes: 640
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;
import java.util.TreeSet;

public class Main {
    Scanner sc = new Scanner(System.in);
  
    public static void main(String[] args) {
        new Main(); 
    }
  
    public Main() {
    	while(sc.hasNextLine()){
    		new D().doIt();
    	}
    }
    class D{
    	void doIt(){
    		String str = sc.nextLine();
    		str = str.toUpperCase();
    		str = str.replaceAll("[^A-Z]", "");
//    		System.out.println(str);
    		ans(str,str.length());
    	}
    	void ans(String str,int length){
    		TreeSet<String> ts = new TreeSet<String>();
    		TreeSet<String> ts2 = new TreeSet<String>();
    		for(int i = 1;i < length - 1;i++){
    			String ss = "";
    			String ss2 = "";
    			for(int j = 1;j < length;j++){
    				if(str.charAt(i-j) == str.charAt(i+j)){
    					ss2 = ss;
    					ss = str.substring(i-j,i+j+1);
    					ts2.add(ss2);
//    					System.out.println(ss);
    				}else{
    					if(ss.equals(""))break;
    					ts.add(ss);
    					break;
    				}
    				if(i-j == 0 || i +j == length-1){
    					if(ss.equals(""))break;
    					ts.add(ss);
    					break;
    				}
    			}
    			ss = "";
    			ss2 = "";
    			if(str.charAt(i) == str.charAt(i+1)){
    				for(int j = 1;j < length;j++){
    					if(i+j+1 == length)break;
        				if(str.charAt(i-j) == str.charAt(i+j+1)){
        					ss2 = ss;
        					ss = str.substring(i-j,i+j+2);
        					ts2.add(ss2);
        				}else{
        					if(ss.equals(""))break;
        					ts.add(ss);
        					break;
        				}
        				if(i - j == 0 || i + j == length-1){
        					if(ss.equals(""))break;
        					ts.add(ss);
        					break;
        				}
        			}
    			}
    		}
    		if(ts.size() > 0){
    			System.out.print(ts.pollFirst());
    		}
    		int size = ts.size();
    		for(int i = 0;i < size;i++){
    			String s = ts.pollFirst();
                if(!ts2.contains(s)){
                	System.out.print(" "+s);
                }
    		}
    		System.out.println();
    	}
    }
}

Measured memory_bytes: 28924
#include <cstdio>
#include <cmath>
#include <vector>

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

typedef std::vector<int> v;
typedef std::vector<std::vector<int>> vv;

int main(void)
{
    if ([]() {
            int k, a, b;
            scanf("%d %d %d", &k, &a, &b);
            rep(i, ceil(b / k))
            {
                if (k * (i + 1) >= a)
                    return true;
            }
            return false;
        }())
    {
        puts("OK");
    }
    else
        puts("NG");
}

Measured memory_bytes: 3140
#include<bits/stdc++.h>
using namespace std;
const unsigned int M = 1000000007;
int main(){
 int d,t,s;
 cin >> d >> t >> s;
 if((t*s)>=d){
   cout << "Yes" << endl;
 }else{
   cout << "No" << endl;
 }
 return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<cmath>
using namespace std;
int main ()
{
    int c=0,d ;
    int a,b;
    cin>>a>>b;
    if (a<b)
    {
        d=a;
        a=b;
        b=d;
    }
    int i;
    for (i=0; i<=a; i++)
    {
        if (abs(a-i) == abs (b-i))
        {
            cout<<i<<endl;
            return 0;
        }
        else c++;
    }

    if (c !=0)
    {
        cout<<"IMPOSSIBLE"<<endl;
    }




    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <list>
#include <algorithm>

using namespace std;

int main()
{
    list<int> l = {1, 2, 3};
    int a = 0;
    int b = 0;
    cin >> a >> b;
    
    auto it = std::find(l.begin(), l.end(), a);
    if (it != l.end()) {
        l.erase(it);
    }
    it = std::find(l.begin(), l.end(), b);
    if (it != l.end()) {
        l.erase(it);
    }
    
    for (int n : l) {
        std::cout << n << '\n';
    }

    return 0;
}


Measured memory_bytes: 256
from sys import stdin

def main():
    N = int(input())
    H = list(map(int, input().split()))

    h = H[:]
    ans = 0
    while any(h):
        flag = 0
        for i, n in enumerate(h):
            if n > 0:
                h[i] -= 1
            else:
                flag = 0
                continue
            if not flag:
                flag = 1
                ans += 1
    print(ans)

input = lambda: stdin.readline()
main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a,b,q;cin >> a >> b >> q;
	vector<ll> s(a+2),t(b+2);
	rep(i,a) cin >> s.at(i+1);
	rep(i,b) cin >> t.at(i+1);
	s.at(a+1)=1000000000000000000;
	t.at(b+1)=1000000000000000000;
	s.at(0)=-1000000000000000000;
	t.at(0)=-1000000000000000000;
	rep(i,q){
		ll x;cin >> x;
		int j=lower_bound(s.begin(),s.end(),x)-s.begin(),k=lower_bound(t.begin(),t.end(),x)-t.begin();
		ll ans,s1=s.at(j),s2=s.at(j-1),t1=t.at(k),t2=t.at(k-1);
		ans=min(max(x-s2,x-t2),min(max(s1-x,t1-x),min((s1-x)*2+(x-t2),min((t1-x)*2+(x-s2),min((x-t2)*2+(s1-x),(x-s2)*2+(t1-x))))));
		cout << ans << endl;
	}
}


Measured memory_bytes: 2944