akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

// order statistics tree
typedef tree<pii, null_type, less<pii>, rb_tree_tag,
             tree_order_statistics_node_update> indexed_set;

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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()

const int N = 2e5 +10;
int n, q;
vector<tuple<int, int, int>> events;
set<int> roadblocks;
// S_i - X_i - 0.5 <= D_i <= T_i -0.5 - X_i
int main() {
  cin.tie(0); cin.exceptions(cin.failbit);
  scanf("%d%d", &n, &q);
  rep(i, 1, n+1){
    int s, t, x;
    scanf("%d%d%d", &s, &t, &x);
    events.PB(make_tuple(s-x, 1, x)); // add roadblock
    events.PB(make_tuple(t-x, 0, x)); // remove roadblock
  }
  sort(events.begin(), events.end());
  int event_cnt = 0;
  rep(i, 1, q+1){
    int st;
    scanf("%d", &st);
    while(event_cnt < events.size() && st >= get<0>(events[event_cnt])){
      int event_type = get<1>(events[event_cnt]);
      int x = get<2>(events[event_cnt]);

      if(event_type) roadblocks.insert(x);
      else roadblocks.erase(x);

      event_cnt++;
    }

    if(!roadblocks.empty()){
      printf("%d\n", *roadblocks.begin());
    } else {
      puts("-1");
    }
  }
}


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

int main() {
	int n; cin >> n; long long ans = 0;
	vector<int>a(n); 
	for (auto&& x : a) {
		cin >> x;
		ans += x - 1;
	}
		
	cout << ans << endl;

	return 0;
}

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

using namespace std;
using ll = long long int;
using ull = unsigned long long int;
#define vll vector<ll>

#define FOR(i, b, e) for(int i = (b); i < (e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define REV(v) reverse((v).begin(), (v).end())
#define IN(v) cin >> (v);
#define VIN(v, n) REP(i, n) cin >> v[i];
#define OUT(v) cout << (v) << endl;
#define YN(b) OUT((b) ? "YES" : "NO")
#define Yn(b) OUT((b) ? "Yes" : "No")
#define yn(b) OUT((b) ? "yes" : "no")

const ll MOD = 1000000007;

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

  ll n;
  cin >> n;
  ll a[n], sum = 0;
  map<ll, ll> m;
  REP(i, n) {
    cin >> a[i];
    sum += a[i];
    m[a[i]]++;
  }

  ll q;
  cin >> q;
  ll b, c;
  REP(i, q) {
    cin >> b >> c;
    if (m.find(b) == m.end()) {
      cout << sum << endl;
      continue;
    }

    sum += (c - b) * m[b];
    m[c] += m[b];
    m[b] = 0;
    cout << sum << endl;
  }

  return 0;
}

Measured memory_bytes: 9548
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <unordered_map>
#include <cmath>
using namespace std;

typedef unsigned int uint;
typedef long long llong;
typedef unsigned long long ullong;
// -2.1e-9 <= int <= 2.1e9
// -9.2e-18 <= long long <= 9.2e18
// 0 <= unsigned int <= 4.2e9
// 0 <= unsigned long long <= 18.4e18

void swap(int &a, int &b) {
    int temp = a;
    a = b;
    b = temp;
}

int main()
{
    int data[3];
    cin >> data[0] >> data[1] >> data[2];
    swap(data[0], data[1]);
    swap(data[0], data[2]);

    cout << data[0] << ' '  << data[1] << ' ' << data[2] << endl;
}


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

#define ll long long
#define mod 1000000007
#define ffor(i,a,b) for(int i=a;i<b;i++)
#define bfor(i,a,b) for(int i=a-1;i>=b;i--)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define mem(x,y) memset(x,y,sizeof(x))
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sz(x) (int)x.size()
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define PI 3.1415926535
#define lb lower_bound
#define ub upper_bound
#define bs binary_search

int main()
{
    int n,l;
    cin>>n>>l;
    int index=-1,ans=INT_MAX;
    ffor(i,1,n+1)
    {
        if(abs(l+i-1)<ans)
        {
            ans=abs(l+i-1);
            index=i;
        }
    }
    ans=0;
    ffor(i,1,n+1)
    {
        if(i==index) continue;
        else ans+=l+i-1;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define p pair<int, int>
using namespace std;

int main() {
    int h, w, k;
    cin >> h >> w >> k;
    string s[h];
    for (int i = 0; i < h; i++) cin >> s[i];
    int ans = 1e9;
    for (int bit = 0; bit < 1 << (h - 1); bit++) {
        int n = 0;
        bool flag = true;
        vector<int> idx(h, 0);
        for (int i = 0; i < h - 1; i++) {
            if (!((bit >> i) & 1))
                idx[i + 1] = idx[i];
            else
                idx[i + 1] = idx[i] + 1, n++;
        }
        int add = 0;
        vector<int> nums(n + 1, 0);
        for (int j = 0; j < w; j++) {
            vector<int> one(n + 1, 0);
            bool ok = true;
            for (int i = 0; i < h; i++) {
                one[idx[i]] += s[i][j] - '0';
                nums[idx[i]] += s[i][j] - '0';
                if (one[idx[i]] > k) flag = false;
                if (nums[idx[i]] > k) ok = false;
            }
            if (!ok) add++, nums = one;
        }
        if (flag) ans = min(ans, n + add);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;

#define rep(i,a) for(int i = 0 ; i < a ; i ++)
#define loop(i,a,b) for(int i = a ; i < b ; i ++)
int main(void){
  int a[3];
  rep(i,3)cin>>a[i];
  sort(a,a+3);
  cout<<(a[2] == a[0] + a[1] ? "Yes" : "No")<<endl;
}

Measured memory_bytes: 256
# C - Welcome to AtCoder

N, M = map(int, input().split())
AC = {}
WA = {}
for _ in range(M):
    p, s = input().split()
    if p not in AC and p not in WA:
        AC[p], WA[p] = 0, 0
    if AC[p] < 1:
        if s == 'AC':
            AC[p] += 1
        elif s == 'WA':
            WA[p] += 1

for p in AC:
    if AC[p] == 0:
        WA[p] = 0

print(sum(AC.values()), sum(WA.values()))


Measured memory_bytes: 23564
#include <iostream>
#include <vector>
#include <algorithm>

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

using namespace std;

int op(int a, int b, int k){
    return k ? a + b : a - b;
}

char a[5];

int main(){
    cin >> a;
    rep(i, 4){
        a[i] -= '0';
    }
    rep(i, 1 << 3){
        int x = a[0];
        rep(j, 3){
            x = op(x, a[j + 1], (i >> j) & 1);
        }
        if(x == 7){
            cout << (int)a[0];
            rep(j, 3){
                cout << ((i >> j) & 1 ? '+' : '-');
                cout << (int)a[j + 1];
            }
            cout << "=7" << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
def main():
    S = input()
    ok = True
    for c in S[::2]:
        if c == "L":
            ok = False
    for c in S[1::2]:
        if c == "R":
            ok = False
    if ok:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()


Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define LL long long
using namespace std;
inline int read(){
    int x = 0; char c = getchar();
    while (!isdigit(c)) c = getchar();
    while (isdigit(c)) x = x * 10 + c - '0',c = getchar();
    return x;
}
template <typename T> void read(T &x){
	x = 0; int f = 1; char ch = getchar();
	while (!isdigit(ch)) {if (ch == '-') f = -1; ch = getchar();}
	while (isdigit(ch)) {x = x * 10 + ch - '0'; ch = getchar();}
	x *= f;
}
inline void write(int x){if (x > 9) write(x/10); putchar(x%10+'0'); }
LL a,b,num1,num2;
int main(){
	int i;
	a = read(),b = read();
	num1 = 0; for (i = 1; i <= b; ++i) num1 = num1 * 10 + a;
	num2 = 0; for (i = 1; i <= a; ++i) num2 = num2 * 10 + b;
	cout << max(num1,num2) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> plp;
int main(){
  ll inf=1000000000000000000;
  ll n,m,s,t;cin>>n>>m>>s>>t;
  ll u[m],v[m],a[m],b[m];
  vector<plp> h[n+1];
  for(ll i=0;i<m;i++){
    cin>>u[i]>>v[i]>>a[i]>>b[i];
    h[u[i]].push_back(make_pair(v[i],make_pair(a[i],b[i])));
    h[v[i]].push_back(make_pair(u[i],make_pair(a[i],b[i])));
  }
  ll ds[n+1],dt[n+1];
  fill(ds,ds+n+1,inf);
  fill(dt,dt+n+1,inf);
  priority_queue<pll,vector<pll>,greater<pll>>qs,qt;
  qs.push(make_pair((ll)0,s));
  ds[s]=0;
  while(qs.size()>0){
    pll p=qs.top();qs.pop();
    ll pf=p.first,ps=p.second;
    for(ll i=0;i<h[ps].size();i++){
      plp hi=h[ps][i];
      ll ht=hi.first,he=hi.second.first;
      if(ds[ht]>pf+he){
        ds[ht]=pf+he;
        qs.push(make_pair(ds[ht],ht));
      }
    }
  }
  qt.push(make_pair((ll)0,t));
  dt[t]=0;
  while(qt.size()>0){
    pll p=qt.top();qt.pop();
    ll pf=p.first,ps=p.second;
    for(ll i=0;i<h[ps].size();i++){
      plp hi=h[ps][i];
      ll ht=hi.first,hs=hi.second.second;
      if(dt[ht]>pf+hs){
        dt[ht]=pf+hs;
        qt.push(make_pair(dt[ht],ht));
      }
    }
  }
  vector<ll>vv(n+1);
  ll mi=inf;
  for(ll i=n;i>0;i--){
    mi=min(mi,ds[i]+dt[i]);
    vv[i]=mi;
  }
  for(ll i=1;i<=n;i++)cout<<1000000000000000-vv[i]<<endl;
}

Measured memory_bytes: 17272
n,k=map(int,input().split())
A=sorted(list(map(int,input().split())))


mod=10**9+7

if A[-1]<0 and k%2==1:
    now=1
    for i in range(k):
        now*=A[-i-1]%mod
        now%=mod
    print(now) ;exit()

l=0 ; r=n-1
ans=1
if k%2==1:
    ans=A[-1]
    r-=1

for i in range(k//2):
    mi=A[l]*A[l+1]
    pl=A[r]*A[r-1]
    if mi>pl:
        ans*= mi%mod
        ans%=mod
        l+=2
    else:
        ans*= pl%mod
        ans%=mod
        r-=2
print(ans%mod)


Measured memory_bytes: 31920
#include<bits/stdc++.h>
using namespace std;
#define MP make_pair
#define PB push_back
#define PII pair<int,int>
#define ll long long
int N=INT_MAX;
ll INF1=1e9 + 5;
ll INF2=1e18L + 5;
map<int ,int>my;
int h[10005];

int main(){
	int n;
	cin>>n;
	cout<<pow(n,3);
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

int main(){
    int n,k;
    cin >> n >> k;
    
    ll tmp=0,tmp2=0;
    tmp = n/k;
    if(k%2==0){
        tmp2 = (n+k/2)/k;

        cout << tmp * tmp * tmp + tmp2 * tmp2 * tmp2 << endl;
    }else{
        cout << tmp * tmp * tmp << endl;
    }
    //cout << tmp << "," << tmp2 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <stdlib.h>
#include <ctype.h>
#include <cstring>
#include <math.h>
#include <limits.h>


int main(){
    long long int N;
    long long int K;
    long long int S1 = 0;
    long long int S2 = 0;
    long long int SUM = 0;
    long long int MOD = 1000000007;


    scanf("%lld %lld",&N,&K);

    for(long long int k = K  ; k <= N+1 ; ++k){

        S1 = ( (k)*(k-1)/2 ) ;

        S2 = (k* (N + N - k + 1) / 2 ) ;
//        printf("%ld\n",S1);
//        printf("%ld\n",S2);
        SUM += S2 -S1 + 1;
//        printf("%lld\n",SUM);
        SUM = SUM % MOD;

    }
            printf("%lld\n",SUM);
    return 0;
}

Measured memory_bytes: 1728
n, k = map(int, input().split())
h = list(map(int, input().split()))

def dif(a, b):
	if a>=b:
		return a-b
	else:
		return b-a

dp = [0]*1000000
dp[0]=0
dp[1]=dif(h[0],h[1])
for i in range(n-2):
	x = i+2
	dp[x] = dp[x-1]+dif(h[x],h[x-1])
	for t in range(k):
		j=t+1
		if x-j < 0:
			break
		dp[x] = min(dp[x],dp[x-j]+dif(h[x],h[x-j]))
print(dp[n-1])
#print(dp[0:n])

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

int main()
{
  string s, t; cin >> s >> t;
  int a, b; cin >> a >> b;
  string u; cin >> u;
  
  cout << (s == u ? a-1 : a) << " " << (t == u ? b-1 : b) << endl;
}

Measured memory_bytes: 256
use v5.18; # strict say state
use warnings;
use List::Util qw(reduce first max min sum0);

chomp (my ($a, $b, $c, $k) = split / /, <STDIN>);
if ($a==$b && $a==$c) {
  say 0;
  exit;
}
if ($k % 2 == 0) {
  say ($a-$b);
} else {
  say -($a-$b);
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

const ll mask = 0xAAAAAAAA;
int n, ans;
vector<vi> e;
ll rec(int c, int p){
	ll s = 0, t = 0;
	for(int i : e[c]) if(i != p){
		ll x = rec(i, c);
		s |= x;
		t += x;
		t &= ~((t & mask) >> 1);
	}
	t &= mask;
	int l = t ? 64 - __builtin_clzll(t) : 0;
	l = __builtin_ctzll((s | (s & ~mask) << 1 | (1ll << l) - 1) + 1);
	
	ans = max(ans, l / 2);
	s |= 1ll <<l;
	s &= ~((1ll << l) - 1);
	return s;
}
int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	scanf("%d", &n);
	e.resize(n);
	rep(i, n - 1){
		int a, b; scanf("%d%d", &a, &b); a--; b--;
		e[a].pb(b);
		e[b].pb(a);
	}
	rec(0, 0);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 10240
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;


int main() {
    int a, b, c;
    cin >> a >> b >> c;
    int sum = a + b + c;
    if((a == 5 || a == 7) && (b == 5 || b == 7) && (c == 5 || c == 7) && (sum == 17)){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
}

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

int main()
{
    int x;
    cin>>x;int sum=0;
   pair<int,int>s;
   s.first=0;s.second=1;
   for(int i=1;i<=x;i++)
   {int y=i;
       while(y%2==0)
       {
           sum++;
           y=y/2;
       }
       if(s.first<=sum)
       {
           s.second=i;
           s.first=sum;
       }
       sum=0;
   }
   cout<<s.second;
}


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

int main() {
  //input
  int A, B, C, X, Y;
  cin >> A >> B >> C >> X >> Y;
  //calc
  int a, b, x, y;
  if ( X < Y ) {
    x = X; y = Y; a = A; b = B;
  }
  else {
    x = Y; y = X; a = B; b = A;
  }
  int answer = 0;
  if ( a + b < 2 * C ) {
    answer = x * (a+b);
  }
  else {
    answer = x * 2 * C;
  }
  if ( y > x ) {
    int diff = y - x;
    if ( b < 2 * C ) {
      answer += b * diff;
    }
    else {
      answer += 2 * C * diff;
    }
  }
  //output
  cout << answer << endl;
}

Measured memory_bytes: 256
/*
======================
[     ___T_          ]
[    | 6=6 | =>HI :-)] 
[    |__o__|         ]
[ >===]__o[===<      ]
[     [o__]          ]
[      .".           ]
[      |_|           ]
[                    ]
======================
 */

#include<bits/stdc++.h>
using namespace std;
using lli = int64_t;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int T = 1;
	for(int t = 1; t <= T; t++){
		map<string,vector<pair<int,int>>> idx;
		int n;
		cin >> n;
		for(int i = 0;i < n; i++){
			string s;
			int p;
			cin >> s >> p;
			idx[s].push_back(make_pair(p,i + 1));
		}
		for(auto i : idx){
			sort(i.second.begin(),i.second.end(),greater<pair<int,int>>());
			for(int j = 0;j < (int) i.second.size(); j++){
				cout << i.second[j].second << "\n";
			}
		}
	}
}


Measured memory_bytes: 3616
def main():
    n = int(input())
    S= []
    from collections import defaultdict
    import itertools
    D = defaultdict(int)
    for _ in range(n):
        s = input()
        D[s[0]] += 1

    L = ['M','A','R','C','H']
    ans = 0
    for p in list(itertools.combinations(L,3)):
        t = 1
        for i in p:
            t *= D[i]
        ans += t
    print(ans)

main()

Measured memory_bytes: 9476
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
/*---------------------DEBUGGING--------------------------------------------*/
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
/*-------------------------------------------------------------------------------------*/
//#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pcc pair<char,char>
#define F first
#define S second
#define int long long
#define pi 3.141592653589793238462643383279502
#define M  1000000007
#define rep(i,a,n) for(int i=a;i<n;i++)
#define INF 10000000000000
#define N 100005
#define vi vector<int>
#define all(v) v.begin(),v.end()
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   int n;
   cin>>n;
   vi a(n);
   rep(i,0,n)cin>>a[i];
   sort(all(a));
   if(a.back() & 1)
   {   int mn=1e15,idx=-1;
       int x=a.back();
       for(int i=n-2;i>=0;i--)
       {
           int mn1=min(abs(x/2 - a[i]),abs(x/2 + 1 - a[i]));
           if(mn1 < mn)
           {
               mn=mn1;
               idx=a[i];
           }
       }
       cout<<a.back()<<" "<<idx<<endl;
   }
   else
   {
       int mn=1e15,idx=-1;
       int x=a.back();
       for(int i=n-2;i>=0;i--)
       {
           int mn1=abs(x/2 - a[i]);
           if(mn1 < mn)
           {
               mn=mn1;
               idx=a[i];
           }
       }
       cout<<a.back()<<" "<<idx<<endl;

   }
}


Measured memory_bytes: 3956
#include <bits/stdc++.h>
 using namespace std;
 #define rep(i,N) for(int i=0;i<int(N);++i)
 using ll = long long;
    //int nax = max_element(p.begin(),p.end())-p.begin();
    //int nin = max_element(p.begin(),p.end())-p.begin();
     //sort(l.begin(),l.end(),greater<int>());
     //stringは",charは'
     //ちょっとあやしかったら立ち止まって考える

 int main(){
     ll h,w;
     cin >> h >> w;
     if(h==1||w==1){
         cout << 1 << endl;
         return 0;
     }
     cout << h*w/2+(h*w)%2 << endl;
     return 0;
 }

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

int main() {
  int N;
  cin >> N;
  
  vector<vector<int>> map(N,vector<int>(2));
  
  for (int i = 0; i < N; i++) {
    map.at(i).at(0) = i + 1;
    cin >> map.at(i).at(1);
  }
  
  int count = 0;
  int k = 1;
  
  bool judge = false;
  
  for (int i = 0; i < N; i++) {
    if (map.at(k - 1).at(1) == 2) {
      judge = true;
      break;
    }
    k = map.at(k - 1).at(1);
    count++;
  }
  
  if (judge) {
    cout << count + 1 << endl;
  } else {
    cout << -1 << endl;
  }
}

Measured memory_bytes: 8776
#!/usr/bin/env python3

N, K  = map(int, input().split())
cnt = [0] * (N)
for i in range(K):
    d = int(input())
    A = list(map(int, input().split()))
    for k in A:
        cnt[k-1] += 1
ans = 0
for i in cnt:
    if i == 0:
        ans += 1
print(ans)

Measured memory_bytes: 67672
#include "bits/stdc++.h"
using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
ld EPS = 1e-12;
int INF = numeric_limits<int>::max() / 2;
ll LINF = numeric_limits<ll>::max() / 2;
int MOD = 1e9 + 7;
#define rep(i,n) for(int i = 0; i < n; i++)
#define all(obj) (obj).begin(), (obj).end()
#define debug(x) cerr << #x << ": " << x << '\n'

vector<vector<pair<int, int> > > edge;//edge[i][j] firstがiからj番目のノード、secondがその重み
vector<int> d(100005,INF);

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a,b;
	cin >> a >> b;
	int ret = 0;
	for(int i = a; i <= b; i++){
		if(i%10 == i/10000 && (i/10)%10 == (i/1000)%10){
			ret++;
		}
	}
	cout << ret << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int main(void){
  int N, K;
  cin >> N >> K;
  vector<int> l(N);
  for(int i=0;i<N;i++) cin >> l[i];
  sort(l.begin(),l.end());
  reverse(l.begin(),l.end());
  
  int ans = 0;
  for(int i=0;i<K;i++){
    ans += l[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>

using namespace std;

int main()
{
   // freopen("file.in","r",stdin);
    //freopen("file.out","w",stdout);
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    int lim=1e6;
    for(int i=0;i<=lim;i++)
        if((b*i+c)%a==0) {printf("YES");return 0;}
    printf("NO");
    return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			String[] a = scan.nextLine().split(" ");
			if(a[0].equals("0") && a[1].equals("0")){
				break;
			}
			int m = Integer.parseInt(a[0]);
			int n = Integer.parseInt(a[1]);
			boolean[] p = new boolean[m];
			int tp = 0;
			int count = m;
			String[] str = new String[n];
			for(int i = 0;i < n;i++){
				str[i] = scan.nextLine();
			}
			for(int i = 1;i <= n;i++){
				if(count == 1){
					break;
				}
				while(p[tp]){
					tp = (tp+1)%m;
				}
				if(i%15 == 0){
					if(!str[i-1].equals("FizzBuzz")){
						p[tp] = true;
						count--;
					}
				}else if(i%5 == 0){
					if(!str[i-1].equals("Buzz")){
						p[tp] = true;
						count--;
					}
				}else if(i%3 == 0){
					if(!str[i-1].equals("Fizz")){
						p[tp] = true;
						count--;
					}
				}else{
					if(!str[i-1].equals(String.valueOf(i))){
						p[tp] = true;
						count--;
					}
				}
				tp++;
				if(tp >= m){
					tp %= m;
				}
			}
			String ans = "";
			for(int i = 0;i < m;i++){
				if(!p[i]){
					ans += (ans.equals(""))?(i+1):(" "+(i+1));
				}
			}
			System.out.println(ans);
		}
	}
}

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

int main()
{
    char s[505][505];
    string v[510];
    int r,c,i,j;
    cin >> r;
    if(r<1200)
    {
        cout << "ABC"<<endl;
    }
    else if(r<2800)
    {
        cout << "ARC" <<endl;
    }
    else
    {
        cout << "AGC" <<endl;
    }
    return 0;
}


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

using namespace std;
using ll = long long;
const int INF = 1e9 + 10;

int main()
{
    int n; cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++)cin >> a[i];
    vector<int> dp(n + 1, INF);

    for(int i = 0; i < n; i++) {
        auto itr = lower_bound(dp.begin(), dp.end(), a[i]);
        *itr = a[i];
    }
    cout << lower_bound(dp.begin(), dp.end(), INF) - dp.begin() << endl;
}


Measured memory_bytes: 3608
#include <iostream>
#include <iomanip>
#include <vector>

typedef long long ll;
using namespace std;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for(ll i=init;i<(n);i++)

int main() {
    int h, w;
    cin >> h >> w;
    char c[h][w];
    repi(i, h, 0) {
        repi(j, w, 0) {
            cin >> c[i][j];
        }
    }

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

    repi(i, h - 1, 1) {
        repi(j, w - 1, 1) {
            int cnt = 0;
            if (c[i][j] == '#') {
                repi(k, 4, 0) {
                    if (c[i + dy[k]][j + dx[k]] == '.')cnt++;
                }
                if (cnt == 4) {
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

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

typedef long long ll;
const ll ten8 = 1e8;
const ll ten9 = 1e9;
const ll ten10 = 1e10;
const ll n8 = 1e8-1;
const ll n9 = 1e9-1;
const ll n10 = 1e10-1;

int main(){
	bool allnine = true;
	ios_base::sync_with_stdio(0);
	ll x, ans = 0;
	char res;
	while(1){
		ll l = 0, r = 9;
		ll suf = n10;
		if(ans > 1e5)
			suf = n8;
		while(l < r){
			ll nd = (l+r)/2;
			if(ans == 0 && nd == 0){
				l = r = 1;
				break;
			}
			cout << "? " << ans*10+nd << suf << endl;
			cout.flush();
			cin >> res;
			if(res == 'Y')
				r = nd;
			else l = nd+1;
		}
		ans = ans*10 + l;
		if(l != 9)
			allnine = false;
		cout << "? " << ans+1 << endl;
		cout.flush();
		cin >> res;
		if(res == 'Y' && allnine == false || res == 'N' && allnine){
			cout << "! " << ans << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 636
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  vector<int> vec;
  char bef = s[0];
  int cnt = 1;
  for (int i = 1; i < n; ++i) {
    if (bef != s[i]) {
      vec.push_back(bef == '0' ? -cnt : cnt);
      cnt = 1;
    } else {
      cnt++;
    }
    bef = s[i];
  }
  vec.push_back(bef == '0' ? -cnt : cnt);
  n = vec.size();
  int ans = 0, sum = 0;
  int j = 0;
  cnt = 0;
  for (int i = 0; i < n; ++i) {
    while (j < n) {
      if (0 <= vec[j]) {
        sum += vec[j];
        j++;
      } else {
        if (cnt < k) {
          sum -= vec[j];
          j++;
          cnt++;
        } else {
          break;
        }
      }
    }
    ans = max(ans, sum);
    if (i == j) {
      j++;
    } else {
      if (vec[i] < 0) {
        sum += vec[i];
        cnt--;
      } else {
        sum -= vec[i];
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1020
// template version 1.15
using namespace std;
#include <bits/stdc++.h>

// varibable settings
#define int long long
const int INF=1e18;

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(a, b, c) make_tuple(a, b, c)
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

#define divceil(a,b) ((a)+(b)-1)/(b)
#define is_in(x, a, b) ((a)<=(x) && (x)<(b))
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define slice(l, r) substr(l, r-l)

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
    #include "lib/dump.hpp"
#else
    #define dump(...) 42
    #define dump_1d(...) 42
    #define dump_2d(...) 42
    #define cerrendl 42
#endif
//}}}

signed main() {
    int x,y;cin>>x>>y;
    dump(x, y);
    int a,b,c;cin>>a>>b>>c;

    vi r(a), g(b), w(c);
    rep(i, a) cin>>r[i];
    rep(i, b) cin>>g[i];
    rep(i, c) cin>>w[i];
    sort(all(r));
    reverse(all(r));
    sort(all(g));
    reverse(all(g));
    sort(all(w));
    reverse(all(w));

    dump(r);
    dump(g);
    dump(w);

    int s = 0;
    rep(i, x) s += r[i];
    rep(i, y) s += g[i];
    dump(s);
    int ans = s;

    int i = x-1;
    int j = y-1;
    rep(k, 1, min(x+y, c)+1){
        dump(k, i, j);
        s += w[k-1];
        dump(s);
        if (j<0 || (i>=0 && r[i]<g[j])){
            s -= r[i];
            i--;
        }
        else{
            s -= g[j];
            j--;
        }
        dump(s);
        chmax(ans, s);

        if (i<0 && j<0) break;
    }
    cout << ans << endl;

    return 0;
}


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

int main()
{
   int x=0 ; int z=0 ;
   char S[200001] , T[200001] ;
   cin>>S >>T ;
   for (int i=0 ; i< strlen(S) ; i++) {
    if (S[i]==T[i]) z++;
    else x++ ;

   }
   if (z==0&&x==0) cout<<z ;
   else cout<<x ;
    return 0;
}


Measured memory_bytes: 3860
import java.util.Scanner;

public class Main {

    static Scanner sc = new Scanner(System.in);


    public static void main(String[] args) {
        int n = sc.nextInt();
        int a;
        int count = 0;
        for (int i = 0; i < n; i++) {
            a = sc.nextInt();
            if (a % 2 == 0) {
                int j = 1;
                boolean b = true;
                while (b) {
                    int c = (int) Math.pow(2, j);
                    if (a % c == 0) {
                        count++;
                        j++;
                    } else {
                        b = false;
                    }
                }
            }
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 36184
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


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

    int ans = 0;
    ll money = 100;
    while(money < 1e18) {
        if (money >= x) break;
        ans++;
        money += money/100;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h> 
using namespace std;
#define int long long int
#define float double
#define pb push_back
#define FF first
#define SS second
#define N 100005
#define MOD 1000000007
#define fn(i,n) for(int i=0;i<n;i++)
#define rep(i,l,r) for(int i=l;i<=r;i++)
#define pii pair<int,int>
#define mp make_pair
#define INF 9223372036854775807
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)


signed main() 
{
    speed;
    //freopen("input.tXt","r",stdin);
    //freopen("output.tXt","w",stdout);

    int n;
    cin>>n;
    float A[n+1];
    for(int i=1;i<=n;i++) cin>>A[i];

    float dp[n+1][n+1];
    memset(dp,0,sizeof(dp));
    dp[0][0]=1;
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<=n;j++)
        {
            if(j==0) dp[i][j]=(1-A[i])*dp[i-1][j];
            else dp[i][j]=A[i]*dp[i-1][j-1]+(1-A[i])*dp[i-1][j];
        }
    }
    float ans=0;
    for(int j=0;j<=n;j++) if(j>n-j) ans+=dp[n][j];
    cout<<fixed<<setprecision(10);
    cout<<ans<<endl;
}   

Measured memory_bytes: 74080
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()

    return divisors

def is_remainder(n):
    if n == 1:
        return True

    for i in range(2, int(n**0.5)+1):
        if n % i == 0:
            return False
    
    return True
        

A, B = [int(i) for i in input().split()]

import fractions
n = fractions.gcd(A, B)
divisors = make_divisors(n)
N = len(divisors)

count = 0
for item in divisors:
    if is_remainder(item):
        count += 1

print(count)

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

using namespace std;

const int N = 510;

char a[N][N], b[N][N];
char s[N][N];

int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf("%s", s[i]);
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (i & 1) {
        a[i][j] = '#';
        b[i][j] = s[i][j];
      } else {
        a[i][j] = s[i][j];
        b[i][j] = '#';
      }
    }
    a[i][0] = '#';
    b[i][0] = '.';
    a[i][m - 1] = '.';
    b[i][m - 1] = '#';
  }
  for (int i = 0; i < n; i++) {
    puts(a[i]);
  }
  puts("");
  for (int i = 0; i < n; i++) {
    puts(b[i]);
  }
  return 0;
}


Measured memory_bytes: 1536
function Main(input){
    a=input.split("\n");
    t=a[0].split(" ").map(Number);
    N=t[0];
    K=t[1]
    Q=t[2]
    //console.log("NKQa",N,K,Q,a)
    a.splice(0,1)
    a.pop()
    A=a.map(Number)
    ANS=Array(N);
    ANS.fill(K)
    //console.log(a,A)
    for(x=0;x<Q;x++)ANS[A[x]-1]++;
    //console.log(ANS)
    for(y=0;y<N;y++){
        ANS[y]-=Q
        if(ANS[y]>0)console.log("Yes")
        else console.log("No")
    }
    //console.log(ANS)
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 30232
#include <bits/stdc++.h>
using namespace std ;
const int N = 5e5 + 10 ;
vector<int> v[N] ;
typedef long long ll ;
int main()
{
  ll x ;
  cin >> x ;
  ll ans = 0 ;
  ans += 1000 *(x / 500 ) ;
  x %= 500 ;

  ans += 5 * (x / 5 );
  cout << ans << endl ;
  return 0 ;
}


Measured memory_bytes: 11904
#include <algorithm>
#include <bitset>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

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

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n, a; cin >> n >> a;
  cout << pow(n, 2) - a << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
typedef long long ll;

int main(){
    char s ; cin >>s;
    cout << (char)(s+1) << endl; return 0;
}


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

using namespace std;

const int Mod = 1e9+7, Nmax = 2e5+5;
typedef long long ll;
typedef pair<int,int> Pair;

int n, c, w, X, Y, i, j, ans=1, colour[Nmax], fact[Nmax], invfact[Nmax], ap[Nmax];
vector< Pair > v[Nmax];
vector<int> edge[Nmax], colours;
Pair Min1, Min2;
bitset<Nmax> used;

int inm(int x, int y) {return (ll)x*y%Mod;}

int power(int x, int y)
{
    if(!y) return 1;
    if(y&1) return inm(x, power(inm(x, x), y/2));
    return power(inm(x, x), y/2);
}

void add_edge(int x, int y)
{
    edge[x].push_back(y);
    edge[y].push_back(x);
}

void dfs(int node)
{
    used[node] = 1;
    if(!ap[colour[node]]) colours.push_back(colour[node]);
    ++ap[colour[node]];

    for(auto it : edge[node])
        if(!used[it]) dfs(it);
}

int get_answer()
{
    int sum = 0, ans = 1;
    for(auto it : colours)
    {
        sum += ap[it];
        ans = inm(ans, invfact[ap[it]]);
        ap[it] = 0;
    }

    ans = inm(ans, fact[sum]);
    colours.clear();
    return ans;
}

int main()
{
 //   freopen("input", "r", stdin);
 //   freopen("output", "w", stdout);

    cin >> n >> X >> Y;
    fact[0] = invfact[0] = 1;
    for(i=1; i<=n; ++i)
    {
        cin >> c >> w;
        colour[i] = c;
        v[c].push_back({w, i});
        fact[i] = inm(fact[i-1], i);
    }

    invfact[n] = power(fact[n], Mod-2);
    for(i=n-1; i; --i) invfact[i] = inm(invfact[i+1], i+1);


    Min1 = Min2 = {Mod, Mod};
    for(i=1; i<=n; ++i)
        if(!v[i].empty())
        {
            for(j=1; j<v[i].size(); ++j)
                if(v[i][j] <  v[i][0]) swap(v[i][j], v[i][0]);

            for(j=1; j<v[i].size(); ++j)
                if(v[i][0].first + v[i][j].first <= X) add_edge(v[i][0].second, v[i][j].second);

            if(v[i][0] < Min1) Min2 = Min1, Min1 = v[i][0];
                else if(v[i][0] < Min2) Min2 = v[i][0];
        }

    for(i=1; i<=n; ++i)
        for(auto it : v[i])
        {
            if(v[i][0] != Min1 && it.first + Min1.first <= Y) add_edge(Min1.second, it.second);
            if(v[i][0] != Min2 && it.first + Min2.first <= Y) add_edge(Min2.second, it.second);
        }

    ans = 1;
    for(i=1; i<=n; ++i)
        if(!used[i])
        {
            dfs(i);
            ans = inm(ans, get_answer());
        }
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 24936
# include <bits/stdc++.h>
typedef long long lint;
using namespace std;

lint gcd(lint x, lint y) {
  if(x == 0) { return y; }
  else { return gcd(y%x,x); }
}

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

lint C(lint n, lint k) {
  if(n == k) { return 1; }
  else if(n < k) { return 0; }
  else if(k == 0) { return 1; }
  else if(k == 1) { return n; }
  else return C(n-1,k-1) + C(n-1,k);
}


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

  map<char,int> mp;
  for(int i=0;i<n;i++) {
    map<char,int> mp0;
    string s; cin >> s;
    for(int j=0;j<(int)s.size();j++) { mp0[s[j]]++; }

    if(i == 0) { mp = mp0; }
    else { for(map<char,int>::iterator i=mp.begin();i!=mp.end();i++) { mp[i->first] = min(i->second,mp0[i->first]); } }
  }

  vector<char> vc;
  for(map<char,int>::iterator i=mp.begin();i!=mp.end();i++) {
    for(int j=0;j<i->second;j++) { vc.push_back(i->first); }
  }

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

  for(int i=0;i<(int)vc.size();i++) { cout << vc[i]; }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#define mp std::make_pair
#define pb push_back
using ll = long long;
template <typename T> constexpr T my_abs(const T &x) { return x < 0 ? -x : x; }

int main()
{
	// freopen("caddi2018-C.in", "r", stdin);
	ll n, p, ans = 1;
	scanf("%lld%lld", &n, &p);
	if (n == 1)
	{
		printf("%lld\n", p);
		return 0;
	}
	for (ll i = 2; i * i <= p; i++)
	{
		ll x = 1;
		for (ll j = 0; j < n && x <= p; j++)
			x *= i;
		if (!(p % x))
			ans = i;
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 256
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    vector<int> gcd_front(n), gcd_back(n);
    gcd_front[0] = a[0];
    gcd_back[n-1] = a[n-1];
    for(int i=1;i<n;i++){
        gcd_front[i] = gcd(gcd_front[i-1], a[i]);
    }
    for(int i=n-2;i>=0;i--){
        gcd_back[i] = gcd(gcd_back[i+1], a[i]);
    }

    int ret = max(gcd_front[n-2], gcd_back[1]);
    for(int i=1;i<n-1;i++){
        ret = max(ret, gcd(gcd_front[i-1], gcd_back[i+1]));
    }

    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 1408
import sys
import itertools
# import numpy as np
import time
import math
 
sys.setrecursionlimit(10 ** 7)
 
from collections import defaultdict
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())
# list(map(int, input().split()))

N = int(input())
A = list(map(int, input().split()))

if A[0] != 0:
    print(0)
    exit()

MAX = 2 * 10 ** 5 + 5
count = [0] * N
count[0] = 1
ans = 3
MOD = 10 ** 9 + 7
for a in A[1:]:
    if a == 0:
        ans *= 3 - count[0]
    else:
        ans *= count[a - 1] - count[a]
    ans %= MOD
    count[a] += 1

print(ans % MOD)

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

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define fill(x, y) memset(x, y, sizeof(x))
#define clr(x) memset(x, 0, sizeof(x))
#define pb push_back
#define eb emplace_back

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

using ll = long long;
using namespace std;

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

	ll result = (10 <= N)
					? R
					: (R + (100 * (10 - N)));
	cout << result << endl;
	return 0;
}


Measured memory_bytes: 256
<?php
function chmax($a, $b) {
    if ($a < $b){
        return $b;
    }else{
        return $a;
    };
}

fscanf(STDIN, "%d", $n);
$abcarray = array();
for($i = 1; $i <= $n; ++$i){
    fscanf(STDIN, "%d %d %d", $a, $b, $c);
    $abcarray[$i] = array($a, $b, $c);
}

$dp = array();
$dp[0] = array(0, 0, 0);
for($i = 1; $i <= $n; $i++){
    for($j = 0; $j < 3; $j++){
        $dp[$i][$j] = -INF;
    }
}

for($i = 1; $i <= $n; $i++){
    for($j = 0; $j < 3; $j++){
        for($k = 0; $k < 3; $k++){
            if($j != $k){
                $dp[$i][$j] = chmax($dp[$i][$j], ($dp[$i-1][$k] + $abcarray[$i][$j]));
            }
        }
    }
}
print max($dp[$n]);

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

int main() {
  char c;
  cin >> c;
  
  if (c=='a' || c=='i' || c=='u' || c=='e' || c== 'o') {
    cout << "vowel" << endl;
  }
  
  else {
    cout << "consonant" << endl;
  }
  
}


Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<map>
#define LEN 100
#define BASE 25

using namespace std;

int maps[LEN][LEN];
int off[LEN][LEN];

int checker[4];
int ncheck[4];

map<int, int> points[LEN];

class State {
public:
	char where;
	int enemy;
	int budget;
	int check[4];
	State() {check[0]=0;check[1]=0;check[2]=0;check[3]=0;}
	State(char w, int e, int b ) {
		where = w;
		enemy = e;
		budget = b; 
		check[0] = ncheck[0];
		check[1] = ncheck[1];
		check[2] = ncheck[2];
		check[3] = ncheck[3];
	}
};


inline bool operator< ( const State& a, const State& b) {
	if( a.enemy == b.enemy )
		return a.budget > b.budget;
	return a.enemy < b.enemy;
}

inline bool operator> ( const State& a, const State& b) {
	if ( a.enemy == b.enemy )
		return a.budget < b.budget;
	return a.enemy > b.enemy;
}

priority_queue<State, deque<State>, greater<State> > status;

inline void copy ( State now ) {
	checker[0] = now.check[0];
	checker[1] = now.check[1];
	checker[2] = now.check[2];
	checker[3] = now.check[3];
}

inline void ncopy ( ) {
	ncheck[0] = checker[0];
	ncheck[1] = checker[1];
	ncheck[2] = checker[2];
	ncheck[3] = checker[3];
}

inline bool check ( int i ) {
	return 0 == ((1<<(i%25)) & checker[i/BASE]);
}

inline void add ( int i ) {
	ncheck[i/BASE] = ((1<<(i%25)) | checker[i/BASE]);
}

inline void insert ( int i, int e, int b ) {
	
	map<int,int>::iterator itr = points[i].find(e);
	if ( itr == points[i].end() ) {
		points[i][e] = b;
		status.push(State(i,e,b));
	} else if ( (*itr).second < b ) {
		(*itr).second = b;
		status.push(State(i,e,b));
	}
}

int main () {


	while ( true ) {
		int n,m,l;
		cin >> n >> m >> l;

		if ( n == 0 )
			break;

		for ( int i=0; i<n; i++ ) {
			for ( int j=0; j<n; j++ ) {
				maps[i][j] = -1;
				off[i][j] = 0;
			}
			points[i].clear();
		}

		for ( int i=0; i<m; i++ ) {
			int a,b,d,e;
			cin >> a >> b >> d >> e;

			maps[a-1][b-1] = maps[b-1][a-1] = d;
			off[a-1][b-1] = off[b-1][a-1] = e;
		}

		for ( int i=0; i<4; i++ ) {
			ncheck[i] = 0;
			checker[i] = 0;
		}

		priority_queue<State, deque<State>, greater<State> > empty;
		status = empty;

		ncheck[0] = 1;
		status.push(State(0,0,l));
		int count = 0;
		while(!status.empty()) {
			State now = status.top();
			status.pop();
			if ( now.where == n-1 ) {
				cout << now.enemy << endl;
				break;
			}

			copy(now);

			for ( int i=0; i<n; i++ ) {
				if ( maps[now.where][i] > 0 ) {
					if ( check( i ) ) {
						ncopy();
						add(i);
						int e, b;
						if ( off[now.where][i] == 0 ) {
							e = now.enemy;
							b = now.budget;
							insert(i,e,b);
						} else {
							if ( now.budget - maps[now.where][i] >= 0 ) {
								e = now.enemy;
								b = now.budget - maps[now.where][i];
								insert(i,e,b);
							}
							e = now.enemy + off[now.where][i];
							b = now.budget;
							insert(i,e,b);
						}
					}
				}
			}
		}
	}
}

		

Measured memory_bytes: 2084