akhauriyash/Code-Regression huggingface dataset:
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

n, h, w= map(int, input().split())
count = 0
for i in range(n):
    a, b = map(int, input().split())
    aa = a // h
    bb = b // w
    if aa > 0 and bb > 0:
        count += min(aa, bb)

print(count)


Measured memory_bytes: 6736
import sys

init = ''.join(sys.stdin.read().split())

# Bidirectional search using breadth-first search
def solve(start, goal):
    if start == goal:
        return 0
    generated_state = {start: 0, goal: 1}   # 0: foreward, 1: backward
    step = {start: 0, goal: 0}
    s = 0
    c_d = [(start, 0), (goal, 1)] # configure and direction
    while True:
        q = iter(c_d)
        c_d = []
        s += 1
        for c, d in q:
            i = c.find('0')
            if 0 <= i <= 5:
                t = str.maketrans('0' + c[i+3], c[i+3] + '0')
                t_c = c.translate(t)
                if t_c in generated_state:
                    if generated_state[t_c] != d:
                        return s + step[t_c]
                else:
                    generated_state[t_c] = d
                    step[t_c] = s
                    c_d.append((t_c, d))
            if i >= 3:
                t = str.maketrans('0' + c[i-3], c[i-3] + '0')
                t_c = c.translate(t)
                if t_c in generated_state:
                    if generated_state[t_c] != d:
                        return s + step[t_c]
                else:
                    generated_state[t_c] = d
                    step[t_c] = s
                    c_d.append((t_c, d))
            if i == 0 or i == 1 or i == 3 or i == 4 or i == 6 or i == 7:
                t = str.maketrans('0' + c[i+1], c[i+1] + '0')
                t_c = c.translate(t)
                if t_c in generated_state:
                    if generated_state[t_c] != d:
                        return s + step[t_c]
                else:
                    generated_state[t_c] = d
                    step[t_c] = s
                    c_d.append((t_c, d))
            if i == 1 or i == 2 or i == 4 or i == 5 or i == 7 or i == 8:
                t = str.maketrans('0' + c[i-1], c[i-1] + '0')
                t_c = c.translate(t)
                if t_c in generated_state:
                    if generated_state[t_c] != d:
                        return s + step[t_c]
                else:
                    generated_state[t_c] = d
                    step[t_c] = s
                    c_d.append((t_c, d))

print(solve(init, '123456780'))

Measured memory_bytes: 10724
#include<stdio.h>

int main(){

  int num;
  int G[100][100];
  int L,k,v,i,j;

  scanf("%d",&num);

  for(i=0; i<num; i++)
    for(j=0; j<num; j++)
      G[i][j] = 0;
    
  // printf("%d\n",num);

  for(i=0; i<num; i++){
    scanf("%d%d",&v,&k);
    if(k!=0){
      for(j=0; j<k; j++){
	scanf("%d",&L);
	G[L-1][v-1] = 1;
      }
    }
  }
 
  for(i=0; i<num; i++){
    for(j=0; j<num; j++){
      if(j!=num-1){
	printf("%d ",G[j][i]);
      }
      else printf("%d",G[j][i]);
    }
    printf("\n");
  }
  //printf("akak\n");
  return 0;

}

Measured memory_bytes: 636
#include<stdio.h>
#include<algorithm>
#include<queue>
#include<vector>
#include<set>
using namespace std;
int n;
int ret=0;
set<vector<int> >S;
inline int ABS(int a){return max(a,-a);}
void dfs(vector<int>a,int b,int last){
	if(b>=ret)return;
	//std::sort(a.begin(),a.end());
	//if(S.count(a))return;
	//S.insert(a);
	int sz=a.size();
	int mv=0;
	for(int i=0;i<sz;i++){
		if(a[i]==n){ret=b;return;}
		mv=max(mv,a[i]);
	}
	if(b==ret-1)return;
	if((mv<<(ret-b-1))<n)return;
	for(int i=0;i<sz;i++){
		for(int j=0;j<sz;j++){
			if(a[i]+a[j]==n||ABS(a[i]-a[j])==n){ret=b+1;return;}
		}
	}
	vector<int>vis;
	for(int i=sz-1;i>=0;i--)for(int j=i;j>=0;j--){
		if(a[i]!=last&&a[j]!=last)continue;
		bool ok=true;
		for(int k=0;k<sz;k++)if(a[i]+a[j]==a[k]){ok=false;break;}
		for(int k=0;k<vis.size();k++)if(vis[k]==a[i]+a[j]){ok=false;break;}
		if(ok){
			a.push_back(a[i]+a[j]);
			vis.push_back(a[i]+a[j]);
			dfs(a,b+1,a[i]+a[j]);
			a.pop_back();
		}
		ok=true;
		if(a[i]==a[j])continue;
		for(int k=0;k<sz;k++)if(ABS(a[i]-a[j])==a[k]){ok=false;break;}
		for(int k=0;k<vis.size();k++)if(vis[k]==ABS(a[i]-a[j])){ok=false;break;}
		if(ok){
			a.push_back(ABS(a[i]-a[j]));
			vis.push_back(ABS(a[i]-a[j]));
			dfs(a,b+1,ABS(a[i]-a[j]));
			a.pop_back();
		}
	}
}
int main(){
	int a;
	while(scanf("%d",&a),a){
		S.clear();
		n=a;
		int c=a;
		ret=0;
		while(c){
			if(c%2)ret++;
			ret++;
			c/=2;
		}
		ret-=2;
		ret=min(ret,13);
		vector<int>st;
		st.push_back(1);
		dfs(st,0,1);
		printf("%d\n",ret);
	}
}

Measured memory_bytes: 1056
#include <stdio.h>

int main(){
  int n,a,b;
  scanf("%d %d %d",&n,&a,&b,stdin);
  int answer = 0;
  int sum;
  for(int i = 1; i <= n; ++i){
    sum = i % 10 + (i/10) % 10 + (i/100) % 10 + (i/1000) % 10 + (i/10000) % 10;
    if(a <= sum && sum <= b) answer += i;
  }
  printf("%d\n",answer);
  return 0;
}

Measured memory_bytes: 128
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
 
public class Main implements Runnable {
	
    public static void main(String[] args) {
    	new Thread(null, new Main(), "", 16 * 1024 * 1024).start();
    }
    
    public void run() {
        FastScanner sc = new FastScanner();
        
        int n = sc.nextInt();
        
        int lcm = 1;
        for(int i=0;i<n;i++){
        	lcm = lcm(lcm,sc.nextInt());
        }
        
        System.out.println(lcm);
    }
    
	//2整数の最大公約数を求める。（ユークリッドの互除法）
	static int gcd(int a, int b){
	     if(b == 0){
	    	 return a;
	     }
	     return gcd(b, a%b);
	}
	// 互いに素かどうか
	static boolean isCoprime(int n, int m) {
		return gcd(n, m) == 0;
	}
	 
	//2整数の最小公倍数を求める（gcdが必要）
	 static int lcm(int a, int b){
		 int g = gcd(a, b);
		 return a * b / g;
	 }
	 
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}
	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}
	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}
	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}
	public int[] nextIntArray(int n){
		int[] a = new int[n];
		for(int i=0;i<n;i++){
			a[i] = nextInt();
		}
		return a;
	}
	public Integer[] nextIntegerArray(int n){
		Integer[] a = new Integer[n];
		for(int i=0;i<n;i++){
			a[i] = nextInt();
		}
		return a;
	}
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


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

int main() {
	int n,q;

	scanf("%d %d",&n,&q);

	int a[n],b[q+1],c[q+1];
	memset(a,0,sizeof(a));
	string s;

	cin>>s;

	for(int i=1; i<=q; i++) {
		int x,y;
		scanf("%d %d",&x,&y);
		b[i]=x;
		c[i]=y;
	}

	for(int i=1; i<n; i++) {
		if(i-1>n) {
			a[i]=0;
		} else {
			if(s[i-1]=='A'&&s[i]=='C') {
				a[i]=1;
			}
		}
	}
	int sum=0;
	for(int i=0; i<n; i++) {
		sum+=a[i];
		a[i]=sum;
	}
	for(int i=1; i<=q; i++) {
		printf("%d\n",a[c[i]-1]-a[b[i]-1]);
	}

	return 0;
}

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

#define rep(i,x,y) for(ll i=(x);i<(y);i++)
#define rrep(i,x,y) for(ll i=(ll)(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
#ifdef LOCAL
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define dassert(...) assert(__VA_ARGS__)
#else
#define dump(x)
#define debug(x)
#define dassert(...)
#endif
//#define int long long

typedef long long ll;
const ll MOD = 1e9 + 7;
const long double EPS = 1e-8;

void solve(long long N, std::vector<long long> A){
    vector<vector<ll>> dp(2001, vector<ll>(2001, 0));
    vector<pair<ll, int>> a(N);
    rep(i,0,N) a[i] = {A[i], i};
    sort(all(a), greater<>());
    ll answer = 0;
    rep(i,0,N+1) rep(j,0,N-i+1) {
        ll lValue = 0, rValue = 0;
        if (i>0) lValue = dp[i-1][j] + a[i+j-1].first * abs((i-1)-a[i+j-1].second);
        if (j>0) rValue = dp[i][j-1] + a[i+j-1].first * abs((N-j)-a[i+j-1].second);
        dp[i][j] = max(lValue, rValue);
        answer = max(dp[i][j], answer);
    }
    cout << answer << endl;
}

signed main(){
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 35052
import java.util.Scanner;

public class Main{
	static int[] bit = new int[10];
	static int[][] cnt = new int[11][101];
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		rec(0);
		while(sc.hasNext()) {
			int n = sc.nextInt();
			int s = sc.nextInt();
			if(n == 0 && s == 0) {
				break;
			}
			System.out.println(cnt[n][s]);
		}
		sc.close();

	}
	static void add() {
		int sum =  0;
		int m = 0;
		for(int i = 0; i < bit.length; i++) {
			if(bit[i] == 1) {
				sum += i;
				m++;
			}
		}
		if(m != 0) {
			cnt[m][sum]++;
		}
	}
	static void rec(int k) {
        if(k == bit.length) {
        	add();
            return;
        }
        rec(k + 1);
        bit[k] = 1;
        rec(k + 1);
        bit[k] = 0;
    }
}


Measured memory_bytes: 26168
n, a, b = map(int, input().split())
ans = 0
for i in range(1, n + 1):
    strli = list(str(i))
    l_n_str = [int(n) for n in strli]
    sumstr = sum(l_n_str)
    if a <= sumstr <= b:
        ans += i
print(ans)

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String g = "CODEFESTIVAL2016";
		String rString = scanner.next();
		int j = 0;
		for (int i = 0; i < rString.length(); i++) {
			if (g.charAt(i) != rString.charAt(i)) {
				j++;
			}
		}
		System.out.println(j);
	}

}

Measured memory_bytes: 9676
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))
rr = lambda N: [ri() for _ in range(N)]
YN = lambda b: print('YES') if b else print('NO')
INF = 10**18

A,B,K=rl()
for i in range(100,0,-1):
    if A%i == 0 and B%i==0:
        K -= 1
    if K==0:
        print(i)
        break

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll XOR(ll n)
{
    ll mod = n % 4;
    if (mod == 0) return n;
    else if (mod == 1) return 1;
    else if (mod == 2) return n + 1;
    else if (mod == 3) return 0;
}
ll XOR(ll l, ll r)
{
    return (XOR(l - 1) ^ XOR(r));
}
int main()
{
    long long  l , r ;
    cin>>l>>r;
    cout << XOR(l, r);

    return 0;
}


Measured memory_bytes: 3560
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
const ll MOD = 1000000007;
using namespace std;

bool isPrime(int p){
    if(p <= 1) return false;
    for(int i = 2; i * i <= p; i++){
        if(!(p%i)) return false;
    }
    return true;
}

int main(){
    int n; cin >> n;
    for(int i = 11; i <= 55555; i += 5){
        if(isPrime(i)){
            if(i > 11) cout << " ";
            cout << i; n--;
        }
        if(!n){
            cout << "\n";
            break;
        }
    }
    
    return 0;
}

Measured memory_bytes: 384
from collections import deque


def main():
    INF = 10 ** 7
    H, W = list(map(int, input().split()))
    CH, CW = list(map(lambda x: int(x) - 1, input().split()))
    DH, DW = list(map(lambda x: int(x) - 1, input().split()))
    S = [input() for _ in range(H)]
    if S[DH][DW] == '#':
        print(-1)
        return
    # 歩き
    walk_list = [[1, 0], [-1, 0], [0, -1], [0, 1]]
    # ワープ
    warp_list = [[-2, -2], [-2, -1], [-2, 0], [-2, 1], [-2, 2], \
            [-1, -2], [-1, -1], [-1, 1], [-1, 2], \
            [0, -2], [0, 2], \
            [1, -2], [1, -1], [1, 1], [1, 2], \
            [2, -2], [2, -1], [2, 0], [2, 1], [2, 2]]
    # 使うワープの最小回数
    cnt = [[INF for _ in range(W)] for _ in range(H)]

    warp_checked = [[0 for _ in range(W)] for _ in range(H)]
    warp_que = deque([(DH, DW)])
    c = 0
    while len(warp_que) > 0:
        # warp_queから歩きのみでいける範囲の探索
        walk_que = deque()
        while len(warp_que) > 0:
            h, w = warp_que.pop()
            cnt[h][w] = c
            walk_que.append((h, w))
            tmp_walk_que = deque([(h, w)])
            while len(tmp_walk_que) > 0:
                h, w = tmp_walk_que.pop()
                for dh, dw in walk_list:
                    nh, nw = h + dh, w + dw
                    if 0 <= nh < H and 0 <= nw < W and \
                        S[nh][nw] == '.' and cnt[nh][nw] == INF:
                        cnt[nh][nw] = c
                        tmp_walk_que.append((nh, nw))
                        walk_que.append((nh, nw))
        # ワープでしかいけない範囲の探索
        while len(walk_que) > 0:
            h, w = walk_que.pop()
            for dh, dw in warp_list:
                nh, nw = h + dh, w + dw
                if 0 <= nh < H and 0 <= nw < W and S[nh][nw] == '.' and \
                    warp_checked[nh][nw] == 0 and cnt[nh][nw] == INF:
                    warp_checked[nh][nw] = 1
                    warp_que.append((nh, nw))
        c += 1

    if cnt[CH][CW] == INF:
        print(-1)
    else:
        print(cnt[CH][CW])


if __name__ == '__main__':
    main()

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

#include <iostream>
#include <fstream>

#include <iostream>
#include <fstream>

#include <string>
#include <vector>
#include <math.h>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>
using namespace std;
using ll = long long;
constexpr ll INF = 1010000000000000017LL;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define all(v) v.begin(), v.end()

class CManyMedians {
public:
	void solve(std::istream& in, std::ostream& out) {
        ll n;
        in>>n;
        vector<ll> x(n),y(n);

        rep(i,n) {
            in>>x[i];
            y[i]=x[i];
        }
        sort(all(y));

        rep(i,n){
            if(x[i]<y[n/2]) out<<y[n/2]<<endl;
            else out<<y[n/2-1]<<endl;
        }
	}
};


int main() {
	CManyMedians solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.first<<","<<p.second<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
#else
#define dbg(...) {}
#endif

int main(){
  int n;
  cin>>n;
  vector<int> a(n),b(n);
  rep(i,n) cin>>a[i];
  rep(i,n) cin>>b[i];

  vector<int> req, cap;
  rep(i,n){
    if(a[i] > b[i]) cap.pb(a[i] - b[i]);
    else if(a[i] < b[i]) req.pb(b[i] - a[i]);
  }

  sort(all(cap));
  int ans = req.size();
  bool hoge = false;
  while(req.size() > 0 && cap.size()>0){
    if(req.back() >= cap.back()){
      req.back() -= cap.back();
      cap.pop_back();
      ans++;
      hoge = false;
      dbg(1,req,cap);
    } else {
      cap.back() -= req.back();
      req.pop_back();
      hoge = true;
      dbg(0,req,cap);
    }
  }

  if(req.size() > 0) cout << -1 << endl;
  else {
    cout << ans + hoge << endl;
  }

  return 0;
}


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

int main() {
  string S;
  cin >> S;
  if ( S.at(5) == '0' && 
     ( S.at(6) == '1' || 
       S.at(6) == '2' || 
       S.at(6) == '3' ||  
       S.at(6) == '4' ))
    cout << "Heisei" << endl;
  else 
    cout << "TBD" << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    String line = scanner.nextLine();
    
    StringBuilder builder = new StringBuilder();
    for (int ix = 0; ix < line.length(); ix++) {
      if (ix % 2 == 0) {
        builder.append(line.charAt(ix));
      }
    }
    
    System.out.println(builder);
  }
}

Measured memory_bytes: 25148
def is_win(n,k):
	dp=[False]*(k+1)
	for i in range(k+1):
		for j in range(n):
			if i-arr[j]>=0 and dp[i-arr[j]]==False:
				dp[i]=True
				break

	return dp[k]
	

# with open ('input.txt') as f :
n,k=map(int,input().split())
arr=list(map(int,input().split()))
res=is_win(n,k)
print('First' if res else 'Second')

# 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99

Measured memory_bytes: 3828
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>

using namespace std;


int a[110];
int n;
void P()
{
    for(int i=1;i<=n;i++)
    {
        printf("%d",a[i]);
        if(i!=n)
            printf(" ");
        else
            printf("\n");

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

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

    for(int i=1;i<=n;i++)
    {
        int key=a[i];
        int j=i-1;
        while(j>0&&a[j]>key)
        {
            a[j+1]=a[j];
            j--;
        }
        a[j+1]=key;
        P();
    }
    return 0;
}



Measured memory_bytes: 3196
n,a,b=map(int, input().split())
sum=0

def digit(n):
    cnt=0
    v=str(n)
    for j in range(len(v)):
        cnt+=int(v[j])
    return cnt

for i in range(n+1):
    tmp =int(digit(i))
    if tmp>=a and tmp<=b:
        sum+=i

print(sum)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
const long double EPS = 1e-14;
const int maxn = 18;
const int mod = 1e9 + 7;
pair < int, int > dp[1 << maxn];

signed main(){
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    for(int i = 0 ; i < (1 << n) ; ++i) cin >> dp[i].first;
    for(int i = 0 ; i < n ; ++i)
        for(int mask = 0; mask < (1 << n) ; ++mask)
            if(mask & (1 << i)){
                vector < int > v;
                v.push_back(dp[mask].first);
                v.push_back(dp[mask].second);
                v.push_back(dp[mask ^ (1 << i)].first);
                v.push_back(dp[mask ^ (1 << i)].second);
                sort(all(v));
                dp[mask].first = v.back();
                dp[mask].second = v[2];
            }
    int ans = 0;
    for(int i = 1 ; i < (1 << n) ; ++i){
        ans = max(ans, dp[i].first + dp[i].second);
        cout << ans << '\n';
    }
    return 0;
}

Measured memory_bytes: 7168
ans = []

while True:
    n = int(input())
    if n == 0:
        break

    s = [int(si) for si in input().split()]
    m = sum(s) / n
    a2 = sum([(si - m) ** 2 for si in s]) / n
    ans += [a2 ** 0.5]

print("\n".join(map(lambda x: "%.5f" % x, ans)))




Measured memory_bytes: 5676
n = int(input())
r = range(1, min(9, n) + 1)
a = [None]
for i in r:
  a.append([None])
  for j in r:
    a[i].append(i == j)
    k = 1
    while 10 * k * i + j <= n:
      a[i][j] += min(k, (n - j) // 10 - k * i + 1)
      k *= 10
print(sum(a[i][j] * a[j][i] for i in r for j in r))

Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, s, n) for (ll i = s; i < (n); i++)
using namespace std;

const ll mod = 998244353;
int main(){
  ll n, k;
  cin >> n >> k;
  vector<ll> dp(n+1, 0LL);
  vector<ll> dpsum(n+1, 0LL);
  vector<ll> L(k), R(k);
  rep(i, k){
    cin >> L[i] >> R[i];
  }
  dp[1] = 1;
  dpsum[1] = 1;
  rep2(now, 2, n+1){
    rep(i, k){
      ll L1 = now-L[i];
      ll R1 = now-R[i]-1;
      if (L1 < 0) continue;
      R1 = max(R1, 0LL);
      dp[now] += dpsum[L1] - dpsum[R1];
      dp[now] %= mod;
    }
    dpsum[now] = dpsum[now-1] + dp[now];
  }
  cout << dp[n] << endl;
  
  return 0;
}


Measured memory_bytes: 6448
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <numeric>
#include <cmath>
#include <cstdlib>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
#define ALL(x) x.begin(), x.end()
#define INF (1001000000)
#define SZ(a) int((a).size())
#define EACH(i,c) for(auto i:c)
#define EXIST(cs,v) (find(ALL(cs),(v))!=cs.end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define UNIQ(c) (c).erase(unique((c).begin(),(c).end()), (c).end());
#define P(p) cout<<(p)<<endl;

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

    int a, b;
    cin >> a >> b;

    P(a*b - a - b + 1);

    return 0;
}


Measured memory_bytes: 256
//#pragma GCC optimize(3)
#include<iostream>
#include<iomanip>
#include<stack>
#include<queue>
#include<list>
#include<vector>
#include<set>
#include<map>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<ctime>
#define ll long long
#define db double
#define mxlen 1000+9
#define inf 1000009
#define INF (int)1e9
#define pi acos(-1)
#define rd(n) {n=0;char ch;int f=0;do{ch=getchar();if(ch=='-'){f=1;}}while(ch<'0'||ch>'9');while('0'<=ch&&ch<='9'){n=(n<<1)+(n<<3)+ch-48;ch=getchar();}if(f)n=-n;}
using namespace std;

char s1[inf],s2[inf];
int q[inf*2],head=inf,tail=inf-1;

int main(){
	int n;
	rd(n)
	scanf("%s%s",&s1,&s2);
	q[++tail]=n+1;
	int pos=n+1,cnt=0,ans=0;
	for (int i=n;i>=1;i--){
		int tmp=pos;
		while (pos>0 && (pos>i || s1[pos-1]!=s2[i-1])){
			pos--;
		}
		if (pos==0){
			puts("-1");
			return 0;
		}
		if (tmp==pos){
			while (head<=tail && q[tail]-cnt>=i){
				tail--;
			}
			q[++tail]=i+cnt;
		}
		else{
			cnt++;
			if (i!=pos){
				ans=max(ans,tail-head+1);
				q[--head]=pos+cnt;
			}
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 7936
lists=[0 for i in range(5)]
mar=["M","A","R","C","H"]
n=int(input())
for i in range(n):
    s=input()
    a=s[0]
    for i in range(5):
        if a==mar[i]:
            lists[i]+=1
answer=0
for i in range(5):
    for j in range(i+1,5):
        for k in range(j+1,5):
            answer+=lists[i]*lists[j]*lists[k]
print(answer)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
const int N=1e6+10;
int q[N];
#define f(i,a,b) for(int i=a;i<b;i++)
#define read(x)  scanf("%d",&x)
int main(){
int k,a,b;
scanf("%d%d%d",&k,&a,&b);
for(int i=a;i<=b;i++){
	if(i%k==0){
		printf("OK");
		return 0;
	}
	else if(i==b)printf("NG");
}
return 0;
}


Measured memory_bytes: 3824
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
// typedef __int128_t Int;
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);

  int N;
  cin >> N;
  vector<int> v(N);
  rep(i, 0, N) { cin >> v[i]; }
  map<int, int> p, q;
  vector<int> ans;
  rep(i, 0, N) {
    p[v[i]]++, q[v[N - 1 - i]]++;
    if (p == q)
      ans.push_back(i + 1);
  }
  rep(i, 0, ans.size()) cout << ans[i] << (i == ans.size() - 1 ? '\n' : ' ');

  return 0;
}



Measured memory_bytes: 7916
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
#include<bitset>
#include<random>
#include<cstdint>
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
#define shosu setprecision(17)
  
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<char,P> Q;
ll longinf=(1ll<<60);
ll inf=1ll<<29;
 

int main(){
      int x;
      x=0;
      string s;
      int n;
      cin>>n;
      cin>>s;
      int ans=0;
      rep0(i,n){
            if(s[i]=='I') x++;
            else x--;
            ans=max(x,ans);
      }
      cout<<ans<<endl;
      return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;


class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		double r = scan.nextDouble();
		double a = r * r * 3.141592653589;
		double b = r * 2 * 3.141592653589;
		System.out.println(String.format("%.6f",a) + " " + String.format("%.6f",b));
	}
}


Measured memory_bytes: 28088
import java.util.*;
import java.io.*;
import java.math.*;
 
 
public class Main
{
    public static void main(String[] args) 
    { 
          Scanner input=new Scanner(System.in);
          int n = input.nextInt();
        //   String s = input.next();
        int count =0;
        int i=1000;
          while(i<n){
              i=i+1000;
            //   count=i;
          }
          
          
          System.out.println(i-n);
          
          
      
            
          input.close(); 
     } 
     
}

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

typedef double f64;
typedef long long i64;
typedef int i32;
typedef pair<i32, i32> pi32;
typedef unsigned long long u64;
typedef unsigned int u32;
typedef vector<i32> vi32;
typedef deque<i32> di32;

#define all(c) (c).begin(), (c).end()
#define REP(i, a, b) for (auto i = a; i < b; i++)
#define REPA(i, a, b, acc) for (auto i = a; i < b; i += acc)
#define PB push_back
#define PF push_front
#define PRINT(x) cout << #x ": " << (x) << endl;
#define TR(c, it) for (auto(it) = (c).begin(); (it) != (c).end(); (it)++)
#define MAX_PRECISION cout << setprecision(numeric_limits<double>::max_digits10);

i32 main() {
  ios::sync_with_stdio(false);  // Makes IO faster, remove this line if C style scanf/printf needed.
  i32 n, k;
  cin >> n >> k;
  string s;
  cin >> s;

  vector<pi32> parts;
  i32 counter = 0;
  REP(i, 0, s.size()) {
    if (s[i] == '1') {
      if (counter) {
        parts.push_back({i - counter, i - 1});
      }

      counter = 0;
      continue;
    }
    counter++;
  }
  if (counter) {
    parts.push_back({s.size() - counter, s.size() - 1});
  }

  if (parts.size() <= k) {
    cout << n << endl;
    return 0;
  }

  i32 best = 0;
  REP(i, 0, parts.size() - k + 1) {
    i32 begin = 0;
    if (i != 0) {
      begin = parts[i - 1].second + 1;
    }
    i32 end = n - 1;
    if (i != (parts.size() - k)) {
      end = parts[i + k].first - 1;
    }
    best = max(best, end - begin + 1);
  }
  cout << best << endl;
}


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

int main(void){
    int L,R,d;
    cin >> L >> R >> d;
    int counter = 0;
    for(int i = L ; i <= R ; i++){
        if(i % d == 0) counter++;
    }
    cout << counter << endl;
    return 0;
}

Measured memory_bytes: 3620
N, D = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]

a = 0
cnt = 0
for i in range(N-1):
    for j in range(i+1, N):
        for l in range(D):
            a += (X[i][l] - X[j][l])**2
        a = a ** 0.5
        if a.is_integer():
            cnt += 1
        a = 0

print(cnt)

Measured memory_bytes: 9440
from collections import deque

H, W = map(int, input().split())
maze = [input() for _ in range(H)]
sy, sx, gy, gx = 0, 0, H-1, W-1

q = deque([[sy, sx]])
visited = [[-1]*W for _ in range(H)]
visited[sy][sx] = 0

d = [[1, 0], [-1, 0], [0, 1], [0, -1]]

flag = False
while q:
  y, x = q.popleft()
  if [y, x] == [gy, gx]:
    flag = True
    break
  for dy, dx in d:
    ny, nx = y+dy, x+dx
    if ny < 0 or ny > H-1 or nx < 0 or nx > W-1:
      continue
    if maze[ny][nx] == "." and visited[ny][nx] == -1:
      visited[ny][nx] = visited[y][x] + 1
      q.append([ny, nx])

black = 0
for i in range(H):
  black += maze[i].count("#")

if flag:
  print(H*W - black - visited[gy][gx] - 1)
else:
  print(-1)

Measured memory_bytes: 3444
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;

namespace contest_Csharp
{

    class Program
    {
        public static (long m, long s)[,] dp;
        public static long mod;

        static long power(long a, long b, long modulo)
        {
            long result = 1;
            long buff = a;
            for (int i = 1; i <= b; i *= 2)
            {
                result = result * ((b / i % (2) == 1) ? buff : 1) % modulo;
                buff = (buff * buff) % modulo;
            }
            return result % modulo;
        }
        static long binomal(long n, long r, long modulo)
        {
            long result = 1;
            for (long i = 0; i < r; i++)
            {
                result = (result * (n - i)) % modulo;
                result = (result * power(i + 1, modulo - 2, modulo)) % modulo;
            }
            return result;
        }
        static void Main(string[] args)
        {
            checked
            {
                var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
                Console.SetOut(sw);

                var vals = Console.ReadLine().Split(' ').
                    Select(x => long.Parse(x)).ToList();

                
                var S = vals[0];
                mod = (long)1e9 + 7;

                long ans = 0;
                for (int i = 1 ; i*3<=S; i++)
                {
                    ans = (ans+ binomal(S-2*i-1,i-1, mod))%mod;
                }

                var f = binomal(2, 2, mod);

                Console.WriteLine(ans);

                Console.Out.Flush();
            }//cheked




        }
        static long gcd(long a, long b)
        {
            long large = Math.Max(a, b);
            long small = Math.Min(a, b);
            while (large % small != 0)
            {
                var S = small;
                small = large % small;
                large = S;
            }
            return small;
        }
    }

}




Measured memory_bytes: 28276
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define MOD 1000000007 //S.size()
using namespace std;
typedef unsigned long long ll;

int main(void){
	int n, m;
	cin >> n >> m;
	int a[n], b[n];
	vector<pair<int, int>> shops(n);
	rep(i, n) {
		cin >> a[i] >> b[i];
		shops[i] = make_pair(a[i], b[i]);
	}
	SORT(shops);
	ll sum = 0;
	int cnt = 0;
	rep(i, n){
		int buy = min(m, shops[i].second);
		sum += (ll) shops[i].first * buy;
		m -= buy;
	}
	cout << sum << endl;

	return 0;
}


Measured memory_bytes: 1792
func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}
    
let ab = readInts()
let a = ab[0]
let b = ab[1]
if (1<=a)&&(a<=9)&&(1<=b)&&(b<=9){
  print(a*b)
}else{
  print(-1)
} 


Measured memory_bytes: 8248
#include <iostream>

using namespace std;
#define MAX 100

int main(void){
  int X,Y;
  cin >> X >> Y;
  // crane
  for(int i=0;i<=50;i++){
  // turtle
    for(int j=0;j<=25;j++){
      if(i+j == X && 2*i + 4*j == Y){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3680
#include<stdio.h>
#include<string.h>

int up(const void *a ,const void *b){
  return *(int *)a - *(int *)b;
}

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

  int a[200001] = {0} , b;
  int count = 0;
  for(int i = 0;i < n;i ++){
    scanf("%d",&b);
    a[b] ++;
    if(a[b] == 1){
      count ++;
    }
  }
  for(int i = 0;i < 200001;i ++){
    if(a[i] == 0){
      a[i] += 20000000;
    }
  }

  qsort(a,200001,sizeof(int),up);

  int ans = 0;
  if(count < k){
    ans = 0;
  }
  else{
    for(int i = 0;i < count - k;i ++){
      ans += a[i];
    }
  }

  printf("%d\n",ans);

  return 0;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;

int gcd(int x, int y) { return x&&y? gcd(y%x,x): x+y; }
int main(void) {
  int n;
  cin >> n;
  vector<int> a(n);
  for(auto &x: a) cin >> x;
  vector<int> lg(n), rg(n);
  lg[1]=a[0];
  for(int i=2;i<n;++i) lg[i]=gcd(lg[i-1],a[i-1]);
  rg[n-2]=a[n-1];
  for(int i=n-3;i>=0;--i) rg[i]=gcd(rg[i+1],a[i+1]);
  
  int answer = max(lg[n-1],rg[0]);
  FOR(i,1,n-1) answer = max(answer, gcd(lg[i],rg[i]));
  cout << answer << endl;
  return 0;
}


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

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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

//INT_MAX	2,147,483,647 = 2*1.0e9

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int R; cin >> R;

    if(R < 1200) cout << "ABC" << endl;
    else if (R< 2800) cout << "ARC" << endl;
    else cout << "AGC" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void){
  int charge,opption,i;
  char s[4];
  
  fgets(s,sizeof(s),stdin);
  
  for(i=0,opption=0;i<3;i++){
    if(s[i]=='o'){
     opption+=100;
    }
  }
  
  charge=opption+700;
  printf("%d\n",charge);
  
 return 0; 
}

Measured memory_bytes: 128
#include"bits/stdc++.h"
using namespace std;

int main(){
	int N;
	cin >> N;
	vector<tuple<string, int,int>> judge;
	for (int i = 0;i < N;++i) {
		string S;
		int P;
		cin >> S >> P;
		judge.emplace_back(S, 100 - P, i);
	}
	sort(judge.begin(), judge.end());
	for (int i = 0;i < N;++i) {
		cout << get<2>(judge[i]) + 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
# sqrt(n) <= 10**6 ループに耐えうる
# // -> (python 3) 除算の結果をintに
import math
N = int(input())
PrimeFactList = []
tmpNum = N

# 素因数分解
# 2 から順に数字を+1しながら√N + 1まで素因数分解すれば素数以外では素因数分解されない
for i in range(2, int(math.sqrt(N))+1):
    if N % i == 0:
        expcnt = 0
        while tmpNum % i == 0:
            tmpNum //= i
            expcnt += 1
        PrimeFactList.append(i)
        PrimeFactList.append(expcnt)

# 1以外の数が残っていたら足す
if tmpNum != 1:
    PrimeFactList.append(tmpNum)
    PrimeFactList.append(1)

# 素因数が1つもなければN自体を因数に加える
if len(PrimeFactList) == 0:
    PrimeFactList.append(N)
    PrimeFactList.append(1)
ans = 0

if PrimeFactList[0] == 1:
    print(0)
    exit()

opeList = [1, 3, 6, 10, 15, 21, 28, 36, 45]  # 同じ因数の連続操作に必要な累乗数
for i in range(1, len(PrimeFactList), 2):
    for j in range(len(opeList)):
        if PrimeFactList[i] < opeList[j]:
            ans += j
            break
print(ans)


Measured memory_bytes: 9228
number=[]
num_m=[]
number=input().split()

num_m=number
j=0
for j in range(2):
    i=0
    for i in range(2):
        if number[i]<number[i+1]:
            tmp=number[i]
            number[i]=number[i+1]
            number[i+1]=tmp

num_m[0]=int(number[0])*10
num_m[1]=int(number[1])
num_m[2]=int(number[2])
sum=0
sum=num_m[0]+num_m[1]+num_m[2]

print(sum)
n,j=0,0

Measured memory_bytes: 3064
#!/usr/bin/python
import sys,heapq
try:
	import rpython.rlib.streamio
	stream=rpython.rlib.streamio.fdopen_as_stream(sys.stdin.fileno(),'r')
	raw_input=stream.readline
	def cmp_lt(x,y): return x < y
	heapq.cmp_lt=cmp_lt
	COMPILE=123456789012
	def compile(a,b,c):
		return ((a+COMPILE)<<18) | (b<<9) | c
	def decompile(a):
		return ((a>>18)-COMPILE,(a>>9)&511,a&511)
except ImportError:
	def compile(a,b,c):
		return (a,b,c)
	def decompile(a):
		return a
	if sys.version_info[0]>=3: raw_input=input

INF=1234567890123456789
def shortestPath(g,dist,prev):
	n = len(g)-1
	h = [INF]*n+[0]
	for k in range(n+1):
		for i in range(n+1):
			for e in g[i]:
				if h[e[1]]<INF and e[0]<INF and h[e[2]] > h[e[1]] + e[0]:
					h[e[2]] = h[e[1]] + e[0]
					if k==n: return False # negative cycle
	for i in range(n):
		for e in g[i]:
			e[0]+=h[i]-h[e[2]]
	for s in range(n):
		Q=[]
		heapq.heappush(Q,compile(0,s,s))
		while Q:
			e = decompile(heapq.heappop(Q))
			if prev[s][e[2]]!=-2: continue
			prev[s][e[2]] = e[1]
			for f in g[e[2]]:
				if e[0]<INF and f[0]<INF and dist[s][f[2]] > e[0] + f[0]:
					dist[s][f[2]] = e[0] + f[0]
					heapq.heappush(Q,compile(e[0]+f[0],f[1],f[2]))
		for u in range(n):
			if dist[s][u]<INF: dist[s][u] += h[u] - h[s]
	return True

def entry_point(argv):
	V,E=[int(e) for e in raw_input().rstrip().split(' ')]
	g=[[] for i in range(V+1)]
	dist=[[INF]*V for i in range(V)]
	prev=[[-2]*V for i in range(V)]
	for i in range(V): g[i].append([0,i,i])
	for i in range(V): g[V].append([0,V,i])
	for i in range(E):
		s,t,e=[int(e) for e in raw_input().rstrip().split(' ')]
		g[s].append([e,s,t])
	if not shortestPath(g,dist,prev):
		print("NEGATIVE CYCLE")
	else:
		for i in range(V):
			print(' '.join(["INF" if dist[i][j]>=INF else str(dist[i][j]) for j in range(V)]))
	return 0

def target(*args):
	return entry_point

if __name__ == '__main__': entry_point([])

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

int main() {
	int H, W;
	cin >> H >> W;
	vector<string> s(H);
	for (int i = 0; i < H; ++i) { cin >> s[i]; }

	bool ok = true;
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			if (s[i][j] == '.') { continue; }

			int cnt1 = 0;
			int cnt2 = 0;
			if ((i > 0) && (s[i - 1][j] == '#')) { ++cnt1; }
			if ((j > 0) && (s[i][j - 1] == '#')) { ++cnt1; }
			if ((i < H - 1) && (s[i + 1][j] == '#')) { ++cnt2; }
			if ((j < W - 1) && (s[i][j + 1] == '#')) { ++cnt2; }

			if ((i == 0) && (j == 0)) {
				if (cnt2 > 1) { ok = false; }
			} else if ((i == H - 1) && (j == W - 1)) {
				if (cnt1 > 1) { ok = false; }
			} else {
				if ((cnt1 != 1) || (cnt2 != 1)) { ok = false; }
			}
		}
	}

	if (ok) { cout << "Possible" << endl; }
	else { cout << "Impossible" << endl; }

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

		int ans=sc.nextInt();

		for(int i=1; i<=32000; i++) {
			if(i*i>ans) {
				System.out.println((i-1)*(i-1));
				break;
			}
		}
	}
}

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

int main(void) {
  int max;
    int A,B;
  
  cin >> A >> B ;

max=A+B;
  
  if(max<A-B)
  {max=A-B;}
  
  if(max<A*B)
  { max=A*B;}
  
  cout<<max;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
using namespace std;
int main()
{
	long long int a,b,c,k,sum=0;
	cin>>a>>b>>c>>k;
	if(k>=a)
	{
		sum+=a;
		k=k-a;
		if(k>=b)
		{
			k-=b;
			if(k!=0)
			{
				sum-=(k);
			}
		}
	}
	else
	sum+=k;
	cout<<sum;
	
	
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
typedef long long ll;

int main() {
    int a,b,c,d; cin >> a >> b >> c >> d;
    while(true){
        c -= b;
        if(c <= 0) break;
        a -= d;
        if(a <= 0) break;
    }
    if(c <= 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3636
import java.util.Scanner;
import java.util.ArrayList;
class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        
        int k = stdIn.nextInt();
        int x = stdIn.nextInt();

        for(int i = x-k+1;i <= x+k-1;i++) {
            System.out.println(i);
        }
    }

}

Measured memory_bytes: 23892
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <istream>
#include <map>
#include <set>
#include <queue>
#define rep0(i,n) for (int i = 0; i <= (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)
#define REP(a,b) for (int i = a; i <= (b); ++i) 
#define mREP(a,b) for (int i = a; i == (b); --i)
#define mod 1e9 + 7
typedef long long ll;
using namespace std;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	/*
	　　　　　 　 _... ..._
	　　　　　 , ´⌒ ⌒ヽ
	　　　 　 ﾉｨ（ノﾉ）ﾉ）ﾉ）
	　　　 　 （（q|.ﾟ ヮﾟﾉ|ﾊ
	　　　　　　△ﾑ,8ﾑﾌつ
	　　　　　/(ﾝ_/＿ヽ＼
	　　　　 ～～i_ﾌ_ﾌ～´
	*/
	string s;
	cin >> s;
	string ans;
	string anss;
	string ansss;
	REP(0, 4) {
		ans += s[i];
	}
	REP(6, 12) {
		anss += s[i];
	}
	REP(14, 18) {
		ansss += s[i];
	}
	cout << ans << " " << anss << " " << ansss << endl;
	return 0;
}


Measured memory_bytes: 504
#include <iostream>

using namespace std;

int main()
{
    int n;
    string s;
    cin >> n >> s;
    
    string res = "";
    for(int i = 0; i < s.length(); i++) {
        char t = s[i] + n;
        if(t > 90) {
            t -= 26;
        }
        
        res += t;
    }
    
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(), (a).end()
// #define sort(a) sort(all(a))
using P = pair<int, int>;
using ll = long long;
using ld = long double;
typedef vector<int> vi;
int dx[4] = { 0, 1, 0,-1 };
int dy[4] = { 1, 0,-1, 0 };
const ll MOD = 1000000007;

int m[200010];
int a;
signed main() {
  int N;cin >>N;
  for (int i = 1; i < N; i++) {
    cin >> a;
    m[a-1]++;
  }
  for (int i = 0; i < N; i++) cout << m[i] << endl;
  return 0;
}

Measured memory_bytes: 5136
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    long N;
    vector<long> RGB(3);
    vector<long> RGBmax(3);

    for(long i = 0; i < 3; i++) {
        cin >> RGB[i];
    }
    cin >> N;

    sort(RGB.begin(), RGB.end(), greater<long>());
    for(long i = 0; i < 3; i++) {
        RGBmax[i] = N / RGB[i];
    }

    long cnt = 0;
    for(long i = 0; i < RGBmax[0] + 1; i++) {
        if(i * RGB[0] > N) break;
        for(long j = 0; j < RGBmax[1] + 1; j++) {
            if(i * RGB[0] + j * RGB[1] > N) break;
            if((i * RGB[0] + j * RGB[1] - N) % RGB[2] == 0) {
                cnt++;
            }
        }
    }

    cout << cnt << endl;
}


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

Measured memory_bytes: 572
n,m=map(int,input().split())
h=list(map(int,input().split()))
ab=[list(map(int,input().split())) for _ in range(m)]
l=[0]*n
for i in range(m):
    if h[ab[i][0]-1]>h[ab[i][1]-1]:
        l[ab[i][1]-1]+=1
    elif h[ab[i][0]-1]<h[ab[i][1]-1]:
        l[ab[i][0]-1]+=1
    else:
        l[ab[i][1]-1]+=1
        l[ab[i][0]-1]+=1
print(l.count(0))

Measured memory_bytes: 32040
import math

def f(x):
   return 180 * math.atan(a * b**2 / (2 * x)) / math.pi

def g(x):
   return 90 - 180 * math.atan(a**3 / (2 * (a * a * b - x))) / math.pi

a, b, x = map(int, input().split())

if a * a * b == x:
    print(0)
elif x <= a * a * b / 2:
    print(f(x))
else:
    print(g(x))

Measured memory_bytes: 3064
#include <cstdio>
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#define min(a,b)    (((a) < (b)) ? (a) : (b))
#define max(a,b)    (((a) > (b)) ? (a) : (b))
#define abs(x)    ((x) < 0 ? -(x) : (x))
#define INF 0x3f3f3f3f
#define delta 0.85
#define eps 1e-3
#define PI 3.14159265358979323846
#define MAX_N 100005
using namespace std;
typedef long long ll;
int N, Q;
int par[MAX_N], mark[MAX_N];
int qt[MAX_N], qv[MAX_N];

int find(int t, int x){
	return mark[x] < t ? x : par[x] = find(t, par[x]);
}

int main(){
	while(~scanf("%d%d", &N, &Q) && N){
		for(int i = 2; i <= N; i++){
			scanf("%d", par + i);
			mark[i] = INF;
		}
		int cnt = 0;
		for(int i = 1; i <= Q; i++){
			int x;
			char c;
			scanf(" %c%d", &c, &x);
			if(c == 'M'){
				mark[x] = min(mark[x], i);
			}
			else{
				qt[cnt] = i, qv[cnt] = x;
				++cnt;
			}
		}
		ll sum = 0;
		for(int i = cnt - 1; i >=0 ; i--){
			sum += find(qt[i], qv[i]);
		}
		printf("%lld\n", sum);
	}
	return 0;
}


Measured memory_bytes: 4428
import bisect
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

N = int(sys.stdin.buffer.readline())
ans = None
for i in range(N + 1):
    if int(i * 1.08) == N:
        ans = i
if ans is None:
    print(':(')
else:
    print(ans)


Measured memory_bytes: 13624
#include <bits/stdc++.h>
using namespace std;
long long int c_n_2(long long int n)
{
    if(n < 2)
        return 0;
    return n * (n - 1) / 2;
}
int main()
{
    long long int n;
    cin >> n;
    vector<long long int> vec;
    map<long long int, long long int> mp;
    for(long long int i = 0; i < n; i++)
    {
        long long int get;
        cin >> get;
        vec.push_back(get);
        map<long long int,long long int>::iterator iter = mp.find(get);
        if(iter != mp.end())
        {
            mp[get]++;
        }
        else
        {
            mp.insert(pair<long long int, long long int>(get, 1));
        }
    }
    map<long long int, long long int>::iterator iter;
    long long int sum = 0;
    for(iter = mp.begin(); iter != mp.end(); iter++)
    {
        //cout << iter -> first << " " << iter -> second << endl;
        sum += c_n_2(iter -> second);
    }
    for(long long int i = 0; i < n; i++)
    {
        cout << sum - mp.find(vec.at(i)) -> second + 1 << endl;
    }
}


Measured memory_bytes: 11120