akhauriyash/Code-Regression huggingface dataset:
from collections import deque
db = ((-1, 0), (-1, -1), (0, -1), (1, -1), (1, 0), (1, 1), (0, 1), (-1, 1))
dw = ((-1, 0), (0, -1), (1, 0), (0, 1))
def make():
    h, w = map(int, raw_input().split())
    if h == w == 0:
        return None
    P = ["."*(w+2)]+["."+raw_input()+"." for i in xrange(h)]+["."*(w+2)]
    deq = deque()
    w += 2; h += 2
    cnt = 0
    used = [[0]*w for i in xrange(h)]
    group = [None]
    for i in xrange(h):
        for j in xrange(w):
            if used[i][j]:
                continue
            cnt += 1
            c = P[i][j]
            dd = dw if c is '.' else db
            used[i][j] = cnt
            tmp = [(j, i)]
            deq.append((j, i))
            while deq:
                x, y = deq.popleft()
                for dx, dy in dd:
                    nx = x + dx; ny = y + dy
                    if 0 <= nx < w and 0 <= ny < h and not used[ny][nx] and P[ny][nx] == c:
                        used[ny][nx] = cnt
                        tmp.append((nx, ny))
                        deq.append((nx, ny))
            group.append(tmp)
    u = set()
    def dfs(num):
        result = []
        for x, y in group[num]:
            for dx, dy in dw:
                nx = x+dx; ny = y+dy
                if 0 <= nx < w and 0 <= ny < h and used[ny][nx] not in u:
                    v = used[ny][nx]
                    u.add(v)
                    result.append(dfs(v))
        return sorted(result)
    return dfs(1)
while 1:
    A = make()
    if not A:
        break
    B = make()
    if A == B:
        print "yes"
    else:
        print "no"

Measured memory_bytes: 15444
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    n, k = LI()
    s = S()
    s[k-1] = s[k-1].lower()
    print("".join(s))

    return

#B
def B():
    s = S()
    a = int("".join(s[:2]))
    b = int("".join(s[2:]))
    if 0 < a <= 12:
        if 0 < b <= 12:
            print("AMBIGUOUS")
        else:
            print("MMYY")
    elif a == 0:
        if 0 < b <= 12:
            print("YYMM")
        else:
            print("NA")
    else:
        if 0 < b <= 12:
            print("YYMM")
        else:
            print("NA")


    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    B()


Measured memory_bytes: 39152
# -*- coding: utf-8 -*-

#############
# Libraries #
#############
import random
import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
import heapq
from collections import defaultdict
from collections import deque
from collections import Counter
from functools import lru_cache

D = int(input().strip())
C = list(map(int,input().split()))
S = [list(map(int, input().split())) for _ in range(D)]

schedule = []

last = [-1 for i in range(26)]
for d in range(D):
  MAX = -10**20
  temp = None
  best_temp_last = None
  for j in range(26):
    temp_last = last[:]
    s = 0
    for i in range(26):
      if i == j:
        temp_last[i] = d
        s += S[d][i]
      else:
        s -= C[i]*(d-temp_last[i])
    if s > MAX:
      MAX = s
      temp = j
      best_temp_last = temp_last[:]
  last = best_temp_last[:]
  schedule.append(temp)
  
score = 0
last = [[-1] for i in range(26)]  

for d in range(D):
  t = schedule[d]
  last[t].append(d)
  score += S[d][t]
  
for i in range(26):
  last[i].append(D)
  for k in range(len(last[i])-1):
    g = last[i][k+1]-last[i][k]-1
    score -= C[i]*g*(g+1)//2

count = 0

while count:
  count -= 1
  prev = score
  d,q = random.choice(range(D)),random.choice(range(26))
  p = schedule[d]
  schedule[d] = q
  score -= S[d][p]
  score += S[d][q]
  
  pos = last[p].index(d)
  score -= C[p]*(last[p][pos]-last[p][pos-1])*(last[p][pos+1]-last[p][pos])
  last[p].remove(d)
  
  pos = bisect.bisect(last[q],d)
  score += C[q]*(d-last[q][pos-1])*(last[q][pos]-d)
  bisect.insort(last[q],d)
  if score<prev:
    score = prev
    bisect.insort(last[p],d)
    last[q].remove(d)
    schedule[d] = p
    
for i in schedule:
  print(i+1)


Measured memory_bytes: 83912
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;cin>>s;
  int k=s.size(),a=0,b=0;
  for(int i=0;i<k;i++){
    if(s.at(i)=='o')a++;
    else b++;
  }
  if(a-b+15-k>0)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, N, money500, money1;
  string op;
  cin >> N >> A;
 
  money500 = N / 500;
  money1 = N % 500;
  
  if (money1 <= A) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define dump(x) cerr << #x << "=" << (x) << endl;
using namespace std;
const int INF = (int)2e9 + 1;
const long long LINF = (long long)9e18 + 1;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, T;
  vector<vector<int>> dp(3005, vector<int>(3005));

  cin >> N >> T;
  vector<pair<int, int>> cooking;

  for (int i = 0; i < N; i++) {
    int A, B;
    cin >> A >> B;
    cooking.push_back(make_pair(A, B));
  }
  cooking.push_back(make_pair(0, 0));

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

  int ans = 0;
  dp[0][0] = 0;

  for (int i = 1; i <= N; i++) {
    for (int j = 0; j < T; j++) {
      dp[i][j] = dp[i - 1][j];
      ans = max(ans, cooking[i].second + dp[i - 1][j]);
      if (j - cooking[i].first >= 0) {
        dp[i][j] =
            max(dp[i][j], dp[i - 1][j - cooking[i].first] + cooking[i].second);
      }
    }
  }

  cout << ans << endl;

  return 0;
}


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


int main(){
	string s,s2;
	cin >> s;
	for(int i=0;i<s.size();i++){
		if(s[i]=='0') s2+='0';
		else if(s[i]=='1') s2+='1';
		else if(s2.size()!=0) s2.erase(s2.end()-1);
	}
	cout << s2 << endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, s, n)    for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define var(type, ...)  type __VA_ARGS__; read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(sz, makeV<T>(initValue, args...));
}

template <class T>
inline istream& operator>> (istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail&... tail) { cin >> head; read(tail...); }

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}

template <class Container>
struct Rev {
    Container &x_;
    inline Rev(Container &x): x_(x) {}
    inline auto begin() { return rbegin(x_); }
    inline auto end() { return rend(x_); }
};
// }}} End Header

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr);

    var(int, N);
    vector<pii> ps(N);
    rep(i, 0, N) {
        var(i64, X, L);
        ps[i] = { X + L, X - L };
    }

    sort(all(ps));
    i64 ans = 0;
    i64 lastR = -LINF;
    for (const auto &e : ps) {
        if (e.second >= lastR) {
            ++ans;
            lastR = e.first;
        }
    }

    print(ans);

    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  int A[20], B[20], C[20];
  cin >> N;
  rep(i, N){
    cin >> A[i];
  }

  rep(j, N){
    cin >> B[j];

  }

  rep(k, N-1){
    cin >> C[k];
  }

  int ans = 0;
  int tmp = 5000;
  rep(i, N){
    ans += B[A[i]-1];
    if (tmp == A[i] - 1) ans += C[tmp-1];
    tmp = A[i];
  }

  cout << ans << endl;

}

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

int n, t, x, l = -1, ans;

int main(){
	scanf("%d%d", &n, &t);
	for(int i = 0; i < n; i++){
		scanf("%d", &x);
		if(l < x){
			l = x + t;
			ans += t;
		}
		else{
			ans += (x + t - l);
			l = x + t;
		}
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 764
#include <iostream>
using namespace std;
typedef long long int lli;

int main(){
    string s;
    cin >> s;
    string ans = "";
    for(int i=0; i<(int)s.length(); i++){
        if(s[i]=='0'){
            ans += '0';
        }else if(s[i]=='1'){
            ans += '1';
        }else if(!ans.empty()){
            ans.pop_back();
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
def makegrid(target=False):
    H,W = map(int,input().split())
    S = [["" for i in range(W+2)]for j in range(H+2)]
    target_xy = []
    for y in range(H):
        line = input()
        for x in range(W):
            S[y+1][x+1] = line[x]
            if line[x] == target:
                target_xy.append([y+1,x+1])
    return H,W,S,target_xy

def getvalue_9(S,y,x): 
    around9 = [None for i in range(9)]      
    idx = 0 
    for h in range(-1,2):
        for w in range(-1,2):
            around9[idx] = S[y+h][x+w]
            idx +=1
    return around9

def getvalue_4(S,y,x):
    around4 = [S[y+1][x],S[y][x-1],S[y][x+1],S[y-1][x]]
    return around4

H,W,S,targets_xy = makegrid(target="#")
ans = "Yes"
for xy in targets_xy:
    around4 = getvalue_4(S,xy[0],xy[1])
    if not ("#" in around4):
        ans = "No"

print(ans)

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

#define Fast ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO freopen("in.txt", "r", stdin)
#define FC freopen("out.txt", "w", stdout)
#define aise cout<<"aise"<<endl
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mp make_pair
#define ll long long
#define all(x) x.begin(), x.end()
#define mset(v, a) memset(v, a, sizeof(v))
#define pll pair< ll, ll >
#define pdd pair< double, double >
#define ff first
#define ss second
#define pi acos(-1.0)
#define mxN 2010
#define inf 1e14
#define MOD 1000000007

int main()
{

    ll a,b;
    string ss;
    cin >> a >> b >> ss;
    bool tf  =1;
    if(ss.size() != a+b+1) tf=0;
    if(ss[a] != '-') tf=0;
    for(ll i = 0; i < ss.size(); i++)
    {

        if(i==a) continue;
        if(!(ss[i] >= '0' && ss[i] <= '9')) tf=0;
    }
    if(tf) cout << "Yes";
    else cout << "No";
}


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

using namespace std;

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

  vector<int> a;
  for(int i = 0; i < n; i++){
    int a_elm;
    std::cin >> a_elm;
    if(a_elm % 2 == 0) a.push_back(a_elm);
  }

  for(int idx = 0; idx < a.size(); idx++){
    if(a[idx] % 3 != 0 && a[idx] % 5 != 0){
      std::cout << "DENIED" << '\n';
      return 0;
    }
  }
  std::cout << "APPROVED" << '\n';

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  switch (n % 10) {
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
      cout << "hon" << endl;
      break;
    case 0:
    case 1:
    case 6:
    case 8:
      cout << "pon" << endl;
      break;
    case 3:
      cout << "bon" << endl;
      break;
  }
}

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

int main()
{
	int a;
	
	
	char op_ ='+';
	int b;
	cin >> a >> op_ >> b;

	switch (op_)
	{
		case '+':

			cout << a + b;

					break;

		case '-':
			cout << a-b;
					break;

		default:
					break;
	}





}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define rep(i, n) FOR(i, 0, n)
using namespace std;
typedef long long ll;

const ll mod = 1e9 + 7;

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

/*-------------------------------------------*/

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

    int n, x[100];
    cin >> n;
    rep(i, n) cin >> x[i];
    ll ans = 1e18;
    FOR(i, 1, 101) {
        ll num = 0;
        rep(j, n) { num += (x[j] - i) * (x[j] - i); }
        chmin(ans, num);
    }
    cout << ans;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  int gcd = (M + N - 1) / N;
  while (gcd >= 1) {
    if (M / gcd * gcd == M) {
      cout << gcd << endl;
      break;
    }
    gcd--;
  }
  // cout << gcd << endl;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
int X[202020],Y[202020];
ll mo=998244353;
vector<int> Xs,Ys;

template<class V, int ME> class BIT {
public:
	V bit[1<<ME];
	V operator()(int e) {if(e<0) return 0;V s=0;e++;while(e) s+=bit[e-1],e-=e&-e; return s;}
	void add(int e,V v) { e++; while(e<=1<<ME) bit[e-1]+=v,e+=e&-e;}
};
BIT<int,20> Lbt,Rbt;
int ev[202020];
ll p2[202020];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	p2[0]=1;
	FOR(i,202010) p2[i+1]=p2[i]*2%mo;
	
	
	cin>>N;
	FOR(i,N) {
		cin>>X[i]>>Y[i];
		Xs.push_back(X[i]);
		Ys.push_back(Y[i]);
	}
	sort(ALL(Xs));
	sort(ALL(Ys));
	Xs.erase(unique(ALL(Xs)),Xs.end());
	Ys.erase(unique(ALL(Ys)),Ys.end());
	
	FOR(i,N) {
		X[i]=lower_bound(ALL(Xs),X[i])-Xs.begin();
		Y[i]=lower_bound(ALL(Ys),Y[i])-Ys.begin();
		ev[X[i]]=Y[i];
		Rbt.add(Y[i],1);
	}
	ll ret=0;
	FOR(i,N) {
		Rbt.add(ev[i],-1);
		int lt,ld,rt,rd;
		FOR(lt,2) FOR(ld,2) FOR(rt,2) FOR(rd,2) {
			ll LT=lt?p2[Lbt(N)-Lbt(ev[i])]-1:1;
			ll LD=ld?p2[Lbt(ev[i])]-1:1;
			ll RT=rt?p2[Rbt(N)-Rbt(ev[i])]-1:1;
			ll RD=rd?p2[Rbt(ev[i])]-1:1;
			int cand=1;
			if((lt&&rd)||(ld&&rt)) cand++;
			(ret+=LT*LD%mo*RD%mo*RT*cand)%=mo;
		}
		
		Lbt.add(ev[i],1);
	}
	cout<<(ret%mo+mo)%mo<<endl;
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 13804
import java.util.Scanner;

public class Main{
	public Main(){
		Scanner sc = new Scanner(System.in);
		
		while(sc.hasNext()){
			String[] str = (sc.nextLine()).split(" ");
			int n = str.length;
			int s = 0;
			double stack[] = new double[n+1];
			int p = 0;
			
			for(int i = 0; i < n; i++){
				if(str[i].equals("+")){
					stack[p-1] = stack[p-1] + stack[p];
					p--;
				} else if(str[i].equals("-")){
					stack[p-1] = stack[p-1] - stack[p];
					p--;
				} else if(str[i].equals("*")){
					stack[p-1] = stack[p-1] * stack[p];
					p--;
				} else if(str[i].equals("/")){
					stack[p-1] = stack[p-1] / stack[p];
					p--;
				} else {
					stack[++p] = Double.parseDouble(str[i]);
				}
			}
			
			System.out.println(String.format("%.6f", stack[p]));
		}
	}
	
	public static void main(String[] args){
		new Main();
	}
}

Measured memory_bytes: 12000
#include<stdio.h>
#include<string.h>
int main(void){
	int l,s=0,t=0,i;
	char m[262144];
	scanf("%s",m);
	l=strlen(m);
	for(i=0;i<l;i++){
		if(m[i]=='S'){
			s++;
		}
		else if(m[i]=='T'){
			if(s){
				s--;
			}
			else{
				t++;
			}
		}
	}
	printf("%d\n",s+t);
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string>
#include <vector>
#include <cstdlib>

using namespace std;

int main(){
    int n, m;
    cin >> n >> m;
    
    int ans = 0;
    if(n >= m){
        ans = 0;
    }else{
        int p[m];
        for(int i = 0; i < m; i++){
            cin >> p[i];
        }
        sort(p, p+m);
        
        int def[m - 1];
        for(int i = 0; i < m - 1; i++){
            def[i] = abs(p[i] - p[i + 1]);
        }
        sort(def, def + (m - 1));
        reverse(def, def + (m - 1));
        
        int sum = 0;
        for(int i = 0; i < n - 1; i++){
            sum += def[i];
        }
        ans = abs(p[0] - p[m - 1]) - sum;
    }
    cout << ans;
}


Measured memory_bytes: 1024
from math import sqrt, ceil

def is_prime(n):
    if n <= 1:
        return False
    if n <= 3:
        return True
    
    if n % 2 == 0 or n % 3 == 0:
        return False
    
    for i in range(5, ceil(sqrt(n))):
        if n % i == 0 or n % (i + 2) == 0:
            return False
    
    return True

def next_prime(N):
    if (N <= 1):
        return 2
    
    prime = N
    found = is_prime(N)

    while(not found):
        prime += 1

        if (is_prime(prime)):
            found = True
    
    return prime

X = int(input())

print(next_prime(X))


Measured memory_bytes: 38384
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
using namespace std;

int main(){
  int N;
  cin>>N;
  int V[N],C[N];
  for(int i=0; i<N; ++i) cin>>V[i];
  for(int i=0; i<N; ++i) cin>>C[i];
  int ans=0;
  for(int i=0; i<N; ++i){
    int a=V[i]-C[i];
    if(a>0) ans+=a;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<utility>
#include<memory>
#include<cmath>
#include<stack>
#include<tuple>
#include<numeric>
#include<cassert>

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define pb push_back
#define DEBUG false

using namespace std;

using ll = long long;
using P = pair<int,int>;

const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll LINF=1LL<<60;
const int MAX_N= 3501;
const ll lmod = 1e9+7;

int main(){
  ll N;
  cin >> N ;
  for(ll n=1;n<MAX_N;n++)
    for(ll h=1;h<MAX_N;h++){
      ll a = N*h*n;
      ll b = 4*h*n-N*n-N*h;
      if(b>0&&(a%b==0)){
        cout << n << " " << h << " " << a/b << endl;
        return 0;
      }
    }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;

int main() {
	string s, t;
	cin >> s >> t;
	int ans = 0;
	for (int i = 0; i < 3; i++) {
		if (s[i] == t[i]) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	public static void main(String args[]) throws Exception {
		MyScanner sc = new MyScanner();
		PrintWriter pr = new PrintWriter(System.out);
		int a = sc.nextInt();
		int b = sc.nextInt();
		pr.println(a * b);

		pr.close();
	}

	public static class MyScanner {
		BufferedReader br;
		StringTokenizer st;

		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}
}


Measured memory_bytes: 32804
import java.util.Arrays;
import java.util.Scanner;
public class Main {
public static void main(String[]srgs) {
	Scanner scan=new Scanner(System.in);
	int a=scan.nextInt();
	long c[]=new long[a+1];
	long count=0;
	for(int i=1;i!=a+1;i++) {
		int b=scan.nextInt();
		count+=b;
		c[i]=count;
	}
	Arrays.sort(c);
	long co=0;
	for(int i=0;i!=a+1;i++) {
	}
	count=0;
	for(int i=0;i!=a;i++) {
		co++;
		if(c[i]!=c[i+1]) {
			count+=co*(co-1)/2;
			co=0;
		}
	}
	count+=(co+1)*(co)/2;
	System.out.println(count);
	}
}

Measured memory_bytes: 81036
#include <iostream>

using namespace std;

int main() {
  char c[2][3];
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> c[i][j];
    }
  }

  if (c[0][0] == c[1][2] && c[0][1] == c[1][1] && c[0][2] == c[1][0])
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 384
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define pii pair<int, int>
#define pll pair<long long, long long>
const double PI = acos(-1);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    int a = N/25;
    N %= 25;
    int b = N/10;
    N %= 10;
    int c = N/5;
    N %= 5;
    cout << a+b+c+N << endl;
}


Measured memory_bytes: 3216
arr = 3.times.map{gets.chomp.split.map(&:to_i)}
N = gets.to_i
B = N.times.map{gets.to_i}

B.each do |b|
    3.times do |y|
        3.times do |x|
            if arr[y][x] == b
                arr[y][x] = -1 
            end
        end
    end
end

flag = false
arr2 = arr.transpose
3.times do |i|
    flag = true if arr[i].select{|num| num == -1}.length == 3
    flag = true if arr2[i].select{|num| num == -1}.length == 3
end

flag = true if arr[0][0] == arr[1][1] && arr[1][1] == arr[2][2] && arr[1][1] == -1
flag = true if arr[0][2] == arr[1][1] && arr[1][1] == arr[2][0] && arr[1][1] == -1

puts (flag ? 'Yes' : 'No')

Measured memory_bytes: 1788
n,m=map(int,input().split())
l=[list(map(int,input().split()))for i in range(m)]
dist=[[1<<29]*n for i in range(n)]
for i in range(n): dist[i][i]=0
for a in l:
  dist[a[0]-1][a[1]-1] = min(dist[a[0]-1][a[1]-1],a[2])
  dist[a[1]-1][a[0]-1] = min(dist[a[1]-1][a[0]-1],a[2])
# print(dist)
for k in range(n):
  for i in range(n):
    for j in range(n):
      dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])
# 経路復元
ans=m
for a in l:
  flag=False
  for j in range(n): 
    if dist[j][a[0]-1]+a[2]==dist[j][a[1]-1]: flag=True
  if flag: ans-=1
print(ans)


Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int L,R,d;cin>>L>>R>>d;
    int i=1;
    int count=0;
    while(d*i<=R){
        if(d*i>=L){
            count++;
        }
        i++;
    }
    cout<<count<<endl;
}


Measured memory_bytes: 3592
from math import ceil, cos
N,K=map(int,input().split())
A=list(map(int,input().split()))
F=list(map(int,input().split()))
A.sort()
F.sort(reverse=True)
sum_A = sum(A)
if K >= sum_A:
    print(0)
    exit()
AFC = [(A[i], F[i], A[i]*F[i]) for i in range(N)]
AFC.sort(key=lambda x: x[2])

def is_ok(x):
    rest = K
    #最大コストをx以下にできるか
    for i in range(N):
        a, f, cost = AFC[i]
        if cost <= x:
            continue
        need = ceil((cost - x)/f)
        rest -= need
    if rest >= 0:
        return True
    else:
        return False

left = 0
right = 10**12 + 100

while right-left > 1:
    mid = (left + right)//2
    res = is_ok(mid)
    if res:
        right = mid
    else:
        left = mid
print(right)

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


int main()
{
	int A, B, C, X, Y;
	cin >> A >> B >> C >> X >> Y;

	int ans = X*A + Y*B;

	for (int a = 0; a <= X; a++) {
		int ac = (X - a) * 2;

		int bmin = 0;
		int bmax = max(0, Y-ac/2);

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

			int b[4] = {bmin, (bmin*2+bmax*1)/3, (bmin*1+bmax*2)/3, bmax};
			int price[4];
			for (int i = 0; i < 4; i++) {
				int c = max(ac, (Y-b[i])*2);
				price[i] = a*A+b[i]*B+c*C;
				ans = min(ans, price[i]);
			}

			if (price[0] < price[1]) {
				break;
			} else if (price[1] < price[2]){
				bmin = b[0];
				bmax = b[2];
			} else if (price[2] < price[3]) {
				bmin = b[1];
				bmax = b[3];
			} else {
				break;
			}
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
typedef long long ll;

int main(void) {
  ll i, j, k, num[10] = {0, 1, 2, 3, 4, 5, 5, 4, 3, 2}, ans = 0;
  char n[1000010];
  bool b = false;
  scanf("%s", n);
  for(i = 0; n[i]; ++i) {
    if(n[i] > '4') {
      if(n[i] > '5') {
        if(b) ans += num[n[i] - '0'] - 2;
        else ans += num[n[i] - '0'];
        b = true;
      } else {
        if(b) ans += 4;
        else if(n[i + 1] > '4') ans += 6, b = true;
        else ans += 5;
      }
    } else if(b && n[i] > '3') {
      if(n[i + 1] > '4') ans += 5;
      else ans += 4, b = false;
    } else ans += num[n[i] - '0'], b = false;
  }
  printf("%lld", ans);
  return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define forinc(i,a,b) for(int i=a;i<=b;++i)
#define fordec(i,a,b) for(int i=a;i>=b;--i)
#define forv(i,x) for(auto &i:x)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rnd(int l,int r)
{
    return l+rng()%(r-l+1);
}
#define in ({int x=0;int c=getchar(),n=0;for(;!isdigit(c);c=getchar()) n=(c=='-');for(;isdigit(c);c=getchar()) x=x*10+c-'0';n?-x:x;})
#define pii pair<int,int>
#define fi first
#define se second
#define batbit(i,x) (x|(1ll<<i))
#define getbit(i,x) ((x>>i)&1)

const int mn=5e5+5;
string s;
int n,r[mn],l[mn];
queue<int> q;

main()
{
//    memset(dd,-1,sizeof dd);
    cin >> s;
    n=s.size();
    s=' '+s;
    int cnt=0;
    fordec(i,n,1)
    {
        if(s[i]=='>') cnt++;
        else cnt=0;
        r[i]=cnt;
    }
    cnt=0;
    forinc(i,2,n+1)
    {
        if(s[i-1]=='<') cnt++;
        else cnt=0;
        l[i]=cnt;
    }
    int res=0;
    forinc(i,1,n+1)
    {
        res+=max(l[i],r[i]);
    }
    cout << res;
}


Measured memory_bytes: 8728
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kein Yukiyoshi
 */

#include "bits/stdc++.h"
#define int long long
#define rep(i, n)           for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b)        for (int i = (int)(a); i < (int)(b); i++)
#define FOR(i, a)           for (auto &i : a)
#define ALL(obj)            begin(obj), end(obj)
#define MAX(x)              *max_element(ALL(x))
#define MIN(x)              *min_element(ALL(x))
#define SUM(x)              accumulate(ALL(x), 0LL)
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))

using namespace std;
const int MOD    = (int)(1e9 + 7);
const int INF    = (int)(1e13 + 7);
const double EPS = 1e-14;
const double PI  = acos(-1);

int CEIL(int a, int b) { return (a >= 0 ? (a + (b - 1)) / b : (a - (b - 1)) / b); } //ceil() for int
int mod(int a, int b) { return a >= 0 ? a % b : a - (b * CEIL(a, b)); }             //always return positive num
int bpm(int a, int b) {                                                             //return x^y in order(log(y))
  int res = 1;
  for (a %= MOD; b; a = a * a % MOD, b >>= 1)
    if (b & 1) res = res * a % MOD;
  return res;
}

class DRoadToMillionaire {
public:
  static void solve(istream &cin, ostream &cout) {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    vector<int> ans;
    int a = 1;
    rep(i, N - 1) {
      if (a) {
        if (A[i] <= A[i + 1]) {
          ans.emplace_back(A[i]);
          a = 0;
        }
      } else {
        if (A[i] >= A[i + 1]) {
          ans.emplace_back(A[i]);
          a = 1;
        }
      }
    }
    if (not a and A[N - 1] >= A[N - 2]) {
      ans.emplace_back(A[N - 1]);
    }
    int now_mon  = 1000;
    int now_kabu = 0;
    if (ans.size() % 2) {
      ans.pop_back();
    }
    rep(i, ans.size()) {
      if (i % 2 == 0) {
        now_kabu = now_mon / ans[i];
        now_mon -= now_kabu * ans[i];
      } else {
        now_mon += now_kabu * ans[i];
      }
    }
    cout << now_mon << endl;
  }
};


signed main() {
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
  DRoadToMillionaire solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val
using namespace std;
using namespace __gnu_pbds;

#define sp << " " <<
#define mod 1000000007
#define PI 3.14159265358979323
#define y second
#define x first
#define pb push_back
#define mp make_pair
#define mem(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pqueue priority_queue< ll >
//#define pdqueue priority_queue< ll,vector<ll> ,greater< ll > >
#define codejamDebug(x) cout<<"Case #"<<x<<": ";
#define debug(x) cout<<#x<<" :"<<x<<endl;
#define rep(i,n) for(long long i=0;i<n;i++)
#define f(i,a,b) for(long long i = a; i < b; i++)
#define fd(i,a,b) for(long long i = a; i >=b; i--)
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef long long int           ll;
typedef long double             ld;
typedef unsigned long long int ull;
typedef vector <int>            vi;
typedef vector <ll>            vll;
typedef pair <int, int>        pii;
typedef pair <ll, ll>          pll;
typedef vector < pii >        vpii;
typedef vector < pll >        vpll;
typedef vector <string>         vs;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

//Handle:cyber_rajat

int main(int argc, char const *argv[])
{
	sync;
	ll n;
	cin >> n;
	map<ll,ll> my;
	for(ll i = 1; i*i <= n; i++){
		for(ll j = 1; j*j <= n; j++){
			for(ll k = 1; k *k <= n; k++){
				ll val = i*i + j*j + k*k + i*j + j*k + k*i;
				my[val]++;
			}
		}
	}
	for(ll i = 1; i <= n; i++){
		cout << my[i] << endl;
	}
	return 0;
}


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

int main() {
    #ifdef DEBUG
        freopen("in.txt", "r", stdin);
    #endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

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

    return 0;
}


Measured memory_bytes: 3636
using System;
using System.Linq;

namespace abc133_b
{
    class Program
    {
        static void Main(string[] args)
        {
            var items = Console.ReadLine().Split(' ');
            var n = int.Parse(items[0]);
            var d = int.Parse(items[1]);
            var x = new int[n][];
            for (int ni = 0; ni < n; ni++)
            {
                x[ni] = Console.ReadLine().Split(' ').Select(m => int.Parse(m)).ToArray();
            }

            var count = 0;
            for (int ni = 0; ni < n; ni++)
            {
                for (int i = ni + 1; i < n; i++)
                {
                    var distance = Distance(d, x[ni], x[i]);
                    if (distance - Math.Floor(distance) == 0.0)
                    {
                        count++;
                    }
                }
            }
            Console.WriteLine($"{count}");
        }
        static double Distance(int d, int[] y, int[] z)
        {
            var ans = 0.0;
            for (int i = 0; i < d; i++)
            {
                ans += Math.Pow(y[i] - z[i], 2);
            }
            return Math.Sqrt(ans);
        }
    }
}


Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
int line[110][110],col[110][110];
short dp[101][101][101][101];
int main()
{
	int n,m,x,y;scanf("%d%d\n",&n,&m);
	for (int i=1;i<=n;i++)
	for (int j=1;j<=m;j++)
	{
		line[i][j]=line[i][j-1];col[i][j]=col[i-1][j];
		char ch=getchar();
		if (ch=='E') {x=i;y=j;}
		else if (ch=='o') {line[i][j]++;col[i][j]++;}
		if (j==m) scanf("\n");
	}
	
	int all=0;
	for (int i=x;i>=1;i--)
	for (int j=y;j>=1;j--)
	for (int k=x;k<=n;k++)
	for (int l=y;l<=m;l++)
	{
		all=max(all,(int)dp[i][j][k][l]);
		if ((1<i)&&(k+1<x+i)) dp[i-1][j][k][l]=max((int)dp[i-1][j][k][l],dp[i][j][k][l]+line[i-1][min(l,m-y+j)]-line[i-1][max(j-1,l-y)]);
		if ((k<n)&&(x+k<n+i)) dp[i][j][k+1][l]=max((int)dp[i][j][k+1][l],dp[i][j][k][l]+line[k+1][min(l,m-y+j)]-line[k+1][max(j-1,l-y)]);
		if ((1<j)&&(l+1<y+j)) dp[i][j-1][k][l]=max((int)dp[i][j-1][k][l],dp[i][j][k][l]+col[min(k,n-x+i)][j-1]-col[max(i-1,k-x)][j-1]);
		if ((l<m)&&(y+l<m+j)) dp[i][j][k][l+1]=max((int)dp[i][j][k][l+1],dp[i][j][k][l]+col[min(k,n-x+i)][l+1]-col[max(i-1,k-x)][l+1]);
	}
	cout<<all<<endl;
}

Measured memory_bytes: 201216
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
	int n,k;cin >> n >> k;
	cout << n-k+1 << endl;
	return 0;
}

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

int main() {
    int H, W; cin >> H >> W;
    vector<vector<int>> li(H, vector<int>(W, 1));
    for (int i = 0; i < H; i++)
    {
        string s;
        cin >> s;
        for (int j = 0; j < W; j++)
        {
            if(s[j] == '#') li[i][j] = 0;
        }
    }

    vector<vector<int>> L(H, vector<int>(W, 0)), R(H, vector<int>(W, 0)), D(H, vector<int>(W, 0)), U(H, vector<int>(W, 0));
    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            if(li[i][j] == 0) L[i][j] = 0;
            else if(j == 0) L[i][j] = 1;
            else L[i][j] = L[i][j-1] + 1;
        }
        for (int j = W - 1; j >= 0; j--)
        {
            if(li[i][j] == 0) R[i][j] = 0;
            else if(j == W-1) R[i][j] = 1;
            else R[i][j] = R[i][j+1] + 1;
        }
    }

    for (int i = 0; i < W; i++)
    {
        for (int j = 0; j < H; j++)
        {
            if(li[j][i] == 0) U[j][i] = 0;
            else if(j == 0) U[j][i] = 1;
            else U[j][i] = U[j-1][i] + 1;
        }
        for (int j = H - 1; j >= 0; j--)
        {
            if(li[j][i] == 0) D[j][i] = 0;
            else if(j == H-1) D[j][i] = 1;
            else D[j][i] = D[j+1][i] + 1;
        }
    }

    int ans;
    ans = 0;
    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            ans = max(ans, L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 78720
def check(m,d):
    flg = False
    if d//10>=2 and d%10>=2:
        if (d//10)*(d%10)==m:
            flg = True
    return flg

def main():
    m,d = map(int,input().split())
    ans = 0

    for i in range(1,m+1):
        for j in range(1,d+1):
           
            ans += check(i,j)
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 39408
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
typedef pair<int, int> P;

int main(){
  int N;
  while(cin >> N && N){
    vector<P> v(N);
    REP(i, N) {
      int a, t;
      cin >> a >> t;
      v[i] = P(-t, a);
    }
    sort(v.begin(), v.end());
    printf("%d %d\n", v[0].second, -v[0].first);
  }
  return 0;
}

Measured memory_bytes: 1180
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int x[5];
    rep(i,5) cin>>x[i];
    rep(i,5) if(x[i]==0) cout<<i+1;
}

Measured memory_bytes: 3592
s = input()
op_cnt = len(s) - 1
ans = []
for i in range(2**op_cnt):
    op = ['']*op_cnt
    for j in range(op_cnt):
        if ((i >> j) & 1):
            op[op_cnt - 1 - j] = '+'
    f = s[0]
    for p, q in zip(op, s[1:]):
        f += p + q
    ans.append(f)
sums = 0
for i in ans:
    sums += eval(i)
print(sums)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

#define ALL(v) (v).begin(),(v).end()

using namespace std ;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;




int main()
{
  int x ;
  cin >> x  ;
  
  if(x%2==0){
    cout << x <<endl ;
  }
  else{
    cout <<2*x<<endl ;
  }
    
    return 0 ;
}

/*　吾輩はやれば出来る子である。 
　　　　∩∩ 
　　　（´･ω･） 
　　 ＿|　⊃／(＿＿_ 
　／　└-(＿＿＿_／ 
　￣￣￣￣￣￣￣ 
　やる気はまだない 

　　 ⊂⌒／ヽ-、＿_ 
　／⊂_/＿＿＿＿ ／ 
　￣￣￣￣￣￣￣　　*/

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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}


int main() {
  int N, K;
  cin >> N >> K;
  double ret = 0;
  for(int i = 1; i <= N; i++) {
    int now = i;
    double add = 1.0;
    while(now < K) {
      now *= 2;
      add *= 0.5;
    }
    ret += (1.0 / N) * add;
  }
  cout << ret << endl;
}




Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.StringTokenizer;

public class Main {
	private static int counter = 0;
	private static int upperOrder = 0;
	private static int lowerOrder = 0;
	
	private static final int MOD = (int)Math.pow(10, 9);
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		int n = sc.nextInt();
		long[] nums = new long[100001];
		long sum = 0;
		
		for (int i = 0; i < n; i++) {
			int num = sc.nextInt();
			nums[num]++;
			sum += num;
		}
		
		int q = sc.nextInt();
		
		for (int i = 0; i < q; i++) {
			int b = sc.nextInt();
			int c = sc.nextInt();
			sum = (sum - nums[b]*b + nums[b]*c);
			nums[c] += nums[b];
			nums[b] = 0;
			
			
			System.out.println(sum);
		}
		System.exit(0);
	}
	
	public static void permuteHelper(int[] nums, int start, int end, List<String> ans) {
        if (start == end) {
            String str = "";
            for (int num: nums) {
                str += ("" + num);
            }
            ans.add(str);
        } else {
            for (int i = start; i < end; i++) {
                swap(nums, i, start);
                permuteHelper(nums, start + 1, end, ans);
                swap(nums, i, start);
            }
        }
    }
	
	static public void swap(int[] nums, int i, int j) {
        int tmp = nums[i];
        nums[i] = nums[j];
        nums[j] = tmp;
    }
	
	static boolean isEqual(int[] a, int[] b) {
		for (int i = 0; i < a.length; i++) {
			if (a[i] != b[i]) {
				return false;
			}
		}
		return true;
	}
	
	static class FastReader {
	    BufferedReader br;
	    StringTokenizer st;
	
	    public FastReader() {
	      br = new BufferedReader(new InputStreamReader(System.in));
	    }
	  
	    String next() { 
	      while (st == null || !st.hasMoreElements()) {
	        try {
	          st = new StringTokenizer(br.readLine());
	        } catch (IOException  e) {
	          e.printStackTrace();
	        }
	      }
	      return st.nextToken();
	    }
	
	    int nextInt() {
	      return Integer.parseInt(next());
	    }
	
	    long nextLong() {
	      return Long.parseLong(next());
	    }
	
	    double nextDouble() { 
	      return Double.parseDouble(next());
	    }
	
	    String nextLine() {
	      String str = "";
	        try{
	            str = br.readLine();
	        } catch (IOException e) {
	            e.printStackTrace();
	        }
	        return str;
	      }
	  }
}


Measured memory_bytes: 58008
#include <iostream>
using namespace std;
#define v long long
bool check = true;
v bins (v b[], v time, v n) {
    v l = 0, r = n, m;
    while (r > l + 1) {
        m = (l + r) / 2;
        //cout << m << ' ';
        if (b[m] < time) {
            l = m;
        }
        else if (b[m] > time) {
            r = m;
        }
        else {
            return m;
        }
        //cout << b[m] << ' ' << l << ' ' << r << endl;
    }
    m = (l + r) / 2;
    //cout << m << ' ' << b[m] << ' ' << time << endl;
    if (b[m] > time) {
        check = false;
        return 0;
    }
    return m;
}
int main () {
    v m, n, k;
    scanf ("%lld %lld %lld", &m, &n, &k);
    v a[m], b[n];
    for (v i = 0; i < m; i++) {
        scanf ("%lld", &a[i]);
        if (i > 0) {
            a[i] += a[i - 1];
        }
    }
    for (v i = 0; i < n; i++) {
        scanf ("%lld", &b[i]);
        if (i > 0) {
            b[i] += b[i - 1];
        }
    }
    v max_books = 0;
    for (v x = 0; x <= m; x++) {
        v time_for_first;
        if (x == 0) {
            time_for_first = 0;
        }
        else if (a[x - 1] > k) {
            break;
        }
        else {
            time_for_first = a[x - 1];
            //cout << time_for_first << ' ';
        }
        v remaining_time = k - time_for_first;
        //cout << remaining_time << endl;
        v y = bins (b, remaining_time, n);
        if (check) {
            y++;
        }
        else {
            check = true;
        }
        //cout << x << ' ' << y << endl;
        if (x + y > max_books) {
            max_books = x + y;
        }
        //cout << endl;
    }
    printf ("%lld\n", max_books);
    return 0;
}

Measured memory_bytes: 6944