akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.Collections.Generic;

namespace AtCoder.Contests.ABC161
{
    /// <summary>
    /// 
    /// </summary>
    static class E
    {
        static void Main(string[] args)
        {
            var n = NextInt();
            var k = NextInt();
            var c = NextInt();
            var s = Next();

            var kf = new int[k];
            var kb = new int[k];

            var days = 0;
            for (int i = 0; i < n; i++)
            {
                if (s[i] == 'x') continue;
                if (days == k) break;
                kf[days++] = i;
                i += c;
            }
            days = k-1;
            for (int i = n - 1; i >= 0; i--)
            {
                if (s[i] == 'x') continue;
                if (days == -1) break;
                kb[days--] = i;
                i -= c;
            }

            for (int i = 0; i < k; i++)
            {
                if (kf[i] == kb[i]) Console.WriteLine(kf[i] + 1);
            }
        }

        #region Console
        static int _index = 0;
        static string[] _buffer;

        static string Next()
        {
            if (_buffer == null || _index >= _buffer.Length)
            {
                _buffer = Console.ReadLine().Split();
                _index = 0;
            }

            return _buffer[_index++];
        }
        static int NextInt()
        {
            return int.Parse(Next());
        }
        static long NextLong()
        {
            return long.Parse(Next());
        }
        static int ReadInt()
        {
            return int.Parse(Console.ReadLine());
        }
        static long ReadLong()
        {
            return long.Parse(Console.ReadLine());
        }
        static int[] ReadIntArray()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }
        static int[] ReadIntArray(int n)
        {
            var a = new int[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = ReadInt();
            }
            return a;
        }
        static long[] ReadLongArray()
        {
            return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        }
        static long[] ReadLongArray(int n)
        {
            var a = new long[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = ReadLong();
            }
            return a;
        }
        static List<T> ReadObjects<T>(int n, Func<int[], T> creator)
        {
            var l = new List<T>(n);

            for (int i = 0; i < n; i++)
            {
                var a = ReadIntArray();
                l.Add(creator(a));
            }

            return l;
        }

        static int[,] ReadMatrix(int n, int m)
        {
            var r = new int[n, m];
            for (int i = 0; i < n; i++)
            {
                var a = ReadIntArray();
                for (int j = 0; j < m; j++)
                {
                    r[i, j] = a[j];
                }
            }
            return r;
        }
        #endregion
    }
}


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

int main() {
  int N, D; cin >> N >> D;
  vector<vector<int>> X(N, vector<int>(D));
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < D; ++j) {
      cin >> X[i][j];
    }
  }
  int ans = 0;
  for (int i = 0; i < N; ++i) {
    for (int j = i+1; j < N; ++j) {
      int norm = 0;
      for (int k = 0; k < D; ++k) {
        int diff = abs(X[i][k] - X[j][k]);
        norm += diff * diff;
      }

      // check whether norm = k for some k
      bool flag = false;
      for (int k = 0; k <= norm; ++k) {
        if (k * k == norm) {
          flag = true;
        }
      }
      if (flag) ++ans;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define rev(a,b,c) for(int a=b;a>=c;a--)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define en end()
#define F first
#define S second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define get(a) cin>>a
#define nextl cout<<"\n"
#define deb(x) cout<<#x<<"="<<x<<"\n";
const ll mod = 1000000007;
const ll maxn = 500005;
const ll mm = 1e+18;
ll power(ll x, ll y)
{
    ll res = 1;
    x = x % mod;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % mod;
        y = y>>1;
        x = (x*x) % mod;
    }
    return res;
}
ll ncr(ll n, ll k)
{
    ll C[k+1];
    memset(C, 0, sizeof(C));

    C[0] = 1;

    for (ll i = 1; i <= n; i++)
    {
        for (ll j = min(i, k); j > 0; j--)
            C[j] = (C[j] + C[j-1])%mod;
    }
    return C[k];
}
void solve()
{
    int n,m;
    cin>>n>>m;
    vector<string>v[n+1];
    rep0(i,m){
        int x;
        cin>>x;
        string s;
        cin>>s;
        v[x].pb(s);
    }
    int an=0;
    int pe=0;
    rep1(i,n){
        int ok=v[i].si;
        int j=0;
        while(j<ok&&v[i][j]=="WA") j++;
        if(j==ok) continue;
        an++;
        pe+=j; 
    }
    pr2(an,pe);
}
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
       // nextl;
    }
    return 0;
}


Measured memory_bytes: 10368
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        D solver = new D();
        solver.solve(1, in, out);
        out.close();
    }

    static class D {
        static final int MOD = (int) 1e9 + 7;
        private static int MAX = 400000;
        private static long[] xs = new long[MAX + 1];
        private static long[] ys = new long[MAX + 1];

        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = in.nextInt();
            int K = in.nextInt();

            for (int i = 1; i <= K; i++) {
                long ans = comb(N - K + 1, i) * comb(K - 1, i - 1) % MOD;
                out.println(ans);
            }
        }

        private long comb(int n, int r) {
            if (r < 0 || r > n) return 0;
            if (xs[0] == 0) {
                xs[0] = 1;
                for (int i = 1; i <= MAX; i++) {
                    xs[i] = xs[i - 1] * i % MOD;
                }
                long inv = modpow(xs[MAX]);
                ys[MAX] = inv;
                for (int i = MAX; i >= 1; i--) {
                    inv = inv * i % MOD;
                    ys[i - 1] = inv;
                }
            }
            return xs[n] * (ys[r] * ys[n - r] % MOD) % MOD;
        }

        private long modpow(long a) {
            return modpow(a, MOD - 2);
        }

        private long modpow(long a, long n) {
            long r = 1;
            while (n > 0) {
                r = r * ((n % 2) != 0 ? a : 1) % MOD;
                a = a * a % MOD;
                n >>= 1;
            }
            return r;
        }

    }
}



Measured memory_bytes: 27988
def main():
    S = input()
    length = len(S)
    loop_count = length // 2
    count = 0

    for i in range(loop_count):
        if(S[i] != S[length - i -1]):
            #print(S[i],"==",S[loop_count - i -1])
            count += 1

    print(count)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
import std.stdio;
import std.string;
import std.conv;

void main() {
	string[] inputs = split(readln());
	int A = to!int(inputs[0]);
	int B = to!int(inputs[1]);
	int C = to!int(inputs[2]);
	
	if(A == B) writeln(C);
	else if(A == C) writeln(B);
	else writeln(A);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define deb(x) cout<<x<<"\n";
#define deb(x,y) cout<<x<<" "<<y<<"\n";
#define deb(x,y,z) cout<<x<<" "<<y<<" "<<z<<"\n";
#define ok cout<<"OK";
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    ll a,b,n,m,o;
    cin>>a>>b>>n>>m>>o;
    ll ar[max({n,m,o})];
    ll i=0;
    while(i<n)
    cin>>ar[i++];
    sort(ar,ar+n);
    i=0;
    vector<ll> v;
    while(i<a)
    {
        v.pb(ar[n-1-i]);
        i++;
    }
    i=0;
    while(i<m)
        cin>>ar[i++];
    sort(ar,ar+m);
    i=0;
    while(i<b)
    {
        v.push_back(ar[m-1-i]);
        i++;
    }
    while(o--)
    {
        cin>>n;
        v.push_back(n);
    }
    sort(v.begin(),v.end());
    ll sum=0;
    i=0;
    while(i<a+b)
    {
        sum+=v[v.size()-1-i];
        i++;
    }
    cout<<sum;
}


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

//C++14 (GCC 5.4.1)

#define LLINF (1LL<<60)
typedef long long ll;
#define mod 1000000007

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define rrepd(i,a,b) for(int i=(a);i>=(b);i--)

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

template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); }

#define dbg_v1(i,V) do{cout<<"-v1----\n";rep(i,V.size())cout<<" "<<i<<"\t:"<<V[i]<<endl;cout<<endl;}while(0)
#define dbg_v2(i,k,V) do{cout<<"-v2----\n";rep(i,V.size()){rep(k,V[0].size())cout<<" "<<V[i][k];cout<<endl;}}while(0)
#define lower_bound_idx(V,c) distance(V.begin(),lower_bound(V.begin(),V.end(),c))

int main() {
    ios::sync_with_stdio(false);//stdoutとcoutの同期解除
    cin.tie(nullptr);//cinとcoutの同期解除
    
    int N;
    string S;
    cin >>N>>S;
    vector<vector<int>> nms(10,vector<int>(N,0));
    vector<int> ls(1000,0);

    nms[S[N-1]-'0'][N-1]++;
    rrepd(i,N-1,1){
        rep(j,10)nms[j][i-1]=nms[j][i];
        nms[S[i-1]-'0'][i-1]++;
    }
    //dbg_v2(i,k,nms);
    int x=0,y;
    ll ans=0;
    rep(i,N-2){
        x=(S[i]-'0')*100;

        rep(t,10){
            if(nms[t][i+1]>0){
                int k=i+1;
                while(k<N-2 && nms[t][k]==nms[t][k+1])k++;
                if(nms[t][k]==nms[t][k+1])continue;
                rep(u,10){
                    if(nms[u][k+1]>0){
                        ls[x + t*10 +u ]++;
                        //cout<<x + t*10 +u<<endl;
                    }
                }
            }
        }
    }
    rep(i,1000)if(ls[i]>0)ans++;

    cout <<ans<<endl;
    return (0);
}

Measured memory_bytes: 1664
#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
const long long INF = 1e18;
const long long MOD = 1e9 + 7;
const double pi = acos(-1);
const int SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
long long fac[100005], finv[100005], inv[100005];

long long dp[100005];
int main() {
	int a, b;
	cin >> a >> b;
	long long k[105], l[105];
	for (int i = 1; i <= a; ++i) {
		cin >> k[i] >> l[i];
	}
	for (int i = 1; i <= a; ++i) {
		for (int j = b; j >= k[i]; --j) {
			dp[j] = max(dp[j], dp[j - k[i]] + l[i]);
		}
	}
	cout << dp[b] << endl;
}

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

ll f(ll a) {
    ll res[] = {a, 1, a+1, 0};
    return res[a%4];
}

ll getXor(ll a, ll b) {
    return f(b) ^ f(a-1);
}

int main() 
{ 
	ll l, r;
	cin >> l >> r;
	cout << getXor(l, r) << "\n";
	return 0; 
} 


Measured memory_bytes: 256
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n = INT()
ans = 0
for x in product([0, 3, 5, 7], repeat=9):
    y = 0
    for i in range(9):
        y += x[8-i] * 10**i
    if y > n:
        break
    if str(y).count('0') == 0 and x.count(3) > 0 and x.count(5) > 0 and x.count(7) > 0:
        ans += 1
print(ans)

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

int main(){
int N;
string S;
cin >>N;
cin >>S;
N=N%26;
rep(i,S.size()){
    if(S[i]+N<91)printf("%c", S[i]+N);
    if(S[i]+N>90)printf("%c", S[i]+N-26);
}

printf("\n");
    return 0;
}

Measured memory_bytes: 256
// #define DEBUGGING
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()

template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
using ll = int64_t;
using ull = uint64_t;
using PLL = pair<ll, ll>;

template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return max(low, min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { t = clamp(t, low, high); }

namespace init__ {

struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

}

#ifdef DEBUGGING
// #include "../debug/debug.cpp"
#include "../../debug/debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

template <typename T>
T make_v(T init) { return init; }

template <typename T, typename... Tail>
auto make_v(T init, size_t s, Tail... tail) {
#define rec make_v(init, tail...)
    return V<decltype(rec)>(s, rec);
#undef rec
}

int main() {
    string S;
    cin >> S;
    ll cur_idx = 0;
    S += '0';
    ll ans = 0;
    for(ll i = 1; i < S.size(); i++) {
        if(S[i] == S[cur_idx]) continue;
        ll len = i - cur_idx;
        ll mod = len % 3;
        ans += (len / 3) * 2 + !!mod;
        cur_idx = i;
        if(mod == 2 && i + 1 < S.size()) {
            ans++;
            cur_idx++;
        }
        DEBUG(make_tuple(i, ans));
    }
    cout << ans << endl;
    return 0;
}


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


int main () {
    int a, b ;
    cin >> a >> b ;
    cout << max(a*b, max(a+b,a-b)) << endl ;
} 

Measured memory_bytes: 3604
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
#define ll long long
ll n,v,a[2000005],sta[2000005],l[20][400005],r[20][400005],L[2000005],R[2000005],ans[2000005],top;
int main(){
	scanf("%lld%lld",&n,&v);
	for(ll i=1;i<=n;i++) scanf("%lld",&a[i]);
	ll m=v;
	while(m) m>>=1,sta[top++]=m;
	sta[top]=v;
	for(ll i=0;i<=top;i++){
		l[i][1]=1;r[i][n]=n;
		for(ll t=2;t<=n;t++) l[i][t]=(a[t]-a[t-1]<=sta[i])?l[i][t-1]:t;
		for(ll t=n-1;t>=1;t--) r[i][t]=(a[t+1]-a[t]<=sta[i])?r[i][t+1]:t;
	}
	for(ll i=0;i<1<<top;i++) R[i]=n+1;
	for(ll i=0;i<1<<top;i++){
		for(ll t=0;t<=top;t++){
			if((i>>t)&1)continue;
			L[(1<<t)|i]=max(L[(1<<t)|i],r[t][L[i]+1]);
			R[(1<<t)|i]=min(R[(1<<t)|i],l[t][R[i]-1]);
		}
	}
	for(ll i=1;i<=n;i++){
		ll fg=0;
		for(ll t=0;t<1<<top;t++){
			ll ano=((1<<top)-1)^t;
			if(L[t]>=i-1&&R[ano]<=r[top][i]+1){fg=1;break;}
		}
		for(ll t=i;t<=r[top][i];t++) ans[t]=fg;
		i=r[top][i];
	}
	for(ll i=1;i<=n;i++){
		if(ans[i]) printf("Possible\n");
		else printf("Impossible\n");
	}
}

Measured memory_bytes: 74520
n = int(input())
a = list(map(int,input().split()))
ans = 100000
for i in range(n):
  now = a[i]
  if now % (2**ans) != 0:
    count = 0
    while True:
      if now % 2 != 0:
        break
      now //= 2
      count += 1
    ans = count
print(ans)

Measured memory_bytes: 3444
#include <stdio.h>
#include <string.h>

int main(void)
{
  char s[1200];
  int cnt[26] = {0};
  int len = 0;
  int i;

  while(1){
    if(fgets(s, sizeof s,stdin) == NULL)
      break;
         
  len = strlen(s);
       
  for(i = 0; i < len; i++)
    if(s[i] >= 'a' && s[i] <= 'z')
      cnt[s[i] - 'a']++;
    else if(s[i] >= 'A' && s[i] <= 'Z')
      cnt[s[i] - 'A']++;
  }

  for(i = 0; i < 26; i++)
    printf("%c : %d\n", 'a' + i, cnt[i]);

  return 0;
}

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

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

Measured memory_bytes: 256
// agc014_b
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N, M;
    cin >> N >> M;
    vector<int> A(M), B(M);
    REP(i, M) cin >> A[i] >> B[i];

    map<int, int> cnt;
    REP(i, M){
        cnt[A[i]]++;
        cnt[B[i]]++;
    }

    bool is_valid = true;
    for (auto e: cnt){
        if (e.second % 2 != 0){
            is_valid = false;
            break;
        }
    }

    if (is_valid){
        print("YES");
    } else {
        print("NO");
    }



    return 0;
}


Measured memory_bytes: 5120
#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>

using namespace std;

#define F(i , a , b) for(int (i) = (a) ; (i) <= (b) ; (i)++)
#define pb push_back
#define ll long long
#define E(a) cerr << #a << " = " << a << '\n'
#define X first
#define Y second
#define INF 10000000000000

const int MAX_N = 100000 + 10 , mod = 1000000007;


string s;
int t;

int32_t main(){

    //    freopen("input.txt" , "r" , stdin);
    //    freopen("output.txt" , "w" , stdout);
    //    cout << setprecision(10) << fixed;

    cin >> s;
    if(s[0] == s[s.length()-1]) t++;
    if(s.length()%2 == 0) t++;
    if(t%2) cout << "Second";
    else cout << "First";



    return 0;
}


Measured memory_bytes: 760
#![allow(unused_imports)]
use proconio::*;

fn main() {
   input! {
      n: usize,
      m: usize,
      lh: [(i64, i64, i64); n],
      lv: [(i64, i64, i64); m],
   }
   let mut mpx = std::collections::BTreeMap::new();
   let mut mpy = std::collections::BTreeMap::new();
   mpx.insert(0, 0);
   mpy.insert(0, 0);
   for &(a,b,c) in lh.iter() {
      mpx.entry(a).or_insert(0);
      mpx.entry(b).or_insert(0);
      mpy.entry(c).or_insert(0);
   }
   for &(d,e,f) in lv.iter() {
      mpx.entry(d).or_insert(0);
      mpy.entry(e).or_insert(0);
      mpy.entry(f).or_insert(0);
   }
   let mut xs = vec![];
   let mut ys = vec![];
   for (x, c) in mpx.iter_mut() {
      *c = xs.len();
      xs.push(*x);
   }
   for (y, c) in mpy.iter_mut() {
      *c = ys.len();
      ys.push(*y);
   }

   let h = xs.len()*2;
   let w = ys.len()*2;
   let mut g = vec![vec![0; w]; h];
   for (a,b,c) in lh.iter() {
      let a = mpx.get(a).unwrap()*2;
      let b = mpx.get(b).unwrap()*2;
      let c = mpy.get(c).unwrap()*2;
      for x in a..=b {
         g[x][c] = -1;
      }
   }
   for (d,e,f) in lv.iter() {
      let d = mpx.get(d).unwrap()*2;
      let e = mpy.get(e).unwrap()*2;
      let f = mpy.get(f).unwrap()*2;
      for y in e..=f {
         g[d][y] = -1;
      }
   }
   let mut q = std::collections::VecDeque::new();
   let sx = mpx.get(&0).unwrap()*2;
   let sy = mpy.get(&0).unwrap()*2;
   q.push_back((sx, sy));
   while let Some((x, y)) = q.pop_front() {
      for i in 0..4 {
         let nx = x as i32+ dx[i];
         let ny = y as i32+ dy[i];
         if nx < 0 || h as i32 <= nx {
            continue;
         }
         if ny < 0 || w as i32 <= ny {
            continue;
         }
         let nx = nx as usize;
         let ny = ny as usize;
         if g[nx][ny] != 0 {
            continue;
         }
         g[nx][ny] = 1;
         q.push_back((nx, ny));
      }
   }

   let mut ans: i64 = 0;
   for x in 0..h {
      for y in 0..w {
         if g[x][y] != 1 {
            continue;
         }
         if x == 0 || x == h-1 || y == 0 || y == w-1 {
            println!("INF");
            return;
         }
         if x%2 == 0 || y%2==0 {
            continue;
         }
         let ex = xs[x/2+1] - xs[x/2];
         let ey = ys[y/2+1] - ys[y/2];
         ans += ex*ey;
      }
   }
   println!("{}", ans);
}

const dx: [i32; 4] = [1, 0, -1, 0];
const dy: [i32; 4] = [0, 1, 0, -1];


Measured memory_bytes: 143232
a,b,c, = map(int,input().split())
k = int(input())

while 0 <= k:
    if a < b < c:
        print ("Yes")
        exit ()
    elif a >= b:
        b *= 2
    elif b >= c:
        c *= 2
    else:
        pass
    k -= 1
print ("No")


Measured memory_bytes: 9100
#include <iostream>
typedef long long ll;
using namespace std;

int main() {
    ll A, B, C, K, ans;
    cin >> A >> B >> C >> K;

    ans = A-B;
    if(ans > 10e18) {
        cout << "Unfair" << endl;
        exit(0);
    }
    if(K%2 != 0) ans = -ans;    // odd case
    cout << ans << endl;
}

Measured memory_bytes: 3144
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<string>
#include<set>
#include<tuple>
#include<utility>
#include<functional>
#include<algorithm>

#define LL long long

using namespace std;

int k[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

int main() {
	int n;
	cin>>n;
	cout<<k[n-1]<<endl;

	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MAXN 200005
#define mod 1000000007
using namespace std;
long long a[MAXN];
int zs = 0,fs = 0;
bool cmp(int a,int b) {
	return a < b;
}
int main() {
	int n,k; scanf("%d%d",&n,&k);
	for(int i = 1;i <= n;i ++) scanf("%lld",&a[i]); 
	sort(a + 1,a + 1 + n,cmp);
	for(int i = 1;i <= n;i ++) {
		if(a[i] < 0) fs ++;
		else zs ++;
	}
	if(fs == n) {
		long long sum = 1;
		if(k % 2) for(int i = n;i >= n - k + 1;i --) sum = (sum % mod * a[i] % mod) % mod;
		else for(int i = 1;i <= k;i ++) sum = (sum % mod * a[i] % mod) % mod;
		printf("%lld",(sum % mod + mod) % mod);
		return 0;
	}
	else if(n == k) {
		long long sum = 1;
		for(int i = 1;i <= n;i ++) sum = (sum % mod * a[i] % mod) % mod;
		printf("%lld",(sum % mod + mod) % mod);
		return 0;
	}
	else {
		long long sum = 1;
		int l = 1,r = n,tot = 0;
		while(tot < k) {
			if(tot != k - 1 && a[l] * a[l + 1] >= a[r] * a[r - 1]) {
				sum = (sum % mod * a[l] % mod * a[l + 1] % mod) % mod;
				l += 2;
				tot += 2;
			}	
			else {
				if(a[r] >= 0) {
					sum = (sum % mod * a[r] % mod) % mod;
					r --;
					tot ++;
				}
				else {
					sum = (sum % mod * a[r] % mod * a[r - 1] % mod) % mod;
					r -= 2;
					tot += 2;
				}
			}
		}
		printf("%lld",(sum % mod + mod) % mod);
		return 0;
	}
}


Measured memory_bytes: 5412
#include <vector>
#include <list>
#include <map>
#include <string>
#include <iostream>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <utility>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
const ll mod = 1000000007;

ll solve(void);

int main(void)
{
	while (solve())
	{
	}
	return 0;
}

ll solve(void)
{
	ll A, B;
	cin >> A >> B;

	cout << ( (A < 10 && B < 10) ? A * B : -1) << endl;

	return 0;
}



Measured memory_bytes: 256
program sample
    implicit none
    character(100)::s,t
    integer(8) :: i,j,k,m,n,ans
    integer(8)::a,b,c,d
    integer(8),allocatable::x(:),y(:)
  
    read(*,*) n,m
    ans=0
    allocate(x(n),y(n))
    do i=1,n

        read(*,*)x(i),y(i)
    end do
    call m2sort(x,y)
    do i=1,n
        if(y(i)<m)then
            ans=ans+x(i)*y(i)
            m=m-y(i)
        else
            ans=ans+x(i)*m
            write(*,*)ans
            stop
        end if
    end do


        stop
        contains
        recursive subroutine m2sort(x,y)
    implicit none
    integer(8), intent(inout) :: x(:),y(:)
 
    integer(8) :: n, mid, i, j, k
    integer(8), allocatable :: tmp(:),tmp2(:)
    
    n = size(x)
    
    if(n == 1) then
      return
    end if
 
    !
    ! 前半と後半に分けてソート
    ! 1~midとmid+1~nをそれぞれソート済みにする
    !
    mid = n / 2
    call m2sort(x(:mid),y(:mid))
    call m2sort(x(mid+1:),y(mid+1:))
 
    !
    ! tmpという配列にxを一時的に保管
    ! マージソートは外部ソート
    !
    allocate(tmp(n),tmp2(n))
    tmp(:) = x(:)
    tmp2(:)=y(:)
    ! tmpの後半部分を左右反転
    do k = n, mid+1, -1
      tmp(k) = x(mid + n - k + 1)
      tmp2(k) = y(mid + n - k + 1)
    end do
 
    ! iは前半のリストのうちまだ見ていないものの最小値
    ! jは後半のリストのうちまだ見ていないものの最小値
    ! kは見た回数の合計
    i = 1
    j = n
 
    do k = 1, n
      !
      ! 一番左と一番右のうち小さい方をxに入れていく
      ! ここが等号つき不等号なので、安定ソートとなる
      !
      if(tmp(i) <= tmp(j)) then
        x(k) = tmp(i)
        y(k)=tmp2(i)
        i = i + 1
      else
        x(k) = tmp(j)
        y(k)=tmp2(j)
        j = j - 1
      end if
    end do
    
    deallocate(tmp,tmp2)
    return
  end subroutine m2sort
end program sample
  



Measured memory_bytes: 5628
N, M = map(int, input().split())
mod = 10**9 + 7

fact = [1] * (M+1)
fact_inv = [1] * (M+1)
for i in range(1, M+1):
    fact[i] = i * fact[i-1] % mod
fact_inv[M] = pow(fact[M], mod-2, mod)
for i in range(1, M+1)[::-1]:
    fact_inv[i-1] = i * fact_inv[i] % mod
comb = lambda n, k: fact[n] * fact_inv[k] * fact_inv[n-k] % mod

ans = comb(M, N) * fact[N] % mod
for k in range(1, N+1):
    ans += (-1)**k * comb(N, k) * fact[M-k] * fact_inv[M-N] % mod
    ans %= mod
ans = ans * comb(M, N) * fact[N] % mod
print(ans)


Measured memory_bytes: 83268
i,k,n,m,a[1001],c[1001];main(){for(scanf("%d%d",&n,&m);i<n;scanf("%d",a+i++));for(;m--;k=0){scanf("%d",&i);for(;k<n;k++)if(a[k]<=i)c[k]++,k=n;}for(;--n+1;)if(c[n]>k)k=c[n],i=n;i=!printf("%d\n",i+1);}

Measured memory_bytes: 604
def ok?(s, t)
  (t.chars.uniq - s.chars.uniq).empty?
end

s = gets.chomp
t = gets.chomp

if !ok?(s, t)
  p -1
  exit
end

pos = Hash.new{|h,k| h[k]=[]}
s.each_char.with_index do |c, i|
  pos[c] << i
end
l = 0
prev_i = pos[t[0]][0]
t[1..-1].each_char do |c|
  j = pos[c].bsearch{|x| x > prev_i}
  prev_i = j || pos[c][0]
  l += 1 if !j
end

p s.size * l + (prev_i + 1)





Measured memory_bytes: 17532
program atcoder_contest_scheduling
  implicit none
  integer :: d, c(26) = 0, s(26, 365) = 0, t(365) = 0, u(365), m, n, p, q, i
  real(8) :: t1, t2
  call cpu_time(t1)
  call random_seed_clock()
  read(*,*) d
  read(*,*) c
  read(*,*) (s(:, i), i = 1, d)
  t = [(mod(i - 1, 26) + 1, i = 1, d)]
  m = score()
  u = t
  do
    p = next_int(365)
    q = next_int(26)
    t(p) = q
    n = score()
    if (m < n) then
      m = n
      u(p) = q
    else
      t(p) = u(p)
    end if
    call cpu_time(t2)
    if (t2 - t1 > 1.975d0) exit
  end do
  write(*,'(i0)') (u(i), i = 1, d)
contains
  integer function score() result(res)
    integer :: last(26), i
    last = 0
    res = 0
    do i = 1, d
      last(t(i)) = i
      res = res + s(t(i), i) - sum(c * (i - last))
    end do
  end
  subroutine random_seed_clock()
    integer :: nseed, clock
    integer, allocatable :: seed(:)
    call system_clock(clock)
    call random_seed(size = nseed)
    allocate(seed(nseed))
    seed = clock
    call random_seed(put = seed)
    deallocate(seed)
  end
  integer function next_int(m) result(res)
    integer, intent(in)  :: m
    real(8) :: r
    call random_number(r)
    res = int(m * r) + 1
  end
end program atcoder_contest_scheduling

Measured memory_bytes: 3036
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using loop = int;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(loop (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(loop (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(loop (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(loop (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    string s; cin >> s;
    cout << s.substr(0, 4) << " " << s.substr(4) << "\n";
}

Measured memory_bytes: 256
while True:
    n = int(input())
    if n == 0:
        break
    v = []
    for _ in range(n):
        m, a, b = map(int, input().split())
        v.append((a,m))
        v.append((b,-m))
    v.sort()
    s = 0
    ans = 'OK'
    for x in v:
        s += x[1]
        if s > 150:
            ans = 'NG'
    print(ans)




Measured memory_bytes: 5616
#include<bits/stdc++.h>
#define ll long long 
#define vl vector
#define pb push_back
#define ff first
#define ss second
using namespace std;
int main()
{
    ll n,m,i,a,b;
    cin>>n;
    ll arr[n];
    for(i=0;i<n;i++) cin>>arr[i];
    ll mn=INT_MAX;
    ll count=0;
    for(i=0;i<n;i++)
    {
        if(arr[i]<mn)
        {
            count++;
            mn=arr[i];
        }
    }
    cout<<count;
    
}

Measured memory_bytes: 5164
#include<bits/stdc++.h>
using namespace std;
using lli = long long;
#define rep(i,n) for(int i=0;i<n;i++)
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; }

lli n;

int main(void){
	cin >> n;
	vector<lli> h(n);
	rep(i, n) cin >> h[i];
	vector<lli> dp(n+5, 1e18);
	dp[0] = 0;
	for(int i = 0; i < n; i++){
		if(i+1 < n) chmin(dp[i+1], dp[i]+abs(h[i+1]-h[i]));
		if(i+2 < n) chmin(dp[i+2], dp[i]+abs(h[i+2]-h[i]));
	}
	cout << dp[n-1] << endl;
	return 0;
}


Measured memory_bytes: 4856
N = int(input())
s = [input() for i in range(N)]
M = int(input())
t = [input() for i in range(M)]

money = -1

for i in s:
    cnt = s.count(i) - t.count(i)
    if money < cnt:
        money = cnt

if money <= 0:
    print(0)
else:
    print(money)

Measured memory_bytes: 3064
'use strict'

const main = (INPUT) => {
  const N = INPUT.split('\n')[0]
  let cnt = 0
  for (let i = 0; i < N.length; i++) {
    if (N[i] == 2) {
      cnt++
    }
  }
  console.log(cnt)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 22964
#include <stdio.h>
#define MAX 100
int main(){

  int key,i,j,n,c;
  int arry[MAX];

  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",&arry[i]);
  
  for(i=0;i<n-1;i++)
    printf("%d ",arry[i]);
    printf("%d",arry[n-1]);
  printf("\n");
  
  for(i=1;i<n;i++){
    key=arry[i];
    j=i-1;
    while(j>=0 && arry[j]>key){
      arry[j+1]=arry[j];
      j--;
      arry[j+1]=key;
    }
    for(c=0;c<n-1;c++)
      printf("%d ",arry[c]);
      printf("%d",arry[n-1]);
    printf("\n");
  }
  return 0;
}

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


int main(){
    ll n,ans=0;
    scanf("%lld",&n);
    ll a[n],b[n];
    for(ll i=0;i<n;i++)scanf("%lld",&a[i]);
    for(ll i=0;i<n;i++)scanf("%lld",&b[i]);
    ll husoku=0,dif;
    vector<ll>posi;

    for(ll i=0;i<n;i++){
        dif=a[i]-b[i];
        if(dif<0){
            ans++;
            husoku+=dif;
        }else if(dif>0){
            posi.push_back(dif);
        }
    }

    sort(posi.begin(),posi.end(),greater<ll>());
    
    
    for(ll e:posi){
        if(husoku>=0)break;
        husoku+=e;
        ans++;
    }
    if(husoku<0)ans=-1;
    cout<<ans<<endl;

}

Measured memory_bytes: 2428
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); i++)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
        return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int main() {
        int k, a, b;
        cin >> k >> a >> b;

        for (int i = a; i <= b; i++) {
                if (i % k == 0) {
                        cout << "OK" << endl;
                        return 0;
                }
        }

        cout << "NG" << endl;

        return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include    <algorithm>
#include <cmath>
#include <cstdio>
#include  <cstdlib>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <vector>
#include <string>
#include <string>
using namespace std;

#define rep(i,n) for(int i=0;i<(int)n;i++)
typedef long long lint;
#define SZ(x) ((int)(x).size())
int main()
{
	int n, k;
	string s;
	cin >> n >> k;
	cin >> s;
	s[k - 1] = tolower(s[k - 1]);
	cout << s << endl;



	return 0;
}


Measured memory_bytes: 256
# -*- coding:utf-8 -*-
N = int(input())
data1 = []
data2 = []
for i in range(N):
    data1.append(int(input()))
    data2.append(int(input()))

for i in range(N):
    if data1[i] > 10**80-1 or data2[i] > 10**80-1 or data1[i]+data2[i] > 10**80-1:
        print('overflow')
    else:
        print(data1[i]+data2[i])

Measured memory_bytes: 7528
#include <bits/stdc++.h>
using namespace std;
 
using ll=long long;
 
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
const ll MOD = 1e9 + 7;

int main() {
    int n; ll a, b;
    cin >> n >> a >> b;
    vector<int> xs(n); 
    rep(i, n) cin >> xs[i];
    ll ans = 0;
    rep(i, n-1) {
        int d = xs[i+1] - xs[i];
        ans += min(a*d, b);
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)((x).size()))

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef long long int64;
typedef unsigned int uint;
typedef unsigned long long uint64;

#define gi(x) ((x) = F())
#define gii(x, y) (gi(x), gi(y))
#define giii(x, y, z) (gii(x, y), gi(z))

int F()
{
	char ch;
	int x, a;
	while (ch = getchar(), (ch < '0' || ch > '9') && ch != '-');
	if (ch == '-') ch = getchar(), a = -1;
	else a = 1;
	x = ch - '0';
	while (ch = getchar(), ch >= '0' && ch <= '9')
		x = (x << 1) + (x << 3) + ch - '0';
	return a * x;
}

const int N = 1e5 + 10;

int n, m;

vector<int> e1[N], e2[N]; 

bool vis[N];

int co[N], flag, cnt[3], s, e;

void dfs(int u)
{
	vis[u] = 1;
	++s;
	++cnt[co[u]];
	for (auto v : e1[u])
	{
		++e;
		if (vis[v])
		{
			if (co[v] != (co[u] + 1) % 3)
				flag = 0;
			continue;
		}
		co[v] = (co[u] + 1) % 3;
		dfs(v);		
	}
	for (auto v : e2[u])
	{
		if (vis[v])
		{
			if (co[v] != (co[u] + 2) % 3)
				flag = 0;
			continue;
		}
		co[v] = (co[u] + 2) % 3;
		dfs(v);
	}
}

long long ans;

int main()
{
	gii(n, m);
	for (int i = 1; i <= m; ++i)
	{
		int u, v;
		gii(u, v);
		e1[u].pb(v);
		e2[v].pb(u);
	}
	for (int i = 1; i <= n; ++i)
	{
		if (!vis[i])
		{
			e = 0;
			s = 0;
			flag = 1;
			cnt[0] = cnt[1] = cnt[2] = 0;
			dfs(i);
			if (!flag)
			{
				ans += 1LL * s * s;
			}
			else if (cnt[0] && cnt[1] && cnt[2])
			{
				ans += 1LL * cnt[0] * cnt[1] + 1LL * cnt[1] * cnt[2] + 1LL * cnt[0] * cnt[2];
			}
			else ans += e;
		}
	}
	printf("%lld\n", ans);
	return 0;
}



Measured memory_bytes: 16384
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define rep(i, n) ;for (int i = 0;i < (int)(n);i++)
#define rep2(i, s, n) ;for (int i = s; i < (int)(n);i++)
#define ALL(vec)  (vec).begin(),(vec).end()
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF (922337203685477587+1)
#define sosuu 1000000007

int main() {
  lli N;
  cin >> N;
  vector<lli> A(N);
  vector<lli> B(N-1);
  lli ans=0;
  rep(i, N) {
    cin >> A[i];
    A[i]%=sosuu;
    }
  rep(i, N-1)
  {
    if(i!=0)
  B[N-(i+1)-1]=(A[N-(i+1)]+B[N-(i+1)])%sosuu;
    
    else
      B[N-2]=A[N-1];
  }
    rep(i, N-1){
    ans+=A[i]*B[i];
      ans%=sosuu;
    
    
    
    }
  cout << ans << endl;
}

Measured memory_bytes: 6416
import java.util.*;
public class Main{

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

      int leftIdx = (n - 1) / 2;
      int rightIdx = leftIdx + 1;
      boolean flag = true;

      for(int i = 0; i < n; i++) {
        if(flag) {
          arr[leftIdx--] = sc.nextInt();
          flag = false;
        } else {
          arr[rightIdx++] = sc.nextInt();
          flag = true;
        }
      }
      if(n % 2 == 0)
        reverse(arr);
      for(int i = 0; i < arr.length; i++)
        if(i == arr.length - 1)
            System.out.println(arr[i]);
        else
            System.out.print(arr[i] + " ");
        
  }

  private static void reverse(int[] arr) {
    int left = 0, right = arr.length - 1;
    while(left < right) {
      int t = arr[left];
      arr[left] = arr[right];
      arr[right] = t;
      left++;
      right--;
    }
  }
}


Measured memory_bytes: 92044
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int>pii;

const int N=1e5+10;

vector<pii>G[N];
int col[N];

void dfs(int u,int f){
    for(auto P:G[u]){
        int v=P.first,w=P.second;
        if(v==f) continue;
        if(w&1) col[v]=1-col[u];
        else col[v]=col[u];
        dfs(v,u);
    }
}

void solve(){
    int n;
    scanf("%d",&n);
    for(int i=1;i<n;i++){
        int u,v,w;
        scanf("%d%d%d",&u,&v,&w);
        G[u].push_back(pii(v,w));
        G[v].push_back(pii(u,w));
    }
    dfs(1,0);
    for(int i=1;i<=n;i++) printf("%d\n",col[i]);
}

int main(){
    solve();
    return 0;
}


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


struct result{
	int x;
	string y;
};
int main() {
	int N,submit;
	int counta,countw=0;
	int countt=0;
	map<int,string> check;

	cin>>N>>submit;
	vector<result>a(submit);
	for(int i=0;i<submit;i++){
		int c;
		string b;
		
		cin>>c>>b;
		if(c<=N){
		a.at(i)={c,b};
		}
	}
	//値を配列にしまった

	for(int i=0;i<submit;i++){
	
	
			
				if(a.at(i).y=="AC"&&check[a.at(i).x]!="AC"){
					counta++;
					check[a.at(i).x]="AC";
				}
				else if(a.at(i).y=="WA"&&check[a.at(i).x]!="AC"){
					countw++;
				}
			
	}
	for(int i=0;i<submit;i++){
		       if(a.at(i).y=="WA"&&check[a.at(i).x]!="AC"){
		       	countt++;
		       }
	}
	cout<<counta<<" "<<countw-countt<<endl;
	return 0;
}

Measured memory_bytes: 17408
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  int N;
  cin >> N;
  ll ans = ((ll)(N-1) * (ll)N) / 2;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
n=int(input())
t,a=map(int,input().split())
H=list(map(int,input().split()))
now=abs(a-(t-H[0]*0.006))
ans=0
for i in range(n):
    cnt=abs(a-(t-H[i]*0.006))
    if now>cnt:
        now=cnt
        ans=i
print(ans+1)

Measured memory_bytes: 3064
#include <stdio.h>

int main(void) {
  int a[100], i = 0;

  while (scanf("%d", &a[i]) != EOF) {
    if (a[i] == 0) {
      printf("%d\n", a[i-1]);
      i--;
    }
    else
      i++;
  }
  return 0;
}

Measured memory_bytes: 600
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    string s;
    int n, p=0;
    cin>>n>>s;
    for(int i=0; i<n-2; i++){
        if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C')
            p++;
    }
    cout<<p<<endl;
}


Measured memory_bytes: 256
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  real t, x; readV(t, x);
  writefln("%.4f", t/x);
}


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

int main()
{
    std::string str;
    std::cin >> str;
    int flag = 0;
    for (auto&& s : str)
    {
        if (flag == 0 && s == 'C')
        {
            flag = 1;
            continue;
        }
        else if (flag == 1 && s == 'F')
        {
            std::cout << "Yes" << std::endl;
            return 0;
        }
    }
    std::cout << "No" << std::endl;

    return 0;
}


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

//昇順
int acs(const void *a, const void *b)
{
  return *(int *)a - *(int *)b;
}

int main() {
  int N;
  cin >> N;
  int s[N], sum = 0;
  for (int i=0; i<N; i++) {
    cin >> s[i];
    sum += s[i];
  }
  qsort(s, N, sizeof(int), acs);
  if (sum%10) {
    cout << sum << endl;
    return 0;
  }
  for (int i=0; i<N; i++) {
    if ((sum-s[i])%10) {
      cout << sum-s[i] << endl;
      return 0;
    }
  }
  cout << 0 << endl;
  return 0;
}

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

using namespace std;

int main()
{
    int N;
    cin >> N;
    int a[200000];

    for(int i = 0; i < N; ++i){
        cin >> a[i];
        a[i] -= i;
    }

    sort(a, a+N);
    long long paternA = 0;
    long long paternB = 0;
    int A = a[N/2];
    if(N == 1){
        cout << 0 << endl;
        return 0;
    }
    for(int i = 0; i < N; ++i){
        paternA += abs(a[i] - A);
    }
    cout << paternA << endl;
    return 0;
}



Measured memory_bytes: 1024
import java.util.*;
public class Main{
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a[] = new int[n];
        for(int i=0; i<n; i++){
            a[i] = sc.nextInt();
            a[i] = a[i] - i-1;
        }
        Arrays.sort(a);
        int b = 0;
        if(n%2 == 0){
            b = a[n/2 - 1];
        }else{
            b = a[(n+1)/2 - 1];
        }

        long f = 0;
        for(int i=0; i<n; i++){
            f += Math.abs(a[i] - b); 
        }
        System.out.println(f);
    }
}


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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};


void solve(long long N){
    cout << ((double) ceil(N/2.0) / (double) N) << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 256