akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
//#include <math.h>
#include <string>
#include <numeric>
#include <queue>
#include <cstdio>
#include <cstring>
#include <cmath>
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<n;++i)
#define mrep(i,n) for(ll i=n;i>=0;--i)
#define all(a) (a).begin(),(a).end()
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vb vector<bool>
#define vvb vector<vector<bool> >
#define pl pair<ll,ll>
#define inf 1001001001001001000
//#define mod 1000000007
#define mod 998244353
#define pi 3.1415926535
using namespace std;
struct __INIT{
    __INIT(){
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout<<fixed<<setprecision(15);
    }
}__init;

//常にindexで管理
struct Doubling{
    vvl next;
    Doubling(vl &nexts){
        ll n = nexts.size();
        ll sz = 1;
        ll now = 1;
        while(now <= inf){
            now *= 2;
            sz++;
        }
        //いけない場所は-1となっている
        next = vvl(n,vl(sz,-1));
        rep(j,sz){
            rep(i,n){
                if(j==0) next[i][j] = nexts[i];
                else{
                    next[i][j] = next[next[i][j-1]][j-1];
                }
            }
        }
    }
    
    //a番目からk解操作
    ll get(ll a,ll k){
        ll now = a;
        ll cnt = 0;
        while(0 < k){
            if((k&1) == 1){
                now = next[now][cnt];
            }
            cnt++;
            k >>= 1;
        }
        return now;
    }
};

int main(void){
    ll n,k;
    cin>>n>>k;
    vl a(n);
    rep(i,n){
        cin>>a[i];
        a[i]--;
    }
    Doubling doub(a);
    cout<<doub.get(0,k)+1<<endl;
}


Measured memory_bytes: 106424
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <climits>
#include <cassert>
#include <algorithm>
#include <utility>

using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<long long int>;
using VVI = vector<vector<long long int> >;
int main(void) {
    Int n;
    cin >> n;
    vector<double> v(n);
    for (Int i = 0; i < n; ++i) {
        cin >> v[i];
    }
    sort(v.begin(), v.end());

    double result = v[0];
    for (Int i = 1; i < n; ++i) {
        result += v[i];
        result /= 2.0f;
    }
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 3840
from collections import deque

N=int(input())
G=[{} for _ in range(N+1)]
for i in range(N-1):
  a,b,c=map(int,input().split())
  G[a][b]=G[b][a]=c
  
def bfs(s):
    seen = [0 for i in range(N+1)]
    d = [0 for i in range(N+1)]
    cross = []
    todo = deque()
    seen[s]=1
    todo.append(s)
    while 1:
      if len(todo)==0:break
      a = todo.popleft()
      for b in G[a].keys():
        if seen[b] == 0:
          seen[b] = 1
          todo.append(b)
          d[b] += d[a] + G[a][b]
    return d

Q,K=map(int,input().split())
d = bfs(K)
for q in range(Q):
  x,y=map(int,input().split())
  print(d[x]+d[y])

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

#define _p(...) (void)printf(__VA_ARGS__)
#define forr(x,arr) for(auto&& x:arr)
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) _rep3(i,0,n)
#define _rep3(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2,)(__VA_ARGS__)
#define _rrep2(i,n) _rrep3(i,0,n)
#define _rrep3(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2,)(__VA_ARGS__)
#define ALL(x) (x).begin(), (x).end()
#define BIT(n) (1LL<<(n))
#define SZ(x) ((int)(x).size())
#define fst first
#define snd second
typedef vector<int> vi;typedef vector<vi> vvi;typedef pair<int,int> pii;typedef vector<pii> vpii;
typedef long long ll;

ll calc(ll w, ll h) {
  //_p("calc(%lld,%lld)\n",w,h);
  if (w == h) return w;
  if (w == 0 || h == 0) return 0;
  ll n = (w-1) / h;
  ll ret = n * h * 2;
  ret += calc(h, w - (n * h));
  return ret;
}

void Main() {
  ll N, X;
  scanf("%lld%lld", &N, &X);

  if (X * 2 == N) {
    _p("%lld\n", X * 3);
    return;
  }

  ll ans;
  if (X * 2 < N) {
    ans = N + 2 * X;
    ans += calc(X, N - X - X);
  }
  else {
    ans = N;
    ans += calc(X, N - X);
  }
  _p("%lld\n", ans);
}
int main() { cin.tie(0); ios::sync_with_stdio(false); Main(); return 0; }


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,ll>
const ll MOD=998244353;
const int INF=1e9;
const double PI=acos(-1);


int main() {
    ios_base::sync_with_stdio(false);

    int n,x,t;
    cin >> n >> x >> t;
    int a=n/x;
    if (n%x>0) ++a;
    cout <<  a*t << endl;

}


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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

#define f first
#define s second
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define pb push_back

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (int i = (b); i >= (a); --i)
#define R0F(i, a) ROF(i, 0, a-1)
#define trav(x, a) for (auto& x: a)

const int MX  = 2e5+5;
const int MOD = 1e9+7;
const ll  INF = 1061109567; // 4557430888798830399LL
const ld  EPS = 1e-9;
const ld  PI  = acos(-1);

ll arr[MX];
unordered_map<ll, ll> mm;

int main() {

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

    int N; cin >> N;

    FOR(i, 1, N+1) cin >> arr[i];
    FOR(i, 1, N+1) {
        mm[i-arr[i]]++;
    }

    ll cnt = 0;
    FOR(i, 1, N+1) {
        cnt += mm[arr[i]+i];
    }

    cout << cnt << "\n";
}


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

int main() {
    // input
    string s;
    cin >> s;

    // solve
    int ans = 0;
    for (int i = 0; i < s.length(); ++i) {
        if (s[i] == '1') ans++;
    }

    // output
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <iostream>

using namespace std;

int main(void) {
  string a;
  int count = 0;
  
  cin >> a;
  
  for (int i = 0; i < 3; i++) {
    if (a[i] == '1') {
      count++;
    }
  }
  
  cout << count << endl;
  
  return 0;
}

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

int MOD = 998244353;

int main(void){

    int N;
    cin >> N;

    int a[N];
    int sum=0;
    long long all=1;
    for(int i=0;i<N;i++){
        cin >> a[i];
        sum += a[i];
        all = (3*all) % MOD;
    }

    vector< vector<long long> > dp1(N+1, vector<long long>(sum+1, 0)), dp2( N+1, vector<long long>(sum+1, 0));
    dp1[0][0] = dp2[0][0] = 1;

    for(int i=0;i<N;i++){
        for(int j=0;j<=sum;j++){
            if( a[i] <= j ){
                dp1[i+1][j] = (dp1[i][j-a[i]] + 2*dp1[i][j]) % MOD;
                dp2[i+1][j] = (dp2[i][j-a[i]] + dp2[i][j]) % MOD;
            }
            else{
                dp1[i+1][j] = 2*dp1[i][j] % MOD;
                dp2[i+1][j] = dp2[i][j] % MOD;
            }
        }
    }

    long long p1=0;
    for(int i=(sum+1)/2;i<=sum;i++){
        p1 = (p1 + dp1[N][i]) % MOD;
    }

    long long p2=0;
    if(sum%2 == 0){
        p2 = dp2[N][sum/2] % MOD;
    }

    long long ans = (all - 3*p1 + 3*p2) % MOD;

    while (ans < 0) {
        ans += MOD;
    }

    cout << ans << endl;
}

Measured memory_bytes: 423744
m = {}
n, k = map(int, input().split())
for j in range(0, n):
    a, b = map(int, input().split())
    m[a] = (m[a] if a in m else 0) + b

i = 0
for a, b in sorted(m.items()):
    i += b
    if i >= k:
        print(a)
        break


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

int main(){
  int h, w;
    cin >> h >> w;
  string g[h];
    for(int i=0; i<h; i++) cin >> g[i];
  vector<int> di, dw;
    for(int i=0; i<h; i++)
      for(int j=0; j<w; j++){
        if(g[i][j]=='#'){
          di.push_back(i);
          break;
        }
      }
      for(int i=0; i<w; i++)
        for(int j=0; j<h; j++){
          if(g[j][i]=='#') {
            dw.push_back(i);
            break;
          }
        }
        for(int i=0; i<di.size(); i++){
          for(int j=0; j<dw.size(); j++){
            cout << g[di[i]][dw[j]];

          }
          cout << endl;
        }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
using namespace std;


int main()
{
    int x,a;
    cin>>x>>a;
    if(x>=a)
        cout<<10<<endl;
    else
        cout<<0<<endl;
    return 0;
}

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

int MX = 1005;
vector<vector<int>> ID(MX,vector<int>(MX,0));
vector<vector<int>> game(MX*(MX-1)/2,vector<int>());
vector<int> in(MX*(MX-1)/2,0);

int id(int i,int j){
    if(i > j) swap(i,j);
    return ID[i][j];
}

int main(){
    int n;
    cin >> n;
    int v = 1;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            ID[i][j] = v++;
        }
    }
    --v;

    vector<vector<int>> a(n,vector<int>(n-1,0));
    rep(i,n)rep(j,n-1){
        cin >> a[i][j];
        a[i][j]--;
    }

    rep(i,n)rep(j,n-2){
        game[id(i,a[i][j])].push_back(id(i,a[i][j+1]));
        in[id(i,a[i][j+1])] ++;
    }

    for(int i=1;i<=v;i++){
        if(in[i] == 0){
            game[0].push_back(i);
            in[i] ++;
        }
    }

    vector<int> day(v+1,0);
    queue<int> q;
    q.push(0);
    while(!q.empty()){
        int now = q.front();
        q.pop();
        for(int next:game[now]){
            in[next] --;
            if(in[next] == 0){
                day[next] = day[now] + 1;
                q.push(next);
            }
        }
    }
    bool ok = true;
    int ans = 0;
    rep(i,v){
        ans = max(ans,day[i+1]); 
        if(day[i+1] == 0){
            ok = false;
            break;
        }
    }
    
    if(ok) cout << ans << endl;
    else cout << -1 << endl;

    return 0;
}



Measured memory_bytes: 39552
package main

import "fmt"

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	v := make([][2]int, m)
	var vm = [50][50]bool{}
	var a, b int
	for i := 0; i < m; i++ {
		fmt.Scan(&a, &b)
		a--
		b--
		v[i] = [2]int{a, b}
		vm[a][b], vm[b][a] = true, true
	}

	ans := 0
	for i := 0; i < m; i++ {
		a, b = v[i][0], v[i][1]
		vm[a][b], vm[b][a] = false, false
		if calc(n, vm) {
			ans++
		}
		vm[a][b], vm[b][a] = true, true
	}
	fmt.Println(ans)
}
func calc(n int, vm [50][50]bool) bool {
	used := make(map[int]bool)
	var dfs func(idx int)
	dfs = func(idx int) {
		if used[idx] {
			return
		}
		used[idx] = true
		for i := 0; i < n; i++ {
			if vm[idx][i] {
				dfs(i)
			}
		}
	}
	dfs(0)

	return len(used) != n
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define nl cout<<'\n';
int main()
{
    string s;
    cin>>s;
    if(s[0]==s[1]||s[2]==s[3]||s[1]==s[2])
      cout<<"Bad";
    else
      cout<<"Good";
    nl;
    return 0;
}


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

int main(){

  string s;
  int ans = 0;

  while(cin >> s){

    for(int i=0;i<s.size();i++){

      int z = 0;

      while(s[i] >= '0' && s[i] <= '9'){
	z *= 10;
	z += s[i] - '0';
	i++;
      }

      ans += z;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 1184
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<set>
#include<complex>
#include<string>
#include<cstring>
using namespace std;
#define rep2(x,from,to) for(long long x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
#define INF 100000000
#define debug(x) cout<<#x<<": "<<x<<endl

#define all(x) x.begin(),x.end()
typedef pair<long long,long long> P;
typedef pair<long long,P> PP;
long long t;
long long n;
long long ans;
long long s;long long a;
long long flag;
int main()
{
	cin>>n;
	s=(long long)sqrt(n);
	for(long long i=1;i<=s;i++)
	{
		if(n%i==0)
		{
		t=n/i;
		ans=1;
		while(1)
		{
			if(t==0)break;
			ans++;
			t/=10;
		}
		if(a==0)
		{
			a=ans;
		}
		else a=min(a,ans);
		}
	}
	cout<<ans-1<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,-1,0,1};

vector<LL> fact;
vector<LL> inver(200001);
 
LL combi(int n,int r){
    if(n<r||n<0||r<0) return 0;
    return fact[n]%mod*inver[n-r]%mod*inver[r]%mod;
}
 
 
LL fpow(LL a, LL n){
    LL x = 1;
    while(n > 0){
        if(n&1){
            x=x*a%mod;
        }
        a=a*a%mod;
        n >>= 1;
    }
    return x;
}
 
void set_combi(){
    LL s=1;
    fact.push_back(1);
    for(int i=1;i<=200000;i++){
        s*=i;
        s%=mod;
        fact.push_back(s);
    }
    inver[200000]=fpow(fact[200000],mod-2);
    for(int i=199999;i>=0;i--){
        inver[i]=inver[i+1]*(i+1)%mod;
    }
}
 
LL hcombi(int n,int r){
    return combi(n+r-1,r); 
}
vector<LL> divi(LL K){
    vector<LL> v;
    for(int i=1;i*i<=K;i++){
        if(K%i) continue;
        v.pb(i);
        v.pb(K/i);
    }
    sort(ALL(v));
    v.erase(unique(ALL(v)),v.end());
    return v;
}

vector<LL> pdivi(LL K){
    vector<LL> v;
    for(int i=2;i*i<=K;i++){
        if(K%i) continue;
        v.pb(i);
        while(K%i==0){
            K/=i;
        }
    }
    if(K!=1) v.pb(K);
    return v;
}




int main(){
    set_combi();
    int n,k;cin >> n >>k;
    for (int i = 1; i <= k; i++) {
        cout << combi(k-1,i-1)*combi(n-k+1,i)%mod << endl;
    }
    return 0;
}


Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  map<int, int> init;
  map<int, int> fin;
  for (int i = 0; i < n; i++){
    cin >> a[i];
    init[a[i]] = i;
  }
  sort(a.begin(), a.end());
  for (int i =0 ; i < n; i++){
    fin[a[i]] = i;
  }
  int ans = 0;
  for (auto it = init.begin(); it != init.end(); it++){
    if (it->second % 2 != fin[it->first] % 2)
      ans++;
  }
  cout << ans/2 << '\n';
  
  return 0;

}



Measured memory_bytes: 9984
///*
#include<iostream>
#include<algorithm>
using namespace std;

int main() {

	int *monster;
	int num, death = 0;
	int min = 0;

	cin >> num;
	monster = new int[num];

	for (int i = 0; i < num; i++) {
		cin >> monster[i];
	}

	sort(monster, monster + num);

	for (int i = 0; death != num - 1; i++) {

		death = 0;

		if (i != 0) {
			while (monster[min] == 0)min++;
			//cout << min << endl;
		}

		for (int i = min + 1; i < num; i++) {
			monster[i] %= monster[min];
		}

		for (int i = 0; i < num; i++) {
			if (monster[i] == 0)death++;
		}

		sort(monster, monster + num);

		//debug
		//for (int i = 0; i < num; i++) {
			//cout << monster[i] << " ";
		//}cout << endl;

	}

	cout << monster[num - 1] << endl;

	return 0;
}
//*/

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
	int n, min, max;
	string s;
	cin >> n;
	
	for(int i=0; i<n; i++){
		cin >> s;
		sort(s.rbegin(),s.rend());
		max = atoi(s.c_str());
		sort(s.begin(), s.end());
		min = atoi(s.c_str());
		cout << max - min << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

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

    cout << 360 / gcd(x, 360) << endl;

    return 0;
}

Measured memory_bytes: 3604
x = gets.chomp.to_s
y = x.split(" ")
a = y[0].to_i
b = y[1].to_i
if a < b then
print ("a"),(" "),("<"),(" "),("b"),("\n")
elsif a > b then
print ("a"),(" "),(">"),(" "),("b"),("\n")
else 
print ("a"),(" "),("=="),(" "),("b"),("\n")
end

Measured memory_bytes: 6096
#include<bits/stdc++.h>
using namespace std;
int n;
int l[25];
int w[25];
int q[25];
int ans;
int main() {
	cin>>n;
	for(int i=1;i<=n;i++) cin>>l[i];
	for(int i=1;i<=n;i++) {
		cin>>w[i];
		ans+=w[i];
	}
	for(int i=1;i<n;i++) cin>>q[i];
	for(int i=1;i<n;i++) if(l[i+1]-l[i]==1) ans+=q[l[i]];
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
typedef long long LL;

//strattime:2017/10/9 21:08
//endtime:2017/10/9 21:11

string str;
int i,n;
int main()
{
	cin>>str;
	n=str.length();
	for(i=0;i<n-8;i++)
		cout<<str[i];
	cout<<endl;
 return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#pragma GCC optimize("Ofast")

// Begin {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T>
inline vector<T> make_v(const T &initvalue, size_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}

constexpr int INF = 0x3f3f3f3f;
constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;
// }}} End

using pii = pair<size_t, size_t>;

vector<pii> G[int(1e4)]; // {node, cost}
size_t N;

vector<size_t> cost(int(1e4), INF);

void dijkstra() {
    priority_queue<pii, vector<pii>, greater<>> que; // {cost, node}
    cost[0] = 0;
    que.emplace(0, 0);

    while (!que.empty()) {
        size_t nowcost = que.top().first;
        size_t nownode = que.top().second;
        que.pop();
        if (cost[nownode] < nowcost) continue;

        for (auto next: G[nownode]) {
            if (chmin(cost[next.first], cost[nownode] + next.second)) {
                que.emplace(cost[next.first], next.first);
            }
        }
    }
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    size_t N; cin >> N;

    for (size_t i = 0; i < N; ++i) {
        size_t u, k; cin >> u >> k;
        for (size_t j = 0; j < k; ++j) {
            size_t v, c; cin >> v >> c;
            G[u].emplace_back(v, c);
        }
    }

    dijkstra();

    for (size_t node = 0; node < N; ++node) {
        cout << node << " " << cost[node] << "\n";
    }

    return 0;
}



Measured memory_bytes: 12136
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int N, X, T;

  std::cin >> N >> X >> T;

  std::cout << (N + X - 1) / X * T << std::endl;

  return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define __ <<' '<<
#define ___ <<' '
#define bash push_back
#define ALL(x) x.begin(),x.end()
//#define int long long

struct IoSetup {IoSetup() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout <<fixed<<setprecision(12);
    cerr <<fixed<<setprecision(12);
}}IoSetup;

using ll = long long;
using pii = pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int SMOD = 1000000007;
constexpr int NMOD = 998244353;
constexpr int dx[]={1,0,-1,0,1,1,-1,-1};
constexpr int dy[]={0,1,0,-1,-1,1,-1,1};

inline bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>bool chmax(T &a, const T &b){return(a<b?a=b,true:false);}
template<class T>bool chmin(T &a, const T &b){return(a>b?a=b,true:false);}
inline int qp(int a,ll b,int mo){ll ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}


signed main() {    

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

    cout << c << endl;
    
  
    return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int N, A, B, C;
  vector<long long int> a_v;
  cin >> N;
  vector<long long int> count_v(1000000, 0);
  for (int i = 0; i < N; i++) {
    long long int a;
    cin >> a;
    a_v.push_back(a);
    count_v[a] += 1;
  }
  long long int max_cnt = 0;
  for (int i = 1; i < 1000000 - 1; i++) {
    if (count_v[i-1] + count_v[i] + count_v[i+1] > max_cnt) {
      max_cnt = count_v[i-1] + count_v[i] + count_v[i+1];
    }
  }
  
  for (int i = 0; i < N; i++) {
    //printf("%d ", count_v[i]);
  }
  cout << max_cnt << endl;
  return 0;
}


Measured memory_bytes: 9208
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
//#include <utility>
#include <set>
#include <iostream>
//#include <memory>
#include <string>
#include <vector>
#include <algorithm>
//#include <functional>
#include <sstream>
//#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
//#include <cctype>
#include <cstring>
//#include <ctime>
#include <iterator>
#include <bitset>
//#include <numeric>
//#include <list>
//#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


namespace{
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}


#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8
static const int INF=1<<24;

void mainmain(){
  int a,b;
  while(cin>>a>>b,a||b){
    rep(i,a){
      int t=i%2;
      rep(j,b){
        if(t%2==0) cout<<"#";
        else cout<<".";
        t++;
      }
      cout<<endl;
    }
    cout<<endl;
  }
}



}
main() try{
    mainmain();
}
catch(...){
}

Measured memory_bytes: 1152
#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() {
    string s;
    cin >> s;

    if (s[2] == s[3] && s[4] == s[5]) puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 256
import java.math.BigInteger;
import java.math.BigDecimal;
import java.util.*;

public class Main {
	public static void main(String[] args)
	{
		BigDecimal N, M;
		Scanner scanner = new Scanner(System.in);
		while(scanner.hasNext())
		{
			N = scanner.nextBigDecimal();
			M = scanner.nextBigDecimal();
			if(N.compareTo(M) == 0) 
				System.out.println("EQUAL");
			else if(N.compareTo(M) > 0)
				System.out.println("GREATER");
			else 
				System.out.println("LESS");
		}
		
	}
}


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

int main () {
    
    int x,y;
    while (1) {
        
        cin >> x;
        cin >> y;
        
        if (x==0 && y==0) {
            break;
        }
        int tmp;
            
        if (x > y) {
            tmp = x;
            x = y;
            y = tmp;
        }
        
        cout << x << " " << y << endl;
    }
}


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

public class Solution
{
    public static void Main()
    {
        var x = int.Parse(Console.ReadLine());
        var rank = 1;
        var th = 1800;
        while (true)
        {
            if (th <= x)
            {
                Console.WriteLine(rank);
                return;
            }
            th -= 200;
            rank++;
        }
    }
}

Measured memory_bytes: 27540
#include<iostream>
#include<cmath>
#include<vector>
#include<queue>
#include<algorithm>
#include <stack>
#include<set>
#include<cstring>
#include <stdio.h>
#include <stdlib.h>
#include <cstdio>
#include <string.h>
#include<iterator>
#include <map>
using namespace std;
// bool cmp(long long a, long long b){
//     return a > b;
// }
int used[205000];
set<long long> sets[205000];
queue<long long> q;
int n;
int a[100500];
int tree[405004];
long long u = 0, d = 0, r = 0, l = 0;
void build_tree(int v, int tl, int tr) {
    if (tl == tr) {
        tree[v] = a[tl];
    } else {
        int tm = (tl + tr) / 2;
        build_tree(v * 2, tl, tm);
        build_tree(v * 2 + 1, tm + 1, tr);
        tree[v] = tree[v * 2] + tree[v * 2 + 1];
    }
}
int get_sum(int l, int r, int v, int tl, int tr) {
    //вариант 1
    if (l <= tl && tr <= r) {
        return tree[v];
    }
    if (tr < l || r < tl) {
        return 0;
    }
    int tm = (tl + tr) / 2;
    return get_sum(l, r, v * 2,     tl,     tm)
           + get_sum(l, r, v * 2 + 1, tm + 1, tr);
}
void update(int idx, int val, int v, int tl, int tr) {
    //вариант 1
    if (idx <= tl && tr <= idx) {    //То же, что и idx == tl == tr
        a[idx] = val;
        tree[v] = val;
        return;
    }
    if (tr < idx || idx < tl) {
        return;
    }
    int tm = (tl + tr) / 2;
    update(idx, val, v * 2,     tl,     tm);
    update(idx, val, v * 2 + 1, tm + 1, tr);
    tree[v] = (tree[v * 2] + tree[v * 2 + 1]) % (long long)(1e9 + 7);
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(0);
    long long t, ch, i, curr, p = 1, x, y, weight, j, k = 0, n, m = 1, ch1, count, ans = 0;
   // long long a, b;
    int fl, fl1, fl2, fl3;
    char s;
//    cin >> t;
    long long c, e, f;
    long long time;
//    for (auto test_case = 0; test_case < t; test_case++) {
        cin >> n >> x >> time;
        ans = ceil((double) n / (double) x) * time;
        cout << ans << endl;
//    }

    return 0;
}
/*2
5
1 1 1 1 1
1
10
 1
 7
5 6 6 1 3 5 4

 */

Measured memory_bytes: 13256
#define MYDEBUG
#include <iostream>
#include <vector>
#include <chrono>
#include <random>
#include <algorithm>
#include <queue>
#include <set>
#include <cstdio>
#include <unordered_map>

#ifdef MYDEBUG
#define debug(x) cout<<#x<<": "<<x<<endl
#else
#define debug(x)
#endif
#define ll long long
#define ull unsigned long long
#define eps 1e-14
#define all(x) x.begin(), x.end()
using namespace std;

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
	out << "[";
	size_t last = v.size() - 1;
	for (size_t i = 0; i < v.size(); ++i) {
		out << v[i];
		if (i != last)
			out << ",";
	}
	out << "]";
	return out;
}

void solve() {
	int k, s;
	cin >> k >> s;
	ll cnt = 0;
	for (int x = 0; x <= k; ++x) {
		for (int y = 0; y <= k; ++y) {
			int z = s - x - y;
			if (z >= 0 && z <= k && (x + y + z) == s) {
				cnt++;
			}
		}
	}
	cout << cnt << endl;
}
int main() {
	solve();
	return 0;
}


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

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr ll MOD = 1000000007;
constexpr ll INF = 1LL << 60;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};
constexpr int H_MAX = 1000;

vector<vector<bool>> a(H_MAX, vector<bool>(H_MAX, true)); 
vector<vector<ll>> dp(H_MAX, vector<ll>(H_MAX, -1LL));

ll dfs(int i, int j) {
    dp[i][j] = 0LL;
    if(i && a[i-1][j]) (dp[i][j] += ((dp[i-1][j] != -1LL)?dp[i-1][j]:dfs(i-1, j))) %= MOD;
    if(j && a[i][j-1]) (dp[i][j] += ((dp[i][j-1] != -1LL)?dp[i][j-1]:dfs(i, j-1))) %= MOD;
    return dp[i][j];
}

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int h, w;
    cin >> h >> w;
    string s;
    for(int i=0;i<h;++i) {
        cin >> s;
        for(int j=0;j<w;++j) {
            if(s[j] == '#') {
                a[i][j] = false;
                dp[i][j] = 0LL;
            }
        }
    }

    dp[0][0] = 1LL;
    cout << dfs(h-1, w-1) << endl;
}


Measured memory_bytes: 8448
import java.util.*;
public class Main{
    public static void main(String[] args)throws Exception{
        Scanner sc = new Scanner(System.in);
        int ans = 0;

        int n;

        n = sc.nextInt();

//        int[] a = new int[n];
//        for(int i = 0;i < n;i++){
//            a[i] = sc.nextInt();
//        }
//

        if(n < 1200)
        System.out.println("ABC");
        else if(n < 2800)
        System.out.println("ARC");
        else
        System.out.println("AGC");
    }
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
const int MOD = 1000000007;
const int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;

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

  int A, B, M;
  cin >> A >> B >> M;
  int Q[A], W[B];
  int minQ = INF, minW = INF;
  rep(i,A){
    cin >> Q[i];
    if(minQ > Q[i]){
      minQ = Q[i];
    }
  }
  rep(i,B){
    cin >> W[i];
    if(minW > W[i]){
      minW = W[i];
    }
  }
  int ans = minQ + minW;
  int a,b,c;
  rep(i,M){
    cin >> a >> b >> c;
    --a; --b;
    ans = min(ans, Q[a] + W[b] - c);
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include<stdio.h>
int main(void){
  int N;
  int K;
  char s[50];
  scanf("%d",&N);
  scanf("%d",&K);
  scanf("%s",&s);
  if(N>=K){
    if(s[K-1]<'a'){
      s[K-1]=s[K-1]+32;
              }else{
        s[K-1]=s[K-1]-32;
      }
    }
  printf("%s\n",s);
  }

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (int)(a) ; i < (int)(b) ; i++)


#define SZ(x) ((int)(x).size())


typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
struct Vector{
    double x, y;
};

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
using namespace std;

bool Kaibun(string s){
    int N = s.length();
    for (int i = 0; i <= (N-1)/2 ; i++)
    {
        if (s[i] != s[N-i-1]) return false;
    }
    return true;

}


int main()
{
    string S, before, after;
    cin >> S;
    int N = S.length();
    if (N % 2 == 0)
        cout << "No" << endl;
    else
    {
        int len = (N-1)/2;
        before = S.substr(0, len);
        after = S.substr(len + 1, len);
        if (Kaibun(S) && Kaibun(before) && Kaibun(after))
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
        
    }
    
    return 0;
}


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

const int INF = 1 << 30;

int dp[100][20];

int solve(int s, int p, const int m, const vector<int>& books)
{
  if (s >= books.size())
    return 0;

  if (p >= m) {
    int sum = 0;
    for (int i = s; i < books.size(); ++i)
      sum += books[i];
    return sum;
  }

  if (dp[s][p] != -1)
    return dp[s][p];

  int res = INF, sum = 0;
  for (int i = s; i < books.size(); ++i) {
    sum += books[i];
    res = min(res, max(sum, solve(i+1, p+1, m, books)));
  }
  return dp[s][p] = res;
}

int main()
{
  int n, m;
  while (cin >> m >> n) {
    if ((n|m) == 0)
      break;

    vector<int> books(n);
    for (int i = 0; i < n; ++i)
      cin >> books[i];

    memset(dp, -1, sizeof(dp));
    cout << solve(0, 0, m-1, books) << endl;
  }
  return 0;
}

Measured memory_bytes: 0
## coding: UTF-8


N, M, Q = map(int,input().split())
lq = []
for i in range(Q):
    lq.append(list(map(int,input().split())))
#print(lq)

dfs = []
for i in range(1, M+1):
    dfs.append([i])
#print(dfs)

def add(l):
    ret = []
    for i in range(len(l)):
        last = l[i][-1]
        for j in range(last, M+1):
            ret.append(l[i] + [j])
    return ret

for i in range(N-1):
    dfs = add(dfs)
#print(dfs)


m = -1
for i in range(len(dfs)):
    A = dfs[i]
    tmp = 0
    for j in range(len(lq)):
        aj = lq[j][0]
        bj = lq[j][1]
        cj = lq[j][2]
        dj = lq[j][3]
        #print('i:{}, j:{}, A:{}, [aj, bj, cj, dj]:{}'.format(i, j, A, lq[j]))
        #print('A[bj-1]:{}, A[aj-1]:{}, A[bj-1]-A[aj-1]:{}, cj:{}, ==?:{}, dj:{}'.format(A[bj-1], A[aj-1], A[bj-1]-A[aj-1], cj,   A[bj-1]-A[aj-1]==cj  , dj))
        #print('i:{}, j:{}, A:{}, lq[j]:{}'.format(i, j, A, lq[j]))
        #print('A[lq[j][i]-1]:{}, A[lq[j][0] - 1]:{}'.format(A[lq[j][i]-1], A[lq[j][0] - 1]))
        #if(A[lq[j][i]-1] - A[lq[j][0] - 1] == lq[2]):
            #tmp += lq[3]
        if(A[bj-1]-A[aj-1] == cj):
            tmp += dj
    #print('i:{}, A:{}, tmp:{}'.format(i, A, tmp))
    if(tmp > m):
        m = tmp    
print(m)

Measured memory_bytes: 109712
/*input
aaaaaaaaaaaaaaab
aaaaaaaaaaaaaaab
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

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

const int MOD = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s, t; cin >> s >> t;
    s += s;
    for(int i = 0; i + t.size() - 1 < s.size(); i++) if(s.substr(i, t.size()) == t)
    {
		cout << "Yes";
		return 0;
    }
    cout << "No";

    return 0;
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<string,int>;

const int MOD = 1e9 + 7;
const int INF = 1001001001;


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

    ll a, b;
    cin >> a >> b;

    if(a <= 0 && b >= 0){
        cout << "Zero" << endl;
    }else if(a > 0){
        cout << "Positive" << endl;
    }else{
        if(((b - a) % 2 == 1 && b < 0)){
            cout << "Positive" << endl;
        }else{
            cout << "Negative" << endl;
        }
    }


    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvl vector<vector<ll>>
#define print(n) cout<<n<<endl
const int M=100111;
const int inf=1000000007;
const long long INF=1000000000000000007;
using ll=long long;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};


int main(){
	int n,W;
	cin>>n>>W;
	int v[M],w[M];
	rep(i,1,n+1)cin>>w[i]>>v[i];
	ll dp[110][M];	//dp[i][j]=k: i番目までで価値がj以上,k=重さ;
	rep(i,0,101)rep(j,0,M)dp[i][j]=INF;
	dp[0][0]=0;
	rep(i,1,n+1)rep(j,0,100001){
		if(j-v[i]>=0)dp[i][j]=min(dp[i-1][j],dp[i-1][j-v[i]]+w[i]);
		else dp[i][j]=dp[i-1][j];
	}
	ll ans=100000;
	while(dp[n][ans]>W)ans--;
	print(ans);
	return 0;
}

Measured memory_bytes: 81280
/*
  AOJ #2798
  title:
  @kankichi573
 */
#include <stdio.h>
#include <string.h>
char seat[102][102];
char sit [102][102];
int M,N;

int main()
{
  int i,j,ret; 

  memset(sit,1,sizeof(sit));
  scanf("%d %d\n",&M,&N);
  for(i=1;i<=M;i++)
    scanf("%s",&seat[i][1]);
  
  for(j=1;j<=N;j++)
    sit[1][j]=0;
  
  for(i=1;i<=M;i++)
    for(j=1;j<=N;j++)
      {
	if(seat[i][j]=='o' || seat[i][j]=='x')
	  sit[i][j]=sit[i][j-1]=sit[i][j+1]=0;
	if(seat[i][j]=='x')
	  sit[i-1][j-1]=sit[i-1][j]=sit[i+1][j]=sit[i-1][j+1]=sit[i+1][j-1]=sit[i+1][j+1]=0;
      }
#ifdef DEBUG
   for(i=1;i<=M;i++)
    {
      for(j=1;j<=N;j++)
      	printf("%c",seat[i][j]);
      printf("\n");
    }
 
  for(i=1;i<=M;i++)
    {
      for(j=1;j<=N;j++)
      	printf("%d",sit[i][j]);
      printf("\n");
    }
#endif
  
  ret=0;
  for(i=1;i<=M;i++)
    for(j=1;j<=N;j++)
      ret += sit[i][j];

  printf("%d\n",ret);
  return(0);
}

Measured memory_bytes: 628
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int n,t;
    cin >> n >> t;
    int C[n], T[n];
    for(int i = 0; i < n;i ++){
        cin >> C[i] >> T[i];
    }
    int mincost = 100000;
    for(int i = 0; i < n; i++){
        if(T[i] <= t){
            if(mincost > C[i]){
                mincost = C[i];
            }
        }
    }
    if(mincost == 100000){
        cout << "TLE" << endl;
    }else{
        cout << mincost << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    ll t,n,m,i;
    cin>>n;
    string a,b;
    cin>>a>>b;
    for(i=0;i<n;i++)
        cout<<a[i]<<b[i];
 }
    


Measured memory_bytes: 3564
n = int(input())
csf = [list(map(int, input().split())) for _ in range(n-1)]

for i in range(n-1):
    t = 0
    for c,s,f in csf[i:]:
        if s > t:
            # 始発を待つ
            t = s
        else:
            # 次発を待つ
            t += (s-t) % f
        t += c
    print(t)
print(0)

Measured memory_bytes: 9228
import java.util.*;
public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int y = sc.nextInt();

     if ( a>=6 && a<=12) {
       System.out.println(y / 2);
     }

     if (a <= 5) {
       System.out.println("0");
     }

     if (a >= 13) {
       System.out.println(y);
     }
  }
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
int main()
{
   int H, W;
   cin >> H >> W;
   vector<vector<bool>> maze(H+2, vector<bool>(W+2, false));
   REP(i, H) {
       string S;
       cin >> S;
       REP(j, W) {
           if(S[j] == '.') {
               maze[i+1][j+1] = true;
           }
       }
   } 
   int max = 0;
   REP(i, H) {
       REP(j, W) {
           if(!maze[i+1][j+1]) continue;
           deque<tuple<int, int, int>> q;
           vector<vector<bool>> used(H+2, vector<bool>(W+2, false));
           q.push_front(make_tuple(i, j, 0));
           used[i+1][j+1] = true;
           while(!q.empty()) {
               int ii = get<0>(q.back());
               int jj = get<1>(q.back());
               int nn = get<2>(q.back());
               //cout << ii << " " << jj << " " << nn << endl; 
               q.pop_back();
               if(nn > max) max = nn;
               if(maze[ii][jj+1] && !used[ii][jj+1]) {
                   q.push_front(make_tuple(ii-1, jj, nn+1));
                    used[ii][jj+1] = true;
               }
               if(maze[ii+2][jj+1] && !used[ii+2][jj+1]) {
                   q.push_front(make_tuple(ii+1, jj, nn+1));
                   used[ii+2][jj+1] = true;
               }
               if(maze[ii+1][jj] && !used[ii+1][jj]) {
                   q.push_front(make_tuple(ii, jj-1, nn+1));
                   used[ii+1][jj] = true;
               }
               if(maze[ii+1][jj+2] && !used[ii+1][jj+2]) {
                   q.push_front(make_tuple(ii, jj+1, nn+1));
                   used[ii+1][jj+2] = true;
               }
           }
       }
   }
    cout << max << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<set>
#include<map>
#include<deque>
#include<string>
#include<stdio.h>
using namespace::std;
#define int long long
vector<int> v;
vector<int> d;
int n, k;
 
signed main()
{
	cin >> n>>k;
	v.resize(n);
	d.resize(k+1);
	for (int i = 0; i < n; i++)
	{
		int a;
		cin >> a;
		v[i] = a;
	}
	 
	for (int i = 0; i <= k; i++)
	{
		for (int j = 0; j < n; j++)
		{
			if (i + v[j] > k)
				continue;
			int f = v[j];
			d[i + f] = (max(d[i+f],(d[i] +1)%2));
		}
	}
	if (d[k])
		cout << "First";
	else
		cout << "Second";
cin >> n;
}
/*
2 3

0 - 0
1 - 0
2 - 1
3 - 1
4 - 1
5 - 0

*/






Measured memory_bytes: 1024
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long power = 1;
        for(int i = 1;i <= N;i++){
            power *= i;
            power %= 1000000007;
        }
        System.out.println(power);
    }
}


Measured memory_bytes: 23636
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.nextLine());
        int[] h = new int[n];

        String[] nums = sc.nextLine().split(" ");
        for (int i = 0; i < n; i++) {
            h[i] = Integer.parseInt(nums[i]);
        }

        for (int i = 0; i < n; i++) {
            if (i >= 1  && h[i - 1] > h[i]) {
                System.out.print("No");
                return;
            }

            if (i == 0) {
                if (h[i] - 1 >= 1) {
                    h[i] -= 1;
                }
            } else if (h[i - 1] < h[i]) {
                h[i] -= 1;
            }
        }
        System.out.print("Yes");
    }
}

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

int N, S;
int main() {
    while(cin >> N && N > 0) {
        int sum = 0;
        int maxi=0, mini=1000000;
        for (int i=0; i<N; ++i) {
            cin >> S;
            sum += S;
            if (S > maxi) {
                maxi = S;
            }
            if (S < mini) {
                mini = S;
            }
        }
        double ans = (sum - maxi - mini) / (N - 2);
        cout << ans << endl;
    }
}


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

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<string> vs;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    cout << fixed << setprecision(15);

    int N;
    cin >> N;


    int k = 1;
    while ((k * (k - 1)) / 2 < N)
        k++;

    if (k * (k - 1) / 2 != N) {
        cout << "No\n";
        return 0;
    }

    cout << "Yes\n";

    vvi res(k);
    int v = 1;
    for (int i = 0; i < k; i++) {
        for (int j = i + 1; j < k; j++) {
            res[i].push_back(v);
            res[j].push_back(v);
            v++;
        }
    }

    cout << k << "\n";
    for (int i = 0; i < k; i++) {
        cout << res[i].size();
        for (int v : res[i])
            cout << " " << v;
        cout << "\n";
    }

    return 0;
}



Measured memory_bytes: 2304
N, A, B = map(int, input().split())

# まずN <= 10**4だからO(N)で間に合う
ans = 0
for i in range(1, N+1):
    num = 0
    if i < 10:  # 1桁
        num = i
    elif i < 10**2:
        ii = i
        for j in [10, 1]:
            a = ii // j
            num += a
            ii -= a * j
    elif i < 10**3:
        ii = i
        for j in [10**2, 10, 1]:
            a = ii // j
            num += a
            ii -= a * j
    elif i < 10**4:
        ii = i
        for j in [10**3, 10**2, 10, 1]:
            a = ii // j
            num += a
            ii -= a * j
    else:  # i == 10**4
        ii = i
        for j in [10**4, 10**3, 10**2, 10, 1]:
            a = ii // j
            num += a
            ii -= a * j
    
    if A <= num and num <= B:
        ans += i

print(ans)

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

int main()

{
   long long a=0,b=0,c,d,e,f,g,h,i,j,k,l,m,n,t;

   cin>>n; long long ar[n];

   for(i=0;i<n;i++)
   {
       cin>>ar[i];

       if(ar[i]%2==1) a++;
   }

   if(a%2==0) cout<<"YES"<<endl;

   else if(a%2==1) cout<<"NO"<<endl;
}


Measured memory_bytes: 4376
(let* ((n (read))
       (d (read))
       (x (make-array (list n d) :initial-element 0))
       (ans 0))
  (loop :for i :from 0 :to (1- n)
        :do (loop :for k :from 0 :to (1- d)
                  :do (setf (aref x i k) (read))))
  (loop :for i :from 0 :to (- n 2)
        :do (loop :for j :from (1+ i) :to (1- n)
                  :do (let ((l (sqrt (loop :for k :from 0 :to (1- d)
                                           :for _ := (- (aref x i k) (aref x j k))
                                           :sum (* _ _)))))
                        (when (= l (floor l))
                          (incf ans)))))
  (format t "~A~%" ans))


Measured memory_bytes: 24660
while True:
    (m, f, r) = [int(i) for i in input().split()]
    if m == f == r == -1:
        break

    total = m + f
    if m == -1 or f == -1 or total < 30:
        print('F')
    elif total < 50 and r < 50:
        print('D')
    elif total < 65:
        print('C')
    elif total < 80:
        print('B')
    else:
        print('A')

Measured memory_bytes: 6720