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

using namespace std;

char arr[100][100];

int A, B;
int main() {
    cin >> A >> B;
    for (int i = 0; i < 50; i++) {
        for (int j = 0; j < 100; j++) {
            arr[i][j] = '.';
        }
    }
    for (int i = 50; i < 100; i++) {
        for (int j = 0; j < 100; j++) {
            arr[i][j] = '#';
        }
    }
    for (int i = 0; i < B - 1; i++) {
        arr[(i / 50) * 2][(i % 50) * 2] = '#';
    }
    for (int i = 0; i < A - 1; i++) {
        arr[99 - (i / 50) * 2][(i % 50) * 2] = '.';
    }
    cout << 100 << ' ' << 100 << endl;
    for (int i = 0; i < 100; i++) {
        for (int j = 0; j < 100; j++) {
            cout << arr[i][j];
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using lint = long long int;
using ulint = unsigned long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T, class U> void assign(V<T>& v, int n, const U& a) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


int main() {
  cin.tie(nullptr); ios_base::sync_with_stdio(false);
  int a, b; cin >> a >> b;
  cout << a * b / 2 << '\n';
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <array>
#include <string>
#include <cmath>
#include <iomanip>
#include <set>
#include <map>
#include <climits>
#include <utility>
#include <deque>
#include <list>
#include <stdexcept>
using namespace std;

int main()
{
	cout << fixed << setprecision(6);
	int q, h, s, d, n;
	cin >> q >> h >> s >> d >> n;
	auto res = 0ULL;

	auto onel = 1ULL * min({ q * 4, q * 2 + h * 1, h * 2, s });
	auto twol = 1ULL * min(onel * 2, (unsigned long long)d);
	res = twol * (n / 2) + onel * (n % 2);

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 768
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n, ans = 0;
		
		n = sc.nextInt();
		int a[] = new int[n];
		for(int i = 0; i < n; ++i) {
			int tmp = sc.nextInt();
			a[i] = tmp;
		}
		
		Arrays.sort(a);
		
		int count = 1;
		
		for(int i = 0; i < n - 1; ++i) {
			if(a[i] == a[i + 1])
				count++;
			else {
				if(count % 2 == 1)ans++;
				count = 1;
			}
		}
		
		if(count % 2 == 1)ans++;
		
		sc.close();
			System.out.println(ans);
	}

}


Measured memory_bytes: 49980
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>

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

//prototype declaration
int iin();
long long llin();
double din();
char cin();
void stin(char *s);
void iout(int i);
void llout(long long i);
void dout(double i);
void cout(char c);
void stout(char *s);
int gcd(int a, int b);
int lcm(int a, int b);
long long llgcd(long long a, long long b);
long long lllcm(long long a, long long b);
int asc(const void *a, const void *b);
int desc(const void *a, const void *b);
double to_deg(double rad);

//main function
int main() {
    int N = iin(), L = iin();
    char s[N][L];
    int index[N];
    int i, j, k;
    REP(i,N) {
        index[i] = i;
        stin(s[i]);
    }

    for (i = 0; i < N; i++) {
        for (j = i + 1; j < N; j++) {
            if (strcmp(s[index[i]], s[index[j]]) > 0) {
//                printf("i = %d, j = %d\n", i, j);
                k = index[i];
                index[i] = index[j];
                index[j] = k;
            }
        }
    }

    REP(i,N) {
//        printf("index = %d\n", index[i]);
        REP(j,L) {
            printf("%c", s[index[i]][j]);
        }
    }
    printf("\n");

    return 0;
}

//body function
int iin() {
    int i;
    scanf("%d", &i);
    return i;
}

long long llin() {
    long long i;
    scanf("%lld", &i);
    return i;
}

double din() {
    double i;
    scanf("%lf", &i);
    return i;
}

char cin() {
    char c;
    scanf("%c", &c);
    return c;
}

void stin(char *s) {
    scanf("%s", s);
}

void iout(int i) {
    printf("%d\n", i);
}

void llout(long long i) {
    printf("%lld\n", i);
}

void dout(double i) {
    printf("%lf\n", i);
}

void cout(char c) {
    printf("%c\n", c);
}

void stout(char *s) {
    printf("%s\n", s);
}

/*
    int型の最大公約数
*/

int gcd(int a, int b) {
    int r;

    if (a < b) {
        r = a;
        a = b;
        b = r;
    }

    r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }

    return b;
}

/*
    int型の最小公倍数
*/

int lcm(int a, int b) {
    int r = llgcd(a, b);
    a /= r;
    return a * b;
}

/*
    long long型の最大公約数
*/

long long llgcd(long long a, long long b) {
    long long r;

    if (a < b) {
        r = a;
        a = b;
        b = r;
    }

    r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }

    return b;
}

/*
    long long型の最小公倍数
*/

long long lllcm(long long a, long long b) {
    long long r = llgcd(a, b);
    a /= r;
    return a * b;
}

/*
    int型の昇順用比較関数
*/

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

/*
    int型の降順用比較関数
*/

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}

/*
    弧度法を度数法に
*/

double to_deg(double rad) {
    return rad * 180.0 / (atan(1.0) * 4.0);
}


Measured memory_bytes: 128
#include <iostream>
#include <list>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <algorithm>

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define MOD 1000000007

typedef long long ll;

using namespace std;
int main(){
    ll X;
    ll ans;
    cin >> X;
    ll i = 1;
    while (i * (i + 1) <= 2 * X) {
    	if (i * (i + 1) == 2 * X) break;
    	i++;
    }

    ans = i;
    cout << ans << endl;
}


Measured memory_bytes: 256
/*
[abc165] B - 1%
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
#define ALL(c) (c).begin(), (c).end()

ll X;

ll solve() {
    ll ans = 0;
    for (ll a = 100; a < X; a *= 1.01) {
        ans++;
    }

    return ans;
}

int main() {
    cin >> X;

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
int s;
map<int,int>m;
int main()
{
    cin>>s;m[s]++;
    int cnt=1;
    while(++cnt){
        if(s%2==0)s/=2;
        else s=s*3+1;
        if(m.find(s)!=m.end()){
            printf("%d",cnt);
            break;
        }
        m[s]++;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
namespace io{
	const int l=1<<20;
	char buf[l],*s,*t;
	inline char gc(){
		if(s==t){
			t=(s=buf)+fread(buf,1,l,stdin);
			return s==t?EOF:*s++;
		}
		return *s++;
	}
	char c;
	template<class IT>inline void gi(IT &x){
		x=0;c=gc();while(c<'0'||c>'9')c=gc();
		while('0'<=c&&c<='9'){x=(x<<1)+(x<<3)+(c^'0');c=gc();}
	}
};
using io::gi;
struct qwq{
	int a,b;
	inline bool operator<(const qwq &x)const{
		return a<x.a;
	}
};
template<class IT>inline void cmin(IT &a,IT b){if(b<a)a=b;}
template<class IT>inline void cmax(IT &a,IT b){if(a<b)a=b;}
const ll p=1000000007ll,inf=1000000000000000000ll;
const int N=200005;

int main(){
	int a,b;
	scanf("%d%d",&a,&b);
	printf("%d",(b+a-3)/(a-1));
	return 0;
}

Measured memory_bytes: 256
#dinic
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    
    # Dinic's algorithm
    from collections import deque
    class Dinic:
        def __init__(self, N):
            self.N = N
            self.G = [[] for i in range(N)]

        def add_edge(self, fr, to, cap):
            forward = [to, cap, None]
            forward[2] = backward = [fr, 0, forward]
            self.G[fr].append(forward)
            self.G[to].append(backward)

        def add_multi_edge(self, v1, v2, cap1, cap2):
            edge1 = [v2, cap1, None]
            edge1[2] = edge2 = [v1, cap2, edge1]
            self.G[v1].append(edge1)
            self.G[v2].append(edge2)

        def bfs(self, s, t):
            self.level = level = [None]*self.N
            deq = deque([s])
            level[s] = 0
            G = self.G
            while deq:
                v = deq.popleft()
                lv = level[v] + 1
                for w, cap, _ in G[v]:
                    if cap and level[w] is None:
                        level[w] = lv
                        deq.append(w)
            return level[t] is not None

        def dfs(self, v, t, f):
            if v == t:
                return f
            level = self.level
            for e in self.it[v]:
                w, cap, rev = e
                if cap and level[v] < level[w]:
                    d = self.dfs(w, t, min(f, cap))
                    if d:
                        e[1] -= d
                        rev[1] += d
                        return d
            return 0

        def flow(self, s, t):
            flow = 0
            INF = 10**9 + 7
            G = self.G
            while self.bfs(s, t):
                *self.it, = map(iter, self.G)
                f = INF
                while f:
                    f = self.dfs(s, t, INF)
                    flow += f
            return flow
        
    N=I()
    a=[0]*N
    b=[0]*N
    c=[0]*N
    d=[0]*N
    for i in range(N):
        a[i],b[i]=MI()
    
    for i in range(N):
        c[i],d[i]=MI()
    
    din=Dinic(2*N+2)
    for i in range(N):
        for j in range(N):
            if a[i]<c[j] and b[i]<d[j]:
                din.add_edge(1+j,1+i+N,1)
                    
    for i in range(N):
        din.add_edge(0,1+i,1)
        din.add_edge(1+i+N,2*N+1,1)
        
    print(din.flow(0,2*N+1))

main()


Measured memory_bytes: 43632
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=998244353;
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

int n;

int main(){
	cin>>n;
	ll g=0;
	for(int i=0;i<n;i++){
		int x,k;
		cin>>x>>k;
		while(x%k!=0){
			int d=x/k+1,t=x/k*k;
			x-=(x-t+d-1)/d*d;
		}
		g^=x/k;
	}
	cout<<(g?"Takahashi":"Aoki")<<endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ins insert
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define vll vector<ll>
#define sz(a) (ll)((a).size())
#define matrix vector<vector<ll>>
#define rep(i,a,b) for(ll i = a; i < b; i++)
#define repd(i,a,b) for(ll i = a; i >= b; i--)
#define tr(container,it) for(typeof(container.begin())it=container.begin();it!=container.end();it++)
#define set_bits(n) __builtin_popcount (n)
const ll MOD = 1000000007LL, INF = 1e9, LINF = 1e18;
const long double Pi = 3.141592653589793116, EPS = 1e-9;
const ll dx[4] = {0, 1, 0, -1};
const ll dy[4] = {1, 0, -1, 0};


int main()
{
    ll n;vll vc;

    cin>>n;
    rep(i,0,n){ll s;cin>>s;vc.pb(s);}

    ll suff[n+5],pref[n+5];

    pref[0]=vc[0];
    rep(i,1,n) pref[i]=max(pref[i-1],vc[i]);

    suff[n-1]=vc[n-1];
    repd(i,n-2,0) suff[i]=max(suff[i+1],vc[i]);

    cout<<suff[1]<<"\n";
    rep(i,1,n-1)
        cout<<max(suff[i+1],pref[i-1])<<"\n";
    cout<<pref[n-2]<<"\n";
    return 0;
}



Measured memory_bytes: 6384
a,b,m=map(int,input().split())
A=[int(i) for i in input().split()]
B=[int(i) for i in input().split()]

ans=99999999999
ans=min(A)+min(B)
for i in range(m):
    x,y,c=map(int,input().split())
    ans=min(ans,A[x-1]+B[y-1]-c)
print(ans)

Measured memory_bytes: 65212
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int amari = 0;
		
		for(int i=1000;i<=10000;i=i+1000) {
			if(N<=i) {
			 amari = i-N;
			 break;
			}
		}
		System.out.println(amari);
		sc.close();
	}

}

Measured memory_bytes: 35652
using System;
using System.Collections.Generic;

namespace AGC002_B
{
    class Program
    {       
        static int[] b = new int[100001];
        static int[] c = new int[100001];
        static int[] d = new int[100001];
        static bool[] e = new bool[100001];
        static void Main(string[] args)
        {
            var a = scan(); 
            for (int i = 1; i <= a[0]; i++)
            {
                b[i] = 1;
            }
           
            for (int i = 1; i <= a[1]; i++)
            {
                var t = scan();
                c[i] = t[0];
                d[i] = t[1];
            }
            e[1] = true;
            getans(a[1],1);
            Array.Sort(e);
            Array.Reverse(e);
            int sum = 0;
            for (int i = 0; i < 100001; i++)
            {
                if (!e[i])
                {
                    break;
                }
                sum++;
            }
            Console.WriteLine(sum);
            
        }
        static void getans(int M,int n)
        {
            while(M>=n)
            {
                if (e[c[n]])
                {
                    b[c[n]]--;
                    if (b[c[n]] == 0)
                    {
                        e[c[n]] = false;
                    }
                    b[d[n]]++;
                    e[d[n]] = true;
                }
                else
                {
                    b[c[n]]--;
                    b[d[n]]++;
                }
                n++;
            }
             
            
        }
        static int[] scan()
        {
            return
                Array.ConvertAll
                (Console.ReadLine().Split(' '),int.Parse);
        }
    }
}


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

  int n,Y,M,D;
  int sum_day;
  
  cin >>n;
  
  rep(i,n){
    
    cin >>Y>>M>>D;
    
    sum_day=0;

    while(1){
      
      if(Y==1000 && M==1 && D==1)break;
      
      D++;
      sum_day++;
      
      if(Y%3==0){
	if(D > 20){
	  M++;
	  D=1;
	}
      }else{
	if(M%2 == 0 && D > 19){
	  M++;
	  D=1;
	}else if(M%2 != 0 && D > 20){
	  M++;
	  D=1;
	}
      }
      
      if(M > 10){
	Y++;
	M=1;
      }
      
    }
    
    cout<<sum_day<<endl;
    
  }
  
  return 0;
}

Measured memory_bytes: 1160
using System;
using System.Collections.Generic;
using System.Linq;
class Program{
 static void Main(string[] args){
   var NY = Console.ReadLine().Split().Select(x => int.Parse(x)).ToList();
   int N = NY[0];
   int Y = NY[1] / 1000;
   for (int i = 0; i <= N; i++){
     for (int j = 0; j <= N - i; j++){
       int k = N - i - j;
       if (i * 10 + j * 5 + k * 1 == Y){
         Console.WriteLine($"{i} {j} {k}");
         return;
       }
     }
   }
   Console.WriteLine("-1 -1 -1");
 }
}


Measured memory_bytes: 13396
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define EB emplace_back
#define GREATER(T) T, VT<T> greater<T>
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

int main(void) {
    string S;
    cin >> S;

    bool ok = S[2] == S[3] && S[4] == S[5];

    cout << (ok ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <queue>
#include <functional>
#include <climits>
using namespace std;

template <typename T>
using pqueue = priority_queue<T, vector<T>, function<bool(T, T)>>;

int main() {
    array<array<int, 2>, 4> dm = {{
        { -1, 0 }, { 1, 0 }, { 0, -1 }, { 0, 1 },
    }};
    array<array<int, 2>, 25> dw = {{
        { -2, -2 }, { -2, -1 }, { -2, 0 }, { -2, 1 }, { -2, 2 },
        { -1, -2 }, { -1, -1 }, { -1, 0 }, { -1, 1 }, { -1, 2 },
        { 0, -2 }, { 0, -1 }, { 0, 0 }, { 0, 1 }, { 0, 2 },
        { 1, -2 }, { 1, -1 }, { 1, 0 }, { 1, 1 }, { 1, 2 },
        { 2, -2 }, { 2, -1 }, { 2, 0 }, { 2, 1 }, { 2, 2 },
    }};

    int h, w; cin >> h >> w;
    array<int, 2> c; for (auto &e : c) { cin >> e; --e; }
    array<int, 2> d; for (auto &e : d) { cin >> e; --e; }
    vector<string> field(h);
    for (auto &e : field) cin >> e;

    vector<vector<int>> cost(h, vector<int>(w, INT_MAX));
    cost[c[0]][c[1]] = 0;

    pqueue<array<int, 3>> que([](auto l, auto r) {
        return l[2] > r[2];
    });
    que.push({ c[0], c[1], 0 });

    while (!que.empty()) {
        auto [cy, cx, cc] = que.top(); que.pop();

        for (auto [dy, dx] : dm) {
            int ny = cy + dy, nx = cx + dx;
            if (ny < 0 || nx < 0 || h <= ny || w <= nx) continue;
            if (field[ny][nx] == '#') continue;

            if (cc < cost[ny][nx]) {
                cost[ny][nx] = cc;
                que.push({ ny, nx, cc });
            }
        }

        for (auto [dy, dx] : dw) {
            int ny = cy + dy, nx = cx + dx;
            if (ny < 0 || nx < 0 || h <= ny || w <= nx) continue;
            if (field[ny][nx] == '#') continue;

            if (cc + 1 < cost[ny][nx]) {
                cost[ny][nx] = cc + 1;
                que.push({ ny, nx, cc + 1 });
            }
        }
    }

    int ans = cost[d[0]][d[1]];

    if (ans != INT_MAX) {
        cout << ans << endl;
    }
    else {
        cout << -1 << endl;
    }
}



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

using i64 = int64_t;

int main(){
    int n;
    cin >> n;
    set<i64> st;
    for(int i=0;i<n;++i){
        i64 a;
        cin >> a;
        if(st.count(a))st.erase(a);
        else st.insert(a);
    }

    cout << st.size() << endl;

    return 0;
}


Measured memory_bytes: 4864
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<bitset>
using namespace std;

int main() {

	int N, K;
	cin >> N >> K;

	vector<int> A(N, 0);

	int d;
	int av;
	for (int i = 0; i < K; i++) {
		cin >> d;
		for (int j = 0; j < d; j++) {
			cin >> av;
			av--;
			A[av] += 1;
		}
	}

	int ans = 0;
	for (int i = 0; i < A.size(); i++) {
		if (A[i] == 0) {
			ans += 1;
		}
	}

	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 3628
/*
  Fuad Ashraful Mehmet Islam
  University of Asia Pacific,Bangladesh
  Date:6th May 2020
  ToDo:
  https://codeforces.com/problemset/problem/287/B
  https://atcoder.jp/contests/abc166/tasks/abc166_e
 */
#include<bits/stdc++.h>
#define dbg(x) cerr <<__LINE__<<" where "<< #x << " = " << x << endl
#define all(x) (x).begin(),(x).end()

using namespace std;
template <class T>
inline void read(T &res)
{
  res = 0; bool bo = 0; char c;
  while (((c = getchar()) < '0' || c > '9') && c != '-');
  if (c == '-') bo = 1; else res = c - 48;
  while ((c = getchar()) >= '0' && c <= '9')
    res = (res << 3) + (res << 1) + (c - 48);
  if (bo) res = ~res + 1;
}
const int N=2e5+5;
typedef long long ll;
int len,_,n,d,k,m,l,c,cs=1;
vector<ll>tree[N*4];
ll a[N],cal[N];
void Solve()
{
    read(n);
    for(int i=1;i<=n;++i)read(a[i]);
} /// end func

void build(int l,int r,int node=1)
{
    if(l==r)
    {
        tree[node].push_back(a[l]+l);
        return;
    }// base case
    int mid=(l+r)>>1;
    build(l,mid,node<<1);
    build(mid+1,r,node<<1|1);
    merge(all(tree[node<<1]),all(tree[node<<1|1]),back_inserter(tree[node]));
} /// end 

ll query(int l,int r,int x,int y,ll val,int node=1)
{
    if(l>y or r<x)return 0;
    if(l>=x and r<=y)
    {
        ll lo=lower_bound(all(tree[node]),val)-tree[node].begin();
        ll up=upper_bound(all(tree[node]),val)-tree[node].begin();
        return up-lo;
    }/// overlaped

    int mid=(l+r)>>1;
    return query(l,mid,x,y,val,node<<1)+query(mid+1,r,x,y,val,node<<1|1);
}/// end func
int main()
{
 // for(read(_);_;_--)
  Solve();
  build(1,n);
  ll ans=0LL;

  for(int i=1;i<=n;++i)
  {
      ans+=query(1,n,1,i,i-a[i]);
  }
  cout<<ans<<"\n";
  return 0;
}

Measured memory_bytes: 67496
#!/usr/bin/env python3
import sys
import itertools


def solve(N: int, P: "List[int]", Q: "List[int]"):
    l = []
    for i in range(N):
        l.append(i+1)

    p = 0
    q = 0
    c = 0
    for i in itertools.permutations(l, N):
        c += 1
        t = list(i)
        if t == P:
            p = c
        if t == Q:
            q = c
        if p != 0 and q != 0:
            print(abs(q - p))
            break

    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    P = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    Q = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, P, Q)

if __name__ == '__main__':
    main()


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

int func(int n, int s, int i){
	if(!n){
    	if(!s)return 1;
    	else return 0;
    }
	if(i >= 10 || s-i < 0)return 0;
	return func(n, s, i+1) + func(n-1, s-i, i+1);
}

int main(){
	int n, s;
	while(cin >> n >> s && (n || s)){
		cout << func(n, s, 0) << endl;
	}
	return 0;
}

Measured memory_bytes: 2980
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define Rep(n) for (ll _ = 0; _ < (ll)(n); _++)

template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
ll min(int a,ll b){return min((ll)a,b);} ll min(ll a,int b){return min(a,(ll)b);}
template <class S> void print(vector<S> &v){for(ll i=0; i<(ll)v.size(); i++){cerr << v[i] << ' ';}cerr << endl;}
template <class S> void print(vector<vector<S>> &v) {for (ll i = 0; i < (ll)v.size(); i++) {for (ll j = 0; j < (ll)v[i].size(); j++) {cerr << v[i][j] << ' ';}cerr << endl;}}

void Main();

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

struct UnionFind {
  vector<int> d;
  UnionFind(int n=0): d(n,-1) {}
  int find(int x) {
    if (d[x] < 0) return x;
    return d[x] = find(d[x]);
  }
  bool unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y);}
  int size(int x) { return -d[find(x)];}
};

void Main(){
	int n,m; cin >> n >> m;
	vector<int> p(n);
	rep(i,n) cin >> p[i];
	int x,y;
	UnionFind uf(n);
	Rep(m){
		cin >> x >> y;
		uf.unite(--x, --y);
	}
	int ans = 0;
	rep(i,n){
		ans += uf.same(i, p[i]-1);
	}
	cout << ans << endl;
}

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

struct Edge {
	int from, to, cost;
	Edge() { }
	Edge(int from, int to, int cost) {
		this->from = from;
		this->to = to;
		this->cost = cost;
	}
	bool operator<(const Edge &r) const {
		return cost < r.cost;
	}
};

struct UF {
	int par[10000];
	UF() { for (int i = 0; i < 10000; i++) par[i] = i; }
	int root(int x) { if (par[x] == x) return x; return par[x] = root(par[x]); }
	void unit(int x, int y) { x = root(x); y = root(y); par[x] = y; }
	bool same(int x, int y) { return root(x) == root(y); }
};

int n, m;
Edge edges[100000];
UF uf;

int main() {
	int i;
	
	cin >> n >> m;
	for (i = 0; i < m; i++) {
		int s, t, w;
		cin >> s >> t >> w;
		edges[i] = Edge(s, t, w);
	}
	
	sort(edges, edges + m);
	
	int ans = 0;
	for (i = 0; i < m; i++) {
		int u = edges[i].from;
		int v = edges[i].to;
		if (uf.same(u, v)) continue;
		uf.unit(u, v);
		ans += edges[i].cost;
	}
	
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4296
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <stack>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;
typedef long long int ll;
const ll modP = 1000000007;


int main()
{
	int n,m,c;
	cin>>n>>m>>c;
	vector<int> B(m);
	rep(i,m) cin>>B[i];
	vector<vector<int>> A = vector<vector<int>>(n);
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			int num;
			cin>>num;
			A[i].push_back(num);
		}
	}
	int ans = 0;
	for(int i = 0; i < n; i++){
		ll sum = 0;
		for(int j = 0; j < m; j++){
			sum += A[i][j] * B[j];
		}
		if( sum + c > 0) ans++;
	}
	
	cout<<ans<<endl;
	return 0;
}


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

template <class F>
int upper_bound(int i0, int i1, F f) {
    while (i0 < i1) {
        int i = (i0 + i1) / 2;
        if (f(i)) i0 = i + 1; else i1 = i;
    }
    return i0;
}

struct P {
    char t, d;
};

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

    int n, q;
    cin >> n >> q;

    string s;
    cin >> s;

    vector<P> p(q);
    for (int h = 0; h < q; h++) {
        cin >> p[h].t >> p[h].d;
    }

    int i[2];
    for (int k = 0; k < 2; k++) {
        i[k] = upper_bound(0, n, [&](int i) {
            for (int h = 0; h < q; h++) {
                if (s[i] == p[h].t) {
                    if (p[h].d == 'L') {
                        if (--i < 0) break;
                    } else {
                        if (++i >= n) break;
                    }
                }
            }
            return k == 0 ? i < 0 : i < n;
        });
    }

    cout << i[1] - i[0] << endl;

    return 0;
}

Measured memory_bytes: 976
'use strict';
process.stdin.on('data', function(chunk) {
    var inputs = chunk.toString().trim().split(' ');
    var a = Number(inputs[0]);
    var b = Number(inputs[1]);
    var c = Number(inputs[2]);

    var  table =  [a,b,c].sort(function(a,b) {
    	return a - b;
    });
    console.log(table.join(' '));
});
process.stdin.resume();
process.stdin.setEncoding('utf8');

Measured memory_bytes: 15560
s=input()
t=input()
ans=1500
for i in range(len(s)-len(t)+1):
	ssub=s[i:i+len(t)]
	cnt=0
	for j in range(len(t)):
		if(ssub[j]==t[j]):
			continue
		else:
			cnt+=1
	if(ans>cnt):
		ans=cnt
print(ans)

Measured memory_bytes: 9108
#include<cstring>
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
#include<map>
using namespace std;

int main(){
	int n;
	cin>>n;
	int s;
	if(n>=3) s=n/3;
	if(n<3) s=0;
	printf("%d",s);
}

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

#define ll long long

#define mod 1000000007

#define pb push_back

#define pi pair<int,int>

#define pll pair<ll,ll>

#define inf 1000000000000000000

using namespace std;

string k;

int d;

ll dp[10010][100][2];

ll fun(int pos, int rem, int equal){

	if(pos == k.length()){		if(rem){

			return 0;

		}

		else{

			return 1;

		}

	}

	if(dp[pos][rem][equal] != -1){

		return dp[pos][rem][equal];

	}

	dp[pos][rem][equal] = 0;

	if(equal){

		for(int num = 0; num < k[pos] - '0'; num++){

			dp[pos][rem][equal] += fun(pos + 1, (rem - num + 10 * d) % d, 0);

		}

		dp[pos][rem][equal] += fun(pos + 1, (rem - (k[pos] - '0') + 10 * d) % d, 1);

	}

	else{

		for(int num = 0; num < 10; num++){

			dp[pos][rem][equal] += fun(pos + 1, (rem - num + 10 * d) % d, 0);

		}

	}

	dp[pos][rem][equal] %= mod;

	return dp[pos][rem][equal];

}

int main(){

	ios::sync_with_stdio(false);

	cin.tie(0);

	cin>>k;

	cin>>d;

	for(int i = 0; i < k.length(); i++){

		for(int j = 0; j < d; j++){

			dp[i][j][0] = -1;

			dp[i][j][1] = -1;

		}

	}

	ll ans = fun(0, 0, 1) - 1 + mod;

	ans %= mod;

	cout<<ans<<endl;

	return 0;

}

Measured memory_bytes: 16640
#include <iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <cstring>
#include <map>
using namespace std;
typedef long long ll;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
	ll x; cin >> x;
	int day = 0;
	ll s = 100;
	while (1) {
		if (x <= s) {
			cout << day << '\n'; return 0;
		}
		s += (s / (ll)100);
		day += 1;
	}

}

Measured memory_bytes: 3196
#include<bits/stdc++.h>
using namespace std;
int gcd(int x,int y);
int main(){
  long n,i,j,ans,flag,pmin,mmax;
  cin>> n;
  flag=0;
  ans=0;
  pmin=1000000001;
  mmax=-1000000001;
  vector<int> a(n),b(n);
  for(i=0;i<n;i++)
  {
    cin >> a.at(i);
    b.at(i)=(-1)*a.at(i);
    if(b.at(i)>=0) {flag++;
     if(mmax<=a.at(i)) mmax=a.at(i);
         ans+=b.at(i);
                   }
    if(a.at(i)>0)
    {
      if(pmin>=a.at(i)) pmin=a.at(i);
      ans+=a.at(i);
    }
  }
  if(flag%2==0) cout << ans << endl;
  if(flag%2==1) 
  {
     if( pmin<=(-1)*mmax) cout << ans-pmin-pmin<< endl;
     if( pmin>(-1)*mmax)  cout << ans+mmax+mmax<< endl;
  }
       
                    
                    
  }

Measured memory_bytes: 1024
#include<cstdio>
#include<algorithm>
#include<queue>
using namespace std;
const int N=200005;
struct node
{
	int h;
	long long d;
}t;
bool operator <(node a,node b)
{
	return a.d>b.d;
}
priority_queue<node> q;
int n,m,i,j,k,ch1[N*5][2],ch2[N*5][2],cnt,num1,num2,head[N*5],adj[N*350],nxt[N*350],len[N*350],l,st,ed;
long long dis[N*5];
bool v[N*5];
void addedge(int u,int v,int w)
{
	adj[++l]=v;
	nxt[l]=head[u];
	head[u]=l;
	len[l]=w;
	//printf("%d %d %d\n",u,v,w);
}
void built(int o1,int o2,int l,int r)
{
	if(l==r)
	{
		if(l==1)
			st=o1;
		if(l==n)
			ed=o2;
		return;
	}
	int mid=l+r>>1;
	ch1[o1][0]=++cnt;
	if(l<mid)
		ch2[o2][0]=++cnt;
	else
		ch2[o2][0]=cnt;
	built(ch1[o1][0],ch2[o2][0],l,mid);
	ch1[o1][1]=++cnt;
	if(mid+1<r)
		ch2[o2][1]=++cnt;
	else
		ch2[o2][1]=cnt;
	built(ch1[o1][1],ch2[o2][1],mid+1,r);
	addedge(ch1[o1][0],o1,0);
	addedge(ch1[o1][1],o1,0);
	addedge(o2,ch2[o2][0],0);
	addedge(o2,ch2[o2][1],0);
}
void update2(int o,int l,int r,int g)
{
	if(l>=i&&r<=j)
	{
		addedge(g,o,k);
		return;
	}
	int mid=l+r>>1;
	if(i<=mid)
		update2(ch2[o][0],l,mid,g);
	if(j>mid)
		update2(ch2[o][1],mid+1,r,g);
}
void update1(int o,int l,int r)
{
	if(l>=i&&r<=j)
	{
		update2(2,1,n,o);
		return;
	}
	int mid=l+r>>1;
	if(i<=mid)
		update1(ch1[o][0],l,mid);
	if(j>mid)
		update1(ch1[o][1],mid+1,r);
}
int main()
{
	scanf("%d%d",&n,&m);
	num1=1,num2=cnt=2;
	built(1,2,1,n);
	while(m--)
	{
		scanf("%d%d%d",&i,&j,&k);
		update1(1,1,n);
	}
	for(i=1;i<=cnt;++i)
		dis[i]=1ll<<60;
	dis[st]=0;
	q.push((node){st,0});
	while(!q.empty())
	{
		t=q.top();
		q.pop();
		if(v[t.h])
			continue;
		for(i=head[t.h];i;i=nxt[i])
			if(t.d+len[i]<dis[adj[i]])
			{
				dis[adj[i]]=t.d+len[i];
				q.push((node){adj[i],dis[adj[i]]});
			}
	}
	if(dis[ed]==(1ll<<60))
		printf("-1");
	else
		printf("%lld",dis[ed]);
	return 0;
}


Measured memory_bytes: 281712
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vl vector<LL>
#define vii vector<vi>
#define vll vector<vl>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

class BIT//1-index
{
public:
    vector<int> bit;
    int M;

    BIT(int M=1):
        bit(vector<int>(M+1, 0)), M(M) {}

    int sum(int i) {//1~iまでの和
        if (!i) return 0;
        return bit[i] + sum(i-(i&-i));
    }

    void add(int i, int x) {//bit[i]にxを足す更新
        if (i > M) return;
        bit[i] += x;
        add(i+(i&-i), x);
    }
};


int main(){
	int n,q;
    string s;
    cin>>n>>s>>q;
    BIT bt[30];
    FOR(i,0,30){
        bt[i]=BIT(n+3);
    }
    FOR(i,0,n){
        bt[s[i]-'a'].add(i+2,1);
    }


    FOR(qi,0,q){
        int t;
        cin>>t;
        if(t==1){
            int i;
            string c;
            cin>>i>>c;
            int j=c[0]-'a';
            int k=s[i-1]-'a';
            s[i-1]=c[0];
            i+=1;
            bt[j].add(i,1);
            bt[k].add(i,-1);
        }else{
            //cerr<<"q2:";
            int l,r;
            cin>>l>>r;
            l+=0;
            r+=1;
            int ans=0;
            FOR(i,0,'z'-'a'+1){
                if(bt[i].sum(r)-bt[i].sum(l)>0){
                    ans++;
                    //cerr<<(char)(i+'a')<<" ";
                }
            }
            cout<<ans<<endl;


        }
    }

}


Measured memory_bytes: 59652
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner input = new Scanner(System.in);
		int n = input.nextInt();
		int[] heap = new int[n];

		for(int i = 0; i < n; i++) {
			heap[i] = input.nextInt();
		}
		
		for(int i = 1; i < heap.length + 1; i++) {
			System.out.print("node " + i + ": ");
			System.out.print("key = " + heap[i - 1] + ", ");
			
			if(i != 1)
				System.out.print("parent key = " + heap[i/2 - 1] + ", ");
			if(2*i - 1 < heap.length)
				System.out.print("left key = " + heap[2*i - 1] + ", ");
			if(2*i < heap.length)
				System.out.print("right key = " + heap[2*i] + ", ");
			
			System.out.println();
		}

	}

}



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

using namespace std;

int main()
{
    int n,i,j;
    long sum=0;

    cin >> n;

    vector<long> a(n+1),b(n);

    for(i=0; i<n+1; i++){
        cin >> a.at(i);
    }
    for(i=0; i<n; i++){
        cin >> b.at(i);
    }

    for(i=0; i<n; i++){
        if(a.at(i) > b.at(i))
            //街nの一部を退治
        {
            sum += b.at(i);
        }
        else if(a.at(i+1) > b.at(i) - a.at(i) )
            //街nを殲滅後、n+1の一部を退治
        {
                a.at(i+1) -= b.at(i) - a.at(i);
                sum += b.at(i);
        }
        else  //街n+1まで殲滅
        {
                sum += (a.at(i) + a.at(i+1));
                a.at(i+1) = 0;
        }
    }

    
    cout << sum << endl;
    
   return 0;
}

Measured memory_bytes: 4852
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repo(i, n) for(int i=1; i<=n; i++)
#define INF 1001001001
#define INFll 100100100100100
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

using namespace std;
using ull = unsigned long long;
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

int main(){
  ll x, k, d, ans;
  cin >> x >> k >> d;
  if(x<0){
    x=-x;
  }
  ll r=x%d, q=x/d;
  if(q >= k){
    ans=x-k*d;
  } else if((k-q)%2ll==0ll) {
    ans=x-q*d;
  } else {
    ans=-(x-q*d-d);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();

int main()
{
    int N, M;
    cin >> N >> M;
    int left_b, right_b;
    cin >> left_b >> right_b;
    for (int i = 1; i < M; i++){
        int left, right;
        cin >> left >> right;
        left_b = max(left, left_b);
        right_b = min(right, right_b);
    }
    int ans = right_b - left_b + 1;
    ans = max(ans, 0);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    int n;
    cin>>n;
    vector<ll> b(n);
    for(int i=0;i<n;++i)
    {
        cin>>b[i];
        b[i]*=2;
    }
    ll sum = 0;
    for(ll x:b)
        sum+=x;
    sum/=2;
    ll oddsum = 0;
    for(int i=0;i<n-1;i+=2)
        oddsum += b[i];
    vector<ll> ans(n);
    ans[n-1] = sum - oddsum;
    for(int i=n-2;i>=0;--i)
    {
        ans[i] = b[i] - ans[i+1];
    }
    for(auto x:ans)
        cout<<x<<" ";
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repf(i,a,b) for (int i = (a); i < (b); i++)
#define repi(i,a,b) for (int i = (a); i <= (b); i++)
#define repr(i,a,b) for (int i = (a); i >= (b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define debug(x)  cout << #x << " = " << (x) << endl;
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;
using tiii = tuple<int, int, int>;

int main() {
  int N, L; cin >> N >> L;
  vs S(N); rep(i,N) cin >> S.at(i);
  
  sort(all(S));
  rep(i,N) {
    cout << S.at(i);
  }
  
  cout << endl; 
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
        public static void main(String[] args){
                Scanner コロナ = new Scanner(System.in);
                String わたし = コロナ.next();
                String あなた = コロナ.next();
                コロナ.close();
                int yoﾉ = 0;
                for(int i = 0 ; i < 3 ; i++){
                        if(わたし.charAt(i) == あなた.charAt(i)) yoﾉ++;
                }
                System.out.println(yoﾉ);
        }
}

Measured memory_bytes: 35560
while True:
    a,op,b=input().split()
    if op=="?":
        break
    a=int(a)
    b=int(b)
    if op=="+":
        print(a+b)
    if op=="-":
        print(a-b)
    if op=="*":
        print(a*b)
    if op=="/":
        print(a//b)

Measured memory_bytes: 7660
a,b,c= map(int, input().split())
k=int(input())
n = 0
m = 0
if a >= b:   
    while True: 
        b = 2*b
        n   =   n+1
        if  a    <   b:
            break
if b >= c:   
    while True: 
        c = 2*c
        m   =   m+1
        if  b    <   c:
            break                  
if m+n<=k:
    print('Yes')
else:
    print('No')    

Measured memory_bytes: 9192
#include <iostream>
#include <vector>
#include <string>

using namespace std;

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


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

int main() {
    string s;
    int k;
    cin >> s >> k;
    for (int i = 0; i < s.length(); i++) {
        if (s[i] != '1' || i == k - 1) {
            cout << s[i] << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static void main(String[]args){
        Scanner sc=new Scanner(System.in);
        int A=sc.nextInt();
        int B=sc.nextInt();
        int C=sc.nextInt();
        if(A==B){
            System.out.println(C);
        }
        if(A==C){
            System.out.println(B);
        }
        if(B==C){
            System.out.println(A);
        }
        
    }
}

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

using namespace std;

#define int long long
#define ll long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl




signed main(){

	int N;
	vector<int> v, c;
	cin >> N;
	v.resize(N);
	c.resize(N);
	rep(i, N) cin >> v[i];
	rep(i, N) cin >> c[i];

	int ans = 0;
	rep(i, N){
		if (v[i] > c[i]) ans += v[i] - c[i];
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
S = input()
before = int(S[0:2])
after = int(S[2::])
if 0 < before <= 12 and 0 < after <= 12:    
    print('AMBIGUOUS')
elif 0 < before <= 12:
    print('MMYY')
elif 0 < after <= 12:
    print('YYMM')
else:
    print('NA')


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
typedef long long ll;
const int MOD = 1000000007;
#define PI 3.141592653589
using namespace std;

int main() {
	int s, w;
	cin >> s >> w;
	cout << (s <= w ? "unsafe": "safe") << endl;
	return 0;
}


Measured memory_bytes: 3624
import sys
import math
def i():return int(sys.stdin.readline().replace("\n",""))
def i2():return map(int,sys.stdin.readline().replace("\n","").split())
def s():return str(sys.stdin.readline().replace("\n",""))
def l():return list(sys.stdin.readline().replace("\n",""))
def intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def lx():return list(map(lambda x:int(x)*-1,sys.stdin.readline().replace("\n","").split()))
def t():return tuple(map(int,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":pass
a ,b =i2()
n = int(a//0.08)
m = int(b//0.1)
for i in range(n+1,2*n):
    for j in range(m+1,2*m):
        if i == j and math.floor(i*0.08) == a  and b == math.floor(j*0.1):
            print(i)
            exit()
print(-1)

Measured memory_bytes: 3064
import sys
n = int(input())
words=[]
for i in range(n):
	words += [input()]
for i in range(n-1):
	for j in range(i+1, n):
		if words[i] == words[j]:
			print('No')
			sys.exit()
	if words[i][-1] != words[i+1][0]:
		print('No')
		sys.exit()
print('Yes')

Measured memory_bytes: 3060
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<deque>
using namespace std;
typedef long long ll;
typedef pair<ll, ll>pii;
typedef pair<pii, ll>pi3;
ll mod = 1000000007;
char a[50][50], b[50][50];
int main()
{
	int n;
	scanf("%d", &n);
	ll t = 1;
	for (int i = 1; i <= n; i++)t = t*i%mod;
	cout << t << endl;
}

Measured memory_bytes: 256
def 解():
    iN = int(input())
    ans = []
    while True:
        if iN in {1,0}:
            ans.append(iN)
            break
        if iN < 0 :
            if iN == -1:
                iN = 1
                ans.append(1)
            else:
                iN *= -1
                ans.append(iN % 2)
                if iN % 2 :
                    iN //= 2
                    iN += 1
                else:
                    iN //= 2

        else:
            ans.append(iN % 2)
            iN //= 2
            iN *= -1
    print("".join(map(str,ans[::-1])))
解()


Measured memory_bytes: 3064
import java.awt.SystemTray;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        try {
            String line = reader.readLine();
            int time = Integer.parseInt(line);
            int seconds = time % 60;
            int minutes2 = (time - seconds)/60;
            int minutes = minutes2 % 60;
            int hours = minutes2 / 60;
            System.out.println(hours+":"+minutes+":"+seconds);
        }  catch (IOException e) {
            System.out.println(e);
        }  
    }
}


Measured memory_bytes: 24204
#include<bits/stdc++.h>
#define pb           push_back
#define pii          pair<int,int>
#define vi           vector<int>
#define vii         vector<pair<int,int>>
#define mp           make_pair
#define FOR(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD0(i, n) for (int i = (int)n; i >= 0; i--)
#define FORD1(i, n) for (int i = (int)n; i >= 1; i--)
#define debug(X) { cout << #X << " = " << (X) << endl; }
#define endl '\n'
#define int long long int
using namespace std;
vi adj[(int)2e5];
map<int, bool> vis;
map<int, bool> col;
bool bi = true;
void dfs(int cur, bool c){
    if(vis[cur]){
        if(col[cur] != c)bi = false;
        return; 
    }
    vis[cur] = true;
    col[cur] =c;
    for(int child:adj[cur]){
        dfs(child, !c);
    }
}
signed main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);

    int n, m;cin >> n >> m;
    FOR(i, m){
        int x, y;cin >> x >> y;
        x--, y--;
        adj[x].pb(y);
        adj[y].pb(x);
    }
    int comp1 = 0, bii= 0, bi1 = 0;
    int prev = 0;
    FOR(i, n){
        if(!vis[i]){
            bi = true;
            dfs(i, false);
            int gp = vis.size() - prev;
            if(gp == 1)comp1++;
            else if(bi)bii++;
            else bi1++;
        } 
        prev = vis.size(); 
    }

   // debug(bii);
    
    //debug(bi1);
    int ans = comp1*comp1 + comp1 * (n- comp1) *2;
    //debug(ans);
    ans += bi1*bii*2;
    ans += bii*bii*2;
    ans += bi1*bi1;
    cout << ans;
}





Measured memory_bytes: 29056
fn b() {
    input! {
        a: i64,
        b: i64,
        c: i64,
        k: i64
    }
    let ones = if a < k { a } else { k };
    if k - (a + b) < 0 {
        println!("{}", ones);
    }
    else {
        println!("{}", ones - (k - (a + b)));
    }
}

use proconio::input;
use proconio::marker::Chars;

fn main() {
    b();
}

Measured memory_bytes: 2080