akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

int main(void){
  int n; cin >> n;
  int a[n], b[n], c[n], d[n];
  for(int i=0;i<n;i++) cin>>a[i];
  for(int i=0;i<n;i++) cin>>b[i];
  for(int i=0;i<n;i++) {c[i]=a[i], d[i]=b[i];}

  sort(c, c+n);
  sort(d, d+n);
  int p=1, q=1;
  do {
    bool sm=true;
    for(int i=0;i<n&&sm;i++) if (c[i]!=a[i]) sm=false;
    if (sm) break; else p++;
  } while(next_permutation(c, c+n));

  do {
    bool sm=true;
    for(int i=0;i<n&&sm;i++) if (d[i]!=b[i]) sm=false;
    if (sm) break; else q++;
  } while(next_permutation(d, d+n));

  //cout<<p<<" "<<q<<endl;
  cout<<abs(p-q)<<endl;
}

Measured memory_bytes: 256
N = int(input())
XL = sorted([list(map(int, input().split())) for _ in range(N)])

remove = 0
reach = 0

for i in range(N):
    r = XL[i]
    right = r[0] + r[1]
    left = r[0] - r[1]

    if i == 0:
        reach = right
        continue

    if reach > left:
        reach = min(reach, right)
        remove += 1
    else:
        reach = right

print(N - remove)


Measured memory_bytes: 62808
// C - Average Length
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define rpz(i,e) rp(i,0,e)

int N;
vvi XY(8, vi(2));
double ans = 0.0;
vi visited(8, false);

void dfs(int p, int depth, double dist){
	rpz(c, N){
		if(c == p) continue;
		if(visited[c]) continue;
		int dx = XY[p][0] - XY[c][0];
		int dy = XY[p][1] - XY[c][1];
		double d = sqrt(dx*dx + dy*dy);
		if(depth+1 >= N-1) ans += dist + d;
		else{
			visited[c] = true;
			dfs(c, depth+1, dist + d);
			visited[c] = false;
		}
	}
}

int main(){
	cin>>N;
	rpz(i, N) cin>>XY[i][0]>>XY[i][1];
	rpz(r, N){
		visited[r] = true;
		dfs(r, 0, 0.0);
		visited[r] = false;
	}
	int n = 1;
	rp(i, 2, N+1) n *= i;
	printf("%.10f\n",ans/n);
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
def solve():
    N, K = map(int, input().split())
    N_1 = [{1},{0}]+[set() for _ in range(N-1)]
    for _ in range(N-1):
        a, b = map(int, input().split())
        N_1[a].add(b)
        N_1[b].add(a)
    checked, q = set(), {0}
    res = 1
    while q:
        n = q.pop()
        checked.add(n)
        q.update(set.difference(N_1[n], checked))
        K_ = K-min(2,n)
        for i in range(len(N_1[n])-(n>0)):
            if K_ == i:
                return str(0)
            res = (res*(K_-i))%(10**9+7)
    return str(res)
if __name__ == '__main__':
    print(solve())



Measured memory_bytes: 47384
N = int(input())
if 1 <= N <2:
  print(1)
if 2 <= N <4:
  print(2)
if 4 <= N <8:
  print(4)
if 8 <= N <16:
  print(8)
if 16 <= N <32:
  print(16)
if 32 <= N <64:
  print(32)
if 64 <= N <= 100:
  print(64)

Measured memory_bytes: 3060
#include<cstdio>
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#define all(X) X.begin(),X.end()
#define rep(X,Y) for(int X=0;(X)<(Y);++(X))

using namespace std;

typedef vector<vector<int>> vvi;

int main(){
  int n;
  while(cin>>n,n){
    vvi v(n);
    int m;
    rep(i,n){
      cin>>m;
      v[i].resize(m);
      rep(j,m)
	cin>>v[i][j];
    }
    cin>>m;
    vector<int> l(m);
    rep(i,m){
      cin>>l[i];
    }
    vector<int> re(n,1);
    rep(i,m){
      rep(j,n){
	int f=0;
	for(int a:v[j])
	  if(a==l[i]) f=1;
	if(!f) re[j]=0;
      }
    }
    int sum=accumulate(all(re),0);
    if(sum==1){
      rep(i,n)
	if(re[i])
	  cout<<i+1<<endl;
    }else{
      cout<<-1<<endl;
    }
  }
}

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

using namespace std;


void solve() {
    int n, W;
    cin >> n >> W;
    map<int, int> dp;
    dp[0] = 0;
    for (int _ = 0; _ < n; _++) {
        int w,v;
        cin >> w >> v;
        vector<pair<int, int>> a;
        for (auto& p: dp) {
            if (p.first + w > W) break;
            a.emplace_back(p.first+w, p.second+v);
        }
        for (auto& p: a) {
            if (dp.find(p.first)!=dp.end()) {
                dp[p.first] = max(dp[p.first], p.second);
            } else {
                dp[p.first] = p.second;
            }
        }
    }
    int res = 0;
    for (auto& p: dp) {
        res = max(res, p.second);
    }
    cout << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;

int main()
{
	int N, K;
	cin >> N >> K;
	bool D[10];
	memset(D, 0, sizeof(D));

	for (auto i = 0; i < K; ++i)
	{
		int d;
		cin >> d;
		D[d] = true;
	}

	for (auto i = N; i < 1000000; ++i)
	{
		auto temp = i;
		auto isValid = true;
		while (temp > 0)
		{
			if (D[temp % 10] != false)
			{
				isValid = false;
				break;
			}
			temp /= 10;
		}

		if (isValid)
		{
			cout << i << endl;
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 256
# coding: utf-8
# hello worldと表示する
#dpでできないかな？
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n=I()
l=LI()
lis=[]
for i in range(n):
    lis.append(l[i]-1)
    lis.append(l[i]+1)
    lis.append(l[i])
c=Counter(lis)
u=c.most_common()[0]
print(u[1])

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

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

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

    string s[n];
    map<char, int> mp;
    cin >> s[0];
    for (int j = 0; j < s[0].size(); j++) mp[s[0][j]]++;

    for (int i = 1; i < n; i++) {
        cin >> s[i];
        map<char, int> mp_tmp;
        for (int j = 0; j < s[i].size(); j++) mp_tmp[s[i][j]]++;
        for (char c = 'a'; c <= 'z'; c++) mp[c] = min(mp[c], mp_tmp[c]);
    }

    for (char c = 'a'; c <= 'z'; c++) {
        for (int i = 0; i < mp[c]; i++) printf("%c", c);
    }
    printf("\n");

    
}

Measured memory_bytes: 3208
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int x,y,z,k;
 
bool inc(tuple<int,int,int>& t,int i){
    if(i==0){
        if(get<0>(t)==x-1)return false;
        get<0>(t)++;
    }
    else if(i==1){
        if(get<1>(t)==y-1)return false;
        get<1>(t)++;
    }
    else{
        if(get<2>(t)==z-1)return false;
        get<2>(t)++;
    }
    return true;
}
 
void dec(tuple<int,int,int>& t,int i){
    if(i==0)get<0>(t)--;
    else if(i==1)get<1>(t)--;
    else get<2>(t)--;
}
 
int main(){
    cin>>x>>y>>z>>k;
    ll a[1000],b[1000],c[1000];
    for(int i=0;i<x;i++)cin>>a[i];
    for(int i=0;i<y;i++)cin>>b[i];
    for(int i=0;i<z;i++)cin>>c[i];
    sort(a,a+x,greater<ll>());
    sort(b,b+y,greater<ll>());
    sort(c,c+z,greater<ll>());
    priority_queue<pair<ll,tuple<int,int,int>>> pq;
    set<tuple<int,int,int>> set;
    pq.push(make_pair(a[0]+b[0]+c[0],make_tuple(0,0,0)));
    set.insert(make_tuple(0,0,0));
    for(int i=0;i<k;i++){
        auto t=pq.top();
        pq.pop();
        cout<<t.first<<endl;
        auto u=t.second;
        for(int j=0;j<3;j++){
            if(!inc(u,j))continue;
            if(set.find(u)==set.end()){
                pq.push(make_pair(a[get<0>(u)]+b[get<1>(u)]+c[get<2>(u)],u));
                set.insert(u);
            }
            dec(u,j);
        }
    }
}


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

int main(void) {
	int n;
	int a[101];
	int flag[9] = {};
	int count = 0;
	int maxi, mini;

	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}

	for (int i = 1; i <= n; i++) {
		if (a[i] / 400 >= 8) {
			flag[8]++;
		}
		else {
			flag[a[i] / 400]++;
		}
	}

	for (int i = 0; i <= 7; i++) {
		if (flag[i]>=1) {
			count++;
		}
	}

	mini = max(1, count);
	maxi = count + flag[8];

	cout << mini << " " << maxi << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    string S;
    cin >> S;

    int len;
    len = S.size()-2;

    string ans;
    ans = S.at(0) + to_string(len) + S.at(len+1);

    cout << ans;
    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.math.*;
import java.util.*;

public class Main {
    private static boolean debug = false;
    private static boolean elapsed = true;

    private static PrintWriter _out = new PrintWriter(System.out);
    private static PrintWriter _err = new PrintWriter(System.err);

    private static long MOD = 1_000_000_007;
    private static BigInteger MOD_BI = BigInteger.valueOf(MOD);

    private void solve(Scanner sc) {
        int N = sc.nextInt();
        int M = sc.nextInt();

        if (Math.abs(N - M) > 1) {
            _out.println(0);
            return;
        }

        BigInteger res;
        if (N > M) {
            res = P(N, N).multiply(P(N - 1, M)).remainder(MOD_BI);
        } else if (N < M) {
            res = P(M, M).multiply(P(M - 1, N)).remainder(MOD_BI);
        } else {
            res = P(N, N).multiply(P(N, M)).multiply(BigInteger.valueOf(2)).remainder(MOD_BI);
        }
        _out.println(res);
    }
    private static BigInteger C(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        for (long i = r; i > 1; --i) {
            res = res.divide(BigInteger.valueOf(i));
        }
        return res;
    }
    private static BigInteger P(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i)).remainder(MOD_BI);
        }
        return res;
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();

        Scanner sc = new Scanner(System.in);
        new Main().solve(sc);
        _out.flush();

        long G = System.currentTimeMillis();
        if (elapsed) {
            _err.println((G - S) + "ms");
        }
        _err.flush();
    }
}

Measured memory_bytes: 53168
x = [[0]*50 for i in range(11)]
for i in range(0, 2**10):
    B = format(i,'b')[::-1]
    s,c,j = 0,0,0
    for e in B:
        if e=="1": s+=j; c+=1
        j+=1
    x[c][s]+=1

while 1:
    n,s = map(int, raw_input().split())
    if n==0 and s==0: break
    print 0 if s>=50 else x[n][s]

Measured memory_bytes: 4244
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		if(a%3==0||b%3==0||(a+b)%3==0) {
			System.out.println("Possible");
		}else {
			System.out.println("Impossible");
		}
	}

}


Measured memory_bytes: 21588
n,t = map(int, input().split())
a = []
for i in range(n):
    aa = list(map(int, input().split()))
    a.append(aa)

cost = float(10000)
for a in a:
    if a[1] <= t and a[0] < cost:
        cost = a[0]

if cost == 10000:
    cost = 'TLE'
print(cost)


Measured memory_bytes: 62648
n, m = map(int, input().split())
denq = []
for _ in range(m):
    ks = tuple(map(lambda x: int(x)-1, input().split()))
    denq.append(ks[1:])
P = tuple(map(int, input().split()))

ans = 0
for i in range(2**n):
    kk = [0] * m
    # switch_states = [(i>>j)&1 for j in range(n)]
    for idq, dq in enumerate(denq):
        counts = 0
        for s in dq:
            counts += (i>>s)&1
        if counts%2 != P[idq]:
            break
    else:
        ans += 1
print(ans)


Measured memory_bytes: 68044
#include <iostream>
#include <vector>
#include <string>
 
using namespace std;
 
int main()
{
    string s;
    std::cin >> s;
 
    for(int i = 0; i < (((s.length() - 1) / 2) / 2); i++){
        if(s[i] != s[((s.length() - 1) / 2) - i - 1]){
            std::cout << "No" << std::endl;
            //std::cout << "out1" << std::endl;
            return 0;
        }
    }
 
    for(int i = 0; i < (((s.length() - 1) / 2) / 2); i++){
        if(s[((s.length() + 3) / 2) + i - 1] != s[s.length() - i - 1]){
            std::cout << "No" << std::endl;
            //std::cout << "out2" << std::endl;
            return 0;
        }
    }
 
    for(int i = 0; i < (((s.length() - 1) / 2) / 2 + 1); i++){
        if(s[i] != s[s.length() - i - 1]){
            std::cout << "No" << std::endl;
            //std::cout << "out3" << std::endl;
            return 0;
        }
    }
 
    std::cout << "Yes" << std::endl;
 
    return 0;
}

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

int main(void){
  int n, a, b;
  cin >> n >> a >> b;
  int p[n];
  for(int i = 0; i < n; i++) cin >> p[i];
  int l = 0;
  int m = 0;
  int h = 0;
  for(int i = 0; i < n; i++){
    if(p[i] <= a) l++;
    if(a + 1 <= p[i] && p[i] <= b) m++;
    if(b + 1 <= p[i]) h++;
  }
  l = min(l, m);
  l = min(l, h);
  cout << l << endl;
  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <complex>
#include <set>
#include <list>
#include <iomanip>
#include <map>
#include <memory.h>



using namespace std;
static const double EPS = 1e-9;
typedef long long ll;
typedef unsigned long long ull;
#define FOR(i,n) for(int i=0;i<(int)n;++i)
#define FORNUM(p, x) for (int num = p; num < (int)(x); ++num)
#define FORI(p, x) for (int i = p; i < (int)(x); ++i)
#define FORJ(p, x) for (int j = p; j < (int)(x); ++j)
#define FORK(p, x) for (int k = p; k < (int)(x); ++k)
#define FORL(p, x) for (int l = p; l < (int)(x); ++l)

typedef pair<int,int>P;
#define INF 1000000000
 
struct edge { 
	int from, to; 
	edge (int from, int to){
		this->from=from; this->to=to;
	}
};
 
int V,E;
typedef vector<edge> edges;
vector<edges> G;

int a[105];

int main(){
	int n;
	cin >> n;
	int mi = 200, ma = -200;
	FORI(0,n) {
		cin >> a[i];
		mi=min(mi, a[i]); ma=max(ma, a[i]);
	}
	int ans = INF;
	for (int i = mi; i <= ma; i++) {
		int sum = 0;
		FORJ(0, n) {
			sum += (a[j] - i)*(a[j] - i);
		}
		ans = min(sum, ans);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>


long long  INF=1000000000000000000;
long long mod=1000000007;
using namespace std;


int main(){
int N;
cin>>N;
multimap<long long,int> A;
vector<long long>v(N);
long long a;
for(int i=1;i<=N;i++){
    cin>>a;
    A.insert(make_pair(a,i));
}
auto iter=A.begin();
long long ans=0;
for(int i=1;i<=N;i++){
if(iter->second%2==1 && i%2==0){
    ans++;
}
iter++;
}

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

Measured memory_bytes: 7424
# -*- coding: utf-8 -*-
import numpy as np

n, m = map(int, input().split())
h = np.array(input().split(), dtype='int')
bad_tower = []

for i in range(m):
    a, b = map(int, input().split())
    ha = h[a-1]
    hb = h[b-1]

    if ha > hb:
        bad_tower.append(b)
    elif ha < hb:
        bad_tower.append(a)
    elif ha == hb:
        bad_tower.append(a)
        bad_tower.append(b)

bad_tower = np.unique(bad_tower)

ans = n - len(bad_tower)

print(ans)

Measured memory_bytes: 40256
import * as fs from 'fs';

export class Reader {
    lines: string[];
    currentLine: number;

    constructor() {
        this.lines = fs.readFileSync("/dev/stdin", "utf8").trim().split("\n");
        this.currentLine = 0;
    }

    readLine(): string {
        return this.lines[this.currentLine++];
    }

    readInt(): number {
        return Number(this.readLine());
    }

    readInts(): number[] {
        return this.readLine().split(" ").map(Number);
    }
}

let reader = new Reader();
let N = reader.readInt();

let A: number[] = [], B: number[] = [];

for(let i=0; i<N; i++) {
	let [a, b] = reader.readInts();
	A.push(a);
	B.push(b);
}

function findMedian(arr: number[]) {
	arr.sort((a, b) => a-b);
	let median: number;
	let mid = Math.floor(arr.length/2);
	if (arr.length%2 == 1)
		median = arr[mid];
	else
		median = (arr[mid-1]+arr[mid])/2;
	return median;
}

let medians = findMedian(B)-findMedian(A)+1;
if (N%2 == 0)
	medians += medians-1
console.log(medians);


Measured memory_bytes: 90160
#include<bits/stdc++.h>
using namespace std;
#define int long long

#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif

signed main(){

  int a; cin >> a;
  string s; cin >> s;

  //int b = int(s - '0');
  if(a >= 3200) cout << s << endl;
  else cout << "red" << endl;

  return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
keys = []
for _ in range(M):
  a, b = map(int, input().split())
  c = list(map(int, input().split()))
  s = 0
  for cc in c:
    cc -= 1
    s |= 1<<cc
  keys += [(s, a)]

dp = [float('inf')]*(1<<N)
dp[0] = 0
for s in range(1<<N):
  for i in range(M):
    t = s | keys[i][0]
    dp[t] = min(dp[t], keys[i][1]+dp[s])

if dp[-1] == float('inf'):
  print(-1)
else:
  print(dp[-1])

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

bool Comp(pair<int,int>a,pair<int,int>b)
{
    return a.second < b.second;
}
int main()
{
   int N,M;
   cin >> N >> M;
   vector<pair<int,int>>ab(M);
   rep(i,0,M){
       cin >> ab[i].first >> ab[i].second;
   }
   sort(ab.begin(),ab.end(),Comp);

   int prev=-1;
   ll ans=0;
   rep(i,0,M){
       if(prev<ab[i].first)
       {
           ans++;
           prev=ab[i].second-1;
       }
   }

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

Measured memory_bytes: 1024
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

h,w,k = inpl()
s = [input() for _ in range(h)]
bl = sum(1 if x == '#' else 0 for i in range(h) for x in s[i])
res = 0
for yy in itertools.product([0,1], repeat = h):
    for xx in itertools.product([0,1], repeat = w):
        cnt = 0
        seen = set()
        for i,y in enumerate(yy):
            if y:
                for j in range(w):
                    if (i,j) in seen:
                        continue
                    seen.add((i,j))
                    if s[i][j] == '#':
                        cnt += 1
        for j,x in enumerate(xx):
            if x:
                for i in range(h):
                    if (i,j) in seen:
                        continue
                    seen.add((i,j))
                    if s[i][j] == '#':
                        cnt += 1
        if bl-cnt == k:
            res += 1
print(res)

Measured memory_bytes: 84644
package main

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

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

func main() {
	X := nextInt()
	var n int
	// 一応、値決め打ちでなくてちゃんと計算させた場合
	for i := 0; i*i*i*i*i-(i-1)*(i-1)*(i-1)*(i-1)*(i-1) < 1e9; i++ {
		n = i + 1
	}
	for i := 0; i <= n; i++ {
		for j := 0; j <= i; j++ {
			if i*i*i*i*i-j*j*j*j*j == X {
				fmt.Println(i, j)
				return
			} else if i*i*i*i*i+j*j*j*j*j == X {
				fmt.Println(i, -j)
			}
		}
	}
}

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


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()   //reverse
#define strall(v) (v).cbegin(),(v).cend() //const_itterator
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
const long long INF = 1LL << 60;
//const int INF = 1e9+5;


int main(){
  int n,W;
  cin >> n >> W;
  vector<ll> w(n),v(n);
  rep(i,n) cin >> w[i] >> v[i];
  vector<vector<ll>> dp(n+5,vector<ll>(100005,INF));
  dp[0][0] = 0;
  int MAX_V = 100005;
  for(int i=0;i<n;i++){
    for(int j=0;j<MAX_V;j++){
      
      if(j-v[i] >= 0){
        chmin(dp[i+1][j],dp[i][j-v[i]]+w[i]);
      }
      
      chmin(dp[i+1][j],dp[i][j]);
      
    }
  }
  ll res = 0;
  rep(i,MAX_V) if(dp[n][i] <= W) res = i;
  cout << res << endl;
} 

Measured memory_bytes: 83328
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readA(T)(size_t n,ref T[]t){t=new T[](n);auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  int[] a; readA(3, a);

  auto r = int.max;
  foreach (p; iota(3).permutations)
    r = min(r, (a[p[1]]-a[p[0]]).abs + (a[p[2]]-a[p[1]]).abs);

  writeln(r);
}


Measured memory_bytes: 256
N, M = [int(x) for x in input().split()]
KAs = [[int(x) for x in input().split()] for _ in range(N)]

s = set()
for i in range(1, M + 1):
    s.add(i)
for KA in KAs:
    As = KA[1:]
    for i in range(1, M + 1):
        if not i in As and i in s:
            s.remove(i)
ans = len(s)

print(ans)


Measured memory_bytes: 3064
import itertools
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

seq = (a,b,c,d,e)
a = list(itertools.permutations(seq))
mn = 10**4
for i in range(120): #行
  sm = 0
  for j in range(4): #列
    sm += a[i][j]
    if sm%10 != 0:
      sm += (10-sm%10)
  sm += a[i][-1]
  mn = min(mn, sm)
print(mn)

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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
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;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

// テーブルを作る前処理
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        ll num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

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

    vector<ll> x(N);
    vector<ll> x2(N);
    vector<ll> y(N);
    vector<ll> y2(N);

    REP(i,N) {
        cin >> x[i] >> y[i];
        x2[i] = x[i];
        y2[i] = y[i];
    }
    sort(all(x2));
    sort(all(y2));

    ll ans = (x2[N-1] - x2[0]) * (y2[N-1] - y2[0]);
    REP(xi,N) rep(xj,xi+1,N) REP(yi,N) rep(yj,yi+1,N) {
        ll xl = x2[xi];
        ll xr = x2[xj];
        ll yl = y2[yi];
        ll yr = y2[yj];

        int num = 0;
        REP(i,N) if(xl <= x[i] && x[i] <= xr && yl <= y[i] && y[i] <= yr) num++;

        if(num >= K) {
            chmin(ans,(xr-xl)*(yr-yl));
        }
    }  

    pl(ans)

    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MAX 510000
#define rrep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define dcout cout<<fixed<<setprecision(15);

using namespace std;
typedef long long int  ll;
typedef pair<ll, ll> P;

constexpr ll MOD = 1e9 + 7;
constexpr ll inf = 1LL << 60;

template< typename S, typename T >
inline void chmax(S &a, const T &b) { if(a < b) a = b; }
 
template< typename S, typename T >
inline void chmin(S &a, const T &b) { if(a > b) a = b; }
 


//a^n mod p//
ll modpow(ll a, ll n, ll p) {
  if( n==0) return (ll)1;
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modpow(a, n - 1, p)) % p;
  ll t = modpow(a, n / (ll)2, p);
  return (t * t) % p;
}

//inversemod//
ll modinv(ll a, ll m) {
	if(m==0)return (ll)1;
	ll b = m, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//Cmonp//
ll fac[MAX], finv[MAX], inv[MAX];
// 
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 
ll COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//LARGE n
ll com(ll n,ll m){
    if(n<m || n<=0 ||m<0){
		return 0;
	}
	if( m==0 || n==m){
		return 1;
	}
	ll k=1;
	for(ll i=1;i<=m;i++){
       k*=(n-i+1); 
	   k%=MOD;
	   k*=modinv(i,MOD);
	   k%=MOD;
	}
	return k;
}

//radP
ll rad(ll u, ll p){
ll cnt=0;
	while(u%p==0){
		u/=p;
		cnt++;
	}
	return cnt;
}

ll gcdd(ll x, ll y) {
	if (x == 0) return y;
	return gcdd(y%x, x);
}



////////////////////////////////////////////////////////////////////


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

ll me[200051];
me[0]=1;
for(ll i=1;i<=200050;i++){
me[i]=me[i-1]*2;
me[i]%=MOD;
}



vector<P> vec{};
map<P, ll> mp{};

ll t=0;

rep(i,n){
  ll p,q;
  cin>>p>>q;
  ll pp=abs(p);
  ll qq=abs(q);
  if(pp!=0 && qq!=0){
    ll v=gcdd(pp, qq);
    p/=v;
    q/=v;
  }


  if(q<0 && p<0){
    p=-p;
    q=-q;
  }
  if(p<0 && q>0){
    q=-q;
    p=-p;
  }

  if(p==0 && q==0){t++; continue;}
  if(p==0)q=10;
  if(q==0)p=10;
vec.push_back(make_pair(p,q));
if(!mp.count(make_pair(p,q))) mp[make_pair(p,q)]=1;
else mp[make_pair(p,q)]++;

 
}


ll ans=(ll)1;


for(ll i=0;i<vec.size();i++){
 ll p=vec[i].first;
 ll q=vec[i].second;

ll val=(ll)0;

if(mp[make_pair(p,q)]==0){continue;}
val+=me[mp[make_pair(p,q)]];
val%=MOD;

ll newp;
ll newq;

if(p==0 || q==0){newp=q; newq=p;}
else if(p>0 && q>0){newp=q; newq=-p;}
else{newp=-q; newq=p;}

if(mp.count(make_pair(newp,newq))){
val+=me[mp[make_pair(newp,newq)]];
val+=MOD-1;
mp[make_pair(newp,newq)]=0;
val%=MOD;
}
ans*=val;
ans%=MOD;

mp[make_pair(p,q)]=0;
}

cout<<(ans-(ll)1+t+MOD)%MOD<<endl;

return 0;


}



Measured memory_bytes: 20372
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define ceiling(a,b) (((a)+(b)-1)/(b))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#ifdef i_am_noob
#define debug(a) print2(#a,a)
#else
#define debug(a) 
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
 
using namespace std;
using namespace __gnu_pbds;
 
const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod2;
 
inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}
 
const int maxn=100005;
//i_am_noob
int a,b,c;

signed main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
	cin >> a >> b >> c;
	print1(a+b+c-max(max(a,b),c));
	return 0;
}


Measured memory_bytes: 256
<?php
fscanf(STDIN,"%d%d%d", $W, $H, $N);
for($y = 1; $y <= $H; $y++){
    for($x = 1; $x <= $W; $x++){
        $map[$y][$x] = 1;
    }
}
for($i = 0; $i < $N; $i++){
    fscanf(STDIN,"%d%d%d", $X, $Y, $A);
    switch($A){
        case 1:
            for($y = 1; $y <= $H; $y++){
                for($x = 1; $x <= $X; $x++){
                    $map[$y][$x] = 0;
                }
            }
            break;
        case 2:
            for($y = 1; $y <= $H; $y++){
                for($x = $X+1; $x <= $W; $x++){
                    $map[$y][$x] = 0;
                }
            }
            break;
        case 3:
            for($y = 1; $y <= $Y; $y++){
                for($x = 1; $x <= $W; $x++){
                    $map[$y][$x] = 0;
                }
            }
            break;
        case 4:
            for($y = $Y+1; $y <= $H; $y++){
                for($x = 1; $x <= $W; $x++){
                    $map[$y][$x] = 0;
                }
            }
            break;
    }
}

$sum = 0;
foreach($map as $line){
    $sum+=array_sum($line);
}
echo $sum;


Measured memory_bytes: 4604
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
    int N, T;
    cin >> N >> T;
    int minCost = 9999;
    for(int i = 0; i < N; i++) {
        int c, t;
        cin >> c >> t;
        if(T >= t) {
           minCost = min(minCost, c);
	    }
    }
    if(minCost == 9999) {
        cout << "TLE" << endl;
    } else {
        cout << minCost << endl;
    }
}


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



class list {
public:
    int val;
    list* prev;
    list* next;
};
list* head = NULL;
list* tail = NULL;

void insert_(int val)
{
    list* element;
    element = new list;
    element->val = val;
    element->prev = NULL;
    if (head == NULL) {
        element->next = NULL;
        tail = element;
    } else {
        head->prev = element;
        element->next = head;
    }
    head = element;
}

void delete_(int val)
{
    list* p = head;
    while (p->val != val) {
        if (p == tail) {
            return;
        }
        p = p->next;
    }
    if (p == head) {
        head = p->next;
    } else {
        p->prev->next = p->next;
    }
    if (p == tail) {
        tail = p->prev;
    } else {
        p->next->prev = p->prev;
    }
    delete p;
}

void deleteFirst()
{
    list* p = head;
    head = p->next;
    if (head != NULL) {
        head->prev = NULL;
    } else {
        tail = NULL;
    }
    delete p;
}

void deleteLast()
{
    list* p = tail;
    tail = p->prev;
    if (tail != NULL) {
        tail->next = NULL;
    } else {
        head = NULL;
    }
    delete p;
}

void trace()
{
    for (list* p = head; p != NULL; p = p->next) {
        cout << p->val;
        if (p->next != NULL) {
            cout << " ";
        } else {
            cout << "\n";
        }
    }
}

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

    list* head;

    for (int i = 0; i < n; i++) {
        string command;
        cin >> command;
        if (command == "deleteFirst") {
            deleteFirst();
            continue;
        }
        if (command == "deleteLast") {
            deleteLast();
            continue;
        }
        int val;
        cin >> val;
        if (command == "insert") {
            insert_(val);
        } else {
            delete_(val);
        }
    }
    trace();
}

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

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

cnt = 0
for i in range(1, n - 1):
    s = 0
    if p[i - 1] < p[i]:
        s += 1
    if p[i + 1] < p[i]:
        s += 1
    if s == 1:
        cnt += 1

print(cnt)


Measured memory_bytes: 2940
n = int(input())
st = []
for i in range(n):
    x, l = map(int, input().split())
    st.append([x + l, x - l])

st.sort()
cnt = 1
right = st[0][0]
for i in range(1, n):
    if right <= st[i][1]:
        right = st[i][0]
        cnt += 1

print(cnt)

Measured memory_bytes: 20080
#include "bits/stdc++.h"

#ifdef PRINTERS
#include "printers.hpp"
using namespace printers;
#define tr(a)		cerr<<#a<<" : "<<a<<endl
#else
#define tr(a)    
#endif

#define ll          long long
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b)	for(int i=a;i<b;i++)
using namespace std;

void solve(){
	int N;
	cin>>N;
	int lastt=0,lastx=0,lasty=0;
	rep(i,0,N){
		int t,x,y;
		cin>>t>>x>>y;
		int reqd=abs(x-lastx)+abs(y-lasty);
		if(reqd>t-lastt or reqd%2!=(t-lastt)%2){
			cout<<"No";
			return;
		}
		lasty=y;
		lastx=x;
		lastt=t;
	}
	cout<<"Yes";
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t=1;
//	cin>>t;
	while(t--){
		solve();
	}
	return 0;
}

Measured memory_bytes: 256
from fractions import gcd  #python 3.5より前
#from math import gcd  #python 3.5以降
n = int(input())
a = sorted([int(i) for i in input().split()])
ans = gcd(a[0],a[1])
for i in range(2,len(a)):
    ans = min(ans,gcd(ans,a[i]))
print(ans)

Measured memory_bytes: 16280
import java.io.*;
import java.util.*;
import java.math.*;
import static java.lang.Math.*;

public class Main {

    private static final FastScanner fs = new FastScanner();

    public static void main(String[] args) {
//        int t = fs.nextInt();
        int t = 1;
        for (int i = 1; i <= t; i++) {
            // System.out.print("Case #" + i + ": ");
            solve();
        }
    }
    
    static int n, w;
    static int[] weights, values;
    static long[][] memo;

    private static void solve() {
        n = fs.nextInt();
        w = fs.nextInt();
        weights = new int[n];
        values = new int[n];
        for (int i = 0; i < n; i++) {
            weights[i] = fs.nextInt();
            values[i] = fs.nextInt();
        }
        memo = new long[n + 1][w + 1];
        for (int i = 0; i <= n; i++) Arrays.fill(memo[i], -1);
        for (int j = 0; j <= w; j++) memo[n][j] = 0;
        for (int i = 0; i<= n; i++) memo[i][0] = 0;
        System.out.println(dp(0, w));
    }
    
    private static long dp(int i, int j) {
        if (memo[i][j] != -1) return memo[i][j];
        long val = dp(i + 1, j);
        if (weights[i] <= j) {
            val = max(val, values[i] + dp(i + 1, j - weights[i]));
        }
        memo[i][j] = val;
        return val;
    }

    private static class FastScanner {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

        public String next() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                } 
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public int[] intArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) a[i] = nextInt();
            return a;
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public long[] longArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++) a[i] = nextLong();
            return a;
        }
    }

}


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

using namespace std;

string s;
vector<string> c{"zzzzz", "zzzzz", "zzzzz", "zzzzz", "zzzzz"};

int K;

void update(string sub) {
    if (find(c.begin(), c.end(), sub) == c.end()) {
        for (int i = 0; i < K; i++) {
            if (sub < c[i]) {
                c.insert(c.begin() + i, sub);
                c.pop_back();
                break;
            }
        }
    }
}

int main() {
    cin >> s >> K;
    for (int i = 0; i < s.length(); i++) {
        for (int j = 1; j <= K; j++) {
            update(s.substr(i, j));
        }
    }
    cout << c[K - 1] << endl;
}


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

#define __STDC_FORMAT_MACROS
#define p64 PRId64

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR (i, 0, n)
#define ALL(f, x, ...)                                                         \
    ([&] (decltype ((x)) ALL) {                                                \
        return (f) (begin (ALL), end (ALL), ##__VA_ARGS__);                    \
    }) (x)

using namespace std;
using ll = int64_t;

int main() {
    int N;
    cin >> N;
    vector<int> A (N, 0), B (N, 0), C (N - 1, 0);
    REP (i, N) cin >> A[i];
    REP (i, N) cin >> B[i];
    REP (i, N - 1) cin >> C[i];
    int ans = ALL (accumulate, B, 0);
    FOR (i, 1, N) if (A[i - 1] + 1 == A[i]) ans += C[A[i - 1] - 1];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
int main(){
int N,K;
  cin>>N>>K;
  vector<int>h(N);
  for(int i=0;i<N;i++)
    cin>>h.at(i);
  
  if(N-1<=K)
    cout<<abs(h[0]-h[N-1])<<endl;
  else{
  vector<int>dp(N);
    for(int i=N-1;N-(K+1)<=i;i--)
      dp[i]=abs(h[N-1]-h[i]);
    for(int i=N-K-2;0<=i;i--){
    int Min=10000000000;
      for(int j=1;j<=K;j++){
      if(abs(h[i+j]-h[i])+dp[i+j]<Min)
        Min=abs(h[i+j]-h[i])+dp[i+j];
      
      }dp[i]=Min;
    
    
    }cout<<dp[0]<<endl;
  
  }  return 0;

}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e16
typedef pair<int,int> P;
typedef long long ll;



int main(void){
    int n;
    string t;
    cin>>n;
    map<char,int>f,x;
    for(int i=0;i<n;i++){
        cin>>t;
        if(i==0){
            for(int j=0;j<t.length();j++){
                f[t[j]]++;
            }
        }
        else{
            for(char m='a';m<='z';m++)x[m]=0;
            for(int j=0;j<t.length();j++){
                x[t[j]]++;
            }
            for(char m='a';m<='z';m++){
                f[m]=min(f[m],x[m]);
            }
        }
    }
    string u="";
    for(char m='a';m<='z';m++){
        if(f[m]!=0){
            for(int j=0;j<f[m];j++){
                u+=m;
            }
        }
    }
    cout<<u<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
#define overload4(_1,_2,_3,_4,name,...) name
#define rep1(n) for(ll i=0;i<(n);++i)
#define rep2(i,n) for(ll i=0;i<(n);++i)
#define rep3(i,a,b) for(ll i=(a);i<(b);++i)
#define rep4(i,a,b,c) for(ll i=(a);i<(b);i+=(c))
#define rep(...) overload4(__VA_ARGS__,rep4,rep3,rep2,rep1)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define vec vector<ll>
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
const string YES = "Yes";
const string NO = "No";

void solve(ll a, ll b, ll c){
    cout<<(a==b&&b==c?YES:NO)<<'\n';
}

int main(){
    ll a;
    scanf("%lld",&a);
    ll b;
    scanf("%lld",&b);
    ll c;
    scanf("%lld",&c);
    solve(a, b, c);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	map<string,int> mp;
	int n; cin>>n;
	while(n--){
		string s; cin>>s;
		mp[s]++;
	}
	cout<<"AC x "<<mp["AC"]<<endl;
	cout<<"WA x "<<mp["WA"]<<endl;
	cout<<"TLE x "<<mp["TLE"]<<endl;
	cout<<"RE x "<<mp["RE"]<<endl;
	return 0;
}

Measured memory_bytes: 3664
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int k, n;
	int i, j;
	int maxdist = 0;
	long ans = 0;

	cin >> k >> n;
	int *a = new int[n];
	cin >> a[0];
	for (i = 1; i < n; i++) {
		cin >> a[i];
		maxdist = max(maxdist,a[i]-a[i-1]);
	}
	maxdist = max(maxdist, k - a[n - 1] + a[0]);
	ans = k - maxdist;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
/*
Author : Devil088
*/
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define sep cout<<"\n";
#define Yes cout<<"Yes\n";
#define No cout<<"No\n";
#define YES cout<<"YES\n";
#define NO cout<<"NO\n";
int main(){
	long A[3];
	for(int i=0;i<3;i++){
		cin>>A[i];
	}
	
	sort(A,A+3);
	long ans = 0;
	for(int i=1;i<3;i++){
		ans+=abs(A[i]-A[i-1]);
	}
	cout<<ans<<"\n";
}
/*
7
1 1 1 1 2 3 4
1  2  3  4  5  6  7
0 -1 -2 -3 -3 -3 -3
-3 -3 -3 -3 -2 -1 0
-3 -2 -1 0 0 0 0
A - ( b + i )
A - i = b ;
*/


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <typeinfo>
#include <math.h>

using namespace std;
using ll = long long;
const ll res = 1000000007;

int main() {
	ll n, m, ans = 0;
	cin >> n >> m;
	vector<ll> s(m,0), c(m,0), a(n,0);

	if (n != 1)
		a[0] = 1;

	for (int i = 0; i < m; i++) {
		cin >> s[i] >> c[i];
		a[s[i] - 1] = c[i];
	}

	for (int i = 0; i < m; i++) {
		if (a[s[i]-1] != c[i])
			ans = -1;
		if (s[i] == 1 and c[i] == 0 and n != 1)
			ans = -1;
	}
	
	if (ans != -1) {
		for (int i = 0; i < n; i++) {
			cout << a[i];
		}
	}
	else
		cout << ans << endl;
}

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

using namespace std;

static int ROUND = 1000;

int weeks;
int loan = 100000;
int rishi = loan * 0.05;
int temp;

int main(){
  scanf("%d", &weeks);
  while (weeks != 0){
      loan = loan*1.05;
      loan = loan % ROUND != 0 ? (int(loan/ROUND) +1)*ROUND : loan;
      weeks--;
  }
 cout << loan << endl;
 return 0;   
}

Measured memory_bytes: 3080
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        BigDecimal a = new BigDecimal(sc.next()), b = new BigDecimal(sc.next());
        System.out.println(a.multiply(b).setScale(0, BigDecimal.ROUND_DOWN).toPlainString());
    }
}


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

#define Max(a,b) max({a,b})
#define Min(a,b) min({a,b})
#define rep(i,m,n) for(int (i)=(m);(i)<(int)(n);(i)++)
#define len(n) n.size()
#define print(n) cout << (n) << endl;


// s.substr(i,n)

typedef long long ll;

using namespace std;

//char a = 65;
long long int inf = 1000000007;
int n,m,a,b,c,d,cou,co,p;
long long int lla,llb,llc;
double k;
const ll LINF = 1e18;
char num = 65;
string s,t;
int li[20];
/*
int binary(int bina){
    int ans = 0;
    for (int i = 0; bina>0 ; i++)
    {
        ans = ans+(bina%2)*pow(10,i);
        bina = bina/2;
    }
    return ans;
}
*/

int sosuu(int x){
    rep(i,2,ceil(pow(double(x),0.5))+1) {
        if(x % i == 0) return false;
    }
    return true;
}
int w[400000];
int e[400000];
int ans[60];

int main(){
    
    cin >> n;
    cou = 1;

    rep(j,0,n){
        int key = 0;
        while(key == 0){
            cou += 1;
            if(sosuu(5*cou+1)){
                ans[j] = 5 * cou+1;
                key = 1;
            }
        }
    }

    rep(i,0,n) cout << ans[i] << " ";
    print("\n")

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (true) {
            int H = scanner.nextInt();
            int W = scanner.nextInt();
            if (H == 0 && W == 0) break;
            for (int h = 0; h < H; h++) {
                if (h == 0 || h == H-1) {
                    for (int w = 0; w < W; w++) {
                        System.out.print('#');
                    }
                } else {
                    for (int w = 0; w < W; w++) {
                        char c = '.';
                        if (w == 0 || w == W-1) c = '#';
                        System.out.print(c);
                    }
                }
                System.out.println("");
            }
            System.out.println("");
        }
    }
}



Measured memory_bytes: 37020
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

func main() {
	var wtr = bufio.NewWriter(os.Stdout)
	var N int
	fmt.Scan(&N)
	v := make([]float64, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&v[i])
	}
	sort.Float64s(v)
	for i := 0; i < N-1; i++ {
		v[i+1] = (v[i] + v[i+1]) / 2.0
	}
	fmt.Fprintln(wtr, v[N-1])

	_ = wtr.Flush()
}


Measured memory_bytes: 640
import java.util.*;

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

        int A = 0;
        int base = 1;
        for(int i=0; i<b; i++){
            A = A + base * a;
            base = base * 10;
        }
        int B = 0;
        base = 1;
        for(int i=0; i<a; i++){
            B = B + base * b;
            base = base * 10;
        }
        String AS = String.valueOf(A);
        String BS = String.valueOf(B);
        if(AS.compareTo(BS) <0){
            System.out.println(AS);
        }else{
            System.out.println(BS);
        }
    }
}

Measured memory_bytes: 21844