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

// using ll = long long;
#define int long long

#define LOG(variable) cout << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cout << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, r, n) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
/***** MAIN *****/
signed main() {
  map<char, queue<char>> mp;
  for(char c = 'a'; c <= 'c'; ++c) {
    string s;
    cin >> s;
    queue<char> que;
    REP(i,s.size()) {
      que.push(s[i]);
    }
    mp[c] = que;
  }
  char next_player = 'a';
  while(mp[next_player].size() > 0) {
    char tmp = mp[next_player].front();
    mp[next_player].pop();
    next_player = tmp;
  }
  switch (next_player)
  {
    case 'a':
      cout << 'A';
      break;
    case 'b':
      cout << 'B';
      break;
    case 'c':
      cout << 'C';
      break;
  }
  cout << "\n";
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 256
import           Data.Maybe
import           Data.List

main :: IO ()
main = do
    input <- getContents
    let l1 : l2 : _ = lines input
    let [n, m]      = (map read . words) l1 :: [Int]
    let list        = (map read . words) l2 :: [Int]
    let mlist       = (map (`mod` m) . scanr (+) 0) list
    let f n = (n * (n - 1)) `div` 2
    let x = (sum . map f . map length . group . sort) mlist
    putStrLn $ show x


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

using namespace std;
using ll = long long;
ll n,k, a[300005],f[300005];
bool check(ll time){
    ll need=0;
    for(int i=0;i<n;i++){
        if(a[i]*f[i] > time){
                need = need + (a[i] - (time/f[i]));
        }
    }
    if(need<=k)
        return true;
    else    return false;
}
int main() {
    
    cin>>n>>k;
    for(int i=0;i<n;i++)    cin>>a[i];
    for(int i=0;i<n;i++)    cin>>f[i];
    sort(a,a+n);
    sort(f,f+n,greater<ll>());
    ll l=-1,h=1e18,mid,ans;
    while(l+1<h){
        mid=(l+h)/2;
        if(check(mid) == false){
            l=mid;
        }
        else{
            h=mid;
        }
    }
    cout<<h;
    
}

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

using namespace std;

using ll = long long;

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

    vector<vector<ll>> nums(9, vector<ll> (9, 0));
    for (int i = 1; i <= n; i++) {
        int ii = i;
        int a = i % 10;
        while (ii >= 10) {
            ii /= 10;
        }
        int b = ii;
        if (!a || !b) continue;
        a--; b--;
        nums[a][b]++;
    }

    ll ans = 0;
    for (int i = 0; i < 9; i++) {
        for (int j = 0; j < 9; j++) {
            ans += nums[i][j] * nums[j][i];
        }
    }

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

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

int main()
{
	int A, B, C, D;
	scanf("%d %d %d %d", &A, &B, &C, &D);

	if ((A + B) == (C + D))
	{
		printf("Balanced");
	}
	else
	{
		if ((A + B) > (C + D))
		{
			printf("Left");
		}
		else
		{
			printf("Right");
		}
	}

	return 0;
}

Measured memory_bytes: 256
h, w = map(int, input().split())
grid = []

for _ in range(0, h):
    grid.append(input())

while True:
    modified = False

    for i in range(0, h):
        if all(True if grid[i][j] == "." else False for j in range(0, w)):
            del grid[i]

            modified = True
            h       -= 1

            break

    for j in range(0, w):
        if all(True if grid[i][j] == "." else False for i in range(0, h)):
            for i in range(0, h):
                grid[i] = grid[i][0:j] + grid[i][j + 1:]

            modified = True
            w       -= 1

            break

    if not modified:
        break

for r in grid:
    print(r)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define INF 2147483647
#define INFF 9223372036854775807
#define ll long long
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,m,n) for(int i=m;i<n;i++)
#define ALL(N) (N.begin(),N.end())
 
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  string S, T;
  cin >> N >> S >> T;
  REP(i,N) {
    cout << S[i] << T[i];
  }
  cout << endl;
  return 0;
}  

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mk make_pair
using namespace std;

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

       int t=1;
       //cin>>t;
       while(t--)
       {
               ll n;
               cin>>n;
               ll a[n];
               ll ans=0;
               for(ll i=0;i<n;++i)
               {
                    cin>>a[i];
                    ans ^= a[i];
               }
               for(ll i=0;i<n;++i )
               {
                    ll temp = ans^a[i];
                    cout<<temp<<" ";
               }
       }
}


Measured memory_bytes: 5212
a, b, c = map(int, raw_input().split())
for i in xrange(1000):
    if a %2 or b % 2 or c % 2:
        print i
        quit()
    a, b, c = b / 2 + c / 2, a / 2 + c / 2, a / 2 + b / 2
print -1


Measured memory_bytes: 2572
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<cmath>
#include<string>

#define ls (t<<1)
#define rs ((t<<1)+1)
#define mid ((l+r)>>1)
#define fi first
#define se second
#define mk make_pair
#define pb push_back

#define N 1005
#define M 200005
#define seed 23333

using namespace std;
int i,j,m,n,p,k,cnt,R[N],t;
long long G[N],C[N][N];
int main()
{
		for (i=0;i<N;++i)
		{
				C[i][0]=1;
				for (j=1;j<=i;++j) C[i][j]=C[i-1][j]+C[i-1][j-1];
		}
		for (i=0;i<=600;++i) G[i]=(i==0?0:G[i-1])+C[i+6][i];
		long long K; cin>>K;
		for (i=600;i>=0;--i)
			while (K>=G[i]) K-=G[i],R[i]++;
		for (i=0;i<=600;++i) 
		{
			printf("FESTIVA");
			for (j=1;j<=R[i];++j) printf("L");
		}
}


Measured memory_bytes: 7168
def numinput():
    a = input().split()
    for i in range(len(a)):
        a[i] = int(a[i])
    return a

def main():
    a = numinput()
    if a[0] < a[1]: print("a < b")
    elif a[0] > a[1]: print("a > b")
    else: print("a == b")

if __name__ == "__main__":
    main()



Measured memory_bytes: 5600
#include <iostream>

using namespace std;

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

  int A[N];
  bool flg = true;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    if (A[i] % 2 == 0) {
      if (flg && (A[i] % 3 == 0 || A[i] % 5 == 0)) {
        flg = true;
      } else {
       flg = false;
      }
    }
  }

  if (flg) {
    cout << "APPROVED" << endl;
  } else {
    cout << "DENIED" << endl;
  }

}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
    char s[10] ;

         scanf("%s", &s);


    if(s[0]=='S')
    {
        printf("Cloudy\n");
    }
   else if(s[0]=='C')
    {
        printf("Rainy\n");
    }
   else if(s[0]=='R')
    {
        printf("Sunny\n");
    }
}


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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int main()
{
    int N, A, B;
    cin >> N >> A >> B;
    int min = std::max(A + B - N, 0);
    int max = std::min(A, B);
    cout << max << " " << min << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdlib>
#include <ctime>
using namespace std;
typedef long long ll;

ll po[20];char opt[10];
inline bool Query(ll x){
	printf("? %lld\n", x);
	fflush(stdout);
	scanf("%s", opt);
	return opt[0] == 'Y';
}

int main(){
	po[0] = 1;
	for(int i = 1;i <= 18;++i)po[i] = 10LL * po[i - 1];
	bool flag = 1;
	ll L = 0;
	for(int i = 1;i <= 9;++i){
		if(!Query(po[i])){
			flag = 0;
			if(!L)L = po[i - 1];
		}
	}
	if(flag){
		int l = 0, r = 9, mid, pos = 9;
		while(l <= r){
			mid = l + r >> 1;
			if(Query(2LL * po[mid]))pos = min(pos, mid), r = mid - 1;
			else l = mid + 1;
		}
		printf("! %lld\n", po[pos]);
	}
	else{
		ll r = L * 10 - 1, l = L + 1, mid, ans = r;
		while(l <= r){
			mid = l + r >> 1;
			if(Query(10LL * mid))ans = min(ans, mid), r = mid - 1;
			else l = mid + 1;
		}
		printf("! %lld\n", ans);
	}
	fflush(stdout);
	return 0;
}


Measured memory_bytes: 596
H, W = map(int, input().split())
A    = [[None for w in range(W)] for h in range(H)]

for h in range(H):
    A[h] = list(map(int, input().split()))

N = 0
R = []

for h in range(H):
    for w in range(W):
        if A[h][w] % 2 == 1:
            if w != W-1:
                N += 1
                A[h][w+1] += 1
                R.append("%s %s %s %s" % (h+1, w+1, h+1, w+1+1))
            else:
                if h != H-1:
                    N += 1
                    A[h+1][w] += 1
                    R.append("%s %s %s %s" % (h+1, w+1, h+1+1, w+1))

print(N)
for r in R:
    print(r)


Measured memory_bytes: 16244
/*
      author  : nishi5451
      created : 15.08.2020 13:30:01
*/

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


int main(){
    string s;
    cin >> s;
    int ans = 0;
    for(int i=0; i<s.size()/2; i++){
        if(s[i]!=s[s.size()-i-1]) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3592
#include <iostream>
using namespace std;
int main(void){
    int k,a,b;
    cin >> k >> a >> b;
    int i = a;
    while(i <= b){
        if(i%k == 0){
            cout << "OK" << endl;
            break;
        }
        i++;
    }
    if(i > b) cout << "NG" << endl;
}

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

using namespace std;

const int M = 500005;
const int mod = 998244353;

int A[M], B[4 * M], C[4 * M], S[4 * M], len[4 * M];
int n, q;

void push_up(int p) {
    S[p] = (S[p << 1] + S[p << 1 | 1]) % mod;
}

void push_down(int p) {
    if (B[p] != 1) {
        B[p << 1] = (long long) B[p << 1] * B[p] % mod;
        C[p << 1] = (long long) C[p << 1] * B[p] % mod;
        S[p << 1] = (long long) S[p << 1] * B[p] % mod;
        B[p << 1 | 1] = (long long) B[p << 1 | 1] * B[p] % mod;
        C[p << 1 | 1] = (long long) C[p << 1 | 1] * B[p] % mod;
        S[p << 1 | 1] = (long long) S[p << 1 | 1] * B[p] % mod;
        B[p] = 1;
    }
    if (C[p] != 0) {
        C[p << 1] = (C[p << 1] + C[p]) % mod;
        S[p << 1] = (S[p << 1] + (long long) C[p] * len[p << 1]) % mod;
        C[p << 1 | 1] = (C[p << 1 | 1] + C[p]) % mod;
        S[p << 1 | 1] = (S[p << 1 | 1] + (long long) C[p] * len[p << 1 | 1]) % mod;
        C[p] = 0;
    }
}

void build(int p, int l, int r) {
    len[p] = r - l + 1;
    B[p] = 1;
    if (l == r) {
        S[p] = A[l];
        return;
    }
    int mid = (l + r) >> 1;
    build(p << 1, l, mid);
    build(p << 1 | 1, mid + 1, r);
    push_up(p);
}

void modify(int p, int l, int r, int a, int b, int x, int y) {
    if (l == a && r == b) {
        B[p] = (long long) B[p] * x % mod;
        C[p] = ((long long) C[p] * x + y) % mod;
        S[p] = ((long long) S[p] * x + (long long) y * len[p]) % mod;
        return;
    }
    push_down(p);
    int mid = (l + r) >> 1;
    if (mid < a)
        modify(p << 1 | 1, mid + 1, r, a, b, x, y);
    else if (b <= mid)
        modify(p << 1, l, mid, a, b, x, y);
    else {
        modify(p << 1, l, mid, a, mid, x, y) ;
        modify(p << 1 | 1, mid + 1, r, mid + 1, b, x, y);
    }
    push_up(p);
}

int query(int p, int l, int r, int a, int b) {
    if (l == a && r == b)
        return S[p];
    push_down(p);
    int mid = (l + r) >> 1;
    if (mid < a)
        return query(p << 1 | 1, mid + 1, r, a, b);
    if (b <= mid)
        return query(p << 1, l, mid, a, b);
    return (query(p << 1, l, mid, a, mid) + query(p << 1 | 1, mid + 1, r, mid + 1, b)) % mod;
}

int main() {
    scanf("%d%d", &n, &q);
    for (int i = 0; i < n; ++i)
        scanf("%d", &A[i]);
    build(1, 0, n - 1);
    while (q-- != 0) {
        int op, l, r, b, c;
        scanf("%d", &op);
        if (op == 0) {
            scanf("%d%d%d%d", &l, &r, &b, &c);
            modify(1, 0, n - 1, l, r - 1, b, c);
        }
        if (op == 1) {
            scanf("%d%d", &l, &r);
            printf("%d\n", query(1, 0, n - 1, l, r - 1));
        }
    }
    return 0;
}

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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var x = Console.ReadLine();
            var acum = new int[x.Length + 1];
            var index = x[0] == 'T' ? 0 : 1;
            acum[index]++;

            for (var i = 1; i < x.Length; i++)
            {
                if (x[i] != x[i - 1])
                {
                    index++;
                    acum[index] = 1;
                }
                else
                    acum[index]++;
            }

            var isTrue = index % 2 == 0;
            var remin = isTrue ? 0 : acum[index];
            var terminate = isTrue ? 0 : -1;

            var sCount = 0;
            var count = 0;
            for (var i = 1; i <= index + terminate; i++)
            {
                if (i % 2 == 1) sCount += acum[i];
                else
                {
                    if (sCount - acum[i] < 0)
                    {
                        count += Math.Abs(sCount - acum[i]);
                        sCount = 0;
                    }
                    else
                    {
                        sCount -= acum[i];
                    }
                }
            }

            var total = acum[0] + sCount + count + remin;

            Console.WriteLine(total);
        }
    }
}


Measured memory_bytes: 12512
a = []

b = {}

for i in range(3):
    x = map(int, input().split())
    a += x

n = int(input())

ans = [0 for i in range(9)]

for i in range(n):
    x = int(input())
    if x in a:
        index = a.index(x)
        ans[index] = 1

# print(a)
# print(ans)

flag = False

for i in range(3):
    if ans[i * 3] + ans[i * 3 + 1] + ans[i * 3 + 2] == 3:
        flag = True
        break
    if ans[i] + ans[i + 3] + ans[i + 6] == 3:
        flag = True
        break

if ans[0] + ans[4] + ans[8] == 3:
    flag = True
elif ans[2] + ans[4] + ans[6] == 3:
    flag = True

print("Yes" if flag else "No")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long int
#define fi first
#define se second
#define endl "\n"
#define all(v) v.begin(),v.end()
#define fastio ios::sync_with_stdio(0); std::cin.tie(0); std::cout.tie(0)
#define go_t int t;cin>>t;for(int tt=1;tt<=t;tt++)
#define set_ar(arr,v) memset(arr,v,sizeof(arr))
#define trace2(x, y)         cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)      cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)   cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define trace5(a, b, c, d, e)cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<endl;
typedef pair<int,int>pi;
typedef pair<ll,ll>pl;
const ll inf = 0x3f3f3f3f3f3f3f3fll;//4x10e18
const int N = 300000 , mod = 1000000007;
int main()
{
    fastio;
    int a,b;
    cin>>a>>b;
    cout<<a*b<<endl;
    return 0;
}

Measured memory_bytes: 3676
#include<cstdio>
#define int long long
signed main() {
	int n,d,cnt=0;
	scanf("%lld%lld",&n,&d);
	for(register int i=1;i<=n;++i) {
		int x,y;
		scanf("%lld%lld",&x,&y);
		if(x*x+y*y<=d*d) ++cnt;
		//printf("%d\n",i);
	} 
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999999
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef vector<llong> LV;

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


int count_ab(string S){
    int n = S.length();
    char be = S[0];
    int ret=0;
    FOR(i,1,n){
        if((be == 'A') && (S[i] == 'B')){
            ret++;
        }
        be = S[i];
    }
    return ret;
    
}

int main() {
	llong N;
    cin >>N;
    vector<string> SV(N);
    string S;
    int an,bn,mn,ba;
    mn = an = bn = ba = 0;
    REP(i,N){
        cin >> S;
        mn += count_ab(S);
        if( (S[0] == 'B') && (S[ S.length()-1] == 'A')){
            ba ++;
            continue;
        }
        if(S[0] == 'B') bn++;
        if(S[ S.length()-1 ] == 'A') an++;
    }

    // printf("a=%d,b=%d,m=%d,ba=%d",an,bn,mn,ba);
    if(ba>0){
        mn+= ba-1;
        if((an>0) && (bn>0)){
            an--;
            bn--;
            mn+=2;
        }else if( max(an,bn) > 0){
            mn++;
        }
    }
    llong ans =min(an,bn) + mn;
    cout << ans << endl;


    

    




}


Measured memory_bytes: 384
#include <stdio.h>

int A[1000000], n;
int binarySearch(int key) {
  int left = 0;
  int right = n;
  int mid;
  while(left < right) {
    mid = (left + right) / 2;
    if(key == A[mid]) return 1;
    if(key > A[mid]) left = mid + 1;
    else if(key < A[mid]) right = mid;
  }
  return 0;
}

int main(void) {
  int i, q, k, sum = 0;
  scanf("%d",&n);
  for(i=0; i<n; i++) {
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++) {
    scanf("%d",&k);
    if(binarySearch(k))
      sum++;
  }
  printf("%d\n",sum);
  return 0;
}


Measured memory_bytes: 2176
#include<bits/stdc++.h> 
#define pb push_back
#define mp make_pair 
#define fi first
#define se second
typedef long long ll;
using namespace std;
const ll mod =1e9+7;

void solve()
{  ll k,n,x;
   
   cin>>k>>n;
   ll a[n];
   for(int i=0;i<n;i++)
   cin>>a[i]; 
   sort(a,a+n);
   x=a[0];
   for(int i=0;i+1<n;i++)
   {  a[i]=a[i+1]-a[i];
   }
       a[n-1]=k-a[n-1]+x;
   ll ans=k-*max_element(a,a+n); 
   cout<<ans;
}
int main()
{
/* #ifndef ONLINE_JUDGE
   freopen("ques.txt","r",stdin);
   freopen("ans.txt","w",stdout);
 #endif 
  int t;
  cin>>t;
  while(t--) */ 
  { solve();
    cout<<"\n";
  }
  return 0;
}


Measured memory_bytes: 1792
n = int(input())
p = list(map(int,input().split()))
c = 0
for i in range(n-1):
    if p[i] == i+1:
        p[i], p[i+1] = p[i+1], p[i]
        c += 1
if p[n-1] == n:
    c += 1
print(c)

Measured memory_bytes: 14008
#include<bits/stdc++.h>
#define mo 1000000007
#define add(a,b) (a+b>=mo)?(a+=b-mo):(a+=b)
using namespace std;
int f[2][22][1<<19],a[22][22];
int lowbit(int s){return s&(-s);}
int main()
{
	int n,m,q;scanf("%d%d%d",&n,&m,&q);
	memset(a,255,sizeof(a));
	while (q--)
	{
		int u,v,w;scanf("%d%d%d",&u,&v,&w);
		a[u][v]=w;
	}
	f[1][0][0]=1;
	for (int i=1;i<=m;i++)
	{
		memset(f[(i&1)^1],0,sizeof(f[(i&1)^1]));
		for (int j=0;j<n-1;j++)
		for (int s=0;s<(1<<(n-1));s++) if (f[i&1][j][s])
		{
			if ((a[i][j+1]!=1)&&((s&(1<<j))==0)) add(f[i&1][j+1][s],f[i&1][j][s]);
			if (a[i][j+1]!=0)
			{
				if (s&(1<<j)) add(f[i&1][j+1][s],f[i&1][j][s]);
				else add(f[i&1][j+1][s-(((s>>j)&(-(s>>j)))<<j)+(1<<j)],f[i&1][j][s]);
			}
		}
		for (int s=0;s<(1<<(n-1));s++) if (f[i&1][n-1][s]) add(f[(i&1)^1][0][s],f[i&1][n-1][s]);
	}
	int ans=0;
	for (int s=0;s<(1<<(n-1));s++) add(ans,f[m&1][n-1][s]);
	printf("%d\n",ans);
}

Measured memory_bytes: 90496
#include <stdio.h>
int main(){
  int n,a,i,A[10000];
  int min[1]={10000000},max[1]={-1000000};
  long int sum[1]={0};
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf(" %d",&A[i]);
    if(A[i]<min[0]){
      min[0]=A[i];
    } 
    if(A[i]>max[0]){
      max[0]=A[i];
    }
    sum[0]+=A[i];
  }
  printf("%d %d %ld\n",min[0],max[0],sum[0]);
}

Measured memory_bytes: 2780
H, W = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(H)]

ans = []
idx_list = [(i, j) if i % 2 == 0 else (i, W - j - 1) 
            for i in range(H) for j in range(W)]
        
for i, (x, y) in enumerate(idx_list[:-1]):
    if A[x][y] % 2 == 1:
        A[idx_list[i + 1][0]][idx_list[i + 1][1]] += 1
        ans.append([x, y, idx_list[i + 1][0], idx_list[i + 1][1]])
        
print(len(ans))
for v in ans:
    print(*[c + 1 for c in v])


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

typedef long long int ll;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(v,a,b) v.begin(a),v.end(b)
#define in cin>>
#define out cout<<
#define endl <<endl
constexpr auto INF = 100000000000000;

int main()
{
	int a;
	in a;
	double x = 1.08;
	int b = a / x;
	if (b*x >= a && b*x < a + 1)
	{
		out b endl;
	}
	else if ((b + 1)*x >= a && (b + 1)*x < a + 1)
	{
		out b + 1 endl;
	}
	else
	{
		out ":(" endl;
	}
}


Measured memory_bytes: 256
#include <cstdlib>
#include <iostream>
#include<algorithm>
#include <string>
#include <vector>
#include <ctime>
#include <numeric>
#include <cmath>
#include <sstream>
#include <thread>
#include <ctime>
#include <deque>
#include <list>
#include<forward_list>
#include<set>
int main()
{
    int n, pg = 1, k;
    std :: cin >> n;
    for(int i = 1; i < n; i++)
    {
        if(i % 2 == 0)
            pg++;
        else
            continue;
    }
    std :: cout << pg;
}   


Measured memory_bytes: 3076
#include<bits/stdc++.h>
#define ll long long
using namespace std;
 
const int sz=4e6+5;



 
  
int main() 
{ 
    // #ifndef ONLINE_JUDGE 
      
    //     // For getting input from input.txt file 
    //     freopen("input.txt", "r", stdin); 
      
    //     // Printing the Output to output.txt file 
    //     freopen("output.txt", "w", stdout); 
      
    // #endif 
 
    int t=1;
    // cin>>t;
    while(t--)
    {
        
        int n;
        cin>>n;
        int d;
        cin>>d;
        int res=0;
        while(n--)
        {
            long double x,y;
            cin>>x>>y;
            long double val=sqrt(x*x+y*y);
            if(val<=d)
                res++;
        }

        cout<<res;


 
    }
    return 0; 
} 

Measured memory_bytes: 3828
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

ll pow5(ll x){ return x*x*x*x*x; }

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    ll x; cin >> x;
    for(ll a=-119; a<=120; a++){
        for(ll b=-119; b<=120; b++){
            if(pow5(a)-pow5(b) == x){
                cout << a << " " << b << endl;
                return 0;
            }
        }
    }
}

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

class DP {
	vector<vector<vector<int64_t>>> m_val;

public:
	DP( int i, int j, int k ):
		m_val( i, vector<vector<int64_t>>( j, vector<int64_t>( k ) ) )
	{}

	int64_t& at( int i, int j, int k ) {
		return m_val.at( i ).at( j ).at( k );
	}
};

int main() {
	int N, A;
	cin >> N >> A;

	int X = A;
	vector<int> x( N );
	for( auto& v: x ) {
		cin >> v;
		X = max( X, v );
	}

	DP dp( N+1, N+1, N*X+1 );

	for( int j = 0; j <= N; ++j ) {
		for( int k = 0; k <= N; ++k ) {
			for( int s = 0; s <= N*X; ++s ) {
				if( j == 0 && k == 0 && s == 0 ) {
					dp.at( j, k, s ) = 1;
				}
				else if( j >= 1 && s < x.at( j-1 ) ) {
					dp.at( j, k, s ) = dp.at( j-1, k, s );
				}
				else if( j >= 1 && k >= 1 && s >= x.at( j-1 ) ) {
					dp.at( j, k, s ) = dp.at( j-1, k, s ) + dp.at( j-1, k-1, s-x.at( j-1 ) );
				}
				else {
					dp.at( j, k, s ) = 0;
				}
			}
		}
	}

	int64_t result = 0;

	for( int k = 1; k <= N; ++k ) {
		result += dp.at( N, k, k*A );
	}

	cout << result << endl;
}


Measured memory_bytes: 52224
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();//データの数 
		int V[] = new int[N]; //配列数を決定
		int C[] = new int[N]; //配列数を決定
		int ans[] = new int[N]; //配列数を決定
		
		for(int i = 0; i<N; i++) {
			V[i] = sc.nextInt(); //配列の中身を挿入
			
		}
		
		for(int i = 0; i<N; i++) {
            C[i] = sc.nextInt(); //配列の中身を挿入
		}
	
		for(int i = 0; i<N; i++) {
            ans[i]=V[i]-C[i]; 
		}
		
		// int配列をInteger配列にコピー(キャスト)
		Integer[] ans1 = new Integer[ ans.length ];
		for ( int i = 0; i < ans.length; ++ i ) {
		    ans1[i] = ans[i];
		 		}
		 	// 降順ソート
		Arrays.sort( ans1, Collections.reverseOrder() );
		
		// Integer配列をint配列にコピー(再キャスト)
		for ( int i = 0; i < ans1.length; ++ i ) {
		 	ans[i] = ans1[i];
		}
		 // 配列の中身を表示
		//for ( int i = 0; i < ans.length; ++ i ) {
		// 	System.out.println(ans[i]);
		//}
		int nums = 0;
		for ( int i = 0; i < ans.length; ++ i ) {
		  if(ans[i]>0) {
		      nums +=ans[i];
		  }else {
			  nums += 0;
		  }
		}
		System.out.println(nums);
	}
	
}


Measured memory_bytes: 23124
from itertools import permutations
n = int(input())
p, q = [list(map(int, input().split())) for i in [0,0]]
i = 1
ans = 0
for a in permutations(list(range(1, n+1)), n):
    if list(a) == p: ans += i
    if list(a) == q: ans -= i
    i += 1
print(abs(ans))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b,c,k;
  cin >> a >> b >> c >> k;
  for(int i = 0 ; i < k; i++)
  {
    if (b <= a)
    {
      b *= 2;
    }
    else
      if (c <= b)
      {
        c *= 2;
      }
    else
    {
      break;
    }
  }
  //cout << a << b << c << "\n";
  if((a < b) && (b < c))
  {
    cout << "Yes\n" ;
  }
  else 
  {
    cout << "No\n";
  }
  return 0;
}


Measured memory_bytes: 3632
var n,m:longint;
    i,j:longint;
    a:array[0..150,0..150]of char;
begin
  readln(n,m);
  for i:=1 to n do
  begin
    for j:=1 to m do
    read(a[i,j]);
    readln;
  end;
  for i:=1 to n do
    for j:=1 to m do
    if (a[i,j]='#')and(a[i-1,j]<>'#')and(a[i,j-1]<>'#')and(a[i+1,j]<>'#')and(a[i,j+1]<>'#') then
    begin
      writeln('No');
      exit;
    end;
    writeln('Yes');
end.

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'

int main(int argc, char const *argv[])
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(0);
    string s;
    cin>>s;
    cout<<(s[2]==s[3] and s[4]==s[5]?"Yes":"No")<<endl;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		ArrayList<Integer> input = new ArrayList<Integer>();
		Scanner insert = new Scanner(System.in);
		while(true){
			String line = insert.nextLine();
			if(line.equals("")) {
				break;
			}
			int lineInt = Integer.parseInt(line);
			input.add(lineInt);
		}
		insert.close();
		int i = 0;
		while(true) {
			ArrayList<Integer> team = new ArrayList<Integer>();
			int jagde = input.get(i);
			if(jagde == 0) {
				break;
			}
			int score = 0;
			for (int j = 1; j <= jagde; j++) {
				team.add(input.get(i + j));
				score = score + input.get(i + j);
			}
			score = score - Collections.max(team);
			score = score - Collections.min(team);
			System.out.println(String.valueOf(score / (jagde - 2)));
			i = i + jagde + 1;
		}
	}
}



Measured memory_bytes: 28616
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 100000000000000009
#define MOD 1000000007
#define int long long
using P = pair<int,int>;
signed main(){
  cout << setprecision(20);
  int n,p;
  cin >> n >> p;
  vint A(n);
  bool odd = false;
  rep(i,n){
    cin >> A[i];
    if(A[i] % 2 == 1) odd = true;
  }
  if(odd){
    cout << pow(2,n-1) << endl;
  }
  else{
    if(p == 0) cout << pow(2,n) << endl;
    else cout << 0 << endl;
  } 
}

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

int main()
{
	string s;
    cin >> s;
	int n = s.size();
	int a[10];
	int max = 753;
	for (int i = 0; i < n; i++) {
		a[i] = s[i] - '0';
	}
	for (int i = 0; i < n - 2; i++) {
		if (abs(a[i] * 100 + a[i + 1] * 10 + a[i + 2] - 753) < max) {
			max = abs(a[i] * 100 + a[i + 1] * 10 + a[i + 2] - 753);
		}
	}
	cout << max << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい

#define ALL(x) x.begin(),x.end()
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<int, vector<int>, greater<int> > gpq; //逆順priority_queue
typedef priority_queue<int> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const double PI=3.1415926535;

int main(){
    ll A,B,C,K;
    cin>>A>>B>>C>>K;
    if(K<=A){
        cout<<K<<endl;
    }else if(K<=A+B){
        cout<<A<<endl;
    }else{
        cout<<(A-(K-A-B))<<endl;
    }
}


Measured memory_bytes: 3600
#include<stdio.h>
int main(){
	int y,m,d;
	for(;scanf("%d %d %d",&y,&m,&d)!=EOF;){
		if(y<=1868){
			if(y==1868){
				if(m<=9){
					if(d<=7)printf("pre-meiji\n");
					else printf("meiji 1 %d %d\n",m,d);
				}
				else printf("meiji 1 %d %d\n",m,d);
			}
			else printf("pre-meiji\n");
		}
		else if(y<1912)printf("meiji %d %d %d\n",y-1868+1,m,d);
		else if(y<1926){
			if(y==1912){
				if(m<=7){
					if(d<=29)printf("meiji %d %d %d\n",y-1868+1,m,d);
					else printf("taisho %d %d %d\n",y-1912+1,m,d);
				}
				else printf("taisho %d %d %d\n",y-1912+1,m,d);
			}
			else printf("taisho %d %d %d\n",y-1912+1,m,d);
		}
		else if(y<1989){
			if(y==1926){
				if(m<=12){
					if(d<=24)printf("taisho %d %d %d\n",y-1912+1,m,d);
					else printf("showa %d %d %d\n",y-1926+1,m,d);
				}
			}
			else printf("showa %d %d %d\n",y-1926+1,m,d);
		}
		else {
			if(y==1989){
				if(m<=1){
					if(d<=7)printf("showa %d %d %d\n",y-1926+1,m,d);
					else printf("heisei %d %d %d\n",y-1989+1,m,d);
				}
				else printf("heisei %d %d %d\n",y-1989+1,m,d);
			}
			else printf("heisei %d %d %d\n",y-1989+1,m,d);
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	int k;
	cin >> k;
	int ma = max(max(a, b), c);
	int co = ma;
	for (int i = 1; i <= k; i++) {
		ma *= 2;
	}
	cout << a + b + c - co + ma << endl;
	return 0;
}


Measured memory_bytes: 256
from collections import*
N,*A=map(int, open(0).read().split())
A.sort()
C=Counter(A)
s=0
for a in A[::-1]:
	if not C[a]:
		continue
	C[a]-=1
	b=2**a.bit_length()-a
	if C[b]:
		C[b]-=1
		s += 1
print(s)

Measured memory_bytes: 33712
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(ll i = (ll)(a); i <= (ll)(b); i++)
#define NFOR(i,a,b) for(ll i = (ll)(a); i >= (ll)(b); --i)
#define rep(i, a) for (ll i = 0; i < a; i++)
#define endl "\n"
#define fi first
#define se second
#define MOD 1000000007
#define inf 1e12
#define pb push_back
#define Case cout<<"Case #"<<++cas<<": ";
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define all(v) v.begin(),v.end()

typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;

#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ","; dbs(str.substr(idx + 1), s...);}
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const multiset<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}

void solve() {
	ll mod = 1000000007;
	ll n;
	cin >> n;
	vector<double> p(n);
	rep(i, n) cin >> p[i];
	
	vector<vector<double> > dp(2, vector<double> (n + 1, 0));

	dp[0][0] = 1.0;
	FOR(i, 1, n)
		FOR(j, 0, i)
			dp[i%2][j] = dp[(i+1)%2][j] * (1.0 - p[i - 1]) + ((j >= 1) ? dp[(i+1)%2][j-1] * p[i-1] : 0);

	double ans = 0;
	FOR(i, n / 2 + 1, n) ans += dp[n%2][i];

	cout << setprecision(10) << fixed << ans << endl;
}

int main()
{
    fastio;
    ll t  = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
}


Measured memory_bytes: 384
/*
Author: Hossam Eissa
Idea:
*/
#include <bits/stdc++.h>
using namespace std;
#define ll  long long
#define FI freopen("input.txt", "r", stdin);
#define FO freopen("o.txt", "w", stdout);
#define start ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 2000000000;
const int N = 1e3+5;
const double PI=acos(-1);
ll stx,sty,enx,eny;
int n,m,k;
struct circle{
ll x,y,r;
circle(int X,int Y,int R){
    x=X;
    y=Y;
    r=R;
}
};
double get_dist(circle r1,circle r2){
    ll x=r1.x-r2.x;
    ll y=r1.y-r2.y;
    ll L=r1.r+r2.r;
    double dist=sqrt(x*x+y*y);
    if(dist<=L){
        return 0;
    }
    return dist-L;
}
vector<circle>vec;
double cost[N];
int main()
{
    fill(cost,cost+N,1e12);
    cin>>stx>>sty>>enx>>eny;
    int n;
    cin>>n;
    vec.push_back(circle(stx,sty,0));
    vec.push_back(circle(enx,eny,0));
    for(int i=0;i<n;i++){
        int a,b,c;
        cin>>a>>b>>c;
        vec.push_back(circle(a,b,c));
    }
                // time,idx
    priority_queue<pair<double,int>,vector<pair<double,int>>,greater<pair<double,int>>>pq;
    pq.push({0,0});
    while(!pq.empty()){
        double ti=pq.top().first;
        int idx=pq.top().second;
        pq.pop();
        if(ti>cost[idx])continue;
        cost[idx]=ti;
        for(int i=1;i<vec.size();i++){

            double dist=get_dist(vec[idx],vec[i])+cost[idx];
            if(dist<cost[i]){
                cost[i]=dist;
                pq.push({cost[i],i});
            }
        }
    }
    cout<<fixed<<setprecision(9)<<cost[1]<<endl;
}


Measured memory_bytes: 6276
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

#[allow(dead_code)]
fn yesno(b: bool){
    if b {
        println!("Yes");
    }
    else{
        println!("No");
    }
}


fn main(){
    let x = read::<i64>();
    yesno(x>=30);
}

Measured memory_bytes: 2108
#include <iostream>

int main(int argc, char *argv[])
{
  int s;
  int a, b;
  
  std::cin >> s;
  a = s/100;
  b = s-a*100;
  
  if ((a >= 1) && (a <= 12)) {
    // a: month, b: unknown
    if ((b >= 1) && (b <= 12)) {
      // a: month. b: month
      std::cout << "AMBIGUOUS" << std::endl;
    } else {
      // a: month. b: not month
      std::cout << "MMYY" << std::endl;
    }
  } else {
    // a: not month, b: unknown
    if ((b >= 1) && (b <= 12)) {
      // a: not month, b: month
      std::cout << "YYMM" << std::endl;
    } else {
      // a: not month, b: not month
      std::cout << "NA" << std::endl;
    }
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <numeric>
#include <algorithm>
#include <utility>


using std::cout;
using std::cin;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;


ll gcd(ll a, ll b) {
    while (b != 0) {
        auto tmp = a;
        a = b;
        b = tmp % a;
    }
    return a;
}

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

int isPrime(int a) {
    for (int i = 2; i * i <= a; ++i) {
        if (a % i == 0) {
            return 0;
        }
    }
    return 1;
}




void oneCase () {
    int n, m;
    cin >> n >> m;
    vector<string> a(n);
    vector<string> b(m);
    for (auto& l : a) {
        cin >> l;
    }
    for (auto& l : b) {
        cin >> l;
    }
    for (int row = 0; row + m <= n; ++row) {
        for (int col = 0; col + m <= n; ++col) {
            bool contain = true;
            for (int r = 0; r < m; ++r) {
                for (int c = 0; c < m; ++c) {
                    if (a[row + r][col + c] != b[r][c]) {
                        contain = false;
                        break;
                    }
                }
                if (!contain) {
                    break;
                }

            }
            if (contain) {
                cout << "Yes" << "\n";
                return;
            }
        }
    }
    cout << "No" << "\n";


}





int main() {
    int t = 1;
//    cin >> t;
    while (t > 0) {
        oneCase();
        --t;
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define BLACK 0
#define WHITE 1
#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

int N;
vector<pair<int,Int> > G[100000+10];
bool used[100000+10];
int color[100000+10];

void dfs(int u, Int dist) {
    if(used[u])
        return;
    used[u] = true;
    color[u] = dist % 2 == 0 ? BLACK : WHITE;

    for(int i = 0;i < G[u].size();i++) {
        pair<int,Int> v = G[u][i];
        dfs(v.first, dist+v.second);
    }

    return;
}
void solve(void) {
    dfs(1,0);

    for(int i = 1;i <= N;i++) {
        if(color[i] == BLACK) {
            cout<<0<<endl;
        } else {
            cout<<1<<endl;
        }
    }

    return;
}

int main(void) {
    cin>>N;
    int u,v;
    Int w;
    
    for(int i = 0;i < N-1;i++) {
        cin>>u>>v>>w;
        if(w % 2 == 1) {
            w = 1;
        } else {
            w = 2;
        }

        G[u].push_back(make_pair(v,w));
        G[v].push_back(make_pair(u,w));
    }

    solve();

    return 0;
}


Measured memory_bytes: 9856
#include <iostream>
using namespace std;
using large = long long;
int main() {
    large l, r;
    cin >> l >> r;

    int ans = 2'100'000'000;

    if ((l / 2019) < (r / 2019)) {
        ans = 0;
    } else {
        ans = (l * r) % 2019;

        for (large x = l; x <= r; x++) {
            for (large y = x + 1; y <= r; y++) {

                auto tmp = (x * y) % 2019;
                if (tmp < ans) {
                    ans = tmp;
                }
            }
        }
    }

    cout << ans;
    return 0;
}


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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

struct BIT{
  int n;
  vector<ll> bit;
  BIT(int size):n(size),bit(size+1,0){}

  ll sum(int i){
    ll s=0;
    while(i>0){
      s+=bit[i];
      i-=i&-i;
    }
    return s;
  }

  void add(int i,ll v){
    if(i==0)return ;
    while(i<=n){
      bit[i]+=v;
      i+=i&-i;
    }
  }

  ll lower_bound(ll w){
    if(w<=0)return 0;
    ll x=0,r=1;
    while(r<n)r<<=1;
    for(ll k=r;k>0;k>>=1){
      if(x+k<=n&&bit[x+k]<w){
        w-=bit[x+k];
        x+=k;
      }
    }
    return x+1;
  }
};

ll N;
ll p[100010],l[100010];
P sum[100010];
ll ans[100010];
ll perm[100010];

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

  cin>>N;
  rep(i,N)cin>>p[i];
  rep(i,N)cin>>l[i];
  rep(i,N){
    sum[i+1]=P(sum[i].fi+p[i],i+1);
  }
  sort(sum,sum+N+1);
  bool ok=true;
  rep(i,N){
    if(sum[i+1].fi-sum[i].fi<l[i])ok=false;
    perm[sum[i+1].se-1]=i;
  }
  if(!ok){
    cout<<-1<<endl;
    return 0;
  }
  ll res=0;
  BIT bit(N+1);
  for(ll i=N-1;i>=0;i--){
    ll j=perm[i];
    res+=bit.sum(j+1);
    bit.add(j+1,1);
  }
  cout<<res<<endl;

  return 0;
}



Measured memory_bytes: 7548
#include <iostream>
#include <cstring>

using namespace std;

int A[1000],B[1000],C[1000];

int main()
{
    int n;
    cin >> n;
    while(n > 0)
    {
        n--;
        string str1,str2;
        cin >> str1 >> str2;
        int len1 = str1.length();
        int len2 = str2.length();
        if(len1 < len2)
        {
            string st = str1;
            str1 = str2;
            str2 = st;
            int ll = len1;
            len1 = len2;
            len2 = ll;
        }
        for(int i = 0; i < 1000; i++)
        {
            C[i] = 0;
            A[i] = 0;
            B[i] = 0;
        }

        for(int i = 0; i < len1; i++)
            A[i] = str1[len1 - 1 - i] - '0';
        for(int i = 0; i < len2; i++)
            B[i] = str2[len2 - 1 - i] - '0';
        for(int i = 0 ; i < len1; i++)
        {
            C[i] = A[i] + B[i] + C[i];
            C[i+1] = C[i] / 10;
            C[i] = C[i] % 10;
        }
        //for(int i = len2; i <len1; i++)
       // {
           //  C[i] = C[i] + A[i];
           //  C[i+1] = C[i] / 10;
          //   C[i] = C[i] % 10;
       // }


        if(C[80] > 0)
            cout << "overflow" << endl;
        else
            {
                if(C[len1] > 0)
                    len1++;
                for(int i = len1-1; i >= 0; i--)
                    cout << C[i];
                cout << endl;
            }
    }
    return 0;
}

Measured memory_bytes: 1224
package main

import (
	"bufio"
	"fmt"
	"os"
)

func abs(a int) int {
	if a < 0 {
		a = -a
	}
	return a
}

func main() {
	r := bufio.NewReader(os.Stdin)
	var h, w int
	var a, b [80][80]int
	var max int
	fmt.Fscan(r, &h, &w)
	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			fmt.Fscan(r, &a[i][j])
		}
	}
	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			fmt.Fscan(r, &b[i][j])
			d := abs(a[i][j] - b[i][j])
			if max < d {
				max = d
			}
		}
	}
	max *= h + w
	var dp [80][80][80*(80+80) + 1]bool
	dp[0][0][abs(a[0][0]-b[0][0])] = true

	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			for k := 0; k <= max; k++ {
				if !dp[i][j][k] {
					continue
				}
				if i+1 < h {
					d := abs(a[i+1][j] - b[i+1][j])
					dp[i+1][j][k+d] = true
					dp[i+1][j][abs(k-d)] = true
				}
				if j+1 < w {
					d := abs(a[i][j+1] - b[i][j+1])
					dp[i][j+1][k+d] = true
					dp[i][j+1][abs(k-d)] = true
				}
			}
		}
	}

	for k := 0; k <= max; k++ {
		if dp[h-1][w-1][k] {
			fmt.Println(k)
			break
		}
	}
}


Measured memory_bytes: 82688
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define sz size
#define se second
#define fe first
#define mper make_pair
#define all(x) x.begin(), x.end()
#define mal ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL);
#define vl vector<ll>
#define vi vector<int>
#define vli vector <pair <ll, int> >
#define vll vector <pair <ll, ll> >
#define vii vector <pair <int, int> >
using namespace std;

const ll MAXN = 2e5 + 100;
ll n, pos[MAXN], ans, pref[MAXN];

void solve() {

    cin >> n;

    for(int i = 1; i <= n; ++i) {
        ll ai;
        cin >> ai;
        pos[ai] = i;

    }
    
    for(int i = 1; i <= n; ++i) {

        pref[i] += 1;
        if(pos[i] < pos[i + 1]) {pref[i + 1] += pref[i];}
        ans = max(ans, pref[i]);
    }

    cout << n - ans;

}

int main(){

mal
//freopen("ladder.in", "r", stdin);
//freopen("ladder.out", "w", stdout);

ll tt = 1;


while(tt--) {

    solve();

}

return 0;
}



Measured memory_bytes: 3328
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<stdlib.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<numeric>
#include<iomanip>
using namespace std;
int main() {
	int n;
	cin >> n;
	int i = 0;
	while (1) {
		if(n>=pow(2,i)){
			i++;
		}
		else {
			cout << pow(2, i-1) << endl;
			break;
		}
	}
}

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


using namespace std;

int main()
{
	string s;
	//int count=0;

	cin >> s;
	s.at(5)=' ';
    s.at(13)=' ';

    
    cout<<s<<endl;
    
    
		return 0;

}

Measured memory_bytes: 256
/**
 * File    : C.cpp
 * Author  : Kazune Takahashi
 * Created : 2018-3-25 21:00:57
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

int main()
{
  int N;
  cin >> N;
  int A[100010];
  A[0] = 0;
  for (auto i = 1; i <= N; i++)
  {
    cin >> A[i];
  }
  A[N + 1] = 0;
  int ans = 0;
  for (auto i = 0; i <= N; i++)
  {
    ans += abs(A[i] - A[i + 1]);
  }
  for (auto i = 1; i <= N; i++)
  {
    cout << ans - abs(A[i - 1] - A[i]) - abs(A[i] - A[i + 1]) + abs(A[i - 1] - A[i + 1]) << endl;
  }
}

Measured memory_bytes: 1664