akhauriyash/Code-Regression huggingface dataset:
# include <bits/stdc++.h>
# define sz(x) (int)((x).size())
# define F first
# define S second
# define pb push_back
# define ub upper_bound
# define lb lower_bound
# define all(x) x.begin(), x.end()
# define pqueue priority_queue
# define mset multiset
# define umap unordered_map
# define Speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
# define rep(i,n) for(int i=0;i<n;++i)
# define forn(i,n) for(int i=1;i<=n;++i)
# define lr(i,l,r) for(int i=l;(l>r?i>=r:i<=r);(l>r?--i:++i))

using namespace std;

template<class T> void umin(T &a, T b) { a = min(a, b); }
template<class T> void umax(T &a, T b) { a = max(a, b); }

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

const int mod = 1e9+7;
const int N = 1e5+5;

int n,m;
ll ans;
void solve(){
	cin>>n>>m;
	vector<pii>v;
	forn(i,n){
		int x,y;
		cin>>x>>y;
		v.pb({x,y});
	}
	sort(all(v));
	rep(i,n){
		if(!m)break;
		if(m-v[i].S>=0){
			m-=v[i].S;
			ans+=v[i].S*1LL*v[i].F;	
		}
		else{
			ans+=v[i].F*1LL*m;
			m=0;
		}
	}

	cout<<ans;
}

int main(){
	Speed();
	int T=1; 
	//cin>>T;	
	while(T--)
		solve();
	return 0;
}

Measured memory_bytes: 4260
import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

if __name__ == '__main__':
    a = [int(i) for i in input().split()]
    
    if a[0] % 2 ==1:
        a[0] +=1


    if a[0]//2 >=a[1] :
        print("YES")
    else:
        print("NO")


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

typedef long long ll;
typedef long double ld;
#define pi 3.14159265359
#define inf (1 << 21)
#define mod 1000000007

int gcd(int n, int m) {
    if (n < m) swap(n, m);
    if (n % m == 0) return m;
    return gcd(m, n % m);
}

int main() {
    int N; cin >> N;
    vector<int> A(N);
    int ans;
    for (int i = 0; i < N; i++) {
        cin >> A.at(i);
        if (i == 0) ans = A.at(i);
        else ans = gcd(ans, A.at(i));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
N,x=map(int,input().split())
a=list(map(int,input().split()))
ans=0
for i in range(1,N):
    tmp=a[i-1]+a[i]
    if tmp>x:
        ans+=tmp-x
        if a[i]>=tmp-x:
            a[i]-=tmp-x
        else:
            a[i]=0
print(ans)


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

int main() {
string s;
  cin>>s;
  for(int i=0;i<8;i++) {
    int x = s[0]-'0';
    string ans = "";
    ans += s[0];
    for(int j=0;j<3;j++){
      if (i>>j&1) {
        x += s[j+1]-'0';
        ans += '+';
      } else {
        x -= s[j+1]-'0';
        ans += '-';
      }
      ans += s[j+1];
    }
    if (x == 7) {
      ans += "=7";
      cout<<ans<<endl;
      return 0;
    }
  }
  cout<<-1<<endl;
  return 0;
}



Measured memory_bytes: 3588
#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;

ll modpow(ll a, ll b, ll p = 1e9+7){
    if(b == 0)  return 1;
    if(b % 2 == 0){
        ll d = modpow(a, b/2, p);
        return (d*d) % p;
    }else{
        return (a%p * modpow(a, b-1, p)) % p;
    }
}

struct ModComb{
    vector<ll> po, inv;
    ll N;

    ModComb(ll n) : N(n), po(n), inv(n) {
        po[0] = 1;
        for(int i = 1; i < N; i++)  po[i] = (po[i-1] * i) % mod;
        inv[N-1] = modpow(po[N-1], mod-2, mod);
        for(int i = N-2; i >= 0; i--)   inv[i] = (inv[i+1] * (i+1)) % mod;
    }
    
    ll nCk(ll n, ll k){
        if(n < k)   return 0;
        return (((po[n]*inv[n-k])%mod)*inv[k])%mod;
    }

    ll nPk(ll n, ll k){
        if(n < k)   return 0;
        return (po[n]*inv[n-k])%mod;
    }

    ll nHk(ll n, ll k){
        if(n == 0 && k == 0)    return 1;
        return nCk(n+k-1, k);
    }
};

int main(){
    ModComb mc(100005);
    int n;
    cin >> n;
    vector<int> a(n+1), cnt(n+1, 0);
    int p;
    for(int i = 0; i <= n; i++){
        cin >> a[i];
        cnt[a[i]]++;
        if(cnt[a[i]] == 2)  p = a[i];
    }
    int l = n+1, r = -1;
    for(int i = 0; i <= n; i++){
        if(a[i] == p)   l = min(l, i), r = max(r, i);
    }
    for(int k = 1; k <= n+1; k++){
        ll ans = 0;
        if(n+1-2 >= k)  ans += mc.nCk(n-1, k);
        ans %= mod;
        ans += 2*mc.nCk(n-1, k-1);
        if(n+1-(r-l+1) >= k-1)  ans -= mc.nCk(n+1-(r-l+1), k-1);
        if(ans < 0) ans += (-ans/mod+1)*mod;
        ans %= mod;
        if(k >= 2)  ans += mc.nCk(n+1-2, k-2);
        ans %= mod;
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll ans = (b*d);
    ans = max(ans, b*c);
    ans = max(ans, a*c);
    ans = max(ans, b*d);
    ans = max(ans, a*d);
    cout << ans ;
  return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a , b , c , d , e;
  cin >> a;
  b = a % 10;
  c = ((a-b)/10)%10;
  d = ((a-a%100)/100)%10;
  e = ((a-a%1000)/1000)%10;
  if (b == c && c == d){
    cout << "Yes" << endl;
  }
  else if (c == d && d == e){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;


int main(void) {
	int h, w;
	char c;
	cin >> h >> w;
	for (int i = 0; i < w + 2; i++) cout << "#";
	cout << endl;
	for (int i = 0; i < h; i++) {
		cout << "#";
		for (int j = 0; j < w; j++) {
			cin >> c;
			cout << c;
		}
		cout << "#" << endl;
	}
	for (int i = 0; i < w + 2; i++) cout << "#";
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
int hito = 0, ai = 0, bi = 0, ci = 0;
	char a[100];
char b[100];
	char c[100];
	gets(a);
	gets(b);
	gets(c);
	while(1){
		switch(hito){
			case 0:
			if(a[ai] == 'a'){
					hito = 0;
				}else if(a[ai] == 'b'){
					hito = 1;
				}else if(a[ai] == 'c'){
					hito = 2;
				}else{
					printf("A\n");
					return 0;
				}
			ai++;
			break;
			case 1:
			if(b[bi] == 'a'){
					hito = 0;
				}else if(b[bi] == 'b'){
					hito = 1;
				}else if(b[bi] == 'c'){
					hito = 2;
				}else{
					printf("B\n");
					return 0;
				}
			bi++;
			break;
			case 2:
				if(c[ci] == 'a'){
					hito = 0;
				}else if(c[ci] == 'b'){
					hito = 1;
				}else if(c[ci] == 'c'){
					hito = 2;
				}else{
					printf("C\n");
					return 0;
				}
			ci++;
			break;
			}
	
}
}



Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<string>
#include<map>
#include<set>
#include<functional>
#include<list>
#include<bitset>
using namespace std;
typedef long long ll;



int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin >> s;
	if (s[0] != 'A') {
		cout << "WA";
		return 0;
	}
	int a = 0;
	for (int i = 2; i < s.size() - 1; i++) {
		if (s[i] == 'C') {
			a++;
			continue;
		}
		
		if ((s[i]>= 'A') && (s[i] <= 'Z')) {
	//		cout << s[i] << "   d" << endl;
			cout << "WA";
			return 0;
		}
	}
	if (a != 1) {
		cout << "WA";
		return 0;
	}
	if (s[s.size() - 1] <= 'Z'&&s[s.size()-1] >= 'A') {
		cout << "WA";
		return 0;
	}
	if (s[1] <= 'Z'&&s[ 1] >= 'A') {
		cout << "WA";
		return 0;
	}
	cout << "AC";
	return 0;
	
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100005
#define NIL -1
struct Node_struct{int p, l, r;}; /*p: 親(parent), l: 一番左の子(left child), r:右の兄弟(right sibling)*/
typedef struct Node_struct Node;
Node T[MAX];
int D[MAX];

void print(int u){
 int i, c;
 printf("node %d: parent = %d, depth = %d, ", u, T[u].p, D[u]);

 if(D[u] == 0) printf("root, ");
 else if(T[u].l == NIL) printf("leaf, ");
 else printf("internal node, ");

 printf("[");
 for (i=0, c = T[u].l; c != NIL; i++, c = T[c].r){
   if(i) printf(", ");
   printf("%d", c);
 }
 printf("]\n");

}

void calcDepth(int u, int p){
 D[u] = p;
 if(T[u].r != NIL) calcDepth(T[u].r,p);
 if(T[u].l != NIL) calcDepth(T[u].l,p+1);
}

int main(){
 int i, j, k;
 int n;
 int id, sib, child;
 int root = NIL;
 scanf("%d", &n);
 for(i=0; i<n; i++) T[i].p = T[i].l = T[i].r = NIL;

 for(i=0; i<n; i++){
   scanf("%d %d", &id, &k);
   for(j = 0, sib = NIL; j<k; j++){ //子を入力する (input children)
     scanf("%d", &child);
     T[child].p = id;
     if(j == 0) T[id].l = child; //idの一番左の子 (the most left child of id)
     else T[sib].r = child; //左の兄弟に繋げる (connect to left sibling)
     sib = child;//次の子供の左の兄弟 (the left sibling of the next child)
   }
 }

 //根を求める (find the root)
 for(i=0; i<n; i++){
   if(T[i].p == -1) root = i;
 }

 //それぞれのノードの深さを求める (find depth of each node)
 calcDepth(root, 0);

 //出力 (output)
 for(i=0; i<n; i++) print(i);

 return 0;
}



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

using namespace std;

template <typename T>
T gcd(T a, T b) {
  return (b ? gcd(b, a % b) : a);
}

template <typename T>
T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}

int calc(int64_t x) {
  int k = 0;
  while (x % 2 == 0) {
    x /= 2;
    k++;
  }
  return k;
}

int main() {
  int64_t N, M;
  cin >> N >> M;
  vector<int64_t> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  vector<int64_t> B(N);
  for (int i = 0; i < N; i++) {
    B[i] = A[i] / 2;
  }

  int64_t L = 1;
  for (int64_t b : B) {
    L = lcm(L, b);
    if (L >= M * 2) {
      cout << 0 << endl;
      return 0;
    }
  }

  unordered_set<int> S;
  for (int64_t b : B) {
    S.insert(calc(b));
  }
  if (S.size() != 1) {
    cout << 0 << endl;
    return 0;
  }

  int64_t result = M / L - M / (L * 2);
  cout << result << endl;

  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define vll vector<ll>
#define vi vector<int>
#define vvll vector<vll>
#define wh(t) while(t--)
#define fi(n) for(ll i = 0; i < n; i++)
#define fj(n) for(ll j = 0; j < n; j++)
#define fu(i,s,e) for(ll i = s; i <=e; i++)
#define fd(i,s,e) for(ll i = s; i >=e; i--)
#define mp make_pair
#define pb push_back
#define pii pair<int, int>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define fr first
#define se second
#define sll stack<ll>
#define qll queue<ll>
using namespace std;
const ll M = 1e9+7;
//const ll M = 998244353;

ll pmp(ll x,ll n){ll a = 1;while(n > 0){if(n & 1) a = (a * x)%M;x = (x * x)%M;n = n>>1;}return a;}
ll pwr(ll x,ll n){ll a = 1;while(n > 0){if(n & 1) a = (a * x);x = (x * x);n = n>>1;}return a;}

void solve(){
	ll n;
	cin >> n;
	ll p = 1;
	ll l = 1;
	while(n-26*p > 0){
		p*=26;
		n-=p;
		l++;
	}
	// ll l=p-1;
	char ans[l];
	n--;
	ll pos = l-1;
	while(n){
		ans[pos--] = n%26+'a';
		n/=26;
	}
	while(pos!=-1) ans[pos--]='a';
	fi(l) cout << ans[i];
	cout << endl;
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	#endif
	ll t;
	t = 1;
	// cin >> t;
	wh(t){
		solve();
	}
	cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
	return 0;
}

Measured memory_bytes: 3764
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>
#include<iomanip>

using namespace std;
typedef long long int ll;

int n,m,r=0;
string a[101],b[101];
map<string,int> mp;

int main(){
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        cin>>a[i];
        mp[a[i]]=0;
    }
    scanf("%d",&m);
    for(int i=0;i<m;i++){
        cin>>b[i];
        mp[b[i]]=0;
    }
    
    for(int i=0;i<n;i++){
        mp[a[i]]++;
    }
    for(int i=0;i<m;i++){
        mp[b[i]]--;
    }
    
    for(auto itr=mp.begin();itr!=mp.end();++itr){
        r=max(itr->second,r);
    }
    printf("%d\n",r);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define INF 1e18L
int main() {
    int n, W;
    cin >> n >> W;
    vector< int > wt(n), val(n);
    for (int i = 0; i < n; i++) cin >> wt[i] >> val[i];
    int sum_val = 0;
    for (int i = 0; i < n; i++) sum_val += val[i];
    vector< long long > dp(sum_val + 1, INF);
    dp[0] = 0;
    for (int item = 0; item < n; item++) {
        for (int val_already = sum_val - val[item]; val_already >= 0; val_already--) {
            dp[val_already + val[item]] = min(dp[val_already + val[item]], dp[val_already] + (long long)wt[item]);
        }
    }
    long long ans = 0;
    for (int i = 0; i <= sum_val; i++) {
        if (dp[i] <= W) ans = max(ans, (long long) i);
    }
    cout << ans << "\n";
}

Measured memory_bytes: 4052
#include<iostream>
using namespace std;
int main()
{
int n;
cin>>n;
int ctr=0;
for(int a=1;a<n;a++)
{
  for(int b=1;b<n;b++)
   {
      int c=n-(a*b);
      if(c<=0)
      {
        break;
        }
       ctr++; 
      }
   }
   cout<<ctr<<endl;
   return 0;
}
      

Measured memory_bytes: 3644
// In the name of GOD
#include<bits/stdc++.h>
using namespace std;

#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";

#define     IOS         ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define 	setprecn(x) cout<<fixed<<setprecision(x);
#define 	ll          long long int
#define 	pb          push_back
#define 	pll         pair<ll,ll>
#define 	vll         vector<ll>
#define 	ff          first
#define 	ss          second
#define 	all(a)      (a).begin(),(a).end()
#define 	sz(x)       (ll)x.size()
#define 	mod         1000000007
#define 	inf         10000000000000007
#define 	rep(i,n)    for(ll i=0;i<n;i++)
#define 	repe(i,a,b) for(ll i=a;i<b;i++)
#define 	lbnd        lower_bound
#define 	ubnd        upper_bound
#define 	bs          binary_search

ll power(ll a,ll b,ll m=mod)
{
	if(b==0)
		return 1;
	if(b==1)
		return a;
	ll c=power(a,b/2,m);
	if(b%2==0)
		return((c%m)*(c%m))%m;
	return ((((c%m)*(c%m))%m)*(a%m))%m;
}
/********************************************************/
//	d.erase(unique(all(d)), d.end());



int main()
{
	IOS;
	ll n,k,m,i,j,c=0,cs=0,t;
	t=1;

	// cin>>t;
	string s,q,p="";
	while(t--)
	{
		ll a,b;
		cin>>n>>a>>b>>c;
		// n=s.length();
		// ll a[n];
		cin>>s;
		rep(i,n)
		{
			if(i<n-1)cin>>q;
			if(s=="AB")
			{
				if(a==1 && b==1 && c==0)
				{
					if(q=="AC")
						a++,b--,p+='A';
					else a--,b++,p+='B';
				}
				else if(a>b)
					a--,b++,p+='B';
				else a++,b--,p+='A';
			}
			else if(s=="AC")
			{
				if(a==1 && b==0 && c==1)
				{
					if(q=="AB")
						a++,c--,p+='A';
					else a--,c++,p+='C';
				}
				else if(a>c)
					a--,c++,p+='C';
				else a++,c--,p+='A';
			}
			else
			{
				if(a==0 && b==1 && c==1)
				{
					if(q=="AC")
						c++,b--,p+='C';
					else c--,b++,p+='B';
				}
				else if(b>c)
					b--,c++,p+='C';
				else b++,c--,p+='B';
			}
			if(a<0 || b<0 || c<0)
			{
				cout<<"No\n";
				return 0;
			}
			s=q;
		}
		
		cout<<"Yes\n";
		rep(i,n)
		{
			cout<<p[i]<<"\n";
		}
	}
	return 0;
}

Measured memory_bytes: 3796
n = int(input())
d = list(map(int,input().split()))
d.sort()
ans = 0
if len(d) % 2 == 1:
    ans = 0
if len(d) % 2 == 0:
    med = int(len(d) / 2)
    if d[med] == d[med-1]:
        ans = 0
    else:
        for i in range(d[med-1]+1,d[med]+1):
            ans += 1
    
    
print(ans)

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

using i64 = long long;
using P = pair<i64, i64>;


void solve(long long N, long long K, long long R, long long S, long long P, std::string T){
    i64 n = N;
    vector<i64> pre(n);
    i64 ans = 0;
    for(int i = 0; i < n; ++i){
        bool f = false;
        if(i >= K){
            if(T[i] != T[i - K]){
                pre[i] = 1;
                f = true;
            }else if(pre[i - K] == 0){
                pre[i] = 1;
                f = true;
            }
        }else{
            pre[i] = 1;
            f = true;
        }
        if(f){
            if(T[i] == 'r') ans += P;
            if(T[i] == 's') ans += R;
            if(T[i] == 'p') ans += S;
        }
    }
    cout << ans << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    long long R;
    scanf("%lld",&R);
    long long S;
    scanf("%lld",&S);
    long long P;
    scanf("%lld",&P);
    std::string T;
    std::cin >> T;
    solve(N, K, R, S, P, T);
    return 0;
}


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

int main() {
  int cat,mix,hopeCat;
  string chk = "NO";
  
  cin >> cat >> mix >> hopeCat;
  
  if(cat == hopeCat){
    chk = "YES";
  }else if(cat < hopeCat){
    if(cat + mix >= hopeCat) chk = "YES";
  }
  
  cout << chk;
}


Measured memory_bytes: 256
import sys
bbn=1000000007
	
#+++++
		
def main():
	n = int(input())
	pl=101
	
	ff=[0]*pl
	for i in range(pl):
		ff[i]=[0]*pl
	
	v=[]
	v0=[]
	for i in range(n):
		x, y, h = map(int, input().split())
		if h > 0:
			v.append([x,y,h])
		else:
			v0.append([x,y,h])
		
	
	tt=0
	for i, [xi, yi, hi] in enumerate(v):
		for [xj, yj, hj] in v[i+1:]:
			tt+=1
			for px in range(pl):
				for py in range(pl):
					ihp=hi+abs(px-xi)+abs(py-yi)
					jhp=hj+abs(px-xj)+abs(py-yj)
					if ihp==jhp:
						ff[px][py]+=1
	
	for i, [xi, yi, hi] in enumerate(v):
		for [xj, yj, hj] in v0:
			tt+=1
			for px in range(pl):
				for py in range(pl):
					ihp=hi+abs(px-xi)+abs(py-yi)
					jhp=hj+abs(px-xj)+abs(py-yj)
					if ihp<=jhp:
						ff[px][py]+=1
								
	for i, vl in enumerate(ff):
		for j, va in enumerate(vl):
			if va == tt:
				[x,y,h]=v[0]
				rh=h+abs(x-i)+abs(y-j)
				print(i,j,rh)
				return
	if len(v)	== 0:		
		raise NameError('HiThere')
	print(0,0,1)
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 56668
N=int(input())

Mod=10**9+7
S=input()
T=input()

if S[0]==T[0]:
    K,I=3,1
    Mode=True
else:
    K,I=6,2
    Mode=False

#Mode:True->縦,False->横

while I<N:
    if S[I]==T[I]:
        if Mode:
            K*=2
        else:
            K*=1
        Mode=True
        I+=1
    else:
        if Mode:
            K*=2
        else:
            K*=3
        Mode=False
        I+=2
    K%=Mod
print(K)

Measured memory_bytes: 61856
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;

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

	vector<vector<double>> x(n, vector<double>(d));
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < d; j++)
		{
			cin >> x.at(i).at(j);
		}
	}

	int cnt = 0;
	for (int i = 0; i < n; i ++)
	{
		for (int j = i + 1; j < n; j++)
		{
			double s = 0;
			for (int k = 0; k < d; k++)
			{
				s += (x.at(i).at(k) - x.at(j).at(k)) * (x.at(i).at(k) - x.at(j).at(k));
			}


			if ((int)sqrt(s) == sqrt(s))
			{
				cnt++;
			}
		}
	}

	cout << cnt << endl;
}

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


int main() {
	int n,res = 0;
	cin >> n;
	
	vector<int> d(n);
	
	rep(i,n) cin >> d[i];
	
	rep(i,n){
	    for(int j=i+1;j<n;j++){
	        res += d[i]*d[j];
	    }
	}
	
	cout << res << endl;
	
	return 0;
}



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

using namespace std;
typedef long long ll;
#define int ll
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#ifdef int
const ll INF = (1LL<<60);
#else
const int INF = (1LL<<30);
#endif
const double PI = 3.14159265359;
const double EPS = 1e-12;
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

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

#define MAX_N 200000

class UnionFind {
private:
  // 親と木の深さ
  int par[MAX_N];
  int rank[MAX_N];
  int s[MAX_N];
  bool used[MAX_N];
public:
  UnionFind();
  UnionFind(int);
  int find(int x);
  void unite(int, int);
  bool same(int, int);
  int size(int);
  int group(int);
};

//MAX_Nで初期化
UnionFind::UnionFind() {
  for(int i=0; i<MAX_N; ++i) {
    par[i] = i;
    rank[i] = 0;
    s[i] = 1;
  }
}

// 要素数nで初期化
UnionFind::UnionFind(int n) {
  for(int i=0; i<n; i++) {
    par[i] = i;
    rank[i] = 0;
    s[i] = 1;
  }
}

// 要素xの親を求める
int UnionFind::find(int x) {
  if(par[x] == x) return x;
  else return par[x] = find(par[x]);
}

// xとyの属する集合を併合
void UnionFind::unite(int x, int y) {
  // xとyの親
  x = find(x);
  y = find(y);
  if(x == y) return;

  // yのほうが深さが深い　xの親はyの親
  if(rank[x] < rank[y]) {
    par[x] = y;
    s[y] = s[x] + s[y];
  }
  else {
    par[y] = x;
    s[x] = s[x] + s[y];
    if( rank[x] == rank[y] ) rank[x]++;
  }
}

// xの属する連結成分のサイズ
int UnionFind::size(int x) { return s[find(x)];}

// xとyが同じ集合に属するか
bool UnionFind::same(int x, int y) { return find(x) == find(y);}

// 連結成分数
int UnionFind::group(int n) {
  REP(i, n) used[find(i)] = true;
  int ret = 0;
  REP(i, n) if(used[i]) ret++;
  return ret;
}

UnionFind uf;

int l[100010], r[100010], a[100010], b[100010], su[100010];
signed main(void)
{
  string s;
  cin >> s;
  int n;
  cin >> n;
  REP(i, n) cin >> l[i] >> r[i];

  REP(i, s.size()) a[i+1] = s[i]-'a';
  a[s.size()+1] = 0;
  REP(i, s.size()+1) b[i] = a[i+1] - a[i];

  REP(i, n) uf.unite(l[i]-1, r[i]);
  REP(i, (s.size()+1)/2) uf.unite(i, s.size()-i);

  REP(i, s.size()+1) {
    su[uf.find(i)] += b[i];
  }

  REP(i, s.size()+1) {
    if(su[uf.find(i)]%26 != 0) {
      cout << "NO" << endl;
      return 0;
    }
  }

  cout << "YES" << endl;

  return 0;
}


Measured memory_bytes: 9088
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

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

	int N, M, C;
	
	cin >> N >> M >> C;
	int B[M];

	int A[N][M];

	rep(i, M)
	{
		cin >> B[i];
	}

	int count = 0;

	rep(i, N)
	{
		int sum = 0;
		rep(j, M)
		{
			cin >> A[i][j];
			sum += A[i][j] * B[j];
		}
		sum += C;
		if (sum > 0)
		{
			count++;
		}
	}

	cout << count << endl;
	
	return 0;
}


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

int n;
vector<int> vp[200001];
int d[200001];
int mx;
void dfs(int s,int par,int dt){
    d[s]=dt;
    if(d[mx]<d[s]) mx=s;
    rep(i,vp[s].size()){
        if(vp[s][i]!=par){
            dfs(vp[s][i],s,dt+1);
        }
    }
}
int main(){
    int ai,bi;
    cin>>n;
    rep(i,n-1){
        cin>>ai>>bi;
        --ai;--bi;
        vp[ai].pb(bi);
        vp[bi].pb(ai);
    }
    dfs(0,-1,0);
    memset(d,0,sizeof(d));
    dfs(mx,-1,0);
    cerr<<d[mx]<<endl;
    if(d[mx]%3==1){
        cout<<"Second"<<endl;
    }
    else{
        cout<<"First"<<endl;
    }
    return 0;
}


Measured memory_bytes: 24448
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i= (a); i < (b); ++i)
typedef long long ll;
typedef pair<int,int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
struct Edge {
  ll to;
  ll cost;
};
int main() { string s, t;
  cin >> s >> t;
  cout << t << s << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


signed main()
{

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

#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif  

    int n;
    cin>>n;
    pair<int,int>p[n+1];
    int x,y;
    for(int i=1;i<=n;i++)
    {
        cin>>x>>y;
        p[i].first=x-y;
        p[i].second=x+y;     
    }
    sort(p+1,p+n+1);
    int ans=0;
    int prev=-1e10;
    for(int i=1;i<=n;i++)
    {
        if(prev<=p[i].first)
        {
            ans++;
            prev=p[i].second;
        }
        else
        {
            prev=min(prev,p[i].second);
        }        
    }
    cout<<ans;

} 



Measured memory_bytes: 1792
//#define _USE_MATH_DEFINES
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
#pragma GCC diagnostic ignored "-Wmissing-declarations"
#define FINAL_OUT(x) {cout << (x) << '\n'; exit(0); }
//inline int safe_mul(const int x, const int y) __attribute__ ((warn_unused_result));


int main()
{
//    freopen("in.txt","r", stdin);
//    freopen("out.txt", "w", stdout);
//    cout << fixed << setprecision(20);
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int n,k;
    cin >> n >> k;

    if (k > (n-1) * (n - 2) / 2)
        FINAL_OUT(-1);

    vector<pair<int,int>> a;
    for (int i = 2; i <= n; ++i)
        a.emplace_back(1, i);

    int d = (n - 1) * (n - 2) / 2;
    if (d < k)
        FINAL_OUT(-1);

    for (int i = 2; d > k && i <= n; ++i)
        for (int j = i + 1; d > k && j <= n; ++j) {
            --d;
            a.emplace_back(i, j);
        }

    cout << a.size() << endl;
    for (const auto& pa : a)
        cout << pa.first << ' ' << pa.second << '\n';
}


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

#define int long long

int n, m;
ll a[101010], as[101010];
ll res = 0;

bool check(ll mid)
{
    ll cnt = 0, sum = 0;
    rep(i, n)
    {
        auto lb = lower_bound(a, a + n, mid - a[i]);
        int num = (int)(lb - a);
        cnt += n - num;
        sum += as[n] - as[num] + (n - num) * a[i];
        //cerr << sum << " ";
    }
    sum -= (cnt - m) * mid;

    if(cnt >= m)
    {
        res = sum;
        return true;
    }
    else{
        return false;
    }
}

signed main()
{
    cin >> n >> m;
    rep(i, n) cin >> a[i];
    sort(a, a + n);
    rep(i, n) as[i + 1] = a[i] + as[i];

    long long ok = 0;
    long long ng = 10000000001;
    
    while(abs(ok - ng) > 1)
    {
        long long mid = (ok + ng) / 2;
        if(check(mid))
        {
            ok = mid;
        }
        else
        {
            ng = mid;
        }
    }

    cout << res << endl;

    //return 0;
}

Measured memory_bytes: 1792
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime,random
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())

N,K = inpl()
aa = inpl()
NotLooking = list(itertools.combinations(range(1,N),N-K))

ans = INF
for NL in NotLooking:
    h = aa[0]
    tmp = 0
    for i in range(1,N):
        if i in NL:
            h = max(h,aa[i])
            continue
        else:
            if h < aa[i]:
                h = aa[i]
            else:
                tmp += h+1 - aa[i]
                h = h+1
    ans = min(tmp,ans)

print(ans)


Measured memory_bytes: 4968
#include <cstdio>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>

using namespace std;
typedef long long ll;

int main() {
    int m,d,ans;
    ans = 0;
    scanf("%d %d",&m,&d);
    for (int i = 1; i <= m; i++) {
        for (int j = 11; j <= d; j++) {
            int d1 = j / 10;
            int d2 = j - d1 * 10;
            if (d1 > 1 && d2 > 1 && d1 * d2 == i) {
                ans++;
            }
        }
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
int main(){
    int H;
    int W;
    cin >> H;
    cin >> W;
    vector<string> word(H);
    for (int j=0; j<H;j++){
        cin >> word.at(j);
    }
    for (int i=0;i<W+2;i++){
        cout << "#";
    }
    cout << endl;
    for (int i=0;i<H;i++){
        cout << "#";
        cout << word.at(i) ;
        
        cout << "#";
        cout << endl;
    }
    for (int i=0;i<W+2;i++){
        cout << "#";
    }
    return 0;
}

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

int main(){
  int N;
  std::cin >> N;
  int p=0, w=0, g=0, y=0;
  for(int i = 0; i < N; i++){
    std::string temp;
    std::cin >> temp;
    if(temp == "P" && p == 0) p++;
    else if(temp == "W" && w == 0) w++;
    else if(temp == "G" && g == 0) g++;
    else if(temp == "Y" && y == 0) y++;
  }
  int ans = p + w + g + y;
  if(ans == 3) std::cout << "Three" << std::endl;
  else std::cout << "Four" << std::endl;
}

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

int BEKI(int b, int p){
    int beki = 1;
    for (int i = 0; i < p; ++i) {
        beki *= b;
    }
    return beki;
}
int main() {
    int n; cin >> n;

    int ans = 1;

    for (int i = 1; i <= n; ++i) {
        for (int j = 2; j <= 9; ++j) {
            if(BEKI(i,j) <= n){
                ans = max(ans, BEKI(i,j));
            }
        }
    }
    print(ans);
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

using namespace std;
const int Max_N(105);

int N, Cnt[Max_N];

int main()
{
	scanf("%d", &N);
	for (int i = 1, a;i <= N;++i)
		scanf("%d", &a), ++Cnt[a], Cnt[0] = max(Cnt[0], a);
	if ((Cnt[0] & 1) == 0)
	{
		for (int i = 0;i <= Cnt[0] / 2 - 1;++i)
			if (Cnt[Cnt[0] - i] < 2)
			{
				puts("Impossible");
				return 0;
			}
		if (Cnt[Cnt[0] - Cnt[0] / 2] != 1)
		{
			puts("Impossible");
			return 0;
		}
		for (int i = Cnt[0] / 2 + 1;i <= Cnt[0] - 1;++i)
			if (Cnt[Cnt[0] - i])
			{
				puts("Impossible");
				return 0;
			}
	}
	else
	{
		for (int i = 0;i <= Cnt[0] / 2 - 1;++i)
			if (Cnt[Cnt[0] - i] < 2)
			{
				puts("Impossible");
				return 0;
			}
		if (Cnt[Cnt[0] - Cnt[0] / 2] != 2)
		{
			puts("Impossible");
			return 0;
		}
		for (int i = Cnt[0] / 2 + 1;i <= Cnt[0] - 1;++i)
			if (Cnt[Cnt[0] - i])
			{
				puts("Impossible");
				return 0;
			}
	}
	puts("Possible");
	return 0;
}

Measured memory_bytes: 128
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
from fractions import gcd
from functools import lru_cache

#############
# Constants #
#############

MOD = 10**9 +7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#############
# Main Code #
#############

A,B,K = inputIL()

if A>=K:
  print(A-K,B)
elif A+B>=K:
  print(0,A+B-K)
else:
  print(0,0)

Measured memory_bytes: 66156
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vchar = vector<char>;
using vvchar = vector<vchar>;
using vp = vector<P>;
using vpp = vector<pair<P, P>>;
using vvp = vector<vp>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
istream &operator>>(istream &is, P &a)
{
    return is >> a.first >> a.second;
}
ostream &operator<<(ostream &os, const P &a) { return os << "(" << a.first << "," << a.second << ")"; }

template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

int main()
{
    int n;
    cin >> n;
    ll keta = 0;
    ll sum = 0;
    rep(i, n)
    {
        ll a, b;
        cin >> a >> b;
        sum += a * b;
        keta += b;
    }
    ll total = (sum - 1) / 9;

    ll ans = keta - 1 + total;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int i ,j ; 
  int n= 0 ;
  scanf("%d",&n);
  int min  = 1000000;
  int small = 0 ;
  int big = n; 
  int half = n/2;
  int sums[half ];
  int sum;
  for(i = 1 ; i <= half+1 ; i++){
    int a = i ;
    int b = n - i ;
    int ad = checkDigit(a);
    int bd = checkDigit(b);
    int bn,an;
    int bdig0,adig0;
    while(bd > 0 ){
      bdig0 = expo(10 ,bd - 1);
      if(bd > 1 )
        bn =  b/bdig0;
      else
        bn = b ;
      sum+= bn;
      b = b - bn*bdig0;
      bd--;
    }

    while(ad > 0 ){
      adig0 = expo(10 ,ad - 1);
      if(ad > 1 )
        an =  a/adig0;
      else
        an = a;
      sum+= an;
      a = a - an*adig0;
      ad--;
    }
    sums[i] = sum ; 
    sum = 0 ;
  }
  for (i = 1 ; i<half+1 ; i++) if(min > sums[i]) min = sums[i] ;
  printf("%d",min);
  return 0 ;
}
int expo(int num ,int n ){
  int i ; 
  int nf = num;
  for (i = 1; i < n ; i++) 
    num = num * nf ; 
  return num; 
}
//調べたい　数と　最大の数　桁数5なら10000
//桁数を返す
int checkDigit(int n ){
  int digit = 0 ;
  if(n == 0 ) digit = 1;
  while(n > 0 ){
    n = n / 10 ;
    digit++;
  }
  return digit;
}


Measured memory_bytes: 384
// D.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>
#include <cmath>

using namespace std;

typedef long double LD;

int main(int argc, char* argv[]) {
	cout.precision(10);
	while (true) {
		LD a = -1, b = -1, x = -1, ans;
		cin >> a >> b >> x;
		if (a <= 0 || b <= 0 || x <= 0) break;
		LD f = a * a * b, h = f * 0.5;
		if (x >= f) {
			ans = 0;
		} else if (x >= h) {
			LD r = f - x, v = r / (a * a) * 2;
			ans = 90 - atan2(a, v) / (2 * M_PI) * 360;
		} else {
			LD v = x / (a * b) * 2;
			ans = atan2(b, v) / (2 * M_PI) * 360;
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<stdio.h>
#include<time.h>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<deque>
#include<set>
#include<map>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define FOR(i, a, b) for(ll i = a; i < b; ++i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int qx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
int qy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

int main(void) {
	vector<bool> p(1000001, true);
	p[0] = p[1] = false;
	FOR(i, 2, 1000001) {
		if(p[i]) {
			for(ll j = 2; i * j <= 1000000; ++j) {
				p[i * j] = false;
			}
		}
	}
	while(true) {
		ll a, d, n;
		cin>>a>>d>>n;
		if(a == 0 && d == 0 && n == 0) break;
		ll cnt = 0;
		while(true) {
			if(p[a]) {
				++cnt;
				if(cnt == n) {
					cout<<a<<endl;
					break;
				}
			}
			a += d;
		}
	}
}

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

#define cc(x) cout << (x) << endl
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define repi(i,a,b) for(int i = int(a); i < int(b); ++i)
typedef long long ll;

template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }

const ll inf = 1LL<<58;
const int iinf = 1<<30;
int keta[100][2];

int main(){
    int d, g;
    cin >> d >> g;
    int p[d], c[d];
    rep(i,d){
        cin >> p[i] >> c[i];
    }
    int num=iinf;
    rep(i,pow(2, d)){
        int toitakazu=0;
        int tokuten=0;
        int maxpid=-1;
        rep(j,d){
            if(i&(1<<j)){
                toitakazu+=p[j];
                tokuten+=100*(j+1)*p[j]+c[j];
            }else{
                maxpid=j;
            }
        }

        rep(j,p[maxpid]+1){
            if(tokuten>=g){
                amin(num, toitakazu);
                // cc(i);
                // cc(j);
                // cc(maxpid);
                // cc(toitakazu);
                // cc(tokuten);
                // cc("");
                break;
            }else{
                toitakazu++;
                tokuten+=100*(maxpid+1);
            }
        }
    }
    cc(num);
}

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

int main()
{
    char a,b,c,d;
    cin>>a>>b>>c>>d;
    int n = (int)(b-'0');
    n+= 10 *(int)(a-'0');
     int m = (int)(d-'0');
    m+= 10 *(int)(c-'0');
  //  cout<<n<<" "<<m<<endl;
  if(1<=n&&n<=12&&1<=m&&m<=12)
  {
      cout<<"AMBIGUOUS"<<endl;
  }
  else if(1<=n&&n<=12)
  {
      cout<<"MMYY"<<endl;
  }
  else if(1<=m&&m<=12)
  {
       cout<<"YYMM"<<endl;
  }
  else
  {
      cout<<"NA"<<endl;
  }
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		int n=in.nextInt();
		long[][] dp=new long[n+1][n+1];
		int[][] s=new int[n+1][n+1];
		long[] a=new long[n+1];
		for (int i=1;i<=n;++i)
			for (int j=i;j<=n;++j)
				dp[i][j]=Long.MAX_VALUE;
		for (int i=1;i<=n;++i) {
			a[i]=in.nextLong()+a[i-1];
			dp[i][i]=0;
			s[i][i]=i;
		}
		for (int l=1;l<n;++l)
			for (int i=1;i+l<=n;++i) {
				int j=i+l;
				for (int k=Math.max(i,s[i][j-1]);k<=Math.min(j-1,s[i+1][j]);++k)
					if (dp[i][j]>dp[i][k]+dp[k+1][j]+a[j]-a[i-1]) {
						s[i][j]=k;
						dp[i][j]=dp[i][k]+dp[k+1][j]+a[j]-a[i-1];
					}
				}
		System.out.println(dp[1][n]);
	}
}

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

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

using namespace std;

int gcd(int a,int b){ return b?gcd(b,a%b):a; }

int main(){
	int n,X; scanf("%d%d",&n,&X);
	int ans=0;
	rep(i,n){
		int x; scanf("%d",&x);
		ans=gcd(ans,abs(x-X));
	}
	printf("%d\n",ans);

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define ll long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
ll int gcd (ll int a,ll int b) { return b ? gcd (b, a % b) : a; }

int main()
{
	ll int n,c;
	cin>>n>>c;
	ll int w[n],v[n];
	for (int i = 0; i < n; ++i)
	{
		cin>>w[i]>>v[i];
	}
	ll int dp[n+1][c+1];
	for (int i = 0; i <= n; ++i)
	{
		for(int j=0;j<=c;j++)
		{
			if(i==0 || j==0)
				dp[i][j]=0;
		}
	}
	for (int i = 1; i <= n; ++i)
	{
		for (int j = 1; j <=c ; ++j)
		{
			if(w[i-1]>j)
				dp[i][j]=dp[i-1][j];
			else
				dp[i][j]=max(dp[i-1][j],v[i-1]+dp[i-1][j-w[i-1]]);

			//cout<<dp[i-1][j]<<"\n";
			//cout<<dp[i][j]<<" ";
		}
		//cout<<"\n";
	}
	cout<<dp[n][c]<<"\n";
}


Measured memory_bytes: 82288
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

ll binomialCoeff(ll n, ll k) 
{ 
    ll C[k+1]; 
    memset(C, 0, sizeof(C)); 
  
    C[0] = 1;  // nC0 is 1 
  
    for (ll i = 1; i <= n; i++) 
    { 
        // Compute next row of pascal triangle using 
        // the previous row 
        for (ll j = min(i, k); j > 0; j--) 
            C[j] = C[j] + C[j-1]; 
    } 
    return C[k]; 
} 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    int n=s.length();
    int test=0;
    for(int i=n-2;i>=0;i-=2)
    {
        bool f=1;
        for(int j=0;j<i/2;j++)
            if(s[j]!=s[j+i/2])
            {
                f=0;
                break;
            }
        if(f)
        {
            test=i;
            break;
        }
    }

    cout<<test<<endl;
    
    
    return 0;   
}




 
 


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod107 1000000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
#define grepq priority_queue<double, std::vector<double>, std::greater<double>>
#define all(v) v.begin(), v.end()
#define PI acos(-1)

const ll INF = 10010001010;
const int inf = 1000034000;
typedef vector<ll> vecl;
typedef vector<int> veci;
typedef tuple<string, int, int> TUP;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
 
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //cout << fixed << setprecision(15);
    int N;
    cin >> N;
    vector<string> S(N);
    string ans;
    for (int i = 0; i < N; i++)
    {
        cin >> S[i];
    }
    for (char c = 'a'; c <= 'z';c++)
    {
        int M = 50000;
        for (int i = 0; i < N; i++)
        {

            int count = 0;
            for (int j = 0; j < S[i].size();j++)
            {
                if(c == S[i][j]){
                    count++;
                }
            }
            M = min(M,count);
        }
       // cout << M << endl;
        for (int i = 0; i < M; i++)
        {
            ans += c;
            
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3564
import sys

n = int(input())
minv = int(input())
maxv = -1000000000

for r in map(int,sys.stdin.readlines()):
  if maxv < r-minv < 0:
    maxv = r-minv
    minv = r
  elif maxv < r-minv:
    maxv = r-minv
  elif r-minv < 0:
    minv = r

print(maxv)

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

int main()
{
  int n, t;
  cin >> n;
  vector<pair<int, int>> A;
  for (int i = 0; i < n; i++)
  {
    cin >> t;
    A.push_back(make_pair(t, i + 1));
  }
  sort(A.begin(), A.end());

  for (int i = 0; i < n; i++)
    cout << A[i].second << endl;
}

Measured memory_bytes: 1780
#include<bits/stdc++.h>
//cervello|Phoenix
using namespace std;
#define ll long long int
#define eb emplace_back
#define mk make_pair
#define all(x) x.begin(),x.end()
#define mod 1000000007

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  ll n; cin>>n;
  for(int i=1;i<=1e5;i++){
    if((360*i)%n==0)
      return cout<<((360*i)/n)<<"\n", 0;
  }
  // ll ans=(360)/n;
  // cout<<ans<<"\n";
  return 0;
}

Measured memory_bytes: 3648
/*
START BY THE NAME OF ALMIGHTY ALLAH
THIS WONT BE ACCEPTED
STOP_GIVING_UP

██╗███████╗████████╗██╗ █████╗ ██╗  ██╗
██║██╔════╝╚══██╔══╝██║██╔══██╗██║ ██╔╝
██║███████╗   ██║   ██║███████║█████╔╝
██║╚════██║   ██║   ██║██╔══██║██╔═██╗
██║███████║   ██║   ██║██║  ██║██║  ██╗
╚═╝╚══════╝   ╚═╝   ╚═╝╚═╝  ╚═╝╚═╝  ╚═╝




*/
#include<bits/stdc++.h>
#define l(i,a,n)for(int i=a;i<n;i++)
#define pb push_back
#define in insert
#define mp make_pair
#define lw(v) sort(v.begin(),v.end());
#define hi(v) sort(v.begin(),v.end(),greater<long long>());
#define all(v) v.begin(),v.end()
#define filein freopen ("input.txt", "r", stdin)
#define fileout freopen ("output.txt", "w", stdout)
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    long long t,r=1,r1=0,r2=0,k=0,a,b,c=1,m,d=0,n,e,f=0,x=0,g,p=0,q=0,y=0,z=0;
double kk=0;
    vector<pair<long long,long long>>v;
    vector<long long>u;
    map<string,long long>s;
    std::vector<int>::iterator it;
    string  s1,s2,s3,s4,s5,s6;
   cin>>n>>m>>k;
   d=n-m;
   d=k-d;
 d=max(z,d);
 cout<<d<<endl;



}






Measured memory_bytes: 3644
//BISMILLAH
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define lli long long int
#define ve vector<int>
#define FOR(n)          for(int i=0; i<(int)(n); ++i)
#define TEST_CASE(t)    for(int z=1;z<=t;z++)
#define PRINT_CASE      printf("Case %d: ",z)
#define pb push_back
#define mod 1000000007
int arr[1000000];
int main()
{
  int n,flag,cnt=1,temp=0;
  scanf("%d",&n);
  n=n-1;
  int a,b;
  scanf("%d %d",&a,&b);
  while(n--)
  {
      int x,y;
      scanf("%d %d",&x,&y);
      if(a==b && x==y)
      {
          ++cnt;
         // cout<<"count"<<cnt<<endl;
          if(cnt==3)
          {
              temp=1;
              break;
          }
      }
      else cnt=1;

      a=x,b=y;


  }
  if(temp) printf("Yes\n");
  else printf("No\n");

}

Measured memory_bytes: 3760