akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h> 
using namespace std;
///////////////////////////////////////////
const long long int INF = INT32_MAX;
const long long int Mod = 1000000007;
const long long int mod = 100000;//10^5
using ll = long long int; //long long int は64bit
using ci = const int; using vi = vector<int>; using Vi = vector<long long int>; using pii = pair<int,int>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(int i=0;i<N;i++)
#define np nullptr
template<class T>bool chmax(T &former, const T &b) { if (former<=b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define fill(x,num) memset(x,num,sizeof(x));
typedef vector<vector<ll> > matrix;
//       cin.tie(0);ios::sync_with_stdio(false);
void cinit(){cin.tie(0);ios::sync_with_stdio(false);}
//////////////////////////^^ *Emile ^^^//////////////////////////////////////////////////////

ll n,m;

int main(){
	cin>>n>>m;
	ll ans = 0;
	if(min(n,m)==1){
		ans += max(m,n)-2;
	}else{
		ans += (m-2)*(n-2);
	}
	if(n==1&&m==1)ans=1;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import bisect
import math
from collections import deque

def sRaw():
    return input().rstrip("\r")


def iRaw():
    return int(input())


def ssRaw():
    return input().split()


def isRaw():
    return list(map(int, ssRaw()))

INF = 1 << 29


def main():
    N,X,Y = isRaw()
    Es = [[1]]+[[n-1,n+1] for n in range(1,N-1)]+[[N-2]]
    Es[X-1].append(Y-1)
    Es[Y-1].append(X-1)
    def shortest(n):
        qu = deque()
        visited = [0]*N
        qu.append(n)
        visited[n]=1
        path =[INF]*N
        path[n]=0
        while len(qu)!=0:
            m = qu.popleft()
            for l in Es[m]:
                if visited[l]!=0:
                    continue
                path[l] = min(path[m]+1,path[l])
                visited[l]=1
                qu.append(l)
        return path
    shortests = [shortest(n) for n in range(N)]
    npathes = [0 for i in range(N-1)]
    for n in range(N):
        for m in range(n+1,N):
            npathes[shortests[n][m]-1]+=1
    return "\n".join([str(a) for a in npathes])

if __name__ == "__main__":
    print(main())


Measured memory_bytes: 76508
import Control.Applicative ((<$>))

solve t (x:xs)
  | xs == [] = [t]
  | t > (head xs) - x = (head xs) - x : solve t xs
  | otherwise = t : solve t xs

main = do
  [n, t] <- fmap read <$> words <$> getLine :: IO [Int]
  ts <- fmap read <$> words <$> getLine :: IO [Int]
  putStrLn (show (sum (solve t ts)))


Measured memory_bytes: 70012
N,M = map(int, input().strip().split())
PS = [input().strip().split() for _ in range(M)]
acset = set()
acc = 0
wacd = {str(i):0 for i in range(1, N+1)}
for p, s in PS:
    if s == "WA" and p not in acset:
        wacd[p] += 1
    if s == "AC" and p not in acset:
        acc += 1
        acset.add(p)
wac = sum([c for i, c in wacd.items() if i in acset])
print(acc, wac)

Measured memory_bytes: 50716
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<math.h>
using namespace std;
int main(void){
	double sum,mostnear;
	bool a[20];
	int n,kyas[20],shiftmax,sssum,ansint,i,j;
	while(1){
		scanf("%d",&n);
		if(n==0)
			break;
		for(i=0;i<n;i++){
			scanf("%d",&kyas[i]);
		}
		sort(kyas,kyas+n);
		sum=0;
		for(i=0;i<n;i++){
			sum+=kyas[i];
		}
		sum/=2;
		mostnear = 2100000000;
		shiftmax = 1<<n;
		for(i=0;i<shiftmax;i++){
			for(j=0;j<n;j++){
				a[j] = i&1<<j;
			}
			sssum=0;
			for(j=0;j<n;j++){
				sssum += a[j]*kyas[j];
			}
			mostnear = mostnear>fabs(sssum-sum) ? fabs(sssum-sum) : mostnear;
		}
		printf("%d\n",(int)(mostnear*2));
	}
	return 0;
}

Measured memory_bytes: 884
import java.util.Scanner;

public class Main {

	public static String Y = "Yes";
	public static String N = "No";
	public static String I = "IMPOSSIBLE";

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		if ((s.charAt(0) == s.charAt(1) && s.charAt(2) == s.charAt(3)
				|| s.charAt(0) == s.charAt(2) && s.charAt(3) == s.charAt(1)
				|| s.charAt(0) == s.charAt(3) && s.charAt(2) == s.charAt(1))
				&& !(s.charAt(0) == s.charAt(1) && s.charAt(1) == s.charAt(2) && s.charAt(2) == s.charAt(3))) {
			out(Y);
		} else {
			out(N);
		}
	}

	/*
	 * 以下メソッド集
	 */
	static int kaijo(int n) {
		if (n == 0 || n == 1) {
			return 1;
		} else {
			return n * kaijo(n - 1);
		}
	}

	static int fib(int n) {
		return (n == 1 || n == 0) ? n : fib(n - 2) + fib(n - 1);
	}

	static long lcm(long m, long n) {

		return m * n / gcd(m, n);
	}

	static int lcm(int m, int n) {

		return m * n / gcd(m, n);
	}

	static long gcd(long a, long b) {
		return (b == 0) ? a : gcd(b, a % b);
	}

	static int gcd(int a, int b) {
		return (b == 0) ? a : gcd(b, a % b);
	}

	static void out(String info) {
		System.out.println(info);
	}

	static void out(int info) {
		System.out.println(info);
	}

	static void out(double info) {
		System.out.println(info);
	}

	static void out(long info) {
		System.out.println(info);
	}
}


Measured memory_bytes: 21844
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

#define MIN_INT -2147483648
#define MAX_INT 2147483647
#define MIN_LONG -9223372036854775808L
#define MAX_LONG 9223372036854775807L
#define PI 3.141592653589793238462643383279502884L

#define long long long int

using std::vector;
using std::map;
using std::set;
using std::string;
using std::pair;
using std::cin;
using std::cout;
using std::cerr;

// @author: pashka

int main() {
    std::ios::sync_with_stdio(false);

    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    map<int, int> cnt;
    for (int x : a) {
        cnt[x]++;
    }
    int res = 0;
    while (cnt.size() > 0) {
        auto p = *cnt.rbegin();
        if (p.second == 0) {
            cnt.erase(p.first);
        } else {
            int x = p.first;
            cnt[x]--;
            for (int q = 0; q < 31; q++) {
                int pp = 1 << q;
                if (pp <= x) continue;
                int y = pp - x;
                if (cnt[y] > 0) {
                    res++;
                    cnt[y]--;
                }
            }
        }
    }
    cout << res << "\n";

    return 0;
}

Measured memory_bytes: 10368
// {{{
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
// }}}

using ll = long long;

ll I, O, T, J, L, S, Z;

int main() {
    cin >> I >> O >> T >> J >> L >> S >> Z;
    ll ans = O + I/2*2 + J/2*2 + L/2*2 + (I%2+J%2+L%2)/3*3;
    if (I > 0 && J > 0 && L > 0) {
        ans = max(ans, O + 3 + (I-1)/2*2 + (J-1)/2*2 + (L-1)/2*2);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <cstdint>
#include <istream>
#include <sstream>
#include <cctype>
#include <functional>
#include <iomanip>
#define rep(i,N) for(ll i=0;i<N;i++)
#define disp(a) cout << a << endl;
#define PI 3.1415926535897932384626433
//cout << fixed << setprecision(20) << ** << endl;
typedef long long ll;
using namespace std;

double deg2rad(double degree)
{
    return degree * PI / 180.0000000000;
}
int main()
{
	ll X,Y,ANS=0;
	cin>>X>>Y;
	if(X==1)ANS=ANS+300000;
	if(Y==1)ANS=ANS+300000;
	if(X==2)ANS=ANS+200000;
	if(Y==2)ANS=ANS+200000;
	if(X==3)ANS=ANS+100000;
	if(Y==3)ANS=ANS+100000;
	if(X==1&&Y==1)ANS=ANS+400000;
	cout<<ANS<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
    int a,b,c,ans;
    cin>>a>>b>>c;
    ans=max({a,b,c})-min({a,b,c});
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll  long long 
#define mp make_pair
#define pb push_back
#define f first
//#define s second
#define mod 1000000007
const ll N=2e5+5;
unordered_map<ll,vector<ll>> adj;
vector<ll> vis(300005,0);
vector<ll> p(100005,0);
ll c[100005];
ll cnt;
ll n;
void dfs(ll node)
{
  if(vis[node])
    return;
  vis[node]=1;
  cnt++;
  for(auto i:adj[node])
    {
      dfs(i);
    }
}
struct range{
  ll l;
  ll r;
  ll index;
};
bool cmp(range& p1,range& p2)
{
     return p1.l<p2.l;
}


int main()
{
   string s;
   cin>>s;
   ll n=s.size();
   n--;
   if(s[n]=='s')
       {
          s+='e';
          s+='s';
       }
      else
      {
        s+='s';
      }
      cout<<s;
}

Measured memory_bytes: 6228
#include <stdio.h>

int calc(int n){
  int diff;
  int c=1;
  while (1) {
    diff=(1000*c)-n;
    if(0<=diff){
      return diff;
    }
    c++;
  }
}

int main(void){
  int N;
  scanf("%d",&N);
  int result = calc(N);
  printf("%d\n",result);
  return 0 ;
}


Measured memory_bytes: 1708
#include<bits/stdc++.h>
#include<math.h>
#define ll long long int
#define ve vector<int>
#define vl vector<long long int>
#define vd vector<double>
#define all(a) a.begin(),a.end()
using namespace std;

ll kaijo(ll x){
  ll A=1;
  if(x=0) A=0;
  for(int i=1;i<=x;i++){
    A*=i;
  }
  return A;
}
int main(){
  double n;
  cin>>n;
  vd x(n),y(n);
  for(int i=0;i<n;i++){
    cin>>x[i]>>y[i];
  }
  int s=n+(n*(n-3))/2;
  vd L(s);
  int t=0;
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      if(i!=j){
        L[t]=sqrt(pow((x[i]-x[j]),2)+pow((y[i]-y[j]),2));
        t++;
      }
    }
  }
  double sum=0;
  for(int i=0;i<s;i++){
    sum+=L[i]*(((kaijo(n-2)*(n-3)+1)+1)/(s*kaijo(n-1)));
  }
  cout<<setprecision(20)<<sum<<endl;
}

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

int main()
{
	int n, m;		//????????°, ??????????????????????????°
	int x[1000];	//x[i] = ??????i+1??§?????????????????????
	int num[1000];	//num[i] = i+1????????????????????????
	int pos;		//pos = ?????¨?????????pos+1????????????.
	int i;			//???????????¨?????°
	
	while( cin >> n >> m ){
		if( n == 0 && m == 0 )
			break;
		for( i = 0; i < n; i++ )
			cin >> x[i];
		for( i = 0; i < m; i++ )
			cin >> num[i];
		
		//??´??????????????????
		pos = 0;
		//m????§?????????????
		for( i = 0; i < m; i++ ){
			pos += num[i];
			pos += x[pos];
			if( pos >= n - 1 )
				break;
		}
		cout << i + 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<numeric>
#include<algorithm>
#include<complex>

using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> price(N,0);
    for(int i=0;i<N;i++){
        cin >> price[i];
    }
    sort(price.begin(),price.end());
    int ans=0;
    for(int i=0;i<N;i++){
        if(i==N-1){
            ans+=price[i]/2;
        }
        else{
            ans+=price[i];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
n, k = [int(x) for x in sys.stdin.readline().split()]
p = [x.strip()[0] for x in sys.stdin.read().split()]
if len(set(p)) < k:
	print 0
	exit()
dic = {}
for x in p:
	dic[x] = dic.get(x, 0) + 1
loop, count = True, 0
while(loop):
	ctr, inc = k, False
	for x, _ in sorted(dic.items(), key=lambda x: x[1], reverse=True):
		if ctr == 0:
			count += 1
			inc = True
			break
		if dic[x] <= 0:
			loop = False
			break
		else:
			dic[x] -= 1
		ctr -= 1
	if ctr != 0:
		loop = False
	elif not inc:
		count += 1
print count

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

int main()
{
    ll n, a, b, res, rem;
    cin >> n >> a >> b;

    res = (n / (a + b)) * a;
    rem = n % (a + b);
    
    if(rem < a)
        res += rem;
    else res += a;

    cout << res << "\n";

    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

int main() {
	int n, k; scanf("%d%d", &n, &k); std::vector<int> vec(n, 0);
	while(n--) {
		int a; scanf("%d", &a);
		
		vec[a - 1]++;
	}
	sort(begin(vec), end(vec)); reverse(begin(vec), end(vec));
	
	int ans = 0;
	for(int i = k; i < vec.size(); i++) ans += vec[i];
	printf("%d\n", ans);
	return 0;
}


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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var nk = ReadInts();
            var h = ReadInts();
            var ans = 0;
            for (int i = 0; i < nk[0]; i++)
            {
                if (h[i] >= nk[1]) ans++;
            }
            WriteLine(ans);
        }
        



        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}

Measured memory_bytes: 18016
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int a[1000001];
main()
{

    long long n,m,sum,p;
    scanf("%lld %lld",&n,&m);
    if (n*2==m)
    {
        sum=n;
    }
    else if (n*2<m)
    {
        p=m-n*2;
        sum=n+p/4;
    }
    else
    {
        sum=m/2;
    }
    printf("%lld\n",sum);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a, b, c, d;
int main() {
    cin >> a >> b >> c >> d;
    if(abs(a-c) <= d || (abs(a-b) <= d && abs(b-c) <= d)) {
        cout << "Yes" << endl;
    }else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
n=int(input())
l=[list(map(int,input().split())) for _ in range(n)]
ct,cx,cy=0,0,0
for t,x,y in l:
    dt=t-ct
    d=abs(cx-x)+abs(cy-y)
    if dt-d<0 or (dt-d)%2==1:
        print('No')
        exit()
    ct,cx,cy=t,x,y
print('Yes')


Measured memory_bytes: 27040
#include <stdio.h>
#include <string>
#include <iostream>
#include <map>
#include <algorithm>
using namespace std;

int main(void){
    int a,b,c;
    cin >> a >> b >> c;
    int ans=(a-b==0)?c:(b-c==0)?a:b;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
# coding:utf-8

INF = float('inf')


def inpl(): return list(map(int, input().split()))


N, T = inpl()
X = []
for i in range(N):
    c, t = inpl()
    X.append([t, c])

X.sort()
ans = INF
for i in range(N):
    if X[i][0] > T:
        break
    if X[i][1] < ans:
        ans = X[i][1]

if ans == INF:
    print('TLE')
else:
    print(ans)


Measured memory_bytes: 3064
#include<stdio.h>
int main(void){
    int H,W;
    while(1){
        scanf("%d%d",&H,&W);
        if(H==0&&W==0){
            break;
        }
    for (int h=1;h<=H;h++){
        for(int w=1;w<=W;w++){
            if(h==1||h==H){
                printf("#");
            }
            else if(h!=1&&h!=H&&w==1||w==W){
                printf("#");
            }
            else{
                printf(".");
            }
        }
        printf("\n");
    }
    printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2100
#include<bits/stdc++.h>
#define ll long long
#define mp make_pair
#define F first
#define S second
#define db double
#define pb push_back
#define rep(i,a,b)  for(ll i=a;i<=b;i++)
using namespace std;
 
 ll mod=998244353;
 
ll expo(ll base,ll exponent,ll mod){
    ll ans=1;
    while(exponent!=0){
        if(exponent&1) ans=(1LL*ans*base)%mod;
        base=(1LL*base*base)%mod;
        exponent>>=1;
    }
    return ans%mod;
}
 
vector<bool>  prime(90000002,true);
void Sieve() 
{ 
   
    for (int p=2; p*p<=90000001; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=90000001; i += p) 
                prime[i] = false; 
        } 
    } 
}

const ll M=200006;
ll f[M],inv[M];

void compute(){
    f[0]=1;
    rep(i,1,M-1){
        f[i]=(1LL*i*f[i-1])%mod;
    }
    inv[M-1]=expo(f[M-1],mod-2,mod);
    for(ll i=M-2;i>=0;i--){
        inv[i]=(1LL*(i+1)*inv[i+1])%mod;
    }
}
ll C(ll n,ll r){
    return (1LL*((1LL*f[n]*inv[r])%mod)*inv[n-r])%mod;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // compute();
    Sieve();
    ll tests=1;
    // cin>>tests;
    while(tests--)
    {
      ll n,i,j;
      cin>>n;
      ll ans=0;
      for(i=2;i<=90000001;i++)
      {
        if(!prime[i]) continue;
        // cout<<i<<"\n";
        ll cnt=0;
        while(n%i==0)
        {
          n=n/i;
          cnt++;
        }
        ll tmp=1;
        while(cnt>0)
        {
          if(cnt-tmp>=0) {ans++;cnt-=tmp;}
          else break;
          tmp++;
        }
        if(n<=1) break;
      }  
      if(n>1) ans++;
      cout<<ans;
    }
    return 0;
   }

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

int n, m;

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

    cout << (n - 1) * (m - 1) << endl;
}

Measured memory_bytes: 256
s = input() #文字列入力
year = int(s[0:4])
month = int(s[5:7])
day = int(s[8:10])

if year > 2019:
    print('TBD')
elif year == 2019:
    if month <= 4:
        print('Heisei')
    else:
        print('TBD')
else:
    print('TBD')

Measured memory_bytes: 3060
#include<stdio.h>
int main()
{
	int t=1;
	//scanf("%d",&t);
	int a[t][3],i,j,max,count=0;
	for(i=0;i<t;i++)
		for(j=0;j<3;j++)
			scanf("%d",&a[i][j]);
	for(i=0;i<t;i++)
	{
		max=a[i][0];
		count=0;
		for(j=0;j<3;j++)
			if(a[i][j]>max)
				max=a[i][j];
		for(j=0;j<3;j++)
			count+=(max-a[i][j]);
		if(count%2==0)
			count=(0.5*count);
		else
			count=(0.5*count)+2;
		printf("%d\n",count);
	}
	return 0;
}
		
			


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

int main(){
  string s;
  cin >> s;

  REP(i,3){
    cout << s[i];
  }

  return 0;
}

Measured memory_bytes: 3592
#!python3.4
# -*- coding: utf-8 -*-
# abc159/abc159_c
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    L = i2n()
    print(L * L * L / 27)
    return

main()


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

int main(){
  string S;
  cin >> S;
  if(S=="RRR"){
    cout << 3 << endl;
  }
  else if(S=="SSS"){
    cout << 0 << endl;
  }
  else if(S=="RSS" || S=="SRS" || S=="SSR" || S=="RSR"){
    cout << 1 << endl;
  }
  else{
    cout << 2 << endl;
  }
}

Measured memory_bytes: 3532
n, m = map(int, input().split())

cnt = {x: 0 for x in range(1, n+1)}

for _ in range(m):
  a, b = map(int, input().split())
  cnt[a] += 1
  cnt[b] += 1

for i in range(1, n+1):
  print(cnt[i])

Measured memory_bytes: 3060
def main():
  import sys
  from heapq import heappush as hpush, heappop as hpop
  input = sys.stdin.readline
  
  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()))
  A.sort(reverse = True)
  B.sort(reverse = True)
  C.sort(reverse = True)
  
  memo = set([(0, 0, 0)])
  h = [(-(A[0]+B[0]+C[0]), (0, 0, 0))]
  for _ in range(K):
    val, (i,j,k) = hpop(h)
    if i+1 < len(A) and (i+1, j, k) not in memo:
      hpush(h, (-(A[i+1]+B[j]+C[k]), (i+1, j, k)))
      memo.add((i+1, j, k))
    if j+1 < len(B) and (i, j+1, k) not in memo:
      hpush(h, (-(A[i]+B[j+1]+C[k]), (i, j+1, k)))
      memo.add((i, j+1, k))
    if k+1 < len(C) and (i, j, k+1) not in memo:
      hpush(h, (-(A[i]+B[j]+C[k+1]), (i, j, k+1)))
      memo.add((i, j, k+1))
    print(-val)

if __name__ == "__main__":
  main()

Measured memory_bytes: 5104
//Date: 17 - 02 - 18	//Author : Rishabh Paul

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<float.h>
#include<math.h>
#include<inttypes.h>
#include<assert.h>
#include<ctype.h>
#include<limits.h>
#include<time.h>
#define ll long long
#define For(i,n)	for(int i=0;i<n;i++)
#define rep(i ,a ,b)	for(int i=(a);i<=(b);i++)
#define mset(a ,value)	memset(a ,value ,sizeof(a))
#define s(a)	scanf("%d" ,&a);
#define ls(a)	scanf("%ld" ,&a)
#define reg(i)	register int i
#define infinite INT_MAX
#define MAX 100005
#define NIL -1
ll min(ll a,ll b){	return (a<b?a:b);	}
ll max(ll a,ll b){	return (a>b?a:b);	}
int a[101];
int cmp(const void *a,const void *b){
	int *a1 = (int *)a;
	int *b1 = (int *)b;
	if((*a1) < (*b1))	return 1;
	if((*a1) == (*b1))	return 0;
	return -1;
	}
int main(){
	int n;
	s(n);	
	For(i ,n)	s(a[i]);
	qsort(a ,n ,sizeof(a[0]) ,cmp);
	int A = 0 ,B = 0;
	For(i ,n){
		if(i & 1)	B += a[i];
		else A += a[i];
	}
	printf("%d" ,A - B);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define PI 3.14159265358979323
#define ll long long int
#define vi vector <int>
#define vl vector <ll>
#define all(v) (v).begin(),(v).end()
#define pb push_back
 
ll power(ll a, ll b){//a^b
    ll res=1;
    while(b>0){
        if(b&1){res=(res*a);b--;}
        a=(a*a);
        b>>=1;
    }
    return res;
}

ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
vl mp(1000006,0);
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;
	cin>>n;
	vl v(n);
	for(ll i=0;i<n;i++){
		cin>>v[i];
		mp[v[i]]++;
	}
	ll c=0;
	for(ll i=0;i<n;i++){
		ll d=v[i];
		mp[d]--;
		int f=0;
		for(ll j=1;j*j<=d;j++){
			if(d%j==0){
				if(mp[j]>0||mp[d/j]>0){
					f=1;
					break;
				}
			}
		}
		mp[d]++;
		if(f==0)
			c++;
	}
	cout<<c<<"\n";	
}

Measured memory_bytes: 12700
import sys

line = list(map(int,input().split()))

if line[0] - line[1] >= 2:
	ans = 2*line[0] - 1	
elif line[1] - line[0] >= 2:
	ans = 2*line[1] - 1
else:
	ans = line[0] + line[1]

print(ans)


Measured memory_bytes: 2940
#include <vector>
#include <deque>
#include <iostream>
#include <functional>

using namespace std;

void topological_sort(vector<vector<int>> G, deque<int>& ans) {
    vector<bool> seen(G.size());

    function<void(int)> visit;
    visit = [&](auto key) {
        if (seen[key])
            return;
        seen[key] = true;
        for (auto x : G[key]) {
            if (seen[x]) {
                continue;
            }
            visit(x);
        }
        ans.push_front(key);
    };

    for (int i = 0; i < G.size(); ++i) {
        visit(i);
    }
}

int main() {
    int V, E;
    cin >> V >> E;
    vector<vector<int>> G(V);
    for (int i = 0; i < E; ++i) {
        int s, t;
        cin >> s >> t;
        G[s].push_back(t);
    }

    deque<int> ans;
    topological_sort(G, ans);
    for (auto x : ans) {
        cout << x << endl;
    }

    return 0;
}

Measured memory_bytes: 4120
from collections import Counter

N = int(input())
As = list(map(lambda x: int(x), input().split(" ")))
c = Counter(As)

sum_a = sum(As)

Q = int(input())
for _ in range(Q):
    B, C = map(lambda x: int(x), input().split(" "))
    change_count = c[B]
    sum_a -= change_count * B
    c[B] = 0
    sum_a += change_count * C

    if C in c:
        c[C] += change_count
    else:
        c[C] = change_count

    print(sum_a)


Measured memory_bytes: 24156
from math import sqrt

num = input().split()
number, dim = int(num[0]), int(num[1])
dots = [input().split() for i in range(number)]

tmp = []
count = 0

for i in range(len(dots)):
  for j in range(i+1,len(dots)):
    ans = [(int(dots[i][k])-int(dots[j][k]))**2 for k in range(dim)]
    tmp.append(sqrt(sum(ans)))
    
for item in tmp:
  if item-int(item)==0:
    count += 1
    
print(count)

Measured memory_bytes: 3064
from math import ceil, floor

q = int(input())
ab = [list(map(int, input().split())) for _ in range(q)]


def f(a, b, x):
    return (a + x - 1) * (b - x + 1)


def get_mx(a, b, num):
    tmp = (b - a + 2) / 2
    lx = max(1, floor(tmp))
    rx = min(num, ceil(tmp))
    mx = max(f(a, b, lx), f(a, b, rx))
    return mx


def check(a, b, num):
    mx = 1
    a, b = min(a, b), max(a, b)
    if num < a:
        mx = max(mx, get_mx(1, num, num))
    elif a <= num < b:
        mx = max(mx, get_mx(1, num, a - 1))
        mx = max(mx, get_mx(a + 1, num - a + 1, num - a + 1))
    elif num >= b:
        if num - b + 1 > a - 1:
            mx = max(mx, get_mx(1, num + 1, a - 1))
            mx = max(mx, get_mx(a + 1, num - a - 2, num - a - b + 2))
            mx = max(mx, get_mx(num - b - 2, b - 1, b - 1))
        elif num - b + 1 == a - 1:
            mx = max(mx, get_mx(1, num + 1, a - 1))
            mx = max(mx, get_mx(a + 1, b - 1, b - 1))
        else:
            mx = max(mx, get_mx(1, num + 1, num - b + 1))
            mx = max(mx, get_mx(num - b + 2, b - 1, a + b - num - 2))
            mx = max(mx, get_mx(a + 1, num - a + 1, num - a + 1))

    if mx < a * b:
        return True

    return False


for a, b in ab:
    if a == b:
        print(2 * a - 2)
        continue
    l = 0
    r = 10 ** 10
    while r - l > 1:
        m = (l + r) // 2
        if check(a, b, m):
            l = m
        else:
            r = m

    print(l)


Measured memory_bytes: 3192
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
namespace mydef {
const int INF = 1ll << 60;
const int MOD = 1e9 + 7;
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
void Yes(bool flag = true) {
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
void No(bool flag = true) {
    Yes(!flag);
}
void YES(bool flag = true) {
    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}
void NO(bool flag = true) {
    YES(!flag);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
bool dbg = false;
}  // namespace mydef
using namespace mydef;
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<pair<int, int>>
#define vvp vector<vector<pair<int, int>>>
#define pi pair<int, int>
//#define P pair<int, int>
//#define V vector<int>
//#define S set<int>
#define asn ans

string S, T;

void solve() {
    int ans = INF;
    for (int i = 0; i <= S.size() - T.size(); i++) {
        int tmp = 0;
        for (int j = 0; j < T.size(); j++) {
            if (S[i + j] != T[j])
                tmp++;
        }
        chmin(ans, tmp);
    }
    cout << ans << endl;
}

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

    cin >> S >> T;

    solve();
    return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

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

    int sum[n];
  	sum[0]=a[0];
    for(int i = 1; i<n;i++)
        sum[i] = sum[i - 1] + a[i];

    int mini = sum[n-1];
    for(int i = 0; i <n; i++)
    {
        mini = min(mini, abs(sum[n-1] - 2*sum[i]));
    }

    cout << mini;
    return 0;
}


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


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

    string s;
    cin>>s;
    int n=s.size();
    bool pos=true;
    if(s[n-1]=='1' || s[0]=='0') pos=false;
    for(int i=0;i<n-1;i++){
        if(s[i]=='1' && s[n-2-i]=='0') pos=false;
    }
    if(!pos){
        cout<<-1<<endl;
        return 0;
    }
    queue<int> qu;
    for(int i=0;i<n;i++){
        if(s[i]=='1')qu.push(i+1);
    }
    qu.push(n);
    for(int i=1;i<n;i++){
        if(i==qu.front()){
            qu.pop();
        }
        cout<<i<<" "<<qu.front()<<endl;
    }

}

Measured memory_bytes: 1872
n = int(input())
a = list(map(int,input().split()))
flag = True
ret = 0
while flag:
    flag=False
    for j in range(1,n)[::-1]:
        if a[j-1] > a[j]:
            a[j],a[j-1]=a[j-1],a[j]
            flag=True
            ret += 1
print(" ".join(map(str,a)))
print(ret)



Measured memory_bytes: 5600
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
#include<time.h>
#include<cassert>

using namespace std;
#define ll long long
#define ld long double
#define int long long
#define all(a) (a).begin(),(a).end()
#define EPS (1e-13)
#define fs first
#define sc second
#define xx first
#define yy second.first
#define zz second.second
#define H pair<int, int>
#define P pair<int, pair<int, int>>
#define Q(i,j,k) mkp(i,mkp(j,k))
#define rep(i,n) for(int (i) = 0 ; (i) < (n) ; (i)++)
#define mkp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define crdcomp(b) sort(all((b)));(b).erase(unique(all((b))),(b).end())
const int Mod = 1e9 + 7;
const int mod = 998244353;
const ll Inf = 3 * 1e18;
const int inf = 15 * 1e8;
ll read() {
	ll u, k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}
ll bcount(ll x) {
	int sum = 0;
	for (int i = 0; i < 20; i++)
		if ((1ll << i) & x) sum++;
	return sum;
}
/*const int fn_ = 2000000;
ll fact_[fn_], comp_[fn_];
ll comb(ll x, ll y, ll mod = Mod) {
	if (!fact_[0]) {
		fact_[0] = 1; comp_[0] = 1;
		for (int i = 1; i < fn_; i++) {
			fact_[i] = fact_[i - 1] * i % mod;
			comp_[i] = mod_pow(fact_[i], mod - 2, mod);
		}
	}
	if (x < y) return 0;
	return fact_[x] * comp_[x - y] % mod * comp_[y] % mod;
}*/
//---------------------------------------------------
int n, m, l, q;
int a[400][400];
int b[400][400];
signed main() {
	cin >> n >> m >> l;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			b[i][j] = inf;
			a[i][j] = inf;
		}
		b[i][i] = 0;
	}
	for (int i = 0; i < m; i++) {
		int u, v, r;
		cin >> u >> v >> r;
		b[u][v] = r;
		b[v][u] = r;
	}
	for (int k = 1; k <= n; k++) {
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= n; j++) {
				b[i][j] = min(b[i][j], b[i][k] + b[k][j]);
			}
		}
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			if (b[i][j] <= l) a[i][j] = 1;
		}
		a[i][i] = 0;
	}
	for (int k = 1; k <= n; k++) {
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= n; j++) {
				a[i][j] = min(a[i][j], a[i][k] + a[k][j]);
			}
		}
	}
	cin >> q;
	for (int i = 0; i < q; i++) {
		int u, v;
		cin >> u >> v;
		if (a[u][v] == inf) cout << -1 << endl;
		else cout << a[u][v] - 1 << endl;
	}
}


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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()

void solve() {
  int n, m;
  cin >> n >> m;
  cout << abs((n - 2) * (m - 2)) << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) solve();
}


Measured memory_bytes: 3640
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)

func main() {
	in := bufio.NewReader(os.Stdin)
	var n, p int
	fmt.Fscanf(in, "%d %d\n", &n, &p)

	if n == 1 {
		fmt.Println(p)
		return
	}
	result := 1
	for value, count := range Factoring(p, 2) {
		result *= int(math.Pow(float64(value), float64(count/n)))
	}
	fmt.Println(result)
}

func Factoring(num , pnum int) map[int]int{
	result := make(map[int]int)
	if pnum * pnum > num {
		if num != 1 {
			result[num] += 1
		}
		return result
	}

	if num % pnum == 0 {
		num /= pnum
		result[pnum] ++
	} else {
		pnum ++
	}
	return merge(result , Factoring(num, pnum))
}

func merge(m1, m2 map[int]int) map[int]int {
	ans := map[int]int{}
	for k, v := range m1 {
		ans[k] += v
	}
	for k, v := range m2 {
		ans[k] += v
	}
	return ans
}


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

h = list(map(int, input().split()))

c = 0
i = 0

while sum(h) > 0:
    if h[i] > 0:
        j = i
        c = c + 1
        while j < n and h[j] > 0:
            h[j] = h[j] - 1
            j = j + 1
    else:
        i = i + 1

print(c)

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

const int MAX_N = 200005;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
} comb(MAX_N);

vector<int> to[MAX_N];

struct DP {
  mint dp;
  int t;
  DP(mint dp=1, int t=0):dp(dp),t(t) {}
  DP& operator+=(const DP& a) {
    dp *= a.dp;
    dp *= comb(t+a.t, t);
    t += a.t;
    return *this;
  }
  DP operator-(const DP& a) const {
    DP res(*this);
    res.t -= a.t;
    res.dp /= comb(res.t+a.t, res.t);
    res.dp /= a.dp;
    return res;
  }
  DP addRoot() const {
    DP res(*this);
    res.t++;
    return res;
  }
};

vector<DP> dp[MAX_N];
DP dpSum[MAX_N];

DP dfs(int v, int p=-1) {
  // dpSum[v] = DP(1,0);
  dp[v] = vector<DP>(to[v].size());
  rep(i,to[v].size()) {
    int u = to[v][i];
    if (u == p) continue;
    dp[v][i] = dfs(u,v);
    dpSum[v] += dp[v][i];
  }
  return dpSum[v].addRoot();
}
void bfs(int v, const DP& dpP=DP(), int p=-1) {
  if (p != -1) dpSum[v] += dpP.addRoot();
  rep(i,to[v].size()) {
    int u = to[v][i];
    if (u == p) continue;
    bfs(u, dpSum[v] - dp[v][i], v);
  }
}

int main() {
  int n;
  cin >> n;
  rep(i,n-1) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  dfs(0);
  bfs(0);
  rep(i,n) {
    cout << dpSum[i].addRoot().dp << endl;
  }
  return 0;
}


Measured memory_bytes: 34292
H, W, D = map(int, input().split())
XY = [0] * (H * W)
for X in range(H):
    for Y, A in enumerate(map(int, input().split())):
        XY[A - 1] = (X, Y)
Q = int(input())
LR = []
for _ in range(Q):
    LR.append(list(map(int, input().split())))

toD = [0] * (H * W)
for i, (a, b) in enumerate(zip(XY, XY[D:]), D):
    toD[i] = abs(a[0] - b[0]) + abs(a[1] - b[1])

from itertools import accumulate
acc = [0] * (H * W)
for i in range(D):
    acc[i::D] = accumulate(toD[i::D])

for l, r in LR:
    ans = acc[r - 1] - acc[l - 1]
    print(ans)


Measured memory_bytes: 40136
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl


int main(){
    string s;
    cin >> s;

    int n = s.size();
    ll ans = 0;
    string prev = "";
    for(int i = 0; i < n; i++){
        string t = "";
        t += s[i];
        if(prev == t){
            if(i==n-1){break;}
            prev = s[i]+s[i+1];
            i++;
        }else{
            prev = s[i];
        }
        ans++;
    }

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


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

int main()
{
    int n, m, x, y;
    cin >> n >> m >> x >> y;
    int xmax = -101;
    int ymax = 101;
    for (int i = 0; i < n; i++) {
        int xi;
        cin >> xi;
        xmax = max(xmax, xi);
    }
    for (int i = 0; i < m; i++) {
        int yi;
        cin >> yi;
        ymax = min(ymax, yi);
    }
    for (int i = xmax + 1; i <= ymax; i++) {
        if (x < i && i <= y) {
            cout << "No War" << endl;
            return 0;
        }
    }
    cout << "War" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

            int max = 0;
            for (int i = 1; i * i <= N; i++) {
                max = i * i;
            }

            System.out.println(max);
        }
    }
}


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

int main(){
    int W,H,x,y,r;
    cin>>W>>H>>x>>y>>r;
    string ans="Yes";
    if(x-r<0 || y-r<0 || x+r>W || y+r>H)ans="No";
    cout<<ans<<endl;
}


Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

int main() {
  string s;
  cin >> s;
  if (s == "ABC") cout << "ARC" << endl;
  else cout << "ABC" << endl;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define Would
#define you
#define please

int main() {
	//おまじない
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	string S;
	cin >> S;

	int kotae = 700;
	rep(i,3) if(S[i] == 'o') kotae += 100;
	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 256
from collections import deque
ov = deque([0])
n = int(input())
e = [[int(_)-1 for _ in input().split()] for __ in range(n-1)]
c = sorted([int(_) for _ in input().split()])
m = sum(c[:-1])
d = [0 for _ in range(n)]
adv = [[] for _ in range(n)]
for i in range(n-1):
    adv[e[i][0]].append(e[i][1])
    adv[e[i][1]].append(e[i][0])
while len(ov) > 0:
    i = ov.popleft()
    d[i] = c.pop()
    for j in range(len(adv[i])):
        if d[adv[i][j]] == 0:
            ov.append(adv[i][j])
print(m); print(' '.join([str(_) for _ in d]))

Measured memory_bytes: 7516
X, N = (int(s) for s in input().rstrip().split())
if N == 0:
  nums = []
else:
  nums = [int(s) for s in input().rstrip().split()]

def find(nums, X):
  if not nums:
    return X
  if X not in nums:
    return X
  for i in range(1, X + 1):
    X_plus = X + i
    X_minus = X - i
    
    if X_minus not in nums:
      return X_minus
    if X_plus not in nums:
      return X_plus

print(find(nums, X))

Measured memory_bytes: 9208
#include <stdio.h>
 
#define N 2000000
#define INF -1000000
 
int size, stuck[N];
 
void increaseKey(int i, int key) {
    int tmp;
    if (key < stuck[i]) return;
    stuck[i] = key;
    while(i>1 && stuck[i/2]<stuck[i]) {
        tmp = stuck[i];
        stuck[i] = stuck[i/2];
        stuck[i/2] = tmp;
        i=i/2;
    }
}
 
void maxHeapify(int i) {
    int l,r,max;
    int tmp;
 
    l = i*2;
    r = i*2+1;
 
    if (l <= size && stuck[l] > stuck[i]) max = l;
    else max = i;
    if (r <= size && stuck[r] > stuck[max]) max = r;
 
    if (max != i) {
        tmp = stuck[i];
        stuck[i] = stuck[max];
        stuck[max] = tmp;
        maxHeapify(max);
    }
}
 
void insert(int key) {
    size++;
    stuck[size] = INF;
    increaseKey(size, key);
}
 
int extract() {
    int max;
    if (size < 1) return INF;
    max = stuck[1];
    stuck[1] = stuck[size--];
    maxHeapify(1);
    return max;
}
 
int main() {
    int k;
    char com[10];
 
    while (1) {
        scanf("%s", com);
        if (com[0] == 'e' && com[1] == 'n') break;
        if (com[0] == 'i') {
            scanf("%d", &k);
            insert(k);
        } else {
            printf("%d\n", extract());
        }
    }
 
    return 0;
}

Measured memory_bytes: 4700
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <math.h>
#include <string>
using namespace std;

int main () { 
// Baca bilangan
    /*double x; cin >> x;
    int fl = floor(x); // Masih Double
    int cl = ceil(x); // Masih Double
   
    cout << fl << " " << cl << "\n";*/
   
    // Looping FOR
   
   
    /*int n; cin >> n;
   
    for(int j = 1; j <= n; j++){
        // -------------------------
        // Print 1 baris N buah bintang
        for(int i = 1; i <= n; i++){
            cout << "*";
        }
        cout << "\n";
        // -------------------------
    }*/
//  int n,sum = 0, j;
//  cin >> n;
//  for(int k = 1; k <= n; k++ ){
//      cin >> j;
//  sum = sum + j
 
    //int x;
    //cin >> x;
    //for(int n = x ; n >= 1; n--){
    //if (x % n == 0){
    //cout << n << "\n";
    //}
//  }
 
////    int x,y,a;
////    cin >> a;
////    for(int i=0; i < a; i++){
//  //  cin >> x >> y;
////    if(x > y)
//  //  cout << ">"<< "\n";
////    if(x < y)
//  //  cout << "<" << "\n";
//  //if(x == y)
//  //  cout << "=" << "\n";
//}
////
//string x,y,a;
//x = "Hajj";
//y = "Umrah";
//int NoKasus = 1;
//while(cin >> a){
//  if (a==x)
//      cout << "Case" << " " << NoKasus << ":" << " " << "Hajj-e-Akbar"<< "\n";
//  if (a==y)
//      cout << "Case" << " " << NoKasus << ":" << " " << "Hajj-e-Asghar"<< "\n";
//  if(a== "*")
//      break;
//      NoKasus++;
//}
//string s;
//int NoKasus = 1;
//while(cin>>s){
//  if(s=="HELLO")
//      cout << "Case "<< NoKasus << ": " << "ENGLISH" << "\n";
//  else if(s=="HOLA")
//      cout << "Case "<< NoKasus << ": " << "SPANISH" << "\n";
//  else if(s=="HALLO")
//      cout << "Case "<< NoKasus << ": " << "GERMAN" << "\n";
//  else if(s=="BONJOUR")
//      cout << "Case "<< NoKasus << ": " << "FRENCH" << "\n";
//  else if(s=="CIAO")
//      cout << "Case "<< NoKasus << ": " << "ITALIAN" << "\n";
//  else if(s== "ZDRAVSTVUJTE")
//      cout << "Case "<< NoKasus << ": " << "RUSSIAN" << "\n";
//  else if(s== "#")
//      break;
//  else
//      cout << "Case "<< NoKasus << ": " << "UNKNOWN" << "\n";
//  NoKasus++;
//}

//	int n,k; cin>> n >>k;
//	for(int i = 1; i <= n; i++){
//	if (i % k == 0){
//	}
//	cout << "i\n";
//	cout << "*";
//	cout << "\n";
//	}

//int x;
//cin >> x;
//if (x == 2)
//	cout << "NO" << "\n";
//else if (x % 2 == 0)
//	cout << "YES" << "\n";
//else if (x % 2 == 1)
//	cout << "NO" << "\n";
	
//int a,b,c; cin >> a >> b >> c;
//for (int i = 1; i<=a; i++)
//if ()x

//string s;
//getline(cin, s);
//cout << s << endl;
	
int x;
	cin >> x;
	if (x == 3){
		cout << "YES" << endl;
	}else if (x== 5){
		cout << "YES" << endl;
	}else if (x == 7){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}	
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

int main(){
    string s, t;
    cin >> s >> t;
    int slen = s.size(), tlen = t.size(), check=-1;
    rep(i,slen-tlen+1){
        bool flag=true;
        rep2(j, i, i+tlen){
            if(s[j]!='?'&&s[j]!=t[j-i]){
                flag = false;
                break;
            }
        }
        if(flag){
            check=i;
        }
    }
    if(check==-1){
        cout << "UNRESTORABLE" << endl;
        return 0;
    }
    rep(i, slen){
        if(s[i]!='?'){
            cout << s[i];
        }else{
            if(check<=i&&i<check+tlen){
                cout << t[i-check];
            }else{
                cout << 'a';
            }
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3556
import java.math.BigDecimal
import java.util.*

fun toSumOfNumbers(n: BigDecimal): BigDecimal {

    tailrec fun toSumOfNumbers(acc: BigDecimal, n: BigDecimal): BigDecimal {
        return if (n == BigDecimal.ZERO) acc
        else toSumOfNumbers(acc + n % BigDecimal.TEN, n.divideToIntegralValue(BigDecimal.TEN))
    }

    return toSumOfNumbers(BigDecimal.ZERO, n)
}

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    val list = mutableListOf<BigDecimal>()
    while (true) {
        val x = scanner.nextBigDecimal()
        if (x == BigDecimal.ZERO) {
            break
        }
        list.add(x)
    }
    list.forEach {
        println(toSumOfNumbers(it))
    }
}



Measured memory_bytes: 70096
n,m = map(int,input().split())
hyoko = list(map(int,input().split()))
road=[list(map(int,input().split())) for i in range(m)]
ans=[1]*n

for j in road:
    a, b = j
    if hyoko[a-1] > hyoko[b-1]:
        ans[b-1] = 0
    elif hyoko[a-1] == hyoko[b-1]:
        ans[a-1] = 0
        ans[b-1] = 0
    else:
        ans[a-1] = 0
print(sum(ans))

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

int main() {
  string S;
  int64_t K;
  cin >> S >> K;
  
  int ans =1;
  int N = S.size();
  for(int i=0; i<N; i++){
    if(S.at(i)!='1' && i<K){
      ans = 0;
      cout << S.at(i) << endl;
      break;
    }
  }
  
  if(ans)cout << ans << endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define FOR(i,x,y) for(int i=(x),i##END=(y);i<=i##END;++i)
#define DOR(i,x,y) for(int i=(x),i##END=(y);i>=i##END;--i)
template<typename T,typename _T>inline bool chk_min(T &x,const _T y){return y<x?x=y,1:0;}
template<typename T,typename _T>inline bool chk_max(T &x,const _T y){return x<y?x=y,1:0;}
typedef long long ll;
const int N=2e5+5;
int a[N],col[N];
int n,m;

int main()
{
	scanf("%d",&n);
	FOR(i,1,n)scanf("%d",&a[i]);
	DOR(i,n,1)
	{
		bool res=0;
		for(int j=i+i;j<=n;j+=i)
			res^=col[j];
		if(res^a[i])col[i]=1,m++;
		else col[i]=0;
	}
	printf("%d\n",m);
	if(m)
	{
		bool flg=0;
		FOR(i,1,n)if(col[i])
		{
			if(flg)printf(" ");
			flg=1;
			printf("%d",i);
		}
	}
	return 0;
}


Measured memory_bytes: 2432