akhauriyash/Code-Regression huggingface dataset:
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>
using namespace std;

#define INF (1ll<<60)


long long M = 1000000007;


int main(int argc, char const *argv[]) {
    long long n,m;cin>>n>>m;
    vector<long long> w(n),v(n);
    for(int i=0;i<n;++i){
        cin>>w[i];
        cin>>v[i];
    }
    vector<long long> dp(m+1,-1);
    dp[0] = 0;
    long long res = 0;
    for(int i=0;i<n;++i){
        for(int k=m;k>0;--k){
            if(k-w[i]>-1&&dp[k-w[i]]!=-1){
                dp[k] = max(dp[k], dp[k-w[i]]+v[i]);
                res = max(res,dp[k]);
            }
        }
    }
    cout<<res<<endl;
    return 0;
}

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

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

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N; cin >> N;
	vector<int> v(N); rep(i, 0, N) { cin >> v[i]; }
	int ans(0);
	rep(i, 0, N) {
		
		ans += v[i] / 2;
		if (i + 1 < N&&v[i + 1] != 0)v[i + 1] += v[i] % 2;

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

Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static final int A = 0;
	public static final int C = 1;
	public static final int G = 2;
	public static final int T = 3;

	public static class Dictionary {
		private Dictionary[] index;
		private boolean judge;

		public Dictionary() {
			this.index = new Dictionary[4];
			this.judge = false;
		}

		public void insert(String word) {
			int i;

			if(word.charAt(0) == 'A') {
				i = A;
			} else if(word.charAt(0) == 'C') {
				i = C;
			} else if(word.charAt(0) == 'G') {
				i = G;
			} else {
				i = T;
			}

			if(this.index[i] == null) {
				this.index[i] = new Dictionary();
			}

			if(word.length() == 1) {
				this.index[i].judge = true;
				return;
			}

			this.index[i].insert(word.substring(1));
		}

		public boolean find(String word) {
			int i;

			if(word.charAt(0) == 'A') {
				i = A;
			} else if(word.charAt(0) == 'C') {
				i = C;
			} else if(word.charAt(0) == 'G') {
				i = G;
			} else {
				i = T;
			}

			if(this.index[i] == null) {
				return false;
			}

			if(word.length() == 1) {
				return this.index[i].judge;
			}

			return this.index[i].find(word.substring(1));
		}

	}

	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int orderNum = Integer.parseInt(br.readLine());

		Dictionary dictionary = new Dictionary();

		for(int i = 0; i < orderNum; i++) {
			String[] order = br.readLine().split(" ");

			if(order[0].equals("insert")) {
				dictionary.insert(order[1]);
			} else if(order[0].equals("find")) {
				if(dictionary.find(order[1])) {
					System.out.println("yes");
				} else {
					System.out.println("no");
				}
			}
		}
	}
}

Measured memory_bytes: 247416
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long long i=0; i<(n); ++i)
#define REP(i, d, n) for(long long i=(d); i<(n); ++i)
#define all(v) v.begin(), v.end()
using ll = long long;
int main() {//言語変えろ言語変えろ言語変えろ言語変えろ言語変えろ

int a; cin>>a;
string b; cin>>b;
  int c=b.size();
  
  if(c<=a){cout<<b<<endl;}
  else{
  rep(i,a){cout<<b.at(i);}
  
  cout<<"..."<<endl;
  }
}


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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    X=I()
    N=100
    ans=0
    while N<X:
        N=int(N*1.01)
        ans+=1
    print(ans)

main()


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

#define fastIO                    \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0);

using namespace std;

typedef long long ll;
typedef long double ld;

int main()
{
    fastIO;
    int N, K;
    cin >> N >> K;
    vector<int> h(N);
    for (int i = 0; i < N; i++)
    {
        cin >> h[i];
    }
    vector<int> min_cost(N, INT_MAX);
    min_cost[0] = 0;
    for (int i = 1; i < N; i++)
    {
        for (int j = 1; j <= min(i, K); j++)
        {
            min_cost[i] = min(min_cost[i], min_cost[i - j] + abs(h[i] - h[i - j]));
        }
    }
    cout << min_cost[N - 1] << "\n";
}

Measured memory_bytes: 3992
#include <bits/stdc++.h>
using i64 = long long;

std::vector<long long> fact, inv;

constexpr auto pow(long long x, long long n, const long long mod) {
    long long ret = 1;
    while(n > 0) {
        if ((n & 1) == 1) ret = (ret * x) % mod;
        x = (x * x) % mod;
        n >>= 1;
    }
    return ret;
}

constexpr auto inverse(const long long x, const long long p) {
    return pow(x, p - 2, p);
}

void init_factorial(const int n, const long long mod) {
    fact.resize(n + 1);
    inv.resize(n + 1);
    fact[0] = 1;
    for (long long i = 1; i <= n; i++) fact[i] = fact[i - 1] * i % mod;
    inv[n] = inverse(fact[n], mod);
    for (long long i = n; i > 0; i--) inv[i - 1] = inv[i] * i % mod;
}

constexpr i64 mod = 1000000007;

i64 calc(i64 r, i64 c) {
    if (!r || !c) return 0;
    if (r > c) std::swap(r, c);

    i64 s = 0, ret = 0;

    for (int i = 2; i <= r + 1; i++) {
        s = (s + 1) * 2 % mod;
        ret = (ret + s) % mod;
    }

    for (int i = r + 2; i <= c + 1; i++) {
        s = (s * 2 + 1 + mod - fact[i - 1] * inv[r] % mod * inv[i - 1 - r] % mod) % mod;
        ret = (ret + s) % mod;
    }

    for (int i = c + 2; i <= r + c; i++) {
        s = (s * 2 + mod * 2 - fact[i - 1] * inv[r] % mod * inv[i - 1 - r] % mod - fact[i - 1] * inv[c] % mod * inv[i - 1 - c] % mod) % mod;
        ret = (ret + s) % mod;
    }

    return ret;
}

int main() {
    constexpr i64 mod = 1000000007;
    int a, b, c, d;
    std::cin >> a >> b >> c >> d;
    init_factorial(2000001, mod);
    --a; --b;

    i64 ret = (calc(c, d) + calc(a, b) + mod - calc(a, d) + mod - calc(c, b)) % mod;
    std::cout << ret << std::endl;

    return 0;
}


Measured memory_bytes: 31488
#include <stdio.h>

int main() {
  int i;
  int alphabet[26] = {};
  char input_str[100001];
  scanf("%s", input_str);
  for(i = 0; i < strlen(input_str); i++) {
    alphabet[input_str[i]-'a']++;
  }
  for(i = 0; i < 26; i++) {
    if(alphabet[i] == 0) {
      printf("%c\n", 'a' + i);
      i--;
      break;
    }
  }
  if(i == 26) {
    printf("None\n");
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#define FOR(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
typedef long double dou;
const int N=6,M=51;
int n,m,L,u,w,vi[N],rk[N],p[N],a[N],f[N*M][32][N*M];
dou ans,nv;
void work(){
	memset(f,0,sizeof f);
	f[0][0][a[0]]=1;
	FOR(i,1,L)FOR(j,0,(1<<m)-1)FOR(k,i+1,L+1)if(w=f[i-1][j][k]){
		f[i][j][k]+=w;
		//cout<<i-1<<' '<<j<<' '<<k<<' '<<w<<'\n';
		if(!(u=p[i%n]) || (j&1<<u-1)) continue;
		f[i][j|1<<u-1][max(k,min(i+a[u],L+1))]+=w;
	}
	ans+=f[L][(1<<m)-1][L+1];
	//printf("%.13Lf\n",ans);
}
void dfs(int x){
	if(x>m) work();
	FOR(i,1,m)if(!vi[i]) vi[i]=1,rk[p[x]=i]=x,dfs(x+1),vi[i]=0;
}
int main(){
	//freopen("1.in","r",stdin);
	scanf("%d%d",&n,&L);L*=n;m=n-1;
	FOR(i,0,m) scanf("%d",&a[i]),a[i]*=n;
	FOR(i,1,m)if(a[i]>a[0]) swap(a[i],a[0]);
	dfs(1);nv=1;
	FOR(i,1,m) nv*=i*L/n;
	printf("%.13Lf",ans/nv);
} 

Measured memory_bytes: 12032
from functools import lru_cache

num = int(input())
arr = list(map(int, input().split()))
question_nums = int(input())
questions = list(map(int, input().split()))

@lru_cache(maxsize=2**12)
def solve(index, total):
    if total == 0:
        return True
    if index == num:
        return False
    return solve(index+1, total - arr[index]) or solve(index+1, total)

for q in questions:
    if solve(0, q):
        print("yes")
    else:
        print("no")


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


int main(void)
{
  string sentence;
  cin >> sentence;
  int flag = 0;
  int size;
  size = (int)(sentence.length());
  for(int i = 0; i < size/2; i++)
  {
    if(!(sentence.at(i) == sentence.at(size -1 -i)))
    {
      flag++;
    }
  }
  for(int i = 0; i < ((size - 1)/2) /2; i++)
  {
    if(!(sentence.at(i) == sentence.at((size -1)/2 -1 -i)))
    {
      flag++;
    }
  }
 // cout << size;
  for(int i = (size + 3) / 2 - 1; i < (size - (size + 3) / 2) /2; i++)
  {
    if(!(sentence.at(i) == sentence.at((size -1)/2 -1 -i)))
    {
      flag++;
    }
  }
  if(flag == 0)
  {
    cout << "Yes" << endl;
  }else
  {
    cout << "No" << endl;
  }
}

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

int main(){
  string S,T;
  cin >> S >> T;
  bool a=false;
  for(int i=0;i<S.size();i++){
    if(S==T){
      a=true;
      break;
    }
    char A=T.at(0);
    string U=T.substr(1,S.size()-1);
    T=U+A;
  }
  if(a){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}   

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

using namespace std;
typedef long long ll;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define INF (ll)2e9
#define MOD ((ll)1e9+7)
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((int)(x).size())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define bit(n) (1LL<<(n))

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

template<class InputIterator>
InputIterator adv(InputIterator x, typename std::iterator_traits<InputIterator>::difference_type n) {
    advance(x, n);
    return x;
}

class mod {
    static ll fact[];
public:

    template<class... A>
    static ll mul(A... args) {
        ll res = 1;
        for (ll i : std::initializer_list < ll > {args...}) {
            res = (res * i) % MOD;
        }
        return res;
    }

    static ll power(ll base, ll exp) {
        if (exp == 0) return 1;
        if (exp & 1) {
            return mul(base, power(base, exp - 1));
        } else {
            ll p = power(base, exp / 2);
            return mul(p, p);
        }
    }

    static ll factorial(int n) {
        if (fact[n] != 0) return fact[n];
        if (n == 0) return 1;
        return fact[n] = mul(n, factorial(n - 1));
    }

    static ll inverse(int n) {
        return power(n, MOD - 2);
    }

    static ll comb(int n, int r) {
        if (r < 0 || r > n) return 0;
        return mul(factorial(n), inverse(factorial(n - r)), inverse(factorial(r)));
    }

    template<class... A>
    static ll div(ll dividend, A... args) {
        ll res = dividend;
        for (ll i : std::initializer_list < ll > {args...}) {
            res = mul(res, inverse(i));
        }
        return res;
    }

    template<class... A>
    static ll add(A... args) {
        ll res = 0;
        for (ll i : std::initializer_list < ll > {args...}) {
            res = (res * i) % MOD;
        }
        return res;
    }

    template<class... A>
    static ll sub(ll l, A... args) {
        ll res = l;
        for (ll i : std::initializer_list < ll > {args...}) {
            res = (res - i + MOD) % MOD;
        }
        return res;
    }
};

ll mod::fact[(int) 1e6 + 1];

int ni() {
    int i;
    cin >> i;
    return i;
}

ll nll() {
    ll l;
    cin >> l;
    return l;
}

int main() {
    int N = ni();
    ll K = nll();
    ll cnt[(int)1e5+1] = {};
    REP(i, N) {
        int a = ni();
        int b = ni();
        cnt[a] += b;
    }

    ll sum = 0;
    REP(i, 1e5+1) {
        sum += cnt[i];
        if (sum >= K) {
            cout << i << endl;
            return 0;
        }
    }

    return 0;
}

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

#define in_fre freopen("redir.txt", "r", stdin);
#define out_fre freopen("out5.txt", "w", stdout);
#define fast() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define debug(i) printf("\nDebug %d\n",i);
#define mod 1000000007
#define ll long long int

int main()
{	
clock_t begin, end;
double time_spent;
begin = clock();

//	fast();
#ifndef ONLINE_JUDGE
	in_fre
	out_fre
#endif

int n;
cin>>n;
int a=0,b=0,c=0,d=0;
for(int i=0;i<n;i++)
{
	string st;
  cin>>st;
  if(st=="AC")
    a++;
  else if(st=="WA")
    b++;
  else if(st=="TLE")
    c++;
  else
    d++;
}
  cout<<"AC x "<<a<<"\n";
  cout<<"WA x "<<b<<"\n";
  cout<<"TLE x "<<c<<"\n";
  cout<<"RE x "<<d<<"\n";



end = clock();
time_spent = (double)(end - begin) / CLOCKS_PER_SEC;
cerr<<"Time spent = "<<time_spent<<endl;

return 0;
}

Measured memory_bytes: 3780
package main

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

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func main() {
	_, m := oneInt(), oneInt()
	lMax := 0
	rMin := 1000000

	for i := 0; i < m; i++ {
		//input := scanNums(2)
		lMax = max(lMax, oneInt())
		rMin = min(rMin, oneInt())
	}
	if rMin-lMax+1 < 0 {
		fmt.Println(0)
	} else {
		fmt.Println(rMin - lMax + 1)
	}
}

func oneInt() int {
	var a int
	fmt.Scan(&a)
	return a
}
func oneStr() string {
	var a string
	fmt.Scan(&a)
	return a
}

func readLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func scanNums(n int) (nums []int) {
	str := readLine()
	s := strings.Split(str, " ")
	for i := 0; i < n; i++ {
		num, _ := strconv.Atoi(s[i])
		nums = append(nums, num)
	}
	return nums
}

func scanStrings() []string {
	str := readLine()
	s := strings.Split(str, " ")

	return s
}

func abs(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton 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 max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton 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 strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}

func sortAsc(a []int) []int {
	sort.Ints(a)
	return a
}

func sortDesc(a []int) []int {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	return a
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	if a == 0 && b == 0 {
		return 0
	}
	return a * b / gcd(a, b)
}

func cumSum(nums []int) []int {
	sums := []int{0}

	for i := 0; i < len(nums); i++ {
		sums = append(sums, sums[i]+nums[i])
	}
	return sums
}


Measured memory_bytes: 7660
/*
 * Author : Sadi
 * Tue 14/07/2020
 * 14:26:46.34
 */
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <climits>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <vector>
#include <deque>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>

using namespace std;

#define    watch(x); cout << "\n" <<  #x << " is: " << x << "\n";
#define    all(a) (a).begin(), (a).end()
#define    fi first
#define    se second

template<class A, class B>
ostream& operator << (ostream& output, const pair<A, B>& p) {
    output << "(" << p.first << ", " << p.second << ")";
    return output;
}

template<class A>
ostream& operator << (ostream& output, const vector<A>& a) {
    output << "[";
    for(auto it = a.begin(); it != a.end(); ++it) {
        if(it != a.begin()) {
            output << ", ";
        }
        output << *it;
    }
    output << "]";
    return output;
}

using lld = long long;
using pii = pair<int, int>;
using pll = pair<lld, lld>;

//const int inf = 1e9;
//const int mod = 1e9 + 7;
//const double PI = acos(-1.0);
//const int mx = 1e5 + 5;



int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE

    int a, b;
    cin >> a >> b;
    if(a < 10 && b < 10) {
        cout << a * b << endl;
    }
    else {
        cout << -1 << endl;
    }
    return 0;
}


Measured memory_bytes: 3576
#########行列読み込み ##############################################
"""
from sys import stdin
n = int(stdin.readline().rstrip())
data = [stdin.readline().rstrip().split() for _ in range(n)]
print(data)
print(*data, sep='\n')
"""
##################################################################
#########入力系####################################################
"""
s =input()
s=list(input())
a=int(input())
x,y = map(int,input().split())	
li = input().split()	
li = list(map(int,input().split()))	
li = input().split('T')	
"""
##################################################################
n = int(input())
A = list(map(int,input().split()))	
B = []
cnt = 0

for i in A:
    if i%2==0:
        B.append(i)
for i in B:
    if i%3==0 or i%5==0:
        cnt +=1
if cnt==len(B):
    print("APPROVED")
else:
    print("DENIED")
        
            
    
    





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




int main(){

    int a,b,c;
    cin>>a>>b>>c;
    int d=max(a,b);
    int e=max(d,c);
    int f=a+b+c-e;
    cout<<f<<endl;
    return 0;
}


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

using namespace std;

int main(void){
    int count = 0;
    int N;

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

    for(int i=0; i<N-2; i++){
        if((p[i+1] - p[i])*(p[i+1] - p[i+2]) < 0){
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	string str1,str2;
	int n;
	cin>>n;
	n=n%26;
	cin>>str1;
	str2=str1;
	for(int i=0;i<str1.length();i++)
	{
		str2[i]+=n;
	}
	for(int i=0;i<str1.length();i++)
	{
		if(str2[i]>'Z')
		{
			int m=str2[i]-'Z';
			str2[i]='A'+(m-1);
		}
	}
	cout<<str2;
}

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

int main(){
    int n;
    cin>>n;
    int ans=0;
    ans+=n/500*1000;
    n%=500;
    ans+=n/5*5;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3592
#include <stdio.h>          // printf(), scanf()
#include <ctype.h>          // isdigit()

const int MAX_L = 80;
const char NUL = '\0';

int
main(int argc, char **argv)
{
	char str[MAX_L + 1];

	int sum = 0;
	while (scanf("%s", str) != EOF)
	{
		const char *s = str;
		while (*s != '\n' && *s != NUL)
		{
			while (!isdigit(*s) && *s != '\n' && *s != NUL)
				s++;

			int n = 0;
			while (isdigit(*s))
			{
				n = n * 10 + *s - '0';
				s++;
			}

			sum += n;
		}
	}

	printf("%d\n", sum);
	return 0;
}

Measured memory_bytes: 540
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> pii;
typedef tuple<int, int, int> tupiii;
typedef tuple<ll, ll, ll> tuplll;

const int INTMAX = 2147483647;
const ll LLMAX = 9223372036854775807;
const int MOD = 1000000007;

template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
inline void swap(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
inline void swap(int& a, int& b) { a ^= b; b ^= a; a ^= b; }


int n, k;
vll dp, vh;

void init()
{
	cin >> n >> k;
	dp.resize(n, INTMAX);
	vh.resize(n);

	REP(i, n) cin >> vh[i];
}


int main()
{
	init();

	dp[0] = 0;

	REP(i, n - 1)
	{
		REP1C(j, k)
		{
			if (i + j < n)
				chmin(dp[i + j], dp[i] + abs(vh[i] - vh[i + j]));
		}
	}
	cout << dp[n - 1] << endl;
}


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

set<string> ss;

signed main()
{
	ios::sync_with_stdio(false);
	string s;
	int k;
	cin>>s>>k;
	for(int i=0;i<s.size();i++){
		for(int j=1;j<=k;j++){
			if(i+j-1<s.size()) ss.insert(s.substr(i,j));
		}
	}
	int cnt=0;
	for(set<string>::iterator it=ss.begin();it!=ss.end();it++){
		cnt++;
		if(cnt==k){
			cout<<*it<<endl;
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 1664
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
using namespace std;
static const double EPS = 1e-10;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PI;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define F first
#define S second
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};

bool app[5001][5001];
int x[3000],y[3000];

main(){
  int n;
  while(scanf("%d",&n),n){
    memset(app,0,sizeof(app));
    rep(i,n){
      scanf("%d%d",x+i,y+i);
      app[x[i]][y[i]]=1;
    }
    int ans=0;
    rep(i,n){
      rep(j,n){
	int tx=x[i]-x[j],ty=y[i]-y[j];
	if(tx*tx+ty*ty<=ans)continue;
	if(0<=x[i]-ty && x[i]-ty<=5000 &&
	   0<=y[i]+tx && y[i]+tx<=5000 &&
	   app[x[i]-ty][y[i]+tx] &&
	   0<=x[j]-ty && x[j]-ty<=5000 &&
	   0<=y[j]+tx && y[j]+tx<=5000 &&
	   app[x[j]-ty][y[j]+tx])ans=tx*tx+ty*ty;
      }
    }
    printf("%d\n",ans);
  }
}

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

def main():
    N = int(input())
    a = list(map(int,input().split()))
    a.sort(reverse=True)
    k = max(a)
    tmp = k
    ans = 0
    for i in range(1,N):
        if tmp > abs(k//2-a[i]):
            tmp = abs(k//2-a[i])
            ans = a[i]

    print(k,ans)

if __name__ == "__main__":
    main()

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

int main() {
  int N,M;
  cin >> N >> M;
  int count=0;
  if (N>1){
    count += N*(N-1)/2;
  }
  if (M>1){
    count += M*(M-1)/2;
  }
  cout << count << endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
double dp[301][301][301];
int n;
double sushi(int o,int z, int t){
	if(z<0||o<0||t<0)
	return 0.0;
	if(dp[o][z][t]>=0.0)
	return (double) dp[o][z][t];
	dp[o][z][t]= o*sushi(o-1,z,t)+z*sushi(o+1,z-1,t)+t*sushi(o,z+1,t-1)+n;
	dp[o][z][t]/=(o+z+t);
	return dp[o][z][t];
}
int main(){
	
	int  o=0,z=0,t=0;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
	{
	cin>>a[i];
	if(a[i]==2)
	z++;
	else if(a[i]==1)
	o++;
	else
	t++;
	}
	memset(dp,-1.0,sizeof (dp));
	dp[0][0][0]=0.0;

	cout<<fixed<<setprecision(12)<<sushi(o,z,t);
	
	
	
}

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

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

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

  int s = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] == 1) s = i;
  }

  int ans = 0;
  ans += (s + (k - 2)) / (k - 1);
  int r1 = (s) % (k - 1);

  ans += (n - s - 1 + (k - 2)) / (k - 1);
  int r2 = (n - s - 1) % (k - 1);

  if (r1 > 0 && r2 > 0 && r1 + r2 <= k - 1) ans--;

  cout << ans << endl;
}


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

using namespace std;

int main()
{
   string s;
   cin>>s;
   int ans=0,len=s.length();
   for(int i=0;i<len/2;i++)
   {
       if(s[i]!=s[len-1-i])
        ans++;
   }
   cout<<ans;
   return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;
 
 
int main() {
    int N; cin >> N;
    vector<int>ns(N);
    for (int i = 0; i < N; ++i) {
        cin >> ns[i];
    }
    int Q; cin >> Q;
    int sum = 0;
    while (Q--) {
        int a; cin >> a;
        auto it = lower_bound(ns.begin(), ns.end(), a);
        auto jt = upper_bound(ns.begin(), ns.end(), a);
        sum += min(1,int(jt - it));
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3132
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long

signed main(){
    int A,B;
    cin>>A>>B;
    if(A>=13) cout<<B<<endl;
    if(A<=12&&A>=6) cout<<B/2<<endl;
    if(A<6) cout<<0<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <map>
#include <iostream>
#include <algorithm>
using namespace std;
#define ll long long
const int mod=1e9+7;
map<ll,ll> f;
ll Dp(ll x){
    if(f[x]) return f[x];
    return (f[x]=(Dp(x/2)+Dp((x-1)/2)+Dp((x-2)/2))%mod);
}
int main(){
    ll n;
    cin>>n;
    f[0]=1;
    f[1]=2;
    cout<<Dp(n)<<endl;
    return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
H = [int(i) for i in input().split()]
vec = [[] for _ in range(N)]
for _ in range(M) :
  A, B = map(int, input().split())
  vec[A - 1].append(B - 1)
  vec[B - 1].append(A - 1)

ret = 0
for i in range(N) :
  for j in vec[i] :
    if H[j] >= H[i] :
      break
  else :
    ret += 1
    
print(ret)

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

#define ll long long
#define pii pair<int,int>
#define fi first
#define se second
#define pb push_back

/** Dateloper */


using namespace std;
int main()
{
    string s,f;
    cin>>s>>f;
    int ans=0;
    for(int i=0;i<s.size();i++)
        if(s[i]==f[i])
        ans++;
    cout<<ans;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <deque>
#include <queue>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <bitset>
#include <stack>
#include <iomanip>
#include <utility>
#include <functional>
using namespace std;
//orz jzm
#define ll long long
#define ull unsigned ll
const ll PR=19260817;
int n, f[100005];
vector<int> g[100005];
void dfs(int u) {
	vector<int> v;
	for (int i=0; i<g[u].size(); i++) {
		dfs(g[u][i]);
		v.push_back(f[g[u][i]]);
	}
	sort(v.begin(), v.end());
	reverse(v.begin(), v.end());
	for (int i=0; i<g[u].size(); i++) {
		f[u]=max(f[u], v[i]+i+1);
	}
}
int main() {
	scanf("%d", &n);
	for (int i=1; i<n; i++) {
		int a;
		scanf("%d", &a);a--;
		g[a].push_back(i);
	}
	dfs(0);
	printf("%d\n", f[0]);
	return 0;
}

Measured memory_bytes: 13952
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <cstdio>
#include <iomanip>

using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;(i)>=0;(i)--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define PB_VEC(Itr1,Itr2) (Itr1).insert((Itr1).end(),(Itr2).begin(),(Itr2).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())

typedef long long ll;

int main(){
    
    int a[20];
    REP(i,20)cin>>a[i];
    
    sort(a,a+10);
    sort(a+10,a+20);
    
    cout<<a[7]+a[8]+a[9]<<" "<<a[17]+a[18]+a[19]<<endl;
    
    return 0;
}

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

using namespace std;

typedef pair<int, int> P;

const int M = 1<<18;

int main(){
    int m_idx[M], m2_idx[M];
    m_idx[0] = 0;
    m2_idx[0] = -1;
    int N;
    cin >> N;
    int A[M];
    for(int i = 0; i < (1<<N); i++){
        cin >> A[i];
    }
    for(int i = 1; i < (1<<N); i++){
        m_idx[i] = -1;
        for(int j = 0; j <= N; j++){
            int n = (1<<j);
            if(i&n){
                int m = i-n;
                if(m == 0){
                    if(A[i] > A[0]) {
                        m_idx[i] = i;
                        m2_idx[i] = 0;
                    }else{
                        m_idx[i] = 0;
                        m2_idx[i] = i;
                    }
                }else{
                    if(m_idx[i] == -1){
                        P cnd[3] = {P(A[m_idx[m]], m_idx[m]), P(A[m2_idx[m]], m2_idx[m]), P(A[i], i)};
                        sort(cnd, cnd+3, greater<P>());
                        m_idx[i] = cnd[0].second;
                        m2_idx[i] = cnd[1].second;
                    }else{
                        P cnd[4] = {P(A[m_idx[m]], m_idx[m]), P(A[m2_idx[m]], m2_idx[m]), P(A[m_idx[i]], m_idx[i]), P(A[m2_idx[i]], m2_idx[i])};
                        sort(cnd, cnd+4, greater<P>());
                        m_idx[i] = cnd[0].second;
                        for(int k = 1; k < 4; k++){
                            if(cnd[k].second != cnd[0].second){
                                m2_idx[i] = cnd[k].second;
                                break;
                            }
                        }
                    }
                }
            }
        }
    }
    int tmp_max = A[0]+A[1];
    cout << tmp_max << '\n';
    for(int i = 2; i < (1<<N); i++){
        //cout << m_idx[i] << ' ' << m2_idx[i] << endl;
        tmp_max = max(tmp_max, A[m_idx[i]]+A[m2_idx[i]]);
        cout << tmp_max << endl;
    }
}

Measured memory_bytes: 6144
$n=gets.chomp.to_i

def dfs(s)
  return 0 if s.to_i > $n
  ret = 0
  ret = 1 if s.include?("3") && s.include?("7") && s.include?("5")
  c = "753"
  for i in 0..2 do
    ret += dfs(s+c[i])
  end
  return ret
end

puts dfs("0")


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

/* using */
using namespace std;

/* main constructor */
struct Fast
{
    Fast()
    {
        std::cin.tie(0);
        ios::sync_with_stdio(0);
        cout << fixed << setprecision(12);
    }
} fast;

/* template */
template <class T>
bool chmax(T &a, const T &b) { return (a < b) ? (a = b, 1) : 0; }
template <class T>
bool chmin(T &a, const T &b) { return (b < a) ? (a = b, 1) : 0; }

/* define */
#define REP(i, x, n) for (int i = x; i < (int)(n); ++i)
#define RREP(i, x, n) for (int i = x - 1; i >= (int)(n); --i)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) REP(i, 1, n + 1)
#define rrep(i, n) RREP(i, n, 0)
#define each(i, n) for (auto &i : n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define eunique(x) \
    sort(all(x));  \
    (x).erase(unique(all(x)), (x).end())
#define int long long
#define mp make_pair

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

/* const */
const int inf = 1e9 + 7;
const int dxl[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dyl[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dxs[4] = {1, 0, -1, 0};
const int dys[4] = {0, 1, 0, -1};

/* main */
signed main(void)
{
    string a, b, c;
    cin >> a >> b;
    c = a + b;
    cout << ((sqrt((double)stoi(c)) == (int)sqrt((double)stoi(c))) ? "Yes" : "No") << 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);
        double a = sc.nextDouble();
        double b = sc.nextDouble();
        double x = sc.nextDouble();
        double m = a*a*b;
        double y = 0.0;
        double ans = 0.0;
        if(x < m/2){
            y = 2*x/(a*b*b);
            ans = 90.0 - Math.toDegrees(Math.atan(y));
        }else{
            y = 2*(a*a*b-x)/(a*a*a);
            ans = Math.toDegrees(Math.atan(y));
        }

        System.out.println(ans);
        sc.close();

    }

}


Measured memory_bytes: 23252
#include<iostream>
#include<algorithm>
#include<map>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
ll dp[3][3];
ll a[10005];
ll b[10005];
int main() {
	ll ans = inf;
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> dp[i][j];
			ans = min(ans, dp[i][j]);
		}
		a[i] = ans;
		ans = inf;
	}
	for (int i = 0; i < 3; i++) {
		b[i] = dp[0][i] - a[0];
	}
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			if (dp[i][j] != a[i] + b[j]) {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    string s;
    cin >> a >> b;
    cin >> s;
    int t = 1;
    for(int i = 0; i < a; i++){
        if(s[i] < '0' || s[i] > '9'){
            t = 0;
        }
    }
    if(s[a] != '-'){
        t = 0;
    }
    for(int i = a + 1; i < a + b + 1; i++){
        if(s[i] < '0' || s[i] > '9'){
            t = 0;
        }
    }
    if(t == 1){
        cout << "Yes";
    }else{
        cout << "No";
    }
}

Measured memory_bytes: 256
n = int(input())
A = [int(i) for i in input().split()]

q = int(input())
m = [int(i) for i in input().split()]

def dfs(idx, s, target):
    if s + sum(A[idx:]) < target:
        return 0
    if s == target:
        return 1
    if s > target or idx == n:
        return 0

    return dfs(idx+1, s, target) or dfs(idx+1, s + A[idx], target)

for target in m:
    ans = 'yes' if dfs(0, 0, target) else 'no'
    print(ans)


Measured memory_bytes: 5628
import java.util.*;
public class Main {

	public static void main(String[] args) {		
		Scanner scn = new Scanner(System.in);
		int d = scn.nextInt();
		int t = scn.nextInt();
		int s = scn.nextInt();
		if(d<=t*s)
			System.out.println("Yes");
		else
			System.out.println("No");
	}

}


Measured memory_bytes: 27012
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using lint = long long;
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; }

int main()
{
	int A, B, C;
  	cin >> A >> B >> C;
  
  	if (A == B && B != C) {
      cout << "Yes" << endl;
    } else if (B == C && C != A) {
      cout << "Yes" << endl;
    } else if (C == A && A != B) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream> // c++の標準入出力
#include <stdio.h> // c言語の標準入出力
#include <string>
using namespace std;

int main()
{
	int a;
	char s[20];
	scanf("%d", &a);
	scanf("%s", s);
	if (a >= 3200) { printf("%s", s); }
	else if (a < 3200) { printf("%s", "red"); };
}

Measured memory_bytes: 256
K = gets.to_i

if [0, 2, 4, 5, 6, 8].include?(K % 10)
  puts -1
  exit
end

n = 0
1_000_000.times.each do |i|
  n = n * 10 + 7
  if n % K == 0
    puts i + 1
    exit
  end
  n = n % K
end


Measured memory_bytes: 14400
#include<iostream>
#include<math.h>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

#include<cstdio>

#define FOR(i, n) for(int i = 0; i < (n); i++)
#define FORq(i, m, n) for(int i = (m); i < (n); i++)
#define FORr(i, n) for (int i = (n); i >= 0; i++)


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

	cout << (N * N) - A << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class Program {
	static void Main(string[] args) {
		new Calc().Solve();
	}
	public class Calc {
		public Calc() { }
		public void Solve() {
			int n = Utils.ReadLine<int>();
			var a = Utils.ReadLine<int>(' ');
			long sum = 0;
			long x = 0, y = 0;
			for (int i = 0; i < n; i++) {
				sum += a[i];
				if (i % 2 == 0) {
					if (sum > 0) continue;
					x += Math.Abs(sum) + 1;
					sum = 1;
				} else {
					if (sum < 0) continue;
					x += Math.Abs(sum) + 1;
					sum = -1;
				}
			}
			sum = 0;
			for (int i = 0; i < n; i++) {
				sum += a[i];
				if (i % 2 == 1) {
					if (sum > 0) continue;
					y += Math.Abs(sum) + 1;
					sum = 1;
				} else {
					if (sum < 0) continue;
					y += Math.Abs(sum) + 1;
					sum = -1;
				}
			}
			Math.Min(x, y).WriteLine();
			return;
		}
	}
}
public static class Utils {
	public static T ReadLine<T>() {
		return (T)Convert.ChangeType(Console.ReadLine(), typeof(T));
	}

	public static T[] ReadLine<T>(params char[] separators) {
		return Console.ReadLine()
			.Split(separators)
			.Where(_ => _.Length > 0)
			.Select(_ => (T)Convert.ChangeType(_, typeof(T)))
			.ToArray();
	}

	public static List<T> ReadLines<T>(int readCount) {
		List<T> rt = new List<T>();
		for (int i = 0; i < readCount; i++) {
			rt.Add(ReadLine<T>());
		}
		return rt;
	}

	public static string Docking<T>(this IEnumerable<T> s, int sequenceRange, Func<T, string> filter = null) {
		string str = "";
		int c = 0;
		foreach (var item in s) {
			str += filter == null ? item.ToString() : filter(item);
			c++;
			if (c == sequenceRange) break;
		}
		return str;
	}

	public static string Docking<T>(this IEnumerable<T> s, Func<T, string> filter = null) {
		return s.Docking(s.Count(), filter);
	}

	public static string RangeDocking<T>(this IEnumerable<T> s, int start, int end, Func<T, string> filter = null) {
		string str = "";
		end = end < s.Count() ? end : s.Count();
		var items = s.ToArray();
		for (int i = start; i < end; i++) {
			str += filter == null ? items[i].ToString() : filter(items[i]);
		}
		return str;
	}
	public static int IntParse(this string n) {
		return int.Parse(n);
	}


	public static void WriteLine(this object obj) {
		Console.WriteLine(obj);
	}
	public static void AddTo<T>(this T obj,List<T> list) {
		list.Add(obj);
	}
}

Measured memory_bytes: 29020
#include <iostream>

using namespace std;

int main(){
  int n;
  cin >> n;
  int b,f,r,v;
  int room[4][3][10] = {0}; // 4棟 3階建て 10部屋
  for(int i = 0; i<n; i++){
    cin >> b >> f >> r >> v;
    room[b-1][f-1][r-1] += v;
  }
  //cout << "debug" <<endl;
  for(int i = 0;i<4; i++){
    for(int j = 0;j<3; j++){
      for(int k = 0; k<10 ; k++){
        if(k != 9)cout << ' ' << room[i][j][k] ;
        else cout << ' ' << room[i][j][k] << endl;
      }
    }
    if(i != 3)cout << "####################" << endl;
  }


  return 0;
}



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

int main(){

  int h[5];
  int f[4];

  while(1){
    for(int i=0;i<4;i++) f[i]=0;
    for(int i=0;i<5;i++){
      cin>>h[i];
      if(h[i]==0) break;
      f[h[i]]=1;
    }
    if(h[0]==0) break;

    int x[2], cnt=0;
    for(int i=1;i<4;i++){
      if(f[i]==1)
	x[cnt++]=i;
      //cout<<i<<" "<<f[i]<<endl;
    }
    //cout<<"    "<<cnt<<" "<<x<<endl;
    if(cnt==2){
      if(x[0]==1&&x[1]==2){
	for(int i=0;i<5;i++){
	  if(h[i]==1) cout<<1<<endl;
	  else cout<<2<<endl;
	}
      }
      if(x[0]==1&&x[1]==3){
	for(int i=0;i<5;i++){
	  if(h[i]==1) cout<<2<<endl;
	  else cout<<1<<endl;
	}
      }
      if(x[0]==2&&x[1]==3){
	for(int i=0;i<5;i++){
	  if(h[i]==2) cout<<1<<endl;
	  else cout<<2<<endl;
	}
      }
    }else{
      for(int i=0;i<5;i++) cout<<3<<endl;
    }
  }
  
  return 0;
}

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

int main(){
    while(1){
        int n,m;
        cin >> n >> m;
        if(n == 0 && m ==0) break;
        vector<int> a(n),b(m);
        int a_sum = 0,b_sum = 0;
        P ans = P(INF,INF);
        rep(i,n){
            cin >> a[i];
            a_sum += a[i];
        }
        rep(i,m){
            cin >> b[i];
            b_sum += b[i];
        }
        rep(i,n)rep(j,m){
            if(a_sum - a[i] + b[j] == b_sum - b[j] + a[i]){
                if(ans.first + ans.second > a[i] + b[j]){
                    ans = P(a[i],b[j]);
                }
            }
        }
        if(ans.first == INF) cout << -1 << endl;
        else cout << ans.first <<" " << ans.second << endl;
    }
    return 0;
}


Measured memory_bytes: 3088
n=int(input())
x=1
X='abcdefghijklmnopqrstuvwxyz'
for i in range(1,100):
    if x<=n<x+26**i:
        n-=x
        cnt=i
        break
    else:
        x+=26**i
ans=''
for i in range(cnt):
    ans=ans+X[n%26]
    n//=26

print(ans[::-1])

Measured memory_bytes: 61072
#include <algorithm>
#include <complex>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
using namespace std;

int main()
{
    int n, l;
    cin >> n >> l;
    vector<string> s(n);
    for (int i = 0; i < n; i++) cin >> s[i];
    sort(s.begin(), s.end());
    for (int i = 0; i < n; i++) {
        cout << s[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define EQ(x, y) (abs(x - y) < 1e-9)
typedef long long ll;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.precision(10);
	cout << fixed;

	int a, b;
	cin >> a >> b;
	cout << max(max(a - b, a + b), a * b) << '\n';

#ifdef local
	cout << setprecision(3) << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s.\n";
#endif
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>
#include <ios>
#include <cctype>
#include <cstdio>
#include <functional>
#include <cassert>

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define FORR(i,a,b) for(int i = (a) - 1;i >=(b);--i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).sizeT()
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())
#define ASSERT(cond,mes) assert(cond && mes)

using namespace std;
using ll = long long;

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())is >> v[i];
    return is;
}

template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
    REP(i, (int)v.size())os << v[i] << endl;
    return os;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a)n = a;
    if (n > b)n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u / GCD(u, v) * v;
}

template <typename T>
static int sign(T t) {
    if (t > 0)return 1;
    else if (t < 0)return -1;
    else return 0;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << fixed << setprecision(20);

    int N;
    cin >> N;
    vector<int>A(N);
    cin >> A;

    ll cnt = 0;
    ll sum = 0;

    REP(i, N) {
        sum += A[i];
        if (i % 2 == 0 && sum <= 0) {
            cnt += (1 - sum);
            sum = 1;
        }
        if (i % 2 == 1 && sum >= 0) {
            cnt += (sum + 1);
            sum = -1;
        }
    }

    sum = 0;
    ll cnt2 = 0;
    REP(i, N) {
        sum += A[i];
        if (i % 2 == 1 && sum <= 0) {
            cnt2 += (1 - sum);
            sum = 1;
        }
        if (i % 2 == 0 && sum >= 0) {
            cnt2 += (sum + 1);
            sum = -1;
        }
    }

    cout << min(cnt, cnt2) << endl;

    return 0;
}

Measured memory_bytes: 640
import Data.Char                                                                                                           
main :: IO ()                                                                                                              
main = do                                                                                                                  
  s <- getLine                                                                                                             
  let a = (=='A') (head s)                                                                                                 
      b = (==1) $ length . filter (=='C') $ init . drop 2 $ s                                                              
      c = all isLower . filter (/='C') . tail $ s                                                                          
  putStrLn $ if a && b && c then "AC" else "WA"

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

int main(){
  int A, B,C;
  cin>>A>>B>>C;
  if((A==B && A!=C) || (A==C && B!=C) || (C==B && A!=C)) printf("Yes\n");
  else printf("No\n");
  return 0;
}


Measured memory_bytes: 256
N=int(input())
A=[]
for i in range(N):
    a,b=list(map(int,input().split()))
    A.append([a,b])
A=sorted(A,key=lambda a:a[1])
m=0
s="Yes"
for a in A:
    m+=a[0]
    if m>a[1]:
      s="No"
      break
print(s)

Measured memory_bytes: 40532
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
inline void Rd(int &res){
	char c;res=0;
	while(c=getchar(),c<'0');
	do{
		res=(res<<1)+(res<<3)+(c^48);
	}while(c=getchar(),c>='0');
}
const int M=100005;
struct Node{int to,nxt;}Edge[M<<1];
int Head[M],tot,n,SG[M];
inline void Addedge(int a,int b){
	Edge[tot]=(Node){b,Head[a]};Head[a]=tot++;
	Edge[tot]=(Node){a,Head[b]};Head[b]=tot++;
}
void dfs(int x,int f){
	for(int i=Head[x];~i;i=Edge[i].nxt){
		int to=Edge[i].to;
		if(to==f)continue;
		dfs(to,x);
		SG[x]^=(SG[to]+1);
	}
}
int main(){
	Rd(n);
	memset(Head,-1,sizeof(Head));
	for(int i=1;i<n;i++){
		int a,b;
		Rd(a),Rd(b);
		Addedge(a,b);
	}
	dfs(1,0);
	puts(SG[1]?"Alice":"Bob");
	return 0;
}

Measured memory_bytes: 7296
import bisect as bi
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
if sum(a)<sum(b):print(-1)
else:
    add=[]
    req=0
    ans=0
    for i in range(n):
        if a[i]>b[i]:
            add.append(a[i]-b[i])
        elif a[i]<b[i]:
            req+=b[i]-a[i]
            ans+=1
    add.sort(reverse=True)
    sadd=[0]*(len(add)+1)
    for i in range(len(add)):
        sadd[i+1]=sadd[i]+add[i]
    print(ans+bi.bisect_left(sadd,req))

Measured memory_bytes: 19188