akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}
 
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=std::sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}
 
long long gcd_(long long a, long long b){
  if(a<b){
    std::swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
//using namespace std;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;

int main(){
  using namespace std;
  int n;
  cin>>n;
  int r = n % 10;
  if(r == 3){
    cout << "bon" << endl;
  }else if(r == 0 || r == 1 || r == 6 || r == 8){
    cout << "pon" << endl;
  }else{
    cout << "hon" << endl;
  }
  return 0;
}


Measured memory_bytes: 3676
char = {}
char["I"] = 1
char["V"] = 5
char["X"] = 10
char["L"] = 50
char["C"] = 100
char["D"] = 500
char["M"] = 1000
while input = gets
  chars = input.chomp.split("")
  n = chars.size
  n.times{|i|
    chars[i] = char[chars[i]]
  }
  (n-1).downto(1){|i|
    if chars[i] > chars[i-1]
      chars[i] -= chars[i-1]
      chars[i-1] = 0
    end
  }
  p chars.inject(:+)
end

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

using namespace std;
typedef long long int ll;
typedef pair <ll,ll> P;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n-1; i >= 0; i--)
#define FOR(i, n, m) for(int i = n; i < (int)(m); i++)
#define PRINT(x) cout << x << endl
#define ALL(v) v.begin(), v.end()

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

ll MOD = 1000000007;

int main()
{
    ll N;
    cin >> N;
    vector<ll> A(N);
    REP(i, N) cin >> A[i];
    vector<ll> dp(N);
    dp[1] = abs(A[1] - A[0]);
    FOR(i, 2, N) {
        dp[i] = min(dp[i-1] + abs(A[i] - A[i-1]), dp[i-2] + abs(A[i] - A[i-2]));
    }
    PRINT(dp.back());
    return 0;
}


Measured memory_bytes: 1792
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readNInts = readInt >>= flip replicateM readInt

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = do
	[ a, b ] <- map ( \x -> if x == 1 then 14 else x ) <$> readInts
	putStrLn $ case compare a b of
		GT -> "Alice"
		LT -> "Bob"
		_ -> "Draw"

Measured memory_bytes: 380
#include <iostream>
#include <cstdio>

using namespace std;

int main(){
	int n, k, temp, count;
	while (1){
		scanf("%d", &n);
		if (n == 0) break;
		count = 0; temp = 0;
		for (int i = 0; i < n; i++){
			scanf("%d", &k);
			if (k > temp) temp = k;
			if (k == 0) count++;
		}
		if (n == 1 && temp >= 2) printf("2\n");
		if (temp < 2) printf("NA\n");
		if (n != 1 && temp >= 2) printf("%d\n", n - count + 1);
	}
	
	return 0;
}

Measured memory_bytes: 1196
import sys
sys.setrecursionlimit(100000000)
def gcd(a,b): 
    if (b == 0): 
         return a 
    return gcd(b, a%b) 


mod = 10**9 + 7

n = int(input())
arr = [int(j) for j in input().split()]

prod = 1
l = 1
for x in arr:
	g = gcd(l, x)
	prod = l*x
	l = prod//g

su = 0
for x in arr:
	su += (l//x)
print(su%mod)


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

int main(){
  int n,s[100];

  while(cin >> n,n){
  for(int i=0;i<n;i++)cin >> s[i];
  sort(s,s+n);
  cout << accumulate(s+1,s+n-1,0)/(n-2) << endl;
 }
}

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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    cout << a + b + c - max({a, b, c}) << endl;
}


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

int main() {
   string a, b, c;
   cin >> a >> b >> c;
  if(a[a.size()-1] != b[0] || b[b.size()-1] != c[0])  cout << "NO" << endl;
  else  cout << "YES" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <iomanip>
#include <queue>
#include <cctype>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

//vector<vector<int>> data(3, vector<int>(4));

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

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

    cout << a*b;




    return 0;
}

Measured memory_bytes: 3636
from sys  import stdin,stdout

import bisect

import math

def st():
    return list(stdin.readline().strip())

def inp():
    return int(stdin.readline())

def li():
    return list(map(int,stdin.readline().split()))

def mp():
    return map(int,stdin.readline().split())

def pr(n):
    stdout.write(str(n)+"\n")

def soe(limit):
    l=[1]*(limit+1)
    prime=[]
    for i in range(2,limit+1):
        if l[i]:
            for j in range(i*i,limit+1,i):
                l[j]=0

    for i in range(2,limit+1):
        if l[i]:
            prime.append(i)
    return prime

def segsoe(low,high):
    limit=int(high**0.5)+1
    prime=soe(limit)
    n=high-low+1
    l=[0]*(n+1)
    for i in range(len(prime)):
        lowlimit=(low//prime[i])*prime[i]
        if lowlimit<low:
            lowlimit+=prime[i]
        if lowlimit==prime[i]:
            lowlimit+=prime[i]
        for j in range(lowlimit,high+1,prime[i]):
            l[j-low]=1
    for i in range(low,high+1):
        if not l[i-low]:
            if i!=1:
                print(i)
                
def gcd(a,b):
    while b:
        a,b=b,a%b
    return a

def power(a,n):
    r=1
    while n:
        if n&1:
            r=(r*a)
        a*=a
        n=n>>1
    return r

    
def solve():
    n=inp()
    a,b=1,1
    for _ in range(n):
        x,y=mp()
        d=max((x+a-1)//x,(y+b-1)//y)
        a=d*x
        b=d*y
    pr(a+b)
for _ in range(1):
    solve()
    


Measured memory_bytes: 9268
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define fix(n) cout<<fixed<<setprecision(n)
#define co(n) cout<<n<<endl
#define all(n) (n).begin(),(n).end()
using namespace std;
typedef long long ll;
const ll mod=1000000007;
double pi=3.1415926535;

int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  a=c-a; b=d-b;
  rep(i,0,b) cout<<'U';
  rep(i,0,a) cout<<'R';
  rep(i,0,b) cout<<'D';
  rep(i,0,a+1) cout<<'L';
  rep(i,0,b+1) cout<<'U';
  rep(i,0,a+1) cout<<'R';
  cout<<'D'<<'R';
  rep(i,0,b+1) cout<<'D';
  rep(i,0,a+1) cout<<'L';
  cout<<'U'<<endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define ll          long long
#define ld          long double
#define pb          push_back
#define pf          push_front
#define mp          make_pair
#define pll         pair<ll,ll>
#define vl          vector<ll>
#define sl          set<ll> 
#define vll         vector<pll>
#define ml          map<ll,ll>
#define mll         map<pll,ll>
#define all(a)      a.begin(),a.end()
#define x           first
#define y           second
#define sz(x)       (ll)x.size()
#define dl          '\n'
#define mod         (ll)1000000007
#define lp(i,a,b)   for(ll i=a;i<b;++i)
#define lpr(i,a,b)  for(ll i=a;i>=b;i--)
#define lpd(i,x)    for(auto i:x)
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
ll inf = (ll)1e18;
ld pi = 3.141592653589;
using namespace std;

ll bpow(ll x, ll v) {   
    if (v == 0)
        return 1 % mod;
    if (v % 2 == 1)
        return (x * bpow(x, v - 1)) % mod;
    ll r = bpow(x, v / 2);
    return (r * r) % mod;   
}

ll solve(){ 
    string a; cin>>a;
    if(sz(a)%2) {cout<<"No"; return 0;}
    lp(i,0,sz(a)-1){
        if(a[i]!='h' or a[i+1]!='i'){
            cout<<"No";
            return 0;
        }
        i++;
    }
    cout<<"Yes";
}
int main(){
    ios
    ll t=1; 
    //cin>>t;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, A, B;
    cin >> N >> A >> B;
    string S; cin >> S;
    rep(i, N) {
        if (S[i] == 'a') {
            if (A + B > 0) {
                cout << "Yes" << endl;
                A--;
            } else {
                cout << "No" << endl;
            }
        } else if(S[i] == 'b') {
            if(A + B > 0 && B > 0) {
                cout << "Yes" << endl;
                B--;
            } else {
                cout << "No" << endl;
            }
        } else {
            cout << "No" << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 848
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;

int main(){
	int r,x,g;
	while(~scanf("%d %d",&r,&g)){
    x=2*g-r;
    printf("%d\n",x);
	}
}

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

class Main {
    private static final Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int n = Integer.parseInt(sc.nextLine());
        int x = 111;
        while (x < n) {
            x += 111;
        }
        System.out.println(x);
        sc.close();
    }
}


Measured memory_bytes: 21712
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
using namespace std;

typedef pair<int,int> P;

#define rep(i,s,e) for(int i = (s);i <= (e);i++)

int n;
int p[20010];

int a[20010];
int b[20010];

int MAX = 20000;

int main()
{
	cin >> n;
	rep(i,1,n) cin >> p[i];

	rep(i,1,n)
	{
		a[i] = (MAX + 1) * i;
		b[i] = (MAX + 1) * (n - i + 1);
	}

	rep(i,1,n)
	{
		a[p[i]] += i;
		b[p[i]] += i;
	}

	rep(i,1,n) cout << a[i] << " ";
	cout << endl;
	rep(i,1,n) cout << b[i] << " ";
	return 0;
}

	


Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
int times(int n){
  if(n==0){
    return 1;
  }
  else if(n==1){
    return 100;
  }
  else{
    return 10000;
  }
}
int main(){
  int D,N;
  cin>>D>>N;
  int K=times(D);
  int count=0;
  int i=0;
  while(count<N){
    i=i+1;
    if(i%K==0&&i%(K*100)!=0){
      count=count+1;
    }
    if(count==N){
      cout<<i<<endl;
    }
  }
}

Measured memory_bytes: 256
n, m = map(int, input().split())
h = list(map(int, input().split()))
lst = [True for i in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    if h[a-1] > h[b-1]:
        lst[b-1] = False
    elif h[a-1] < h[b-1]:
        lst[a-1] = False
    else:
        lst[a-1] = False
        lst[b-1] = False
print(lst.count(True))

Measured memory_bytes: 19972
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws Exception {
        try (BufferedReader reader = new BufferedReader(new InputStreamReader(System.in))) {
            int N = readInt(reader);
            int[] B = readIntArray(reader);

            int sum = 0;
            sum += B[0] + B[N - 2];
            for (int i = 1; i < N - 1; i++) {
                sum += Math.min(B[i - 1], B[i]);
            }

            System.out.println(sum);
        }
    }

    public static int readInt(BufferedReader reader) throws Exception {
        return Integer.parseInt(reader.readLine());
    }

    public static int[] readIntArray(BufferedReader reader) throws Exception {
        String[] str = reader.readLine().split(" ");
        int[] array = new int[str.length];
        for (int i = 0; i < str.length; i++) {
            array[i] = Integer.parseInt(str[i]);
        }
        return array;
    }

}


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

int n;
vector<int> A;

int bisearch(int a){
	int left=0,right=n;
	int mid;
	while(left<right){
		mid=(left+right)/2;
		if(A[mid]==a) return 1;
		else if(A[mid]>a) right=mid;
		else if(A[mid]<a) left=mid+1;
	}
	return 0;
}

int main(){
	int q ,a ,k=0;
	cin>>n;
	for(int i = 0;i<n;i++){
		cin>>a;
		A.push_back(a);
	}
	cin>>q;
	for(int i = 0;i<q;i++){
		cin>>a;
		k+=bisearch(a);
	}
	cout<<k<<endl;
	return 0;
}


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

using namespace std;

vector<int> ans, arr;

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

    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int num;
        cin >> num;
        arr.push_back(num);
    }
    for (int i = 0; i < n; i++) {
        bool ok = false;
        for (int j = n - i - 1; j >= 0; j--) {
            if (arr[j] == j + 1) {
                ans.push_back(*(arr.begin() + j));
                arr.erase(arr.begin() + j);
                ok = true;
                break;
            }
        }
        if (!ok) {
            cout << -1 << '\n';
            return 0;
        }
    }
    reverse(ans.begin(), ans.end());
    for (auto a : ans) {
        cout << a << '\n';
    }

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <complex>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <iterator>

using namespace std;

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define iter(c) __typeof__((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

const int INFTY=1<<29;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

int getcolor(vs& grid,vvi& vis,int i,int j)
{
	int h=grid.size(),w=grid[0].size();
	if(i<0 || h<=i || j<0 || w<=j || vis[i][j])
		return 0;
	if(isupper(grid[i][j]))
		return 1<<(grid[i][j]=='W');
	vis[i][j]=1;
	int res=0;
	rep(k,4){
		int ni=i+"\xff\x1\0\0"[k],nj=j+"\0\0\xff\x1"[k];
		res|=getcolor(grid,vis,ni,nj);
	}
	return res;
}
void setcolor(vs& grid,int i,int j,char c)
{
	int h=grid.size(),w=grid[0].size();
	if(i<0 || h<=i || j<0 || w<=j || grid[i][j]!='.')
		return;
	grid[i][j]=tolower(c);
	rep(k,4){
		int ni=i+"\xff\x1\0\0"[k],nj=j+"\0\0\xff\x1"[k];
		setcolor(grid,ni,nj,c);
	}
}

int main()
{
	for(int w,h;cin>>w>>h,w|h;){
		vs grid(h);
		rep(i,h) cin>>grid[i];
		
		vvi vis(h,vi(w));
		rep(i,h) rep(j,w) if(!vis[i][j]){
			int res=getcolor(grid,vis,i,j);
			setcolor(grid,i,j,"*BWX"[res]);
		}
		
		int bcnt=0,wcnt=0;
		rep(i,h) rep(j,w){
			if(grid[i][j]=='b') bcnt++;
			if(grid[i][j]=='w') wcnt++;
		}
		cout<<bcnt<<' '<<wcnt<<endl;
	}
	
	return 0;
}

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

int main(){
    int a, b, c, d;
    bool ans = true;
    scanf("%d %d %d %d", &a, &b, &c, &d);
    if((abs(a - c) > d)){
        if((abs(a - b) > d) || (abs(b - c) > d))
            ans = false;
    }
    printf("%s\n", (ans == true)? "Yes" : "No");
    return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) = println(run {
    val (a,b,c,x) = (1..4).map { readLine()!!.toInt() }

    var count = 0
    for (i in 0..a) {
        for (j in 0..b) {
            for (k in 0..c) {
                if (500*i+100*j+50*k == x) count++
            }
        }
    }
    count
})


Measured memory_bytes: 33820
#pragma region Macros

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
#define int ll
using vi = vector<int>;
using vvi = vector<vi>;

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

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;
}

// debug methods
// usage: debug(x,y);
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cout << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << endl
#define debug_4(x1, x2, x3, x4) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#ifdef _DEBUG
#define debug(...)                                                        \
    CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) \
    (__VA_ARGS__)
#else
#define debug(...)
#endif

#pragma endregion

void Main() {
    int A, V, B, W, T;
    cin >> A >> V >> B >> W >> T;


    int sa = abs(B - A);

    int iii = V - W;

    if (T * iii >= sa) {
        cout << "YES";
        return;
    }

    cout << "NO";
}

#pragma region main
main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    Main();
    cout << flush;
}
#pragma endregion


Measured memory_bytes: 3656
def getBeforeTax(afterTaxAmount, taxRateBefore, a0)
    a1 = (a0 * (100 + taxRateBefore) / 100).floor
    b1 = afterTaxAmount - a1
    (1..b1).each do |b0|
        b1Tem = (b0 * (100 + taxRateBefore) / 100).floor
        if b1Tem == b1
            return b0
        end
    end
    return nil
end

input_data = gets.chomp.split(" ")
taxRateBefore = input_data[0].to_i
taxRateAfter = input_data[1].to_i
afterTax = input_data[2].to_i

while taxRateBefore != 0 do 
    price = []
    (1..(afterTax/2)).each do |a0|
        b0 = getBeforeTax(afterTax, taxRateBefore, a0)
        if b0 == nil
            next
        end
        a2 = (a0 * (100 + taxRateAfter) / 100).floor
        b2 = (b0 * (100 + taxRateAfter) / 100).floor
        price.push(a2 + b2)
    end
    
    puts price.max

    input_data = gets.chomp.split(" ")
    taxRateBefore = input_data[0].to_i
    taxRateAfter = input_data[1].to_i
    afterTax = input_data[2].to_i
end


Measured memory_bytes: 6884
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    int num[3];
    cin >> num[0] >> num[1] >> num[2];
    
    sort(num,num+3);
    cout << num[0] << " " << num[1] << " " << num[2] << endl;

    return 0;
}



Measured memory_bytes: 3164
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

typedef struct{
  double x;
  double y;
} pos;


void kock( int n, pos p1, pos p2) {

  pos s, t, u;


  if(n == 0) {
    return;
  }

  s.x = ( 2 * p1.x + p2.x )/3;
  s.y = ( 2 * p1.y + p2.y )/3;

  t.x = ( p1.x + 2 * p2.x )/3;
  t.y = ( p1.y + 2 * p2.y )/3;

  u.x = (t.x - s.x)*cos(M_PI/3) - (t.y - s.y)*sin(M_PI/3) + s.x;
  u.y = (t.x - s.x)*sin(M_PI/3) + (t.y - s.y)*cos(M_PI/3) + s.y;


  kock( n-1, p1, s);
  printf("%f %f\n", s.x, s.y);
  kock( n-1, s, u);
  printf("%f %f\n", u.x, u.y);
  kock( n-1, u, t);
  printf("%f %f\n", t.x, t.y);
  kock( n-1, t, p2);

}

int main() {

  int n;
  pos start={ 0, 0};
  pos end={ 100, 0};

  scanf("%d", &n);

  printf("%f %f\n", start.x, start.y);

  kock( n, start, end);

  printf("%f %f\n", end.x, end.y);

  return 0;

}

Measured memory_bytes: 636
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long a,b,c=-1;
  cin>>a>>b;
  for(int i=2;i<=1000000;i++){
	if(a*i%b!=0&&c==-1) c=a*i;
  }
  cout<<c<<"\n";
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {

  long n,k;
  scanf("%ld %ld", &n, &k);
  long a[n];
  for (long i = 0; i < n; i++) {
    scanf("%ld", &a[i]);
  }
  long ng = 0,ok = 1000000000,center,cut;
  while (ng+1 < ok) {
    center = (ng+ok)/2;
    cut = 0;
    for (long i = 0; i < n; i++) {
      cut += (a[i]+center-1)/center-1;
    }
    if (cut <= k) {
      ok = center;
    } else {
      ng = center;
    }
  }
  printf("%ld\n", ok);

  return 0;
}

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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 5e5 + 55;

char d[MAXN];

void solve(){
	scanf("%s", &d[0]);
	int n = strlen(d);
	REP(i, 0, n){
		d[i] -= '0';
	}
	reverse(d, d + n);
	
	n += 10;
	
	int add = 0, sum = 0;
	REP(i, 0, n){
		int v = add + 9 * d[i];
		d[i] = v % 10;
		add = v / 10;
		
		sum += d[i];
	}
	
	for(int ans = 1; ; ans++){
		REP(k, 0, 9) {
			int i;
			for(i = 0; d[i] == 9; i++){
				d[i] = 0;
				sum -= 9;
			}
			d[i]++;
			sum++;
		}
		if (sum <= 9 * ans){
			printf("%d\n", ans);
			return;
		}
	}
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 768
import sys
input = sys.stdin.readline

S= list(input().rstrip('\n'))
T= list(input().rstrip('\n'))
result = []
for i in range(len(S)-len(T)+1):
  s = S[i:len(T)+i]
  c = [1 for x in range(len(T)) if s[x]!=T[x]]
  result.append(sum(c))
print(min(result))

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

int main(){
    vv c(3, vi (3));
    rep(i,3)rep(j,3)cin>>c[i][j];
    
    rep(j,3)rep(i,2){
        c[i][j] -= c[i+1][j];
    }
    
    rep(i,2){
        if(c[i][0]!=c[i][1]){
            cout << "No" << endl;
            return 0;
        }
        if(c[i][2]!=c[i][1]){
            cout << "No" << endl;
            return 0;
        }
    }
    
    cout << "Yes" << endl;
    
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] arr = new int[n];
		for (int i = 0; i < n; i++) {
		    arr[i] = sc.nextInt();
		}
		UnionFindTree uft = new UnionFindTree(n);
		for (int i = 0; i < m; i++) {
		    uft.unite(sc.nextInt() - 1, sc.nextInt() - 1);
		}
		int count = 0;
		for (int i = 0; i < n; i++) {
		    if (uft.same(arr[i] - 1, i)) {
		        count++;
		    }
		}
		System.out.println(count);
    }
    
    static class UnionFindTree {
        int[] parents;
        
        public UnionFindTree(int size) {
            parents = new int[size];
            for (int i = 0; i < size; i++) {
                parents[i] = i;
            }
        }
        
        public int find(int x) {
            if (parents[x] == x) {
                return x;
            } else {
                return parents[x] = find(parents[x]);
            }
        }
        
        public boolean same(int x, int y) {
            return find(x) == find(y);
        }
        
        public void unite(int x, int y) {
            if (same(x, y)) {
                return;
            }
            parents[find(x)] = find(y);
        }
    }
}



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

int main(){
  string s,t;
  int n;
  cin>>n>>s;
  if(s.size()%2!=0) {
    cout<<"No";
    return 0;
  }  
  t=s.substr(0,n/2);
  t=t+t;
  if(s==t) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
// #include <boost/lexical_cast.hpp>
using namespace std;


#define ll long long int
#define vll vector<ll>
#define vllv vector<vector<ll>> 
#define sz size()
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

ll ceil1(ll n,ll m){if(n%m==0){return n/m;}return n/m +1;}
vll factor(ll n){
    vll ans;
    if(n>0)ans.pb(1);if(n==2)ans.pb(2);
    for(ll i=2;i*i<=n;i++){if(n%i==0){ans.pb(i);if(n/i!=i)ans.pb(n/i);}}if(n>2)ans.pb(n);
    return ans;
}
ll fact(ll n){
	
    ll res = 1; 
    for (ll i = 2; i <= n; i++) 
        res = res * i; 
    return res; 
} 
  
int nCr(ll n, ll r) 
{ 
    return fact(n) / (fact(r) * fact(n - r)); 
} 
  
void dfs(vllv &v,ll k,vll &par,vll &dis,ll p)
{
 
    par[k]=p;
    dis[k]=dis[p]+1;
    for(ll i=0;i<v[k].sz;i++){
        if(v[k][i]!=p){
            dfs(v,v[k][i],par,dis,k);
        }
    }
}
bool sortbysec(const pair<string,int> &a,const pair<string,int> &b){return (a.second<b.second);} 


ll ston(string s) 
{ 
    stringstream geek(s); 
    ll x = 0; 
    geek >> x; 
    
  
    return x; 
}
ll pow2(ll n,ll k){ll ans=1;
    while(k>0){
        if(k%2==1)ans=ans*n;n=n*n;k/=2;
    }return ans;}
bool prime(int n){
    int i,j;
    for(i=2;i<=sqrt(n);i++){
        if(n%i==0){
            return false;
        }
    }
    return true;
}
bool bserch(vector<string> a, string s){
	
	ll l=0,r=a.sz-1,mid;
	while(l<=r){
		mid=(l+r)/2;
		if(a[mid]==s)return true;
		if(a[mid]<s){
			l=mid+1;
		}else{
			r=mid-1;
		}
	}
	return false;
}

bool sortcol( const vector<int>& v1, 
               const vector<int>& v2 ) { 
 return v1[0] < v2[0]; 
} 

 ll degit(ll n)
 {
 	ll t=0;
 	while(n>0)
 	{
 		t++;
 		n/=10; 	}
 		return t;
 }

ll gcd(ll a, ll b) 
{ 
    // Everything divides 0  
    if (a == 0) 
       return b; 
    if (b == 0) 
       return a; 
   
    // base case 
    if (a == b) 
        return a; 
   
    // a is greater 
    if (a > b) 
        return gcd(a-b, b); 
    return gcd(a, b-a); 
} 

void solve()
{
	ll a,b,c;
	cin>>a>>b>>c;
	if(c%gcd(a,b)!=0)
		cout<<"NO";
	else
		cout<<"YES";
	
	return;	
}

int main()
{
	fast;
    ll q;
    q=1;
    // cin>>q;
    while(q--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=200005;
int n,m,d[N],x,y,Stack[N],flag[N],fi[N],ne[N],tot,zz[N];
void jb(int x,int y){
	ne[++tot]=fi[x];
	fi[x]=tot;
	zz[tot]=y;
}
void dfs(int x){
	flag[x]=1;
	for (int i=fi[x];i;i=ne[i])
		if (!flag[zz[i]])dfs(zz[i]);
}
int main(){
	scanf("%d%d",&n,&m);
	for (int i=1;i<=m;i++){
		scanf("%d%d",&x,&y);
		d[x]++,d[y]++;
		jb(x,y);jb(y,x);
	}
	int cnt1=0,cnt2=0;
	for (int i=1;i<=n;i++)
		if (d[i]&1){
			puts("No");
			return 0;
		}	
		else if (d[i]>=6)cnt1++,cnt2++;
		else if (d[i]==4)cnt2++;
	if (cnt1||cnt2>=3){
		puts("Yes");
		return 0;
	}
	tot=0;int lastx=0,lasty=0;	
	for (int i=1;i<=n;i++)
		if (d[i]==4){
			if (!lastx)lastx=i;
			else lasty=i;
		}
	if (!lasty){
		puts("No");
		return 0;
	}	
	flag[lastx]=1;
	dfs(lasty);
	for (int i=1;i<=n;i++)
		if (!flag[i]){
			puts("Yes");
			return 0;
		}
	puts("No");	
}

Measured memory_bytes: 4864
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<chrono>
#include<random>
#include<cstdio>
#include<set>
#include<map>
#include<numeric>
#include<cfenv>
#include<cmath>
#define MAX_N pow(10,6)
#define MAX_M pow(10,6)
#define INF pow(10,6)
#define REP(i,n) for(long long i=0;i<n;i++)
typedef long long ll;
using namespace std;

int main(){
    ll N;
    cin>>N;
    vector<ll>a(N);
    REP(i,N){
        cin>>a[i];
    }
    ll ans=0,temp=1;
    bool judge=false;
    REP(i,N){
        if(temp==a[i]){
            temp++;
            judge=true;
            continue;
        }
        ans++;
    }
    if(judge){
        cout<<ans;
    }else{
        cout<<-1;
    }
}

Measured memory_bytes: 1792
from collections import defaultdict


def main():
    N, W = list(map(int, input().split(' ')))
    items, cumsums = defaultdict(list), defaultdict(list)
    w_0 = 0
    for i in range(N):
        w, v = list(map(int, input().split(' ')))
        if i == 0:
            w_0 = w
        items[w].append(v)
    for w in items.keys():
        items[w].sort(reverse=True)
        cumsum_w, cumsum_v = 0, 0
        for v in items[w]:
            cumsum_w += w
            cumsum_v += v
            # w - w_0 is in [0, 1, 2, 3]
            cumsums[w - w_0].append((cumsum_w, cumsum_v))

    def dfs(cur, rest_w):
        if cur == 0:
            max_v = 0
            for cumsum_w, cumsum_v in cumsums[cur]:
                if cumsum_w <= rest_w:
                    max_v = cumsum_v
            return max_v
        else:
            ret = dfs(cur - 1, rest_w)
            for cumsum_w, cumsum_v in cumsums[cur]:
                if rest_w >= cumsum_w:
                    ret = max([ret, cumsum_v + dfs(cur - 1, rest_w - cumsum_w)])
            return ret

    print(dfs(3, W))


if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <iterator>
#include <queue>
#include <stack>
#include <deque>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <string>
#include <cmath>
#include <complex>
#include <functional>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <cstdlib>
#include <cctype>

#define REP(i,m,n) for(int i=m;i<(int)n;i++)
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rrep(i,n) for(int i = 1; i <= n; i++)
#define drep(i,n) for(int i = n; i >= 0; i--)
#define rp(i,c) rep(i,(int)c.size())
#define fr(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define mp make_pair
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define rall(u) (u).rbegin(),(u).rend()
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl
#define v_delete(a,b) (a).erase(remove((a).begin(), (a).end(), b), (a).end())
#define v_unique(a) (a).erase(unique((a).begin(), (a).end()), (a).end())
#define VV(T) vector<vector< T > >
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
const int inf=1<<28;
const double INF=1e10,EPS=1e-9;


template<class T>int SIZE(T a){return a.size();}
template<class T>string IntToString(T num){string res;stringstream ss;ss<<num;return ss.str();}
template<class T>T StringToInt(string str){T res=0;for(int i=0;i<SIZE(str);i++)res=(res*10+str[i]-'0');return res;}
template<class T>T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template<class T>T lcm(T a,T b){return a/gcd(a,b)*b;}

template <class T> void input(T& a, int n) { for (int i = 0; i < n; ++i) cin >> a[i]; }
template <class T> void input(T* a, int n) { for (int i = 0; i < n; ++i) cin >> a[i]; }

int chmax(int& a,int b){
	if(b > a){
		a=b;
	}
	return a;
}
int chmin(int& a,int b){
	if(b < a){
		a=b;
	}
	return a;
}
struct uf{
private:
	vector<int> par;
	vector<int> rank;

public:
	uf(int n){
		for (int i=0;i<n;i++){
			par.pb(i);
		}
		rank.resize(n,0);
	}

	int find(int x){
		if (par[x] == x){
			return x;
		}else{
			return par[x] = find(par[x]);
		}
	}

	void unite(int x,int y){
		x = find(x);
		y = find(y);
		if ( x== y ) return;

		if (rank[x] < rank[y] ) {
			par[x]=y;
		}else{
			par[y]=x;
			if(rank[x]==rank[y]) rank[x]++;
		}
	}

	bool same(int x,int y){
		return find(x) == find(y);
	}
};

struct edge{
	int u,v,cost;
	edge(int ui,int vi,int costi):u(ui),v(vi),cost(costi){}
};
bool comp(const edge& l,const edge& r){
	return l.cost < r.cost;
}
int N,M;
vector<edge> es;
int main () {
	while(cin >> N,N){
		cin >> M;
		es.clear();
		rep(i,M){
			int a,b,c;
			char t;
			cin >> a >> t >> b >>t >> c;
			es.pb(edge(a,b,c/100-1));
			es.pb(edge(b,a,c/100-1));
		}
		sort(all(es),comp);
		uf U(101);
		int ans=0;
		rep(i,es.size()){
			edge &e = es [i];
			if(!U.same(e.u,e.v)){
				U.unite(e.u,e.v);
				ans += e.cost;
			}
		}
		cout << ans << endl;

	}
	return 0;
}

Measured memory_bytes: 1444
#pragma GCC optimize("O3")
 #pragma GCC optimize("unroll-loops")
 #pragma GCC optimize("fast-math")
#include<bits/stdc++.h>

using namespace std;

using ll = long long;
using ld = long double;
using ull = unsigned long long;

// #define int long long
#define F first
#define S second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

void accell() {
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
}
const int N = 2001;
bitset<N * N>dp;

signed main() {
    accell();
    int n;
    cin >> n;
    vector<int>a(n);
    int s = 0;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        s += a[i];
    }
    s = (s + 1) / 2;
    dp[0] = 1;
    for (int i = 0; i < n; ++i) {
        dp |= (dp << a[i]);
    }
    int c = dp._Find_next(s - 1);
    cout << c << '\n';
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int n,a[25],b[25],c[25];

int main()
{
	cin>>n;
	int sum=0;
	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-1;i++){
		cin>>c[i];
	}
	for(int i=0;i<n;i++){
		if(a[i+1]!=a[i]+1){
			sum+=b[a[i]-1];
		//	cout<<sum<<endl;
		}
		else sum+=b[a[i]-1]+c[a[i]-1];
	}
	cout<<sum<<endl;

	
	return 0; 
}

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


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


	int H, W;
	cin >> H >> W;
	bool A[1002][1002] = {};
	vector<pair<int, int>> que;
	rep1(i, H) {
		string S;
		cin >> S;
		rep(j, W) {
			if (S[j] == '#') {
				que.pb(mp(i, j + 1));
			}
			else {
				A[i][j + 1] = true;
			}
		}
	}

	pair<int, int> P[4] = { mp(-1,0),mp(1,0),mp(0,-1),mp(0,1) };
	int kotae = 0;
	while (que.size()) {
		int nutta = 0;
		vector<pair<int, int>> que2;
		for (auto p : que) {
			rep(k, 4) {
				int y = p.first + P[k].first;
				int x = p.second + P[k].second;
				if (A[y][x]) {
					A[y][x] = false;
					que2.pb(mp(y, x));
					nutta = 1;
				}
			}
		}
		kotae += nutta;
		que = que2;
	}

	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 14308
package main

import (
	"fmt"
	"math"
)

type Status struct {
	val string
	len int
}

func main() {
	n := SingleInt()
	k := SingleInt()
	s := SingleStr()
	ss := make([]int, 0, n)

	now := "1"
	cnt := 0
	for i := 0; i < n; i++ {
		if string(s[i]) == now {
			cnt++
		} else {
			ss = append(ss, cnt)
			now = reverse(now)
			cnt = 1
		}
	}
	if cnt != 0 {
		ss = append(ss, cnt)
	}
	if len(ss)%2 == 0 {
		ss = append(ss, 0)
	}

	add := 2*k + 1
	ans := 0

	for i := 0; i < n; i += 2 {
		var tmp int

		left := i
		right := Min(i+add, len(ss))

		for j := left; j < right; j++ {
			tmp += ss[j]
		}
		ans = Max(tmp, ans)
	}
	fmt.Printf("%#v\n", ans)
}

func Max(nums ...int) int {
	if len(nums) == 0 {
		panic("function max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func Min(nums ...int) int {
	if len(nums) == 0 {
		panic("function min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func reverse(v string) string {
	if v == "0" {
		return "1"
	}
	return "0"
}

func SingleStr() string {
	var s string
	fmt.Scan(&s)
	return s
}

func SingleInt() int {
	var n int
	fmt.Scan(&n)
	return n
}


Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
int a[3];
int k;
int main()
{
	for(int i=0;i<3;i++)
	{
		scanf("%d",&a[i]);
	}
	cin>>k;
	int sum=0;
	sort(a,a+3);
	sum+=a[0]+a[1];
	while(k--)
	{
		a[2]*=2;
	}
	sum+=a[2];
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
#文書の中にある同じ単語をいくつあることを確認できるプログラム

word =  gets.
        chomp.
        downcase                    #小文字で探したい単語の入力
counter = 0                         #数字を出すためにINTをつくろ
while true
        sentence =  gets.
                    chomp           #大文書をとる
  break if
        sentence=="END_OF_TEXT"     #プログラム中止する
counter += sentence.                #大文
           downcase.                #小文字
           split.                   #単語分ける
           count(word)              #単語数をカウント
end

puts counter                        #単語数



Measured memory_bytes: 6864
a, b, c, d = gets.split.map(&:to_i)
t = 0
u = 0
if c >=a
  t = c
else
  t = a
end
if d <=b
  u = d
else
  u = b
end
if c > b
  puts 0
  exit
end
if a > d
  puts 0
  exit 
end
puts u - t

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define fi first
#define se second
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ll A,B;
    cin >> A >> B;
    vector<vector<char>> s(100,vector<char>(100,'#'));
    REP(i,50,100){
        rep(j,100){
            s[i][j] = '.';
        }
    }
    cout << 100 << " " << 100 << endl;
    A--;B--;
    ll cnt = 0;
    rep(i,50){
        rep(j,100){
            if(cnt >= A) goto gt1;
            if(j == 0)continue;
            if(i%2==0 &&j%2==0){
                s[i][j] = '.';
                cnt++;
            }else if(i%2==1 && j%2 == 1){
                s[i][j] = '.';
                cnt++;
            }
        }
        i++;
    }
    gt1:
    cnt = 0;
    REP(i,51,100){
        rep(j,100){
            if(cnt >= B) goto gt2;
            if(j == 0)continue;
            if(i%2==0 &&j%2==0){
                s[i][j] = '#';
                cnt++;
            }else if(i%2==1 && j%2 == 1){
                s[i][j] = '#';
                cnt++;
            }
        }
        i++;
    }
    gt2:
    rep(i,100){
        rep(j,100){
            cout << s[i][j];
        }
        cout << endl;
    }
}

Measured memory_bytes: 3628
import numpy as np
N = int(input())
li = []
for n in range(N):
    li.append([int(i) for i in list(input().split())])
arr = np.array(li)
ruiseki = 0
for a in arr[np.argsort(arr[:,1], axis=0)]:
    if ruiseki + a[0] > a[1]:
            yn = "No"
            break
    else:
        yn = "Yes"
        ruiseki+=a[0]
print(yn)

Measured memory_bytes: 54680
import sys
from heapq import heappush, heappop
from collections import Counter


N, K = map(int, input().split())
#sushi = [list(map(int, x.split())) for x in sys.stdin.readlines()]
sushi = [list(map(int, input().split())) for _ in range(N)]

sushi.sort(key=lambda x: x[1], reverse=True)

base = 0
ate = Counter()
q = []
for i in range(K):
    t, d = sushi[i]
    base += d
    heappush(q, (d, t))
    ate[t] += 1

var = len(list(ate.keys()))
candidate = [base + var ** 2]
for i in range(K, N):
    t, d = sushi[i]
    if ate[t] == 0:
        while len(q):
            dx, tx = heappop(q)
            if ate[tx] > 1:
                break
        else:
            break
        ate[t] += 1
        ate[tx] -= 1
        base += d - dx
        var += 1
        candidate.append(base + var ** 2)

print(max(candidate))


Measured memory_bytes: 38384
#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
int main()
{
      long long n, k;
      cin >> n >> k;
      if (n%k==0) cout << 0 << endl;
      else
      {
            if (n>k)
            {
                  n=n%k;
                  cout << min((long long)abs(k-n), (long long)abs(n)) << endl;
            }
            else
            {
                  cout << min((long long)abs(k-n), (long long)abs(n)) << endl;
            }
      }
	return 0;
}


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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long

typedef pair<int, int> P;

int main(){
    int n, m;
    cin >> n >> m;
    vector<bool> hantei(n, false);
    vector<int> wa_kaisu(n, 0);
    ll ac = 0, wa = 0;

    REP(i, m) {
        int p;
        string s;
        cin >> p >> s;
        p--;
        if(!hantei[p]) {
            if(s == "AC") {
                hantei[p] = true;
                ac++;
                wa += wa_kaisu[p];
            } else {
                wa_kaisu[p]++;
            }
        }
    }

    cout << ac << " " << wa << endl;

    return 0;
}

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

int n;

long double pi = 3.141592653;

struct Node{
  long double x;
  long double y;
};

void koch(int d, Node p1, Node p2){
  if(d == 0) return;

  Node s, t, u;

  s.x = (2 * p1.x + 1 * p2.x) / 3;
  s.y = (2 * p1.y + 1 * p2.y) / 3;
  t.x = (1 * p1.x + 2 * p2.x) / 3;
  t.y = (1 * p1.y + 2 * p2.y) / 3;
  u.x = (t.x - s.x) * cos(pi / 3) - (t.y - s.y) * sin(pi / 3) + s.x;
  u.y = (t.x - s.x) * sin(pi / 3) + (t.y - s.y) * cos(pi / 3) + s.y;

  koch(d - 1, p1, s);
  cout << std::setprecision(8) <<  s.x << ' ' << s.y << endl;
  koch(d - 1, s, u);
  cout << std::setprecision(8)<< u.x << ' ' << u.y << endl;
  koch(d - 1, u, t);
  cout << std::setprecision(8)<< t.x << ' ' << t.y << endl;
  koch(d - 1, t, p2);

}

int main(){

  cin >> n;

  Node p1, p2;

  p1.x = 0.0;

  p1.y = 0.0;

  p2.x = 100.0;

  p2.y = 0.0;

  cout << fixed;

  cout << std::setprecision(8)<< p1.x << ' ' << p1.y << endl;

  koch(n, p1, p2);

  cout << std::setprecision(8)<< p2.x << ' ' << p2.y << endl;
  return 0;
}



Measured memory_bytes: 3460
package main

import (
	"fmt"
	"io"
	"strconv"
)

var top = 0
var stack [101]int

func main() {
	var num, x int
	var jugde string
	for {
		_, err := fmt.Scan(&jugde)
		if err == io.EOF {
			break
		}
		if jugde == "*" {
			x = Pop()
			x = x * Pop()
			Append(x)
		} else if jugde == "+" {
			x = Pop()
			x = x + Pop()
			Append(x)
		} else if jugde == "-" {
			x = Pop()
			x = Pop() - x
			Append(x)
		} else {
			num, _ = strconv.Atoi(jugde)
			Append(num)
		}
	}
	fmt.Println(stack[top])
}
func Append(x int) {
	if err := isFull(); err != nil {
		fmt.Println(err)
	}
	top++
	stack[top] = x
}
func isFull() error {
	if top > 100 {
		return fmt.Errorf("overflow")
	}
	return nil
}
func Pop() int {
	if err := isEmpty(); err != nil {
		fmt.Println(err)
	}
	top--
	return stack[top+1]
}
func isEmpty() error {
	if top == 0 {
		return fmt.Errorf("underflow")
	}
	return nil
}



Measured memory_bytes: 1116
/**********************************************
 * author : deepak nayan
 * file   : e:/Solutions/atcoder/abc113_a.cpp
 * time   : Fri May  1 02:12:54 2020
 * quest  : A - Discount Fare
 *********************************************/
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int x, y;
  cin >> x >> y;
  cout << x + (y / 2) << "\n";
  return 0;
}


Measured memory_bytes: 256
object Main extends App {
  val src = io.Source.stdin.getLines.map(_.split(",").map(_.toInt).toList).toList

  val sum = (0 /: src){ (num, li) => num + li(0) * li(1) }
  val avg = math.round(((for (li <- src) yield (li(1))).sum / src.length.toDouble))

  println(s"${sum}\n${avg}")
}

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<tuple<int, int, int>> V(M);
  for (int i = 0; i < M; i++) {
    int P, Y;
    cin >> P >> Y;
    V.at(i) = make_tuple(Y, P, i);
  }
  sort(V.begin(), V.end());
  vector<tuple<int, int, int>> ans(M);
  vector<int> cnt(N + 1);
  for (int i = 0; i < M; i++) {
    cnt.at(get<1>(V.at(i)))++;
    ans.at(i) = make_tuple(get<2>(V.at(i)), get<1>(V.at(i)), cnt.at(get<1>(V.at(i))));
  }
  sort(ans.begin(), ans.end());
  for (auto a : ans) {
    cout << setfill('0') << setw(6) << get<1>(a);
    cout << setfill('0') << setw(6) << get<2>(a);
    cout << "\n";
  }
}

Measured memory_bytes: 4224