akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>

using namespace std;

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

long long int INF = 1e18;
long long int mod = 1000000007;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//↓,→,↑,←

#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(15)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,n) for(i=0;i<n;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl

ll rui(ll abc,ll bed){
    //abcのbed乗を計算する
    if(bed==0){return 1;}
    else{
        ll ced = rui(abc,bed/2);
        ced *= ced;
        ced %= mod;
        if(bed%2==1){ced*=abc; ced%=mod;}
        return ced;
    }
}
ll gcd(ll number1,ll number2){
	if(number1 > number2){
		swap(number1,number2);
	}
	if(number1 == 0 || number1 == number2){
		return number2;
	}else{
		return gcd(number2 % number1,number1);
	}
}

ll i,j,k,ii,jj,r,l;
ll n,m,num,sum,ans;
ll a,b,c,d,e,g,h,w;
ll x[500005],y[500005],z[500005];
char s[500005];

int main(){
	cin >> n;
	for(i=0;i<n;i++){
		cin >> x[i];
		num += x[i];
	}
	ans = INF;
	c = -1;
	for(i=0;i<n;i++){
		if(ans > abs(num - n * x[i])){
			ans = abs(num - n * x[i]);
			c = i;
		}
	}
	p(c);
	return 0;

}

Measured memory_bytes: 28284
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author gainullin.ildar
 */

#include <bits/stdc++.h>

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <time.h>
#include <math.h>
#include <random>
#include <deque>
#include <queue>
#include <cassert>
#include <unordered_map>

using namespace std;

bool kek(int x)
{
    return (x % 10 == 0);
}

class Main
{
public:
    void solve(std::istream &in, std::ostream &out)
    {
        int n;
        in >> n;
        bitset<100000> dp;
        dp[0] = 1;
        for (int i = 0; i < n; i++)
        {
            int x;
            in >> x;
            dp |= dp << x;
        }
        int ans = 0;
        for (int i = 0; i < 100000; i++)
        {
            if (dp[i] && !kek(i))
            {
                ans = i;
            }
        }
        out << ans << '\n';
    }
};


int main()
{
    ios::sync_with_stdio(0);
    Main solver;
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
<?php

$input = trim(fgets(STDIN));

$n = (int)$input;
if ($n < 105) {
	echo 0;
	exit(0);
}

$numcount = 0;
for ($i=105; $i <= $n; $i= $i+2) { 
	$max = ($i+1) / 2;
	$yaku = 1;
	for ($j=3; $j <= $max; $j= $j+2) { 
		if ($i % $j == 0) {
			++$yaku;
		}
		if ($yaku > 7) {
			break;
		}
	}
	if ($yaku == 7) {
		++$numcount;
	}
}

echo $numcount;

Measured memory_bytes: 4856
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

  int n, m;
  cin >> n >> m;
  vector<vector<int>> connect(m);

  rep(i, 0, m) {
    int k;
    cin >> k;
    rep(j, 0, k) {
      int s;
      cin >> s;
      s--;
      connect[i].push_back(s);
    }
  }

  vector<int> p(m);
  rep(i, 0, m) cin >> p[i];

  int ans = 0;
  rep(i, 0, 1 << n) {
    bool isok = true;
    rep(j, 0, m) {
      int c = 0;
      for (int id : connect[j]) {
        if (i >> id & 1) c++;
      }
      c %= 2;
      if (c != p[j]) isok = false;
    }
    if (isok) ans++;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <vector>
#include <iostream>
#include <map>
#include <cstring>
#include <set>
#include <sstream>
using namespace std;
int n;
map<string,int> group;
set<string> member;
vector<string> s[1000];
bool checked[10001];
void chain(int v){
	for(int i=0;i<s[v].size();i++){
		string ns=s[v][i];
		if(group.find(ns)==group.end()){
			member.insert(ns);
		}else{
			map<string,int>::iterator it=group.find(ns);
			if(!checked[it->second]){
				checked[it->second]=true;
				chain(it->second);
			}
		}
	}
} 

int main(void){
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		group.clear();
		member.clear();
		memset(checked,false,sizeof(checked));
		for(int i=0;i<n;i++){
			s[i].clear();
			string str;
			cin >> str;
			istringstream iss(str);
			string tmp;
			getline(iss,tmp,':');
			group[tmp]=i;
			while(getline(iss,tmp,',')){
				s[i].push_back(tmp);
			}
			s[i][s[i].size()-1]=s[i][s[i].size()-1].assign(s[i][s[i].size()-1],0,s[i][s[i].size()-1].size()-1);
		}
		checked[0]=true;
		for(int i=0;i<s[0].size();i++){
			string ns=s[0][i];
			if(group.find(ns)==group.end()){
				member.insert(ns);
			}else{
				map<string,int>::iterator it=group.find(ns);
				checked[it->second]=true;
				chain(it->second);
			}
		}
		cout << member.size() << endl;
	}
	return 0;
}

Measured memory_bytes: 1424
#include<stdio.h>
int main(void)
{
  //nを入力
  int n;
  scanf("%d",&n);
  //wを入力
  int i,w[n];
  for(i=0;i<n;i++)
    scanf("%d",&w[i]);
  int t,s1,s2,sub,ans=100;
  for(t=0;t<n;t++){
    //s1,s2を初期化
    s1 = 0;  s2 = 0;
    for(i=0;i<n;i++){
      //番号がt以下ならs1に加算
      if(t>=i)
        s1 += w[i];
      else
        s2 += w[i];
    }
    //差の絶対値をsubとする
    sub = s1-s2;
    if(sub<0)
      sub = -sub;
    //ansを更新
    if(sub<ans)
      ans = sub;
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
#define ll long long
ll a[200005];
ll sum[200005];
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>a[i];
        sum[1]=a[1];
    for(int i=2;i<=n;i++)
        sum[i]=sum[i-1]+a[i];
        ll minn=abs(2*sum[1]-sum[n]);
        for(int i=1;i<=n-1;i++)
            minn=min(minn,abs(2*sum[i]-sum[n]));
            cout<<minn<<endl;
    return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define rep(i,x,n) for(int i=x; i<(int)(n); i++)
#define rep_eq(i,x,n) for(int i=x; i<=(int)(n); i++)
using namespace std;

int main() {
  int N,K; cin >>N >>K;
  int ans=1;
  rep(i,0,N) {
    if (ans*2<ans+K) ans*=2;
    else ans+=K;
  }
  cout <<ans <<endl;
  return 0;
}


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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

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

using ll = long long;

using namespace std;

int main() {
  in(int, n, k);
  vector<int> p(n);
  rep(i, n) cin >> p[i];
  sort(all(p));
  out(accumulate(p.begin(), p.begin() + k, 0));
}


Measured memory_bytes: 3632
#!/usr/bin/env python3
import copy

n = int(input())

mod = 10**9+7

memo = {}

banned = {'ACTG', 'TCAG', 'GCAG', 'TACG', 'AACG', 'ACAG', 'GAGC', 'CACG',
          'AGC', 'ATCG', 'ACCG', 'CAG', 'GACG', 'CCAG', 'AAGC', 'ACG', 'TAGC'}

count = 0


def dp(lettrs, state):

    if state in banned:
        return 0
    if lettrs == 0:
        return 1
    if (lettrs, state) in memo:
        return memo[lettrs, state]

    ans = 0
    for c in "ACGT":
        ans += dp(lettrs-1, (state+c)[-4:])
        ans %= mod
    ans %= mod
    memo[lettrs, state] = ans

    return ans


print(dp(n, ""))
# print(memo)
# AG = [0, 1]
# for i in range(2, n):
#     ans_pre = copy.deepcopy(ans)
#     ans = copy.deepcopy(ans_base)
#     print(ans_pre)
#     for key in ans_pre.keys():

#         for l in ["A", "C", "G", "T"]:

#             if key+l in miss:
#                 print(key+l)
#                 continue
#             else:
#                 # print((key+l))
#                 ans[(key+l)[1:]] += ans_pre[key] % mod
#     AG.append(ans["AG"])
#     print(AG)
#     ans["AC"] -= AG[-3]
#     ans["GC"] -= AG[-3]
#     ans["TC"] -= AG[-3]


# print(sum(ans.values()) % mod)

# AA
# AC
# AG
# AT
# CA
# CC
# CG
# CT
# GA
# GC
# GG
# GT
# TA
# TC
# TG
# TT


Measured memory_bytes: 9180
N=int(input())
F=[int(input().replace(' ',''),2) for _ in range(N)]
P=[tuple(map(int,input().split())) for _ in range(N)]

ans=-(10**7*N)
for o in range(1,1<<10):
    p=0
    for i in range(N):
        p+=P[i][bin(F[i]&o).count('1')]
    ans=max(ans,p)
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
using namespace std; //std::の省略のため
using ll = long long;

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

  ll t[n];

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

  cin >> m;

  ll x[m], p[m];

  for(int i=0; i<m; i++)
    cin >> p[i] >> x[i];

  ll time = 0;

  for(int i=0; i<m; i++){
    time = 0;
    for(int j=0; j<n; j++){
      if(j == p[i]-1) 
        time += x[i];
      else
        time += t[j];
    }

    cout << time << endl;
  }

}


Measured memory_bytes: 3576
// A - Frog 1
#include <bits/stdc++.h>
using namespace std;

int main(){
	int n, ha, hb, hc, a, b, c;
	cin>>n;
	cin>>ha>>hb;
	a = 0;
	b = c = abs(ha-hb);
	n -= 2;
	while(n--){
		cin>>hc;
		c = min(a + abs(hc-ha), b + abs(hc-hb));
		a = b; b = c;
		ha = hb; hb = hc;
	}
	cout<< c <<endl;
}


Measured memory_bytes: 256
import java.util.*;

import java.lang.*;

import java.math.*;



public class Main {

	Scanner sc = new Scanner(System.in);

	void run(){

		for(;;){

			

			int n = sc.nextInt();

			if(n == 0)break;

			char[] map = new char[256];

			for(int i = 0; i < 256; i++){

				map[i] = (char) i;

			}

			for(int i = 0; i < n; i++){

				map[sc.next().charAt(0)] = sc.next().charAt(0);

			}

			long m  = sc.nextLong();

			for(long i = 0; i < m; i++){

				System.out.print(map[sc.next().charAt(0)]);

			}

			

			System.out.println();

			

		}

		

	}

	public static void main(String[] args){

		Main m = new Main();

		m.run();

	}

}

Measured memory_bytes: 12000
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.util.StringTokenizer

fun main(args: Array<String>) {
    val sc = FastScanner(System.`in`)

    val first = sc.next()
    val second = sc.next()

    if(first[0] != second[2] || first[1] != second[1] || first[2] != second[0]) println("NO")
    else println("YES")

}


class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}




Measured memory_bytes: 31384
import heapq
from collections import deque
from enum import Enum
import sys
import math
from _heapq import heappush, heappop

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001


class UnionFind:
    def __init__(self,arg_V):
        self.V = arg_V
        self.boss = [None]*arg_V
        self.height = [None]*arg_V

    def init(self):
        for i in range(self.V):
            self.boss[i] = i
            self.height[i] = 0

    def get_boss(self,index):
        if index == self.boss[index]:
            return index
        else:
            self.boss[index] = self.get_boss(self.boss[index])
            return self.boss[index]


    def is_same_group(self,a,b):
        return self.get_boss(a) == self.get_boss(b)

    def unite(self,x,y):
        boss_x = self.get_boss(x)
        boss_y = self.get_boss(y)

        if boss_x == boss_y:
            return

        if self.height[x] > self.height[y]:

            self.boss[boss_y] = boss_x

        elif self.height[x] < self.height[y]:

            self.boss[boss_x] = boss_y

        else:
            self.boss[boss_y] = boss_x
            self.height[x] += 1

class Edge:
    def __init__(self,arg_FROM,arg_TO,arg_WEIGHT):
        self.FROM = arg_FROM
        self.TO = arg_TO
        self.WEIGHT = arg_WEIGHT

    def __lt__(self,arg):
        return self.WEIGHT < arg.WEIGHT



V,E = map(int,input().split())

UF = UnionFind(V)
UF.init()

table = []

for loop in range(E):
    tmp_from,tmp_to,tmp_cost = map(int,input().split())
    edge = Edge(tmp_from,tmp_to,tmp_cost)
    table.append(edge)

table.sort()

ans = 0

for i in range(E):
    if UF.is_same_group(table[i].FROM, table[i].TO):
        continue
    UF.unite(table[i].FROM, table[i].TO)
    ans += table[i].WEIGHT


print("%d"%(ans))





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

using namespace std;
using ll = long long;
using vs = vector<string>;
using pll = pair<ll,ll>;
using vpl = vector<pll>;
using vvpl = vector<vpl>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using vvb = vector<vb>;
using ld = long double;
using vd = vector<ld>;
using vvd = vector<vd>;
using vvvd = vector<vvd>;

#define R(a,i) for(ll a=0; a < (i); (a)++)
#define FOR(a,i,j) for(ll a=(i); a < (j); (a)++)
#define RD(a,i) for(ll a=(i)-1; (a) >= 0; (a)--)
#define FORD(a,i,j) for(ll a=(j)-1; (a) >= (i); (a)--)

#define xx first
#define yy second
#define pb push_back

#define all(X) begin(X),end(X)
#define sz(X) (X).size()

const ll oo = 0x3f3f3f3f3f3f3f3f;
const ld eps = 1e-9;

#define DBG 0
#define TR(X) {if(DBG) cerr << (#X) << " = " << (X) << "\n";}
#define TRM(X,i,j) {if(DBG) cerr << (#X) << "[" << i << "][" << j << "] = " << (X[i][j]) << "\n";}
#define TRP(X,i,j) {if(DBG) cerr << (#X) << "[" << i << "][" << j << "] = (" << (X[i][j]).xx << ", " << (X[i][j]).yy << ")\n";}
#define hline {if(DBG) cerr << "----------------------------------------------------------------------" << "\n";}
#define PK(X) {if(DBG) cerr << (X) << "\n";}

const ll mod = 1e9+7;

template <class T>
void myMin(T& a, T b){
	a = min(a,b);
}

vvl adj;
vb mark;

// xx cur node is white
// yy black
pll rek(ll i){
	mark[i] = true;
	pll res = {1,1};

	for(const auto it : adj[i]){
		if(!mark[it]) {
			pll cur = rek(it);
			res.xx *= (cur.xx + cur.yy) % mod;
			res.xx %= mod;
			res.yy *= cur.xx;
			res.yy %= mod;
		}
	}

	return res;
}

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

	ll N;
	cin >> N;

	adj.assign(N, vl());

	FOR(i,0,N-1) {
		ll x, y;
		cin >> x >> y;

		x--;
		y--;

		adj[x].pb(y);
		adj[y].pb(x);
	}
	
	mark.assign(N, false);
	pll foo = rek(0);

	cout << (foo.xx + foo.yy) % mod << endl;
}


Measured memory_bytes: 9856
#include<iostream>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[n];
    int i;
    for(i=1;i<=n;i++)
        cin>>a[i];
    int count=0;
    for(i=1;i<=n;i+=2)
    {
        if(a[i]%2!=0)
            count++;
    }
    cout<<count<<endl;
    return 0;
}


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

#define LIMIT 1000000000

int main(int argc, char **argv) {
  long N;
  cin >> N;
  vector<long> A;
  map<long, long> L, R;
  for (long i = 0; i < N; ++i) {
    long a;
    cin >> a;
    A.push_back(a);

    long l, r;
    l = i + a;
    r = i - a;

    if (!L.count(l))
      L[l] = 0;
    if (!R.count(r))
      R[r] = 0;

    L[l]++;
    R[r]++;
  }

  long cnt = 0;
  for (auto &l : L) {
    if (R.count(l.first)) {
      cnt += l.second * R[l.first];
    }
  }

  cout << cnt << endl;

  return 0;
}


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

int main(void){
   int N;
   cin >> N;
   ll A[N];
   for(int i = 0; i < N; i++) cin >> A[i];
   set<int> st;
   for(int i = 0; i< N;i++) {
       st.insert(A[i]);
   }
   
   if(st.size() == N) cout <<"YES"<<endl;
   else cout <<"NO" << endl;
}


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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  ll a,b,c,d;
  cin >> a >> b >> c >> d;
  
  cout << max(a*b, c*d) << endl;
}

Measured memory_bytes: 256
# Problem A - Digit Sum 2

# input process
N = input()

# initizalization
keta_len = len(N)
keta_list = [[0]*2 for i in range(keta_len+1)] # keta_list[keta][smaller]
keta_list[0][0] = int(N[0])
keta_list[0][1] = int(N[0]) - 1

for i in range(1, keta_len): # keta loop 2桁目から
    for j in range(2): # smaller loop
        n_lim = 0
        if j==1:
            n_lim = 9
        else:
            n_lim = int(N[i])
        cost = keta_list[i-1][j] + n_lim
        keta_list[i][j] = max(keta_list[i][j], cost)

# output process
max_ans = max(keta_list[keta_len-1])
print(max_ans)


Measured memory_bytes: 38384
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<utility>
#ifdef XS
	const int Te=1;
#include<De>
#else 
	const int Te=0;
#endif
using namespace std;
#define IF if(Te)
#define MS(m) memset(m,0,sizeof(m))

typedef unsigned U;
typedef pair<int,int > P;
typedef long long ll;
void inp();
const int mod = 1e9+7;
ll qp(ll x){
	ll b = 1;
	ll n = mod-2;
#ifdef XS 
	printf("%lld^-1 = ",x);
#endif
	while(n){
		if(n&1)b*=x;
		x*=x;
		b%=mod;
		x%=mod;
		n>>=1;
	}
#ifdef XS
	printf("%lld\n", b);
#endif 
	return b;
}
int main(){
#ifdef XS
	freopen("D.in","r",stdin);
#endif
	try{
		//int n;scanf("%d",&n);for(int i=1;i<=n;i++)
		inp();
	}
	catch(... ){
		IF printf("%s","exception");
	}//for compatibility with cygwin c++ runtime
	return 0;
}
const int N = 1e5+5;
int a[N];
ll com[2][N];
#define mo(x) (x%=mod)
void init(ll *a, int n ){
	a[0]=1;
	for(int i =1;i<=n;i++){
		a[i]=a[i-1]*(n-i+1);
		mo(a[i]);
		a[i]*=qp(i);
		mo(a[i]);
	}
}
void inp(){
	int n;
	scanf("%d",&n);
	int d=0;
	for(int i = 1;i<=n+1;i++){
		int x;
		scanf("%d",&x);
		if(a[x]){
			d = i - a[x] + 1;
			break;
		}
		else a[x]=i;
	}
	//printf("%d\n",n);
	MS(a);
	MS(com);
	init(com[0],n+1);
	init(com[1],n+1-d);
#ifdef XS
	for(int i = 1;i<=n+1;i++){
		printf("com[0][%d]:%lld ,com[1][%d]:%lld\n",i,com[0][i],i-1,com[1][i-1]);
	}
#endif
	for(int i =1;i<=n+1;i++){
	//	l*=(n-i+2);mo(l);l*=qp(i);mo(l);
	//	r*=(n-d-i+2);mo(r);r*=qp(i-1);mo(r);
	//	if(i>n-d+1)r=0;
		printf("%lld\n",((com[0][i] - com[1][i-1]+mod)%mod));
	}
}
//D.cc by xsthunder at Thu Jul 13 20:59:49 2017


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

int main() {
    int a, b, c;
    int r1 = 0, r2 = 0;
    while(~scanf("%d,%d,%d", &a, &b, &c)) {
        r1 += a * a + b * b == c * c;
        r2 += a == b;
    }
    cout << r1 << "\n" << r2 << endl;
}


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

#define int long long

void solve() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int result = max(a * c, max(a * d, max(b * c, b * d)));
    cout << result;
}

signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int t = 1;
    //cin >> t;

    while (t--) {
        solve();
    }

    return 0;
}

Measured memory_bytes: 3604
#include <string>
#include <iostream>
#include <cstring>
#include <algorithm>

using namespace std;

bool lt(string arg1, string arg2){
    if(arg1.size() == arg2.size()){
        return arg1 < arg2;
    }
    return arg1.size() <= arg2.size();
}

int main(){
    int w, h;

    while(cin >> w >> h){
        if((w|h) == 0) break;

        string dp[h+1][w+1];
        char b[h+1][w+1];
        char tmp;

        for(int i=0;i<=h;++i){
            for(int j=0;j<=w;++j){
                dp[i][j] = "";
            }
        }

        for(int i=1;i<=h;++i){
            for(int j=1;j<=w;++j){
                cin >> tmp;
                if('0' <= tmp && tmp <= '9'){
                    b[i][j] = tmp;
                }else{
                    b[i][j] = -1;
                }
            }
        }

        string ret="";
        for(int i=1;i<=h;++i){
            for(int j=1;j<=w;++j){
                if(b[i][j] == -1){
                    dp[i][j] = "";
                }else{
                    string str[2];
                    str[0] = dp[i-1][j] + b[i][j];
                    str[1] = dp[i][j-1] + b[i][j];
                    if(str[0] == "0") str[0] = "";
                    if(str[1] == "0") str[1] = "";

                    if(lt(str[0],str[1])){
                        dp[i][j] = str[1];
                    }else{
                        dp[i][j] = str[0];
                    }
                }
                if(lt(ret,dp[i][j])){
                    ret = dp[i][j];
                }
            }
        }
        cout << ret << endl;
    }
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>

int main(void)
{
    long long n,pow=5,ans=0;

    scanf("%lld",&n);

    if(n%2==1) printf("%d",0);
    else
    {
        n=n/2;
        while(pow<=n)
        {
            ans+=n/pow;
            pow*=5;
        }
        printf("%lld",ans);
    }

    return 0;
}

Measured memory_bytes: 128
n = int(input())
s = input()

# All black
isBlack = []
for i in range(len(s)):
    isBlack.append(True if s[i]=='#' else False)
    
cost = len(s) - sum(isBlack)
min_cost = cost

# turning white one by one
for i in range(len(s)):
    if not isBlack[i]:
        cost -= 1
    else:
        cost += 1
        
        
    if cost<min_cost:
        min_cost = cost
print(min_cost)

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

int main()
{
  int n, k;
  cin >> n >> k;
  vector<int> a(n), dp(k+1);
  for (int i = 0; i < n; ++i)
    cin >> a[i];
  dp[0] = 0;
  for (int i = 1; i <= k; ++i)
  {
    for (auto elem : a) {
      if (i >= elem and dp[i - elem] == 0) {
        dp[i] = 1;
        break;
      }
    }
  }
  cout << (dp[k] ? "First" : "Second")<< '\n';

  return 0;
}


Measured memory_bytes: 640
fun main(args: Array<String>) {
    val (Nl, C) = listOfLong()
    val N = Nl.toInt()
    val x = LongArray(N + 1)
    val v = IntArray(N + 1)
    val sL = LongArray(N + 1)
    val sR = LongArray(N + 1)
    val sLM = LongArray(N + 1)
    val sRM = LongArray(N + 1)
    val sLTM = LongArray(N + 1)
    val sRTM = LongArray(N + 1)
    for (n in 1..N) {
        val (X, V) = listOfLong()
        x[n] = X; v[n] = V.toInt()
        sL[n] = sL[n - 1] + v[n]
    }
    for (n in 1..N) {
        sR[n] = sR[n - 1] + v[N - n + 1]
    }
    for (n in 1..N) {
        sLM[n] = Math.max(sLM[n - 1], sL[n] - x[n])
        sRM[n] = Math.max(sRM[n - 1], sR[n] - (C - x[N - n + 1]))
    }
    for (n in 1..N) {
        sLTM[n] = Math.max(sLTM[n - 1], sL[n] - 2 * x[n] + sRM[N - n])
        sRTM[n] = Math.max(sRTM[n - 1], sR[n] - 2 * (C - x[N - n + 1]) + sLM[N - n]
        )
    }
    val ans = Math.max(
        Math.max(sLM[N], sRM[N]),
        Math.max(sLTM[N], sRTM[N])
    )
    println(ans)
}

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun listOfString() = next().split(" ")
fun listOfLong(d: Int = 0) = listOfString().map { it.toLong() + d }



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

int main() {
    vector<int> as(5);
    for (int i = 0; i < 5; i++) cin >> as[i];
    int ans = 1e9;
    for (int i = 0; i < 5; i++) {
        int tmp = 0;
        for (int j = 0; j < 5; j++) {
            if (i == j) {
                tmp += as[j];
            } else {
                tmp += (as[j] + 9) / 10 * 10;
            }
        }
        // cerr << tmp << endl;
        ans = min(ans, tmp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define slowanddetermined ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define debug(x); cout<<#x<<"="<<x<<endl;
#define debug2(x,y); cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl;
#define int long long
using namespace std;



int32_t main()
{
    slowanddetermined

    int n,k,c;
    cin>>n>>k>>c;

    string s;
    cin>>s;

    vector<int>left(n);
    vector<int>right(n);
    int cnt=1;
    for(int i=0;i<n;i++){
        if(s[i]=='o'){
            left[i]=cnt;
            cnt++;
            i+=c;
        }
    }
    cnt=k;
    for(int i=n-1;i>=0;i--){
        if(s[i]=='o'){
            right[i]=cnt;
            cnt--;
            i-=(c);
        }

    }
    for(int i=0;i<n;i++){
        if(left[i]==right[i] && left[i]>=1){
            cout<<i+1<<endl;
        }
    }

    return 0;
}





Measured memory_bytes: 5012
import sys
#import string
#from collections import defaultdict, deque, Counter
#import bisect
#import heapq
#import math
#from itertools import accumulate
#from itertools import permutations as perm
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as combr
#from fractions import gcd
#import numpy as np

stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18

def solve():
    #n = int(stdin.readline().rstrip())
    n,k = map(int, stdin.readline().rstrip().split())
    A = list(map(int, stdin.readline().rstrip().split()))
    #numbers = [[int(c) for c in l.strip().split()] for l in sys.stdin]
    #word = [stdin.readline().rstrip() for _ in range(n)]
    #number = [[int(c) for c in stdin.readline().rstrip()] for _ in range(n)]
    #zeros = [[0] * w for i in range(h)]
    for i in range(k,n+1):
        last = A[i-1]
        if i == k:
            pass
        else:
            fi = A[i-k-1]
            if fi < last:
                print("Yes")
            else:
                print("No")


if __name__ == '__main__':
    solve()


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

int main(){
  long n;
  cin >> n;
  string ans;
  while(n){
    ans.push_back(--n % 26 + 'a');
    n /= 26;
  }
  reverse(ans.begin(), ans.end());
  cout << ans << endl;
}

Measured memory_bytes: 3596
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Scanner;
import java.util.TreeSet;

import javax.print.attribute.standard.MediaSize.Other;
import javax.xml.bind.ParseConversionEvent;

public class Main {

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

		final int N = sc.nextInt();
		final int K = sc.nextInt();
		
		int[][] boats = new int[K][];
		for(int i = 0; i < K; i++){
			final int size = sc.nextInt();
			boats[i] = new int[size];
			
			for(int j = 0; j < size; j++){
				boats[i][j] = sc.nextInt() - 1;
			}
		}
		
		final int R = sc.nextInt();
		boolean[][] bad = new boolean[N][N];
		for(int i = 0; i < R; i++){
			final int one = sc.nextInt() - 1;
			final int two = sc.nextInt() - 1;
			bad[one][two] = bad[two][one] = true;
		}
		
		boolean[] feelgood = new boolean[N];
		Arrays.fill(feelgood, true);
		
		for(int i = 0; i < K; i++){
			for(int j = 0; j < boats[i].length; j++){
				for(int k = j + 1; k < boats[i].length; k++){
					if(bad[boats[i][j]][boats[i][k]]){
						feelgood[boats[i][j]] = feelgood[boats[i][k]] = false;
					}
				}
			}
		}
		
		int count = 0;
		for(boolean f : feelgood){
			if(!f){
				count++;
			}
		}
		
		System.out.println(count);
	}

}

Measured memory_bytes: 12000
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		long[] A = new long[N];
		long[] B = new long[N];
		for(int i = 0; i < N; i++) {
			A[i] = sc.nextLong();
			B[i] = sc.nextLong();
		}
		sc.close();
		Data[] d = new Data[N];
		for(int i = 0; i < N; i++) {
			d[i] = new Data(A[i], B[i]);
		}
		Arrays.sort(d, new MyComp());
		long ans = 0;
		long res = M;
		for(int i = 0; i < N; i++) {
			if(res - d[i].b <= 0) {
				ans += d[i].a * res;
				break;
			}else {
				ans += d[i].b * d[i].a;
				res -= d[i].b;
			}
		}
		System.out.println(ans);

	}
	static class Data{
		long a, b;
		Data(long a, long b){
			this.a = a;
			this.b = b;
		}
	}
	static class MyComp implements Comparator<Data>{
		public int compare(Data d1, Data d2) {
			if(d1.a < d2.a) {
				return -1;
			}else if(d1.a == d2.a) {
				return 0;
			}else {
				return 1;
			}
		}
	}
}


Measured memory_bytes: 92956
from collections import deque

S = input()
Q = int(input())
queue = deque(S)

rev_cnt = 0
rev = 0
for i in range(Q):
  query = input().split()
  if query[0]=="1":
    rev_cnt += 1
    rev = rev_cnt % 2
  elif query[0]=="2":
    #print(query)
    s=query[2]
    if query[1] == "1" and rev == 0:
      queue.appendleft(s)
    elif query[1] == "1" and rev == 1:
      queue.append(s)
    elif query[1] == "2" and rev == 0:
      queue.append(s)
    elif query[1] == "2" and rev == 1:
      queue.appendleft(s)
if rev == 0:
  print(''.join(list(queue)))
else:
  print(''.join(reversed(list(queue))))

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

int main()
{
  int N;
  cin >> N;
  string S;
  cin >> S;
  int now = 0;
  int ans = 0;
  for (int i = 0; i < S.size(); i++)
  {
    if (S[i] == 'I')
      now++;
    else
      now--;
    ans = max(now, ans);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n;
  cin>>n;
  if(n<105)cout<<0<<endl;
  else if(n<135)cout<<1<<endl;
  else if(n<165)cout<<2<<endl;
  else if(n<189)cout<<3<<endl;
  else if(n<195)cout<<4<<endl;
  else cout<<5<<endl;
}

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

int main() {
  int N;
  cin >> N;
  if (N % 10 == 2 || N % 10 == 4 || N % 10 == 5 || N % 10 == 7 || N % 10 == 9) {
    cout << "hon" << endl;
  }
  else if (N % 10 == 0 || N % 10 == 1 || N % 10 == 6 || N % 10 == 8) {
    cout << "pon" << endl;
  }
  else {
    cout << "bon" << endl;
  }
}

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

int main(){
    string s; cin >> s;
    int K; cin >> K;
    for(int i=0; i<s.length()-1; i++){
        if(s[i]!='a'){
            if(K>='z'-s[i]+1){
                K -= ('z'-s[i]+1);
                s[i]='a';
            }
        }
    }
    K = K%26;
    int letter = s[s.length()-1] + K;
    if(letter>'z'){
        letter -= 26;
    }
    s[s.length()-1] = letter;
     cout << s << endl;
    return 0;
}

Measured memory_bytes: 512
from operator import itemgetter
n, m = map(int, input().split())
cities = []
for i in range(1, m + 1):
    p, y = map(int, input().split())
    cities.append([i, p, y])
cities.sort(key=itemgetter(2))
cities.sort(key=itemgetter(1))

prefNo = 0
for city in cities:
    if prefNo != city[1]:
        prefNo = city[1]
        seq = 0
    seq += 1
    city.append(seq)
cities.sort()
for city in cities:
    print(str(city[1]).zfill(6) + str(city[3]).zfill(6))


Measured memory_bytes: 31140
require 'pp'
require 'prime'
$DEBUG ? define_method(:dpp){|e|pp e} : define_method(:dpp){|e|}

# Nと空白区切の入力値を数値の配列で返却する
def gets_n_and_i_list()
  return gets.chomp.to_i, gets.chomp.split(" ").map(&:to_i)
end
n, alist = gets_n_and_i_list
total = 0

alist.each do |a|
  if a.even?
    factors = a.prime_division
    total += factors.first[1]
  end
end

puts total

Measured memory_bytes: 15400
S = input()
T = input()
N = len(S)
n = len(T)
ans = N
for i in range(N-n+1):
    s = S[i:i+n]
    temp = 0
    for ss, t in zip(s, T):
        temp += ss != t
    ans = min(ans, temp)

print(ans)

Measured memory_bytes: 9128
n = gets.to_i
x = []
x[0] = gets.split.map(&:to_i)
x[1] = gets.split.map(&:to_i)
puts x.transpose.map{|f,s|(f-s).abs}.inject(:+)
puts Math.sqrt(x.transpose.map{|f,s|(f-s)**2}.inject(:+))
puts Math.cbrt(x.transpose.map{|f,s|(f-s).abs**3}.inject(:+))
puts x.transpose.map{|f,s|(f-s).abs}.max

Measured memory_bytes: 8840
int main(){
    int A,B,C,D;
    int second=0;
    scanf("%d%d%d%d",&A,&B,&C,&D);
    if(B>C&&B<=D){
        if(A<=C)second=B-C;
        else if(A>C)second=B-A;
    }
    else if(B>D){
        if(A<=C)second=D-C;
        else if(A>C&&A<D)second=D-A;
    }
    printf("%d",second);
    return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>

namespace IO {
    template <typename _T>
    inline bool read (_T& x) {
        x = 0;
        _T y = 1;
        char c = getchar();
        while ((c < '0' || '9' < c) && c != EOF) {
            if (c == '-') y = -1;
            c = getchar();
        }
        if (c == EOF) return false;
        while ('0' <= c && c <= '9') x = x * 10 + c - '0', c = getchar();
        x *= y;
        return true;
    }

    template <typename _T>
    inline _T input () {
        _T x = 0, y = 1;
        char c = getchar();
        while ((c < '0' || '9' < c) && c != EOF) {
            if (c == '-') y = -1;
            c = getchar();
        }
        if (c == EOF) return 0;
        while ('0' <= c && c <= '9') x = x * 10 + c - '0', c = getchar();
        x *= y;
        return x;
    }
};
using namespace IO;

namespace modular {
    const int MOD = 1000000007;

    inline int add (int x, int y) { return (x += y) >= MOD ? x -= MOD : x; }

    inline void inc (int &x, int y) { (x += y) >= MOD ? x -= MOD : 0; }

    inline int mul (int x, int y) { return 1LL * x * y % MOD; }

    inline int qpow (int x, int y) {
        int ans = 1;
        for (; y; y >>= 1, x = mul(x, x)) if (y & 1) ans = mul(ans, x);
        return ans;
    }
};

#define reg register
#define MAX_N 200007
#define FIN(s) freopen(s, "r", stdin)
#define FOUT(s) freopen(s, "w", stdout)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define rep(i, l, r) for(int i = l; i <= r; ++i)
#define lep(i, l, r) for(int i = l; i < r; ++i)
#define irep(i, r, l) for(int i = r; i >= l; --i)
#define ilep(i, r, l) for(int i = r; i > l; --i)
typedef long long ll;

int N, M;
int head[MAX_N], to[MAX_N << 1], nxt[MAX_N << 1], cap;
int dis[MAX_N];
ll cnt[MAX_N];
bool vis[MAX_N];

inline void addE (int u, int v) {
    nxt[++cap] = head[u];
    head[u] = cap;
    to[cap] = v;
}

bool dfs (int x) {
    vis[x] = true;
    bool flag = false;
    for (int i = head[x]; i; i = nxt[i]) {
        if (!vis[to[i]]) {
            dis[to[i]] = dis[x] + 1;
            flag |= dfs(to[i]);
        } else flag |= (!(dis[x] - dis[to[i]] & 1));
    }
    return flag;
}

int main () {
#ifdef LOCAL
    FIN("in");
#endif
    read(N), read(M);
    int u, v;
    rep (i, 1, M) {
        read(u), read(v);
        addE(u, v);
        addE(v, u);
    }
    rep (i, 1, N) if (!vis[i]) {
        if (!head[i]) { cnt[0]++; continue; }
        if (dfs(i)) cnt[2]++;
        else cnt[1]++;
    }
    ll res = 0;
    res += cnt[2] * cnt[2];
    res += 2LL * cnt[2] * cnt[1];
    res += 2LL * cnt[1] * cnt[1];
    res += 2LL * cnt[0] * (N - cnt[0]);
    res += cnt[0] * cnt[0];
    printf("%lld\n", res);
    return 0;
}


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

using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 2147483647;
const ll INFL = 9223372036854775807;
const ll mod = 1000000007;




ll gcd(ll x, ll y) {
	if (y == 0) return x;
	return gcd(y, x%y);
}



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

	VI a(n);
	REP(i, n)cin >> a[i];

	REP(i, n - 1) {
		a[i + 1] = gcd(a[i + 1], a[i]);
	}

	cout << a[n - 1] << endl;
	

	return 0;

}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B;
  string S;
  cin >> A >> B >> S;
  bool res = true;
  for (int i = 0; i < S.size(); i++) if (i == A && S[i] != '-' || i != A && !isdigit(S[i])) res = false;
  cout << (res ? "Yes" : "No");
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <boost/multiprecision/cpp_int.hpp>
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstring>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <set>
#include <numeric>
#include <sstream>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
#include<iomanip>
namespace mp = boost::multiprecision;
using namespace std;
using ull = unsigned long long;
using ld = long double;
using lll = boost::multiprecision::cpp_int;
using ll = long long;
#define FOR(i, N) for(ll i = 0; i < N; ++i)

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
// using int = ll;
ll gcd(ll m, ll n) {
    if(n == 0)
        return abs(m);
    return (gcd(n, m % n));
}
void putYN(bool b) {
    if(b) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}
void swap(ll &a, ll &b) {
    ll tmp = a;
    a = b;
    b = tmp;
}
ll combi(ll n, ll k) {
    ll r = 1, rr = 1;
    for(ll i = 0; i < k; ++i) {
        r *= (n - i);
        rr *= (i + 1);
        // r %= 1000000007;
        // rr %= 1000000007;
    }
    r /= rr;
    // r %= 1000000007;
    return r;
}
ll saiki(ll a,ll b,ll c,ll i,vector<ll> &hat,ll N,vector<map<vector<ll>,ll>>& memo){
  ll num=0;
  if(i==N)return 1;
  if(memo[i].find(vector<ll>{a,b,c})!=memo[i].end()){
    return memo[i].find(vector<ll>{a,b,c})->second;
  }
  if(a==hat[i]){
    num+=saiki(a+1,b,c,i+1,hat,N,memo);
  }
  if(b==hat[i]){
    num+=saiki(a,b+1,c,i+1,hat,N,memo);
  }
  num%=1000000007;
  if(c==hat[i]){
    num+=saiki(a,b,c+1,i+1,hat,N,memo);
  }
  num%=1000000007;
  memo[i][vector<ll>{a,b,c}]=num;
  return num;
}
int main() {
  ll N;
  cin>>N;
  vector<ll>A(N);
  FOR(i,N){
    cin>>A[i];
  }
  vector<map<vector<ll>,ll>> memo(N);
  cout<<saiki(0,0,0,0,A,N,memo)<<endl;;
  return 0;
}


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

using namespace std;

const int N = 2e5 + 3;
const int M = 1e6 + 6;
const long long MOD = 1e9 + 7;
const long long INF = 1e18 + 3;
const int SM = 1e3 + 7;
const double EPS = 3e-16;

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

	int a, n;
	cin >> a >> n;
	
	if(a - n * 2 > 0){
		cout << a - n * 2;
	}
	else {
		cout << 0;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;

//定数
//円周率
const double pi = 3.141592653589793238462643383279;
//天井
const int INF = 1000000000; // = 10^9
const ll LINF = 100000000000000000; // = 10^17
//ABC文字列
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZABC";
const string abc = "abcdefghijklmnopqrstuvwxyzabc";
//よくあるmodくん
const ll MOD = 1000000007; // = 10^9 + 7
//前処理テーブルの大きさ指定
const int MAX = 1200000; // = 10^6 + 2*(10^5)
//ちなみに、1024MBで持てる最大長の配列は10^8程度

//データ構造
//隣接リスト用構造体（有向グラフ向け）
struct edge {
  ll to; // E.toでその辺の終点へアクセスできる。
  ll cost; // e.costでその辺の重みにアクセスできる。
};
//Union_Find木
struct UnionFind {
  vector<int> UF; // UF.at(i) : iの親の番号
  vector<int> SIZE; // SIZE.at(root(i)) : iと連結されてる要素の数
  UnionFind(int N) : UF(N), SIZE(N, 1) { // 最初は全てが根であるとして初期化
    for(int i = 0; i < N; i++) {
      UF.at(i) = i;
    }
  }
  int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (UF.at(x) == x) {
      return x;
    }
    return UF.at(x) = root(UF.at(x));
  }
  void unite(int x, int y) { // xとyの木を併合
    int rx = root(x); // xの根をrx
    int ry = root(y); // yの根をry
    if (rx == ry) {
      return; // xとyの根が同じ(=同じ木にある)時はそのまま
    }
    // xとyの根が同じでない(=同じ木にない)時：小さい方の根を大きい方の根につける。
    if (SIZE.at(rx) < SIZE.at(ry)) {
      UF.at(rx) = ry;
      SIZE.at(ry) += SIZE.at(rx);
      SIZE.at(rx) = 0;
    }
    else {
      UF.at(ry) = rx;
      SIZE.at(rx) += SIZE.at(ry);
      SIZE.at(ry) = 0;
    }
  }
  bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す。
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
  int size(int x) { // xと連結されてる要素の数を返す。
    return SIZE.at(root(x));
  }
};

//関数 (計算量)
//ctoi (O(1))
int ctoi(char c){
  if (c == '0') return 0;
  if (c == '1') return 1;
  if (c == '2') return 2;
  if (c == '3') return 3;
  if (c == '4') return 4;
  if (c == '5') return 5; 
  if (c == '6') return 6;
  if (c == '7') return 7;
  if (c == '8') return 8;
  if (c == '9') return 9;
  return -1;  
}
//to_char (O(1))
char to_char(int i){
  if (i == 0) return '0';
  if (i == 1) return '1';
  if (i == 2) return '2';
  if (i == 3) return '3';
  if (i == 4) return '4';
  if (i == 5) return '5';
  if (i == 6) return '6';
  if (i == 7) return '7';
  if (i == 8) return '8'; 
  if (i == 9) return '9';
  return ' ';  
}

// A^N mod M を計算する。modしたくなかったらM = LINFとかにすればよい。(O(√N))
ll modpow(ll A, ll N, ll M) {
  ll ans = 1;
  while (N > 0) {
    if (N & 1) ans = ans * A % M;
      A = A * A % M;
      N >>= 1;
   }
  return ans;
}

//メイン処理
int main() {
  cout << fixed << setprecision(16); //精度向上
  //ここまでテンプレ
  int N;
  cin >> N;
  ll TN = 0, AN = 0;
  for (int i = 0; i < N; i++) {
    ll T, A;
    cin >> T >> A;
    if ((TN + 0.0) / T > (AN + 0.0) / A) {
      ll M = TN / T;
      if (TN % T != 0) {
        M++;
      }
      TN = T * M;
      AN = A * M;
    }
    else {
      ll M = AN / A;
      if (TN == 0 || AN % A != 0) {
        M++;
      }
      TN = T * M;
      AN = A * M;
    }
  }
  cout << TN + AN << endl;
}

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

int main() {
	vector<int> vec(3); int jui_a, jui_b, ans;
	for (int i = 0; i < 3; i++) cin >> vec[i];
	cin >> jui_a >> jui_b;
	sort(vec.begin(), vec.end());
	ans = vec[0] + (jui_a > jui_b ? jui_b : jui_a) - 50;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3132
#include "bits/stdc++.h"
#define PRECISION(x) cout << fixed << setprecision(x)
#define FAST_IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define ALLR(X) (X).rbegin(), (X).rend()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define F first
#define S second

using namespace std;
 
template<class T> void max_self(T & a, const T & b) { if(a < b) a = b; }
template<class T> void min_self(T & a, const T & b) { if(a > b) a = b; }
typedef long long LL;
const int INF = 1e9 + 7;
const double PI = acos(-1.0);
const double EPS = (1e-9);


int main(){
  FAST_IO  

  int grid[3][3];

  for(int r = 0; r < 3; ++r){
    for(int c = 0; c < 3; ++c){
      cin >> grid[r][c];
    }
  }

  auto checkRow = [&](){
    for(int r = 0; r < 2; ++r){
      int diff1 = grid[r][0] - grid[r + 1][0];
      int diff2 = grid[r][1] - grid[r + 1][1];
      int diff3 = grid[r][2] - grid[r + 1][2];
      if(diff1 != diff2 || diff2 != diff3) return false;
    }

    return true;
  };
  
  auto checkCol = [&](){
    for(int c = 0; c < 2; ++c){
      int diff1 = grid[0][c] - grid[0][c + 1];
      int diff2 = grid[1][c] - grid[1][c + 1];
      int diff3 = grid[2][c] - grid[2][c + 1];
      if(diff1 != diff2 || diff2 != diff3) return false;
    }

    return true;
  };

  if(checkRow() && checkCol()) cout << "Yes\n";
  else cout << "No\n";

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;
const ll INF = 1000000000000000000LL;

// ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

ll factorial(ll n) {
  ll answer = 1;
  while (n > 1) {
    answer *= n;
    answer %= mod;
    n--;
  }
  return answer;
}

ll combination(ll n, ll r) {
  return factorial(n) / (factorial(r) * factorial(n - r));
}

ll permutation(ll n, ll r) { return factorial(n) / factorial(n - r); }

template <typename T>
void remove(std::vector<T>& vector, unsigned int index) {
  vector.erase(vector.begin() + index);
}

map<ll, ll> prime_factor(ll n) {
  map<ll, ll> ret;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1) ret[n] = 1;
  return ret;
}
// for (auto p : prime_factor(n)) {
//	while (p.second--) {
//		cout << p.first << endl;
//	}
//}

vector<ll> divisor(ll n) {
  vector<ll> ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

bool compare_by_b(pair<ll, ll> a, pair<ll, ll> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

ll gcd(ll a, ll b) {
  if (a < b) {
    a ^= b;
    b ^= a;
    a ^= b;
  }

  return b ? gcd(b, a % b) : a;
}

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

typedef vector<int> ivec;
typedef vector<string> svec;
typedef vector<ll> lvec;

int main() {
  int a, b;
  cin >> a >> b;
  ll ans = lcm(a, b);
  cout << ans << endl;
  return 0;
}

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

using namespace std;
int main(void){
    // Your code here!
    map<string, int> mp;
    int N;
    cin >> N;
    for(int i=0; i<N; i++){
        string str;
        cin >> str;
        if(mp[str]==0) {
            mp[str]=1;
        } else {
            mp[str]+=1;
        }
    }
    cout << mp.size();
    
}

Measured memory_bytes: 19224
#include <bits/stdc++.h>
typedef unsigned long long ll; 
#define rep(i, n) for(ll i=0; i<(n); i++)
using namespace std;
const ll mod = 1e9 + 7;

// Returns sum of bitwise OR of all pairs **** O(n) ***** 
ll sumXOR(ll arr[], int n){

    ll sum = 0; 
    rep(i, 60){
        ll zero_cnt = 0, one_cnt = 0;  
        ll idsum = 0;  
        rep(j, n){           //ビット桁ごとに計算
            if(arr[j] & 1) // 1ビット目が1ならone_nt++; 
                one_cnt++; 
            else
                zero_cnt++; 
            arr[j] >>= 1;
        }         
        idsum = one_cnt * (zero_cnt * ( (1LL << i) % mod) % mod);   
        sum += idsum % mod;
        sum %= mod;
    } 
    return sum; 
} 
  
int main(){

    int n;
    cin >> n;
    ll a[300000]; 
    rep(i, n){
        cin >> a[i];
    } 
    cout << sumXOR(a, n)%mod;
    return 0; 
} 


Measured memory_bytes: 2560