akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(ll i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind 
#define Pint pair<int,int>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 100000000000;
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
struct edge { int to, cost; };
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

// mod. m での a の逆元 a^{-1} を計算するよ！
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


//aCbをmod.mで割った余りを求める
ll int c(ll int a, ll int b, ll int m) {
	ll int ans = 1;
	for (ll int i = 0; i < b; i++) {
		ans *= a - i;
		ans %= m;
	}
	for (ll int i = 1; i <= b; i++) {
		ans *= modinv(i, m);
		ans %= m;
	}
	return ans;
}

//sは初めの点、vは頂点size、dは最短距離を求める(初期化はINF),Gは有向グラフ
void dijkdtra(int s, int v, vector<int>& d, whei(edge)& G) {
	priority_queue<Pint, vector<Pint>, greater<Pint>> que;//firstが距離、secondが頂点
	d[s] = 0;//スタートの距離はもちろんzero
	que.push(Pint(0, s));
	while (!que.empty()) {
		Pint p = que.top();
		que.pop();
		int V = p.second;
		if (d[V] < p.first)continue;
		for (int i = 0; i < G[V].size(); i++) {
			edge e = G[V][i];
			if (d[e.to] > d[V] + e.cost) {
				d[e.to] = d[V] + e.cost;
				que.push(Pint(d[e.to], e.to));
			}
		}
	}
}



int main() {
	string n;
	cin >> n;
	int k = n.size();
	if (k == 1) {
		cout << stoi(n) << endl;
		return 0;
	}
	llint ans = 0;
	rep(bit, 0, (1 << k - 1)) {
		llint x = 1;
		llint sum = n[k - 1]-'0';
			for (int i = k - 2; i >= 0; i--) {
				if (bit & (1 << i)) {
					sum += n[i]-'0';
					x = 1;
				}
				else {
					x *= 10;
					sum += x*(n[i]-'0');
				}
			}
			
			ans += sum;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.buffer.readline

def main():

    n, m, s = map(int, input().split())
    g = [[] for i in range(n*2501)]
    for i in range(m):
        u, v, a, b = map(int, input().split())
        u, v = u-1, v-1
        for j in range(2501):
            k = j-a
            if 0 <= k <= 2500:
                g[u+n*j].append((b, v+n*k))
                g[v+n*j].append((b, u+n*k))

    for i in range(n):
        c, d = map(int, input().split())
        for j in range(2501):
            k = j+c
            if 0 <= k <= 2500:
                g[i+n*j].append((d, i+n*k))

    import heapq
    INF = 10**18
    def dijkstra_heap(s, edge, n):
        d = [INF] * n
        used = [True] * n #True: not used
        d[s] = 0
        used[s] = False
        edgelist = []
        for e in edge[s]:
            heapq.heappush(edgelist,e)
        while len(edgelist):
            minedge = heapq.heappop(edgelist)
            if not used[minedge[1]]:
                continue
            v = minedge[1]
            d[v] = minedge[0]
            used[v] = False
            for e in edge[v]:
                if used[e[1]]:
                    heapq.heappush(edgelist,(e[0]+d[v],e[1]))
        return d

    s_ = 0+min(s, 2500)*n
    d = dijkstra_heap(s_, g, n*2501)
    #print(d)
    for i in range(1, n):
        min_ = INF
        for j in range(2501):
            k = i+n*j
            min_ = min(min_, d[k])
        print(min_)

if __name__ == '__main__':
    main()


Measured memory_bytes: 128548
#include<bits/stdc++.h>
using namespace std;
long long int Mod=1e9+7;
long long  dp[3005][3005];
long long rec(long long A[],long i,long j)
{
    if(i>j)
        return(0);
    else if(i==j)
    {
        dp[i][i]=A[i];
        return(dp[i][i]);
    }
    else if(i==j-1)
    {
        dp[i][i+1]=max(A[i],A[i+1]);
        return(dp[i][i+1]);
    }
    else if(i==j-2)
    {
        dp[i][i+2]=max(A[i]+min(A[i+1],A[i+2]),A[i+2]+min(A[i],A[i+1]));
        return(dp[i][i+2]);
    }
    if(dp[i][j]!=-1)
        return(dp[i][j]);
    else
    {
    dp[i][j]=max(min(rec(A,i+2,j),rec(A,i+1,j-1))+A[i],min(rec(A,i+1,j-1),rec(A,i,j-2))+A[j]);
        return(dp[i][j]);
        
    }
}
int main()
{
    long i,j,n,k,ans,sum=0;
    cin>>n;
    long long A[n+1];
    A[0]=-1;
    for(i=1;i<=n;i++)
    {
        cin>>A[i];
        sum+=A[i];
    }
    
    for(i=0;i<=n;i++)
        for(j=0;j<=n;j++)
            dp[i][j]=-1;
    
    ans = rec(A,1,n);
    cout<<2*ans-sum<<endl;
}

Measured memory_bytes: 70784
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var imp1 = Console.ReadLine().Split(' ');
            var imp2 = Console.ReadLine().Split(' ');

            Console.Write(((int.Parse(imp1[0])) - (int.Parse(imp2[0]))) * ((int.Parse(imp1[1])) - (int.Parse(imp2[1]))));
            //System.Threading.Thread.Sleep(1000);
        }
    }
}


Measured memory_bytes: 13140
from heapq import heappop, heappush
H, W = map(int,input().split())
min_cost = [float("inf")] * 10
min_cost[1] = 0
costs = [list(map(int,input().split())) for _ in range(10)]
que = [(0, 1)]
while que:
    cost, v = heappop(que)
    if cost != min_cost[v]:
        continue
    for to in range(10):
        if min_cost[to] > cost + costs[to][v]:
            min_cost[to] = cost + costs[to][v]
            heappush(que, (min_cost[to], to))
ans = 0
for i in range(H):
    for ch in list(map(int,input().split())):
        if ch != -1:
            ans += min_cost[ch]
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
const int M = 1000000007;

int main() {
    int n, q;
    string s;
    cin >> n >> s >> q;
    vector<int> di, mi, ci;
    vector<int> dmcnt, cmcnt;
    for (int i = 0; i < n; ++i) {
        if (s[i] == 'D') {
            di.push_back(i);
            dmcnt.push_back(mi.size());
        }
        if (s[i] == 'M') {
            mi.push_back(i);
        }
        if (s[i] == 'C') {
            ci.push_back(i);
            cmcnt.push_back(mi.size());
        }
    }
    for (int _ = 0; _ < q; ++_) {
        int k;
        cin >> k;
        int j = 0, pj = 0;
        long long ans = 0;
        long long sum = 0;
        long long c = 0;
        for (int i = 0; i < di.size(); ++i) {
            while (pj < ci.size() && ci[pj] < di[i]) {
                sum -= cmcnt[pj];
                ++pj;
                --c;
            }
            while (j < ci.size() && ci[j] - di[i] < k) {
                sum += cmcnt[j];
                ++j;
                ++c;
            }
            ans += max(0LL, sum - dmcnt[i] * c);
        }
        cout << ans << "\n";
    }

    return 0;
}


Measured memory_bytes: 11380
#include <bits/stdc++.h>
using namespace std;
int main() {
  string S;
  cin >> S;
  int N = S.size();
  int change = 0;
  for (int i = 0; i < N / 2; i++) {
    if (S.at(i) != S.at(N - i - 1)) {
      change++;
    }
  }
  cout << change << endl;
}

Measured memory_bytes: 256
# from pprint import pprint
import math

# import collections

# n = int(input())
n, d = map(int, input().split(' '))
# a = list(map(int, input().split(' ')))

x = []
y = []
for i in range(n):
    _x, _y = map(int, input().split(' '))
    x.append(_x)
    y.append(_y)


def distance(x, y):
    return math.sqrt(x ** 2 + y ** 2)


ans = sum([1 if distance(_x, _y) <= d else 0 for _x, _y in zip(x, y)])
print(ans)


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

#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dump() fprintf(stderr, "#%s.%d\n", __func__, __LINE__);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumplll(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%ld, %ld, %ld)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
typedef std::vector<long> LI;
typedef std::queue<long> QI;
#define rep(i,n) for(long i = 0; i < (long)n; ++i)
const double pi = M_PI;

template<typename T> void scan1(T& x) { fprintf(stderr, "unknown type\n"); }
template<> void scan1(long& x) { if( scanf("%ld", &x) < 0 ) exit(0); }
template<> void scan1(std::string& x) { if( not ( std::cin >> x ) ) exit(0); }
void scan() {}
template<typename Head, typename... Tail>
void scan(Head& x, Tail&... xs) {
  scan1(x); scan(xs...);
}

const long mod = 1000000007;

struct Solver {
   Solver() { fprintf(stderr, "--------Solver begin--------\n"); }
   ~Solver() { fprintf(stderr, "--------Solver end--------\n"); }
   void solve() {
      long n, m; scan(n, m);
      LI xs(n); for(long &x : xs) { scan(x); x -= 1; }
      LI lefts(n-1, 0);
      LI rights(n-1, 0);
      for(long i = 0; i < n-1; ++i) {
         long left = xs[i] + 2;
         long right = xs[i+1];
         if( xs[i+1] < xs[i] ) right += m;
         lefts[i] = left;
         rights[i] = right;
      }
      LI ys(2*m+1, 0);
      // step 1
      for(long i = 0; i < n - 1; ++i) {
         ys[lefts[i]] += 1;
         ys[rights[i]+1] -= 1;
      }
      // step 2
      long t = 0;
      for(long i = 0; i < 2 * m; ++i) {
         t += ys[i];
         ys[i] = t;
      }
      // step 3
      for(long i = 0; i < n - 1; ++i) {
         ys[rights[i]+1] += -(rights[i] - lefts[i] + 1);
      }
      // step 4
      long t2 = 0;
      for(long i = 0; i < 2 * m; ++i) {
         t2 += ys[i];
         ys[i] = t2;
      }
      // step 5
      for(long i = 0; i < m; ++i) {
         ys[i] += ys[i+m];
      }
      // check
      // for(long i = 0; i < m; ++i) {
      //    dumpll(i, ys[i]);
      // }
      long totaldist = 0;
      for(long i = 0; i < n - 1; ++i) {
         totaldist += (xs[i+1] - xs[i] + m) % m;
      }
      // dumpl(totaldist);
      long res = (1LL << 50);
      for(long i = 0; i < m; ++i) {
         res = std::min(res, totaldist - ys[i]);
      }
      printf("%ld\n", res);
   }
};

int main() {
   loop std::unique_ptr<Solver>(new Solver())->solve();
}



Measured memory_bytes: 4096
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
	static Boolean prime(int x){
		for(int i = 2; i * i <= x; i++){
			if(x % i == 0){
				return false;
			}
		}

		return true;
	}

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

		int n = s.nextInt();

		int[] result = new int[n];

		int added = 0;

		for(int i = 11; added < n; i += 10){
			if(prime(i)){
				result[added] = i;
				added++;
			}
		}

		for(int i = 0; i < n; i++){
			System.out.print(String.valueOf(result[i]) + ' ');
		}
		System.out.print('\n');
	}
}

Measured memory_bytes: 21076
n= int(input())
 
index=0
flag=0
list2=[0,0,0]
while index<n:
    list =input().split()
    t = abs(int(list[0])-list2[0])
    x = abs(int(list[1])-list2[1])
    y = abs(int(list[2])-list2[2])
    if x+y == t and flag ==0:
        answer="Yes"
        list2=[t,x,y]
    elif x+y<t and (x+y)%2==t%2 and flag ==0:
        answer="Yes"
        list2=[t,x,y]
    else:
        answer="No"
        list2 =[t,x,y]
        flag=1
    index+=1
print(answer)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std ;
#define rep(i,n) for(int i =0;i<n;i++)
int main(){
    string s;
    int count=0;
	cin>>s;
	rep(i,s.length())
	{char key=s[i];
    for(int j=i+1;j<s.length();j++)
	{if(key==s[j])
	{s[j]='0';
	}
	else
	{continue;
	}
	} 
	}
	rep(k,s.length())
	{if(s[k]!='0')
	{count++;
	}
	}
if(count==2)
	{cout<<"Yes"<<endl;
	}
	else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
siki = list(input())

A=int(siki[0])
B=int(siki[1])
C=int(siki[2])
D=int(siki[3])



if A+B+C+D ==7:
    ans = str(A),'+',str(B),'+',str(C),'+',str(D),'=7'
    print(''.join(map(str, ans)))
elif A+B-C+D ==7:
    ans = str(A),'+',str(B),'-',str(C),'+',str(D),'=7'
    print(''.join(map(str, ans)))
elif A+B+C-D ==7:
    ans = str(A),'+',str(B),'+',str(C),'-',str(D),'=7'
    print(''.join(map(str, ans)))
elif A-B+C+D ==7:
    ans = str(A),'-',str(B),'+',str(C),'+',str(D),'=7'
    print(''.join(map(str, ans)))
elif A-B-C+D ==7:
    ans = str(A),'-',str(B),'-',str(C),'+',str(D),'=7'
    print(''.join(map(str, ans)))
elif A-B+C-D ==7:
    ans = str(A),'-',str(B),'+',str(C),'-',str(D),'=7'
    print(''.join(map(str, ans)))
elif A+B-C-D ==7:
    ans = str(A),'+',str(B),'-',str(C),'-',str(D),'=7'
    print(''.join(map(str, ans)))
elif A-B-C-D ==7:
    ans = str(A),'-',str(B),'-',str(C),'-',str(D),'=7'
    print(''.join(map(str, ans)))
    

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

using ll = int_fast64_t;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define repr(i,n) for(int i{n};i-->0;)

signed main(){

  int n,t;
  cin>>n>>t;
  vector<pair<int,int>> ab(n);
  rep(i,n){int ai,bi;cin>>ai>>bi;ab[i]={ai,bi};}
  sort(begin(ab),end(ab));

  vector dp (n+1,vector(6010,0));
  rep(i,n){
    auto& [ai,bi] = ab[i];
    rep(j,t){
      dp[i+1][j] = max(dp[i+1][j],dp[i][j]);
      dp[i+1][j+ai] = max(dp[i+1][j+ai],dp[i][j]+bi);
    }
  }

  int ans = 0;
  for(auto vec:dp)
    for(auto val:vec)
      ans = max(ans,val);

  cout<<(ans)<<endl;

}

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

#define ll long long
#define fo(i,a,n) for(ll i=a;i<n;i++)
#define rfo(i,n,a) for(ll i=n;i>=a;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    ll t,n,i,j;
    cin>>t>>n;
    if((4*t-n)%2==0 && n>=2*t && n<=4*t)
        cout<<"Yes\n";
    else
        cout<<"No\n";
}


Measured memory_bytes: 3652
#include <stdio.h>
#define N 150
int main(void)
{
  char s[N][N]={0},ans[N][N]={0};
  int i,j,h,w;
  scanf("%d%d",&h,&w);
  for(i=0;i<h;i++)
  {
    scanf("%s",s[i]);
  }
  for(i=0;i<h+2;i++)
  {
    for(j=0;j<w+2;j++)
    {
      if(i==0 || i==h+1)
      {
        ans[i][j]='#';
      }
      else if(j==0 || j==w+1)
      {
        ans[i][j]='#';
      }
      else
      {
        ans[i][j]=s[i-1][j-1];
      }
    }
  }
  for(i=0;i<h+2;i++)
  {
    printf("%s\n",ans[i]);
  }
  return 0;
}


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

int ch(int x){
  int y;
  if(x == 1){y = 0;}
  if(x == 0){y = 1;}
  return y;
}


int main(){
  int n;
  cin >> n;
  vector<vector<int>> v(n,vector<int>(0));

  for(int i = 0; i < n; i++){
    int a; cin >> a;
    for(int j = 0; j < a; j++){
      int x, y; cin >> x >> y;
      v[i].push_back(x);
      v[i].push_back(y);
    }
  }

  
  bool f;
  int cnt = 0;
  vector<int> vp(0);
  for(int bit = 0; bit < (1<<n); bit++){
    int p = n;
    bool br = false;
    for(int i = 0; i < n; i++){
      f = false;
      if(bit & (1<<i)){f = true; p--; continue;}
      for(int j = 0; j < v[i].size()/2; j++){
        int k = v[i][2*j+1];
        if(f){
          k = ch(k);
        }
        if(bit & (1<<v[i][2*j]-1)){
          if(k == 1){br = true; break;}
        }
        else{
          if(k == 0){br = true; break;}
        }
      }
      if(br){break;}
    }
    if(!br){vp.push_back(p);}
  }
  sort(vp.begin(), vp.end());
  if(vp.size() > 0){
  cout << vp[vp.size()-1] << endl;
  }
  else{cout << 0 << endl;}
}

Measured memory_bytes: 512
import bisect
n = input()
a = [int(raw_input()) for i in xrange(n)]
S = sum(a)

c = 0
lst = [0]
for i in xrange(2):
    for j in xrange(n):
        c += a[j]
        lst.append(c)
ans = 0
for i in xrange(n):
    base = lst[i]
    idx1 = bisect.bisect_left(lst, base + (S+2)/3)
    r = S - (lst[idx1] - base)
    idx2 = bisect.bisect_left(lst, lst[idx1] + (r+1)/2)
    mi1 = min(lst[idx1] - base, lst[idx2]-lst[idx1], S - (lst[idx2] - base))
    mi2 = min(lst[idx1] - base, lst[idx2-1]-lst[idx1], S - (lst[idx2-1] - base))
    ans = max(ans, mi1, mi2)
print ans

Measured memory_bytes: 13772
#include<iostream>
#include<math.h>

using namespace std;

int main(){
  long long A,B,N;
  cin >> A >> B >> N;
  long long a,c,d,e;
  a=A/B;
  c=A%B;
  if(N >= B){
    e=B-1;
  }else{
    e=N;
  }
  cout << a*e + long((c*e)/B);
  return 0;
}

Measured memory_bytes: 3624
H,W,h,w = gets.split.map(&:to_i)
ans = Array.new((H+3*h-1)/h*h).map{Array.new((W+3*w-1)/w*w,0)}
for i in 0..(H+h-1)/h
    for j in 0..(W+w-1)/w
        ans[i*h][j*w] = -10**9
        ans[i*h+1][j*w+1] = 10**9-1
    end
end
sum = 0
for i in 1..H
    sum += ans[i][1..W].inject(:+)
end
if sum > 0
    puts "Yes"
    for i in 1..H
        puts ans[i][1..W].join(" ")
    end
else
    puts "No"
end

Measured memory_bytes: 33916
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int cnt(int n, int k){
  int ans = 0;
  while(n < k){
    ans ++;
    n *= 2;
  }
  return ans;
}

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

  double ans = 0;
  for(int i = 1; i <= N; i++){
    ans += 1 / (double)N * pow(0.5, cnt(i, K));
  }

  printf("%.10lf\n", ans);
  return 0;

}

Measured memory_bytes: 384
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
    
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int H = sc.nextInt();
		int W = sc.nextInt();
		int h = sc.nextInt();
		int w = sc.nextInt();
		
		// 計算
		int result = 0;
		result = (H - h)*(W - w);
		
		// 出力
		System.out.println(result);
        
	}
}


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

#define LL long long
#define fi first
#define se second
#define mp make_pair
#define pb push_back

using namespace std;

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;}
LL powmod(LL a,LL b,LL MOD){LL ans=1;while(b){if(b%2)ans=ans*a%MOD;a=a*a%MOD;b/=2;}return ans;}
const int N = 2e5 +11;
int n,d;
int a[33][33],ans;
int main(){
	ios::sync_with_stdio(false);
	cin>>n>>d;
	for(int i=1;i<=n;i++)for(int j=1;j<=d;j++)cin>>a[i][j];
	for(int i=1;i<=n;i++){
		for(int j=i+1;j<=n;j++){
			if(i==j)continue;
			int res=0;
			for(int k=1;k<=d;k++){
				res+=(a[i][k]-a[j][k])*(a[i][k]-a[j][k]);
			}
			int ll=sqrt(res);
			if(ll*ll==res)ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define pb push_back
#define N 200001
#define ll long long
#define int ll 
#define pi pair<int , int>
#define pip pair<pair ,int>
#define mp make_pair 
#define f first
#define s second
#define mod 998244353
ll Mod(ll x, ll y, int p) 
{ll res = 1; x = x % p;
while (y > 0) 
{if(y & 1) res = (res*x) % p; 
y = y>>1;x = (x*x) % p; 
}return res; 
}
int* getlps(string pattern){
 int len = pattern.length();
 int * lps = new int[len];
 lps[0] = 0;
 int i = 1 , j = 0;
 while(i < len){
  if(pattern[i] == pattern[j]){
	  lps[i] = j+1;
   i++;
   j++;
  }
  else{
		if(j != 0){
		 j = lps[j-1];
		}
		else{
		 lps[i] = 0;
		 i++;
		}
  }
 }
 return lps;
}
class Triplet{
 public:
 int x ;
 int y ;
 int gcd;
};
Triplet extendedEuclid(int a , int b){
 if(b == 0){Triplet ans; ans.gcd = a;ans.x = 1;ans.y = 0;return ans;}
 Triplet smallAns = extendedEuclid(b , a%b);
 Triplet ans;
 ans.gcd = smallAns.gcd;
 ans.x = smallAns.y;
 ans.y = smallAns.x - (a/b)*smallAns.y;
 return ans;
}
int mmInverse(int a , int m){
 Triplet ans = extendedEuclid(a , m);
 return ans.x;
}
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n , a , b;
cin>>n>>a>>b;
cout<<a*(n/(a+b)) + min(a , (n%(a+b)));
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Range(container) container.begin(), container.end()
#define Cin(T, x) T x; cin >> x;
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i];
#define Cout(val) cout << (val) << "\n";
using namespace std;
using ll = long long;

int main(void){
    Cin(string, s);
    Cout(700 + ((s[0] == 'o') ? 100 : 0) + ((s[1] == 'o') ? 100 : 0) + ((s[2] == 'o') ? 100 : 0));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
    #define ll long long int
    #define f(i,n) for(ll i=0;i<n;i++)
    #define fz for(ll j=i+1;j<n;j++)
    #define f2(i,n) for(ll i=1;i<=n;i++)
    #define endl "\n"
    #define vll vector <ll>
    #define mod 1000000009
    #define pb push_back
    #define inf 1e13+5

    ll gcd(ll a, ll b){if(b==0)return a;return gcd(b, a%b);}
    ll lcm(ll a, ll b){return a*b/gcd(a, b);}
    ll fexp(ll a, ll b){ll ans = 1;while(b){if(b&1) ans = ans*a%mod; b/=2;a=a*a%mod;}return ans;}
    ll inverse(ll a, ll p){return fexp(a, p-2);}   

    
    void solve(){
       string s,t;cin>>s>>t;
       s="3"+s;t="3"+t;
       ll n1=(ll)s.size();
       ll n2=(ll)t.size();
       ll dp[3002][3002]={0};
       for(int i=1;i<n1;i++){
           for(int j=1;j<n2;j++){
               if(s[i]==t[j])dp[i][j]=dp[i-1][j-1]+1;
               else{
                   dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
               }
           }
       }
    //    f(i,n1){
    //        f(j,n2)cout<<dp[i][j]<<" ";
    //        cout<<endl;
    //    }
       ll x=n1-1;
       ll y=n2-1;
       string ans="";
       while(x>=1 && y>=1){
           if(s[x]==t[y]){
               ans+=s[x];
               x--;y--;
               
           }
           else if(dp[x][y]==dp[x-1][y]){
               x--;
           }
           else y--;
        //    cout<<ans<<endl;
       }
       
       reverse(ans.begin(),ans.end());
       cout<<ans<<endl;


    }


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

        

        ll t;
        t=1;
        // cin>>t;
        while(t--){
            solve();
        }

        
        
        return 0;
    }

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

int main() {
	int a,b;
	cin>>a>>b;
	if(a<b){
		cout<<"a < b"<<endl;
	}
	if(a>b){
		cout<<"a > b"<<endl;
	}
	if(a==b){
		cout<<"a == b"<<endl;
	}
	return 0;
}

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

int p[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
int y2,m2,d2;

int leap(int y){
  if( !(y%400) ) return 1;
  if( !(y%100) ) return 0;
  if( !(y%4) ) return 1;
  return 0;
}

int solve(int y, int m, int d){

  if(y == y2 && m == m2 && d == d2) return 0;

  if(leap(y) && m == 2 && d == 28) return solve(y,3,1)+2;
  else if(m == 12 && d == 31) return solve(y+1,1,1)+1;
  else if(p[m] == d) return solve(y,m+1,1)+1;
  else return solve(y,m,d+1)+1;

}

int main(){

  int y,m,d;

  while(true){
    cin >> y >> m >> d >> y2 >> m2 >> d2;
    if(y < 0 || m < 0 || d < 0 || y2 < 0 || m2 < 0 || d2 < 0) break;

    cout << solve(y, m, d) << endl;
  }

}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
int const nax = 3e5 + 10;
using ll = long long ;
int n, a[nax];

ll const inf = 1e18;

ll ans;

ll e[nax], o[nax];

ll dp[nax][3];


int main () {
    scanf("%d", &n);

    ll esum = 0, osum = 0;

    for (int i = 1 ; i <= n ; ++ i) {
        scanf("%d", a + i);
    }

    for (int i = 0 ; i <= n ; ++ i) {
        for (int j = 0 ; j < 3 ; ++ j)
            dp[i][j] = -inf;
    }

    dp[0][0] = 0;
    dp[1][0] = a[1];
    dp[2][1] = a[2];

    for (int i = 3 ; i <= n ; ++ i) {
        dp[i][0] = max(dp[i][0], dp[i - 2][0] + a[i]);
        dp[i][1] = max(dp[i][1], dp[i - 2][1] + a[i]);
        dp[i][2] = max(dp[i][2], dp[i - 2][2] + a[i]);

        if (i >= 3) dp[i][1] = max(dp[i][1], dp[i - 3][0] + a[i]);
        if (i >= 4) dp[i][2] = max(dp[i][2], dp[i - 4][0] + a[i]);
        if (i >= 3) dp[i][2] = max(dp[i][2], dp[i - 3][1] + a[i]);
    }

    if (n % 2 == 0) {
        printf("%lld\n", max({ dp[n][1], dp[n][0], dp[n - 1][0]}));
    } else {
        printf("%lld\n", max({dp[n - 2][0], dp[n - 1][1], dp[n][2], dp[n][1]}));
    }


}
/*
    Good Luck
        -Lucina
*/


Measured memory_bytes: 9296
#include <bits/stdc++.h>
#define db(x) cout << (x) << '\n';
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pii;
typedef pair<double,ll> pdi;
typedef pair<string,ll> psi;
typedef pair<ll,string> pls;
typedef pair<string,string> pss;
typedef pair<ll,pii> pip;
typedef pair<pii,pii> ppp;
#define MAXQ 55

int a[MAXQ],b[MAXQ],c[MAXQ],d[MAXQ];

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

    int n,m,q;
    cin >> n >> m >> q;
    for(int i=0;i<q;i++)
        cin >> a[i] >> b[i] >> c[i] >> d[i];

    ll res=0;
    for(int i=0;i<(1<<(n+m-1));i++)
    {
        if(__builtin_popcount(i)!=n)
            continue;
        vector<int> vals;
        int v=1;
        for(int j=0;j<(n+m-1);j++)
        {
            if(i&(1<<j))
                vals.push_back(v);
            else
                v++;
        }

        ll sum=0;
        for(int j=0;j<q;j++)
            if((vals[b[j]-1]-vals[a[j]-1])==c[j])
                sum+=d[j];
        res=max(res,sum);
    }
    db(res)

    return 0;
}


Measured memory_bytes: 3660
#include <stdio.h>
int main()
{
  int W,H,x,y,r;

  scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
  if(x-r<0 || x+r>W || y-r<0 || y+r>H ) printf("No\n");
  else printf("Yes\n");
  return 0;

}

Measured memory_bytes: 584
n = int(input())
a = []
b = []
for i in range(n):
    x, y = map(int, input().split())
    a.append(x)
    b.append(y)
a.sort()
b.sort()
if n%2==1:
    print(b[n//2]-a[n//2]+1)
else:
    print(b[n//2]+b[n//2-1]-a[n//2]-a[n//2-1]+1)

Measured memory_bytes: 25328
/*****************************
 Filename: dkjlskdf.cpp
 Author: hbb
 Create: 2020-04-05 11:48:16
*****************************/
#include<map>
#include<cmath>
#include<queue>
#include<cstdio>
#include<string>
#include<vector>
#include<climits>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn = 1e6 + 5;
const int mod = 1e9 + 7;
const int inf = INT_MAX >> 1;
typedef long long int LL;

int main(){
	queue<LL> que;
	while(que.size()) que.pop();
	LL k;
	scanf("%lld", &k);
	for(int i = 1; i <= 9; i++) que.push(i);
	LL now = 0;
	while(k--){
		now = que.front();
		que.pop();
		LL temp = now % 10;
		if(temp != 0) que.push(now * 10LL + temp - 1LL);
		que.push(now * 10LL + temp);
		if(temp != 9) que.push(now * 10LL + temp + 1LL);
	}
	printf("%lld\n", now);
}

Measured memory_bytes: 1792
// #include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <climits>
#include <string>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <ctime>
#include <cassert>
#include <fstream>
#include <stack>
#include <random>

typedef long long ll;
typedef std::pair<int, int> Pii;
typedef std::pair<long long, long long> Pll;
typedef std::pair<double, double> Pdd;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define all(a) a.begin(), a.end()
#define MM << " " <<

template<typename T>
using MaxHeap = std::priority_queue<T>;
template<typename T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

template<typename T>
void vdeb(std::vector<T> &da) {
    for (int i = 0;i < da.size();i++) {
        if (i == da.size() - 1) std::cout << da[i];
        else std::cout << da[i] << ' ';
    }
    std::cout << '\n';
}
template<typename T>
void vdeb(std::vector<std::vector<T>> &da) {
    for (int i = 0;i < da.size();i++) {
        std::cout << i << ' ';
        vdeb(da[i]);
    }
    std::cout << '\n';
}

using namespace std;

int main() {
    ll n, d; cin >> n >> d;
    int cnt = 0;
    rip(i,n,0) {
        ll x, y; cin >> x >> y;
        if(x*x + y*y <= d*d) cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3640
#include <stdio.h>
#include <math.h>

int main()
{
	long int n,k;
	
	scanf("%ld %ld",&n,&k);
	
	if(n % k == 0)
		n = 0;
	else
		while(1)
		{
			if(n > k)n %= k;
			if(n >= k / 2)
			{
				n = labs(n - k);
				break;
			}
			else 
			{
				break;	
			}
		}
	
	printf("%ld\n",n);
	
	return 0;
}

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

int main() {
	// your code goes here
	int n,i;
	cin>>n;
	int a[n+5];
	for(i=0;i<n;i++)
	cin>>a[i];
	long long int ans =1000,z,y,ans1=1000;
	for(i=0;i<n-1;i++)
	{
		if(a[i]<a[i+1])
		{
			z=ans/a[i];
			y=ans%a[i];
			ans=z*a[i+1];
			ans+=y;
		}
	}
	if(ans<ans1)
	cout<<ans1;
	else
	
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3624
n, y = gets.to_s.split.map{|t|t.to_i}

y /= 1000

m_max = [n, y/10].min
g_max = [n, y/5].min

0.upto(m_max) do |m|
  t = y - 10 * m
  break if y < 0
  0.upto(g_max) do |g|
    s = t - 5 * g
    break if s < 0
    if n == m + g + s
      puts "#{m} #{g} #{s}"
      exit
    end
  end
end

puts "-1 -1 -1"

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

	string s,t;


	cin >>s;
	rep(i,s.length()){
		t=t+'x';
	}
	cout << t << endl;
	return 0;
}


Measured memory_bytes: 256
//https://atcoder.jp/contests/code-festival-2017-qualb/tasks/code_festival_2017_qualb_b
//B - Problem Set
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
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;}
int main() {
    ll N; cin>>N;
    unordered_map<ll,ll> dn;
    REP(i,N){
        ll D; cin>>D;
        dn[D]++;
    }
    ll M; cin>>M;
    bool ans=true;
    REP(i,M){
        ll T; cin>>T;
        if (dn.count(T) > 0 && dn[T]>0){
            dn[T]-=1;
        } else {
            ans=false;
            break;
        }
    }
    cout<<(ans?"YES":"NO")<<endl;
    return 0;
}

Measured memory_bytes: 8520
#include <bits/stdc++.h>
using namespace std;
#define INF 1<<30
#define endl '\n'
#define maxn 100005
#define tc printf("Case %d: ", cs)
#define tcn printf("Case %d:\n", cs);
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
typedef long long ll;
const double PI = acos(-1.0);
#define dbg(x) cerr << #x << " = " << x << endl;
#define dbg2(x, y) cerr << #x << " = " << x << ", " << #y << " = " << y << endl;
#define dbg3(x, y, z) cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;


int main()
{
    FASTIO
    /*
    //double start_time = clock();
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif
//*/
    int T;
    //cin >> T;
    T = 1;
    for (int cs = 1; cs <= T; cs++) {
        int n;
        cin >> n;
        int ans = 3 * n * n;
        cout << ans << endl;
    }

    //double end_time = clock();
    //printf( "Time = %lf ms\n", ( (end_time - start_time) / CLOCKS_PER_SEC)*1000);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    char c;
    cin >> c;
    if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
        cout << "vowel" << endl;
    } else {
        cout << "consonant" << endl;
    }
}

Measured memory_bytes: 256
import itertools
n = int(input())
p = list(map(int,input().split()))
q = list(map(int,input().split()))

pattern = list(itertools.permutations(list(range(1,n+1))))


a = 0
b = 0

for x in pattern:
  new_x = list(x)
  if new_x == p:
    a = pattern.index(x)
  if new_x == q:
    b = pattern.index(x)


print(abs(a-b))


Measured memory_bytes: 13964
#include<bits/stdc++.h>
#define rep(i,a,...) for(int i = (a)*(strlen(#__VA_ARGS__)!=0);i<(int)(strlen(#__VA_ARGS__)?__VA_ARGS__:(a));++i)
#define per(i,a,...) for(int i = (strlen(#__VA_ARGS__)?__VA_ARGS__:(a))-1;i>=(int)(strlen(#__VA_ARGS__)?(a):0);--i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using ll = long long;
//const ll MOD = (ll)1e9+7;
const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}
#ifdef DEBUG
#define debug(x) cout<<"LINE "<<__LINE__<<": "<<#x<<" = "<<x<<endl;
#else
#define debug(x) (void)0
#endif

ll modpow(ll x, ll b){
  ll res = 1;
  while(b){
    if(b&1)res = res * x % MOD;
    x = x * x % MOD;
    b>>=1;
  }
  return res;
}

ll modinv(ll x){
  return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t a){
  if(was_output)cout << " ";
  cout << a;
  was_output = true;
}
void outendl(){
  was_output = false;
  cout << endl;
}
ll in(){
  ll res;
  scanf("%lld", &res);
  return res;
}

template<class t>
istream& operator>>(istream&is, vector<t>&x){
  for(auto &i:x)is >> i;
  return is;
}

template<class t, class u>
istream& operator>>(istream&is, pair<t, u>&x){
  is >> x.first >> x.second;
  return is;
}

template<class t>
void in(t&x){
  cin >> x;
}

template<class t>
void out(t x){
  cout << x;
}

bool func(){
  int n = in();
  int la = 0;
  rep(i,n){
    int d = in();
    if(la>d)return false;
    chmax(la,d-1);
  }
  return true;
}

int main(){
  cout <<(func()?"Yes":"No") << endl;
  return 0;
}


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

int w[100000], k, n;

int check(long long p){
    int j = 0;
    for(int i=0; i<k; ++i){
        long long s = 0;
        while(s + w[j] <= p){
            s += w[j++];
            if(j == n) return n;
        }
    }
    return j;
}

long long ans(){
    long long p = 10000*100000, left, right;
    left = 0; right = p;
    while(left < right){
        long long mid = (left + right) / 2;
        if(check(mid) >= n){
            right = mid;
        }else{
            left = mid + 1;
        }
    }
    return right;
}

int main(){
    cin >> n >> k;
    for(int i=0; i<n; ++i) cin >> w[i];

    cout << ans() << endl;
}


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

using namespace std;
#define DBG(x)                         \
    (void)(cout << "L" << __LINE__     \
                << ": " << #x << " = " \
                << (x) << '\n')

typedef long long ll;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 0x3f3f3f3f;
const int maxn = 110000;
int main()
{
    //检查有没有特判0,有没有越界限.
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    ll a, b;
    cin >> a >> b;
    cout << a * b / __gcd(a, b) << "\n";
    return 0;
}

Measured memory_bytes: 3660
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cassert>
//#include <tuple>
#include <cmath>
#define int long long
using namespace std;

string s;
int k;

signed main() {
	int i;
	
	cin >> s >> k;
	
	for (i = 0; i < s.length(); i++) {
		if (s[i] != '1') break;
	}
	
	if (k <= i) cout << 1 << endl;
	else cout << s[i] << endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

		if (N % 10 == 9 || N >= 90){
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}





Measured memory_bytes: 22484
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x,h,w) (y) < 0 || (h) <= (y) || (x) < 0 || (w) <= (x)
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
const long double pi = acos(-1);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& input, vector<T>& v) { for (auto& elemnt : v)input >> elemnt; return input; }


int main() {
    init();

    int n, a, b, c, d; cin >> n >> a >> b >> c >> d;
    --a, --b, --c, --d;
    string s; cin >> s;

    bool ok = true;
    if (c > d) {
        int Max = 0, cnt = 0;
        eFOR(i, b - 1 , d + 1) {
            if (s[i] != '#')++cnt;
            else {
                chmax(Max, cnt);
                cnt = 0;
            }
        }
        chmax(Max, cnt);
        if (Max < 3)ok = false;
    }
    FOR(i, a, d) {
        if (s[i] == s[i + 1] && s[i] == '#')ok = false;
    }

    cout << (ok ? "Yes\n" : "No\n");
}


Measured memory_bytes: 592
#include <iostream>
#include <vector>
#include <algorithm>
 
int main()
{
	int N = 0, ans = 0;
	std::cin >> N;
 
	std::vector<int> H(N);
	for (int i = 0; i < N; i++)std::cin >> H[i];
 
	int cnt = 0;
	for (int i = N-1; i > 0; i--){
		if (H[i] <= H[i - 1])cnt++;
		else cnt = 0;
		ans = std::max(ans, cnt);
	}
 
	std::cout << ans << std::endl;
 
	return 0;
}

Measured memory_bytes: 640
import scala.io.StdIn._

object Main extends App {
  val n = readInt()
  var l = readLine().split(" ").map(_.toInt).toList
  var count = 0
  while (l forall (n => n >= 2 && n % 2 == 0)) {
    l = l.map(_ / 2)
    count += 1
  }
  println(count)
}


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

int main(){
    int K;
    cin >> K;
    vector<int> d(K);
    rep(i,K) cin >> d[i];

    if( K % 2 != 0){
        cout << 0 << endl;
        return 0;
    }
    int middle = K/2;
    sort(d.begin(),d.end());
    int ans = d[middle]-d[middle-1];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char a = sc.next().charAt(0); 
      	char b = sc.next().charAt(0); 
      if(a<b){System.out.println("<");}
      else if(a>b){System.out.println(">");}
      else if(a==b){System.out.println("=");}

    }
}

Measured memory_bytes: 23124
import java.util.*;
import java.io.*;

public class Main {
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		char[] a = sc.next().toCharArray();
		
		int r = 0;
		int w = 0;
		for(int i = 0; i < n; i++) {
			if(a[i] == 'R') {
				r++;
			} else {
				w++;
			}
		}
		int done_r = 0;
		int done_w = 0;
		int ans = n;
		for(int i = 0; i <= n; i++) {
			ans = Math.min(ans, Math.max(done_w, r));
			if(i < n) {
				if(a[i] == 'W') {
					w--;
					done_w++;
				} else {
					r--;
					done_r++;
				}
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 41120
#!/Library/Frameworks/Python.framework/Versions/3.5/bin/python3

n = int(input())
a = list(map(int, input().split()))

c = 1
s = 0
for i in range(n):
    if a[i] == c:
        c += 1
        s += 1

if s == 0:
    print('-1')
else:
    print(n - s)


Measured memory_bytes: 26140
N = int(input())
A = list(map(int, input().split()))
l = 0
r = N - 1
L = A[l]
R = A[r]
while r-l!=1:
  if L>=R:
    R += A[r-1]
    r -= 1
  else:
    L += A[l+1]
    l += 1
print(abs(L-R))


Measured memory_bytes: 94104
import bisect
primes = [0, 0] + [1]*999999
for i in range(2, 1001):
    if primes[i]:
        for j in range(i*i, 1000001, i):
            primes[j] = 0

prime_value = [i for i in range(len(primes)) if primes[i]]
while True:
    n = int(input())
    if n == 0:
        break
    x = bisect.bisect_right(prime_value, n//2)
    print(sum(1 for p in prime_value[:x] if primes[n-p]))

Measured memory_bytes: 22972
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string str;
    int cot[27]= {0},flag=0;
    set<char>s;
    cin>>str;
    flag=0;
    sort(str.begin(),str.end());
    for(int i=0; i<str.size(); i++)
    {
        cot[str[i]-97]++;

    }
    for(int i=0; i<26; i++)
    {
        if(cot[i]%2==1)
        {
            flag=1;
            break;
        }
    }
    if(flag==1)
        cout<<"No"<<endl;
    else
        cout<<"Yes"<<endl;
}


Measured memory_bytes: 3572
import java.util.*;
 
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String a = sc.next();
    String b = sc.next();
    int ans;
    ans = convert(a,b);
    System.out.println(ans);
  }
  public static int convert(String a, String b){
      int l = a.length();
      int count = 0;
      for(int i =0; i< l; i++){
          if(a.charAt(i) != b.charAt(i))
            count++;
      }
      return count;
  }
}

Measured memory_bytes: 41096
n = int(input())

c = [[0 for i in range(10)] for j in range(10)]

for i in range(n+1):
    if i % 10 == 0:
        continue
    s = str(i)
    a = int(s[0])
    b = int(s[-1])

    c[a][b] += 1

ans = 0

for i in range(10):
    for j in range(10):
        ans += c[i][j] * c[j][i]

print(ans)



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

using namespace std;

int main() {
	int n, s = 0, m = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int l;
		cin >> l;
		s += l;
		m = max(m, l);
	}
	cout << (m + m < s ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 256
def solve():
    A, B, K = map(int, input().split())

    ansA = max(0, A - K)
    if ansA > 0:
        ansB = B
    else:
        ansB = max(0, B - (K - A))

    print(ansA, ansB)
if __name__ == '__main__':
    solve()


Measured memory_bytes: 38384
/* Look for:
* the exact constraints (multiple sets are too slow for n=10^6 :( ) 
* special cases (n=1?)
* overflow (ll vs int?)
* array bounds
* if you have no idea just guess the appropriate well-known algo instead of doing nothing :/
*/

// Author:: Subash Singha Roy
// Institution:: Jalpaiguri Government Engineering College

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define dd double
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define mod (int)(1e9+7)
#define fr(i,a,b) for(ll i=a;i<b;i++)
#define frr(i,a,b) for(ll i=a-1;i>=b;i--)
#define tc(t) int t;cin >>t;while(t--)
#define pb(i) push_back(i)
#define rr return 0
#define mp make_pair
#define pr  pair <ll,ll> 
#define ff first
#define ss second
#define inf 999999999999999999
ll mult(ll a,ll b, ll p=mod){return ((a%p)*(b%p))%p;}
ll add(ll a, ll b, ll p=mod){return (a%p + b%p)%p;}
ll fpow(ll n, ll k, ll p = mod) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n%p; n = n * n%p;} return r;}
ll inv(ll a, ll p = mod) {return fpow(a, p - 2, p);}
bool sa(const pair<int,int> &a,const pair<int,int> &b){return (a.second<b.second);}
bool fd(const pair<int,int> &a,const pair<int,int> &b){return (a.first>b.first);}
bool sd(const pair<int,int> &a,const pair<int,int> &b){return (a.second>b.second);}

int main(){
fio
ll n;
cin>>n;
ll a[n+5],b[n+5],c[n+5];
fr(i,0,n){
    cin>>a[i]>>b[i]>>c[i];
}
ll dp[n+5][4];
dp[0][0]=a[0];
dp[0][1]=b[0];
dp[0][2]=c[0];
fr(i,1,n){
    dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i];
    dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b[i];
    dp[i][2]=max(dp[i-1][1],dp[i-1][0])+c[i];
}
// cout<<dp[n-1][0]<<" ";
// cout<<dp[n-1][1]<<" ";
// cout<<dp[n-1][2]<<" ";
cout<<max(max(dp[n-1][0],dp[n-1][1]),dp[n-1][2]);
rr;}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = 1; i <= n; i++)
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); }
using P = pair <int, int>;
 
ll MOD = 1000000007;
ll INF =1<<29;

int main() {
    string s,t;
    cin >> s>>t;
    if(s.size()==t.size()){
        rep(i,s.size()){
            cout <<s[i]<<t[i];
        }
    }
    else{
         rep(i,s.size()-1){
             cout << s[i]<<t[i];
         }
         cout << s[s.size()-1];
    }
    
}

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

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

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

/**
 * @brief 多次元 vector の作成
 * @author えびちゃん
 */
namespace detail {
    template<typename T, int N>
    auto make_vec(vector<int>& sizes, T const& x) {
        if constexpr (N == 1) {
            return vector(sizes[0], x);
        } else {
            int size = sizes[N-1];
            sizes.pop_back();
            return vector(size, make_vec<T, N-1>(sizes, x));
        }
    }
}
template<typename T, int N>
auto make_vec(int const(&sizes)[N], T const& x = T()) {
    vector<int> s(N);
    for (int i = 0; i < N; ++i) s[i] = sizes[N-i-1];
    return detail::make_vec<T, N>(s, x);
}

__attribute__((constructor))
void fast_io() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

int main() {
    int n, x;
    cin >> n >> x;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    sort(a.begin(), a.end());
    int ans = 0;
    rep(i, n) {
        if (x >= a[i]) {
            ans++;
            x -= a[i];
        }
    }
    if (x != 0 && ans == n) ans--;
    cout << ans << '\n';
}


Measured memory_bytes: 3660
#include <iostream>

using namespace std;

int main() {
    int k, s, cnt = 0;
    cin >> k >> s;
    for (int x = 0; x <= k; ++x)
        for (int y = 0; y <= k; ++y) {
            int z = s - x - y;
            if (z > k) y += z - k - 1;
            else if (z < 0) break;
            else cnt++;
        }
    cout << cnt << endl;
}


Measured memory_bytes: 256