akhauriyash/Code-Regression huggingface dataset:
import Queue

N = int(raw_input())
tree = [[] for _ in xrange(N)]

for i in range(N-1):
    a, b, c = map(int, raw_input().split())
    a -= 1; b -= 1;
    tree[a].append((b, c))
    tree[b].append((a, c))

Q, K = map(int, raw_input().split())
K -= 1

d = [float("inf") for _ in xrange(N)]

def dijkstra(s):
    que = Queue.PriorityQueue()
    d[s] = 0
    que.put([0, s])

    while not que.empty():
        p = que.get()
        v = p[1]
        if d[v] < p[0]:
            continue
        for i, j in tree[v]:
            if d[i] > d[v] + j:
                d[i] = d[v] + j
                que.put([d[i], i])

dijkstra(K)

for i in range(Q):
    x, y = map(int, raw_input().split())
    x -= 1; y -= 1
    print d[x] + d[y]


Measured memory_bytes: 53020
#include <iostream>
#include <cstdio>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <stdlib.h>
#include <functional>
#include <string>
#include <list>
#include <fstream>
#include <iomanip>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <chrono>
#include <bitset>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int

#include <nmmintrin.h>
#ifdef _MSC_VER

#define __builtin_popcount _mm_popcnt_u32
#define __builtin_popcountll _mm_popcnt_u64
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}



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

	vector<int> num(n);
	vector<array<int, 20>> cou(n + 1);
	
	REP(i, n) {
		scanf("%d", &num[i]);

		REP(j, 20) {
			cou[i + 1][j] = bitcheck(num[i], j) + cou[i][j];
		}
	}


	ll ans = 0;

	REP(i, n) {

		ll Min = INT_MAX;

		REP(j, 20) {
			int l = i, r = n + 1;

			while (r - l > 1) {
				int mid = (l + r) / 2;

				int cu = 0;

				cu = cou[mid][j] - cou[i][j];

				if (cu >= 2) r = mid;
				else l = mid;

			}

			Min = min(Min, 1LL*r);

		}

		ans += Min-i-1;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 16768
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007
#define pi 3.141592653589793
typedef vector<int> vi;
typedef vector<ll> vl;
ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t=rep_jijo(n,x/2);
        return t*t%mod;
    }
    return n*rep_jijo(n,x-1)%mod;
}
ll com(ll n,ll r){
    ll x=1,y=1;
    ll tmp=n;
    while(tmp>=n-r+1){
        x=x*tmp%mod;
        tmp--;
    }
    while(r>0){
        y=y*r%mod;
        r--;
    }
    return x*rep_jijo(y,mod-2)%mod;
}


int main (){
    int h,n;
    cin >> h >> n;
    vi a(n);vi b(n);
    rep(i,n) cin >> a[i] >> b[i];
    vi hp(h+1,inf); 
    hp[0]=0;
    rep(i,n){
        rep(j,h){
            int nx=min(j+a[i],h);
            hp[nx]=min(hp[nx],hp[j]+b[i]);
        }
    }
    cout << hp[h] <<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int ms = 2e5+9;
int cut[ms];
vector<int> vet[ms];
vector<int> s;

int main(){
	int n,a,b,m,cont = 0;
	cin >> n >> m;
	for(int i = 1;i<=m;i++){
		cin >> a >> b;
		vet[a].push_back(i);
		vet[b].push_back(-i);
	}
	
	for(int i = 1;i<=n;i++){
		bool f = 0;
		vector<int> s2;
		for(int j = 0;j<vet[i].size();j++){
			int id = vet[i][j];
			if(id < 0 and f){
				cut[-id] = 1;
			}else if(!f and id < 0 and !cut[-id]){
				cont++;
				f = 1;
				cut[-id] = 1;
				while(s.size()){
					cut[s.back()] = 1;
					s.pop_back();
				}	
				
			}else if(id >=0)
				s2.push_back(id);
		}
		while(s2.size()){
			s.push_back(s2.back());
			s2.pop_back();
		}
	
	}
	cout<<cont;

}

Measured memory_bytes: 8956
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    vector<ll>a(5);
    ll sum=0;
    ll mn = 10;
    rep(i,5){
        cin>>a[i];
        ll p = a[i]%10;
        if(p==0){
            sum+=a[i];
            p=10;
        }else{
            sum+=a[i]+10-p;
        }
        chmin(mn,p);
        
    }
    
    cout << sum-10+mn << endl;


    return 0;
    

}

Measured memory_bytes: 3604
# https://atcoder.jp/contests/abc138/tasks/abc138_d
# 4 3
# 1 2
# 2 3
# 2 4
# 2 10
# 1 100
# 3 1
# 100 110 111 110
# N Q
# Ai Bi
# ...
# An Bn
# Pj Xj
# ..
# Pq X q
# p以下に値を加える
# 1が頂点

n, q = gets.chomp.split.map(&:to_i)
tree = Array.new(n) { [] }

(n - 1).times do
  a, b = gets.chomp.split.map { |v| v.to_i - 1 }
  tree[a] << b
  tree[b] << a
end
points = Array.new(n, 0)
q.times do
  p, x = gets.chomp.split.map(&:to_i)
  points[p - 1] += x
end
queue = [0]
al = {}
while curr = queue.shift
  al[curr] = true
  tree[curr].each do |ch|
    next if al[ch]
    queue << ch
    points[ch] += points[curr]
  end
end
puts points.join(' ')


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

int main(){
    int x[5],ans;
    lp(i,5){
        cin>>x[i];
        if(x[i]==0)
            ans=i+1;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3620
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());
		PrimeNumberGenerator png = new PrimeNumberGenerator();
		
		int start = 0;
//		if(n % 2 == 0){
//			start = 3;
//		}
//		else {
//			start = 2;
//		}
		
		start = 11;
		
		int count = 0;
		for(int i = start ; i <= 55555; i+= 5){
			if(png.isPrime(i)){
				System.out.print(i);
				count++;
				
				if(count == n){
					break;
				}
				else {
					System.out.print(" ");
				}
			}
		}
		System.out.println();
	}

}


class PrimeNumberGenerator {
    private boolean[] isPrime= new boolean[10000001];
 
    public PrimeNumberGenerator() {
        //Date from = new Date();
        Arrays.fill(isPrime, true);
 
        isPrime[0] = false;
        isPrime[1] = false;
        isPrime[2] = true;
 
        for(int i = 3; i <= Math.sqrt( isPrime.length ); i+=2){
            /*
            if(i % 2 == 0){
                isPrime[i] = false;
                continue;
            }
            */
 
            if(isPrime[i] == false){
                continue;
            }
 
            for(int j = i * 2; j <= isPrime.length - 1; j += i){
                isPrime[j] = false;
            }
        }
        //Date to = new Date();
        //System.out.println("init takes "+ (to.getTime() - from.getTime())+ "milli sec");
    }
 
    public boolean isPrime(int index){
        if(index % 2 == 0 && index != 2){
            return false;
        }
        return isPrime[index];
    }
}

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

#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define fore(i, l, r) for (int i = (int)(l); i <= (int)(r); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvl;
typedef pair<int, int> pint;
typedef vector<pint> vpint;
typedef long double ld;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout << fixed;
  int A, B;
  cin >> A >> B;
  int C;
  if (A > B) C = A--;
  else C = B--;
  C += max(A, B);
  cout << C << endl;
  return 0;
}


Measured memory_bytes: 256
from collections import deque

def main():
    N = int(input())
    edge = [[] for _ in range(N)]
    for i in range(N-1):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        edge[a].append(b)
        edge[b].append(a)
    C = list(map(int, input().split()))
    C.sort(reverse=True)
    ans = [0] * N
    Q = deque([0])
    cnt = 0
    ans[0] = C[0]
    while Q:
        s = Q.pop()
        for v in edge[s]:
            if ans[v]:
                continue
            cnt += 1
            ans[v] = C[cnt]
            Q.append(v)

    print(sum(C) - max(C))
    print(*ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 51288
#include<iostream>
using namespace std;
int main() {
	int n;
	cin >> n;
	int a[n];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int swapCount = 0;
	for (int i = 0; i < n; i++) {
		int mini = i;
		for (int j = i; j < n; j++){
			if (a[j] < a[mini]) mini = j;
		}
		if (mini != i) {
			int tmp = a[i];
			a[i] = a[mini];
			a[mini] = tmp;
			swapCount++;
		}
	}
	for (int i = 0; i < n - 1; i++) {
		cout << a[i] << ' ';
	}
	cout << a[n - 1] << '\n' << swapCount << '\n';
}


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

int main() {
  int n;
  cin >> n;
  vector<int> S(n);
  rep(i, n) {
    cin >> S[i];
  }
  int q;
  cin >> q;
  vector<int> T(q);
  rep(i, q) {
    cin >> T[i];
  }
  int ans = 0;
  rep (i, q) {
    int L = -1;
    int U = n;
    while (U - L > 1) {
      int x = (L + U) / 2;
      if (S[x] == T[i]) {
        ans++;
        break;
      }
      else if (S[x] > T[i]) {
        U = x;
      }
      else {
        L = x;
      }
    }
  }
  cout << ans <<endl;
}





Measured memory_bytes: 3276
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
string s,t;
ll L,LL,tot;
vector<ll> a[26],v;
int main(void){
    cin>>s>>t;
    L=0;
    for(int i=0;i<s.size();i++){
        a[s[i]-'a'].push_back(i+1);
    }
    for(int i=0;i<t.size();i++){
        if(a[t[i]-'a'].size()==0){cout<<-1<<endl;return 0;}
        LL=upper_bound(a[t[i]-'a'].begin(),a[t[i]-'a'].end(),L)-a[t[i]-'a'].begin();
        if(LL==a[t[i]-'a'].size())L=a[t[i]-'a'][0];
        else L=a[t[i]-'a'][LL];
        v.push_back(L);
    }
    L=0;
    for(ll x:v){
        if(L==x)tot+=s.size();
        if(L<x)L=x;
        if(L>x){tot+=s.size();L=x;}
    }
    cout<<tot+L<<endl;
}


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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string data = Console.ReadLine(); 
            Dice dice = new Dice(data);

            string direction = Console.ReadLine();
            for (int i = 0; i < direction.Length; i++)
            {
                if (direction[i] == 'N')
                {
                    dice.RollingDirectN();
                }
                else if (direction[i] == 'E')
                {
                    dice.RollingDirectE();
                }
                else if (direction[i] == 'W')
                {
                    dice.RollingDirectW();
                }
                else
                {
                    dice.RollingDirectS();
                }
            }

            dice.TopNumber();
        }
    }

    class Dice
    {
        private int[] number = null;

        public Dice(string data)
        {
            number = data.Split(' ').Select(s => int.Parse(s)).ToArray();
        }

        public void RollingDirectN()
        {
            int temp = number[0];
            number[0] = number[1];
            number[1] = number[5];
            number[5] = number[4];
            number[4] = temp;
        }

        public void RollingDirectE()
        {
            int temp = number[0];
            number[0] = number[3];
            number[3] = number[5];
            number[5] = number[2];
            number[2] = temp;
        }

        public void RollingDirectW()
        {
            int temp = number[0];
            number[0] = number[2];
            number[2] = number[5];
            number[5] = number[3];
            number[3] = temp;
        }

        public void RollingDirectS()
        {
            int temp = number[0];
            number[0] = number[4];
            number[4] = number[5];
            number[5] = number[1];
            number[1] = temp;
        }

        public void TopNumber()
        {
            Console.WriteLine(number[0]);
        }
    }
}

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

int main() {
  int n,m,x;
  cin >>n>>m>>x;
  int sum1=0;
  int sum2=0;
  for(int i=1;i<=m;i++){
    int a;
    cin>>a;
    if(a>=1&&a<x)sum1++;
    if(a>x&&a<n)sum2++;
  }  
  cout<<min(sum1,sum2)<<endl; 
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <map>
#include <algorithm>
#include <cmath>
#include <vector>
#include <fstream>
#include <string>
#include <random>
#include <queue>
#include <iomanip>

using namespace std;

using ll = unsigned long long int;
using pii = pair<int, int>;

vector<pii> vec[100010] = {};
ll result[100010] = {};
bool flag[100010] = {};

void solve(int k,int i,ll c) {

	if (!flag[i]) {
		flag[i] = true;
		result[i] = c;

		for (auto v : vec[i]) {
			solve(k,v.first,v.second+c);
		}

	}

}

int main() {

	int n,q,k;

	cin >> n;

	for (int i = 0; i < n-1; i++) {
		int a, b, c;
		cin >> a >> b >> c;

		vec[a].push_back({ b,c });
		vec[b].push_back({ a,c });

	}

	cin >> q >> k;

	solve(k,k,0);

	for (int i = 0; i < q; i++) {
		int x, y;
		cin >> x >> y;

		cout << result[x] + result[y] << endl;

	}



}



Measured memory_bytes: 12800
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

struct Init{
  Init(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    cerr << fixed << setprecision(12);
  }
}init;


std::int64_t power(std::int64_t n, std::int64_t p, std::int64_t m){
  std::int64_t ret = 1;
  while(p>0){
    if(p & 1) (ret *= n) %= m;
    (n *= n) %= m;
    p >>= 1;
  }
  return ret;
}



const LLI mod = 1e9+7;


int main(){
  int N;
  while(cin >> N){
    vector<LLI> A(N); cin >> A;

    LLI ans = 0;
    
    REP(i,60){
      int c0 = 0;
      int c1 = 0;

      for(auto x : A){
        if(x & bit(i)){
          ans += power(2, i, mod) * c0 % mod;

          c1 += 1;
        }else{
          ans += power(2, i, mod) * c1 % mod;

          c0 += 1;
        }

        ans %= mod;
      }
      
    }


    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <cstring>
#include <vector>
#include <cstdio>
using namespace std;
const int NICO = 1000000 + 10;
typedef long long ll;
ll n, sum;
ll a[NICO];
int main()
{
    cin >> n;
    for(int i=1;i<=n;i++)
    {
        cin >> a[i];
        sum += a[i];
    }
    if(sum % (n*(n+1)/2)) 
        cout << "NO" << endl;
    else 
    {
        ll k = sum / (n*(n+1)/2);
        int ok = 1;
        for(int i=1;i<=n-1;i++)
        {
            ll tmp = a[i] - a[i+1] + k;
            if(!( (tmp >= 0) && (tmp % n == 0) )) ok = 0;
        }
        ll tmp = a[n] - a[1] + k;
        if(!( (tmp >= 0) && (tmp % n == 0) )) ok = 0;
        if(ok) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
}

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

typedef long long ll;

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

    int n; cin >> n;
    vector<string> s(n);
    map<string,int> mp;
    int maxn = 0;
    for(int i=0;i<n;i++){
        cin >> s[i];
        mp[s[i]]++;
    }
    for(int i=0;i<n;i++){
        maxn = max(maxn,mp[s[i]]);
    }
    for(auto x : mp){
        if(x.second==maxn){
            cout << x.first << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 25472
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		String t = sc.next();
		for(int i=0;;i++) {
			String ans = s.substring(0, i) + t;
			if (ans.startsWith(s)) {
				System.out.println(ans.length());
				return;
			}
		}
	}

}


Measured memory_bytes: 9684
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
 
int main() {
	int n, k;
	int i;
	int sum = 1;
	cin >> n >> k;

	for (i = 0; i < n; i++)
	{
		if (sum < k)
		{
			sum *= 2;
		}
		else
		{
			sum += k;
		}
	}
	cout << sum << endl;

}


Measured memory_bytes: 3564
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using static System.Math;

class program
{
    static public int mod = 1000000007;
    static void Main()
    {
        int[] sw = inta();
        if (sw[0] > sw[1]) Write("safe");
        else Write("unsafe");
    }

    static int pow(int a, int b) { string binary = Convert.ToString(b, 2); int bileng = binary.Length; long a_power = a; long value = 1; for (int i = bileng - 1; i >= 0; i--) { if (binary[i] == '1') { value = value * a_power % mod; } a_power = a_power * a_power % mod; } return (int)value; }
    static string rstr() { return ReadLine(); }
    static int rint() { return int.Parse(ReadLine()); }
    static long rlong() { return long.Parse(ReadLine()); }
    static string[] stra() { return ReadLine().Split(' '); }
    static char[] chara() { string[] a = stra(); string b = ""; for (int i = 0; i < a.Length; i++) { b += a[i]; } return b.ToCharArray(); }
    static int[] inta() { string[] read_str_array = ReadLine().Split(' '); int[] return_int_array = new int[read_str_array.Length]; for (int countup_i = 0; countup_i < read_str_array.Length; countup_i++) { return_int_array[countup_i] = int.Parse(read_str_array[countup_i]); } return return_int_array; }
    static long[] longa() { string[] read_str_array = ReadLine().Split(' '); long[] return_long_array = new long[read_str_array.Length]; for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) { return_long_array[countup_i] = long.Parse(read_str_array[countup_i]); } return return_long_array; }
    static double[] doublea() { string[] read_str_array = ReadLine().Split(' '); double[] return_double_array = new double[read_str_array.Length]; for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) { return_double_array[countup_i] = double.Parse(read_str_array[countup_i]); } return return_double_array; }
    static long GCD(long a, long b) { if (a < b) { long temp = a; a = b; b = temp; } if (a % b == 0) { return b; } else { long temp = b; b = a % b; a = temp; return GCD(a, b); } }
    static long LCM(long a, long b) { return a * b / GCD(a, b); }
    static void WriteArray2(int[,] a, int b, int c) { for (int i = 0; i < b; i++) { for (int j = 0; j < c; j++) { if (j != 0) Write(" "); Write(a[i, j]); } WriteLine(); } }
    static void WriteArray(int[] a, int b) { for (int i = 0; i < b; i++) { Write(" "); Write(a[i]); } WriteLine(); }
}


Measured memory_bytes: 27292
<?php
while ($line = fgets(STDIN)) {
   $array[] = trim($line);
}
$fir_array = explode(" ",$array[0]);
$D = (int)$fir_array[1];
$N = (int)$fir_array[0];
$count = 0;

for ($i=0;$i<=$N-1;$i++) {
    $distance = explode(" ", $array[$i+1]);
    $x = (int)$distance[0];
    $y = (int)$distance[1];
    $x_pow = pow($x, 2);
    $y_pow = pow($y, 2);
    $xy = $x_pow + $y_pow;
    $result = sqrt($xy);
    if ($result<=$D) {
        $count++;
    }
}

echo $count;
?>


Measured memory_bytes: 30068
fn main() {
	let mut N = String::new();
    let mut S = String::new();
    std::io::stdin().read_line(&mut N).ok();
    std::io::stdin().read_line(&mut S).ok();
    let N: i32 = N.trim().parse().unwrap();
    S = S.trim().to_string();
    if N % 2 == 1 {
        println!("No");
    } else {
        let s1 = &S[..(N/2) as usize];
        let s2 = &S[(N/2) as usize..];
        if s1 == s2 {
            println!("Yes");
        } else {
            println!("No");
        }
    }
}

Measured memory_bytes: 4352
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;

#define getmid(l,r) ((l) + ((r) - (l)) / 2)
#define MEM(a,b) memset(a,b,sizeof(a))
#define MP(a,b) make_pair(a,b)
#define PB push_back

typedef long long ll;
typedef pair<int,int> pii;
const double eps = 1e-8;
const int INF = (1 << 30) - 1;

int N,M;
int V[100010],Vb[100010];
int cnt[100010];

int main(){
	scanf("%d%d",&N,&M);
	for(int i = 1; i <= N; ++i){
		int a;
		scanf("%d",&a);
		cnt[a]++;
	}
	for(int i = 1; i <= 100000; ++i){
		if(!cnt[i]) continue;
		V[i % M] += cnt[i];
		Vb[i % M] += cnt[i] / 2;
	}
	int ans = V[0] / 2;
	if(M % 2 == 0){
		ans += V[M / 2] / 2;
	}
	for(int i = 1; i < (M + 1) / 2; ++i){
		int j = M - i;
		if(V[i] == V[j]){
			ans += V[i];
		}
		else if(V[i] > V[j]){
			ans += V[j];
			ans += min((V[i] - V[j]) / 2,Vb[i]);
		}
		else{
			ans += V[i];
			ans += min((V[j] - V[i]) / 2,Vb[j]);
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1408
def main():
    n, c, k = list(map(int, input().split()))
    T = [int(input()) for _ in range(n)]
    T.sort()
    count = 0
    ans = 1
    t0 = T[0]
    for t in T:
        if t - t0 <= k:
            count += 1
        if count > c or t - t0 > k:
            ans += 1
            count = 1
            t0 = t
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 50632
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n;
  cin >> n;
  vector<int> a;
  rep(i, n){
    int t;
    cin >> t;
    a.emplace_back(t);
  }
  sort(ALL(a));
  if(n == 2){
    cout << a[1] << " " << a[0] << endl;
    return 0;
  }
  int a_i = a[n - 1];
  double val = a_i/2.0;

  int back = int(lower_bound(a.begin() + 1, a.end() - 1, val) - a.begin());
  int front = back - 1;

  double x = a[front] - val;
  double y = a[back] - val;
  // cout << x << ", " << y << endl;

  int near;
  if (x * x < y * y) near = front;
  else near = back;
  int a_j = a[near];
  cout << a_i << " " << a_j << endl;
}


Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,count1=0,count2=0,count3=0;
  cin>>n;
  for(int i=0;i<n;i++){
    int c;cin>>c;
    if(c%4==0) count2++;
    else if(c%2==0) count1++;
    else count3++;
  }
  if(count1<=1)
    cout<<(count2+1>=count1+count3&&count2>0?"Yes":"No")<<endl;
  else 
    cout<<(count2>=count3?"Yes":"No")<<endl;
}

Measured memory_bytes: 384
#include <stdio.h>
#define N 100000
#define NIL -1

typedef struct{
  int p,l,r;
}Node;

Node T[N];
int n, D[N];

void print(int );
int rec(int,int);

int main(){

  int i,j,d,v,c,l,root;

  scanf("%d",&n);
  for(i=0;i<n;i++)
    T[i].p = T[i].l = T[i].r = NIL;

  for(i=0;i<n;i++){
    scanf("%d%d", &v, &d);
    for(j=0;j<d;j++){
      scanf("%d",&c);
      if(j == 0) T[v].l = c;
      else T[l].r = c;
      l = c;
      T[c].p = v;
    }
  }

  for(i=0;i<n;i++)
    if(T[i].p == NIL) root=i;

  rec(root,0);
  for(i=0;i<n;i++)
    print(i);
 
return 0;
}

void print(int u){
  int i,c;
 
  printf("node %d: parent = %d, depth = %d, ",u,T[u].p,D[u]);
 
  if(T[u].p == NIL)printf("root, [");
  else if(T[u].l == NIL)printf("leaf, [");
  else printf("internal node, [");
 
  for(i=0,c=T[u].l;c!=NIL;i++,c=T[c].r){
    if(i)printf(", ");
    printf("%d",c);
  }
  printf("]\n");
}
 
int rec(int u,int p){
 
  D[u] = p;
  if(T[u].r != NIL)rec(T[u].r,p);
  if(T[u].l != NIL)rec(T[u].l,p+1);
}

Measured memory_bytes: 5296
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
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 INF 1000000000
int main(){
cin.tie(0);
ios::sync_with_stdio(false);

	long long int A,B,C,K;
	cin>>A>>B>>C>>K;
	if(K%2==0){
		cout<<A-B<<endl;
		return 0;
	}
	else{
		cout<<B-A<<endl;
		return 0;
	}
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
int ans,max=-1,n,m,a[110],i,b,j;
while(1){
scanf("%d %d\n",&n,&m);
if(n==0 && m==0){
break;
}
for(i=1;i<=m;i++){
a[i]=0;
}
for(j=1;j<=n;j++){
for(i=1;i<=m;i++){
scanf("%d ",&b);
if(b==1){
a[i]++;
}
}
scanf("\n");
}
for(i=1;i<=m;i++){
for(j=1;j<=m;j++){
if(a[j]>max){
max=a[j];
ans=j;
}
}
max=-1;
if(i==1){
printf("%d",ans);
}
else{
printf(" %d",ans);
}
a[ans]=-1;
}
printf("\n");
}
return 0;
}


Measured memory_bytes: 2044
def get_points(n)
  points = n.times.map do |i|
    point = gets.chomp.split(" ").map(&:to_i)
    x = point[0]
    y = point[1]
    min = x < y ? x : y
    max = x < y ? y : x
    { x: x, y: y, min: min, max: max, paired: false }
  end
end

n = gets.chomp.to_i
red_points = get_points(n).sort_by { |p| p[:max] }.reverse
blue_points = get_points(n).sort_by { |p| p[:min] }

counter = 0
blue_points.each do |blue|
  next if blue[:min].zero?

  pair_red = red_points.select { |red| red[:x] < blue[:x] && red[:y] < blue[:y] && !red[:paired] }.first
  unless pair_red.nil? 
    counter = counter.next
    pair_red[:paired] = true
    blue[:paired] = true
  end
end

puts counter

Measured memory_bytes: 1912
// AtCoder Beginners Selection
// ABC177 A Don't be late
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
 
int main() {
  
  // 初期値
  float D = 0, T = 0, S = 0;
  cin >> D >> T >> S;
  
  // メインループ
  if (D / S <= T){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

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

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())#整数値　複数の入力
def S_MAP(): return map(str, input().split())#文字　複数の入力
def LIST(): return list(map(int, input().split()))#整数　複数の入力　配列
def S_LIST(): return list(map(str, input().split()))#文字　複数の入力　配列


x=S_LIST()


print(x.index("0")+1)

Measured memory_bytes: 9564
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e5+10;
struct Node
{
    int  x,y;
}s[maxn];
bool cmp(Node a,Node b)
{
    if(a.y==b.y)
    return a.x<b.x;
    else
        return a.y<b.y;

}
int main()
{

    int n;
    priority_queue<int,vector<int>,greater<int> >que;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
        scanf("%d%d",&s[i].x,&s[i].y);
    sort(s,s+n,cmp);
 ll now=0;
    int flag=1;
    for(int i=0;i<n;i++)
    {
        que.push(s[i].y);
        if((ll)now+s[i].x>que.top())
        {
            flag=0;
            break;
        }
        else
        {
            now=now+s[i].x;
            que.pop();
        }

    }

   if(flag)
    puts("Yes");
   else
    puts("No");

    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;

long long cost[2000];
long long ai[2000];
long long ret[2000];
int main(){
  long long n, x;

  cin >> n >> x;
  for(long long i=0;i<n;i++){
    cin >> ai[i];
    cost[i]=ai[i];
  }
  for(long long k=0;k<n;k++){
    ret[k]=k*x;
    
    for(long long i=0;i<n;i++){
      if(cost[i]> ai[(n+i-k)%n]){
	cost[i]=ai[(n+i-k)%n];
      }
    }
    for(long long i=0;i<n;i++)
      ret[k]+=cost[i];
  }
  long long ret0=ret[0];
  for(int i =1;i<n;i++)
    if(ret0>ret[i])
      ret0=ret[i];
  cout << ret0<<endl;
}


Measured memory_bytes: 256
/*
    ->->->->-> Vora Mahammasasim <-<-<-<-<-
*/
#include<bits/stdc++.h>
#define Quick std :: ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define pb emplace_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define MOD 1e7+7;
using namespace std;





signed main(){

    Quick;
    int x;
    cin>>x;
    cout<<!x;
    return 0;
}


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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int r,g;
    Scd2(r,g);

    printf ("%d\n", g*2 - r );
    return 0;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define inf = 1e9 + 5;
#define dbg(vari) cerr << #vari << " = " << (vari) << endl;

void solve(std::string s, std::string t) {
  unordered_map<char, vector<ll>> m;
  for (int i = 0; i < s.size(); i++) {
    char c = s[i];
    m[c].push_back(i);
  }
  long long copies = 0;
  long long curr = -1;
  for (int i = 0; i < t.length(); i++) {
    if (!m.count(t[i])) {
      cout << "-1" << endl;
      return;
    }
    auto &vectorToSearch = m[t[i]];
    auto found_iter = upper_bound(vectorToSearch.begin(), vectorToSearch.end(), curr);
    if (found_iter == vectorToSearch.end()) {
      copies++;
      curr = vectorToSearch[0];
    } else {
      curr = *found_iter;
    }
  }
  cout << copies * s.length() + curr + 1 << endl;
}

int main() {
  std::string s;
  std::cin >> s;
  std::string t;
  std::cin >> t;
  solve(s, t);
  return 0;
}


Measured memory_bytes: 1688
#[test]
fn test_solve() {
    assert_eq!(solve("3\n2 0\n3 1\n1 3\n4 2\n0 4\n5 5\n"), "2\n");
    assert_eq!(solve("3\n0 0\n1 1\n5 2\n2 3\n3 4\n4 5\n"), "2\n");
    assert_eq!(solve("2\n2 2\n3 3\n0 0\n1 1\n"), "0\n");
    assert_eq!(
        solve("5\n0 0\n7 3\n2 2\n4 8\n1 6\n8 5\n6 9\n5 4\n9 1\n3 7\n"),
        "5\n"
    );
    assert_eq!(
        solve("5\n0 0\n1 1\n5 5\n6 6\n7 7\n2 2\n3 3\n4 4\n8 8\n9 9\n"),
        "4\n"
    );
}
fn solve(src: &str) -> String {
    let mut sc = Scanner::from_str(src);

    let n: usize = sc.read();
    let mut ab: Vec<(usize, usize)> = (0..n).map(|_| (sc.read(), sc.read())).collect();
    let mut cd: Vec<(usize, usize)> = (0..n).map(|_| (sc.read(), sc.read())).collect();
    ab.sort();
    cd.sort();

    let mut ans = 0;
    let mut prd = vec![false; n];
    for i in 0..n {
        let mut p = None;
        for j in 0..n {
            if ab[j].0 >= cd[i].0 {
                break;
            }
            if !prd[j] && ab[j].1 < cd[i].1 {
                p = Some(p.map_or((j, ab[j].1), |(jy, y)| {
                    if y > ab[j].1 {
                        (jy, y)
                    } else {
                        (j, ab[j].1)
                    }
                }));
            }
        }
        if let Some((j, _)) = p {
            ans += 1;
            prd[j] = true;
        }
    }

    format!("{}\n", ans)
}
fn main() {
    let mut buf = String::new();
    use std::io::{Read, Write};
    std::io::stdin().read_to_string(&mut buf).unwrap();
    std::io::stdout().write_all(solve(&buf).as_bytes()).unwrap();
}
struct Scanner<'a>(std::str::SplitWhitespace<'a>);
impl<'a> Scanner<'a> {
    fn from_str(src: &str) -> Scanner {
        Scanner(src.split_whitespace())
    }
    fn get(&mut self) -> &str {
        self.0.next().unwrap()
    }
    fn read<T: std::str::FromStr>(&mut self) -> T {
        self.get().parse().ok().unwrap()
    }
}


Measured memory_bytes: 4352
X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

ans1 = []
for i in range(X):
    for j in range(Y):
        ans1.append(A[i] + B[j])
        
ans1 = sorted(ans1, reverse=True)[:K]

ans = []
for i in range(len(ans1)):
    for j in range(Z):
        ans.append(ans1[i] + C[j])
        
print(*sorted(ans, reverse=True)[:K], sep='\n')




Measured memory_bytes: 141048
w,h,n = map(int,input().split())
x_bit = [1]*w
y_bit = [1]*h

for _ in range(n):
	x,y,a = map(int,input().split())
	if a == 1:
		for i in range(0,x):
			x_bit[i] = 0
	elif a == 2:
		for i in range(x,w):
			x_bit[i] = 0
	elif a == 3:
		for i in range(0,y):
			y_bit[i] = 0
	elif a == 4:
		for i in range(y,h):
			y_bit[i] = 0

print((x_bit.count(1) * (y_bit.count(1))))


Measured memory_bytes: 3064
package main
import (
  "fmt"
  "math"
  "strconv"
)
func main() {
  var n,m,l int64
  fmt.Scan(&n)
  m = sqrt(n)
  l = 0
  for i:=m;i>0;i-- {
    if n%i == 0 {
      l = n/i
      break
    }
  }
  if l == 0 {
    fmt.Println(len(strconv.FormatInt(n,10)))
  } else {
    fmt.Println(len(strconv.FormatInt(l,10)))
  }
}
func sqrt(n int64) int64 {
  var f float64 = math.Sqrt(float64(n))
  return int64(math.Ceil(f))
}

Measured memory_bytes: 512
/*************************************************************************
    > File Name: b.cpp
    > Author: Amano Sei
    > Mail: amano_sei@outlook.com 
    > Created Time: 2020年01月02日 星期四 22时02分11秒
 ************************************************************************/

#include <cstdio>
#include <algorithm>
#include <cstring>

using namespace std;

int main(){
    long long a, b, k;
    scanf("%lld%lld%lld", &a, &b, &k);
    printf("%lld %lld\n", max(a-k, 0ll), max(min(a+b-k,b), 0ll));
    return 0;
}



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

int main()
{
  int N;
  cin >> N;
  auto _N = N;
  int SN = 0;
  while (0 < _N)
  {
    SN += _N%10;
    _N /= 10;
  }
  cout << ((0 == N%SN) ? "Yes" : "No");
  return 0;
}


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

using namespace std;

int main(void)
{
  int participants_count;
  int initial_point;
  int answers_count;
  int *answer_counts;
  
  cin >> participants_count >> initial_point >> answers_count;
  
  answer_counts = new int[participants_count]();
  for(int i = 0; i < answers_count; i++){
    int answerer;
    cin >> answerer;
    answer_counts[answerer - 1]++;
  }
  
  for(int i = 0; i < participants_count; i++){
    int point_decrement = answers_count - answer_counts[i];
    
    if(initial_point > point_decrement){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }
  
  return 0; 
}

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

#define INF 1001001001
#define LINF 1001001001001001001
#define MOD 1000000007
#define MOD2 998244353

template<class T,class U>bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U>bool chmin(T &a, const U &b){if(b<a){a=b;return 1;}return 0;}

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rep1(i,a,b) for(int a_=(a),b_=(b),i=a_;i<b_;++i)
#define repr(i,n) for(int _i=(n),i=_i;i>0;--i)

#define db(x) cerr<<#x<<" = "<<x<<" ";
#define db2(x,y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<") ";
#define db3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<") ";
#define ln cout<<endl;

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define se second
#define fi first

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,pii> ppii;

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

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

int d8x[8]={0,1,1,1,0,-1,-1,-1};
int d8y[8]={-1,-1,0,1,1,1,0,-1};

int main(){
    bool flag=false;
    ll ans=0,sum=0;

    int h,w;
    cin>>h>>w;
    vector<string> g(h);
    char ansg[h][w]={};

    rep(i,h)cin>>g[i];

    rep(i,h)rep(j,w){
            if(g[i][j]=='#'){ansg[i][j]='#';continue;}

            int num=0;
            rep(d,8){
                int ny=i+d8y[d];
                int nx=j+d8x[d];

                if(0<=ny && ny<h && 0<=nx && nx<w){
                    if(g[ny][nx]=='#')++num;
                }

            }
            ansg[i][j] = '0'+num;
    }


    //cout <<fixed<<setprecision(16)<< << endl;
    
    rep(i,h){
        rep(j,w){
            cout<<ansg[i][j];
        }
        ln;
    }
    
    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 256
require 'set'; require 'prime'
INF=Float::INFINITY; MOD=10**9+7
n = gets.chomp.to_i
h = {}
h.default = 0
n.times do
  key = gets.chomp
  h[key] += 1
end

m = gets.chomp.to_i
m.times do
  key = gets.chomp
  h[key] -= 1
end

puts [h.values.max, 0].max



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

int max(int a, int b){
	return a >= b ? a : b;
}

int main(){
	int A, B, C, S, M, ans;
	scanf("%d%d%d", &A, &B, &C);
	S = A + B + C;
	M = max(A, max(B, C));
	if(S % 2 == M % 2){
		ans = 3 * M - S;
	}
	else{
		ans = 3 * (M + 1) - S;
	}
	printf("%d\n", ans / 2);
	return 0;
}

Measured memory_bytes: 128
N,P = map(int,input().split())
A = list(map(int,input().split()))
ans = [1,0]
for a in A:
    if a%2:
        ans[1],ans[0] = ans[1] + ans[0], ans[1] + ans[0]
    else:
        ans[0] = ans[0]*2
        ans[1] = ans[1]*2
print(ans[P])

Measured memory_bytes: 3060
#include<stdio.h>
int main(){
    char s[3];
    int i,c=0,d;
    scanf("%s",s);
    for(i=0;i<3;i++){
        if(s[i]=='A'){
            c++;
        }
    }
    //printf("%d\n",c);
    d=3-c;
    if(c==3 || d==3){
        printf("No\n");
    }
    else{
        printf("Yes\n");
    }

return 0;
}


Measured memory_bytes: 128
n = gets.to_i
a = gets.to_i
b = gets.to_i
c = gets.to_i
d = gets.to_i
e = gets.to_i
f = [a, b, c, d, e].min.to_f
if f >= n
  puts "5"
else
  puts (n / f).ceil + 4
end

Measured memory_bytes: 1788
#include <iostream>


using namespace std;

#define vi vector<int>
#define pb push_back
#define ll long long
#define qi queue<int>
#define vll vector<long long>
#define si set<int>
#define mi map<int,int>
#define mod %
#define frt(i,a,b) for(int i=a;i<b;i++)
#define fre(i,a,b) for(int i=a;i<=b;i++)
#define pair_int pair<int,int>
#define pair_ll pair<ll,ll>
#define pq priority_queue
#define N 100007

ll M = 1000000007;

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

   int a[n+1][m+1];
   ll dp[n+1][m+1];

   for(int i=1;i<=n;i++)
   {
   	  for(int j=1;j<=m;j++)
   	  {
   	  	 char ch;
   	  	 cin >> ch;
   	  	 if(ch=='.')
   	  	 	a[i][j] = 1;
   	  	 else
   	  	 	a[i][j] = 0;
   	  }
   }

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

   	  	  if(i==0 || j==0)
   	  	  	dp[i][j] = 0;

   	  	  else if(i==1 && j==1)
   	  	  	dp[i][j] = 1;

   	  	  else if(a[i][j]==0)
   	  	  	dp[i][j] = 0;

   	  	  else
   	  	  	dp[i][j] = (dp[i-1][j] + dp[i][j-1]) mod M;

   	  	  // cout << i << " " << j << "  : " << dp[i][j] << endl;
   	  }
   }

   cout << dp[n][m] << endl;
   return 0;

}

  


Measured memory_bytes: 12032
N = int(input())
k = []
for i in range(N):
    k.append(int(input()))
B = k.copy()
B.sort()
B.reverse()
P = B[0]
Q = B[1]
for i in range(N):
    if k[i] == P:
        print(Q)
    else:
        print(P)

Measured memory_bytes: 14932
#include <bits/stdc++.h>
#define int long long
#define ld long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define rep(i,l,r) for(int i = (int)l;i<(int)r;i++)
#define td(v) v.begin(),v.end()
#define sz(v) (int)v.size()
//#define M   1000000007 // 1e9 + 7
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
inline int mod(int n, int m){ int ret = n%m; if(ret < 0) ret += m; return ret; }
int gcd(int a, int b){return (b == 0 ? a : gcd(b, a%b));}
int exp(int a,int b,int m){
    
    if(b==0) return 1;
    if(b==1) return mod(a,m);
    int k = mod(exp(a,b/2,m),m);
    if(b&1){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);
}
const int N = 2020;
pii A[N];
int dp[N][N];

int n;
int solve(int l,int r,int id){
  if(l==r){
    return A[id].ff*abs(l-A[id].ss);
  }
  int &x = dp[l][r];
  if(x!=-1)return x;
  int op1 = A[id].ff*abs(l-A[id].ss) + solve(l+1,r,id+1);
  int op2 = A[id].ff*abs(r-A[id].ss) + solve(l,r-1,id+1);
  return x = max(op1,op2);
}

int32_t main(){
  memset(dp,-1,sizeof(dp));
  fastio;
  cin>>n;
  for(int i=1;i<=n;i++){
    cin>>A[i].ff;
    A[i].ss=i;
  }
  sort(A+1,A+1+n,greater<pii>());
  cout<<solve(1,n,1)<<endl;
  
}

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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second
#define lwb lower_bound
#define upb upper_bound
#define all(x) (x).begin(),(x).end()

#define cbr(x) ((x)*(x)*(x))

signed main() {
#ifdef _DEBUG
  // freopen("in", "r", stdin);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int n, k;
  cin >> n >> k;
  cout << cbr((n + k / 2) / k) * (k % 2 == 0) + cbr(n / k) << '\n';
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        public static void Main()
        {
            new Program().Solve();
        }

        void Solve()
        {
            int n = int.Parse(Console.ReadLine());
            int[][] A = new int[2][];
            for (int i = 0; i < 2; i++)
            {
                A[i] = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
            }

            int max = int.MinValue;
            for (int i = 0; i < n; i++)
            {
                max = Math.Max(max, GetTotalCandy(A, i));
            }
            Console.WriteLine(max);

        }

        int GetTotalCandy(int[][] map, int goDownXIndex)
        {
            int x = 0, y = 0;
            int count = 0;
            while (true)
            {

                count += map[y][x];
                if (x == goDownXIndex && y == 0)
                {
                    y++;
                }
                else
                {
                    x++;
                }

                if (y == map.Length - 1 && x == map[0].Length - 1)
                {
                    break;
                }
            }
            count += map[y][x];//(2, N)
            return count;
        }
    }
}


Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
template<class T> inline T gcd(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}else{return 0;}}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}else{return 0;}}

#define MOD 1000000007
typedef long long ll;

int main(){
  int n,t;
  cin >> n >> t;
  int a[1000000];
  FOR(i,n){
    cin >> a[i];
  }
  int sum=0;
  FOR(i,n-1){
    sum+=min(t,a[i+1]-a[i]);
  }
  sum+=t;
  cout << sum << endl;
}

Measured memory_bytes: 2688
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<cmath>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>
    #include<cassert>
    #include<cmath>
    #include<cstdint>
    #include<numeric>
    #include<array>
     
    #define INF 1e9
    #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 VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
    #define ALL(a)  (a).begin(),(a).end()
    #define chmin(a, b) a = min(a, b)
    #define chmax(a, b) a = max(a, b)
    #define Vl vector<ll>
     
    using namespace std;
    using ll = long long;
    using Graph = vector<vector<ll>>;
    using P = pair<ll, ll>;
     
const ll MOD = 1e9 + 7;
const ll ZER = 0;

int main(){
    vector<int> v(4);
    rep(i, 3){
        int a, b;
        cin >> a >> b;
        a--;b--;
        v[a]++;
        v[b]++;
    }
    sort(ALL(v));
    if(v[0] == 1 && v[1] == 1 && v[2] == 2 && v[3] == 2)cout << "YES" << endl;
    else cout << "NO" << endl;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
int main() {
    string n;
    cin >> n;
    if ((n[0] == n[1] && n[1] == n[2]) || (n[1] == n[2] && n[2] == n[3])) cout << "Yes";
    else cout << "No";
}

Measured memory_bytes: 3632