akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#define endl "\n"
#define ll long long int
using namespace std;

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

    ll i;
    vector <ll> v(n);
    for(i = 0; i < n; i ++)
    	cin >> v[i];

    ll preSum = 0;
    ll ans1 = 0;
    ll ans2 = 0;
    for(i = 0; i < n; i ++)
    {
    	preSum = preSum + v[i];
    	if(i % 2 == 1)
    	{
    		if(preSum >= 0)
    		{
    			ans1 = ans1 + preSum + 1;
    			preSum = -1;
    		}
    	}
    	else
    	{
    		if(preSum <= 0)
    		{
    			ans1 = ans1 + abs(preSum) + 1;
    			preSum = 1;
    		}
    	}
    }

    preSum = 0;
    for(i = 0; i < n; i ++)
    {
    	preSum = preSum + v[i];
    	if(i % 2 == 1)
    	{
    		if(preSum <= 0)
    		{
    			ans2 = ans2 + abs(preSum) + 1;
    			preSum = 1;
    		}
    	}
    	else
    	{
    		if(preSum >= 0)
    		{
    			ans2 = ans2 + abs(preSum) + 1;
    			preSum = -1;
    		}
    	}
    }
    ll ans = min(ans1, ans2);
    cout << ans << endl;
}

Measured memory_bytes: 1024
def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    ans = 0
    for i in range(N):
        b = B[i]
        if A[i] >= b:
            ans += b
        else:
            b -= A[i]
            ans += (A[i] + min(b, A[i+1]))
            A[i+1] = max(A[i+1] - b, 0)

    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 19156
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)















int main() {
	ll n;
	cin >> n;
	bool ok = true;
	REP(i, n) {
		ll a;
		cin >> a;
		if(a % 2 == 0 && a % 3 != 0 && a % 5 != 0) ok = false;
	}
	if(ok) cout << "APPROVED" << endl;
	else cout << "DENIED" << endl;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
ipy = []

for i in range(m):
    p, y = map(int, input().split())
    ipy.append([i, p, y])
    
ipy = sorted(ipy, key=lambda x: x[2])

count = {}
order = {}

for i, p, y in ipy:
    if not p in count:
        count[p] = 1
    else:
        count[p] += 1
    order[i, p] = count[p]
    
ipy = sorted(ipy, key=lambda x: x[0])
for i, p, y in ipy:
    print('{:06}{:06}'.format(p, order[i, p]))

Measured memory_bytes: 44208
#include <stdio.h>
#include <stdlib.h>
#define int long long
#define p (int)(1e9 + 7)

int MOD(int a){
	a %= p;
	return a >= 0 ? a : a + p;
}

int power(int a, int N){
	if(N == 0){
		return 1;
	}
	else if(N % 2 == 0){
		return power(MOD(a * a), N / 2);
	}
	else{
		return MOD(a * power(a, N - 1));
	}
}

signed main(){
	int N, M, i, j, A, B, Ac, ans = 1;
	scanf("%lld%lld", &N, &M);
	int *a = (int *)malloc(sizeof(int) * M);
	int *b = (int *)malloc(sizeof(int) * M);
	for(i = 0; i < M; i++){
		scanf("%lld%lld", &a[i], &b[i]);
		a[i]--;
		b[i]--;
	}
//	printf("test1\n");

	int *E = (int *)malloc(sizeof(int) * (1 << N));
	for(i = 0; i < (1 << N); i++){
		E[i] = 0;
		for(j = 0; j < M; j++){
			E[i] += ((((i | (1 << a[j])) == i) ? 1 : 0) ^ (((i | (1 << b[j])) == i) ? 1 : 0));
		}
//		printf("E[%lld] = %lld\n", i, E[i]);
	}
//	printf("test2\n");

	int *pow2inv = (int *)malloc(sizeof(int) * (M + 1));
	pow2inv[0] = 1;
	for(i = 1; i <= M; i++){
		pow2inv[i] = MOD(pow2inv[i - 1] * ((p + 1) / 2));
	}
//	printf("test3\n");

	int *P = (int *)malloc(sizeof(int) * (1 << N));
	P[1] = 1;
	for(A = 0; A < (1 << N); A++){
		if((A & 1) != 0){
//			printf("A = %lld\n", A);
			P[A] = 1;
			for(i = ((A - 1) & A); i != A; i = ((i - 1) & A)){
				if((i | 1) == i){
//					printf("i = %lld\n", i);
					P[A] = MOD(P[A] - P[i] * pow2inv[(E[i] + E[A - i] - E[A]) / 2]);
				}
			}
		}
		else{
			P[A] = 0;
		}
//		printf("P[%lld] = %lld\n", A, P[A]);
	}
//	printf("test4\n");

	int *Q = (int *)malloc(sizeof(int) * (1 << N));
	Q[2] = 1;
	for(B = 0; B < (1 << N); B++){
		if((B & 2) != 0){
			Q[B] = 1;
			for(i = ((B - 1) & B); i != B; i = ((i - 1) & B)){
				if((i | 2) == i){
					Q[B] = MOD(Q[B] - Q[i] * pow2inv[(E[i] + E[B - i] - E[B]) / 2]);
				}
			}
		}
	}
//	printf("test5\n");

	for(A = 0; A < (1 << N); A++){
		Ac = (1 << N) - 1 - A;
		B = Ac;
		do{
			if((A & 1) != 0 && (B & 2) != 0 && E[A] + E[B] - E[A + B] == 0){
				ans = MOD(ans - MOD(P[A] * Q[B]) * pow2inv[E[A] + E[B]]);
			}
			B = ((B - 1) & Ac);
		}while(B != Ac);
	}
	printf("%lld\n", MOD(ans * power(2, M)));
	return 0;
}

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



int main() {
string S;
cin >> S;
ll N;
cin >> N;
ll lo = S.size();

for(int i = 0; i < min(lo, N); i++){
if(S[i] >= '2') {cout << S[i] << endl; return 0;}

}
cout << '1' << endl;
return 0;

}

Measured memory_bytes: 256
using System;

namespace ITP1_1_D
{
    class Program
    {
        static void Main(string[] args)
        {
            int S = int.Parse(Console.ReadLine());
            int s = S % 60;
            int h = S / 3600;
            int m = (S - 3600 * h) / 60;
            Console.WriteLine("{0}:{1}:{2}", h, m, s);
        }
    }
}

Measured memory_bytes: 9192
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>

using namespace std;

int ctoi(const char c) {
    switch (c) {
        case 'A': return 10; break;
        case 'B': return 11; break;
        case 'C': return 12; break;
        case 'D': return 13; break;
        case 'E': return 14; break;
        case 'F': return 15; break;
    }
}

int main() {
    char X, Y;

    cin >> X >> Y;

    if (ctoi(X) > ctoi(Y)) {
        cout << ">" << endl;
    } else if (ctoi(X) < ctoi(Y)) {
        cout << "<" << endl;
    } else if (ctoi(X) == ctoi(Y)) {
        cout << "=" << endl;
    }

    return 0;
}


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>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
*/

int table[101][101], time_table[101][2];
int common_time = 1, n;

void dfs(int node){
    if(time_table[node][0] == 0) time_table[node][0] = common_time++;
    else return;
    for(int i = 1; i <= n; i++){
        if(table[node][i] == 1) dfs(i);
    }
    time_table[node][1] = common_time++;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    int id, k, v;
    rep(i,n+1){
        rep(j,n+1) table[i][j] = 0;
        time_table[i][0] = 0;
        time_table[i][1] = 0;
    }
    rep(i,n){
        cin >> id >> k;
        rep(j,k){
            cin >> v;
            table[id][v] = 1;
        }
    }
    for(int i = 1; i <= n; i++){
        dfs(i);
    }
    for(int i = 1; i <= n; i++){
        cout << i << " " << time_table[i][0] << " " << time_table[i][1] << endl;
    }
    return 0;
}


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

using namespace std;

using ll = long long;

struct _IN {
    _IN() {
        ios::sync_with_stdio(0);
        cin.tie(0);
    }
    template <typename T>
    operator T() const {
        T x;
        cin >> x;
        return x;
    }
    template <typename Container>
    void operator()(Container& c) {
        for (auto& x : c)
            cin >> x;
    }
} IN;

int main() {
    int H1 = IN, M1 = IN, H2 = IN, M2 = IN, K = IN;
    int diff = H2 * 60 + M2 - H1 * 60 - M1;
    cout << diff - K << endl;
}


Measured memory_bytes: 3652
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i, n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i, n) for(ll i=(ll)(n-1);i>=0;i--)
#define FOR(i, a, b) for(ll i=(ll)(a); i<=(ll)(b); i++)
#define RFOR(i, a, b) for(ll i=(ll)(a);i>=(ll)(b); i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

signed main()
{
	int N;
	cin >> N;
	if(N%1000 == 0){
		cout << 0 << endl;
	}else{
		cout << (1000 - N%1000) << endl;
	}
}


Measured memory_bytes: 3632
#include<iostream>
#include <math.h>
using namespace std;
int main()
{
	int N, K;
	int x = 0;

	cin >> N >> K;
	while (true) {
		
		int a = pow(K, x);
		if (N / a == 0)
			break;

		x++;

	}
	cout << x;
}

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


void solve(long long A, long long B){
    cout << max(A+B, max(A-B, A*B)) << endl;
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a

ans = gcd(a[0], a[1])
for i in range(2, n):
    ans = gcd(ans, a[i])
print(ans)

Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//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; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    ll H,W; cin >> H >> W;
    ll maxv, minv, a, b, c;

    ll ans = 1LL<<60;

    for(ll w=1; w<=W-2; w++){
        a = (W-w)/2;
        b = W-w-a;
        maxv = max(w*H, max(a*H, b*H));
        minv = min(w*H, min(a*H, b*H));
        ans = min(ans, maxv-minv);
    }

    for(ll h=1; h<=H-1; h++){
        a = H-h;
        b = W/2;
        c = W-b;
        maxv = max(h*W, max(a*b, a*c));
        minv = min(h*W, min(a*b, a*c));
        ans = min(ans, maxv-minv);
    }

    for(ll h=1; h<=H-2; h++){
        a = (H-h)/2;
        b = H-h-a;
        maxv = max(h*W, max(a*W, b*W));
        minv = min(h*W, min(a*W, b*W));
        ans = min(ans, maxv-minv);
    }

    for(ll w=1; w<=W-1; w++){
        a = W-w;
        b = H/2;
        c = H-b;
        maxv = max(w*H, max(a*b, a*c));
        minv = min(w*H, min(a*b, a*c));
        ans = min(ans, maxv-minv);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
lst = list(range(0, n + 1))
reversed_lst = list(reversed(lst))
mod = 10 ** 9 + 7

min_lst = sum(lst[:k])
max_lst = sum(reversed_lst[:k])
ans = max_lst - min_lst + 1

while k <= n:
    min_lst += lst[k]
    max_lst += reversed_lst[k]
    ans += max_lst - min_lst + 1
    k += 1
    
print(ans % mod)

Measured memory_bytes: 19760
package main

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

/*
const (
	initialBufSize = 10000
	maxBufSize     = 1000000
)
*/

func dvector(x1, y1, x2, y2 int) (int, int) {
	return -(y2 - y1), x2 - x1
}

func main() {
	var wtr = bufio.NewWriter(os.Stdout)
	var N int
	var S string
	fmt.Scan(&N)
	fmt.Scan(&S)
	var max, sum int
	for _, v := range S {
		if v == 'I' {
			sum++
			if max < sum {
				max = sum
			}
		} else {
			sum--
		}

	}
	fmt.Fprintln(wtr, max)
	_ = wtr.Flush()
}


Measured memory_bytes: 1844
using System;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] a = Console.ReadLine().Split(' ').Select(gg => int.Parse(gg)).ToArray();
            Array.Sort(a);
            Array.Reverse(a);

            int ans = 0;

            for(int i = 0; i < N; i++)
            {
                if(i % 2 == 0)
                {
                    ans += a[i];
                }
                else
                {
                    ans -= a[i];
                }
            }
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 28164
#!/usr/bin/env python3
import sys
import copy


def solve(N: int):
    divs = make_divisors(N)
    arr = []
    for div in divs:
        if div == 1:
            continue
        n = copy.copy(N)
        while(n % div == 0):
            n //= div
        if n % div == 1:
            arr.append(div)
    cnt = len(set(arr + make_divisors(N - 1))) - 1
    print(cnt)
    return


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3728
#include <iostream>
using namespace std;
int main(){
int a,b,c;
  cin>>a>>b;

if(a>=1 && b>=1){
    if(a<=9 && b<=9){


  c=a*b;
      cout<<c<<endl;}
    else{
  cout<<"-1"<<endl;

    }
}

  return 0;
}


Measured memory_bytes: 3584
#設定
import sys
input = sys.stdin.buffer.readline

from collections import defaultdict

def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	#受け取り、処理
	N, M = getlist()
	X = getlist()
	D = defaultdict(int)
	for i in X:
		D[i] += 1
	L = [[] for i in range(M)]
	for i in D:
		L[i % M].append(D[i])
	#計算
	ans = 0
	for i in range(1, M):
		if i != M - i:
			a1 = 0
			a2 = 0
			for j in L[i]:
				a1 += j
				a2 += int(j // 2) * 2
			b1 = 0
			b2 = 0
			for j in L[M - i]:
				b1 += j
				b2 += int(j // 2) * 2
			if a1 - a2 > b1:
				ans += b1 + a2 // 2
			elif b1 - b2 > a1:
				ans += a1 + b2 // 2
			else:
				ans += (a1 + b1) // 2
	
	ans = ans // 2
	#細かい処理、偶奇
	if M % 2 == 0:
		ans += sum(L[M // 2]) // 2
	ans += sum(L[0]) // 2
	#答え
	print(ans)

if __name__ == '__main__':
	main()

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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  double n;
  cin >> n;
  ll t = n/2;
  t = n-t;
  double ans = t/n;
  cout << ans<< endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
const int dx[4]={-1,1,0,0},dy[4]={0,0,-1,1};
typedef long long ll;
const int N=3005;
const ll inf=1ll<<60;
int a,b,c,d,e,f;
int x[N],y[N];
using namespace std;

/*struct node
{
	int t,next;
}adj[N<<1];
void add(int s,int t)
{
	adj[++now]=(node){t,head[s]};
	head[s]=now;
}*/
inline int read()
{
	char c;int x;
	while (c=getchar(),c<'0' || c>'9');x=c^'0';
	while (c=getchar(),c>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
	return x;
}
void write(int x)
{
	if (x==0) return;
	write(x/10);
	putchar((x%10)+'0');
}
void upd(int& x,int y){if (x==-1) x=y;else x=max(x,y);}
int main()
{
	#ifdef Kay
		freopen ("code.in","r",stdin);
		freopen ("code.out","w",stdout);
	#endif
	cin>>a>>b>>c>>d>>e>>f;
	a*=100,b*=100;
	int ans1=0,ans2=a,i,j;
	x[0]=y[0]=1;
	for (i=1;i<=3000;i++)
	{
		if (i>=a) x[i]|=x[i-a];
		if (i>=b) x[i]|=x[i-b];
		if (i>=c) y[i]|=y[i-c];
		if (i>=d) y[i]|=y[i-d];
	}
	for (i=1;i<=3000;i++)
	if (x[i])
	for (j=1;j<=3000;j++)
	if (y[j])
	{
		if (j>(i/100)*e) continue;
		if (i+j<=f)
		{
			if (ans1==0 || (ans1*i<ans2*j)) ans1=j,ans2=i;
		}
	}
	printf ("%d %d",ans1+ans2,ans1);
	return 0;
}


Measured memory_bytes: 256
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        h: [usize; n],
    }
    let mut ans = 1;
    let mut acc = h[0];
    for i in 1..n {
        if h[i] >= acc {
            ans += 1;
            acc = max(acc, h[i]);
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
$stdin.gets.to_i.times do
  c,a,n = $stdin.gets.chomp.split(" ").map(&:to_i)
  numTeam = 0
  while n >= 1 && c >= 1 && a >= 1
    c -= 1
    a -= 1
    n -= 1
    numTeam += 1
  end
  while c >= 2 && a >= 1
    c -= 2
    a -= 1
    numTeam += 1
  end
  while c >= 3
    c -= 3
    numTeam += 1
  end
  p numTeam
end

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

int main(){
    int a,b,c,k,s;
    cin >> a >> b >> c >> k;
    s = min(k,a);
    k-=s;
    if(!k){
        cout << s;
        return 0;
    }
    int m = min(k,b);
    if(m==k){
        cout << s;
        return 0;
    }
    k -= m;
    s -= k;
    cout << s;
    return 0;
}

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

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

    int n;
    cin >> n;

    int idx = -1;
    for(int i = 1; i <= n; i++){
        int f = (i + 1) * i / 2;
        if(f >= n){
            idx = i;
            break;
        } 
    }


    vector<int> Ans;
    for(int i = idx; i >= 1; i--){
        int f = (i - 1) * i / 2;
        if(f > n);
        else if (n >= i){
            Ans.push_back(i);
            n -= i;
        }
    }

    sort(Ans.begin(), Ans.end());

    for(auto x: Ans){
        cout << x << endl;
    }


    return 0;
}

Measured memory_bytes: 3664
#include <stdio.h>

int main(void) {
  int i;
  int r, D, x2000;
  int num;

  scanf("%d %d %d", &r, &D, &x2000);

  num=x2000;
  for(i=1; i<=10; i++){
    num=r*num-D;
    printf("%d\n", num);
  }

  return 0;
}


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

int main(){
    int n,x;
    cin >> n >> x;
    vector<int> a(n);
    
    rep(i,n)cin >> a[i];

    sort(a.begin(),a.end());

    vector<int> b(n);

    rep(i,n){
        b[i]=min(x,a[i]);
        x-=b[i];

    }
    b.back()+=x;

    int ans = 0;

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

    cout << ans << endl;

}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((ll)(x).size())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define pb push_back
#define mp make_pair
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
using namespace std;

ll solve(ll a){
  ll ans = 0;
  if(a%2!=0){
    if(((a+1)/2)%2==0){
      ans = 0;
    }
    else{
      ans = 1;
    }
  }
  else{
    if((a/2)%2==0){
      ans = a;
    }
    else{
      ans = 1^a; 
    }
  }
  return ans;
}

int main(){
  ll A, B;
  cin >> A >> B;

  cout << (solve(A-1)^solve(B)) << endl;



  return 0;
}


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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define FOR(i, s, e) for (ll(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (ll(i) = (s); (i) > (e); (i)--)
#define debug(x) cout << #x << ": " << x << endl
#define mp make_pair
#define pb push_back
const ll MOD = 1000000007;
const int INF = 1e9;
const ll LINF = 1e16;
const double PI = acos(-1.0);
int dx[8] = {0, 0, 1, -1, 1, 1, -1, -1};
int dy[8] = {1, -1, 0, 0, 1, -1, 1, -1};

/* -----  2017/06/10  Problem: ABC 064 C / Link: http://abc064.contest.atcoder.jp/tasks/abc064_c  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

ll N;
int c[10];

ll ans = 0LL;

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

  cin >> N;
  int a[200];
  FOR(i, 0, N) {
	  cin >> a[i];
  }
  FOR(i, 0, N) {

	  if (a[i] < 400)c[0]++;
	  else if (a[i] < 800)c[1]++;
	  else if (a[i] < 1200)c[2]++;
	  else if (a[i] < 1600)c[3]++;
	  else if (a[i] < 2000)c[4]++;
	  else if (a[i] < 2400)c[5]++;
	  else if (a[i] < 2800)c[6]++;
	  else if (a[i] < 3200)c[7]++;
	  else c[8]++;
  }

  int x = c[8];
  
  FOR(i, 0, 8) {
	  if (c[i] > 0)ans++;
  }
  ans += c[8];
  int ans2 = 0;
  FOR(i, 0, 8) {
	  if (c[i] > 0)ans2++;
  }
  if (ans2 == 0 && x != 0)ans2 = 1;
  cout << ans2<<" "<<ans << endl;

  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define ms(a,b) memset(a,b,sizeof(a))
#define msn(a,n,b) for(int i=0;i<=n;i++)a[i]=b
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define fi first
#define se second
using namespace std;
mt19937 rng_32(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef double db;
const int mod=1e9+7;
const int seed=233;
const double PI=acos(-1.0);
const double eps=1e-7;
const int inf=0x3f3f3f3f;
const int max_n=100005;
ll ceil(ll x,ll y){if(x==0)return 0;if(y<0)x=-x,y=-y;bool sign=x>0;x=abs(x);return sign?(x+y-1)/y:-x/y;}
ll floor(ll x,ll y){if(x==0)return 0;if(y<0)x=-x,y=-y;bool sign=x>0;x=abs(x);return sign?x/y:-(x+y-1)/y;}
char str[max_n];
void reads(string& s){scanf(" %s",str);s=str;}
namespace {
    inline int Add(int x,int y){return (x+=y)>=mod?x-mod:x;}
    inline int Sub(int x,int y){return (x-=y)<0?x+mod:x;}
    inline int Mul(int x,int y) {return 1ll*x*y%mod;}
    inline int Pow(int x,int y=mod-2){int res=1;while(y){if(y&1)res=1ll*res*x%mod;x=1ll*x*x%mod;y>>=1;}return res;}
}
/**********************head************************/
int x,y;
int main(){
    scanf("%d%d",&x,&y);
    if(y-2*x>=0&&(y-2*x)%2==0&&4*x-y>=0)printf("Yes\n");
    else printf("No\n");
    return 0;
}

Measured memory_bytes: 3768
#include	<bits/stdc++.h>
using namespace std;
    
int	main() {
  int N;
  cin >>N;
  for (int i=0; N>=i*4; i++) {
    if (0==(N-i*4)%7) {
      cout <<"Yes" <<endl;
      return 0;
    }
  }
  cout <<"No" <<endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>

int main() {
	int n;
	long long sum = 0;
	scanf ("%d", &n);
	int last, x;
	for(int i = 1; i <= n; i++) {
		scanf ("%d", &x);
		if(x < last) {
			sum += last - x;	
			x = last;		
		}
		last = x;
	}
	printf("%lld\n", sum);
	return 0;
}

Measured memory_bytes: 3228
/* In the name of God */

#include<bits/stdc++.h>

using namespace std;
//#define int long long
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define F first
#define S second
#define IOS() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define Dec cout<<fixed<< setprecision
#define endl "\n"
#define nlp printf("\n")
#define nl cout << "\n"
#define MP(make_pair)
#define SZ(x) (int) x.size()
#define tc() int t; cin >> t ; while (t--)
#define debug(x , y) cout << "### " << y << " is : " << x << " ###" << endl
#define clr(a) memset(a , 0 , sizeof a)
#define endl "\n"
#define bit(i , x) ((x >> i) & 1)
#define all(v) v.begin() , v.end()
typedef long long ll;
typedef pair<int,int> pii;
typedef long double ld;
typedef vector<int> VI ;
typedef vector<pii> VPI;

inline void smax(int &x , int y) { x = max(x , y) ; }
inline void smin(int &x , int y) { x = min(x , y) ; }

class FastIO{
public:
    inline FastIO & operator << (const int &a){ printf("%d" , a); return *this; }
//    inline FastIO & operator << (const long long &a){ printf("%I64d" , a); return *this; }
    inline FastIO & operator << (const double &a){ printf("%.9f" , a); return *this; }
    inline FastIO & operator << (const long double &a){ printf("%.9lf" , a); return *this; }
    inline FastIO & operator << (const char * const&a){ printf("%s" , a); return *this; }
    inline FastIO & operator << (const string &a){ printf("%s" , a.c_str()); return *this; }
    inline FastIO & operator >> (int &a){ scanf("%d" , &a); return *this; }
//    inline FastIO & operator >> (long long &a){ scanf("%I64d" , &a); return *this; }
    inline FastIO & operator >> (double &a){ scanf("%lf" , &a); return *this; }
    inline FastIO & operator >> (long double &a){ scanf("%lf" , &a); return *this; }
    inline FastIO & operator >> (char * const&a){ scanf("%s" , a); return *this; }
}fastIO;

const int MOD = 1e9 + 7 ;
const ld EPS = 1e-9 ;
const int INF = 1e9 + 10 ;
const ll LINF = 1e18 ;
const int N = 1e3 + 10 ;
const int maxn = 1e4 + 10 ;
const int MAXN = 1e5 + 10 ;
const int MN = 1e6 + 10 ;
inline int powmod(int x , int y){ ll res = 1 , a = x ; while(y){if(y&1) res = (res*a)%MOD ;  a = (a*a)%MOD ; y >>= 1 ;} return res ; }

int n , a[2*MAXN] , ans[2*MAXN] ;

int32_t main (){
	IOS() ;
	cin >> n ;
	for(int i=0 ; i < n ; i++)
		cin >> a[i] ;
	int aval = 0 , akhar = n-1 ;
	for(int i=0 ; i < n ; i++){
		if(i&1){
			ans[akhar--] = a[n-i-1] ;
		}
		else{
			ans[aval++] = a[n-i-1] ;
		}
	}
	for(int i=0 ; i < n ; i++)
		cout << ans[i] << ' ' ;
	nl ; return 0 ;
}


Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;                                                            
#define pb push_back                                                            
#define mp make_pair                                                                                                                                
#define sqr(a) ((a) * (a))                                                      
#define io() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);   
#define co() cout.precision(10);                                                
#define F for(li i=0;i<n;i++)
#define fo(i,a,n) for(i=a;i<n;i++)
#define ne cout<<"\n"; 
#define test int t;cin>>t;while(t--)
//#define oj #ifndef ONLINE_JUDGE freopen("input.txt","r",stdin); freopen("output.txt","w",stdout); #endif

typedef long long li;
typedef long double ld;
#define LL long long int

const li mod = 1000000007;

int main() 
{
    io();
    LL a;
    cin>>a;
	long double b;
	cin>>b;
    long double ans=(long double)a*b;
    long double an=truncl(ans);
	string s=	to_string(an);
	for(LL i=0; i<s.length(); i++)
	{
		if(s[i]!='.')
		cout<<s[i];
		else
		break;
	}
	cout<<"\n";

}

Measured memory_bytes: 3852
import math
A=[list(map(int,input().split())) for _  in range(3)]
N=int(input())
b=[int(input()) for _ in range(N)]
l=[[0 for _ in range(3)] for _ in range(3)]
flag=0
#print(A,b,l)

for i in range(N):
    for j in range(3):
        for k in range(3):
            if b[i]==A[j][k]:
                l[j][k]=1
#print(l)
for i in range(3):
    if (l[i][0]+l[i][1]+l[i][2])==3:
        flag=1
        break
    if (l[0][i]+l[1][i]+l[2][i])==3:
        flag=1
        break
if (l[0][0]+l[1][1]+l[2][2]==3)or(l[2][0]+l[1][1]+l[0][2]==3):
    flag=1
if flag==0:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 38256
#include "bits/stdc++.h"
#include<unordered_map>
#pragma warning(disable:4996)
using namespace std;

const int my_inf=2147483647;
const long long int my_linf=9223372036854775807;


int dp[11][100001];
int main() {
	int n, d, x; cin >> n >> d >> x;
	memset(dp, 0, sizeof(dp));
	for (int i = 0; i < 11; ++i) {
		for (int j = 0; j <= 100000; ++j) {
			dp[i][j] = 0;
		}
	}
	vector<vector<int>>places(d, vector<int>(n));
	for (int i = 0; i < d; ++i) {
		for (int j = 0; j < n; ++j) {
			int p; cin >> p;
			places[i][j] = p;
		}
	}
	dp[0][x] = 0;
	int now = x;
	for (int day = 0; day < d-1; ++day) {
		for (int money = 0; money <=now; ++money) {
			if (dp[day][money] >= 0) {
				for (int k = 0; k < n; ++k) {
					if (money >= places[day][k]) {
						dp[day][money] = max(dp[day][money], max(0,dp[day][money-places[day][k]]) - places[day][k] + places[day + 1][k]);
					}
				}
			}
			
		}
		now = dp[day][now] + now;
		
	}
	
	cout <<now << endl;
	return 0;
}

Measured memory_bytes: 7448
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
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; }
ll gcd(ll a, ll b) { return b?gcd(b, a%b):a;}
ll lcm(ll a, ll b) { return a*b/gcd(a,b);}
ll MOD=1000000007;

int main(){
  int n,m;
  cin >>n>>m;
  vi s(m);
  vi c(m);
  rep(i,m){
    cin >> s.at(i) >> c.at(i);
  }
  int ans = -1;
 
  vi ans2(n,0);
  rep(i,m){
    ans2.at(s.at(i)-1)=c.at(i);
  }
 
  bool fl=true;
  rep(i,m){
    rep(j,m){
      if(i==j) continue;
      if(s.at(i)==s.at(j)){
        if(c.at(i) != c.at(j)){
          cout << ans << endl;
          fl=false;
          break;
        }
      }
    }
    if(fl==false) break;
  }

  if(n>=2){
    rep(i,m){
      if(s.at(i)==1){
        if(c.at(i)==0){
          cout<<ans<<endl;
          fl=false;
        }
      }
    }
  }
  if(n>=2){
    if(ans2.at(0) == 0){
      ans2.at(0)=1;
    }
  }
 
  if(fl){
    for(int i = 0; i<n; i++){
      cout << ans2.at(i);
    }
    cout<< endl;
  }
}

Measured memory_bytes: 256
#define ll long long int
#include <bits/stdc++.h>
//#include <fstream>
using namespace std;
 
#define         ff               first
#define         ss               second
#define         mp               make_pair
#define         pb               push_back
#define         pf               push_front
#define         vi               vector<ll>
#define         pii              pair<ll,ll>
#define         qi               queue<ll>
#define         mem(a,b)         memset(a,b,sizeof(a))
#define         print(a)         cout<<a<<'\n'
#define         sorted(arr)      sort(arr.begin(),arr.end())
#define         gcd(a,b)         gcd((a),(b))
#define         lcm(a,b)         ((a)*(b))/gcd((a),(b))
#define         all(v)           v.begin(),v.end()
#define         read(a)          scanf("%d", &a)
#define         f(a,n)           for(ll i=a;i<n;i++)
#define         in2(n,m,arr)     for(ll i=0;i<n;i++){for(ll j=0;j<m;j++)cin>>arr[i][j];}
#define         debug(a)         cerr<<a<<" ";
#define         debug1(a)        cerr<<a<<'\n'
 
/*typedef tree<int, null_type, less<int>, rb_tree_tag , tree_order_statistics_node_update> Set;*/
 
 
const unsigned ll mod = 1e9 + 7 ;
const ll inf = (ll)1e18 + 2;
const ll N = (ll)1e6 + 2;
 
//template<typename... T>
//void write(T&... args)
//{
//    ((cout << args << ' '), ...);
//}
//ll power ( ll x , unsigned ll y)
//{
//    ll res = 1;
//    while (y > 0)
//    {
//        if (y & 1)
//            res = (res * x) % mod ;
//        y = y >> 1;
//        x = (x * x) % mod;
//    }
//    return res % mod ;
//}
//
//struct node{
//    ll x , y , z;
//};
//map<pair<ll, ll>,ll> c;
//vector<set<ll>> tree;
//vector<ll> ar ;
//set<ll> s;
//ll get(ll x)
//{
//    if(x == ar[x])
//        return x;
//    return ar[x] = get(ar[x]);
//}
//void merge(ll a ,ll b)
//{
//    a = get(a);
//    b = get(b);
//    if(a == b)
//    {
//        return ;
//    }
//    ar[b] = ar[a];
//    //ans[a] += ans[b];
//    //return true;
// }
//
//ll sev[275];
//vector<ll> pri;
//void seive()
//{
//    for(ll i = 2 ; i < 275 ; i ++)
//    {
//        if(!sev[i])
//        {
//            for(ll j = i ; j < 275 ; j += i)
//            {
//                if(!sev[j])
//                    sev[j] = i;
//            }
//        }
//        if(sev[i] == i)
//            pri.pb(i);
//    }
//}
void solve()
{
    ll a , b;
    cin >> a >> b;
    string st1 = "" , st2 = "";
    for(ll i = 0 ; i < a ;i ++)
        st1 += '0' + b;
    for(ll i = 0 ;i < b ;i ++)
        st2 += '0' + a;
    if(st1 < st2)
        print(st1);
    else
        print(st2);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll t ;
    t = 1;
    //cin >> t;
    //seive();
    while(t --)
    {
        solve();
    }
    //cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}
 


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>

using namespace std;

#define mod 1000000007

long long int fact[200001] = {};
long long int revfact[200001] = {};

void getfact()
{
	fact[0] = 1;
	for(int i = 1; i <= 200000; i++){
		fact[i] = (fact[i - 1] * i) % mod;
	}
}

void getrevfact()
{
	for(int i = 0; i <= 200000; i++){
		long long int tmp[31] = {};
		tmp[0] = fact[i];
		for(int j = 1; j <= 30; j++){
			tmp[j] = (tmp[j - 1] * tmp[j - 1]) % mod;
		}
		long long int rest = mod - 2;
		revfact[i] = 1;
		for(int j = 30; j >= 0; j--){
			if(rest >= (1 << j)){
				rest -= (1 << j);
				revfact[i] = (revfact[i] * tmp[j]) % mod;
			}
		}
	}
}


long long int comb(int n, int r)
{
	return (((fact[n] * revfact[r]) % mod) * revfact[n - r]) % mod;
}

int main()
{
	int n, m;
	cin >> n >> m;
	getfact();
	getrevfact();
	vector<int> v;
	for(int i = 2; i * i <= m; i++){
		if(m == 1) break;
		int cnt = 0;
		while(m % i == 0){
			m /= i;
			cnt++;
		}
		if(cnt > 0) v.push_back(cnt);
	}
	if(m > 1) v.push_back(1);
	long long int ans = 1;
	for(int i = 0; i < v.size(); i++){
		ans = (ans * comb(v[i] + n - 1, v[i])) % mod;
	}
	cout << ans << endl;
}

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

typedef long long int64;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;

int main() {
  int a;
  std::cin >> a;
  std::cout << a + a * a + a * a * a << std::endl;
  return 0;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define m 100005
int a[m],b[m],c[m],dp[3][m];
int main()
{
   ll n;
   cin>>n;
   for(int i=1;i<=n;i++)
   {
       cin>>a[i]>>b[i]>>c[i];
   }
   for(int i=1;i<=n;i++)
   {
       dp[0][i]=max(dp[1][i-1],dp[2][i-1])+a[i];
       dp[1][i]=max(dp[0][i-1],dp[2][i-1])+b[i];
       dp[2][i]=max(dp[0][i-1],dp[1][i-1])+c[i];
  }
  cout<<max({dp[0][n],dp[1][n],dp[2][n]})<<endl;
}


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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            //入力
            var a = int.Parse(Console.ReadLine());

            int b = (a-1) / 111;
            var c = (b + 1) * 111;

            Console.WriteLine("{0}", c);
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
 
using namespace std;
using S = set<long long>;
using D = deque<long long>; //pop_back pop_front push_back push_front front back clear empty
using L = vector<long long>;
using M = map<int,long long>;  //erase  (でキーごと削除) 追加削除検索O(log(N))
using A = vector<vector<long long>>;
using PQ = priority_queue<long long>; //erase  (でキーごと削除) push pop top 
using PQG = priority_queue<long long,L,greater<long long>>; //erase  (でキーごと削除) push pop top 
using U = unordered_map<int,long long>; //map  (との違いはkeyの順番を保持していない)

#define sorted(vector) sort(vector.begin(),vector.end()) //O(nlongn)
#define sortedreverce(vector) sort(vector.rbegin(),vector.rend()) //O(nlongn)
#define vmin(vector) *min_element(vector.begin(),vector.end()) //O(N)
#define vmax(vector) *max_element(vector.begin(),vector.end()) //O(N)
#define vsum(vector) accumulate(vector.begin(),vector.end(),0) //O(N)
#define vdel(vector,a) vector.erase(vector.begin()+a)
#define vcount(vector,a) count(vector.begin(), vector.end(),a) //O(N)
#define bisect_left(vector,a) (lower_bound(vector.begin(),vector.end(),a)-vector.begin())
#define bisect_right(vector,a) (upper_bound(vector.begin(),vector.end(),a)-vector.begin())
#define vfind(vector,a) find(vector.begin(), vector.end(), a) != vector.end() //遅いからあんまり使うな
#define inf 1000000000000000000+10
#define setans long long ans=0;

template <typename T>
void print(T a){for (auto b:a){cout<<b<<" ";};cout<<endl;}
template <>
void print(unsigned long a){cout<<a<<endl;}
template <>
void print(char a){cout<<a<<endl;}
template <>
void print(bool a){cout<<a<<endl;}
template <>
void print(long long a){cout<<a<<endl;}
template <>
void print(A a){for (auto b:a){for (auto c:b){cout<<c<<" ";}cout<<endl;};cout<<endl;}
template <>
void print(string a){cout<<a<<endl;}


//存在確認はmap!!!!!!!!!!!!!か配列に埋め込んでcontinueで回避
//__gcd(a,b)はコンパイラがGCC時のみ
//printf("%.16f", ans); 誤差落ち対応君

int main(){
    long long n,m,tmp;
    cin>>n>>m;
    PQ a;
    for(long long i=0  ;i<n  ;i++){
        cin>>tmp;
        a.push(tmp);
    }

    long long cnt=0;
    while (cnt!=m){
        cnt++;
        tmp=a.top();
        a.pop();
        a.push(tmp/2);
    }
    tmp=0;
    
    while (!a.empty()){
        tmp+=a.top();
        a.pop();
    }
    print(tmp);
}


Measured memory_bytes: 1400
#include<stdio.h>

int main(){
  int i, n, m, x, sum;

  while(1){
    scanf("%d", &n);
    if(n == 0) break;

    m = n * (n-1) / 2;
    for(i=0, sum=0; i<m; ++i){
      scanf("%d", &x);
      sum += x;
    }

    sum /= (n-1);
    printf("%d\n", sum);
  }

  return 0;
}

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

int main(){
    int a,b;
    int c;
    cin >> a >> b;
    if(b/100 !=0){
        c = 1000*a+b;
    }
    else if(b/10!=0){
        c = 100*a+b;
    }
    else{
        c = 10*a+b;
    }
    for(int i=1;i<1000;i++){
        if(i*i==c){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" <<endl;return 0;
}

Measured memory_bytes: 256
class Combination:
    def __init__(self, n, mod):
        self.mod = mod

        # self.fac[i] ≡ i! (factorial:階乗)
        l = [1]
        num = 1
        for i in range(1, n+1):
            num *= i
            num %= mod
            l.append(num)
        self.fac = l.copy()

        # self.rec[i] ≡ 1 / i! (reciprocal:逆数)
        num = pow(num, mod-2, mod)
        l = [1 for i in range(n+1)]
        l[n] = num
        for i in range(n-1, 0, -1):
            num *= i + 1
            num %= mod
            l[i] = num
        self.rec = l.copy()

    # comb(n, r) ≡ nCr
    def comb(self, n, r):
        return self.fac[n] * self.rec[r] * self.rec[n - r] % self.mod

mod = 10**9 + 7

k = int(input())
s = input()
n = len(s)

c = Combination(k + n, mod)

ans = 0
for i in range(k+1):
    ans += c.comb(n + i - 1, i) * pow(25, i, mod) * pow(26, k-i, mod)
    ans %= mod

print(ans)

Measured memory_bytes: 222064
using System;

namespace ConsoleApp1
{
    class ABC117A
    {
        static void Main(string[] args)
        {
            var DTS = Console.ReadLine().Split();
            int D = Int32.Parse(DTS[0]);
            int T = Int32.Parse(DTS[1]);
            int S = Int32.Parse(DTS[2]);

            // Dメートル、T分後、分速Sメートル
            if (D <= T * S)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


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

int main() {
  unsigned long long n;
  int m;
  string name;
  cin >> n;
  bool flag = false;
  if(n <= 26) flag = true;
  while(true) {
    m = n % 26;
    if(m == 0) m = 26;
    n = (n-m) / 26;
    name.push_back(char(m + 96));
    if(flag) break;
    if(n <= 26) flag = true;
  }
  reverse(name.begin(), name.end());
  cout << name << endl;
  return 0;
}

Measured memory_bytes: 3624
A, B, M =list(map(int,input().split()))
a = list(map(int,input().split()))
b = list(map(int,input().split()))
ma=[]
for i in range(M):
    ma.append(list(map(int,input().split())))

ans=min(a)+min(b)
for x,y,m in ma:
    c=a[x-1]+b[y-1]-m
    if c < ans:
        ans = c
print(ans)

Measured memory_bytes: 38484
#include <iostream>
#include <vector>
#include <limits.h>
#include <string>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>

using namespace std;



int main()
{

	int n;
	vector<string> s;

	cin >> n;
	string wk;
	for (int i = 0; i < n; i++) {
		cin >> wk;

		s.push_back(wk);
	}

	for (int i = 0; i < n; i++) {
		sort(s[i].begin(), s[i].end());
	}
	

	sort(s.begin(), s.end());
	

	wk = s[0];
	long long int answk = 1;
	long long int ans = 0;
	for (int i = 1; i < n; i++) {
		if (wk == s[i]) {

			
			answk++;
		}
		else {
			ans += (answk * (answk - 1)) / 2;
			wk = s[i];
			answk = 1;
		}

	}
	ans += (answk * (answk - 1)) / 2;


	cout << ans << endl;




}



Measured memory_bytes: 7284
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int INF = 1e8;

signed main() {
	int N;
	cin >> N;
	set<int>s;
	int num;
	rep(i, N) {
		cin >> num;
		s.insert(num);
	}
	cout << s.size();
}

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

int main(){
   int n;
   cin >> n;
   if(n%1000 == 0) cout << 0 << endl;
   else cout << 1000 - n%1000 << endl;
   return 0;
}

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


template<typename T>
struct UnionFind
{
    vector<T> parents;
    vector<T> rank;
    UnionFind(T n):parents(n),rank(n,0){
        for (T i=0;i<n;i++){
            parents[i] = i;
        }
    }
    T root(T x){
        //再帰的に根をつけなおす//rootを返す
        return parents[x] == x ? x: parents[x] = root(parents[x]);
    }
    //mergeする　すでに一致してたらfalseを返す。
    bool unite(T x, T y){
        if (x==y) return false;
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        parents[y] = x;
        return true;
    }
    bool same(T x, T y){
        if (x==y) return true;
        return root(x) == root(y);
    }
};


void solve(long long N, long long M, std::vector<long long> p, std::vector<long long> x, std::vector<long long> y){
    UnionFind<ll> uf(N+1);
    for (ll i=0;i<M;i++){
        uf.unite(x[i],y[i]);
    }
    ll n_swappable = 0;
    for (ll i=1;i<=N;i++){
        if (uf.same(i,p[i-1])){
            n_swappable+=1;
        }
    }
    printf("%lld\n",n_swappable);

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> p(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&p[i]);
    }
    std::vector<long long> x(M);
    std::vector<long long> y(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&x[i]);
        scanf("%lld",&y[i]);
    }
    solve(N, M, std::move(p), std::move(x), std::move(y));
    return 0;
}


Measured memory_bytes: 4096
n = int(input())
ac = 0
wa = 0
tle = 0
re = 0

for _ in range(n):
    s = input()
    if s=="AC":
        ac += 1
    elif s=="WA":
        wa += 1
    elif s=="TLE":
        tle += 1
    else:
        re += 1

print("AC x {}".format(ac))
print("WA x {}".format(wa))
print("TLE x {}".format(tle))
print("RE x {}".format(re))

Measured memory_bytes: 9204
#include <iostream>
#include <math.h>
#include <stdio.h>

using namespace std;

int main()
{
    int a,b,x;
    cin >> a >> b >> x;
    double a1,a2,a3;
    double l = (double)a*b*a/2;
    if(l == x)
        cout << "45.0000000000" << endl;
    else if(l < x)
    {
        double w = (double)x/a;
        w -= (double)a*b/2;
        w = (double)a*b/2-w;
        a1 = (double)a;
        a2 = (double)w*2/a1;
        a3 = sqrt(a1*a1+a2*a2);
        double tt = (a1*a1+a3*a3-a2*a2)/(2*a1*a3);
        double t = 180/3.1415926535898 * acos(tt);
        printf("%.10f\n",t);
    }
    else{
        double w = (double)x/a;
        a1 = (double)b;
        a2 = (double)w*2/a1;
        a3 = sqrt(a1*a1+a2*a2);
        double tt = (a1*a1+a3*a3-a2*a2)/(2*a1*a3);
        double t = 180/3.1415926535898 * acos(tt);
        t = 90-t;
        printf("%.10f\n",t);
    }
    return 0;
}


Measured memory_bytes: 256