akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define int long long
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

signed main(){
	int n,b,t;
	double y,r;
	while(1) {
		cin>>n;
		if(n==0) break;
		cin>>y;
		int ans=0;
		double MAX=0;
		rep(i,0,n){
			cin>>b>>r>>t;
			double tmp;
			if(t==1){
				tmp=1+y*r/100;
			}else{
				tmp=pow((1+r/100),y);
			}
			if(tmp>MAX){
				MAX=tmp;
				ans=b;
			}
		}
		o(ans);
	}

}

Measured memory_bytes: 1316
def main():
    N = int(input())
    A = tuple(map(int, input().split()))
    B = tuple(map(int, input().split()))

    la = 0
    lb = 0
    for a, b in zip(A, B):
        if a > b:
            la += a - b
        elif a < b:
            lb += (b - a) // 2

    if la > lb:
        print('No')
    else:
        print('Yes')

main()


Measured memory_bytes: 4600
#include<iostream>
#include<cmath>
#include<deque>
#include<vector>
#include<algorithm>
#include<unordered_set>
#include<cassert>

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

using namespace std;

typedef unsigned long long ull;

const ull base = 1000000007ULL;
const int maxr = 5;

#define MAX 100100
int n;
string s[MAX];
char tmp[410000];
unordered_set<ull> S;

void init() {
  REP(len,1,maxr+1) {
    rep(i,n) {
      rep(j,(int)s[i].size()) {
	ull hash = 0;
	bool ok = true;	 
	rep(k,len) {
	  if( j + k >= (int)s[i].size() ) { ok = false; break; }
	  hash *= base;
	  hash += (ull)s[i][j+k];
	}
	if( ok ) {
	  S.insert(hash);	
	} else break;
      }
    }
  }
}

string ans;
bool dfs(int depth,int len,ull hash) {
  if( depth >= len ) {
    if( S.count(hash) ) return false;
    return true;
  }
  for(char c='a';c<='z';++c) {
    if( dfs(depth+1,len,hash*base+c) ) {
      ans += string(1,c);
      return true;
    }
  }
  return false;
}

void compute() {
  init();
  ans = "";
  REP(len,1,maxr+1) {
    if( dfs(0,len,0) ) {
      reverse(ans.begin(),ans.end());
      cout << ans << endl;
      return;
    }
  }
  assert(false);
}

int main() {
  scanf("%d",&n);
  rep(i,n) {
    scanf(" %s",&tmp[0]);
    s[i] = string(tmp);
  }
  compute();
  return 0;
}

Measured memory_bytes: 38252
N = int(input())
T,A = map(int,input().split())
List = list(map(int,input().split()))
div = 100000
for i in range(len(List)):
    heat = T - List[i] *0.006
    if(div>abs(A - heat)):
        div = abs(A -heat)
        ans = i + 1
print(ans)

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


void solve(long long K, long long A, long long B){
    for(int i = A;i <= B;i++){
        if(i % K == 0){
            cout<<"OK"<<endl;
            return;
        }
    }
    cout<<"NG"<<endl;
}

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


Measured memory_bytes: 3764
/*
                                                  __          __
      /\   |   |     /\   |  | |  |     /\   | / |  )   /\   |  )
     /__\  |   |    /__\  |--| |  |    /__\  |<  |-<   /__\  |-<
    /    \ |__ |__ /    \ |  | \__/   /    \ | \ |__) /    \ |  \

*/

#import<bits/stdc++.h>
typedef long long ll;
#define num 10000010
#define root 10000
#define forll(i,a,b,c) for(int i=a; i<=b; i+=c)
#define forll2(i,a,b,c) for(int i=a; i>=b; i-=c)
#define pb(n) push_back(n)

using namespace std;

int main()
{
  int a;
  cin>>a;
  int p=a%1000;
  if(p==0) cout<<p<<"\n";
  else cout<<1000-p<<"\n";
}


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

using namespace std;
#define rep(i,m,n) for(int i=m;i<n;++i)
#define llrep(i,m,n) for(ll i=m;i<n;++i)
#define inf 1000000000
#define llinf 1000000000000000000
#define mod 1000000007
#define ll long long
#define mp make_pair
#define all(v) v.begin(),v.end()

ll fac(ll n) {
	ll hoge = 1;
	rep(i, 1, n + 1) {
		hoge = (hoge * i) % mod;
	}
	return hoge;
}

ll inv(ll n) {
	int p = mod - 2;
	ll hoge = 1;
	ll tmp = n;
	while (p) {
		if ((p & 1) == 1) {
			hoge = (hoge * tmp) % mod;
		}
		tmp = (tmp * tmp) % mod;
		p >>= 1;
	}
	return hoge;
}

int main() {
	ll n, m, k;
	cin >> n >> m >> k;
	ll ans = (((((n - 1) * n * (n + 1) / 6) % mod) * ((m * m) % mod)) % mod + ((((m - 1) * m * (m + 1) / 6) % mod) * ((n * n) % mod)) % mod) % mod;
	ans *= (((fac(n * m - 2) * inv(fac(k - 2))) % mod) * inv(fac(n * m - k))) % mod;
	ans %= mod;
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>

using namespace std;
using lli = long long int;
using ll = long long;

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

    vector<ll> T(5);
    for (int i = 0; i < 5; ++i) {
        cin >> T[i];
    }

    ll min = *min_element(T.begin(), T.end());

    lli answer = (N - 1) / min + 1;

    cout << answer + 4 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 9999999

using namespace std;

typedef pair<int, int> P;

int dy[4] = { 0,0,1,-1 };
int dx[4] = { 1,-1,0,0 };
long long ccc[100000];

int main() {
	ll N;
	cin >> N;
	ll cnt = INF;
	for (ll i = 0; i <= N; i++) {
		int cnt1 = 0, cnt2 = 0;
		ll A = i, B = N - i;
		int six = 1, nine = 1;
		while (A > 0) {
			six = 1;
			while (six <= A) {
				six *= 6;
			}
			A -= (six / 6);
			cnt1++;
		}
		while (B > 0) {
			nine = 1;
			while (nine <= B) {
				nine *= 9;
			}
			B -= (nine/9);
			cnt2++;
		}
		if (cnt1 + cnt2 < cnt)cnt = cnt1 + cnt2;
	}
	cout << cnt << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll res = 0;
int N, M;
void solve(long long curr, map<int, vector<int>>& m, set<int>& seen) {
  if (seen.size() == N-1) {
    res++;
    return;
  }
  seen.insert(curr);
  for (auto neigh : m[curr]) {
    if (seen.count(neigh)) continue;
    solve(neigh, m, seen);
  }
  seen.erase(curr);
}

int main() {
  cin >> N >> M;
  map<int, vector<int>> m;
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    m[a].push_back(b);
    m[b].push_back(a);
  }
  set<int> seen;
  solve(1, m, seen);
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
n,m,c=map(int,input().split())
b=list(map(int,input().split()))

res=0
for _ in range(n):
    a=list(map(int,input().split()))
    d=sum(map(lambda a:a[0]*a[1], list(zip(a,b))))+c
    if d > 0:
        res += 1
print(res)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <list>
#include <stack>
#include <unordered_set>
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1LL << 50;
static const int NIL = -1;
static const int MOD = 1000000007;
 
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define SORT(v) sort(v.begin(), v.end());
#define pb push_back
#define mp make_pair
#define np next_permutation
#define pq priority_queue
 
int gcd(int a, int b) { int c; while (b != 0) { c = a%b; a = b; b = c; }return a; }
int lcm(int a, int b) { int c = gcd(a, b); a /= c; return a*b; }
int nCr(int a, int b) { int i, r = 1; for (i = 1; i <= b; i++) { r *= (a + 1 - i); r /= i; }return r; }
int pow(int a, int b) { int i, r = 1; for (i = 1; i <= b; i++) { r *= a; }return r; }
long long llpow(long long a, long long b) { long long i, r = 1; for (i = 1; i <= b; i++) { r *= a; }return r; }
long long llgcd(long long a, long long b) { long long c; while (b != 0) { c = a%b; a = b; b = c; }return a; }
long long lllcm(long long a, long long b) { long long c = llgcd(a, b); a /= c; return a*b; }
long long llnCr(long long a, long long b) { long long i, r = 1; for (i = 1; i <= b; i++) { r *= (a + 1 - i); r /= i; }return r; }
 
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
 
struct edge{
    int from, to; ll cost;
};

int main(){
    int n;
    cin >> n;
    vector<ll> a, b;
    REP(i, n){
        ll ta, tb;
        cin >> ta >> tb;
        a.pb(ta); b.pb(tb);
    }
    reverse(a.begin(), a.end());
    reverse(b.begin(), b.end());
    ll ans = 0;
    REP(i, n){
        ll x = a[i] + ans, y = b[i];
        if(x % y == 0) continue;
        if(x > y){
            ll tmp = (x + y - 1) / y;
            ans += y * tmp - x;
        }else{
            ans += y - x;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 2036
#include <bits/stdc++.h>
#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long

using namespace std;

// int dp[10005][10005];
ll dp[10005];

int main() {
  ll h, n;
  scanf("%lld %lld", &h, &n);

  vector<pair<ll, ll>> m(n);
  for (ll i = 0; i < n; i++) {
    ll a, b;
    scanf("%lld %lld", &a, &b);

    m[i] = make_pair(a, b);
  }

  for (ll i = 0; i < 10005; i++) {
    // for (ll j = 0; j < 10005; j++) {
    //   dp[i][j] = 1000000000;
    // }
    // dp[i] = 1000000000;
    dp[i] = -1;
  }

  dp[h] = 0;
  for (ll i = h; i >= 0; i--) {
    if (dp[i] == -1) {
      continue;
    }
    for (ll magic = 0; magic < n; magic++) {
      ll damage = m[magic].first;
      ll consume = m[magic].second;

      ll nextH = i - damage;
      if (nextH < 0) {
        nextH = 0;
      }

      // cout << "nextH:" << nextH << endl;
      // cout << "dp[i]:" << dp[i] << endl;
      if (dp[nextH] == -1) {
        dp[nextH] = dp[i] + consume;
      } else {
        ll newValue = min(dp[nextH], dp[i] + consume);
        dp[nextH] = newValue;
      }

      // cout << "newValue:" << newValue << endl;
    }
  }

  // for (ll i = 0; i < 10; i++) {
  //   cout << i << ":" << dp[i] << endl;
  // }
  cout << dp[0] << endl;
}


Measured memory_bytes: 512
import java.util.*;
import java.math.BigInteger;

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

		while(true){
			int m = sc.nextInt();
			int n = sc.nextInt();
			if(m == 0 && n == 0) break;

			ArrayList<Integer> rem = new ArrayList<Integer>();
			for(int i=1;i<=m;i++) rem.add(i);

			int now = 0;
			for(int i=1;i<=n;i++){
				String s1 = "";
				if(i % 3 == 0) s1 += "Fizz";
				if(i % 5 == 0) s1 += "Buzz";
				if(i % 3 != 0 && i % 5 != 0) s1 += i;

				String s2 = sc.next();
				boolean flg = true; //true:¾¯Å\¬³ê½¶ñÅ é

				for(int j=0;j<s2.length();j++){
					if(s2.charAt(j) < '0' || '9' < s2.charAt(j)){
						flg = false;
					}
				}
				if(flg){
					s2 = new BigInteger(s2).toString();
				}

				if(!s1.equals(s2) && rem.size() > 1){
					rem.remove(now);
					now--;
				}

				now = (now + 1) % rem.size();
			}

			System.out.println(rem.toString().replaceAll("\\[|\\]|,",""));
		}
	}
}

Measured memory_bytes: 13000
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
 
ll mod = 1e9 + 7;
 
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
 
  string s;
  cin >> s;
 
  string k = "keyence";
  ll rec = 0, knum = 0, sl = s.size();
 
  REP(i, sl){
    if(s[i] == k[knum]) knum++;
    else{
      REP(j, 7 - knum){
        if(s[sl - 1 - j] != k[6 - j]){
          cout << "NO" << endl;
          return 0;
        }
      }
      cout << "YES" << endl;
      return 0;
    }
    if(knum == 7){
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
program main
  implicit none
  
  integer :: n,i,j,t,a(100) = 0,al=0,bo=0,endal,endbo
  
  read(*,*)n
  read(*,*)(a(i),i=1, n)
  
  if (n == 1) then
    write(*,*)a(i)
    stop
  end if
  
  do i=1,N-1
     do j=i+1,N
        if(a(i) .gt. a(j))then
           t=a(i)
           a(i)=a(j)
           a(j)=t
        end if
     end do
  end do
  if (mod(n,2)==0) then
    endal = 2
    endbo = 1
  else
    endal = 1
    endbo = 2
  end if
  do i = n, endal, -2
    al = al + a(i)
  end do
  
  do i = n-1, endbo, -2
    bo = bo + a(i)
  end do
  write(*,*)al-bo
end program main

Measured memory_bytes: 256
//Let's join Kaede Takagaki Fan Club !!
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define all(x) x.begin(),x.end()
template<class T>
void dmp(T a){
	rep(i,a.size()) cout << a[i] << " ";
	cout << endl;
}
template<class T>
bool chmax(T&a, T b){
	if(a < b){
		a = b;
		return 1;
	}
	return 0;
}
template<class T>
bool chmin(T&a, T b){
	if(a > b){
		a = b;
		return 1;
	}
	return 0;
}
template<class T>
void g(T &a){
	cin >> a;
}
template<class T>
void o(const T &a,bool space=false){
	cout << a << (space?' ':'\n');
}
//ios::sync_with_stdio(false);
const ll mod = 998244353;

int n, k, a[300005];

int op(int a, int b){
	return max(a, b);
}
int e(){
	return -INF;
}
int main(){
	scanf("%d%d", &n, &k);
	segtree <int, op, e> seg(300005);
	for(int i=1;i<=n;i++){
		scanf("%d", &a[i]);
		int lb = max(0, a[i]-k);
		int ub = min(300000, a[i]+k);
		int cur = max(0, seg.prod(lb, ub+1)) + 1;
		seg.set(a[i], cur);
	}
	printf("%d\n", seg.all_prod());
}

Measured memory_bytes: 8620
import java.util.*;
import java.io.*;
import java.lang.*;
import java.math.*;
public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        // Scanner scan = new Scanner(System.in);
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        // int n = Integer.parseInt(bf.readLine());
       StringTokenizer st = new StringTokenizer(bf.readLine());
       int A = Integer.parseInt(st.nextToken());
       int B = Integer.parseInt(st.nextToken());
       char[][] grid = new char[100][100];
       for(int i=0; i<50; i++) {
         Arrays.fill(grid[i], '.');
         Arrays.fill(grid[i+50], '#');
       }
       int cur = 0;
       for(int i=0; i<B-1; i++) {
         grid[cur/100+1][cur % 100] = '#';
         cur += 2;
         if(cur % 100 == 96) cur+=105;
         else if(cur % 100 == 97) cur+=103;
       }
       cur = 0;
       for(int i=0; i<A-1; i++) {
         grid[cur/100+51][cur % 100] = '.';
         cur += 2;
         if(cur % 100 == 96) cur+=105;
         else if(cur % 100 == 97) cur+=103;
       }
       out.println("100 100");
       for(int i=0; i<100; i++) {
         StringBuilder sb = new StringBuilder();
         for(int j=0; j<100; j++) sb.append(grid[i][j]);
         out.println(sb.toString());
       }
        // int[] a = new int[n];
        // for(int i=0; i<n; i++) a[i] =  Integer.parseInt(st.nextToken());

        out.close(); System.exit(0);
    }


}


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

int N, X, arr[100000];

int main(){
	long long sum = 0;
	scanf("%d%d", &N, &X);
	for(int i = 0; i < N; i++) scanf("%d", &arr[i]);
	for(int i = 1; i < N; i++){
		int sub = max(0, (arr[i] + arr[i - 1]) - X);
		sum += sub;
		arr[i] = max(0, arr[i] - sub);
	}
	printf("%lld\n", sum);
	return 0;
}


Measured memory_bytes: 640
s = input()
n = len(s) - 1
for i in range(1 << n):
    p_or_m = ['-'] * n
    for j in range(n):
        if i >> j & 1:
            p_or_m[n-j-1] = '+'
    
    formula = ''
    for k in range(n):
        formula += s[k] + p_or_m[k]
    formula += s[3]
    if  eval(formula) == 7:
        print(formula + '=7')
        exit()

Measured memory_bytes: 9036
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left
from functools import reduce
input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_list(N): return [s_list() for _ in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    n, k = i_map()
    num_list = i_list()

    trans_list = [0] * n

    next_trans = num_list[0]
    for i in range(n):
        trans_list[i] = next_trans
        next_trans = num_list[next_trans-1]

    # print(trans_list)

    chcek_list = [INF] * n
    for i in range(n):
        if chcek_list[trans_list[i]-1] != INF:
            break
        chcek_list[trans_list[i]-1] = 1

    first_town = trans_list.index(trans_list[i])

    period = i - first_town

    if k <= n:
        print(trans_list[k-1])
    else:
        trans_list = trans_list[first_town:]
        trans_list = trans_list[:period]
        print(trans_list[(k-first_town)%period-1])

if __name__ == '__main__':
    main()


Measured memory_bytes: 97012
#include <iostream>
#include <cstdio>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <queue>
#include <cmath>
#include <cstring>
using namespace std;

void init();
void solve();
int main(){
try { 

#ifndef CUSTOM_MAIN
#ifdef MULTIPLE_TEST_CASES_WITH_T

int T; scanf("%d",&T); while(T--) {init(); solve();}

#else
#ifdef MULTIPLE_TEST_CASES_WITHOUT_T

while(1) {try{init(); } catch(bool t){return 0;} solve(); }

#else

init(); solve();

#endif
#endif
#endif

} catch (const char* s) { return 0; }
    return 0;
}

#ifdef ENABLE_LL
#define int long long
#endif

#ifdef ENABLE_LL
#define I "%lld"
#define II "%lld%lld"
#define III "%lld%lld%lld"
#define IIII "%lld%lld%lld%lld"
#define IN "%lld\n"
#define IIN "%lld%lld\n"
#define IIIN "%lld%lld%lld\n"
#define IIIIN "%lld%lld%lld%lld\n"
#else
#define I "%d"
#define II "%d%d"
#define III "%d%d%d"
#define IIII "%d%d%d%d"
#define IN "%d\n"
#define IIN "%d%d\n"
#define IIIN "%d%d%d\n"
#define IIIIN "%d%d%d%d\n"
#endif

#ifdef __LOCALE__
#define see(a) std::cout << #a << "=" << a << std::endl
#define ses(a) std::cout << #a << "=" << a << " " 
#else
#define see(a) //std::cout << #a << "=" << a << std::endl
#define ses(a)
#endif
#define repe(a,b) for (int a=0;a<(int)b.size();a++)
#define rep(i,n) for (int i=0;i<n;i++)
#define repa(i,n) for (int i=1;i<=n;i++)
#define repi(i,a,b) for (int i=a;i<=b;i++) 
#define repb(i,a,b) for (int i=a;i>=b;i--)
typedef pair < int , int > pr; typedef pair < pr  , int > prr;
#define L first
#define R second
template <class T> inline bool checkMin(T& a , T b) { return (a > b ? a=b,1 : 0); }
template <class T> inline bool checkMax(T& a , T b) { return (a < b ? a=b,1 : 0); }
class Scanner{ private: istream& ist;public: Scanner(istream& in):ist(in){} string next(){ string r; ist >> r; return r; } string nextLine(){ string r; getline(ist,r); return r; } int nextInt(){ int r; ist >> r; return r; } double nextDouble(){ double r; ist >> r; return r; } char nextChar(){ char r; ist>>r; return r;} }; Scanner sc(cin);
void ALERT(bool judgememt, const char* phrase) { if (judgememt) { puts(phrase); throw "ALERT"; } }
bool alert(bool judgememt, const char* phrase) { if (judgememt) puts(phrase); return judgememt; }

const int N = 105;
int a[N];
int n;

void init() {
    scanf(I,&n);
    rep (i,n) scanf(I,&a[i]); 
}

void solve() {
    int ans=0;
    rep (i,n) if (i%2==0 && a[i]%2==1) ans++;
    printf(IN,ans);
}



Measured memory_bytes: 3748
#include <bits/stdc++.h>
using namespace std;
struct data
{
    int t,x,y;
};
bool cmp(data a,data b)
{
    return a.t<b.t;
}
int dist(data a,data b)
{
    return abs(a.x-b.x)+abs(a.y-b.y);
}
const int nmax=100000;
int n;
data p;
data v[nmax+5];
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>v[i].t>>v[i].x>>v[i].y;
    sort(v+1,v+n+1,cmp);
    for(int i=1;i<=n;i++)
    {
        ///cout<<dist(p,v[i])<<" "<<v[i].t-v[i-1].t<<"\n";
        if(dist(p,v[i])<=v[i].t-v[i-1].t and (dist(p,v[i])%2)==(v[i].t-v[i-1].t)%2)
        {
            p=v[i];
            continue;
        }
        cout<<"No";
        return 0;
    }
    cout<<"Yes";
    return 0;
}
/**

**/


Measured memory_bytes: 1408
#include<iostream>
#include<iomanip>
#include<cmath>
#include<vector>
#include<map>
#include<string>
#include<algorithm>
using namespace std;
int main(){
  cout << setprecision(10);
  int N;
  cin >> N;
  vector<int> B(N);
  for(int i=1; i<=N; i++){
    int ai;
    cin >> ai;
    B[ai-1]=i;
  }
  cout << B[0];
  for(int i=1; i<N; i++) cout << " " << B[i];
  cout << endl;
  return 0;
}

Measured memory_bytes: 1280
#include"stdio.h"
#include"stdlib.h"
int main(void){
  int input,odd;
  int tmp;
  scanf("%d",&input);
  tmp = input / 2;
  //printf("%d\n",tmp);
  if(input%2!=0){
    //奇数
    odd = tmp + 1;
  }
  else{
    //偶数
    odd = tmp;
    //printf("0.5",odd);
    //return 0;
  }
  
  printf("%.10f\n",(double)odd/(double)input);
  return 0;
}


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

*/
int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  string S; cin>>S;
  ll sum = 0;
  ll i = 0;
  while (S[i])
  {
    sum += S[i] - '0';
    i++;
  }
  if (sum % 9 == 0)
    cout << "Yes" <<endl;
  else
    cout <<"No" << endl;
  
}

Measured memory_bytes: 3780
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

void zero ()
{
	cout << 0 << endl;
}
int main()
{
	int n, a[100000], check[100000] = {};
	cin >> n;
	for(int i=0; i<n; i++) {
		cin >> a[i];
		check[a[i]]++;
	}

	bool odd = n % 2 ? true : false;
	if((odd and check[0] > 1) or (!odd and check[0])) {
		zero();
		return 0;
	}

	int oel = 0;
	for(int i=1; i<100000; i++){
		if(check[i] % 2) {
			zero();
			return 0;
		}
	}

	n /= 2;

    int ans = 1;
    for(int i=0; i<n; i++){
    	ans *= 2;
    	ans %= 1000000007;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define all(in) in.begin(), in.end()
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
template<class T, class Func = function<T(T, T)>>
class segtree {
    vector<T> obj;
    int offset;
    Func updater;
    T e;
    int bufsize(int num) {
        int i = 1;
        for (; num + 1 >i; i <<= 1);
        offset = i - 1;
        return (i << 1) - 1;
    }
    T query(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l)return e;
        if (a <= l && r <= b)return obj[k];
        else return updater(query(a, b, k * 2 + 1, l, (l + r) / 2), query(a, b, k * 2 + 2, (l + r) / 2, r));
    }
public:
    T query(int a, int b) {//[a,b)
        return query(a, b, 0, 0, offset + 1);
    }
    void updateall(int l = 0, int r = -1) {
        if (r < 0)r = offset + 1;
        l += offset, r += offset;
        do {
            l = (l - 1) >> 1, r = (r - 1) >> 1;
            for (int i = l; i < r; i++)obj[i] = updater(obj[i * 2 + 1], obj[i * 2 + 2]);
        } while (l);
    }
    void update(int k, T &a) {
        k += offset;
        obj[k] = a;
        while (k) {
            k = (k - 1) >> 1;
            obj[k] = updater(obj[k * 2 + 1], obj[k * 2 + 2]);
        }
    }
    segtree(int n, T e, const Func &updater = Func()) :obj(bufsize(n), e), e(e), updater(updater) {}
    segtree(vector<T> &vec, T e, const Func &updater = Func()) :obj(bufsize(vec.size()), e), e(e), updater(updater) {
        copy(vec.begin(), vec.end(), obj.begin() + offset);
        updateall();
    }
    typename vector<T>::reference operator[](int n) {
        return obj[n + offset];
    }
};
signed main(){
    int N; cin >> N;
    vector<int>A(N);
    for(auto& e : A) cin >> e;
    auto sgt = segtree<int>(A,0,[](int a,int b){
        return max(a,b);
    });
    for(int i = 0; i < N; ++i){
        cout <<
        max(sgt.query(0,i),sgt.query(i+1,N));
        cout << endl;
    }
}


Measured memory_bytes: 7296
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<long long>v(n + 5), dp(n + 5);
    for(int i = 1; i <= n; i++){
        cin >> v[i];
    }
    dp[1] = 0;
    dp[2] = abs(v[2] - v[1]);
    if(n == 2){
        cout << dp[2];
        return 0;
    }
    for(int i = 3; i <= n; i++){
        dp[i] = min(dp[i - 1] + abs(v[i] - v[i - 1]), dp[i - 2] + abs(v[i] - v[i - 2]));
    }
    cout << dp[n];
    return 0;
}

Measured memory_bytes: 1792
fn read<T: std::str::FromStr>() -> T {
    let mut n = String::new();
    std::io::stdin().read_line(&mut n).ok();
    n.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn relu(x: i32) -> i32 {
    if x > 0 {
        x
    } else {
        0
    }
}

fn main() {
    let v = read_vec::<i32>();
    let a = v[0];
    let b = v[1];
    let c = v[2];
    let x = v[3];
    let y = v[4];

    let ans1 = c * 2 * x + relu(y - x) * b;
    let ans2 = c * 2 * y + relu(x - y) * a;
    let ans3 = a * x + b * y;
    let ans = std::cmp::min(std::cmp::min(ans1, ans2), ans3);
    println!("{}", ans);
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<cmath>
#include<map>
#include<functional>
#include<queue>
#include<set>
#include<stack>
#include<iomanip>
#include<algorithm>
#include<unordered_map>
#include <numeric>
#include<string_view>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(i) i.begin(),i.end()
template<typename T =ll> using v = vector<T>;
template<typename T =ll> using vv = v<v<T>>;
template<typename T =ll,typename U =ll> using p = pair<T,U>;
template<typename T> T chmin(T &a,T b) {return a=min(a,b);}
template<typename T> T chmax(T &a,T b) {return a=max(a,b);}
const ll INF = (ll)1e9;
template <int MOD>
struct ModInt {
    using lint = long long;
    int val;

    // constructor
    ModInt(lint v = 0) : val(v % MOD) {
        if (val < 0) val += MOD;
    };

    // unary operator
    ModInt operator+() const { return ModInt(val); }
    ModInt operator-() const { return ModInt(MOD - val); }
    ModInt inv() const { return this->pow(MOD - 2); }

    // arithmetic
    ModInt operator+(const ModInt& x) const { return ModInt(*this) += x; }
    ModInt operator-(const ModInt& x) const { return ModInt(*this) -= x; }
    ModInt operator*(const ModInt& x) const { return ModInt(*this) *= x; }
    ModInt operator/(const ModInt& x) const { return ModInt(*this) /= x; }
    ModInt pow(lint n) const {
        auto x = ModInt(1);
        auto b = *this;
        while (n > 0) {
            if (n & 1) x *= b;
            n >>= 1;
            b *= b;
        }
        return x;
    }

    // compound assignment
    ModInt& operator+=(const ModInt& x) {
        if ((val += x.val) >= MOD) val -= MOD;
        return *this;
    }
    ModInt& operator-=(const ModInt& x) {
        if ((val -= x.val) < 0) val += MOD;
        return *this;
    }
    ModInt& operator*=(const ModInt& x) {
        val = lint(val) * x.val % MOD;
        return *this;
    }
    ModInt& operator/=(const ModInt& x) { return *this *= x.inv(); }

    // compare
    bool operator==(const ModInt& b) const { return val == b.val; }
    bool operator!=(const ModInt& b) const { return val != b.val; }

    // I/O
    friend std::istream& operator>>(std::istream& is, ModInt& x) noexcept { return is >> x.val; }
    friend std::ostream& operator<<(std::ostream& os, const ModInt& x) noexcept { return os << x.val; }
};

constexpr int MOD = 1e9 + 7;
using mint = ModInt<MOD>;

void b(){
    string s; cin >> s;
    ll cnt =0;
    ll ans = 0;
    rep(i,s.size()){
        if(s[i]=='A') cnt++;
        else if(s[i]=='B'&&s[i+1]=='C'){
            ans+=cnt; i++;
        }else{
            cnt=0;
        }
    }
    cout << ans << endl;
}

int main(void){
    b();
    return 0;
 }

Measured memory_bytes: 3728
#include <vector>
#include <algorithm>
#include <cstddef>

struct strongly_connected_component {
	using size_type = std::size_t;
private : 
	std::vector<std::vector<size_type>> g, revg;
	std::vector<size_type> order, index;
	std::vector<bool> seen;

	void dfs (size_type v) {
		seen[v] = true;
		for (const size_type &u : g[v]) {
			if (not seen[u]) dfs(u);
		}
		order.push_back(v);
	}

	void dfs2 (size_type v, const size_type idx) {
		seen[v] = true; index[v] = idx;
		for (const size_type &u : revg[v]) {
			if (not seen[u]) dfs2(u, idx);
		}
	}

public : 
	strongly_connected_component (size_type n)
	noexcept : g(n), revg(n), index(n), seen(n) { order.reserve(n); }

	void add_edge (size_type u, size_type v) noexcept {
		g[u].push_back(v);
		revg[v].push_back(u);
	}

	size_type solve () noexcept {
		size_type idx = 0;
		order.clear();
		std::fill(seen.begin(), seen.end(), false);
		for (size_type v = 0; v < g.size(); v++) if (not seen[v]) dfs(v);
		std::fill(seen.begin(), seen.end(), false);
		std::reverse(order.begin(), order.end());
		for (const size_type &v : order) if (not seen[v]) dfs2(v, idx++);
		return idx;
	}

	std::vector<std::vector<size_type>> build () noexcept {
		std::vector<int> count(solve());
		std::vector<std::vector<size_type>> tpls(count.size());
		for (size_type i = 0; i < g.size(); i++) count[index[i]]++;
		for (size_type i = 0; i < count.size(); i++) tpls[i].reserve(count[i]);
		for (size_type i = 0; i < g.size(); i++) tpls[index[i]].push_back(i);
		return tpls;
	}

	const size_type &operator[] (size_type v) const noexcept {
		return index[v];
	}

};


#include <iostream>

using usize = std::size_t;

int main() {
	usize n, m;
	std::cin >> n >> m;
	strongly_connected_component scc(n);
	for (usize i = 0; i < m; i++) {
		usize a, b;
		std::cin >> a >> b;
		scc.add_edge(a, b);
	}
	
	auto ans = scc.build();
	std::cout << ans.size() << '\n';
	for (const auto &v : ans) {
		std::cout << v.size();
		for (const auto &e : v) std::cout << ' ' << e;
		std::cout << '\n';
	}
	
	return 0;
}

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

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

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

const int MAX = 2e5 + 10;
int N;
LL A[MAX];

LL calc(LL b) {
    LL ret = 0;
    REP(i, N) ret += llabs(A[i] - (b + i + 1));
    return ret;
}

int main(void) {
    cin >> N;
    REP(i, N) cin >> A[i];
    LL high = 2e9 + 10, low = -high;
    while (high - low > 2) {
        const LL mid1 = (high + low + low) / 3;
        const LL mid2 = (high + high + low) / 3;
        if (calc(mid1) < calc(mid2)) {
            high = mid2;
        } else {
            low = mid1;
        }
    }
    DEBUG(calc(low))
    DEBUG(calc(high))
    LL ans = LLINF;
    for (LL i = low - 10; i <= high + 10; i++) {
        //cerr << i << "  = " << calc(i) << endl;
        chmin(ans, calc(i));
    }
    cout << ans << endl;
}


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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
 
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;
 
const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
 
const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};


void solve(long long x, long long a, long long b){
    if(abs(x-a) < abs(x-b)) cout << "A" << endl;
    else cout << "B" << endl;
}

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


Measured memory_bytes: 256
def resolve():
    '''
    code here
    '''
    import math
    N = int(input())
    sqrt_n = math.sqrt(N)

    B1=10**10
    for i in range(1, int(sqrt_n)+1):
        if N % i == 0:
            B1 = min(B1, N//i)
            
    B2 = N // B1
    print(max(len(str(B1)), len(str(B2))))


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 9160
#include<bits/stdc++.h>
using namespace std; 
int main() {
  int c = 0;
  string s; cin >> s;
  int size = s.size();
  for(int i = 0; i < size; i++) {
    if(s.at(i) == '0') {
      c += 0;
      continue;
    }
    if(s.at(i) == '1') {
      c += 1;
      continue;
    }
    if(s.at(i) == '2') {
      c += 2;
      continue;
    }
    if(s.at(i) == '3') {
      c += 3;
      continue;
    }
    if(s.at(i) == '4') {
      c += 4;
      continue;
    }
    if(s.at(i) == '5') {
      c += 5;
      continue;
    }
    if(s.at(i) == '6') {
      c += 6;
      continue;
    }
    if(s.at(i) == '7') {
      c += 7;
      continue;
    }
    if(s.at(i) == '8') {
      c += 8;
      continue;
    }
    if(s.at(i) == '9') {
      c += 9;
    }
  }
  if(c % 9 == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3736
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long n=sc.nextInt(),sum=0;
    for(long i=1;i<=n;i++) {
    	if(i%3!=0&&i%5!=0)sum+=i;
    }
    System.out.println(sum);
  }
	public static int GCD(int min,int max) {
		if(max%min==0)return min;
		else return GCD(max%min,min);
	}
}

Measured memory_bytes: 35884
#include <bits/stdc++.h>
using namespace std;
 
 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define fill(a)  memset(a, 0, sizeof (a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

void pre(){


}
 
void solve(){
 
 
}

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin.exceptions(cin.failbit);
	pre();

    string s;cin>>s;
    if(s[2]==s[3]&&s[4]==s[5])cout<<"Yes\n";
    else cout<<"No\n";

	return 0;
}
 



Measured memory_bytes: 256
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	x := getNextInt(scanner)
	y := getNextInt(scanner)

	fmt.Fprintln(writer, solve(x, y))
	writer.Flush()
}

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

func solve(x, y int) int {
	ans := absint(absint(y) - absint(x))

	if x < 0 && y < 0 {
		if x > y {
			ans += 2
		}
		return ans
	}
	if x > 0 && y > 0 {
		if x > y {
			ans += 2
		}
		return ans
	}
	if x < 0 && y == 0 {
		return ans
	}
	if x == 0 && y > 0 {
		return ans
	}
	ans++
	return ans
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,d;
  cin >> n >> d;
  if (n/(d*2+1)*(d*2+1)==n) cout <<n/(d*2+1)<< endl;
  else cout <<n/(d*2+1)+1<< endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 100000
int binarySearch(int *,int,int);

main(){
  int i,j,k,l,count=0,a[N],b,c[N],d;
  scanf("%d",&b);
  for(i=0;i<b;i++){
    scanf("%d",&a[i]);
  }

  scanf("%d",&d);
  for(j=0;j<d;j++){
    scanf("%d",&c[j]);
  }

  for(i=0;i<d;i++){
    k = binarySearch(a,c[i],b);
    if(a[k]==c[i])count++;
  } 
  printf("%d\n",count);
  return 0;
}

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

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

    int n;
    cin >> n;
    int odd[MAX] = {};
    int even[MAX] = {};
    rep(i, n){
        int v;
        cin >> v;
        if(i % 2 == 0){
            even[v-1]++;
        }
        else{
            odd[v-1]++;
        }
    }
    int m_odd = 0, m_even = 0; 
    rep(i, MAX){
        if(odd[i] > odd[m_odd]){
            m_odd = i;  
        }
        if(even[i] > even[m_even]){
            m_even = i;  
        }
    }
    sort(odd, odd+MAX);
    sort(even, even+MAX);
    
    if(m_odd != m_even){
        cout << n - (odd[MAX-1] + even[MAX-1]) << endl;
    }
    else{
        cout << n - max(odd[MAX-2] + even[MAX-1], odd[MAX-1] + even[MAX-2]) << endl;
    }
    return 0;
}

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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
#define all(v) v.begin(),v.end()
const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
   
    ll n; cin>>n;
    map<pair<char,ll>,bool> mp;
    rep(i,n){
        char c; ll a;
        cin>>c>>a;
        mp[make_pair(c,a)]=true;
    }
    char im[]={'S','H','C','D'};
    map<char,ll> ans;
    rep(i,4)rep(j,13){
        if(!mp[{im[i],j+1}]) cout<<im[i]<<" "<<j+1<<endl;
    }
    return 0;
}


Measured memory_bytes: 3076
#include<bits/stdc++.h>
#define lint long long int
#define rep(i,n) for(int i=0;i<int(n);i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define arep(i,a,n) for(int i=a;i<n;i++)
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define fill(a,x) fill(a.begin(),a.end(),x)
#define eb(data) emplace_back(data)
#define pb(data) emplace_back(data)
#define mp make_pair
#define ALNUM 26
#define vint vector<int>
#define vlint vector<lint>
#define F first
#define S second
#define ALL(data) data.begin(),data.end()
#define GEts(s) getline(cin,s);
#define UNIQUE(vec) vec.erase(unique(vec.begin(), vec.end()), vec.end())

using namespace std;
template<typename Rast>inline void out(Rast rast){cout<<rast<<"\n";return;}
template<typename Rast>inline void in(Rast& rast){cin>>rast;return;}
template<typename T>istream& operator >> (istream& is, vector<T>& vec){for(T& x: vec) is >> x;return is;}
template<typename First, typename... Rest>void in(First& first, Rest&... rest){cin >> first;in(rest...);return;}
template<typename First, typename... Rest>void out(First first, Rest... rest){cout << first<<" ";out(rest...);return;}
template<typename T>T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template<typename T1,typename T2>bool chmax(T1& a,T2 b){if(a<b){a=b;return true;}else{return false;}}
template<typename T1,typename T2>bool chmin(T1& a,T2 b){if(a>b){a=b;return true;}else{return false;}}
template<typename T>T lcm(T a, T b){return a * b / gcd(a, b);}
static const double pi = 3.141592653589793;
int modpow(int a,int n,int p){if (n==0)return 1%p; if(n==1)return a%p;if(n%2==1)return (a*modpow(a,n-1,p))%p;lint t=modpow(a,n/2,p);return (t*t)%p;}//a^n%p
lint MOD=pow(10,9)+7;
//lint MOD=998244353;
lint inf=pow(2,50);
int intinf=pow(2,30);
/**int dirx[]={1,0};int diry[]={0,1};//*///右、下
/**int dirx[]={0,1,0,-1};int diry[]={-1,0,1,0};//*///四方位
/**int dirx[]={-1,0,1,1,1,0,-1,-1};int diry[]={-1,-1,-1,0,1,1,1,0};//*///八方位


class unionfind{
public:
	vector<int> table;
	void init(int size){
		table.resize(size);
		rep(i,size)table[i]=i;
	};
	int root(int index){
		if(table[index]==index)return index;
		else{
			int hoge=root(table[index]);
			table[index]=hoge;
			return hoge;
		}
	};
	bool same(int x,int y){
		return(root(x)==root(y));
	};
	int marge(int x,int y){
		int yroot=root(y);
		int xroot=root(x);
		if(xroot==yroot)return 0;
		table[yroot]=xroot;
		return 0;
	}
};

int main(){
	cin.tie(0);ios::sync_with_stdio(false);cout<<std::fixed<<std::setprecision(19);
	string s,t;
	in(s,t);
	int ans=intinf;
	int n=int(s.size())-int(t.size());
	rep(i,n+1){
		string subs=s.substr(i,t.size());
		int cou=0;
		rep(j,t.size())if(subs[j]!=t[j])cou++;
		chmin(ans,cou);
	}
	out(ans);
	return 0;
}


Measured memory_bytes: 3664
#include <iostream>

using namespace std;

const int prime[25] = {
    2, 3, 5, 7, 11,
    13, 17, 19, 23, 29,
    31, 37, 41, 43, 47,
    53, 59, 61, 67, 71,
    73, 79, 83, 89, 97};

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

    int cnt[25];
    fill(cnt, cnt + 25, 0);
    for (int n = 1; n <= N; ++n) {
        int m = n;
        for (int i = 0; i < 25; ++i) {
            while (m % prime[i] == 0) {
                ++cnt[i];
                m /= prime[i];
            }
        }
    }
    int ans = 0;
    for (int p = 0; p < 25; ++p) {
        if (cnt[p] >= 74) ++ans;
    }
    for (int p = 0; p < 25; ++p) {
        for (int q = 0; q < 25; ++q) {
            if (p == q) continue;
            if (cnt[p] >= 4 && cnt[q] >= 14) ++ans;
            if (cnt[p] >= 2 && cnt[q] >= 24) ++ans;
        }
    }

    for (int p = 0; p < 25; ++p) {
        for (int q = 0; q < 25; ++q) {
            for (int r = q + 1; r < 25; ++r) {
                if (p == q || r == p) continue;
                if (cnt[p] >= 2 && cnt[q] >= 4 && cnt[r] >= 4) ++ans;
            }
        }
    }

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


Measured memory_bytes: 256
package main

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

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	t, _ := strconv.Atoi(sc.Text())
	return t
}

func main() {
	var N int
	fmt.Scan(&N)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	A := make([]int, N)
	sum := 0
	for i := 0; i < N; i++ {
		A[i] = nextInt(sc)
		sum += A[i]
	}
	// fmt.Println("N", N, "A", A, "sum", sum)
	tsum, cost := 0, 0
	for i := 0; i < N; i++ {
		tsum += A[i]
		if tsum*2 >= sum {
			// 2パターンある
			// 1. tsumを減らして rsumと同じにする
			// 2. rsumを増やして tsumと同じにする
			psum := tsum - A[i]
			rsum := sum - tsum
			// fmt.Printf("psum=%d, A[%d]=%d, rsum=%d\n", psum, i, A[i], rsum)
			cost = min(tsum*2-sum, rsum+A[i]-psum)
			break
		}
	}
	fmt.Println(cost)
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}


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

int main(){
    int n,p[100];
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>p[i];
    }
    int m=0;
    int b=0;
    int g=0;
    sort(p,p+n);
    for(int i=0;i<n;i++){
        if(m==0){
        m++;
         b+=p[i];}
        else if(m==1){
             g+=p[i];
            m--;
        }
    }
    if(g<b){
        std::cout << b-g << std::endl;
    }
    else{
    std::cout << g-b << std::endl;
}
}

Measured memory_bytes: 3596