akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <vector>
#include <numeric>
#include <climits>
using namespace std;



int main() {
  // 入力
  int N, W;
  cin >> N >> W;
  int ans[3];
  ans[0] = -1;
  ans[1] = -1;
  ans[2] = -1;
  int val = 0;
  int k;
  bool break_flag = false;
  for(int i = 0; i < N+1; ++i){
    for(int j = 0; j < N+1; ++j){
      if((i + j) > N){
        break;
      }

      k = N-i-j;
      if(k < 0){break;}

      val = i*10000 + j*5000 + k*1000;
      if((val == W) && (i+j+k == N)){
        ans[0] = i;
        ans[1] = j;
        ans[2] = k;
        break_flag = true;
        break;
      }
    }
    if(break_flag){
      break;
    }
  }

  cout << ans[0] << ' ' << ans[1] << ' ' << ans[2] << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;

int main() {
    string S;
    cin >> S;
    reverse(ALL(S));
    vector<int> A(S.size()), B(S.size());
    A.at(0) = 10 - (S.at(0) - '0');
    B.at(0) = S.at(0) - '0';
    for (int i = 1; i < S.size(); i++){
        A.at(i) = min(A.at(i - 1) + 10 - (S.at(i) - '0' + 1), 10 - (S.at(i) - '0') + B.at(i - 1));
        B.at(i) = min(A.at(i - 1) + S.at(i) - '0' + 1, B.at(i - 1) + S.at(i) - '0');
    }
    cout << min(A.at(S.size() - 1) + 1, B.at(S.size() - 1)) << endl;
}


Measured memory_bytes: 9220
#include<bits/stdc++.h>
#define pb push_back
#define int long long
#define M 1000000007
using namespace std;
const int inf=4e18;
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	int n,i,j;cin>>n;
	for(i=1;i<10;i++)
		for(j=1;j<10;j++)
			if(i*j==n)
			{
				cout<<"Yes\n";
				return 0;
			}
	cout<<"No\n";
}

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

int main(void){
	string s;
	cin >> s;

	int cnt = 0;
	for(int i=0;i<s.size();i++){
		if(!cnt && s[i] == 'C'){
			cnt++;
		}else if(cnt == 1 && s[i] == 'F'){
			cnt++;
		}
	}
	if(cnt == 2)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 764
import java.util.Scanner;

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

        int b = scan.nextInt();

        if(a<b){
            System.out.println("a < b");
        }
        if(a>b){
            System.out.println("a > b");
        }
        if(a==b){
            System.out.println("a == b");
        }    
      }
}



Measured memory_bytes: 26180
function Main(input) {
    var a = parseInt(input[0], 10);
    var b = parseInt(input[1], 10);

    var result = (a + b) / 2;
    console.log((a + b) % 2 === 0 ? result : 'IMPOSSIBLE');
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split(/\n|\s/));

Measured memory_bytes: 11468
from collections import Counter
from math import factorial

def prime_factorize(n):
    a = []
    while n%2 == 0:
        a.append(2)
        n //=2
    f = 3
    while f*f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

def prime_factoring(n):
    from collections import Counter
    a = prime_factorize(n)
    return Counter(a)

N = int(input())
fac =factorial(N)
List = prime_factoring(fac).values()
# print(List)

def num(m):
    return len(list(filter(lambda x: x >= m-1, List)))
print(num(75)+ num(25)*(num(3)-1) + num(15)*(num(5)-1)+ num(5)*(num(5)-1)*(num(3)- 2)//2)


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

int main() {
  int64_t x;
  cin >> x;
  
  int64_t ans = 0, x_dash = 0;
  
  ans += (x / 500) * 1000;
  x_dash = x % 500;
  ans += (x_dash / 5) * 5;
  
  cout << ans << endl;
}

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


int main() {
  ll N;
  cin >> N;
  ll ans = 0;
  for (ll i = 1; i <= N; i++) {
    if (i % 3 != 0 && i % 5 != 0) ans += i;
  }

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


Measured memory_bytes: 3640
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s1= sc.next();
		String s2= sc.next();
		int a[] = new int[26];
		int b[] = new int[26];
		for (int i=0;i<s1.length();i++) {
			a[s1.charAt(i)-'a']++;
		}
		for (int i=0;i<s1.length();i++) {
			b[s2.charAt(i)-'a']++;
		}
		Arrays.sort(a);
		Arrays.sort(b);
		for (int i=0;i<26;i++) {
			if (a[i]!=b[i]) {
				System.out.println("No");
				return;
			}
		}
		System.out.println("Yes");
	}

}

Measured memory_bytes: 28136
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


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

    string s;
    cin >> s;

    vector< bool > used(27, false);
    rep (i, s.size())
    {
        used[s[i] - 'a'] = true;
    }

    int idx = 0;
    for (; idx < 26; ++idx)
    {
        if (!used[idx]) break;
    }

    string ans;
    int pos = -1;
    for (int i = s.size() - 1; i > 0; --i)
    {
        if (s[i - 1] < s[i])
        {
            pos = i - 1;
            break;
        }
    }

    if (idx == 26)
    {
        if (pos == -1) ans = "-1";
        else
        {
            char c = 'z';
            for (idx = pos; idx < s.size(); ++idx)
            {
                if (s[idx] > s[pos] && c > s[idx])
                {
                    c = s[idx];
                }
            }
            ans = s.substr(0, pos) + c;
        }
    }
    else
    {
        ans = s + (char)(idx + 'a');
    }

    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int> >;
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 1000000000000000ll;
const ll MOD = 1000000007LL;
//ノート　isupperで大文字の判定　islowerで小文字の判定
int main(){
   int n;
   std::cin >> n;
   VEC(int,a,n);
   sort(all(a));
   bool han=1;
   rep(i,n-1){
        if(a[i]==a[i+1])han=0;
    }  
    if(han)std::cout << "YES" << std::endl;
    else std::cout << "NO" << std::endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <cassert>
#include <limits>
#include <numeric>
#include <type_traits>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <functional>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

typedef long long ll;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)

int main(){
	ll X, A;
	cin >> X >> A;
	if(X < A){
		cout << 0 << endl;
	}
	else{
		cout << 10 << endl;
	}
}

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

int main(){
  	string S, T;
  	int A, B;
  	string U;
  	cin >> S >> T >> A >> B >> U;
  	if(S==U){
    	cout << A-1 << " "<< B << endl;
    }else{
    	cout << A << " " << B-1 << endl;
    }
	return 0;
}

Measured memory_bytes: 256
N=int(input())
s=input()

def judge(a1,an):
    A=[-1]*N
    A[0]=a1
    A[N-1]=an
    A[1]=A[N-1]^A[0]^(1 if s[0]=='o' else 0)
    for i in range(1,N-2):
        A[i+1]=A[i-1]^A[i]^(1 if s[i]=='o' else 0)
    jn=A[N-3]^A[N-2]^(1 if s[N-2]=='o' else 0)
    j1=A[N-2]^jn^(1 if s[N-1]=='o' else 0)
    if j1==a1 and jn==an: return A
    return None

for a1 in range(2):
    for an in range(2):
        r = judge(a1,an)
        if r!=None:
            print(''.join([('S' if a==1 else 'W') for a in r]))
            exit()
print(-1)


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

using namespace std;

typedef long long ll;

ll n, k;
ll w[110], v[110], wb;
ll knap[110][110][310];
ll INF = 1LL<<40;

int main() {
    int i, j, l;

    scanf("%lld%lld",&n,&k);
    for (i=1;i<=n;i++) scanf("%lld%lld",&w[i],&v[i]);
    wb = w[1];
    for (i=1;i<=n;i++) w[i] -= wb;
    for (i=0;i<=n;i++) for (l=0;l<=3*n;l++) knap[i][0][l] = -INF;
    knap[0][0][0] = 0;
    for (i=0;i<=n;i++) {
        for (j=1;j<=n;j++) {
            for (l=0;l<=3*n;l++) {
                knap[i][j][l] = max(knap[i][j-1][l],((l>=w[j]&&i>=1)?knap[i-1][j-1][l-w[j]]+v[j]:(-INF)));
            }
        }
    }
    ll res = 0;
    for (i=0;i<=n;i++) {
        for (l=0;l<=min(k-wb*i,3*n);l++) {
            res = max(res,knap[i][n][l]);
        }
    }
    printf("%lld\n",res);

    return 0;
}


Measured memory_bytes: 28800
#include<cstdio>
main(){
	int w,h,x,y,r;
	scanf("%d%d%d%d%d",&w,&h,&x,&y,&r);

	printf("%s\n",((x-r<0||x+r>w||y-r<0||y+r>h)?"No":"Yes"));
}

Measured memory_bytes: 1016
while 1:
    n = input()
    if n == 0:
        break
    st = [[]]
    for i in xrange(n):
        s = raw_input()
        lev = s.count('.')
        v = s[lev:]
        while lev+1 < len(st):
            top = st.pop()
            op = st[-1].pop()
            if op == '+':
                st[-1].append(sum(top))
            else:
                st[-1].append(reduce(lambda x,y: x*y, top))
        if v in '+*':
            st[lev].append(v)
            st.append([])
        else:
            st[lev].append(int(v))
    while len(st) > 1:
        top = st.pop()
        op = st[-1].pop()
        if op == '+':
            st[-1].append(sum(top))
        else:
            st[-1].append(reduce(lambda x,y: x*y, top))
    print st[-1][0]

Measured memory_bytes: 6524
// https://atcoder.jp/contests/cf16-exhibition-final-open/tasks/cf16_exhibition_final_b
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define EPS (1e-9)
#define INF (1e9)
#define INFL (1e18)
#define MOD (1000000007)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define BIT(n) (1LL << (n))
// ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
// ll lcm(ll c, ll d) { return c / gcd(c, d) * d; }

struct dist {
    int x, y;
};
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    dist in[3];
    REP(i, 3) cin >> in[i].x >> in[i].y;
    double a = hypot(in[0].x - in[1].x, in[0].y - in[1].y);
    double b = hypot(in[1].x - in[2].x, in[1].y - in[2].y);
    double c = hypot(in[2].x - in[0].x, in[2].y - in[0].y);
    double s = (a + b + c) / 2;
    double sq = sqrt(s * (s - a) * (s - b) * (s - c));
    double r = 2 * sq / (a + b + c);
    double d = max({a, b, c});
    double x = d / (2 + d / r);
    cout << x << endl;

    return 0;
}


Measured memory_bytes: 256
N, H = map(int,input().split())
damage_low = [0 for i in range(0,N)]
damage_high = [0 for i in range(0,N)]
count = 0

for i in range(0,N):
    a, b = map(int,input().split())
    damage_low[i] = a
    damage_high[i] = b

damage_low.sort()  #小さいもの順に並べる
damage_high.sort()

for i in range(0,N):  #刀を強いもの順に投げる
    if damage_high[N-1-i] > damage_low[N-1]:  #一番強い刀の振りより小さければ投げる必要はない

        H = H - damage_high[N-1-i]  #昇順になってるので逆から指定
        count += 1
    if H <= 0:  #投げてる途中でHPが0になったら抜け出す
        break

while H > 0:  #まだHPがのこっているなら一番強い刀で振りまくる
    if H % damage_low[N-1] == 0:
        count = count + (H // damage_low[N-1])
        break
    else:
        count = count + (H // damage_low[N-1]) + 1
        break

print(count)

Measured memory_bytes: 11360
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define INF 10000000000000
#define MOD 1000000007LL
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
using PII = pair<int64_t, int64_t>;
using VI = vector<int64_t>;
using VVI = vector<VI>;
using VS = vector<string>;
using VP = vector<PII>;
using i64 = int64_t;
template<typename T> void invec(vector<T> &A){for(T& a : A) cin >> a;} // input vector


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

int N, M, Q; cin >> N >> M >> Q;
VVI cnt(N+1, VI(N+1, 0));
rep(i, 0, M){
    int L, R;
    cin >> L >>  R; 
    ++cnt[L][R];
} 

// 2次元累積和
for (int i = 1; i <= N; i++) { for (int j = 1; j <= N; j++) cnt[i][j] += cnt[i][j - 1]; }
for (int i = 1; i <= N; i++) { for (int j = 1; j <= N; j++) cnt[i][j] += cnt[i - 1][j]; }


rep(_, 0, Q){
    int p, q; cin >> p >> q;
    cout << cnt[q][q] - cnt[p-1][q] - cnt[q][p-1] + cnt[p-1][p-1] << "\n";
}
}
// 書いて考える．場合分け．情報整理．
// 境界，出力文字列 チェック．行末にスペース入れない．
// 可読性優先．高速化次点．
// まずは全探索，次にDP
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性，二分探索
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理．前処理によるクエリ高速化．
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり
// 実行エラー：vector添え字超え．0割り．



Measured memory_bytes: 2944
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int maxn=105;
char s[maxn];
int main(){
	scanf("%s",s);
	int n=strlen(s),ans=(~0u)>>1;
	for(char c='a';c<='z';c++){
		int last=n,tmp=0;
		for(int i=n-1;i>=0;i--)if(s[i]==c){
			tmp=max(tmp,last-i-1);
			last=i;
		}
		tmp=max(tmp,last);
		ans=min(ans,tmp);
	}
	printf("%d",ans);
	return 0;
}

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

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;

const int N = 100010;
const double eps = 1e-6;

int n, a[N];

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

    int sum = 0;
    for(int i = 1; i <= n + 1; i++) sum += abs(a[i] - a[i - 1]);

    for(int i = 1; i <= n; i++)
        if(a[i - 1] < a[i] && a[i] < a[i + 1] || a[i - 1] > a[i] && a[i] > a[i + 1])
        {
            cout << sum << endl;
        }
        else
        {
            int d = min(abs(a[i - 1] - a[i]), abs(a[i + 1] - a[i]));
            cout << sum - 2 * d << endl;
        }
    return 0;
}


Measured memory_bytes: 1664
package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"os"
	"strconv"
)

type priorityQueue []int

func (p priorityQueue) Len() int            { return len(p) }
func (p priorityQueue) Less(i, j int) bool  { return p[i] > p[j] }
func (p priorityQueue) Swap(i, j int)       { p[i], p[j] = p[j], p[i] }
func (p *priorityQueue) Push(x interface{}) { *p = append(*p, x.(int)) }
func (p *priorityQueue) Pop() interface{} {
	old := *p
	n := len(old)
	x := old[n-1]
	*p = old[0 : n-1]
	return x
}

func main() {
	var n, m int
	fmt.Scan(&n, &m)

	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	ts := make(map[int][]int)
	for i := 0; i < n; i++ {
		sc.Scan()
		a, _ := strconv.Atoi(sc.Text())
		sc.Scan()
		b, _ := strconv.Atoi(sc.Text())
		ts[a] = append(ts[a], b)
	}

	pq := make(priorityQueue, 0, n)
	heap.Init(&pq)
	ans := 0
	for i := 1; i <= m; i++ {
		for _, v := range ts[i] {
			heap.Push(&pq, v)
		}
		if len(pq) > 0 {
			ans += heap.Pop(&pq).(int)
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 11648
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <stack>
#include <map> 
#include <set>
#include <string>
#include <functional>
#include <list>
#include <random>
#include <time.h>
#include <iomanip>
#include <assert.h>
#include <numeric>
#include <new>
#define BIT(nr) (1ULL << (nr))
#define int long long
#define ll long long
#define double long double
#define mod 1000000007
#define MAXN (int)1e+5 * 2+1
#define LL_MAX 9223372036854775807	//ない環境用
#define LL_HALFMAX 9223372036854775807 / 2	//ない環境用
#define MIN -(9223372036854775807 / 2)
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define mp make_pair
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }


using namespace std;

signed main() {

    int M;
    cin >> M;
    vector<int> d(M), c(M);

    int keta = 0;
    int su = 0;

    rep(i, M) {
        int di, ci;
        cin >> di >> ci;
        d[i] = di;
        c[i] = ci;
        keta += ci;
        su += ci*di;
    }

    cout << keta - 1 + (su - 1)/9 << "\n";

    return 0;
}


Measured memory_bytes: 3456
#include <iostream>
#include <vector>
#include <algorithm>
#define N 100000 //10^5
#define M 100000 //10^5
typedef long long ll;
using namespace std;

int main()
{
    int n, m;
    vector<pair<int, int>> shops;
    ll money = 0;
    int n_drink = 0;

    cin >> n >> m;
    for (int i = 0; i < n; i++)
    {
        int a, b;
        cin >> a >> b;
        shops.push_back(make_pair(a, b));
    }

    sort(shops.begin(), shops.end());
    //, [](pair<int, int> &a, pair<int, int> &b) {
    //    return a.first < b.first || (a.first == b.first && a.second >= b.second);
    //});

    for (int i = 0; i < n; i++)
    {
        for (int j = shops[i].second; j > 0; j--)
        {
            n_drink++;
            money += shops[i].first;
            if (n_drink >= m)
            {
                cout << money << endl;
                return 0;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 1400
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;


public class Main {
	
	public static long gcd(long a, long b){
		return b == 0 ? a : gcd(b, a % b);
	}
	
	public static void main(String[] args) throws IOException {	
		try(final Scanner sc = new Scanner(System.in)){
			final int K = sc.nextInt();
			
			long answer = 0;
			
			for(int i = 1; i <= K; i++) {
				for(int j = 1; j <= K; j++) {
					for(int k = 1; k <= K; k++) {
						answer += gcd(i, gcd(j, k));
					}
				}
			}
			
			System.out.println(answer);
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

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

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

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}


Measured memory_bytes: 32768
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define Mod  1000000007
ll fast(ll n,ll a,ll M)
{
    if(n==0)
        return 1;
    else if(n==1)
        return a;
    else
    {
        ll res=fast(n/2,a,M);
        if(n%2==0)
        {
            return ((res%M)*(res%M))%M;
        }
        else
        {
            return (((((res%M)*a)%M)*res)%M);
        }
    }
}
int main()
{
   ll N;
   cin>>N;
   ll ok=0;
   while(N>0)
   {
       if(N%10==7)
       {
           ok=1;
           break;
       }
       N/=10;
   }
   if(ok==1)
    cout<<"Yes";
   else
    cout<<"No";
}


Measured memory_bytes: 3636
import itertools
import math

n = int(input())
xy = [0]*n

for i in range(n):
  xy[i] = input().split()

t = []
  
for i in range(n):
  t.append(i)

t = list(itertools.permutations(t))
ans = 0

for i in range(len(t)):
  for j in range(n-1):
    tmp = t[i][j]
    tmp2 = t[i][j+1]
    ans += math.sqrt(((int(xy[tmp][0]) - int(xy[tmp2][0]))**2) + ((int(xy[tmp][1]) - int(xy[tmp2][1]))**2))
    
print(ans/len(t))

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

void main_()
{
    ll N;
    cin >> N;
    unordered_map<string, ll> ss;
    ll ans = 0;
    for (ll i = 0; i < N; ++i) {
        string s;
        cin >> s;
        sort(begin(s), end(s));
        ans += ss[s]++;
    }

#if 0
    auto ans = accumulate(begin(ss), end(ss), 0LL,
        [](auto acc, auto&& i) {
            auto m = i.second;
            // acc + mC2
            return acc + m * (m - 1) / 2;
        });
#endif

    cout << ans << endl;
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


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

typedef long long ll;

#define REP(i, n) for(int i=0; i<(n); i++)
#define REPS(i, n) for(int i=0; i<=(n); i++)
#define FOR(i, a, b) for(int i=a; i<(b); i++)
#define FORS(i, a, b) for(int i=a; i<=(b); i++)
// for container x
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) *max_element(ALL(v))
#define MIN(v) *min_element(ALL(v))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;

int main(){
    int n;
    string s;
    cin >> n >> s;

    REP(i, s.size()){
        s[i] = (s[i]-'A'+n+1+'Z'-'A')%('Z'-'A'+1)+'A';
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

		if((a < b) && (b < c)){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}

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

int n;
string str;

int main(){
    cin >> n >> str;
    int ans = 0, cnt = 0;
    rep(i,str.size()){
        if(str[i] == '<') cnt++;
        else break;
    }
    ans = n-cnt;
    cnt = 0;
    for(int i = str.size()-1; i >= 0; i--){
        if(str[i] == '>') cnt++;
        else break;
    }
    ans = max(ans,n-cnt);
    cout << ans << endl;
}

Measured memory_bytes: 3276
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define FORD(x,y,z) for(int x=y;x>=z;x--)
#define MSET(x,y) memset(x,y,sizeof(x))
#define FOR(x,y) for(__typeof(y.begin()) x=y.begin();x!=y.end();x++)
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define SZ size()
#define M 205
void RI(){}
template<typename... T>
void RI( int& head, T&... tail ) {
    scanf("%d",&head);
    RI(tail...);
}
using namespace std;
typedef long long LL;
int n,m;
double cur[M], dp[M];
int main()
{
	int x,y,cnt;
	
	RI(n,m);
	dp[0] = 0;
	REP(i,1,m) dp[i] = -1e100;
	REP(i,1,n)
	{
		RI(cnt);
		int sum=0;

		cur[0] = 0;
		while(cnt--)
		{
			RI(x,y);
			REP(j, sum+1, min(m ,sum+x*y))
				cur[j] = cur[j-1] + 1.0/x;
			sum += x*y;
		}
		sum = min(sum, m);

		FORD(j,m,1) REP(k,1, min(j,sum) ) if(dp[j-k]>=0) dp[j] = max(dp[j], dp[j-k]+cur[k]);
	}

	printf("%.10f\n", dp[m]);
	return 0;
}

Measured memory_bytes: 1208
a,b,c,d=input().split()
a=int(a)
b=int(b)
c=int(c)
d=int(d)
if abs(a-c)<=d:
  print("Yes")
elif abs(a-b)<=d and abs(b-c)<=d:
    print("Yes")
else:
  print("No")

Measured memory_bytes: 9096
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
	int n, m, k; cin >> n >> m >> k;
	int pre_a[n + 1] = {};
	for (int i = 0; i < n; i++) {
		int x; cin >> x;
		pre_a[i + 1] = pre_a[i] + x;
	}
	int pre_b[m + 1] = {};
	for (int i = 0; i < m; i++) {
		int x; cin >> x;
		pre_b[i + 1] = pre_b[i] + x;
	}
	int ans = 0;
	for (int i = 0; i < n + 1; i++) {
		int ex = k - pre_a[i];
		if (ex >= 0) {
			int j = upper_bound(pre_b, pre_b + m + 1, ex) - pre_b;
			ans = max(ans, i + max(0LL, j - 1));
		}
	}
	cout << ans << "\n";
}

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

int main(){
    int a[10000];
    for(int i=0; i<10000; i++){
        cin >> a[i];
        if(a[i]==0)break;
        cout <<  "Case " << i+1 << ": " << a[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 3124
var
	N,i,A,K,T,S:Longint;
begin
	read(N);
	for i:=1 to N do begin
		read(A,K);
		while A mod K<>0 do begin
			T:=A div K+1;
			dec(A,(A mod K+T-1)div T*T);
		end;
		S:=S xor A div K;
	end;
	if S<>0 then writeln('Takahashi')else writeln('Aoki');
end.

Measured memory_bytes: 128
seq = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

K = int(input())
K -= 1
print(seq[K])


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define str string
#define all(x) (x).begin(),(x).end()
#define rep(x,c) for(int x=0;x<c;x++)
#define  pb(x) push_back(x)
int main(){
	vector<int>v;
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
    	int a;
    	cin>>a;
    	v.push_back(a);
	}
	bool flag=true;
	sort(all(v));
    for(int i=0;i<n-1;i++){
    	if(v[i]==v[i+1]) flag=false;
	}	
	if(flag==true) cout<<"YES";
	else cout<<"NO";
	return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main(){
    string s;
    cin >> s;
    int n = s.size();
    if(s[n-1]=='s')cout << s << "es";
    else cout << s << 's';
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  int h, n;
  cin >> h >> n;
  vi a(n), b(n);
  rep(i, n) cin >> a[i] >> b[i];
  vector<vi> dp(n + 1, vi(h + 1, 1e9));
  dp[0][0] = 0;
  rep(i, n) rep(j, h + 1) {
    dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
    dp[i + 1][min(h, j + a[i])] =
        min(dp[i + 1][min(h, j + a[i])], dp[i + 1][j] + b[i]);
  }
  cout << dp[n][h] << endl;
}

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

int main(){
    ll N;
    cin >> N;
    ll res;
    res = N*(N-1)/2;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a,b,c,d;
inline void cmp(ll x,ll y){
	if(x>y)printf("Left\n");
	else if(x<y)printf("Right\n");
	else printf("Balanced\n");
	return;
}
int main(){
	scanf("%lld%lld",&a,&b);
	scanf("%lld%lld",&c,&d);
    a-=c;
    b-=d;
	cmp(a+b,0);
	return 0;
}

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

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

    map<string,int> mp;
    for(int i = 0; i < n; i++){
        string s;
        cin >> s;
        mp[s]++;
    }

    int maxv = 0;
    for(auto i : mp) maxv = max(maxv,i.second);

    for(auto i : mp){
        if(i.second == maxv){
            cout << i.first << endl;
        }
    }

}


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

int main() {
    int N;
    cin >> N;
    double sum = 0;
    for (int i = 0; i < N; ++i) {
        int a; cin >> a;
        sum += 1.0 / a;
    }
    
    double ans = 1 / sum;
    printf("%.10f\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// ----------------------R00TDADA------------------------------
#define rep(i, a, b) for (__typeof((b)) i = (a); i < (b); i++)
#define nrep(i, a, b) for (__typeof((b)) i = (a); i > (b); i--)
#define all(a) (a).begin(), (a).end()
#define ff first
#define ss second
#define ppi pair<int, int>
#define pppi pair<ppi, int>
#define vi vector<int>
#define vii vector<ppi>
#define viii vector<pppi>
#define vs vector<string>
#define pb push_back
#define bitcount __builtin_popcount //count no's of ones in a set bit
#define prq priority_queue
#define mp make_pair
#define mem(x, val) memset((x), (val), sizeof(x));
#define sz(x) (int)x.size()
#define M_PI 3.14159265358979323846
#define rootdada                      \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0);
#define test  \
    int t;    \
    cin >> t; \
    while (t--)
#define int long long
#define M 1000000007
signed main()
{
    rootdada;
    // #ifndef ONLINE_JUDGE
    // // for getting input from input.txt
    // freopen("input.txt", "r", stdin);
    // // for writing output to output.txt
    // freopen("output.txt", "w", stdout);
    // #endif
    int n;
    cin >> n;
    string s;
    cin >> s;
    int red = 0, green = 0, blue = 0;
    rep(i, 0, n)
    {
        if (s[i] == 'R')
            red++;
        else if (s[i] == 'G')
            green++;
        else
            blue++;
    }
    int possible = red * green * blue;
    rep(i, 0, n)
    {
        rep(j, i + 1, n)
        {
            if (s[i] == s[j])
                continue;
            int k = 2 * j - i;
            if (k >= n)
                continue;
            if (s[k] == s[i] || s[k] == s[j])
                continue;
            possible--;
        }
    }
    cout << possible << endl;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
 
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define allsort(v) sort(v.begin(),v.end())
const ll mod = 1e9 + 7;
const int INF = 1e9;
 
int main() {
	cin.sync_with_stdio(false);
	int a, b;
	cin >> a >> b;
	if ((a + b) % 3 == 0 || a % 3 == 0 || b % 3 == 0) cout << "Possible" << endl;
	else cout << "Impossible" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n, qt, t, ct = 0;
    string tn;
    queue<tuple<string, int>> q;
    cin >> n >> qt;
    for (int i = 0; i < n ; i++) {
        cin >> tn >> t;
        q.push(make_tuple(tn, t));
    }

    while(!q.empty()){
        tn = get<0>(q.front());
        t = get<1>(q.front());
        q.pop();
        if (t <= qt){
            cout << tn << " " << ct + t << endl;
            ct += t;
        } else {
            q.push(make_tuple(tn, t - qt));
            ct += qt;
        }
    }
}


Measured memory_bytes: 6236
#include<algorithm>
#include <iostream>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<string>
using namespace std;
int main(){
   
    int n,k,x,y;
    cin>>n>>k>>x>>y;
    
    int ans=0;
    
    for(int i=1;i<k+1 && i<n+1;i++){
        ans+=x;
    }
    if(n>k){
        for(int j=k+1;j<n+1;j++){
            ans+=y;
    }
    }
    
    cout<<ans<<endl;
    
    return 0;
   
}






Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;
const int MOD = 1e9+7;
using ll = long long;
using vi = vector<int>;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(x) x.begin(), x.end()
int main() {
  int a;
  cin >> a;
  int b[a],lcm,sum=0;
  rep(i,a){
    cin >> b[i];
    if(i==0) lcm = b[i];
    lcm = lcm*b[i]/__gcd(lcm,b[i]);
  }
  rep(i,a){
    sum += lcm/b[i];
  }
  double ans1 = lcm,ans2=sum;
  cout << ans1/ans2;
}


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

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		bool[] good = new bool[N];
		for(int i=0;i<N;i++) good[i] = true;
		for(int i=0;i<M;i++){
			if(H[A[i]] == H[B[i]]){
				good[A[i]] = false;
				good[B[i]] = false;
			} else if(H[A[i]] < H[B[i]]){
				good[A[i]] = false;
			} else if(H[A[i]] > H[B[i]]){
				good[B[i]] = false;
			}
		}
		
		int cnt = 0;
		for(int i=0;i<N;i++) if(good[i]) cnt++;
		Console.WriteLine(cnt);
		
		
	}
	int N,M;
	int[] H;
	int[] A,B;
	public Sol(){
		var d = ria();
		N = d[0]; M = d[1];
		H = ria();
		A = new int[M];
		B = new int[M];
		for(int i=0;i<M;i++){
			d = ria();
			A[i] = d[0] - 1;
			B[i] = d[1] - 1;
		}
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 48652
#include<stdio.h>

int main(void){
        int w, h, x, y, r;

        scanf("%d %d %d %d %d", &w, &h, &x, &y, &r);

        if(x - r >= 0 && x + r <= w && y - r >= 0 && y + r <= h){
                printf("Yes\n");
        }else{
                printf("No\n");
        }
        return 0;
}

Measured memory_bytes: 580
#include<iostream>
#include<vector>
#include<cmath>
#include<cstdio>
#define EPS (1e-10)

using namespace std;

class Point
{
  public:
  double x,y;

  Point(double x = -1,double y = -1): x(x),y(y){}

  Point operator + (Point p ){return Point(x+p.x,y+p.y);}
  Point operator - (Point p){return Point(x-p.x,y-p.y);}
  Point operator * (double a){return Point(a*x,a*y);}

  bool operator < (const Point& p) const
  {
    return x != p.x?x<p.x:y<p.y;
  }

  bool operator == (const Point& p)const
  {
    return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS;
  }
};

struct Segment
{
  Point p1,p2;
  Segment(Point p1 = Point(-1,-1),Point p2 = Point(-1,-1)):p1(p1),p2(p2){}
};

double dot(Point a,Point b)
{
  return a.x*b.x + a.y*b.y;
}
double cross(Point a,Point b)
{
  return a.x*b.y - a.y*b.x;
}

double norm(Point a)
{
  return a.x*a.x+a.y*a.y;
}

static const int COUNTER_CLOCKWISE = 1;
static const int CLOCKWISE = -1;
static const int ONLINE_BACK = 2;
static const int ONLINE_FRONT = -2;
static const int ON_SEGMENT = 0;



Point getCrossPoint(Point a1,Point a2,Point b1,Point b2)
{
  Point base = b2 - b1;
  double d1 = abs(cross(base,a1-b1));
  double d2 = abs(cross(base,a2-b1));
  double t = d1/(d1+d2);
  return a1+(a2-a1)*t;
}


int ccw(Point p0,Point p1,Point p2)
{
  Point a = p1-p0;
  Point b = p2-p0;
  if(cross(a,b) > 0)return COUNTER_CLOCKWISE;
  if(cross(a,b) < 0)return CLOCKWISE;
  if(dot(a,b) < 0)return ONLINE_BACK;
  if(norm(a) < norm(b))return ONLINE_FRONT;
  return ON_SEGMENT;
}



bool isIntersect(Point p1,Point p2,Point p3,Point p4)
{
  return (ccw(p1,p2,p3) * ccw(p1,p2,p4) <= 0 &&
          ccw(p3,p4,p1) * ccw(p3,p4,p2) <= 0 );
}

bool isIntersect(Segment s1,Segment s2)
{
return isIntersect(s1.p1,s1.p2,s2.p1,s2.p2);
}


double getArea(vector<Point>& vec)
{
  double sum = 0;
  for(int i=0;i<3;i++)
    sum += cross(vec[i],vec[(i+1)%3]);
  return fabs(sum)/2.0;
}



int main()
{

 int x1,y1,x2,y2;
  while(cin >> x1 >> y1 >> x2 >> y2,(x1|y1|x2|y2))
    {
      Point a(x1,y1);
      Point b(x2,y2);
      cin >> x1 >> y1 >> x2 >> y2;
      Point c(x1,y1);
      Point d(x2,y2);
      cin >> x1 >> y1 >> x2 >> y2;
      Point e(x1,y1);
      Point f(x2,y2);
      Segment s1(a,b),s2(c,d),s3(e,f);


      if(!isIntersect(s1,s2) || !isIntersect(s2,s3) || !isIntersect(s3,s1))
	{
	  cout << "kyo" << endl;
	  continue;
	}
      Point c1,c2,c3;
      c1 = getCrossPoint(s1.p1,s1.p2,s2.p1,s2.p2);
      c2 = getCrossPoint(s2.p1,s2.p2,s3.p1,s3.p2);
      c3 = getCrossPoint(s3.p1,s3.p2,s1.p1,s1.p2);
      vector<Point> vec;
      vec.push_back(c1),vec.push_back(c2),vec.push_back(c3);
      double area = getArea(vec);

      if(area >= 1900000)
	cout << "dai-kichi" << endl;
      else if(area >= 1000000)
	cout << "chu-kichi" << endl;
      else if(area >= 100000)
	cout << "kichi" << endl;
      else if(area > 0)
	cout << "syo-kichi" << endl;
      else 
	cout << "kyo" << endl;
    }
  return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 >& p) {
  os << "{" <<p.first << ", " << p.second << "}";
  return os;
}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/

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

    ll N;
    cin >> N;
    vector<ll> v(N+1,0);
    for(int j = 1; j <= N; j++){
        for(int k = j; k <= N; k+= j){
            v[k]++;
        }
    }
    ll ans = 0;
    for(ll i = 1; i <= N; i++){
        ans += i * v[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 81336
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int n = sc.nextInt();

		int[] array = new int[w];
		for(int i = 0; i < w; i++){
			array[i] = i + 1;
		}
		for(int i = 0; i < n; i++){
			String[] split = sc.next().split(",", 0);
			int a = Integer.valueOf(split[0]) - 1;
			int b = Integer.valueOf(split[1]) - 1;
			int tmp = array[a];
			array[a] = array[b];
			array[b] = tmp;
		}

		for(int i = 0; i < w; i++){
			System.out.println(array[i]);
		}

	}
}

Measured memory_bytes: 26204
#include "bits/stdc++.h"
using namespace std;
int main(){
    string s,t;
    while(true){
        cin >> s;
        if(s=="-") break;
        int n = s.length();
        int m,i,h;
        cin >> m;
        for(i=0;i<m;i++){
            cin >> h;
            t = s.substr(0,h);
            s.erase(0,h);
            s += t;
        }
        cout << s << endl;
    }
    return 0;
}


Measured memory_bytes: 3184
#include <bits/stdc++.h>
using namespace std;
# define MOD 1000000007
typedef long long ll;
int dp[2][1000001];
ll util(vector<int> adj[], int n, int u, int parent, int flag){
    if(dp[flag][u] != -1) return dp[flag][u]%MOD;
    int white = 1;
    for(int i=0;i<adj[u].size();i++){
        int v = adj[u][i];
        if(v != parent) white = (white*(util(adj, n, v, u, 0)%MOD))%MOD;
    }
    int res = white;
    if(flag == 0){
        int black = 1;
        for(int i=0;i<adj[u].size();i++){
            int v = adj[u][i];
            if(v != parent) black = (black*(util(adj, n, v, u, 1)%MOD))%MOD;
        }
        res = (res%MOD + black%MOD)%MOD;
    }
    dp[flag][u] = res;
    return res;
}
int main(){
	int n;
	cin>>n;
    vector<int> adj[n];
    for(int i=0;i<n-1;i++){
        int xi, yi;
        cin>>xi>>yi;
        adj[xi-1].push_back(yi-1);
        adj[yi-1].push_back(xi-1);
    }
    memset(dp, -1, sizeof(dp));
    cout<<util(adj, n, 0, -1, 0);
	return 0;
}

Measured memory_bytes: 21888
// ABC 067 D
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>

#define v_exists(elem, v) find(v.begin(),v.end(),elem)!=v.end()
#define s_exists(elem, s) s.find(elem)!=s.end()

using namespace std;
const int MOD = 1000000007;

long gcd(long a, long b) {
    return b == 0 ? a : gcd(b, a % b);
}

long lcm( long m, long n ){
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;

    return ((m / gcd(m, n)) * n);
}


long kake(long x, long y){
    return x * y % MOD;
}

long fact_mod(long x){
    long ans = x;
    x-=1;
    while(x>1){
        ans = ans * x % MOD;
        x-=1;
    }
    return ans;
}

std::map<long, std::vector<long>> adj;
std::set<long> visited;
long l1 [1000005] = {0};
long l2 [1000005] = {0};

void dfs1(long s, long d){
    l1[s] = d;
    visited.insert(s);

    for(int i=0; i<adj[s].size(); i++){
        if(s_exists(adj[s][i], visited)==false){
            dfs1(adj[s][i], d+1);
        }
    }

}

void dfs2(long s, long d){
    l2[s] = d;
    visited.insert(s);

    for(int i=0; i<adj[s].size(); i++){
        if(s_exists(adj[s][i], visited)==false){
            dfs2(adj[s][i], d+1);
        }
    }
}

int main(){


    long N;
    scanf("%ld",&N);

    for(int i=0; i<N;i++){
        std::vector<long> v;
        adj[i]=v;
    }


    for(int i=0; i<N-1;i++){
        long a,b;
        scanf("%ld %ld",&a,&b);
        adj[a-1].push_back(b-1);
        adj[b-1].push_back(a-1);
    }

    dfs1(0, 0);
    visited.clear();
    dfs2(N-1, 0);

    long score = 0;

    for(int i=0; i<N; i++){
        if(l1[i] <= l2[i]){
            score+=1;
        } else{
            score-=1;
        }
    }

    if(score>0){
        cout << "Fennec" << endl;
    } else{
        cout << "Snuke" << endl;
    }

}


Measured memory_bytes: 30080
import numpy as np
import itertools
from collections import deque

N, M = map(int, input().split())
root = [list(map(int, input().split())) for _ in range(M)]

class Room:
  def __init__(self, num):
    self.num = num
    self.roots = []
    self.kyori = -1
    self.near = 0
    
  def add_root(self, to):
    self.roots.append(to)
  def set_kyori(self, num, kyori):
    self.kyori = kyori
    self.near = num

r_list = sorted(np.unique(np.array(list(itertools.chain.from_iterable(root)))))
rooms = {i:Room(i) for i in r_list}

for r in root:
  a, b = rooms[r[0]], rooms[r[1]]
  a.add_root(b)
  b.add_root(a)

kyori = 0
near = 0
rooms[1].set_kyori(near, kyori)
rooms[1].near = near
q = deque()
q.append(rooms[1])
while len(q) > 0:
  node = q.popleft()
  kyori+=1
  for r in node.roots:
    if r.kyori != -1:
      continue
    r.set_kyori(node.num, kyori)
    q.append(r)
  
rooms[1].set_kyori(0, 0)
for r in rooms.values():
  if r.kyori == -1:
    print('No')
    break
else:
  print('Yes')
  for r in list(rooms.values())[1:]:
    print(r.near) 
  
  

Measured memory_bytes: 103548
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
#N, K = map(int, input().split())
# 文字列の入力
N = int(input())
#開業されたN個要素を受け付ける
A = list(map(int, input().split()))
B = list(map(int, input().split()))
ans = 0
for i in range(N):
    if A[i] <= B[i]:
        ans = ans+A[i]
        B[i] = B[i] - A[i]
        A[i] = 0
        if A[i+1] <= B[i]:
            ans = ans+A[i+1]
            B[i] = B[i] - A[i+1]
            A[i+1] = 0
        else:
            ans = ans+B[i]
            A[i+1] = A[i+1] - B[i]
            B[i] = 0
    else:
        ans = ans+B[i]
        A[i] = A[i] - B[i]
        B[i] = 0
    #print(A)
    #print(B)
    #print(ans)
    #print()

print(ans)


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1e6 + 5;





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

    // If n=1, then game is easily predetermined (odd -> player 1 wins)
    // If n>1, then player 1 can win by forcing all odd values to be even.
    //         If there are no odd values initiallly, then player 1 loses.

    int n;
    cin>>n;
    bool win = false;
    for (int i=0; i<n; i++) {
	int x;
	cin>>x;
	if (x%2==1) win=true;
    }

    cout<<(win ? "first\n" : "second\n");
    
    
    return 0;
}


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

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

const long long MOD = 1000000007;

int main(){
  int n;
  cin >> n;
  vector<int> a(n+1),b(n);
  rep(i,n+1) cin >> a.at(i);
  rep(i,n) cin >> b.at(i);
  ll ans=0;
  for(int i=n-1;i>=0;i--){
    if(a.at(i+1)>b.at(i)){
      ans+=(ll)b.at(i);
    }
    else{
      b.at(i) -= a.at(i+1);
      ans+=(ll)a.at(i+1);
      if(b.at(i)>a.at(i)){
        ans+=(ll)a.at(i);
        a.at(i)=0;
      }
      else{
        ans+=(ll)b.at(i);
        a.at(i)-=b.at(i);
      }
    }
  }
  cout << ans << endl;
      
}


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

int main() {
  int n, k;
  cin >> n >> k;
  int a[n];
  for(int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for(int i = k; i < n; i++) {
    if(a[i] > a[i-k]) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 4372