akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()
#define INF ((int)(2e9))

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

int dis(int x, int y){
	if (x <= y) return y - x;
	return INF;
}

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

	int x, y; cin >> x >> y;
	int res = INF;
	res = min(res, dis(x,y));
	res = min(res, dis(-x,y)+1);
	res = min(res, dis(x,-y)+1);
	res = min(res, dis(-x,-y)+2);

	cout << res << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[n],b[n];
	for(int i=1; i<=n; i++){
		cin>>a[i];
	}
	for(int i=1; i<=n; i++){
		b[a[i]]=i;
	}
	for(int i=1; i<=n; i++){
		cout<<b[i]<<" ";
	}
}

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



int main() {
    int A,B,M;
    cin>>A>>B>>M;
    vector<int> a(A),b(B);
    rep(i,A){cin>>a.at(i);}
    rep(i,B){cin>>b.at(i);}
    vector<int> x(M),y(M),c(M);
    rep(i,M){cin>>x.at(i)>>y.at(i)>>c.at(i);x.at(i)--;y.at(i)--;}
    int ans=MOD;
    rep(i,M){
        int now=a.at(x.at(i))+b.at(y.at(i))-c.at(i);
        ans=min(now,ans);
    }
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    int now=a.at(0)+b.at(0);
    ans=min(ans,now);
    cout<<ans<<endl;
}

Measured memory_bytes: 2176
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N = int(input())
A = [[n-1 for n in list(map(int, input().split()))] + [-1] for _ in range(N)]
A = [a[::-1] for a in A]

def main(N, A):
    now = [A[i].pop() for i in range(N)]
    day = 0
    rest = N * (N-1)
    candidate = set(range(N))

    # WCS O(N**2) <- 1日に1試合だけのときN(N-1)/2回while文が繰り返される
    while True:
        # terminal condition
        # O(1)
        if rest == 0:
            return day

        # see if we have match today
        # O(N)
        have_match = False
        # tmp = now.copy()
        # for i in range(N):
        #     if now[now[i]] == i:
        #         tmp[i] = A[i].pop()
        #         rest -= 1
        #         have_match = True
        # now = tmp
        change = []
        next_candidate = set()
        for i in candidate:
            if now[now[i]] == i:
                j = A[i].pop()
                change.append((i, j))
                # あとで(a, b)でnow[a] = bに更新する
                next_candidate.add(i)
                if j != -1:
                    next_candidate.add(j)
                
                rest -= 1
                have_match = True

        if len(change) == 0:
            return -1
        for (a, b) in change:
            now[a] = b
            
        candidate = next_candidate
        
        day += 1

print(main(N, A))

Measured memory_bytes: 69980
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//using ll = long long;
using P = pair<int,int>;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	int n,m,sum = 0;
	cin >> n >> m;
	priority_queue<int> que;
	for(int i = 0;i < n;i++){
		int a;
		cin >> a;
		sum += a;
		que.push(a);
	}
	for(int i = 0;i < m;i++){
		int v = que.top();que.pop();
		sum = sum - v + v / 2;
		que.push(v / 2);
	}
	cout << sum << endl;
}

Measured memory_bytes: 1400
#!/usr/bin/env python
from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip


def main():
    r = int(input())

    print(3 * (r ** 2))


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()


Measured memory_bytes: 29036
#include <iostream>
#include <vector>
#include <string>

using namespace std;
using ll = long long;

int main()
{

    int n;
    cin >> n;
    int num = 0;
    vector<int> odd{3, 5, 7, 11, 13, 17, 19};

    int count = 0;

    if (n >= 105)
        count++;
    if (n >= 135)
        count++;
    if (n >= 165)
        count++;
    if (n >= 189)
        count++;
    if (n >= 195)
        count++;

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (long i=0;i<(n);i++)
#define FOR(i,a,b) for (long i=(a);i<(b);i++)
#define RREP(i,n) for(long i=n;i>=0;i--)
#define RFOR(i,a,b) for(long i=(a);i>(b);i--)
#define dump1d_arr(array) REP(i,array.size()) cerr << #array << "[" << (i) << "] ==> " << (array[i]) << endl;
#define dump2d_arr(array) REP(i,array.size()) REP(j,array[i].size()) cerr << #array << "[" << (i) << "]" << "[" << (j) << "] ==> " << (array[i][j]) << endl;
#define dump(x)  cerr << #x << " => " << (x) << endl;
#define CLR(vec) { REP(i,vec.size()) vec[i] = 0; } 
#define llINF (long long) 9223372036854775807
#define loINF (long) 2147483647
#define shINF (short) 32767
#define SORT(c) sort((c).begin(),(c).end())

using namespace std;
// to:次の頂点,cap:辺の重み,rev:逆辺のindex
struct edge {long to,cap,rev;};
class Ford_fulkerson {
private:
	vector<vector<edge>> E;
	vector<bool> used;
	size_t V;
public:
	Ford_fulkerson() : V(0) { }

	Ford_fulkerson(size_t v) :
		E(v,vector<edge>(0)),used(v,false),V(v){ }

	size_t size() { return V;}

	void add_edge(long from,long to,long cap){
		E[from].push_back({to,cap,(long)E[to].size()});
		E[to].push_back({from,0,(long)E[from].size()-1});
	}

	long dfs(long node,long goal,long flow){
		if (node == goal) return flow;
		used[node] = true;
		REP(i,E[node].size()){
			edge* e = &E[node][i];
			if (!used[e->to] && e->cap != 0){
				long d = dfs(e->to,goal,min(flow,e->cap));
				if (d != 0) {
					e->cap -= d;
					E[e->to][e->rev].cap += d;
					return d;
				}
			}
		}
		return 0;
	}

	long max_flow(long start,long goal){
		long ans = 0;
		while (1){
			REP(i,used.size()) used[i] = false;
			long f = dfs(start,goal,2147483647);
			if (f == 0) return ans;
			ans += f;
		}
	}

	void dump_E(void){
		REP(i,E.size()){
			REP(j,E[i].size()) {
				dump(E[i][j].to);
				dump(E[i][j].cap);
				dump(E[i][j].rev);
			}
		}
	}
};

int main(void){
	long V,E;
	long u,v,c;
	cin >> V >> E;
	Ford_fulkerson ff(V);

	REP(i,E){
		cin >> u >> v >> c;
		ff.add_edge(u,v,c);
	}

	cout << ff.max_flow(0,V-1) << endl;

	return 0;
}


Measured memory_bytes: 3224
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>

using namespace std;

const long MOD = 1000000007;
typedef pair<int, int> P;
typedef long long ll;

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

    int A[N];
    for(int i=0; i<N; i++){
        cin >> A[i];
    }

    map<int, int> m;
    for(int i=0; i<N; i++){
        if(m.count(A[i]) == 0)m[A[i]] = 1;
        else{
            m[A[i]]++;
        }
    }

    int cnt = 0;
    for(auto e : m){
        e.second = e.second % 2;
        if(e.second % 2 == 0) cnt++;
    }

    if(cnt % 2 == 0) cout << m.size() << endl;
    else cout << m.size() - 1 << endl;

    return 0;
}


Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+7  
using ll = long long; 
using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;


int main(){
    int n;
    cin>>n;
    map<string,double>mp;
    rep(i,n){
        double x;
        string s;
        cin>>x>>s;
        mp[s]+=x;
    }
    string s1="JPY",s2="BTC";
    double ans=mp[s1]+mp[s2]*380000;
    printf("%.4f\n",ans);

    return 0;
}

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 k,s,ans=0;
    cin>>k>>s;
    REP(x,k+1){
        REP(y,k+1){
            int z=s-x-y;
            if(0<=z&&z<=k)ans++;
        }
    }
    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;
using ll = long long;

int main() {
    // 制約見て！！！デカかったらlong longにすること！
    long n, a, b;
    long ans = 0;
    cin >> n >> a >> b;
    if((b - a) % 2 == 0){
        cout << (b - a) / 2  << endl;
        return 0;
    }else{
        long twodiff = (b-a)/2;
        long sidediff = min(a-1,n-b);
        cout << twodiff + sidediff + 1<<endl;
    }
}

Measured memory_bytes: 3644
S = str(input())
T = str(input())
a = 0
b = len(T)

if  (1 <=  len(S) <= 2*10**5) and (1 <= len(T) <= 2*10**5) and len(S) == len(T):
    for i in range(b):
        if S[i] != T[i]:
            a += 1
print(a)
            


Measured memory_bytes: 9428
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var n int
	var k int
	fmt.Scan(&n, &k)
	sc.Split(bufio.ScanWords)

	hates := getHates(k)

	var count int

	for i := n; i < 100000; i++ {
		if count != len(hates) {
			count = 0
			for j := 0; j < len(hates); j++ {
				str := strconv.Itoa(i)
				if !strings.Contains(str, hates[j]) {
					count++
				}
			}
		} else {
			fmt.Println(i - 1)
			return
		}
	}
}

func getHates(k int) []string {
	var hates = make([]int, k, k)

	for i := 0; i < k; i++ {
		hates[i] = nextInt()
	}

	var strHates = make([]string, len(hates), len(hates))

	for i, hate := range hates {
		strHates[i] = strconv.Itoa(hate)
	}

	return strHates
}

func contains(s []int, e int) bool {
	for _, v := range s {
		if e == v {
			return true
		}
	}
	return false
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}


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

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

int N,K;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>K>>N;
	
	if(K%2==0) {
		FOR(i,N) {
			_P("%d%c",(i==0)?(K/2):K,(i==N-1)?'\n':' ');
		}
		return;
	}
	
	vector<int> V;
	FOR(i,N) V.push_back(K/2+1);
	FOR(i,N/2) {
		if(V.back()==1) V.pop_back();
		else {
			V.back()--;
			while(V.size()<N) V.push_back(K);
		}
	}
	
	FORR(c,V) cout<<c<<" ";
	cout<<endl;
	
	
}


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


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

#define NDEBUG
#include <cassert>


typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define eb  emplace_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair

#define PQ(T) priority_queue<T>
#define RPQ(T) priority_queue<T,vector<T>,greater<T>>

template<class T> inline void amin(T & a, T const & b) { a = min(a, b); }
template<class T> inline void amax(T & a, T const & b) { a = max(a, b); }

inline ll square(ll x) { return x * x; }
inline ll gcd(ll a, ll b) { while(a) swap(a, b%=a); return b; }
template <typename T>
inline T mod(T a, T b) { return ((a % b) + b) % b; }


void solve(int N, vi& u,vi& v,vi& w) {
    vector<vector<ii>> nxt(N);
    rep(i,N-1){
        nxt[ u[i] ].emplace_back( v[i], w[i] );
        nxt[ v[i] ].emplace_back( u[i], w[i] );
    }
    queue<ii> q;
    q.emplace(0, 0);
    vi visited(N, INT_MAX);
    while (!q.empty()){
        int u=q.front().first, d=q.front().second;
        q.pop();
        if (visited[u] != INT_MAX) continue;
        visited[u] = d % 2;
        for (auto& p: nxt[u]) {
            int v=p.first, d2=p.second;
            q.emplace(v, d+d2);
        }
    }
    rep(i,N){
        printf("%d\n", visited[i]);
    }
}

int main() {
    int N; scanf("%d%*c", &N);
    vi u(N-1), v(N-1), w(N-1);
    rep(i,N-1){
        scanf("%d %d %d%*c", &u[i], &v[i], &w[i]);
        u[i]--; v[i]--; w[i]%=2;
    }
    solve(N,u,v,w);
    return 0;
}


Measured memory_bytes: 8064
#include<bits/stdc++.h>
using namespace std;
#define N 500005
typedef long long ll;
char s[N];
ll f[N][3];
int n,last,now=1;
ll ans;
int main()
{
	scanf("%d",&n);
	scanf("%s",s+1);
	s[0]=s[n+1]=s[n+2]='0';
	while(now<=n+2)
	{
		while(s[now]=='1') now++;
		if(s[now-1]=='0')
		{
			ans+=max(f[last][0],max(f[last][1],f[last][2]));
			last=now++;
			continue;
		}
		f[now][0]=max(f[last][0],max(f[last][1],f[last][2]));
		if(s[now+1]=='1')
		{
			f[now][1]=max(f[now][1],f[last][0]+now-last-1);
			if(last&&s[last-1]=='1') f[now][1]=max(f[now][1],f[last][1]+now-last-2);
			int tmp=now;
			while(s[tmp+1]=='1') tmp++;
			if(tmp!=now)
			  if(now!=last+2) f[now][2]=max(f[now][2],max(f[last][0],max(f[last][1],f[last][2]-1))+tmp-now);
			  else f[now][2]=max(f[now][2],f[last][0]+tmp-now);
		}
		last=now++;
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 12416
function Main(input) {

    var lines = input.split('\n');
    var count = lines[0];
    var intArray = lines[1].split(' ');
    var total = 0;
    while (true) {
        for (i = 0; i < intArray.length ; i++) {
            if (parseInt(intArray[i]) % 2 !== 0) {
                console.log(total);
                return;
            }
            intArray[i] = intArray[i] / 2;
        }
        total = total + 1;
    }
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


def main():    
    MOD = 10 ** 9 + 7
    n = int(readline())
    a = list(map(int, readline().split()))
    ans = 0
    for i in range(60):
        x = 0
        for j in range(n):
            if a[j] >> i & 1:
                x += 1
        ans += x * (n - x) * 2 ** i
        ans %= MOD
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 89712
#include<vector>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;

const int N = 505;

int n;

char map[N][N];

int col[N], row[N];

int main() {
	scanf("%d", &n);
	bool hasBlack = false;
	for (int i = 0; i < n; ++i) {
		scanf("%s", map[i]);
		for (int j = 0; j < n; ++j) {
			if (map[i][j] == '#') {
				hasBlack = true;
				++col[j];
			} else {
				++row[i];
			}
		}
	}
	if (!hasBlack) {
		printf("-1\n");
		return 0;
	}
	int cnt = n;
	for (int i = 0; i < n; ++i) {
		if (col[i] == n) {
			--cnt;
		}
	}
	int ans = n * n;
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) {
			if (map[i][j] == '#') {
				ans = min(ans, cnt + row[j]);
			}
		}
	}
	for (int i = 0; i < n; ++i) {
		ans = min(ans, 1 + cnt + row[i]);
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 512
L,R = (int(i) for i in input().split())

num_list = []
if R-L >= 2019:
  num_list = [int(i) for i in range(0,2)]
else:
  num_list = [int(i) for i in range(L,R+1)]

ans = 2018
for i in range(len(num_list)):
  for j in range(i+1,len(num_list)):
    ans = min(ans,(num_list[i]*num_list[j])%2019)
print(ans)


Measured memory_bytes: 3060
h, w, k = gets.split.map(&:to_i)

ans = Array.new(h){Array.new(w)}
now = 0
arr = []

h.times do |i|
    s = gets.chomp
    x = s.index("#")
    
    if x.nil?
        i == 0 || ans[i-1][0].nil? ? arr.unshift(i) : ans[i] = ans[i-1]
    else
        now += 1
        ans[i].fill(now, 0..x)
        (x+1).upto(w-1) do |j|
            now += 1 if s[j] == "#"
            ans[i][j] = now
        end
    end
end

arr.each {|i| ans[i] = ans[i+1]}
puts ans.map{|e| e.join(" ")}

Measured memory_bytes: 3964
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let mut a = vec![0; n];
    for i in 0..n { a[i] = read(); }
    a.sort();
    println!("{}", a[n - 1] - a[0]);
}


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

int main() {
	int a, b,c,d;
	d = 0;
	while(cin >> a >> b){
		
		c = a + b;
		while (1) { if (c == 0) {cout << d << endl;
		d = 0; break;
		}
		else { d++; c = c / 10; }
		}
		
	}
	return 0;
}


Measured memory_bytes: 2988
s = input()
T = ""
n = int(input())
for i in range(n):
    # print(s,T)
    t = list(map(str,input().split()))
    if t[0] == "1":
        s,T = T,s
    else:
        if t[1] == "1":
            T += t[2]
        else:
            s += t[2]

print(T[::-1]+s)

Measured memory_bytes: 4436
#include<stdio.h>

int main(void)
{
	int A, B;

	scanf("%d %d", &A, &B);

	if (1 <= A && A <= 20 && 1 <= B && B <= 20) {
		if (A <= 9 && B <= 9)  printf("%d\n", A * B);
		else  printf("-1\n");
	}
	return 0;
}

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

#define _CRT_SECURE_NO_WARNINGS

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

using namespace std;

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

using LL = long long int;
using LD = long double;

const int INF = (1 << 30) - 1;
const LL INF64 = ((LL)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

using pii = pair<int, int>;
using pll = pair<LL, LL>;
using pdd = pair<double, double>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<LL>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vs = vector<string>;
using vb = vector<bool>;

//==============================================

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

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

	if (a <= 0 && 0 <= b) {
		cout << "Zero" << endl;
	} else if (0 < a) {
		cout << "Positive" << endl;
	} else {
		cout << ((b - a + 1) % 2 == 0? "Positive" : "Negative") << endl;
	}
	return 0;
}

Measured memory_bytes: 256
p, g = 998244353, 3
invg = pow(g, p-2, p)
W = [pow(g, (p - 1) >> i, p) for i in range(24)]
iW = [pow(invg, (p - 1) >> i, p) for i in range(24)]
def convolve(a, b):
    def fft(f):
        for l in range(k)[::-1]:
            d = 1 << l
            u = 1
            for i in range(d):
                for j in range(i, n, 2*d):
                    f[j], f[j+d] = (f[j] + f[j+d]) % p, u * (f[j] - f[j+d]) % p
                u = u * W[l+1] % p

    def ifft(f):
        for l in range(k):
            d = 1 << l
            u = 1
            for i in range(d):
                for j in range(i, n, 2*d):
                    f[j+d] *= u
                    f[j], f[j+d] = (f[j] + f[j+d]) % p, (f[j] - f[j+d]) % p
                u = u * iW[l+1] % p

    n0, n1 = len(a), len(b)
    k = (max(n0, n1) - 1).bit_length() + 1
    n = 1 << k
    a = a + [0] * (n-n0)
    b = b + [0] * (n-n1)
    fft(a), fft(b)
    for i in range(n):
        a[i] = a[i] * b[i] % p
    ifft(a)
    invn = pow(n, p - 2, p)
    return [a[i] * invn % p for i in range(n0 + n1 - 1)]

N, M = map(int, input().split())
A = [int(a) for a in input().split()]
B = [int(a) for a in input().split()]
print(*convolve(A, B))


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

using ll =long long;
void solve(int a,int b,int d){
    auto comp=[&](pair<ll,ll> lhs,pair<ll,ll> rhs){
        return lhs.first+lhs.second==rhs.first+rhs.second ?
                a*lhs.first+b*lhs.second<a*rhs.first+b*rhs.second :
                lhs.first+lhs.second<rhs.first+rhs.second;
    };
    ll xex,yex;
    for(int i=0;i<=b;i++){
        if((d-i*a)%b==0){
            xex=i,yex=(d-a*i)/b;
            break;
        }
    }
    pair<ll,ll> res={30000LL,30000LL};
    for(int k=-30000;k<=30000;k++){
        pair<ll,ll> tmp={abs(xex+b*k),abs(yex-a*k)};
        if(comp(tmp,res)) res=tmp;
    }
    cout<<res.first<<" "<<res.second<<endl;
}
int main(){
    int a,b,d;
    while(cin>>a>>b>>d,a){
        int g=__gcd(a,b);
        g=__gcd(g,d);
        a/=g,b/=g,d/=g;
        solve(a,b,d);
    }
    return 0;
}


Measured memory_bytes: 3080
#include <iostream>
#include <bits/stdc++.h>
#define ll long long

using namespace std;
ll Fact[400100],n,c[200100];
const ll Mod = 1e9 + 7;

long long fastpower(long long a,long long b)
{
    if(b==0)
        return 1;
    if(b==1)
        return a;
    long long res = fastpower(a,b/2)%Mod;
    res = (res %Mod  * res % Mod )%Mod;
    if(b%2!=0)
        res*=a;
    return res % Mod;
}



int main()
{
    cin >> n;
    for(int i = 0;i<n;i++)  cin >> c[i];
    Fact[0] = 1;
    for(int i = 1;i<=2*n;i++)  Fact[i] = Fact[i - 1] * i , Fact[i]%=Mod;
    sort(c , c + n);
    ll Ans = 0;
    for(int i = 0;i<n;i++){
            ll x = (c[i] * fastpower(2 , i))%Mod;
            ll y = ((n - i - 1) * fastpower(2 , n - i - 2) + fastpower(2 , n - i - 1))%Mod;
            Ans = ((Ans % Mod) + (x * y)%Mod)%Mod;
    }
    cout << (Ans * fastpower(2 , n))%Mod;
    return 0;
}


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

void solve() 
{
    ll n,k;cin>>n>>k;
    ll x=n%k;
    ll ans=min(x,abs(k-x));
    cout<<ans<<endl;
}

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

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

const int MAXX = 1e9 + 7;

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> h(n), dp(n);
    rep(i,n) cin >> h[i];
    dp[0] = 0;
/// dp[1] = abs(h[0]-h[1]);

    for(int i = 1; i < n; ++i)
    {
        int mini = MAXX, possible_prev = min(i,k);
        for(int j = 1; j <= possible_prev; ++j)
        {
            mini = min(mini, dp[i-j] + abs(h[i-j] - h[i]));
        }
        dp[i] = mini;
    }
    cout << dp[n-1] << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define sz(c) ((int)(c).size())

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
const ll MOD=1e6+3;

ll adm(ll a, ll b){
	return (a+b)%MOD;
}

ll tim(ll a, ll b){
	return (a*b)%MOD;
}
ll extgcd(ll a,ll b,ll& x, ll& y){
	ll d=a;
	if(b!=0){
		d = extgcd(b, a%b, y, x);
		y -= (a/b) * x;
	}
	else{
		x = 1; y = 0;
	}
	return d;
}
ll mod_inv(ll a){
	ll m=MOD;
	ll x,y;
	extgcd(a,m,x,y);
	return (m+x%m)%m;
}

ll pwm(ll a, int k){
  	if(k==1)return a;
	ll b=pwm(a, k/2);
	if(k%2==0){
		return tim(b, b);
	}
	else{
		return tim(tim(b, b), a);
	}
}

int main(){
	int Q;
	cin>>Q;
	
	ll fc[MOD];
	fc[0]=1;
	rep1(i,MOD-1)fc[i]=tim(fc[i-1], (ll)i);
	rep(i,Q){
		ll x,d,n;
		cin>>x>>d>>n;
		
		if(x==0){
			cout<<0<<endl;
			continue;
		}
		if(d==0){
			cout<<pwm(x, n)<<endl;
			continue;
		}
		
		ll v=mod_inv(d);
		v=tim(v, x);
		if(v+n-1>=MOD){
			cout<<0<<endl;
			continue;
		}
		ll ans=fc[v+n-1];
		ans=tim(ans, mod_inv(fc[v-1]));
		ll p=pwm(d,n);
//      	cout<<ans<<" "<<p<<" ";
		ans=tim(ans, p);
		cout<<ans<<endl;
	}
}


Measured memory_bytes: 8704
#include<iostream> 
using namespace std;
int main()
{
	int n;
	cin>>n;
	if(n>=64)
	    cout<<64;
	else
	if(n>=32)
	    cout<<32;
	else
	if(n>=16)
	    cout<<16;
	else
	if(n>=8)
	    cout<<8;
	else
	if(n>=4)
	    cout<<4;
	else
	if(n>=2)
	    cout<<2;
	else
	    cout<<1;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<map>
#include<algorithm>

using namespace std;

typedef struct {
    string name;
    int time;
} Proc;

class Queue {
public:
    Queue(int size) : m_queue(size), m_head(0), m_tail(0) {};
    ~Queue(){};
    void Enqueue(Proc& proc);
    Proc Dequeue();
    bool IsEmpty();

private:
    vector<Proc> m_queue;
    int m_head;
    int m_tail;
};

void Queue::Enqueue(Proc& proc)
{
    m_queue[m_tail] = proc;
    m_tail++;
    m_tail %= m_queue.size();
}

Proc Queue::Dequeue()
{
    Proc ret = m_queue[m_head];
    m_head++;
    m_head %= m_queue.size();

    return ret;
}

bool Queue::IsEmpty()
{
    return m_head == m_tail;
}

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

    Queue queue(n + 1);
    for (int i = 0; i < n; i++) {
        Proc proc;
        cin >> proc.name >> proc.time;
        queue.Enqueue(proc);
    }

    int time = 0;
    while (!queue.IsEmpty()){
        Proc tmp = queue.Dequeue();
        if (tmp.time <= q) {
            time += tmp.time;
            cout << tmp.name << " " << time << endl;
        } else {
            time += q;
            tmp.time -= q;
            queue.Enqueue(tmp);
        }
    }

    return 0;
}



Measured memory_bytes: 5948
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;} //最小公倍数

//-------------------------------------------------
// 
void yes(){
  cout <<"Yes"<<endl ;
}
void no(){
  cout <<"No"<<endl ;
}
void out(vector<vector<int>> vec,int n){
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cout << vec[i][j] ;
            if(j!=n-1){
                cout <<" " ;
            }
        }
        cout << endl ;
    }
}


//-------------------------------------------------
// メモ
/*






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


int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n ;
  cin >> n ;
  vector<vector<int>> graph(n,vector<int>(n,0)) ;
  REP(i,n){
      int ll ;
      cin >> ll ;
      int k ;
      cin >> k ;
      REP(j,k){
          int l ;
          cin >> l ;
          graph[ll-1][l-1] = 1 ;
      }
  }
  
  out(graph,n) ;
  
  
  
  return 0 ;
}



Measured memory_bytes: 3300
#include <iostream>

using namespace std;

int main()
{
    int d , n ;
    cin>>d>>n ;
    if(d == 0)
    {
        if(n < 100)
            cout<<n;
        else
            cout<<101;
        return 0 ;
    }
    else if(d == 1)
    {
        if(n < 100)
            cout<<100*n;
        else
            cout<<10100;
        return 0 ;
    }
    else
    {
        if(n < 100)
            cout<<10000*n ;
        else
            cout<<1010000 ;
        return 0 ;
    }
}


Measured memory_bytes: 256
import java.awt.*;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.math.BigInteger;
import java.util.*;

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

        a[0]=0;
        for(int i=1;i<a.length;i++){
            String s=i+"";
            int len=s.length();
            if((len&1)==1){
                a[i]=a[i-1]+1;
            }
            else a[i]=a[i-1];
        }
        int n=sc.nextInt();
        System.out.println(a[n]);
    }
}

Measured memory_bytes: 37056
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
using namespace std;
#define MOD int(1e9+7)

int main()
{
    int N;
    vector<string> S;
    map<string, long long> mp;
    long long count = 0;

    cin >> N;
    for(int i = 0; i < N; i++){
        string t;
        cin >> t;
        sort(t.begin(), t.end());

        auto itr = mp.find(t);
        if(itr != mp.end())
            mp[t] += 1;
        else
            mp[t] = 1;
    }

    for(auto itr = mp.begin(); itr != mp.end(); ++itr)
        count += itr->second * (itr->second - 1) / 2;

    cout << count << endl;

}

Measured memory_bytes: 11136
a,b=map(int,input().split())
ans=0
for i in range(a,b+1):
    d=list(str(i))
    dl=len(d)
    #print(dl)
    c=0
    for j in range(dl//2):
       # print(d[dl-1-i])
        if d[j]==d[dl-1-j]:
            c+=1
    if c==dl//2:
        ans+=1
print(ans)

Measured memory_bytes: 3060
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define SIZE(a) int((a).size();
const int INF=INT_MAX;
int main(){
  vll x(4),y(4);
  rep(i,0,2){
    cin>>x[i]>>y[i];
  }
  ll a=abs(y[0]-y[1]),b=abs(x[0]-x[1]);
  if(x[0]<=x[1]){
    y[3]=y[0]+b;y[2]=y[1]+b;
    if(y[0]<=y[1]){x[3]=x[0]-a;x[2]=x[1]-a;}
    else{x[3]=x[0]+a;x[2]=x[1]+a;}
  }
  else{
    y[3]=y[0]-b;y[2]=y[1]-b;
    if(y[0]<=y[1]){x[3]=x[0]-a;x[2]=x[1]-a;}
    else{x[3]=x[0]+a;x[2]=x[1]+a;}
  }
  cout<<x[2]<<" "<<y[2]<<" "<<x[3]<<" "<<y[3]<<endl;
}

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

using namespace std;

int main()
{
	int n, m;
	vector<int> v;
	
	scanf("%d", &n);
	
	for(int i = 0; i < n; i++)
	{
		scanf("%d", &m);
		v.push_back(m);
	}
	
	vector<int>::iterator it;
	
	for(it = v.end()-1; it != v.begin(); it--)
		printf("%d ", *it);
	printf("%d\n", *it);
	
	return 0;
}


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

template<typename T>
T get_value(std::istream& is);

int main() {
  cin.sync_with_stdio(false);
  cin.tie(nullptr);

  vector<int> v(get_value<size_t>(cin));
  const auto x {get_value<int>(cin)};
  for (auto& e: v)
    cin >> e;
  sort(v.begin(), v.end());

  auto left {x};
  for (auto i {0u}; i < v.size(); ++i) {
    if (left < v[i]) {
      cout << i;
      return 0;
    }
    left -= v[i];
  }
  cout << v.size() + (left ? -1 : 0) << '\n';
  return 0;
}

template<typename T>
inline T get_value(std::istream& is)
{
  T v;
  is >> v;
  return v;
}


Measured memory_bytes: 256
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n, m = li()
s = list(li())
t = list(li())

MOD = 10**9 + 7

dp = [[0]*(m+1) for _ in range(n+1)]
# for i in range(n+1):
#     dp[i][0] = 1
#
# for j in range(m+1):
#     dp[0][j] = 1

for i in range(n):
    for j in range(m):
        if s[i] == t[j]:
            dp[i+1][j+1] = (dp[i][j+1] + dp[i+1][j] + 1) % MOD
        else:
            dp[i + 1][j + 1] = (dp[i+1][j] + dp[i][j+1] - dp[i][j]) % MOD

print((dp[n][m] + 1) % MOD)


Measured memory_bytes: 72540
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
 long long a[10005];
int main(){
	int H,W,i=0,j=0;
	bool b=false;
	while (cin>>H>>W ){
		if(H==0&&W==0){
			cout<< endl;
			break;
		}
		if(b==true)cout<< endl;
		b=true;
		for(i=0; i<H; i++ ){
			for(j=0;j<W;j++){
				cout<<"#";
			}
			cout<< endl;   
		}	
	}
}



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

namespace ABC138_D
{
    class Program
    {
        static void Main(string[] args)
        {
            var NQ = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var N = NQ[0];
            var Q = NQ[1];

            long[] value = new long[N + 1];
            Node[] node = new Node[N + 1];

            var ab = new List<Tuple<int, int>>();
            for (int i = 0; i < N - 1; i++)
            {
                var line = Console.ReadLine().Split().Select(int.Parse).ToArray();
                ab.Add(new Tuple<int, int>(line[0], line[1]));

                if (node[line[0]] == null)
                {
                    node[line[0]] = new Node();
                }
                node[line[0]].Children.Add(line[1]);
            }

            var px = new List<Tuple<int, int>>();
            for (int i = 0; i < Q; i++)
            {
                var line = Console.ReadLine().Split().Select(int.Parse).ToArray();
                var p = line[0];
                var x = line[1];
                value[p] += x;
            }

            var q = new Queue<int>();
            q.Enqueue(1);

            var parent = new Queue<int>();
            parent.Enqueue(0);

            var ans = new long[N + 1];
            while (q.Count > 0)
            {
                var i = q.Dequeue();
                var p = parent.Dequeue();
                ans[i] += value[i] + ans[p];

                if (node[i] == null) continue;
                foreach (var c in node[i].Children)
                {
                    q.Enqueue(c);
                    parent.Enqueue(i);
                }
            }

            ans = ans.Skip(1).ToArray();
            Console.WriteLine(string.Join(" ", ans));
        }
    }

    public class Node
    {
        public List<int> Children { get; set; } = new List<int>();
    }
}


Measured memory_bytes: 72284
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
using namespace std;
typedef long long ll;
int main(){
  ll n;
  cin >> n;
  ll res = 0;
  for(ll i = 1;i <= n;i++){
    if(i % 3 != 0 && i % 5 != 0)res += i;
  }
  cout << res << endl;
  return 0;
}



Measured memory_bytes: 3636
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
#include <stdbool.h>

#define rep(i, n) for(int i=0; i<(n); ++i)
#define max  200001

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int int_sort( const void * a , const void * b ) {return strcmp(( char * )a , ( char * )b );}
int count_digit(int a){int i=0;while(a!=0){a=a/10;i++;}return i;}
int euclid( int a, int b ){int temp;if(a<b){temp=a;a=b;b=temp;}if(b<1)return -1;if(a%b==0) return b;return euclid(b,a%b);}

int main(void){
    
    int lens, lent;
    char s[max], t[max], tmp;
    
    scanf("%s%s", s, t);
    
    lens=strlen(s);
    lent=strlen(t);
    
    for (int i=0; i<lens; i++) {
        for (int j=i+1; j<lens; j++) {
            if (s[i]>s[j]) {
                tmp=s[i];
                s[i]=s[j];
                s[j]=tmp;
            }
        }
    }
    
    for (int i=0; i<lent; i++) {
        for (int j=i+1; j<lent; j++) {
            if (t[i]<t[j]) {
                tmp=t[i];
                t[i]=t[j];
                t[j]=tmp;
            }
        }
    }

    if (strcmp(s, t)<0) {
        printf("Yes");
    } else {
        printf("No");
    }

    return 0;
}


Measured memory_bytes: 1732
#include <iostream> pre processor directive
#include <string>
#include <iomanip>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    if (a>b ||a==b){
        int Arr1[a];
        for (int i=0;i<a;i++){
            Arr1[i]=b;
        }
        for (int i=0;i<a;i++){
            cout<<Arr1[i];
        }
        cout<<endl;
    }else{
        int Arr2[b];
        for(int i=0;i<b;i++){
            Arr2[i]=a;
        }
        for (int i=0;i<b;i++){
            cout<<Arr2[i];
        }
        cout<<endl;
    }
}



Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int i, j, k, d, g, p, c;
  scanf("%d%d", &d, &g);
  g /= 100;
  int dp[d * 100 + 1];
  for(i = 0; i <= d * 100; ++i) dp[i] = 0;
  for(i = 1; i <= d; ++i) {
    int tmp[d * 100 + 1];
    for(j = 0; j <= d * 100; ++j) tmp[j] = dp[j];
    scanf("%d%d", &p, &c);
    c /= 100;
    for(j = 1; j < p; ++j) for(k = 0; k < d * 100; ++k) if(j + k <= d * 100 && tmp[j + k] < dp[k] + i * j) tmp[j + k] = dp[k] + i * j;
    for(j = 0; p + j <= d * 100; ++j) if(tmp[p + j] < dp[j] + p * i + c) tmp[p + j] = dp[j] + p * i + c;
    for(j = 0; j <= d * 100; ++j) dp[j] = tmp[j];
  }
  for(i = 0; i <= d * 100; ++i) if(dp[i] >= g) {
    printf("%d", i);
    break;
  }
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    int x;
    cin>>x;
    if(x>=400&&x<=599)cout<<8<<endl;
    else if(x>=600&&x<=799)cout<<7<<endl;
    else if(x>=800&&x<=999)cout<<6<<endl;
    else if(x>=1000&&x<=1199)cout<<5<<endl;
    else if(x>=1200&&x<=1399)cout<<4<<endl;
    else if(x>=1400&&x<=1599)cout<<3<<endl;
    else if(x>=1600&&x<=1799)cout<<2<<endl;
    else if(x>=1800&&x<=1999)cout<<1<<endl;
    return 0;
}

Measured memory_bytes: 3616
// C - Guess The Number
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define NG puts("-1")

int main(){
	int N,M; cin>>N>>M;
	string T(N,'-');
	while(M--){
		int s,c; cin>>s>>c; s--, c+='0';
		if(T[s] !='-' && T[s] != c){ NG; return 0; }
		if(N!=1 && s==0 && c=='0'){ NG; return 0; }
		T[s] = c;
	}

	// int ans = 1000;
	// rep(i,1000){
	// 	string A = to_string(i);
	// 	if(A.size() != N) continue;
	// 	bool ok = true;
	// 	rep(j,N) if(T[j]!='-' && T[j]!=A[j]){ ok = false; break; }
	// 	if(ok) ans = min(ans, i);
	// }
	// cout<< ans <<endl;

	// char = '-';
	while(N--){
		if(T[N]=='-'){
			if(T.size()==1){
				T[N] = '0';
			}
			else if(T.size()==2){
				if(N==0){
					T[N] = '1';
				}
				else{// N==1
					T[N] = '0';
				}
			}
			else{// T.size()==3
				if(N==0){
					T[N] = '1';
				}
				else if(N==1){
					T[N] = '0';
				}
				else{// N==2
					T[N] = '0';
				}
			}

		}
		// else{
		// 	T[N] = '0';
		// }
	}
	cout<< stoi(T) <<endl;
}


Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) 
	{
		int MAX = 1000000;
		int[] sieve = new int[MAX+1];
		
		sieve[0] = 1;
		sieve[1] = 1; //0: divide by self. 1: dont divide, its not prime.
		for(long i = 2; i <= MAX; i++)
		{
			if(sieve[(int)i] == 0)
			{
				for(long j = i*i; j <= MAX; j+=i)
				{
					sieve[(int)j] = (int)i;
				}
			}
		}
		
//		for(int i = 0; i < 100; i++)
//			System.out.println(sieve[i]);
		
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] a = new long[n];
		long[] b = new long[n];
		
		long div[] = new long[1000001];
		
		for(int i = 0; i<n;i++)
		{
			a[i]= sc.nextLong();
			b[i] = a[i];
			
			
			while(sieve[(int)a[i]] != 1)
			{
				long diver = sieve[(int)a[i]];
				if(diver == 0)diver=a[i];
				int curder = 0;
				while(a[i]%diver == 0)
				{
					a[i] /= diver;
					curder++;
				}
				div[(int)diver] = Math.max(div[(int)diver], curder);
			}
		}
		
		long MOD = 1000000007;
		
		long master = 1;
		for(int i = 0; i < 1000000;i++)
		{
			if(div[i]>0)
			{
				for(int k = 0; k < div[i]; k++)
				{
					master = (master * i)%MOD;
				}
//				System.out.println(i + " " + div[i]);
			}
		}
		
		BigInteger bimod = new BigInteger("1000000007");
		BigInteger bin;
		BigInteger lcm = new BigInteger(Long.toString(master));
		
//		System.out.println("LCM " + lcm.toString());
		long an = 0;
		for(int i = 0; i < n; i++)
		{
			bin = new BigInteger(Long.toString(b[i]));
//			System.out.println("abinv "+  bin);
			bin = bin.modInverse(bimod);
			
//			System.out.println("binv "+  bin);
			bin = bin.multiply(lcm);
//			System.out.println("bin "+  bin);
			bin = bin.mod(bimod);
			an += bin.longValueExact();
		}
		System.out.println(an%MOD);
		
		
		

	}

}


Measured memory_bytes: 53064
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <cmath>
#include <map>
#include <fstream>
#include <iterator>
// #include "prettyprint.hpp"

using namespace std;
using ll = long long;

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

    double ans = 0;
    for (int i = 1; i <= N; ++i)
    {
        int cnt = 0;
        for (int j = i; j < K; j *= 2)
        { 
            cnt++;
        }
        long double exception = pow(0.5, cnt) * (1 / double(N));
        ans += exception;
    }
    printf("%.16f", ans);
}

Measured memory_bytes: 256
let fold_int f a n =
  let rec fold f a i n =
    if i >= n then
      a
    else
      fold f (f a i) (i + 1) n
  in
    fold f a 0 n

let list_to_array n a xs =
  let res = Array.make n a in
  List.iteri (fun i x -> res.(i) <- x) xs;
  res

(* O(N) *)
let get_max a used =
  fold_int
    (fun (ma, j) i ->
      if used.(i) then
        ma, j
      else
        if a.(i) > ma then a.(i), i else ma, j)
    (-1, -1)
    (Array.length a)

(* O(N^2) *)
let solve n a_s =
  let a_s = list_to_array n 0 a_s in
  let used = Array.make n false in
  fold_int
    (fun sofar i ->
      let ma, j = get_max a_s used in
      used.(j) <- true;
      if i mod 2 = 0 then
        sofar + ma (* Alice *)
      else
        sofar - ma) (* Bob *)
    0
    n

let read_ints () = read_line () |> Str.split (Str.regexp " ") |> List.map int_of_string

let _ =
  let n = read_int () in
  let a_s = read_ints () in
  solve n a_s |> string_of_int |> print_endline

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstring>
#define N 105
using namespace std;

int n, w, a0, s, mx, a[N], b[N], d[N][305];
int main()
{
	int i, j, k;
	memset(d, -1, sizeof(d));
	d[0][0] = 0;
	cin >> n >> w;
	for (i = 0; i < n; i++) {
		scanf("%d %d", &a[i], &b[i]);
		if (!i) a0 = a[0];
		a[i] -= a0;
		s += a[i];
	}
	for (i = 0; i < n; i++) {
		for (j = i + 1; j > 0; j--) {
			for (k = a[i]; k + a0 * j <= w && k <= s; k++) {
				if (d[j - 1][k - a[i]] >= 0) d[j][k] = max(d[j][k], d[j - 1][k - a[i]] + b[i]), mx = max(mx, d[j][k]);
			}
		}
	}
    cout << mx << endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define irep(i,a,b) for(typeof(i) i = (a); i < (b); ++i)
#define itrep(it,c) for(auto it = (c).begin(); it != (c).end(); ++it)


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

	char S[101];
	int K;
	char* p = S;
	cin >> K >> S;
	while (*p != '\0') {
		cout << *p;
		K--;
		p++;
		if (K == 0) break;
	}
	if (*p == '\0') {
		cout << endl;
	}
	else {
		cout << "..." << endl;
	}
	return(0);
}


Measured memory_bytes: 3612
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=505,M=N*N;
int n,i,x,j,a[M];
struct arr{int x,k;}d[N];
bool operator < (arr A,arr B){return A.x<B.x;}
void write(int x){if (x>9) write(x/10);putchar(x%10+48);}
int main(){
	for (scanf("%d",&n),i=1;i<=n;i++)
		scanf("%d",&d[i].x),d[i].k=i;
	sort(d+1,d+n+1);x=1;
	for (i=1;i<=n;i++){
		int k=d[i].k,nx=d[i].x;
		for (j=k-1;j&&x<nx;j--){
			for (;a[x];x++);a[x]=k;
		}
		if (a[nx]){puts("No");return 0;}
		a[nx]=k;
	}
	for (x=n*n,i=n;i;i--){
		int k=d[i].k,nx=d[i].x;
		for (j=n-k;j&&x>nx;j--){
			for (;a[x];x--);a[x]=k;
		}
		if (k!=n&&x<=nx){puts("No");return 0;}
	}
	puts("Yes");
	for (i=1;i<=n*n;i++) write(a[i]),putchar(' ');
}

Measured memory_bytes: 2048
#include <stdio.h>
int main(void){
	int W,H,x,y,r;
	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
	if(x-r>=0 && x+r<=W && y-r>=0 && y+r<=H){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}


Measured memory_bytes: 2140
include Math
a, b, c = gets.chomp.split(' ').map(&:to_f)
rad = (c/180)*PI
s = (a * b * sin(rad)/2).round(6)
l = (a + b + sqrt(a**2 + b**2 - 2*a*b*cos(rad))).round(6)
h = (b * sin(rad)).round(6)
puts s
puts l
puts h

Measured memory_bytes: 6224