akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;

typedef pair<int, int> P;

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

int H, W;
int field[8][8];
bool arrive[8][8][8][8][8][8];

void init(){
  memset(field, 0, sizeof(field));
  memset(arrive, false, sizeof(arrive));
}

void canArrive(int bx, int by, int sx, int sy){
  int tmp_field[8][8];
  memset(tmp_field, 0, sizeof(tmp_field));
  for(int i = 0 ; i < H ; i++){
    for(int j = 0 ; j < W ; j++){
      if(field[i][j] != 1) tmp_field[i][j] = 0;
      else tmp_field[i][j] = field[i][j];
    }
  }
  
  tmp_field[by][bx] = 2;

  queue<P> que;
  que.push(P(sx, sy));
  while(!que.empty()){
    P q = que.front(); que.pop();
    arrive[by][bx][sy][sx][q.second][q.first] = true;
    
    for(int i = 0 ; i < 4 ; i++){
      int nx = q.first + dx[i], ny = q.second + dy[i];
      if(nx < 0 || nx >= W || ny < 0 || ny >= H) continue;
      if(tmp_field[ny][nx] != 0) continue;
      if(arrive[by][bx][sy][sx][ny][nx]) continue;
      que.push(P(nx, ny));
    }    
  }
}


struct State{
  int x, y, sx, sy, cost;
  State(int x, int y, int sx, int sy, int cost) : x(x), y(y), sx(sx), sy(sy), cost(cost){}
};

const bool operator < (const State &a, const State &b){
  return a.cost > b.cost;
}

int bfs(){
  int sx, sy, bx, by;
  for(int i = 0 ; i < H ; i++){
    for(int j = 0 ; j < W ; j++){
      if(field[i][j] == 2) bx = j, by = i;
      if(field[i][j] == 4) sx = j, sy = i;
    }
  }
  
  priority_queue<State> que;
  que.push(State(bx, by, sx, sy, 0));
  
  bool used[8][8][8][8];
  memset(used, false, sizeof(used));
  
  while(!que.empty()){
    State p = que.top(); que.pop();

    if(field[p.y][p.x] == 3) return p.cost;    

    if(used[p.y][p.x][p.sy][p.sx]) continue;
    used[p.y][p.x][p.sy][p.sx] = true;
    
    for(int i = 0 ; i < 4 ; i++){
      int nx1, nx2, ny1, ny2;
      nx1 = p.x + dx[i], ny1 = p.y + dy[i];
      nx2 = p.x - dx[i], ny2 = p.y - dy[i];
      if(nx1 < 0 || nx1 >= W || ny1 < 0 || ny1 >= H ||
	 nx2 < 0 || nx2 >= W || ny2 < 0 || ny2 >= H) continue;
      if(field[ny1][nx1] == 1) continue;
      if(field[ny2][nx2] == 1) continue;
      if(!arrive[p.y][p.x][p.sy][p.sx][ny2][nx2]) continue;      
      que.push(State(nx1, ny1, nx2, ny2, p.cost+1));
    }    
  }
  return -1;
}

int main(){
  while(cin >> W >> H, W|H){
    init();
    
    for(int i = 0 ; i < H ; i++)
      for(int j = 0 ; j < W ; j++) cin >> field[i][j];
    
    for(int by = 0 ; by < H ; by++){
      for(int bx = 0 ; bx < W ; bx++){
	if(field[by][bx] == 1) continue;
	for(int sy = 0 ; sy < H ; sy++){
	  for(int sx = 0 ; sx < W ; sx++){
	    if(sy == by && sx == bx) continue;
	    if(field[sy][sx] == 1) continue;
	    canArrive(bx, by, sx, sy);
	  }
	}
      }
    }

    cout << bfs() << endl;
    
  }

  return 0;
}

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

using namespace std;

int main()
{
	int a, b;
	char op;
	vector<int> v;
	
	while(true)
	{
		scanf("%d %c %d", &a, &op, &b);
		
		if(op == '/')
		{
			if(b > 0)
				v.push_back(a/b);
		}
		else if(op == '+')
			v.push_back(a+b);
		else if(op == '-')
			v.push_back(a-b);
		else if(op == '*')
			v.push_back(a*b);
		else
			break;
	}
	
	for(int i = 0; i < v.size(); i++)
		printf("%d\n", v[i]);
	
	return 0;
}


Measured memory_bytes: 3256
#0WA n==1 mod saikikilimit exit
import sys
input = sys.stdin.readline

n = int(input())
v = list(map(int,input().split()))
c = list(map(int,input().split()))
ans = [0]
for i in range(n):
    if v[i]-c[i] >0:
        ans.append(v[i]-c[i])
print(sum(ans))

Measured memory_bytes: 3060
#include <iostream>
#include <sstream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    lint X;
    cin >> X;
    lint first = max(X - 100, 0LL);
    // t * 11 >= first.
    lint t = first == 0 ? 0 : (first - 1) / 11 + 1;
    lint ret = t * 2;
    t *= 11;
    int sideUp = 6;
    while (t + 11 < X) {
        t += 11;
        ret += 2;
    }

    // t + 11 >= X
    if (t + 6 >= X)
        ret++;
    else ret += 2;
    cout << ret << endl;
    return 0;
};


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

typedef double du ;
typedef string st ;
typedef long long ll ;
typedef long double ld ;
typedef long long int lli ;

#define vi vector <lli>
#define loop(num) for (lli i = 0 ; i < num ; i ++ )
#define loopcin(num , ar ) for (lli i = 0 ; i < num ; i ++ ) {cin >> ar [i] ;}
#define loopcout(num , ar) for (lli i = 0 ; i < num ; i ++ ) {cout << ar [i] << ' '; }

#define forr(num1 , num2) for (lli i = num1 ; i < num2 ; i ++ )
#define forrcin(num1 , num2 , ar ) for (lli i = num1 ; i < num2 ; i ++ ) {cin >> ar [i] ;}
#define forrcout(num1 , num2 , ar) for (lli i = num1 ; i < num2 ; i ++ ) {cout << ar [i] << ' '; }

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main ()
{
    fastio

    lli he , ata , cnt = 0 ;

    cin >> he >> ata ;

    for (lli i = he ; i >= 1 ; i -= ata)
    {
        cnt ++ ;
    }
    cout << cnt << endl ;

    return 0 ;
}

/*___________________________________________________________________functions___________________________________________________________________________*/


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

def main():
    N, M = map(int, input().split())
    xy = [list(map(int, input().split())) for i in range(M)]
    box = [1] * N
    red_flag = [0] * N
    red_flag[0] = 1
    ans = 0
    for i in range(M):
        if red_flag[xy[i][0] - 1] == 1:
            red_flag[xy[i][1] - 1] = 1
        box[xy[i][0] - 1] -= 1
        if box[xy[i][0] - 1] == 0:
            red_flag[xy[i][0] - 1] = 0
        box[xy[i][1] - 1] += 1
    print(sum(red_flag))


if __name__ == "__main__":
    main()


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

#define range(i, a, b) for(int i = (a); i < (b); i++)
#define times(i, n) range(i, 0, n)

template<class T> T next() {
	T t;
	cin >> t;
	return t;
}

int main(){
	int n = next<int>();
	char s[30];
	cin >> s;
	int ans = 0;
	int ln = strlen(s);
	times(i, n){
		char str[120];
		cin >> str;
		int len = strlen(str);
		times(j, strlen(str)){
			if(s[0]!=str[j]) continue;
			for(int k = 1; j + k * (ln - 1) < len; k++){
				// cout << j << " " << k << endl;
				for(int l = 1;l<ln;l++){
					if(s[l] != str[j+k*l]){
						goto nextDur;
					}
				}
				// cout << i << endl;
				ans++;
				goto nextStr;
				nextDur:;
			}
		}
		nextStr:;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1164
N,H = map(int,input().split())
katana = []
damage = 0
for n in range(N):
    katana.append(list(map(int,input().split())))

katanaA = sorted(katana,reverse = True)
katanaB = sorted(katana, key = lambda x:x[1],reverse = True)
numb = 0
num = 0
check = True
while damage < H:
    if katanaA[0][0] <= katanaB[numb][1] and check:
        damage += katanaB[numb][1]
        numb += 1
        if numb == N:
            numb = N-1
            check = False
    else:
        num += (H-damage)//katanaA[0][0]
        if  (H-damage)%katanaA[0][0] == 0:
            num -= 1
        damage = H
    num += 1 
print(num)


Measured memory_bytes: 30728
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    int n;
    cin>>n;
    map<int , ll>mp;
    int arr[n];
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
        mp[arr[i]]++;
    }
    ll sum=0;
    map<int , ll>::iterator it=mp.begin();
    for( ;it!=mp.end();it++)
    {
        ll a=(*it).second;
        sum+=(a-1)*a/2;
    }
    for(int i=0;i<n;i++)
    {
        int a=arr[i];
        a=mp[arr[i]]-1;
        ll s=sum;
        s=s-(a+1)*a/2+a*(a-1)/2;
        cout<<s<<"\n";
    }
    return 0;
}


Measured memory_bytes: 10240
from itertools import chain

alph = "abcdefghijklmnopqrstuvwxyz"
# s = input()

def solve1(s):
    cands = [s]
    for c in reversed(alph[:-1]):
        cands = chain.from_iterable(
            [candidates(s, c) for s in cands]
        )

    cands = list(cands)
    cands.sort()
    print(len(cands))
    if len(cands) > 10:
        for s in cands[:5]:
            print(s)
        for s in cands[-5:]:
            print(s)
    else:
        for s in cands:
            print(s)
            
            
def next_char(c):
    return chr(ord(c)+1)

def candidates(string, key):
    nex = next_char(key)
    flag = False
    for i, c  in enumerate(string):
        if c == nex:
            flag = True
            break

        if c != key:
            continue

        yield string[:i] + nex + string[i+1:]

    if not flag:
        yield string
            



while True:
    s = input()
    if s == "#":
        break
    solve1(s)

Measured memory_bytes: 19888
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;

int main()
{
        int N;
        int A[200010] = {0};
        cin >> N;

        int max = -1;
        int max2 = -1;
        for(int i = 0; i < N; i++)
        {
                cin >> A[i];
                if(A[i] > max) max = A[i];
                else if(A[i] > max2) max2 = A[i];
        }

        for(int i = 0; i < N; i++)
        {
                if(A[i] == max) cout << max2 << endl;
                else cout << max << endl;
        }

        return 0;
}

Measured memory_bytes: 2432
import sys, bisect, math, itertools, string, queue, copy
import numpy as np
import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

n = inp()
S = input()
tmp = string.ascii_uppercase

ans = []
for s in S:
    i = string.ascii_uppercase.index(s)
    if i+n > 25:
        ans.append(tmp[i+n-26])
    else:
        ans.append(tmp[i+n])

print(''.join(ans))

Measured memory_bytes: 31224
#include <iostream>
#include <queue>

using namespace std;

long A[100000];
long pow_[40];

void init(){
    pow_[0] = 1;
    for(long i = 1; i < 40; i++){
        pow_[i] = pow_[i-1]*2;
    }
}

long pow(long n){
    if(n > 35){
        return 2e+9;
    }else{
        return pow_[n];
    }
}

typedef pair<long, long> P;
priority_queue<P> que;
long cnt[100000];

int main(){
    long N, M;
    cin >> N >> M;
    init();
    for(long i = 0; i < N; i++){
        cin >> A[i];
        que.push(P(A[i], i));
    }
    for(long i = 0; i < M; i++){
        P top = que.top();
        que.pop();
        long idx = top.second;
        long p = top.first;
        cnt[idx]++;
        p = A[idx]/pow(cnt[idx]);
        que.push(P(p, idx));
    }
    long ans = 0;
    while(!que.empty()){
        P top = que.top();
        que.pop();
        ans += top.first;
        //cout << top.first << endl;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
#define MOD (1000*1000*1000+7)
using namespace std;
const int mxN=1010;
int dp[mxN][mxN];

int main()
{
	for(int i=0;i<mxN;i++)
		for(int j=0;j<mxN;j++)
			dp[i][j]=1;
	
   int n,m;
   cin>>n>>m;

   char ar[n+1][m+1];

   for(int i=0;i<n;i++)
   {
   		for(int j=0;j<m;j++)
   		{
   			cin>>ar[i][j];
   			if(ar[i][j]=='#')
   				dp[i][j]=0;
   		}
   }
   
   dp[0][0]=0;
   int c=1;
   for(int i=1;i<m;i++)
   {
   		if(dp[0][i]==0)
   			c=0;
   		dp[0][i]=c;
   }
   c=1;
   for(int i=1;i<n;i++)
   {
   		//cout<<dp[i][0]<<" ";
   		if(dp[i][0]==0)
   			c=0;
   		dp[i][0]=c;
   }

   for(int i=1;i<n;i++)
   {
   		for(int j=1;j<m;j++)
   		{
   			if(ar[i][j]=='#') continue;
   			dp[i][j]=dp[i-1][j]+dp[i][j-1];
   			dp[i][j]=dp[i][j]%MOD;
   		}
   }
   /*for(int i=0;i<n;i++)
   {
   		for(int j=0;j<m;j++)
   		{
   			cout<<dp[i][j]<<" ";
   		}
   		cout<<"\n";
   }*/
   cout<<dp[n-1][m-1]%MOD<<"\n";
    
    
	return 0;
}

Measured memory_bytes: 5248
N = int(input())
A = list(map(int,input().split()))
i = 0
j = 0

for i in A:
  if i % 2 == 0:
    if i % 3 == 0 or i % 5 == 0:
      continue
    else:
      j = 1
      break
      
if j == 0:
  print("APPROVED")
else:
  print("DENIED")

Measured memory_bytes: 3060
// B.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <set>
#include <vector>

using namespace std;

int main(int argc, char* argv[]) {
	while (true) {
		int n = -1, k = -1;
		cin >> n >> k;
		if (n <= 0 || k <= 0) break;
		vector<int> p(n), g(n);
		for (int i = 0; i < n; ++i) {
			cin >> p[i];
		}
		int last = 1 << 30, cnt = 0;
		for (int i = n - 1; i >= 0; --i) {
			if (p[i] < last) {
				++cnt;
			} else {
				cnt = 1;
			}
			g[i] = cnt;
			last = p[i];
		}
		set<int> s;
		s.insert(p[0]);
		int ans = 0;
		for (int i = 1; i < k; ++i) {
			s.insert(p[i]);
		}
		ans += g[0] < k;
		int sf = g[0] >= k;
		for (int i = k; i < n; ++i) {
			int low = *(s.begin());
			s.erase(p[i - k]);
			int high = *(s.rbegin());
			if ((low != p[i - k]) || (p[i] < high)) {
				if (g[i - k + 1] < k) {
					++ans;
				} else {
					sf = 1;
				}
			}
			s.insert(p[i]);
		}
		ans += sf;
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 11136
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int a = s.nextInt();
        int b = s.nextInt();
        int c = s.nextInt();
        System.out.println((a < b && b < c)?"Yes":"No");
    }
}

Measured memory_bytes: 17160
#include <stdio.h>

int main(){
   int i,j,n,k;
   double s,mx,p[200000];
 
   scanf("%d %d",&n,&k);
   for (i=0;i<n;i++) {
      scanf("%d",&j);
      p[i]=(j+1)/2.0;
   }
   s=0;
   for (i=0;i<k;i++) s+=p[i];
   mx=s;
   for (;i<n;i++) {
      s+=p[i]-p[i-k];
      if (s>mx) mx=s;
   }
   printf("%f\n",mx);
   return 0;
}


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

#include <atcoder/all>
using namespace std;
using namespace atcoder;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll, ll> P;
using VP = vector<P>;
using VVP = vector<VP>;
using VI = vector<ll>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;
const int inf = 1e9 + 7;
const ll INF = 1LL << 61;
const ll mod = 998244353;
using mint = modint998244353;

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

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

struct S {
    mint sum;
    mint calc;
};
S op(S l, S r) { return S{l.sum + r.sum, l.calc + r.calc}; }
S e() { return S{0, 0}; }
using F = mint;
S mapping(F f, S x) {
    if (f.val() <= 9)
        return S{f * x.calc, x.calc};
    else
        return x;
}
F composition(F f, F g) { 
  if(f.val()>9) return g; 
  else return f; 
}
F id() { return 10; }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int i, j;
    int n, q;
    cin >> n >> q;
    vector<S> p(n);
    p[n - 1] = S{1, 1};
    for (i = n - 2; i >= 0; i--) p[i] = S{p[i + 1].calc * 10, p[i + 1].calc * 10};
    lazy_segtree<S, op, e, F, mapping, composition, id> seg(p);
    while (q--) {
        int l, r, d;
        cin >> l >> r >> d;
        seg.apply(l - 1, r, (mint)d);
        cout << seg.all_prod().sum.val() << endl;
    }
}

Measured memory_bytes: 9832
n,k = map(int, input().split())
a =  list(map(int, input().split()))
b,c = [0 for i in range(n)],[0 for i in range(n)]
num,wa = 10**9 +7,k * (k-1) //2
for i in range(n-1):
    for j in range(i+1,n):
        if a[i] > a[j]:
            b[i] += 1
            c[i] += 1
        elif a[i] < a[j]:
            c[j] += 1
ans = sum(c) * wa % num
ans += sum(b) * k
print(ans % num)


Measured memory_bytes: 3188
import java.util.* ; 
import java.math.*;
class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner (System.in);
	int n = scan.nextInt();
	if(n<1200){
      System.out.println("ABC");
    }else if(n<2800){
      System.out.println("ARC");
    }else{
      System.out.println("AGC");
    }
  }
}


Measured memory_bytes: 20948
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <queue>
#include <utility>
#include <cmath>

using namespace std;

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

typedef long long lint;
typedef pair<int,int> P;

int main() {
	string b;
	cin >> b;

	string ans;

	if(b=="A") ans='T';
	else if(b=="C") ans='G';
	else if(b=="T") ans='A';
	else ans='C';

	cout << ans << endl;

}


Measured memory_bytes: 256
from collections import defaultdict
N, M = [int(val) for val in input().split(' ')]
P, Y = [], []


def complete_val(val):
    length = len(str(val))
    prefix = '0' * (6 - length)
    return prefix + str(val)


for _ in range(M):
    p, y, = [int(val) for val in input().split(' ')]
    P.append(p)
    Y.append(y)

cities = defaultdict(dict)
for i in range(M):
    cities[P[i]][i] = Y[i]

results = {}
for p, p_cities in cities.items():
    p_str = complete_val(p)
    for city_rank, (m_index, year) in enumerate(sorted(p_cities.items(), key=lambda x: x[1])):
        city_str = complete_val(city_rank+1)
        results[m_index] = p_str + city_str

for m_index, string in sorted(results.items(), key=lambda x: x[0]):
    print(string)




Measured memory_bytes: 71856
#include<iostream>
#include<map>

using namespace std;

int main( )
{
	map<char,bool> mp;
	string s;
	cin >> s;
	int l = s.length();
	bool ok = true;
	for(int j = 0; j < l; j ++){
		if(mp[s[j]] == false){
			mp[s[j]] = true;
		}else{
			ok = false;
			break;
		}
	}
	if(ok)
		cout << "yes" << endl;
	else
		cout << "no" << endl; 
}




Measured memory_bytes: 256
#include <algorithm> // std::sort(begin,end), std::min, std::max
#include <iostream>
#include <queue>
#include <string>
#include <unordered_map>
#include <utility> // std::swap
#include <vector>

using namespace std;
using ll = long long;
using pii = pair<int, int>;

template <typename T> // 0<1<2<3<4
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
template <typename T> // 0>1>2>3>4
using pq_dsc = priority_queue<T>;

int main(int argc, char const *argv[]) {

  ll n, d, dd = 0, sum = 0;
  cin >> n;
  for (ll i = 0; i < n; i++) {
    cin >> d;
    dd += d;
    sum -= d * d;
  }
  cout << (sum + dd * dd) / 2 << endl;

  return 0;
}


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

int main() {
 int n;
int zoro=0;
 cin>>n;
 int ans=0;
 for (int i = 0; i < n; i++)
 {
     int o=0;
     int t=0;
     
     cin>>o>>t;

     if(o==t)
     {zoro++;
if(zoro==3)
{ans=1;}}
     else{
         zoro=0;
     }



 }
 

if(ans==1){
 cout<<"Yes"<<endl;
}
else
{
    cout<<"No"<<endl;
}

}


Measured memory_bytes: 3632
#pragma GCC optimize("Ofast")
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<string>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<math.h>
#include<utility>
using namespace std;


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

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

    int half = n/2;
    half--;

    int min = d[half];
    int counter = 0;

    if(d[half] == d[half+1]) {
        cout << 0 << endl;
        return 0;
    }
    
    while(min <= d[half+1]){   
        counter++;
        min++;
    }
    cout << counter-1 << endl;
}

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

using namespace std;

int main(){

int a,b,c,d,e,pasta,juice;

cin>>a>>b>>c>>d>>e;

pasta =a;

if(a>=b)pasta=b;

if(pasta>=c)pasta=c;


juice=d;

if(d>=e)juice=e;

int sum=pasta+juice-50;

cout<<sum<<endl;

return 0;
}


Measured memory_bytes: 3080
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = 1'000'000'007;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

// ガウスの消去法（Gauss elimination）
// O(n^3)
// 
// Verified:
//   http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=3437138

using Num = double;
using Vec = vector<Num>;
using Mat = vector<Vec>;
tuple<bool, int, Vec> gaussianElimination(Mat A, Vec b) {
	const Num EPS = 1e-5; // 誤差
	const int n = A.size(), m = A[0].size();
	int rank = 0, cj = 0;
	while (rank < n && cj < m) {
		// A[rank][cj] が最大になるように
		for (int i = rank + 1; i < n; i++) {
			if (abs(A[i][cj]) > abs(A[rank][cj])) {
				A[i].swap(A[rank]);
				swap(b[i], b[rank]);
			}
		}
		if (abs(A[rank][cj]) > 0) {
			// 係数を 1 に
			Num d = A[rank][cj];
			for (int j = 0; j < m; j++)
				A[rank][j] /= d;
			b[rank] /= d;
			// 前進消去（forward elimination）
			for (int i = rank + 1; i < n; i++) {
				Num k = A[i][cj];
				for (int j = 0; j < m; j++)
					A[i][j] -= k * A[rank][j];
				b[i] -= k * b[rank];
			}
			rank++;
		}
		cj++;
	}
	// 0 != b[i] だったら不能
	for (int i = rank; i < n; i++)
		if (abs(b[i]) > EPS)
			return make_tuple(false, rank, Vec());
	// 不定
	// rank != m
	// cj < m => n < m
	if (rank < m || cj < m)
		return make_tuple(true, rank, Vec());
	// 後退代入（back substitution）
	for (int j = m - 1; j >= 0; j--)
		for (int i = 0; i < j; i++)
			b[i] -= b[j] * A[i][j];
	return make_tuple(true, rank, b);
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(3);
	for (double a, b, c, d, e, f; cin >> a >> b >> c >> d >> e >> f;) {
		Mat A = { { a,b },{ d,e } };
		Vec B = { c,f };
		auto res = gaussianElimination(A, B);
		Vec ans = get<2>(res);
		cout << ans[0] << " " << ans[1] << endl;
	}
	return 0;
}


Measured memory_bytes: 3220
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	var Input = input.split("\n")
    
    var a = Number(Input[0])
    var b = Input[1].split(" ")
    var cnt = ""
    
    var z = new Array(a);
    
    for(var i = 0 ; i < a; i++){
    	z[Number(b[i])] = i + 1
       
    }
  z.shift()
  
  var ans = String(z).replace( /,/g, ' ' )
  console.log(ans)
  
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 41556
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(A, B):
    d = B - A
    ans = (d * (d - 1) // 2) - A
    return ans


def main():
    A, B = read_int_n()
    print(slv(A, B))


if __name__ == '__main__':
    main()


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

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


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>

using namespace std;

typedef long long int lli;

int gcd(int a, int b) {
	return b != 0 ? gcd(b, a%b) : a;
}
lli gcd(lli a, lli b) {
	return b != 0 ? gcd(b, a%b) : a;
}
int lcm(int a, int b) {
	return a * b / gcd(a, b);
}
lli lcm(lli a, lli b) {
	return a * b / gcd(a, b);
}

#define N_MAX 100000
#define MOD 1000000007

bool comp(int N, int *src, int *dst)
{
	for (int i = 0; i < N; i++) {
		if (src[i] != dst[i]) {
			return false;
		}
	}
	return true;
}

void solv()
{
	int N, M; scanf("%d%d", &N, &M);
	int table[N_MAX];
	for (int i = 0; i < N; i++) {
		scanf("%d", table + i);
		table[i] /= 2;
	}

	lli val = table[0];
	for (int i = 1; i < N; i++) {
		val = lcm(val, (lli)table[i]);
		if (val > (lli)M) {
			printf("0");
			return;
		}
	}

	for (int i = 0; i < N; i++) {
		lli d = val / (lli)table[i];
		if (0 == d % 2) {
			printf("0");
			return;
		}
	}

	printf("%lld", ((lli)M - val) / (val * 2) + 1);

	return;
}

int main()
{
	FILE *fin = NULL, *fout = NULL;
	//fin = freopen("input.txt", "r", stdin);
	//fout = freopen("output.txt", "w", stdout);

	solv();

	//finalize
	if (NULL != fin) fclose(fin);
	if (NULL != fout) fclose(fout);

	return 0;
}


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

using namespace std;

bool c[4];

int main()
{
	string s;
	cin >> s;
	
	for (int i = 0; i < s.size(); i ++)
	{
		if (s[i] == 'S')
		{
			c[0] = true;
		}
		if (s[i] == 'N')
		{
			c[1] = true;
		}
		if (s[i] == 'E')
		{
			c[2] = true;
		}
		if (s[i] == 'W')
		{
			c[3] = true;
		}
	}
	
	if (c[0] == c[1] && c[2] == c[3])
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
	return 0;
}


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

#define REP(i,n) for(long long i=0;i<n;++i)
#define REPR(i,n) for(long long i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(long long i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define MOD 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(v) {for(long long sitr=0;sitr<v.size();++sitr){cin>>v[sitr];}}

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

using namespace std;

typedef pair<int,int> pii;

int main(){

  llong n;
  cin >> n;
  map<int, int> mp;

  //素因数分解
  for(llong i= 2; i * i <= n; ++i){
    while(n % i == 0){
      mp[i]++;
      n /= i;
    }
  }
  if(n != 1){
    mp[n]++;
  }

  llong ans = 0;
  REPI(itr, mp){
    int cnt = 1;
    while(cnt <= itr->second){
      itr->second -= cnt;
      cnt++;
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}



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

int main() {
    int A,B,K,ans=101,i=0;
    cin >> A >> B >> K;
    while (i<K) {
        ans--;
        if (A%ans==0 && B%ans==0) {
            i++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a;i<(int)b;++i)
int main(){
  int n,m;cin>>n>>m;
  vector<int> a(n);
  vector<int> b(n);
  vector<int> c(m);
  vector<int> d(m);
  rep(i,n)cin>>a[i]>>b[i];
  rep(i,m)cin>>c[i]>>d[i];
  vector<int> ans(n);
  rep(i,n){
    int minv=1e9;
    for(int j=m-1;j>=0;j--){
       int diff=abs(c[j]-a[i])+abs(d[j]-b[i]);
       if(diff<=minv){
         minv=diff;
         ans[i]=j+1;
       }
    }
  }
  rep(i,n)cout<<ans[i]<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.lang.Math;

class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		String n = stdIn.next();
		if (n.length() == 2) 
			System.out.print(n);
		else {
			char[] a = new char[3];
			for (int j = 0; j < 3; j++)
				a[j] = n.charAt(j);
			for (int i = 2; i >= 0; i--)
				System.out.print(a[i]);
		}
	}
}

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

#define fori(i,a,b) for (long int i = a; i <= b ; ++i)
#define ford(i,a,b) for(long int i = a;i >= b ; --i)
#define mk make_pair
#define mod 1000000007
#define MAXN 1000000
#define pb push_back
#define vec vector<long long int>
#define ll long long
#define rnd mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count())
#define pi pair<long long int,long long int>
#define sc second
#define fs first

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

    map<string,int> mp;
    mp["SUN"]=7;
    mp["MON"]=6;
    mp["TUE"]=5;
    mp["WED"]=4;
    mp["THU"]=3;
    mp["FRI"]=2;
    mp["SAT"]=1;

    string s;
    cin>>s;
    cout<<mp[s];    

    return 0;
}

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

using namespace std;

int dp[100000][3];
int cost[100000][3];

int main(){
    ios::sync_with_stdio(0); cin.tie();
    int N,tmp;
    cin >> N;    
    for(int i = 0 ; i <  N; i++){
        for(int j = 0; j < 3; j ++){
            cin >> tmp;
            cost[i][j] = tmp;
            if( i == 0 ) dp[i][j] = tmp;
        }
    }
    for(int i = 1; i < N ; i++){
        for(int j = 0; j <3 ; j++){
            tmp = 0;
            for(int k = 0 ; k < 3 ; k ++ ){
                if( k != j) tmp = max( tmp, dp[i-1][k] );
            }
            dp[i][j] = cost[i][j] + tmp;
        }
    }
    cout << max( dp[N-1][0], max(dp[N-1][1], dp[N-1][2]));

}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i));
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a); i>n; --i)
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
class Dice{
public:
	vi n;
	int top;
	Dice(){
		n.resize(6);
		top = 0;
	}
	void roll(char c){
		int tmp = n[0];
		if( c == 'E' ){
			n[0] = n[3];
			n[3] = n[5];
			n[5] = n[2];
			n[2] = tmp;
		}else if( c == 'W' ){
			n[0] = n[2];
			n[2] = n[5];
			n[5] = n[3];
			n[3] = tmp;
		}else if( c == 'N' ){
			n[0] = n[1];
			n[1] = n[5];
			n[5] = n[4];
			n[4] = tmp;
		}else if( c == 'S' ){
			n[0] = n[4];
			n[4] = n[5];
			n[5] = n[1];
			n[1] = tmp;
		}else if( c == 'R' ){
			tmp = n[4];
			n[4] = n[3];
			n[3] = n[1];
			n[1] = n[2];
			n[2] = tmp;
		}else if( c == 'L' ){
			tmp = n[4];
			n[4] = n[2];
			n[2] = n[1];
			n[1] = n[3];
			n[3] = tmp;
		}
	}
	void input() {rep(i, 0, 6) cin >> n[i];}
	void output() {P(n[top]);}
};
inline bool f(Dice d1, Dice d2) {
	rep(i, 0, 6) {
		if(d1.n[0] == d2.n[0]) {
			rep(j, 0, 4) {
				bool flg = true;
				rep(k, 1, 6) {
					if(d1.n[k] != d2.n[k]) {
						flg = false;
						break;
					}
				}
				if(flg) return true;
				d2.roll('S');
				d2.roll('E');
				d2.roll('N');
			}
		}
		d2.roll(i % 2 == 1? 'E' : 'S');
	}
	return false;
}
int main() {
	int n; cin >> n;
	Dice d[n]; rep(i, 0, n) d[i].input();
	rep(i, 0, n - 1) {
		rep(j, i + 1, n) {
			if(i == j) break;
			if(f(d[i], d[j])) {
				P("No");
				return 0;
			}
		}
	}
	P("Yes");
	return 0;
}

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

long n,m,ans=0;
map<long,vector<long>> a;
vector<bool> b(100010,true);

void aaa(long x) {
  b[x-1]=false;
  if(a.count(x)) {
    for(long i=0;i<a[x].size();i++) if(b[a[x][i]-1]) aaa(a[x][i]);
  }
}

int main() {
  cin >> n >> m;
  for(long i=0;i<m;i++) {
    long x,y,z;
    cin >> x >> y >> z;
    a[x].push_back(y);
    a[y].push_back(x);
  }
  for(long i=1;i<=n;i++) {
    if(b[i-1]) {
      aaa(i);
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 20608
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define mp make_pair
#define fi first
#define se second
typedef pair<int, int> pint;
#define All(s) s.begin(), s.end()
#define rAll(s) s.rbegin(), s.rend()
#define REP(i, a, b) for (int i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)
double pi = 3.141592653589793;
ll mod = 1000000007;
ll INF = 1000000001;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;

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

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

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;

	if (a+b>c+d) {
		cout << "Left" << endl;
	}
	else if (a+b==c+d) {
		cout << "Balanced" << endl;
	}
	else {
		cout << "Right" << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cmath>
#include <functional>
#include <queue>
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define put(a) cout<<a<<endl;
using namespace std;
typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> P;

const ll INF = 9223372036854775807;
const int inf = 2147483647;

/*********************************************/
/*
 考察
 BFSで最短経路の道のりを出して、それをkとする。
 全白マス数をwをとして、
 res = w-k;
 道のりにスタートとゴールを含めないとずれる
 計算量はBFSがボトルネックで、O(HW)で間に合う
*/
/*********************************************/

int h,w;
string s[55];
//int visited[55][55]={0};//そのマスに訪れたかどうか
int d[55][55] ;//startからの距離
int sx=0,sy=0;
int gx,gy;
queue<P> q;
int dx[4] = {1,0,-1, 0};
int dy[4] = {0,1, 0,-1};

int bfs(){
    REP(i,h){
        REP(j,w){
            d[i][j]=inf;
        }
    }
    
    q.push(P(sx,sy));
    d[sy][sx]=0;
    
    while(q.size()>0){
    
        P p = q.front();
        q.pop();
        if(p.first==gx&&p.second==gy){
            break;
        }
        REP(i,4){
            int nx = p.first +dx[i];
            int ny = p.second+dy[i];
            if(0<=nx&&nx<w&&0<=ny&&ny<h&&s[ny][nx]=='.'&&d[ny][nx]==inf){
                q.push(P(nx,ny));
                d[ny][nx]=d[p.second][p.first]+1;
            }
        }
        
    }
    return d[gy][gx];
}

int main() {
    cin >> h >> w;
    gx = w-1;
    gy = h-1;
    REP(i,h){
        cin >> s[i];
    }
    int white=0;
    REP(i,h){
        REP(j,w){
            if(s[i][j]=='.')white++;
        }
    }
    int k = bfs();
    int res;
    if(k!=inf){
        res = white-k-1;//start分
    }else{
        res = -1;
    }
    put(res);
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;

const int MAXN=200005;

int n,X,Y,ncnt;
int dfn[MAXN],efn[MAXN],fa[MAXN],dep[MAXN];
struct node{
    int v,nex;
}E[MAXN*2],G[MAXN*2];
int Ehead[MAXN],Ghead[MAXN],dcnt[2];
bool tag[MAXN];
pair<int,int> a[MAXN];

void addedge(node edge[],int head[],int &cnt,int u,int v){
    node &p=edge[++cnt];
    p.v=v;
    p.nex=head[u];
    head[u]=cnt;
}

void dfs(int u,int fa=0){
    ::fa[u]=fa;
    dep[u]=dep[fa]+1;
    dfn[u]=++ncnt;
    for(int i=Ghead[u];i;i=G[i].nex){
        int v=G[i].v;
        if(v==fa) continue;
        dfs(v,u);
    }
    efn[u]=++ncnt;
}

bool check(int u,int v){
    if(dfn[u]>dfn[v]) swap(u,v);
    if(dfn[u]<dfn[v]&&efn[v]<efn[u])
        return dep[v]-dep[u]>=3;
    return fa[u]!=fa[v];
}

int vis[MAXN],dis[MAXN],deq[MAXN],l,r;
void bfs(){
    for(int i=1;i<=n;i++) vis[i]=dis[i]=0;
    l=r=1;
    deq[r++]=X;
    while(l<r){
        int u=deq[l++];
        vis[u]=1;
        for(int i=Ehead[u];i;i=E[i].nex){
            int v=E[i].v;
            if(vis[v]) continue;
            dis[v]=dis[u]+1;
            if(dis[v]<dep[v])
                deq[r++]=v;
        }
    }
}

int main(){
    //freopen("coalesce.in","r",stdin);
    //freopen("coalesce.out","w",stdout);

    dep[0]=-1;
    while(~scanf("%d%d%d",&n,&X,&Y)){
        for(int i=1;i<=n;i++) Ehead[i]=Ghead[i]=0;
        dcnt[0]=dcnt[1]=ncnt=0;
        for(int i=1;i<=n;i++) tag[i]=0;
        for(int i=1;i<n;i++) scanf("%d%d",&a[i].first,&a[i].second);
        for(int i=1;i<n;i++){
            int u,v;
            scanf("%d%d",&u,&v);
            addedge(G,Ghead,dcnt[1],u,v);
            addedge(G,Ghead,dcnt[1],v,u);
        }
        dfs(Y);
        for(int i=1;i<n;i++)
            if(check(a[i].first,a[i].second)) tag[a[i].first]=tag[a[i].second]=1;
            else addedge(E,Ehead,dcnt[0],a[i].first,a[i].second),addedge(E,Ehead,dcnt[0],a[i].second,a[i].first);
        bfs();
        int ans=0;
        bool flag=1;
        for(int i=1;i<=n&&flag;i++){
            if(!vis[i]) continue;
            if(tag[i]) flag=0;
            else ans=max(ans,2*dep[i]);
        }
        printf("%d\n",flag?ans:-1);
    }

    fclose(stdin);
    fclose(stdout);
}


Measured memory_bytes: 23168
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        int W = cin.nextInt();
        int H = cin.nextInt();
        int N = cin.nextInt();

        int[][] xya = new int[N][3];
        for (int i = 0; i < N; i++) {
            xya[i][0] = cin.nextInt();
            xya[i][1] = cin.nextInt();
            xya[i][2] = cin.nextInt();
        }

        int maxX = W;
        int minX = 0;
        int maxY = H;
        int minY = 0;

        for (int i = 0; i < N; i++) {
            int a = xya[i][2];

            switch (a) {
                case 1: minX = Math.max(xya[i][0], minX); break;
                case 2: maxX = Math.min(xya[i][0], maxX); break;
                case 3: minY = Math.max(xya[i][1], minY); break;
                case 4: maxY = Math.min(xya[i][1], maxY); break;
            }
        }

        int x = Math.max(maxX - minX, 0);
        int y = Math.max(maxY - minY, 0);

        System.out.println(x * y);
    }
}

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


int main() {
  int a,b,c,d,e;
  cin >> a >> b >> c >> d >> e ;
  if(a==0){
    cout <<1 <<endl;
  }else if(b==0){
    cout <<2 <<endl;
  }else if(c==0){
    cout <<3 <<endl;
  }else if(d==0){
    cout <<4 <<endl;
  }else if(e==0){
    cout << 5<<endl;
  }
}



Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define llint long long int
#define ldouble long double

using namespace std;

int main() {
    llint X,t;
    cin>>X>>t;
    if(X>=t){
        cout<<X-t<<endl;
    }
    else{
        cout<<0<<endl;
    }
return 0;
}

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

#define FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v,x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

typedef long long LL;
template<typename T> using V = std::vector<T>;
template<typename T> using VV = std::vector<std::vector<T>>;
template<typename T> using VVV = std::vector<std::vector<std::vector<T>>>;

template<class T> inline T ceil(T a, T b) { return (a + b - 1) / b; }
template<class T> inline void print(T x) { std::cout << x << std::endl; }
template<class T> inline void print_vec(const std::vector<T> &v) { for (int i = 0; i < v.size(); ++i) {  if (i != 0) {std::cout << " ";} std::cout << v[i];} std::cout << "\n"; }
template<class T> inline bool inside(T y, T x, T H, T W) {return 0 <= y and y < H and 0 <= x and x < W; }
template<class T> inline double euclidean_distance(T y1, T x1, T y2, T x2) { return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); }
template<class T> inline double manhattan_distance(T y1, T x1, T y2, T x2) { return abs(x1 - x2) + abs(y1 - y2); }

const int INF = 1L << 30;
const double EPS = 1e-9;
const std::string YES = "YES", Yes = "Yes", NO = "NO", No = "No";
const std::vector<int> dy4 = { 0, 1, 0, -1 }, dx4 = { 1, 0, -1, 0 };    // 4近傍（右, 下, 左, 上）
const std::vector<int> dy8 = { 0, -1, 0, 1, 1, -1, -1, 1 }, dx8 = { 1, 0, -1, 0, 1, 1, -1, -1 };

using namespace std;


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

	int H, W;
	cin >> H >> W;
	vector<vector<int>> field(H, vector<int>(W));
	FOR(i, 0, H) {
	    string S;
	    cin >> S;
	    FOR(j, 0, W) {
	        field[i][j] = S[j] - '0';
	    }
	}

	vector<vector<int>> dp(H, vector<int>(W, INF));
	dp[0][0] = 0;
	FOR(y, 0, H) {
	    FOR(x, 0, W) {
	        if (y + 1 < H) {
	            dp[y + 1][x] = min(dp[y + 1][x], field[y + 1][x] + dp[y][x]);
	        }
            if (x + 1 < W) {
                dp[y][x + 1] = min(dp[y][x + 1], field[y][x + 1] + dp[y][x]);
            }
	    }
	}

    print(dp[H - 1][W - 1]);

	return 0;
}


Measured memory_bytes: 3256
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define LIMIT(d_in, d_min, d_max) max(d_min, min(d_max, d_in))
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

vector<bool> PrimeNumberBool(int num)
{
	vector<bool> prime_num(num + 1, true);

	prime_num[0] = false;
	prime_num[1] = false;
	for (int i = 2; i <= sqrt(num); i++)
	{
		if (!prime_num[i])
			continue;

		for (int j = i * 2; j <= num; j += i)
		{
			prime_num[j] = false;
		}
	}

	return prime_num;
}

void execute()
{
	int N;
	cin >> N;

	vector<bool> prime_num = PrimeNumberBool(100004);

	for (int i = N; i <=  100003; i++)
	{
		if (prime_num[i])
		{
			cout << i << endl;
			return;
		}
	}
	return;
}

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

	int stop;
	cin >> stop;

	return 0;
}

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

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

  int count = 0;
  for (int i = 0; i < 3; i++)
  {
    if (s.at(i) == '1')
    {
      count++;
    }
  }
  cout << count << endl;
}


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

using namespace std;
int main(){
 long n,z,w;
  cin >> n >> z >> w;
  
  vector<long> a(n);
  for(int i=0;i<n;i++) cin >> a[i];
  
  if(n==1) cout << abs(a[0]-w) << endl;
  else cout << max(abs(a[n-1]-w),abs(a[n-2]-a[n-1])) << endl;
  
  
}

Measured memory_bytes: 256
import bisect
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


N = int(sys.stdin.readline())
S = sys.stdin.readline().rstrip()

a = S [:N//2] == S[N//2:]
if a:
    print('Yes')
else:
    print('No')



Measured memory_bytes: 23236
import collections
import bisect
S = input()
T = input()
N = len(S)
 
d = collections.defaultdict(list)
for i, s in enumerate(S):
  d[s].append(i + 1)

ans = 0
end = 0
isOK = True
i = 0

for t in T:
  if len(d[t])==0: # 存在しない文字ならFalse
    isOK = False
    break
  dic = d[t]
  idx = bisect.bisect_right(dic, i) # i番目以降におけるtの出現位置を取得(O(logN))
  if len(dic) == idx:
    i = dic[0]  # iをtのあるところに動かす
    end += 1    # 端に到達したら，繰り返し数を増やす
  else:
    i = dic[idx]# iをtのあるところに動かす

if isOK:
  ans = N * end + i
else:
  ans = -1
    
print(ans)

Measured memory_bytes: 7924
//#include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>
using namespace std;
//using namespace __gnu_pbds;
//template <class c, class cmp = less<c> > using ordered_set = tree<c, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 
#endif
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}
template <typename T,typename U>pair<T,U> operator+(const pair<T,U> & l,const std::pair<T,U> & r) { return {l.first+r.first,l.second+r.second};}
typedef long long int ll;
const ll mod =1e9+7;
const int maxn = 200002;
#define endl '\n'
#define int ll
#define ld long double
#define all(x) (x).begin(),(x).end()

template <class T> int sgn(T x) { return (x > 0) - (x < 0); }
template<class T>
struct Point {
	typedef Point P;
	T x, y;
	explicit Point(T x=0, T y=0) : x(x), y(y) {}
	bool operator<(P p) const { return tie(x,y) < tie(p.x,p.y); }
	bool operator==(P p) const { return tie(x,y)==tie(p.x,p.y); }
	P operator+(P p) const { return P(x+p.x, y+p.y); }
	P operator-(P p) const { return P(x-p.x, y-p.y); }
	P operator*(T d) const { return P(x*d, y*d); }
	P operator/(T d) const { return P(x/d, y/d); }
	T dot(P p) const { return x*p.x + y*p.y; }
	T cross(P p) const { return x*p.y - y*p.x; }
	T cross(P a, P b) const { return (a-*this).cross(b-*this); }
	T dist2() const { return x*x + y*y; }
	double dist() const { return sqrt((double)dist2()); }
	// angle to x-axis in interval [-pi, pi]
	double angle() const { return atan2(y, x); }
	P unit() const { return *this/dist(); } // makes dist()=1
	P perp() const { return P(-y, x); } // rotates +90 degrees
	P normal() const { return perp().unit(); }
	// returns point rotated 'a' radians ccw around the origin
	P rotate(double a) const {
		return P(x*cos(a)-y*sin(a),x*sin(a)+y*cos(a)); }
	friend ostream& operator<<(ostream& os, P p) {
		return os << "(" << p.x << "," << p.y << ")"; }
};
int32_t main()
{ 
  IOS
  
  ld x;
  cin>>x;
  x = (x*M_PI)/180.0;
  Point<ld> p(0.0,0.0);
  Point<ld>v(0.0,1.0);
  for(int i = 1;i<=5000000;i++){
      p = p+v; 
      if(p.dist()<=1e-9){
          cout<<i;
          return 0;
      }
      v = v.rotate(x);
  }
  
  
}

Measured memory_bytes: 4040