akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
//const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) {cout << (A) << '\n'; exit(0);}

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

  const vector<vector<string>> S =
  {
    {
      "aabc",
      "ddbc",
      "efgg",
      "efhh"
    },
    {
      "abbcc",
      "a.dde",
      "fg..e",
      "fg..h",
      "iijjh"
    },
    {
      "aabbcc",
      "d.e.f.",
      "d.e.f.",
      ".g.h.i",
      ".g.h.i",
      "jjkkll"
    },
    {
      "abcc...",
      "ab..d..",
      "ee..dff",
      "..ghh.i",
      "..g.jji",
      "kl...mm",
      "klnn..."
    }
  };

  if (N == 2)
    cout << -1 << endl;
  else if (N == 3)
  {
    cout << "aa." << endl;
    cout << "..b" << endl;
    cout << "..b" << endl;
  }
  else
  {
    vector<string> ans(N, string(N, '.'));
    for (ll i = 0; i < N - 7; i += 4)
    {
      for (ll j = 0; j < 4; j++)
      {
        for (ll k = 0; k < 4; k++)
        {
          ans.at(i + j).at(i + k) = S.at(0).at(j).at(k);
        }
      }
    }
    for (ll i = N - (4 + N % 4); i < N; i++)
    {
      for (ll j = N - (4 + N % 4); j < N; j++)
      {
        ans.at(i).at(j) = S.at(N % 4).at(i - (N - (4 + N % 4))).at(j - (N - (4 + N % 4)));
      }
    }

    for (ll i = 0; i < N; i++)
    {
      cout << ans.at(i) << endl;
    }
  }
}

Measured memory_bytes: 2304
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	int A, B, T;
	cin >> A >> B >> T;
	cout << T / A * B << endl;
}

Measured memory_bytes: 256
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


def main():
    N,M = map(int, input().split()) 
    uf = UnionFind(N)
    for _ in range(M):
        x, y, z = map(int, input().split()) 
        uf.union(x-1,y-1)

    print(uf.group_count())


if __name__ == "__main__":
    main()

Measured memory_bytes: 7860
/*
	?§£????????????:A Point in a Triangle
	(http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0012&lang=jp)

	-status:AC

	-comment:
        ?¬????????????¢???????????????????????§????????¨?????£??????
        ?????????????¬????????????¢?????????????????????????????????????????§????????????????????????????????????????????????????????????????????¨???????????????
*/
var log = console.log;
if (typeof process != "undefined") {
    var input = "";
    process.stdin.resume();
    process.stdin.setEncoding('utf8');
    process.stdin.on('data', function(chunk) {
        input += chunk;
    });
    process.stdin.on('end', function() {
        var lines = input.split("\n");
        main(lines);
    });
}


function main(lines) {
    lines = lines.map(function(line) {
        return line.split(",").filter(function(e) {
            return e != "";
        }).map(function(e) {
            var n = Number(e);
            if (n.toString() == "NaN") {
                return e.replace(/(\r)|(\n)/g, "");
            }
            return n;
        });
    });
    var last = lines.pop();
    if (last.length == 6) {
        lines.push(last);
    }
    while (lines.length > 0) {
        var dataset = lines.shift();
        p_set(dataset);
    }
}

function p_set(ps) {
    var P1 = [ps[0], ps[1]];
    var P2 = [ps[2], ps[3]];
    var Q = [ps[4], ps[5]];
    var P1_P2 = v_a(P2, v_m(P1, -1));
    var P1_Q = v_a(Q, v_m(P1, -1));
    //??£?°???±????±???????
    var length = cross(P1_Q, P1_P2) / cross(P1_P2, P1_P2);
    var P1_Qd = v_m(P1_P2, length);
    var Q_Qd = v_a(v_m(P1_Q, -1), P1_Qd);
    var Q_R = v_m(Q_Qd, 2);
    var R = v_a(Q, Q_R);
    log(R.join(" "));
}

function sign_s_main(pa, pb) {
    //?????????2??§????????????
    return (pa[0] * pb[1] - pa[1] * pb[0]);
}

function cross(va, vb) {
    return va[0] * vb[0] + va[1] * vb[1];
}

function v_m(v, s) {
    return [v[0] * s, v[1] * s];
}

function v_a(v1, v2) {
    return [v1[0] + v2[0], v1[1] + v2[1]];
}

Measured memory_bytes: 15892
import bisect
n=int(input())
s=list(input())
a={chr(i):[] for i in range(97,123)}
for i,c in enumerate(s):
    bisect.insort(a[c],i+1)
for i in range(int(input())):
    p,q,r=list(map(str,input().split()))
    if p=="1":
        q=int(q)
        b=s[q-1]
        if b!=r:
            a[b].pop(bisect.bisect_left(a[b],q))
            bisect.insort(a[r],q)
            s[q-1]=r
    else:
        d=0
        for l in a.values():
            g=bisect.bisect_left(l,int(q))
            if g<len(l) and l[g]<=int(r):
                d+=1
        print(d)

Measured memory_bytes: 28808
N, K = map(int, input().split())
A = list(map(int, input().split()))
ACC = []
ACC.append(0)
sum = 0
for a in A:
    sum += a
    ACC.append(sum)


L = N-K+1
prev = ACC[K] - ACC[0]
for i in range(1, L):
    score = ACC[i+K] - ACC[i] 
    if prev < score:
        print("Yes")
    else:
        print("No")
    prev = score

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

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

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SP << " " <<

LL mod = 1000000007;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  LL N;
  cin >> N;
  vector<LL> A(N);
  REP(i,N){
    cin >> A[i];
  }

  bool flag = true;
  REP(i, N)
  {
    if(A[i]!=0){
      flag = false;
      break;
    }
  }
  
  if(flag){
    cout << "Yes" << endl;
  }else{

    if(N%3==0){
      map<LL, LL> mp;
      REP(i,N){
        mp[A[i]]++;
      }
      if(mp.size()>=4){
        cout << "No" << endl;
      }else
      if(mp.size()==3){
        LL x = 0;
        vector<LL> s;
        for (auto itr = mp.begin(); itr != mp.end(); ++itr)
        {
          x ^= itr->first;
          s.push_back(itr->second);
        }
        if(x==0&&s[0]==s[1]&&s[1]==s[2]){
          cout << "Yes" << endl;
        }else{
          cout << "No" << endl;
        }        
      }else
      if(mp.size()==2){
        vector<pii> s;
        for (auto itr = mp.begin(); itr != mp.end(); ++itr)
        {
          s.push_back({itr->first,itr->second});
        }
        if(s[0].first==0){
          if(s[0].second*2==s[1].second){
            cout << "Yes" << endl;
          }else{
          cout << "No" << endl;
          }
        }else
        if(s[1].first==0){
          if(s[1].second*2==s[0].second){
            cout << "Yes" << endl;
          }else{
          cout << "No" << endl;
          }
        }else{
        cout << "No" << endl;
        }
      }else{
        cout << "No" << endl;
      }
    }
    else
    {
      cout << "No" << endl;
    }
  }
}


Measured memory_bytes: 5760
#include<cstdio>
const static int MAX_N = 12;
const static int MAX_M = 12;
int A[MAX_N][MAX_M];

int main(){
	int N, M, X;
	scanf("%d %d %d", &N, &M, &X);
	int C[N];
	for (int i = 0; i < N; ++i){
		scanf("%d", C + i);
		for (int j = 0; j < M; ++j){
			scanf("%d", &A[i][j]);
		}
	}
	int ans = 1200001;
	for (unsigned i = 0; i < 1 << N; ++i){
		bool flag = true;
		for (int j = 0; j < M; ++j){
			int understand = 0;
			for (int k = 0; k < N; ++k){
				if((i >> k) & 1) understand += A[k][j];
			}
			if(understand < X){
				flag = false;
				break;
			}
		}
		if(flag){
			int cost = 0;
			for (int j = 0; j < N; ++j){
				if((i >> j) & 1) cost += C[j];
			}
			if(cost < ans) ans = cost;
		}
	}
	printf("%d\n", ans < 1200001 ? ans : -1);
	return 0;
}

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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;

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

ll ngcd(vector<ll> a) {
  ll res = a[0];
  for(ll i=1; i<a.size() && res!=1; i++) res = gcd(a[i], res);
  return res;
}
ll nlcm(vector<ll> a){
  ll res = a[0];
  for(ll i=1; i<a.size(); i++) res = lcm(a[i], res);
  return res;
}
bool is_prime(ll n) {
  if(n < 2) return false;
  for (ll i = 2; i * i <= n; i++) if (n % i == 0) return false;
  return true;
}
ll digsum(ll n) {
  ll res=0;
  while(n) res += n%10, n /= 10;
  return res;
}
ll digcnt(ll n){
  ll res=0;
  while(n) res++, n /= 10;
  return res;
}
vector<ll> divisor(ll n) {
  vector<ll> res;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      res.push_back(i);
      if (i != n / i) res.push_back(n / i);
    }
  }
  return res;
}

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    (a *= a) %= mod;
    n >>= 1;
  }
  return res;
}

const ll maxf = 10000000;
ll fact[maxf+5];

void fact_init(ll n, ll mod){
  fact[0] = 1;
  for(ll i=1; i<=n; i++){
    fact[i] = (fact[i-1] * i) % mod;
  }
}

ll comb(ll a, ll b, ll mod){
  if(a<b || a<0 || b<0) return 0;
  if(fact[0] == 0) fact_init(maxf, mod);
  return (fact[a] * modpow((fact[a-b]*fact[b])%mod, mod-2, mod)) % mod;
}

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n; cin>>n;
  vll a(n);
  rep(i,n) cin>>a[i];
  vll l(n+1);
  vll r(n+1);
  rep(i,n) l[i+1]=gcd(l[i],a[i]);
  rrep(i,n) r[i]=gcd(r[i+1],a[i]);
  ll ans=1;
  rep(i,n){
    chmax(ans,gcd(l[i],r[i+1]));
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define debug(a) cerr << #a << ": " << a << endl
#define sz(a) int(a.size())
#define rep(i,n) for(int i=0;i<n;i++)
#define forr(i, st, en) for(int i = st; i <= en; i++)
#define all(v) (v).begin(),(v).end()
#define X first
#define Y second
#define pb push_back
#define fast cin.tie(0); ios::sync_with_stdio(false)
#define vi vector<int>
#define vii vector<vector<int>>

int32_t main(){ fast;
	int n; cin>>n;
	vector<int> a(n);
	vector<long long> b(n + 1, 0);
	const int mod = 1e9 + 7;
	rep(i, n){
		cin>>a[i];
		b[i + 1] = b[i] + a[i];
	}
	ll answer = 0;
	rep(i, n){
		long long sum = (b[n] - b[i + 1]) % mod;
		answer = (answer + a[i] * sum) % mod;
	}
	cout<<answer<<endl;
}


Measured memory_bytes: 5572
#include "bits/stdc++.h"
#define int long long
#define endl '\n'
using namespace std;
 
typedef long long ll;
#define db(x) cerr << #x << ": " << x << '\n';
#define read(a) int a; cin >> a;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define readarr(a, n) int a[(n) + 1] = {}; FOR(i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}

#define print(a) cout << a << endl;
#define printarr(a, n) FOR (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) FOR (i, 1, n) {FOR (j, 1, m) cout << a[i][j] << " "; cout << endl;} cout << endl;
#define all(v) v.begin(), v.end()
#define sz(v) (int)(v.size())
#define rz(v, n) v.resize((n) + 1);
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define vpi vector <pi>
#define vvi vector <vi>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ll N = 2e5 + 1;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int dp[N][61];
 
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	readb(n, k);
	readarr(a, n);
	FOR (i, 1, n) dp[i][0] = a[i];
	
	FOR (j, 1, 60)
        FOR (i, 1, n)
            dp[i][j] = dp[dp[i][j - 1]][j - 1];
    
    int ans = 1;
    FORD (i, 60, 0)
    {
        if ((1LL << i) <= k)
            ans = dp[ans][i], k -= (1LL << i);
    }
    
    print(ans);
}



















Measured memory_bytes: 100492
from decimal import Decimal

A, B = input().split()

A = int(A)
if len(B) == 1:
    B = int(B[0] + '00')
elif len(B) == 3:
    B = int(B[0] + B[2] + '0')
else:
    B = int(B[0]+B[2]+B[3])

x = str(A*B)

print(x[:-2] if len(x) > 2 else 0)


Measured memory_bytes: 9920
@line = split(/ /, <STDIN>);

$N = $line[0];
$A = $line[1];
$B = $line[2];

if ($A < $B) {
        $Ans1 = $A;
} else {
        $Ans1 = $B;
}

if ($N > $A + $B) {
        $Ans2 = 0;
} else {
        $Ans2 = ($A + $B) - $N;
}


print "$Ans1 $Ans2\n";


Measured memory_bytes: 512
while 1:
    x, y = map(int,raw_input().split())
    if x == 0 and y == 0:
        break
    l = [0] * x
    z = 0
    bowl = y
    while 1:
        if bowl > 0:
            l[z] += 1
            bowl -= 1
            if l[z] == y:
                break
        else:
            bowl += l[z]
            l[z] = 0
        z = (z + 1) % x
    print z

Measured memory_bytes: 6404
#include <bits/stdc++.h>
#define mk make_pair
using namespace std;
typedef long long ll;
const int N = 2e5 + 5;
const int mod = 1e9 + 7;
int n, a[N], b[N];
int main() {
	for (int i = 0; i < 4; ++i) cin >> a[i];
	for (int i = 0; i < 4; ++i) b[i] = i;
	do {
		if (a[b[0]] == 1 && a[b[1]] == 9 && a[b[2]] == 7 && a[b[3]] == 4) {
			puts("YES");
			return 0;
		}
	} while (next_permutation(b, b + 4));
	puts("NO");
}

Measured memory_bytes: 256
h, w = list(map(int, (input().split(" "))))

field = []
for i in range(h):
    field.append(input())
flag = "Yes"

for i in range(h):
    for j in range(w):
        if field[i][j] is "#":
            if i != 0 and field[i-1][j] is "#": continue
            elif i != h-1 and field[i+1][j] is "#": continue
            elif j != 0 and field[i][j-1] is "#": continue
            elif j != w-1 and field[i][j+1] is "#": continue
            else: flag = "No"
print(flag)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define sc(n) scanf("%d",&n)
#define scl(n) scanf("%lld",&n)
#define pr(n) printf("%d",n)
#define prl(n) printf("%lld",n)
#define nl printf("\n")
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
ll pow1(ll a, ll b)
{
	ll ans=1;
	while(b)
	{
		if(b&1)
		{
			ans=ans*a;
		}
		a=a*a;
		b=b>>1;
	}
	return ans;
}
int main()
{
	int i,j,n;
	cin>>n;
	double x;
	string u;
	double ans = 0;
	for(i=0;i<n;i++)
	{
		cin>>x>>u;
		if(u == "BTC")
			x = x*380000.0;
		ans += x;
	}
	printf("%.8lf\n",ans);
}

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    int a, b;cin >> a >> b;
    string ans = "Yay!";
    if(a > 8 || b > 8) ans = ":(";
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <set>
#include <map>
#include <vector>
#include <iomanip>

using namespace std;
using ll = long long;

#define endl "\n"
#define pb push_back

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

	string s;
	string t;
	cin >> s >> t;
	bool ans = true;
	if(t.size() - s.size() != 1) {
		ans = false;
	}
	for(int i = 0; i < s.size(); i++) {
		if(s[i] != t[i]) {
			ans = false;
			break;
		}
	}
	if(ans) {
		cout << "Yes";
	} else {
		cout << "No";
	}
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
typedef long long int ll;


int main(){
  int a,b,c,d,e,f;
  double dp1[35],dp2[3050];
  double n=0;
  double ans1=0,ans2=0;
  cin>>a>>b>>c>>d>>e>>f;
  rep(i,35) dp1[i]=0;
  rep(i,3050) dp2[i]=0;
 	ans1=a*100;
  dp1[a]=dp1[b]=1;
  dp2[c]=dp2[d]=1;
  rep(i,(f+100)/100){
     if(dp1[i-a]==1 && i-a>0 && i*100<=f) dp1[i]=1;
     else if(dp1[i-b] && i-b>0 && i*100<=f) dp1[i]=1;
     //if(dp1[i]==1) cout<<i<<endl;
  }
  rep(i,f+1){
    if(dp2[i-c]==1 && i-c>0) dp2[i]=1;
    else if(dp2[i-d]==1 && i-d>0) dp2[i]=1;
    
  }
  rep(i,(f+100)/100){
    rep(j,f+1){
      if(dp1[i]==1 && dp2[j]==1){
	//	cout<<i<<" "<<j<<endl;
	if(i*100+j<=f && (double)(j*100)/((i*100)+j)>n && (i*e)>=j){
	  //cout<<i<<" "<<j<<endl;
	  n=(double)(j*100)/(i*100+j);
	  ans1=i*100;
	  ans2=j;
	}
      }
    }
  }
  cout<<ans1+ans2<<" "<<ans2<<endl;
  return 0;
}








Measured memory_bytes: 256
//NEVER GIVE UP I AM GOING TO IMPROVE ONE DAY.
//PRACTICE,PRACTICE,PRACTICE!!!
#include<bits/stdc++.h>
#define int long long int
// #define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define mem(a,b) memset(a,b,sizeof(a))
#define inf 1e18
#define endl "\n"
#define all(v) v.begin(),v.end()
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0); 
const int M=1000000000;
const double pi = acos(-1.0);
using namespace std;
// cout<<"Case #"<<test-t<<":"<<" "<<"N"<<endl;
int32_t main(){

    #ifndef ONLINE_JUDGE 
    freopen("in.txt", "r", stdin); 
    freopen("out.txt", "w", stdout); 
    #endif 

    fast;
    int t;
    t=1;
    // cin>>t;
    // int test=t;
    while(t--){
        int n;
        cin>>n;
        if(n>=400 && n<=599){
            cout<<8<<endl;
            continue;
        }
        if(n>=600 && n<=799){
            cout<<7<<endl;
            continue;
        }
        if(n>=800 && n<=999){
            cout<<6<<endl;
            continue;
        }
        if(n>=1000 && n<=1199){
            cout<<5<<endl;
            continue;
        }
        if(n>=1200 && n<=1399){
            cout<<4<<endl;
            continue;
        }
        if(n>=1400 && n<=1599){
            cout<<3<<endl;
            continue;
        }
        if(n>=1600 && n<=1799){
            cout<<2<<endl;
            continue;
        }
        if(n>=1800 && n<=1999){
            cout<<1<<endl;
            continue;
        }
    }
}

Measured memory_bytes: 3648
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    S, T = input().split()
    A, B = map(int, input().split())
    U = input()
    if S == U:
        print(A - 1, B)
    else:
        print(A, B - 1)


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define LEN 100005

typedef struct pp
{
    char name[100];
    int t;
}P;
P Q[LEN+1];
int head, tail, n;
int min_(int a,int b)
{
    if(a>b) return b;
    return a;
}
void enqueue(P x)
{
    Q[tail]=x;
    tail=(tail+1)%LEN;
}
P dequeue()
{
    P x=Q[head];
    head=(head+1)%LEN;
    return x;
}
int main()
{
    int elaps = 0, c;
    int i, q;
    P u;
    scanf("%d %d", &n, &q);
    for ( i = 1; i <= n; i++)
    {
        scanf("%s", Q[i].name);
        scanf("%d", &Q[i].t);
    }
    head=1;
    tail=n+1;
    while(head!=tail)
    {
        u=dequeue();
        c=min_(q,u.t);
        u.t-=c;
        elaps+=c;
        if(u.t>0) enqueue(u);
        else
        {
            printf("%s %d\n",u.name,elaps);
        }
    }
    return 0;
}

Measured memory_bytes: 13300
import java.util.*;

public class Main{
	public static void main(String[] args){
      Scanner scanner = new Scanner(System.in);
      
      int A = scanner.nextInt(); // 1 =< A,B =< 100
      int B = scanner.nextInt();
      int C = scanner.nextInt();  // nA = mB +C, 0 =< C < B
      
      int target = A;
      boolean exist = false;
      for(int counter=0; counter<B; counter++){
        if(target%B == C){
          exist = true;
          break;
        }
        target += A;
      }
      
      if(exist){
        System.out.println("YES");
      }
      else{
        System.out.println("NO");
      }
      
    }
}

Measured memory_bytes: 21972
#include <stdio.h>
#include <iostream>
#include <utility>
#include <algorithm>
#include <math.h>
#include <vector>
using namespace std;
typedef long long ll;

struct node
{
    int key;
    node *parent, *left, *right;
};

node *root = nullptr;
void insert(node *z)
{
    node *y = nullptr;
    node *x = root;
    while (x != nullptr)
    {
        y = x;
        if (z->key < x->key)
            x = x->left;
        else
            x = x->right;
    }
    z->parent = y;

    if (y == nullptr)
        root = z;
    else if (z->key < y->key)
        y->left = z;
    else
        y->right = z;
}

bool find(int k)
{
    node *x = root;
    while (x != nullptr)
    {
        if (x->key == k)
            return true;
        else if (x->key > k)
            x = x->left;
        else
            x = x->right;
    }
    return false;
}
void Preorder(node *x)
{
    printf(" %d", x->key);
    if (x->left != nullptr)
        Preorder(x->left);
    if (x->right != nullptr)
        Preorder(x->right);
}

void Inorder(node *x)
{
    if (x->left != nullptr)
        Inorder(x->left);
    printf(" %d", x->key);
    if (x->right != nullptr)
        Inorder(x->right);
}

int main()
{
    int m, k;
    string str;
    cin >> m;

    for (int i = 0; i < m; i++)
    {
        cin >> str;
        if (str[0] == 'i')
        {
            node *z = (node *)malloc(sizeof(node));
            cin >> z->key;
            z->left = nullptr;
            z->right = nullptr;
            z->parent = nullptr;
            insert(z);
        }
        else if(str[0] == 'f')
        {
            cin >> k;
            if(find(k))
                printf("yes\n");
            else
                printf("no\n");
        }
        else
        {
            Inorder(root);
            printf("\n");
            Preorder(root);
            printf("\n");
        }
    }
    return 0;
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
using std::cin;
using std::cout;
using std::endl;
using std::vector;

int main() {
  int N, C;
  vector<int> s(100000), t(100000), c(100000);
  vector<int> n_recoders(200002);
  vector<int> differential(200002);
  vector<int> accumulation(200002);
  cin >> N >> C;
  for (int pr = 0; pr < N; ++pr)  // Gets input.
    cin >> s[pr] >> t[pr] >> c[pr];
  for (int ch = 1; ch <= C; ++ch) {  // For each channel.
    fill(differential.begin(), differential.end(), 0);
    fill(accumulation.begin(), accumulation.end(), 0);
    for (int pr = 0; pr < N; ++pr) {  // For each program.
      if (c[pr] == ch) {
        ++differential[s[pr] * 2 - 1];
        --differential[t[pr] * 2];
      }
    }
    accumulation[0] = differential[0];
    for (int time = 1; time < 200002; ++time)
      accumulation[time] = accumulation[time - 1] + differential[time];
    for (int time = 0; time < 200002; ++time)
      if (accumulation[time] > 0) ++n_recoders[time];
  }
  cout << *max_element(n_recoders.begin(), n_recoders.end()) << endl;
}


Measured memory_bytes: 3712
def read_input():
    x = int(input())
    a = int(input())
    b = int(input())

    return x, a, b


def submit():
    x, a, b = read_input()

    t = x - a
    t -= (t // b) * b

    print(t)

if __name__ == '__main__':
    submit()


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

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

using namespace std;

int main() {
	int ans;
	string S;
	long long K;
	cin >> S;
	cin >> K;
	unsigned long long time = 5*pow(10,16);
	int num;
	rep(i, 0, S.size()) {
		num = S[i] - '0';
		if (K <= pow(num,time)) {
			ans = num;
			cout << ans << endl;
			cin >> ans;
			return 0;
		}
		K = K - pow(num, time);
	}

	return 0;
}



Measured memory_bytes: 256
# -*- coding: utf-8 -*-
#ABC144C
import sys
import math
import collections
#sys.setrecursionlimit(100000)


n=int(input())

#tmp = input().split()
#a,b = list(map(lambda a: int(a), tmp))

sta=math.floor(math.sqrt(n))

#print(sta)

for i in range(sta):
	if(n%(sta-i)==0):
		print(n//(sta-i)+sta-i-2)
		sys.exit()







Measured memory_bytes: 3440
/* Manish Pant - insider_pants */

#include <bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#include "debug.h"
#endif

#define F first
#define S second
#define endl "\n"
#define pb push_back
typedef long long ll;
typedef long double ldob;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

const ll MOD = 1e9 + 7;
vector<ll> v;
int n, k;

void solve()
{
    if(k == n)
    {
        ll ans = 1;
        for(int i: v)
        {
            ans = ((ans * i) % MOD + MOD) % MOD;
        }
        cout << ans << endl;
        return;
    }
    vector<ll> pos, neg;
    for(int i = 0; i < n; i++)
    {
        if(v[i] > 0)
            pos.pb(v[i]);
        else
            neg.pb(v[i]);
    }

    sort(pos.rbegin(), pos.rend());
    sort(neg.begin(), neg.end());

    if(int(pos.size()) + int(neg.size()) < k)
    {
        cout << 0 << endl;
        return;
    }

    ll ans = 1;
    if(k & 1)
    {
        if(pos.empty())
        {
            reverse(neg.begin(), neg.end());
            ll ans = 1; 
            for(int i = 0; i < k; i++)
            {
                ans = ((ans * neg[i]) % MOD + MOD) % MOD;
            }
            cout << ans << endl;
            return;
        }
        ans = pos[0];
        pos.erase(pos.begin());
        k--;
    }    

    priority_queue<ll> pq;
    for(int i = 1; i < pos.size(); i += 2)
        pq.push(pos[i] * pos[i - 1]);
    for(int i = 1; i < neg.size(); i += 2)
        pq.push(neg[i] * neg[i - 1]);

    for(int i = 0; i < k / 2; i++)
    {
        ll t = pq.top();
        pq.pop();

        ans = ((ans * (t % MOD)) % MOD + MOD) % MOD;
    }
    cout << ans << endl;
}

int main()
{
    fast();
    cin >> n >> k;
    for(int i = 0; i < n; i++)
    {
        ll a; cin >> a;
        v.pb(a);
    }
    solve();
}

Measured memory_bytes: 8456
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#define max(a, b)	(((a) > (b)) ? (a) : (b))		/* ２個の値の最大値 */
#define min(a, b)	(((a) < (b)) ? (a) : (b))		/* ２個の値の最小値 */
#define ENTER		printf("\n")					/* 改行プリント */
/********************************************************************************************************************************/
/* main *************************************************************************************************************************/
/********************************************************************************************************************************/
int DEBUG = 0;										/* デバッグプリント 提出時は0 */

struct ab {
	int		a;
	int		b;
};
int compare(const void *a, const void *b) {
	int aa = ((struct ab *)a)->b;
	int bb = ((struct ab *)b)->b;
	if (aa > bb) return 1;
	if (aa < bb) return -1;
	return 0;
}

int main()
{
	int		n,i,j,ans = 0;
	struct ab	ab[200001];

	scanf("%d",&n);
	for(i=1;i<=n;i++) {
		scanf("%d %d", &ab[i].a, &ab[i].b);
	}

	qsort((void *)&ab[1], n, sizeof(struct ab), compare);

if (DEBUG) {
	ENTER;
	for(i=1;i<=n;i++) {
		printf("%d %d\n", ab[i].a, ab[i].b);
	}
}
	for(i=1,j=0;i<=n;i++) {
		j += ab[i].a;
		if (j > ab[i].b) {
			ans = 1;
			if(DEBUG) printf("j b : %d %d\n",j , ab[i].b);
			break;
		}
	}

	if (ans == 0) {
		printf("Yes\n");
	} else {
		printf("No\n");
	}

	return 0;
}


Measured memory_bytes: 3324
AC,WA,TLE,RE=0,0,0,0
for T in range(int(input())):
	S=input()
	if S=="AC":AC+=1
	elif S=="WA":WA+=1
	elif S=="TLE":TLE+=1
	else:RE+=1
print("AC x", AC)
print("WA x", WA)
print("TLE x", TLE)
print("RE x", RE)

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

const long long MOD = 1000000007;
const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  vector<ll> A(N);
  for (auto &it : A)
    cin >> it;
  vector<ll> B(N);
  for (int i = 0; i < N; i++)
  {
    B[i] = A[i] - (i + 1);
  }
  sort(B.begin(), B.end());
  int b;
  int half = N / 2;
  if (N % 2 == 0)
  {
    b = (B[half - 1] + B[half]) / 2;
  }
  else
  {
    b = B[half];
  }
  ll ans = 0;
  for (int i = 0; i < N; i++)
  {
    ans += abs(A[i] - (b + i + 1));
  }
  cout << ans << endl;
  return 0;
}

// abs(Ai - (b + i))を加算していくことからabs(Ai - i - b) 同じ変数を持つAiとiをまとめてBi = Ai - iと定義すれば，問題は自由に整数bを選び，abs(Bi - b)の総和を最小化する問題となる．よってBiをソートして中央値を求め実際に答えを計算すればよい．


Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int i;

int main(){
	ios::sync_with_stdio(false);
    cin.tie();
    
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    if(b>a&&c>b){
    	cout<<"Yes"<<endl;
        return 0;
    }
	for(i=0;k>0||!(b>a&&c>b);i++){
		if(!(b>a)){
		    b*=2;
			k--;	
		}
		if(k<=0)break;
		if(!(c>b)){
			c*=2;
			k--;
		}
		if(k<=0)break;
		if(b>a&&c>b&&k>0){
		    cout<<"Yes"<<endl;
		    return 0;
	    }
	}
	if(b>a&&c>b) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <stdlib.h>
/******memore********/
#define maxn 
#define inf  

int main()
{
	int n, m;
	while (~scanf("%d", &n))
	{
		m = n / 15;
		printf("%d\n",n * 800 - m * 200 );
	}
	return 0;
} 

Measured memory_bytes: 128
class UnionFind:
	def __init__(self, n):
		self.p=[-1]*n
		self.size=[1]*n
	def root(self, x):
		st=set()
		while self.p[x]>=0:
			st.add(x)
			x=self.p[x]
			for y in st:
				self.p[y]=x
		return x
	def find(self, x, y):
		return self.root(x)==self.root(y)
	def union(self, x, y):
		r1=self.root(x)
		r2=self.root(y)
		if r1==r2:
			return
		p1=self.p[r1]
		p2=self.p[r2]
		if p1<=p2:
			self.p[r2]=r1
			self.size[r1]+=self.size[r2]
			if p1==p2:
				self.p[r1]-=1
		else:
			self.p[r1]=r2
			self.size[r2]+=self.size[r1]

N, M = map(int,input().split())
uft = UnionFind(N)

for i in range(M):
	A, B = map(int,input().split())
	A -= 1
	B -= 1
	uft.union(A, B)
	
print(max(uft.size))

Measured memory_bytes: 74532
#include <iostream>
#include <algorithm>

using namespace std;

int main ( void )
{
	int n;

	while ( cin >> n )
	{
		int m;
		cin >> m;
		for (int i = 0, a, b, x; i < m; ++i)
		{
			cin >> a >> b;

			x = min(a, min(b, min(n - a + 1, n - b + 1)));
			x %= 3;

			if ( x )
				cout << x << endl;
			else
				cout << 3 << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1160
// by adiforluls
#pragma GCC optimize ("-O2")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define FAST            ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ll              long long
#define ld              long double
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define all(a)          (a).begin(),(a).end()
#define clz(a)          __builtin_clz(a) // count leading zeroes
#define ctz(a)          __builtin_ctz(a) // count trailing zeroes
#define popc(a)         __builtin_popcount(a) // count set bits (for ints only diff for ll)
#define rep(i,a,b)      for(int i=a;i<b;i++)
#define rfor(i,a,b)     for(int i=a; i>=b; i--)
#define debug(x)        cerr << #x << " = " << x << endl;
#define F               first
#define S               second
#define endl            '\n'
#define SIZE            1000005
#define deci(n)         cout<<fixed<<setprecision(n)
#define ordered_set     tree<pll, null_type,less<pll>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key(k)
// find_by_order(k)
const ld PI = acos(-1.0);
const int INF = 0x3f3f3f3f;
const ll lul2 = 998244353;
const ll lul = 1000000007;

void mod(ll &x)
{
    if(x>=lul) x-=lul;
    if(x<0) x+=lul;
}

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

ll expo(ll n, ll p)
{
    if(p == 0) return 1;
    ll x = expo((n*n)%lul, p/2)%lul;
    if(p&1) return (x*n)%lul;
    return x;
}
//---------------------------------------------------------------------
ll ans = 0, sum = 0;
unordered_map<ll,ll> ma;
void solve()
{
    ll n,m; cin>>n>>m;
    rep(i,0,n)
    {
        ll x; cin>>x;
        sum=(sum+x)%m;
        ma[sum]++;
    }
    for(auto i:ma)
    {
        if(i.F == 0) ans+=(i.S*i.S+i.S)/2;
        else ans+=(i.S*i.S-i.S)/2;
    }
    cout<<ans;
}
int main()
{   
    FAST;
   //  #ifndef ONLINE_JUDGE
     // freopen("input.txt", "r", stdin);
     // freopen("output.txt", "w", stdout);
   //  #endif
    int t; t=1;
    rep(i,1,t+1){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3724
#include<stdio.h>
#include<math.h>
int main()
{
    long long x;
    scanf("%lld",&x);
    long long i=100,year=0;
    while(i<x)
    {
        i=(long long)i*1.01;
        year++;
    }
    printf("%d\n",year);
}


Measured memory_bytes: 2152
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int lli;
#define ff              first
#define ss              second
#define pb              push_back
#define mp              make_pair
#define pii             pair<lli,lli>
#define vi              vector<lli>
#define mii             map<lli,lli>
#define pqb             priority_queue<lli>
#define pqs             priority_queue<lli,vi,greater<lli> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            lli x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<lli, null_type, less<lli>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void ss()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

}
const lli N = 21;
lli dp[N][1 << N];
lli arr[N][N];
lli n;
lli req;
lli add(lli a, lli b) {
	return ((a % mod) + (b % mod)) % mod;
}
lli help(lli idx, lli mask) {
	//cout << idx << " " << mask << endl;
	if (idx == n) {
		//	cout << "End!" << endl;
		//	cout << mask << endl;
		return mask == req;
	}
	lli ret = 0;
	if (dp[idx][mask] != -1) {
		//	cout << "Memo!" << endl;
		return dp[idx][mask];
	}
	for (lli i = 0; i < n; i++) {
		//cout << i << endl;
		if (arr[idx][i] && !((mask >> i) & 1)) {
			//		cout << idx << " " << i << endl;
			ret = add(ret, help(idx + 1, mask | (1 << i)));
		}
	}
	return dp[idx][mask] = ret;
}
void solve() {

	cin >> n;
	memset(dp, -1, sizeof dp);
	for (lli i = 0; i < n; i++) {
		for (lli j = 0; j < n; j++) {
			cin >> arr[i][j];
			//		cout << arr[i][j] << " ";
		}
		//	cout << endl;
	}
	req = (1 << n) - 1;
	//cout << req << endl;
	cout << help(0, 0) << endl;
}
int main()
{
	ss();
	solve();
	return 0;
}

Measured memory_bytes: 344320
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define ep emplace_back
#define st first
#define sc second

using namespace std;

const ll mod = 998244353;
const int e = 1e6 + 69;
const int base = 311;

// dung igt thay cho gt luc tinh giai thua
// 3
// cach tao hoan vi tu n so : n*(n+1)/2;

ll a[e];
ll b[e];

int main()
{
   int n;
   cin >> n;
   for(int i=1; i<=n; i++)
   {
       cin >> a[i];
   }
   ll ans = 0;
   ll cur = 0, cur1 = 0;
   for(int i=1; i<=n; i++)
   {
       cin >> b[i];
       if(a[i] > b[i])
       {
           cur += a[i];
           cur1 += b[i];
       }
   }
   cout << cur - cur1;
}


Measured memory_bytes: 2304
l = [[1,3,5,7,8,10,12],[4,6,9,11],[2]]
x,y = map(int,input().split())
ans = ""
for i in range(3):
    if (x in l[i]):
        if (y in l[i]):
            print("Yes")
            break
        else:
            print("No")
            break

    
    

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN=100005;
const int MAXM=525;
const ll MOD=998244353;
const ll INF=1000000000000000000LL;
int n,m[3];
vector<int> G[MAXN];
int sg[3][MAXN];
int weight[3][MAXM];
bool has[MAXM];
int p[3*MAXN];
void add(int &a,int b) {a+=b; if(a>=MOD) a-=MOD;}
void dec(int &a,int b) {a-=b; if(a<MOD) a+=MOD;}
int main()
{

    ll x=INF%MOD;
    p[0]=1;
    for(int i=1;i<=300000;i++) p[i]=1LL*p[i-1]*x%MOD;
    scanf("%d",&n);
    for(int i=0;i<3;i++)
    {
        scanf("%d",&m[i]);
        for(int j=1;j<=n;j++) G[j].clear();
        for(int j=0;j<m[i];j++)
        {
            int x,y;
            scanf("%d%d",&x,&y);
            if(x>y) swap(x,y);
            G[x].push_back(y);
        }
        for(int j=n;j>=1;j--)
        {
            memset(has,false,sizeof(has));
            for(auto to:G[j]) has[sg[i][to]]=true;
            int k=0;
            for(;has[k];k++);
            sg[i][j]=k;
            add(weight[i][k],p[j]);
        }
    }
    int ans=0;
    for(int i=0;i<512;i++)
        for(int j=0;j<512;j++)
        {
            int k=i^j;
            add(ans,1LL*weight[0][i]*weight[1][j]%MOD*weight[2][k]%MOD);
        }
    printf("%d\n",ans);
    return 0;
}

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

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

  int k, s;
  cin >> k >> s;

  int cnt = 0;

  for (int i = 0; i <= k; i++)
  {
    for (int j = 0; j <= k; j++)
    {
      int m = s - i - j;
      if (0 <= m && m <= k)
      {
        cnt++;
      }
      
    }
  }
  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 256
S = input()
L = [" "]
for s in S:
  if s == 'A':
    L.append('0')
  elif s == 'B':
    L.append('B')
  elif s == 'C' and L[-1] == 'B':
    L[-1] = '1'
  else:
    L.append('C')

def func(a,b):
#  print(a,b)
  return a * b

ans = 0
a,b = 0,0
i = 0
while i < len(S):
  if S[i] == 'A':
    if b != 0:
      ans += func(a,b)
      b = 0
    a += 1
  elif S[i:i + 2] == 'BC':
    b += 1
  elif S[i - 1:i + 1] == "BC":
    ()
  else:
    ans += func(a,b)
    a,b = 0,0
  i += 1
print(ans + func(a,b))

Measured memory_bytes: 4864
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define MOD (int)1e9+7
#define EPS 1e-8
#define INF 1e9+10
#define INFL 1e18
typedef long long ll;
using namespace std;
int main()
{
  int n;
  cin >> n;
  vector<ll>A(n,0),B(n,0),C(n,0);
  rep(i,n)cin >> A[i];
  rep(i,n)cin >> B[i];
  rep(i,n)cin >> C[i];

  sort(A.begin(),A.end());
  sort(B.begin(),B.end());
  sort(C.begin(),C.end());
  ll ans=0;
  rep(i,n){
      ll l=-1;ll r=n;
      while(r-l>1){
          ll c=(l+r)/2;
          if(A[c]<B[i]){
              l=c;
          }
          else{
              r=c;
          }
      }
      ll a=l+1;

      l=-1;r=n;
      while(r-l>1){
          ll c=(l+r)/2;
          if(C[c]>B[i]){
              r=c;
          }
          else{
              l=c;
          }
      }
      ans+=a*(n-r);
  }

  cout << ans << endl;
}


Measured memory_bytes: 2560
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
using namespace std;
int a[100001],ji,ou;
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		if(a[i]%2==0)ou++;
		else ji++;
	}
	if(ji%2==0)
	{
		cout<<"YES";
	}
	else cout<<"NO";
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[n-1];
    for(int i=1; i<=n-1; i++)
        cin>>a[i];
    int b[n];
    for(int i=1; i<=n; i++)
            b[i]=0;
    for(int i=1; i<=n-1; i++)
    {
       b[a[i]]++;


    }
    for(int i=1; i<=n; i++)
        cout<<b[i]<<endl;
    cout<<endl;


}


Measured memory_bytes: 5156
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

ll N;
vector<P> node[100001];
ll Q,K;
ll x[100000], y[100000];
ll dis[100001];

void dfs(ll m,ll p){
    repr(e,node[m]){
        if(e.first==p) continue;
        dis[e.first]+=dis[m]+e.second;
        dfs(e.first,m);
    }
}

int main(){
    cin>>N;
    rep(i,N-1){
        int a,b,c;
        cin>>a>>b>>c;
        node[a].push_back(P(b,c));
        node[b].push_back(P(a,c));
    }
    cin>>Q>>K;
    rep(i,Q) cin>>x[i]>>y[i];

    dfs(K,0);

    rep(i,Q){
        ll ans=dis[x[i]]+dis[y[i]];
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,t=0,s=0,i;
	cin>>n;
	int m=n;
	while(m>=1){
		m/=10;
		t++;
	}
	if(t==1)
		s=n;
	if(t==2)
		s=9;
	if(t==3)
		s=9+n-99;
	if(t==4)
		s=909;
	if(t==5)
		s=909+n-9999;
	if(t==6)
		s=90909;
	cout<<s;
	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
n = int(input())
l = list(map(int,input().split()))
sum_l = sum(l)
min_dif = abs(sum_l-2*l[0])
acum_sum = l[0]
for i in range(1,n-1):
    acum_sum += l[i]
    if min_dif > abs(sum_l - 2*acum_sum):
        min_dif = abs(sum_l - 2*acum_sum)
#print(acum_sum)
print(min_dif)


Measured memory_bytes: 24832
# coding: utf-8
import fractions


def solve(arg: str) -> str:
    a, b = map(int, arg.split())
    div = [1]

    g = fractions.gcd(a, b)
    n = 2
    while n*n <= g:
        if g % n == 0:
            div.append(n)
            while g % n == 0:
                g = int(g/n)
        n += 1
    if g != 1:
        div.append(g)

    return str(len(div))


if __name__ == "__main__":
    print(solve(input()))


Measured memory_bytes: 64236
#include"bits/stdc++.h"

using namespace std; 

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

#define SORT_ASC(c) sort((c).begin(), (c).end())
#define SORT_DESC(c) sort((c).begin(), (c).end(), greater<typeof((c).begin())>())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INT_LARGE = 1000000100;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

void Main()
{
	int n,d;
	cin >> n>>d;
	VVI x(n);
	REP(i,n){
		x[i].resize(d);
		REP(j,d){
			cin>>x[i][j];
		}
	}

	int r=0;

	FOR(i,0,n){
		FOR(j,i+1,n){
			int dist = 0;
			REP(k,d){
				dist += (x[i][k] - x[j][k])*(x[i][k] - x[j][k]);
			}

			int dist2 = sqrt(dist);
			if(dist == dist2*dist2){
				r++;
			}
		}

	}
	cout << r << endl;



	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

Measured memory_bytes: 256
from sys import exit, setrecursionlimit
from functools import reduce
from itertools import *
from collections import defaultdict
from bisect import bisect

def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

setrecursionlimit(1000000)

(H, W) = reads()

for j in range(1, H+1):
  s = input().split()
  if "snuke" in s:
    i = s.index("snuke")
    print(chr(ord('A')+i) + str(j)); exit()


Measured memory_bytes: 3940
import math

N,Y = map(int,input().split())

Y = Y/1000

for i in range(N+1):
    for j in range(N+1-i):
            if i + j*5 + (N-i-j)*10 == Y:
                print("{} {} {}".format(N-i-j,j,i))
                exit(0)

print("-1 -1 -1")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include<math.h>
#include<algorithm> 
#define rep(i,n) for (int i = 0; i < (n) ; ++i)
using namespace std;
using ll = long long ;
using P = pair<int, int> ;
using PL = pair<ll, ll> ;
#define PI 3.14159265358979323846264338327950
#define INF 1e18
#define mod 1000000007

int modpow(ll a, ll n){
    if(n == 0) return 1 ;
    if(n == 1) return a % mod ;
    if(n % 2) return (a * modpow(a, n-1))%mod ;
    ll t = modpow(a, n/2) ;
    return (t*t) % mod ;
}

int main() {
    ll n ;
    cin >> n ;
    vector<ll> a (n) ;
    vector<ll> c (60) ;
    rep(i, n) {
        cin >> a[i] ;
        rep(j, 60){
            if(a[i] >> j & 1){
                c[j]++ ;
            }
        }
    }
    ll ans = 0 ;
    ll k =  n;
    rep(i, n){
        rep(j, 60){
            if(a[i] >> j & 1){
                ans += modpow(2,j)*(k - c[j]) ;
                ans %= mod ;
                c[j]-- ;
            }
            else {
                ans += modpow(2,j)*c[j] ;
            }
        }
        k-- ;
    }
    cout << ans << endl ;
} 

Measured memory_bytes: 5564