akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <bitset>
#include <fstream>
#include <cmath>
#include <ctime>
#include <numeric>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define REP(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define MSG(a) cout << #a << " "  << a << endl;
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
const int INF = 1 << 30;

struct node
{
	int x, y, cost;
	node(int x, int y, int cost) : x(x), y(y), cost(cost) {}
};
bool operator < (const node &a, const node &b)
{ return a.cost > b.cost; }

int room[500][500];
int from[500 * 500];
bool flag[500][500];

int main()
{
	int r;
	while(cin >> r && r)
	{
		// key, value
		map<int, int> result[2];
		result[0][0] = result[1][0] = 0;

		
		// Dijkstra
		rep(i, 2)
		{
			int w, h, sx, sy;
			cin >> w >> h >> sx >> sy; sx--; sy--;

			rep(y, h) rep(x, w) cin >> room[y][x];


			priority_queue<node> que;
			memset(flag, 0, sizeof(flag));
			
			for(que.push(node(sx, sy, room[sy][sx])); !que.empty(); que.pop())
			{
				node q = que.top();
				
				if(flag[q.y][q.x]) continue;
				else flag[q.y][q.x] = true;
				
				result[i][q.cost]++;
				
				int dx[] = {-1,0,1,0} , dy[] = {0,-1,0,1};
				rep(d, 4)
				{
					int tx = q.x + dx[d], ty = q.y + dy[d];
					if(0 <= tx && tx < w && 0 <= ty && ty < h && !flag[ty][tx]) que.push(node(tx, ty, max(q.cost, room[ty][tx])));
				}
			}
		}

		int res = INF;

		int sum_one = 0;
		vector<int> u;
		
		for(map<int, int>::iterator it = result[1].begin(); it != result[1].end(); it++)
		{
			from[u.size()] = it->first;
			u.push_back(it->second + sum_one);
			sum_one += it->second;
		}
		u.push_back(INF);


		int sum_one_second = 0;

		for(map<int, int>::iterator it = result[0].begin(); it != result[0].end(); it++)
		{
			int l = it->first, c = it->second + sum_one_second, ac = *lower_bound(u.begin(), u.end(), r - l);
			if(ac != INF)
			{
				int al = from[lower_bound(u.begin(), u.end(), r - c) - u.begin()];
				chmin(res, l + al);
			}
			sum_one_second += it->second;
		}

		cout << res << endl;
	}
}

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

int main(){
  int s,n;
  while(cin>>n){
    s = 0;
    for(int i=9;i>=0;i--){
      if(n-i>27) break;
      for(int j=9;j>=0;j--){
	if(n-i-j>18) break;
	for(int k=9;k>=0;k--){
	  if(n-i-j-k>9) break;
	  if(n-i-j-k>=0) s++;
	}
      }
    }
     cout<<s<<endl;
  }
 
  return 0;
}

Measured memory_bytes: 1160
n = int(input())
l = [0]*10000

for x in range(1, 100):
    for y in range(1, 100):
        for z in range(1, 100):
            ind = x**2+y**2+z**2+x*y+y*z+z*x
            if ind <= 10000:
                l[ind-1]+=1

for i in range(n):
    print(l[i])

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define PI 3.14159265358979
#define MOD 1000000007 // = 10^9 + 7

using namespace std;
using ll = long long;

void solve()
{
	int n;
	cin >> n;

	vector<ll> a(n + 1, 0);
	vector<ll> b(n + 1, 0);
	vector<ll> c(n + 1, 0);
	ll ans = 0;
	for(int i = 0; i < n; ++i)
	{
		cin >> a[i];
		a[i]--;
		b[a[i]]++;
	}

	for(int i = 0; i < n; ++i)
	{
		c[i] = (b[i] * (b[i] - 1)) / 2;
		ans += c[i];
	}

	for(int i = 0; i < n; ++i)
	{
		cout << ans - c[a[i]] + ((b[a[i]] - 1) * (b[a[i]] - 2)) / 2 << endl;
		//cout << " " << ans << " - " << c[a[i]] << " + " << ((b[a[i]] - 1) * (b[a[i]] - 2)) / 2 << endl;
	}


}

int main()
{
	fastio;
	solve();

	return 0;
}

Measured memory_bytes: 7296
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstring>
#include<queue>
#include<tuple>
#include<utility>
#include<map>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<unistd.h>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define FOR(i, a, b) for (ll i=a; i<(b); i++)
#define range(a) a.begin(), a.end()
#define endl "\n"
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
const long long mod = 1e9 + 7;
const long long INF = 1LL<<60;
const ll dx[2]={1,2};
const ll dy[2]={2,1};
void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }

// UnionFind
// coding: https://youtu.be/TdR816rqc3s?t=726
// comment: https://youtu.be/TdR816rqc3s?t=6822
struct UnionFind {
  vector<int> d;
  UnionFind(int n=0): d(n,-1) {}	//コンストラクタ

  int find(int x) {
    if (d[x] < 0) return x;
    return d[x] = find(d[x]);
  }
  bool unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y);}
  int size(int x) { return -d[find(x)];}
};

int main(){
    int N, M,ans=1;
    cin >> N >> M;
    UnionFind uf(N);
    while(M--){
        int a, b;
        cin >> a >> b;
        uf.unite(a, b);
    }

    FOR(i, 0, N)
    ans = max(ans, uf.size(i));

    cout << ans << endl;

    return 0;
}





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

A,B,C,D,E,F = list(map(int, input().split()))

m = 0
sw = 0
ss = 0
for a in range(1,F//(A*100)+1):
    w = a*A*100
    for b in range(0,F//(B*100)+1):
        w += b*B*100
        for c in range(0,F//C+1):
            for d in range(0,F//D+1):
                s = c*C + d*D
                dens = (100*s)/(w+s)
                limit_dens = (100*E)/(100+E)
                if w + s <= F and dens <= limit_dens:
                    if m <= (100*s)/(w+s):
                        m = (100*s)/(w+s)
                        sw = w+s
                        ss = s
                        if dens == limit_dens:
                            print(sw, ss)
                            exit()
print(sw, ss)


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

typedef vector<int> VI;
typedef vector<int>::iterator VII;

VI v[10];
int dp[2000];

int main()
{
	int n, k;
	scanf("%d %d", &n, &k);
	
	for (int i = 0; i < n; i++){
		int c, g;
		scanf("%d %d", &c, &g);
		g--;
		
		v[g].push_back(c);
	}
	
	for (int i = 0; i < 10; i++){
		//for (VII it = v[i].begin(); it != v[i].end(); it++){
		//	for (int j = k; j > 0; j--){
		//		dp[j] = max(dp[j], dp[j - 1] + *it);
		//	}
		//}
		
		sort(v[i].begin(), v[i].end());
		reverse(v[i].begin(), v[i].end());
		
		for (int j = 1; j < v[i].size(); j++){
			v[i][j] += v[i][j - 1] + j * 2;
		}
		
		for (int j = k; j > 0; j--){
			for (int l = 0; l < v[i].size(); l++){
				if (j - l > 0)
					dp[j] = max(dp[j], dp[j - l - 1] + v[i][l]);
			}
		}
	}
	
	printf("%d\n", dp[k]);
	
	return 0;
}

Measured memory_bytes: 1232
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <functional>
#include <random>
#include <time.h>
#include <chrono>
#include <sstream>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
#define sort(s) sort(s.begin(), s.end());
#define reverse(s) reverse(s.begin(), s.end());
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }
double log(double a, double b) { return log(b) / log(a); }

unsigned int randxor()
{
	static unsigned int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
	unsigned int t;
	t = (x ^ (x << 11)); x = y; y = z; z = w; return(w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}



int main() {
	int n, m;
	cin >> n >> m;
	vector<int> a(n), b(m);
	rep(i, n) {
		cin >> a[i];
	}
	rep(i, m) {
		cin >> b[i];
	}
	sort(a);
	sort(b);
	reverse(a);
	reverse(b);
	
	int i = 0;
	int j = 0;
	ll ans = 1;

	for (int x=n*m; x > 0; x--) {
		if (i < n && j < m && a[i] == x && b[j] == x) {
			++i;
			++j;
		}
		else if (i < n && a[i] == x) {
			i++;
			ans = (ans * j) % mod;
		}
		else if (j < m && b[j] == x) {
			j++;
			ans = (ans * i) % mod;
		}
		else {
			int z = i * j - (n*m - x);
			if (x <= 0) {
				cout << 0 << endl;
				return 0;
			}
			else {
				ans = (ans * z) % mod;
			}
		}
	}
	cout << ans << endl;
}




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

int n,k,ans;

int main(){
    //freopen("F:\\rush.txt","r",stdin);
    ios::sync_with_stdio(0),cin.tie(0);
    cin >> n;
    cin >> k;
    for (int i = 1,x;i <= n;i++){
        cin >> x;
        ans += 2*min(x,k-x);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <utility>
#include <numeric>
#include <deque>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <limits>
#include <cassert>

#define for0(i, N)    for (int i = 0  ; i <  (N); ++i)
#define for1n(i, N)   for (int i = 1  ; i <= (N); ++i)
#define for1(i, N)    for (int i = 1  ; i <  (N); ++i)
#define forn(i, N)    for (int i = 0  ; i <= (N); ++i)
#define forx(i, N, x) for (int i = (x); i <  (N); ++i)
#define forl(i, n, x, a) for (int i = (x), a = 0; a < (n);  \
                              i = (i + 1) % (n), ++a)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef priority_queue<ll> pq;
typedef priority_queue<ll,vector<ll>, greater<ll>> pql;
typedef stack<ll> stk;
typedef queue<ll> qu;


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

    int N;

    cin >> N;

    int B[(int)1e5];

    for0(i, N - 1){
        cin >> B[i];
    }

    int result = 0;
    result += B[0];

    for0(i, N - 2){
        result += min(B[i], B[i + 1]);
    }
    result += B[N - 2];

    cout << result;


    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <limits>
#include <sstream>
#include <string>
#include <vector>

using namespace std;

#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(i, a, n) for (int i = a; i < n; i++)
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eps 1e-15

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef tuple<int, int, int> ti3;

int main()
{
    int a, b;
    scanf("%d %d %d", &a, &b);
    int add = a + b;
    int sub = a - b;
    int mul = a * b;
    printf("%d\n", max(max(add, sub), mul));

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int[][] info = new int[n][3];
		for(int i = 0; i < n; i++){
		    info[i][0] = sc.nextInt();
		    info[i][1] = sc.nextInt();
		    info[i][2] = sc.nextInt();
		}
		
		// 計算
		int[] result = new int[3];
		int calcH = -1;
		int s = 0;
		int t = 0;
		int u = 0;
		for(int i = 0; i < n; i++){
		    if(info[i][2] != 0){
		        s = info[i][0];
		        t = info[i][1];
		        u = info[i][2];
		    }
		}
		for(int x = 0; x <= 100; x++){
		    for(int y = 0; y <= 100; y++){
		        calcH = abs(x - s) + abs(y - t) + u;
		        boolean check = true;
		        for(int i = 0; i < n; i++){
		            if(info[i][2] == 0){
		                if(calcH > abs(x - info[i][0]) + abs(y - info[i][1]) + info[i][2]) check = false;
		            }else{
		                if(calcH != abs(x - info[i][0]) + abs(y - info[i][1]) + info[i][2]) check = false;
		            }
		        }
		        if(check){
		            result[0] = x;
		            result[1] = y;
		            result[2] = calcH;
		        }
		    }
		}
		// 出力
		System.out.println(result[0] + " " + result[1] + " " + result[2]);
		
	}
}

Measured memory_bytes: 22100
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
ll a,b,c;
  char y,z;
  cin>>a>>y>>b>>z>>c;
  if(b>4) {
cout<<"TBD"<<endl;
  }
  else {
cout<<"Heisei"<<endl;
  }
}

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

int main(){
    int H, W, K;
    cin >> H >> W >> K;
    int answer = 0;
    string c[6];
    rep(i,H) cin >> c[i];
    rep(s, 1<<H)rep(t, 1<<W){
        string temp[6];
        rep(i,H) temp[i] = c[i];
        rep(i, H){
            if(s >> i&1) rep(k, W) temp[i].at(k) = 'R';
        }
        rep(i, W){
            if(t >> i&1) rep(k, H) temp[k].at(i) = 'R';
        }
        int b_cnt = 0;
        rep(i,H) rep(j,W) if (temp[i].at(j) == '#') b_cnt++;
        if(b_cnt == K) answer++;
    }
    cout << answer << endl;

}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define ll long long int
#define endl '\n'
#define M 1000000007
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define f first
#define s second
#define b begin
#define e end
#define pb push_back
#define mp make_pair
#define FOR(i,a,b) for(i=a;i<b;i++)
#define RFOR(i,a,b) for(i=a;i>=b;i--)
#define all(x) x.begin(),x.end()
#define itfr(it,x) for(it=x.begin();it!=x.end();it++)
#define flash ios_base::sync_with_stdio(false); cin.tie(NULL)
using namespace std;

int main()
{
    flash;
    //sieve();
    ll T=1,n,m,q,k,i,j;
    // cin>>T;
    while(T--)
    {
        cin>>n>>m>>q>>k;
        i = min(n,k);
        k -= i;
        k -= min(m,k);
        i -= min(k,q); 
        cout<<i<<endl;
    }
}

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

int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(a>c){
		if(c>b){
			cout<<"Yes"<<endl;
		}else{
			cout<<"No"<<endl;
		}
	}else{
		if(b>c){
			cout<<"Yes"<<endl;
		}else{
			cout<<"No"<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
x=int(input())
if x==2:
    print(2)
else:
    tmp=x
    flag=False
    while True:
        for i in range(2,tmp):
            if tmp%i==0:
                break
            if i==tmp-1:
                flag=True
        if flag:
            break
        else:
            flag=False
            tmp+=1
    print(tmp)

Measured memory_bytes: 9132
#include <iostream>
#include <algorithm>
#include <map>
#include <utility>
#include <vector>
#include <cstdio>
#include <iomanip>
#include <cmath>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < n; i++)




int main(){
    int N;
    double v[50];
    cin >> N;
    rep(i,N) cin >> v[i];

    sort(v, v+N);
    
    double pre = (double)((v[0]+v[1])/2.0);
    if (N==2) {
        cout << pre << endl;
        return 0;
    }
    double now = 0.0;
    for (int i = 2; i < N; i++) {
        now = (double)((pre+v[i])/2.0);
        pre = now;
    }
    cout << fixed << setprecision(12) << now << endl;
    return 0;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main() {
    input! {
        a1: u32,
    }

    let sum: u32 = a1 + a1 * a1 + a1 * a1 * a1;

    println!("{}", sum)
}


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

long long gcd(long long p, long long q) {
	if (p < q) swap(p, q);
	if (p % q == 0) return q;
	else return gcd(p / q, p % q);
}
int keta(long long p, int q) {
	if (p / 10 == 0) return q + 1;
	else return keta(p / 10, q + 1);
}
long long kaijo(int p, int q) {
	if (p == 1) return q;
	else return kaijo(p - 1, p * q);
}

int main() {
	long N, ans;
	ans = 0;
	cin >> N;
	vector<long> vec(N);
	rep(i, N) cin >> vec[i];
	sort(vec.begin(), vec.end());
	pair<long, long> count;
	rep(i, N) {
		if (count.first != vec[i]) {
			if (count.second != (count.second / 2) * 2) ans++;
			count = make_pair(vec[i], 1);
		}
		else count.second++;
	}
	if (count.second != (count.second / 2) * 2) ans++;
	cout << ans << endl;
}

Measured memory_bytes: 4012
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
c = Counter(a)
d = {}
sum = 0
for i in c:
    k = c[i]
    sum += k * (k - 1) / 2
for i in range(n):
    print(int(sum - c[a[i]] + 1))

Measured memory_bytes: 27036
// Problem : C - : (Colon)
// Contest : AtCoder - AtCoder Beginner Contest 168
// URL : https://atcoder.jp/contests/abc168/tasks/abc168_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#define int long long
#define fastio                      \
  ios_base::sync_with_stdio(false); \
  cin.tie(0);                       \
  cout.tie(0);
#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define db1(x) cout << #x << "=" << x << endl
#define db2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z)                                                       \
  cout << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z \
       << endl
#define dbp(x) \
  cout << #x << "= {" << (x.first) << ", " << (x.second) << "}" << endl;
#define dbv(v)                         \
  {                                    \
    cout << #v << " : ";               \
    for (auto x : v) cout << x << ' '; \
    cout << endl;                      \
  }
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define rep2(i, a, b) for (int i = a; i >= b; i--)
#define die(x) return cout << x << '\n', 0;
typedef long double ld;

const ld pi = acos((ld)-1.00);
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

int32_t main() {
  fastio;
  //  freopen("input.txt", "r", stdin);
  //  freopen("output.txt", "w", stdout);
  int testcases;
  testcases = 1;
  // cin>>testcases;

  while (testcases--) {
    ld a, b, h, m;
    cin >> a >> b >> h >> m;
    ld ha = (2.00 * pi * h) / (12.00) + (2.00 * pi * m) / (12.00 * 60.00);
    ld ma = (2.00 * pi * m) / (60.00);
    ld diff = ha - ma;
    //    cout << (180.00 * diff) / (2.00 * pi) << '\n';
    if (ha - ma > pi) {
      diff = 2 * pi - diff;
    }
    if (diff < 0) diff = diff * -1;
    ld ans = a * a + b * b - 2 * a * b * cosl(diff);
    cout << fixed << setprecision(20) << sqrtl(ans);
  }

  return 0;
}


Measured memory_bytes: 4196
// Atcoder
  // Practice Problems
  // A - Biscuit Generator
  #include <bits/stdc++.h>
  #include <iostream>
  #include <map>
  #include <queue>
  #include <set>
  #include <string>   
  #include <vector>
  #include <numeric>
  using namespace std;
  typedef long long int ll;
  typedef pair<ll, int> PLI;
  typedef pair<int, int> PII;
  const ll mxsize = 1e5 + 5;
  #define fastIO                                                                 \
    ios_base::sync_with_stdio(false);                                            \
    cin.tie(NULL);                                                               \
    cout.tie(NULL);
  
  /******************************************* IMPORTANT CODE SNIPPETS ************************************************/ 
  
  ll pow(ll x, ll n) {
    if (n == 0)
      return 1ll;
    ll temp;
    temp = pow(x, n / 2);
    if (n % 2 == 0)
      return temp * temp;
    else
      return x * temp * temp;
  }

  ll gcd(ll a, ll b) {
    if (b == 0)
      return a;
    return gcd(b, a % b);
  }

  int sum_digit(int val) {
    if (val < 0)
      return -1;
    if (val == 0)
      return 0;
    int ans = 0;
    while (val > 0) {
      ans = ans + val % 10;
      val = val / 10;
    }
    return ans;
  }

  ll count_div(ll l, ll r, ll val) {
    if (l % val == 0)
      return (((r / val) - (l / val)) + 1);
    else
      return ((r / val) - (l / val));
  }

  int powmod(int x, int y, int m) {
    int res = 1;
    // x = x % mod;
    while (y > 0) {
      if (y & 1)
        res = (res * x) % m;
      cout << res << endl;
      y = y / 2;
      cout << x << endl;
      x = (x * x) % m;
    }
    // cout << res << endl;
    return res;
  }
  /******************************************** CODE STARTS FROM HERE *************************************************/ 
  
  int main()
  {
    int A , B , T;
    cin >> A >> B >> T;
    int ans = 0;
    while(T >= A)
    {
      ans = ans + B;
      T = T - A;
    }
    cout << ans;
  }

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	int a[81];
	int b[81];
	int ans[81];
	int n;
	cin>>n;
	rep(j,n){
		rep(i,81){
			a[i]=b[i]=ans[i]=0;
		}
		string s[2];
		cin>>s[0];
		int cnt=80;
		for(int i=s[0].size()-1;i>=0;i--){
			a[cnt]=s[0][i]-'0';
			cnt--;
		}
		cin>>s[1];
		if(s[0].size()>80 || s[1].size()>80){
			cout<<"overflow"<<endl;
			continue;
		}
		cnt=80;
		for(int i=s[1].size()-1;i>=0;i--){
			b[cnt]=s[1][i]-'0';
			cnt--;
		}
		bool check=true;
		for(int i=80;i>=0;i--){
			ans[i]=a[i]+b[i];
			//cout<<i<<":"<<a[i]<<"+"<<b[i]<<"="<<ans[i]<<endl;
			if(ans[i]>=10){
				a[i-1]++;
				ans[i]%=10;
			}
		}
		if(ans[0]>0){
			cout<<"overflow"<<endl;
			check=false;
		}
		int ite=0;
		rep(i,81){
			if(ans[i]!=0){
				ite=i;
				break;
			}
		}
		if(check){
			if(ite!=0){
				for(int i=ite;i<81;i++){
					cout<<ans[i];
				}
				cout<<endl;
			}else{
				cout<<0<<endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1212
A,B,C,D,E,F=map(int,input().split())
X=F//100
w,s=100*A,0
for x in range(X,0,-1):
    a,b=0,0
    while A*a<=x:
        b=(x-A*a)%B
        if b==0:
            break
        a+=1
    if b==0:
        b=(x-A*a)//B
        maxs=min(E*x,F-100*(A*a+B*b))
        c,d=0,0
        cc=0
        while C*cc<=maxs:
            dd=(maxs-C*cc)//D
            if C*cc+D*dd>C*c+D*d:
                c,d=cc,dd
            cc+=1
        if s/w<(C*c+D*d)/(100*(A*a+B*b)+C*c+D*d):
            s,w=C*c+D*d,100*(A*a+B*b)+C*c+D*d
print(w,s)

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int h,w,n; cin>>h>>w>>n;
	vector<int>ans(h*w);
	for(int i=1,j=0;i<=n;++i){
		int a; cin>>a;
		for(int k=0;k<a;++j,++k){
			ans.at(j)=i;
		}
	}
	for(int y=0;y<h*w;y+=w){
		if(y/w&1){
			cout<<ans.at(y+w-1);
			for(int x=y+w-2;x>=y;--x){
				cout<<" "s<<ans.at(x);
			}
		}
		else{
			cout<<ans.at(y);
			for(int x=y+1;x<y+w;++x){
				cout<<" "s<<ans.at(x);
			}
		}
		cout<<"\n"s;
	}
}


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

int main(){
    int X, A, B;
    cin >> X >> A >> B;
    
    if(B>A){
		if(X<(B-A)){
			cout << "dangerous" << endl;
		}else{
			cout << "safe" << endl;
		}
	}else{
		cout << "delicious" << endl;
	}

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

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

    vector<ll> s(n+1,0);
    rep(i,n) s[i+1]=s[i]+a[i];

    map<ll,ll> m;
    rep(i,n+1){
        m[s[i]]++;
        //cout<<s[i]<<" ";
    }
    //cout<<endl;
    ll ans=0;
    for(auto e : m){
        ll x=e.second;
        ans+=x*(x-1)/2;
    }

    cout<<ans<<endl;
}
    




Measured memory_bytes: 15872
#include <iostream>
#include <vector>
#include <fstream>
#include <algorithm>
#include <map>
#include <iomanip>
#include <math.h>
using namespace std;
 
#define pb push_back
#define f first
#define s second
#define endl '\n'
#define EPS 1e-9
#define PI acos(-1)
 
using ll = long long;
using ii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<ii>;
using vll = vector<ll>;
using ui = unsigned int;



int main() {
    ofstream out("output.txt");
    ios_base::sync_with_stdio(false);
    

    double r;
    cin>>r;
    double a1 = PI * (r*r);
    double a2 = PI * (1*1);

    cout<<round(a1/a2)<<endl;

    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
char s[500];
int K,N,cnt,a[500],f[2][610][610];
const int P = 998244353;
int main(){
	scanf("%s%d",s+1,&K);
	N = strlen(s+1);
	cnt = 1;
	int sum = 0;
	for (int i=1; i<=N; i++){
		if (s[i] == '1') a[cnt]++;
		else cnt++,sum += a[cnt-1];
	}
	if (!a[cnt]) cnt--;
//	printf("%d\n",cnt);
//	for (int i=1; i<=cnt; i++) printf("%d ",a[i]); puts("");
	K = min(K,N)<<1;
	f[0][0][0] = 1;
	for (int i=0,op=0; i<cnt; i++,op^=1){
		memset(f[op^1],0,sizeof(f[op^1]));
		for (int j=0; j<=K; j++){
			for (int k=0; k<=N; k++){
				if (!f[op][j][k]) continue;
//				printf("debug %d %d %d %d\n",i,j,k,f[i][j][k]);
				f[op^1][j][k] += f[op][j][k];
				f[op^1][j][k] %= P;
				for (int l=1; j+l<=K; l++)
					f[op^1][j+l][k+l] += f[op][j][k], f[op^1][j+l][k+l] %= P;
				for (int l=1; l<=min(a[i+1],k) && j+l<=K; l++)
					f[op^1][j+l][k-l] += f[op][j][k], f[op^1][j+l][k-l] %= P; 
			}
		}	
	}
	int ans = 0;
	for (int i=0; i<=K; i++) ans += f[cnt%2][i][0], ans %= P;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 6680
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define sz(c) ((int)(c).size())
 
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
//const int MAX=;
const int INF=1e9;
 
 
int main(){
	int N, M, R;
	cin>>N>>M>>R;
	int r[8];
	rep(i,R){
		cin>>r[i];
		r[i]--;
	}
	int C[200][200];
	rep(i,N)rep(j,N)C[i][j]=INF;
	rep(_,M){
		int a,b,c;
		cin>>a>>b>>c;
      	a--;
      	b--;
		C[a][b]=c;
		C[b][a]=c;
	}
	rep(k,N)rep(i,N)rep(j,N)C[i][j]=min(C[i][j], C[i][k]+C[k][j]);
	int d[8][8];
	rep(i,R)rep(j,R) d[i][j]=C[r[i]][r[j]];
	
	int dp[256][8];
	rep(k,R+1)rep(bit, 1 << R)dp[bit][k]=INF;
	rep(k, R) dp[1 << k][k]=0;
	rep(bit, 1 << R)rep(k,R)rep(i,R)if(!((bit >> i) & 1)){
		dp[bit | (1 << i)][i]=min(dp[bit | (1 << i)][i], dp[bit][k]+d[k][i]);
	}
	int ans=INF;
	rep(k,R)ans=min(ans, dp[(1<<R)-1][k]);
	cout<<ans<<endl;
}

Measured memory_bytes: 384
from collections import deque

n, q = (int(s) for s in input().split())

que = deque()
for i in range(n):
    name, ts = input().split()
    que.append((name, int(ts)))

t = 0
while que:
    name, time = que.popleft()
    if time <= q:
        t += time
        print(name, t)
    else:
        t += q
        que.append((name, time - q))

Measured memory_bytes: 14888
#include<stdio.h>
#include<string.h>

main(void){
    int num[10], i, high1 = 0, high2 = 0, high3 = 0;
    
    for( i = 0; i < 10; i++){
        scanf("%d", &num[i]);
        if( num[i] >= high1){
            high3 = high2;
            high2 = high1;
            high1 = num[i];
        }else if( num[i] >= high2){
            high3 = high2;
            high2 = num[i];
        }else if(num[i] >= high3){
            high3 = num[i];
        }
    }
    
    printf("%d\n%d\n%d\n", high1, high2, high3);

    return 0;
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin>>N;
    vector<int>A;
    long long sub=0;
    int a;
    for(int i=0;i<N;i++){
        cin>>a;
        A.push_back(a-i);
    }
    sort(A.begin(),A.end());
    int md=A[N/2];
    for(int i=0;i<N;i++){
        sub+=abs(A[i]-md);
    }
    cout<<sub<<endl;
}

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

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

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(int i=cc;i>=n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const double PI = 3.1415926535;
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;

int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }

int main(){
  int n;
  cin >> n;
  vector<int>a(n), left(n+1), right(n+1);
  rep(i, 0, n)cin >> a[i];
  rep(i, 0, n)left[i+1]=GCD(left[i],a[i]);
  rrep(i, n-1, 0)right[i]=GCD(right[i+1],a[i]);
  int ans = 0;
  rep(i, 0, n){
      chmax(ans, GCD(left[i],right[i+1]));
  }
  cout << ans << endl;
}

Measured memory_bytes: 4572
#include <stdio.h>
#include <string.h>

int main()
{
	int		k,slen;
	char	s[101];
	char	ans[103];

	s[0] = '\0';
	scanf("%d", &k);
	scanf("%s", s);

	slen = strlen(s);

	if(k >= slen)
	{
		strcpy(ans, s);
	}
	else
	{
		strncpy(ans, s, k);
		ans[k+0] = '.';
		ans[k+1] = '.';
		ans[k+2] = '.';
		ans[k+3] = '\0';
	}

	printf("%s\n", ans);

    return 0;
}


Measured memory_bytes: 1636
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    string S;
    cin >> S;
    REP(i, 3) {
        if(S[i] == S[i + 1]) {
            cout << "Bad" << endl;
            return 0;
        }
    }
    cout << "Good" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			String s = sc.next();
			int result = 0;
			char tmp = ' ';

			for (char c : s.toCharArray()) {
				if (tmp != c) {
					result++;
				}
				tmp = c;
			}
			System.out.println(result);
		}
	}
}


Measured memory_bytes: 26424
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define int ll
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

signed main(void) {
    int i,j;
    int n, m;
    cin >> n >> m;
    vi a(n);
    rep(i,n) cin >> a[i];
    rep(i,n-1)a[i+1] = (a[i+1] + a[i])%m;
    map<int,int> mp;
    rep(i,n)mp[a[i]%m]++;
    ll ans = 0;
    for(auto itr = mp.begin(); itr != mp.end(); itr++){
        int t = itr->second;
        if(itr->first == 0){
            ans+= t*(t+1)/2;
        }else{
            ans += t*(t-1)/2;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define loop(n) for (int ngtkana_is_genius = 0; ngtkana_is_genius < int(n); ngtkana_is_genius++)
#define rep(i, begin, end) for(int i = int(begin); i < int(end); i++)
#define all(v) v.begin(), v.end()
#define lint long long
auto cmn = [](auto& a, auto b){if (a > b) {a = b; return true;} return false;};
auto cmx = [](auto& a, auto b){if (a < b) {a = b; return true;} return false;};
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail){
  std::cerr << " " << head;
  debug_impl(tail...);
}
#define debug(...)\
  std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
  debug_impl(__VA_ARGS__);\
  std::cerr << std::noboolalpha;

template <typename T>
std::istream& operator>> (std::istream& is, std::vector<T>& v) {
  for (auto & x : v) is >> x;
  return is;
}

template <typename T>
std::ostream& operator<< (std::ostream& os, const std::vector<T>& v) {
  auto n = v.size();
  os << "{";
  for (size_t i = 0; i < n; i++)
    {os << (i > 0 ? "," : "") << v.at(i);}
  return os << "}";
}

// b = a * p
template < typename Value >
auto right_norm(std::vector< Value > const& a, int h) {
  int  w = a.size();
  auto b = a;
  std::vector< int > frozen(w, false);
  for (auto i = h - 1; i >= 0; i--) {
    auto pivot = -1;
    for (auto j = 0; j < w; j++) {
      if (!frozen.at(j) && (b.at(j) & (1LL << i)))
        { pivot = j; break; }
    }
    if (pivot == -1) continue;
    frozen.at(pivot) = true;
    for (auto j = 0; j < w; j++) {
      if (j != pivot && (b.at(j) & (1LL << i)))
        { b.at(j) ^= b.at(pivot); }
    }
  }
  return b;
}

int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  int n; std::cin >> n;
  std::vector< lint > a(n);
  std::cin >> a;
  auto pmax = 60;
  std::vector< int > is_even(pmax, false);
  rep(i, 0, pmax) {
    auto cnt = 0;
    for (auto x : a)
      { cnt += (x >> i) & 1; }
    is_even.at(i) = (cnt % 2 == 0);
  }
  std::vector< lint > b(n);
  rep(i, 0, n) {
    auto x = a.at(i);
    auto y = 0LL;
    for (auto i = 0; i < pmax; i++) {
      if (is_even.at(i))
        { y += x & (1LL << i); }
    }
    b.at(i) = y;
  }
  b = right_norm(b, pmax);
  auto x = std::accumulate(all(b), 0LL, [](auto acc, auto x){ return acc ^ x; });
  auto y = std::accumulate(all(a), 0LL, [](auto acc, auto x){ return acc ^ x; });
  auto ret = x * 2 + y;
  std::cout << ret << std::endl;
  return 0;
}


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

 
int main() {
  string s;
  cin >> s;
  if (s[s.size()-1] == 's'){
    cout << s + "es" << endl;   
  } else {
    cout << s + "s" << endl;   
  }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
#define db(a) cout << fixed << #a << " = " << a << endl;

using namespace std;

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

void solve() {
	ll N, M, K;
	cin >> N >> M >> K;
	ll A[N];
	ll B[M];
	for (int i = 0; i < N; i++) cin >> A[i];
	for (int i = 0; i < M; i++) cin >> B[i];
	ll PA[N + 1];
	ll PB[M + 1];
	PA[0] = 0;
	PB[0] = 0;
	for (int i = 1; i <= N; i++) {
		PA[i] = PA[i - 1] + A[i - 1];
	}
	for (int i = 1; i <= M; i++) {
		PB[i] = PB[i - 1] + B[i - 1];
	}
	int bi = 0;
	while (bi < M) {
		if (PB[bi + 1] <= K) bi++;
		else break;
	}
	int ai = 0;
	while (ai < N) {
		if (PA[ai + 1] + PB[bi] <= K) {
			ai++;
		} else {
			break;
		}
	}
	int ats = ai + bi;
	//cout << ats << " " << ai << " " << bi << endl;
	//db("he");
	while (bi >= 0) {
		while (ai < N) {
			//db(ai); db(bi); db(PB[ai + 1] + PB[bi]);
			if (PA[ai + 1] + PB[bi] <= K) {
				ai++;
			} else {
				break;
			}
		}
		//cout << ats << " " << ai << " " << bi << endl;
		ats = max(ats, ai + bi);
		bi--;
		
	}
	cout << ats << endl;
}

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



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

int main()
{
    long long n,d,sum=0;
    cin >> n;
    d=n;
    while (n!=0)
    {
        sum+=n%10;
        n/=10;
    }

    if(d%sum==0){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

    return 0;
}

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

typedef long long ll;

int main() {
	int n;
	cin >> n;
	int minn =  1e9 + 100;
	int maxm = 0;
	for (int i = 0; i < n; ++i) {
		int x;
		cin >> x;
		maxm = max(maxm,x);
		minn = min(minn,x);
	}
	cout << maxm - minn;
}



















Measured memory_bytes: 256
n = int(input())
alp = 'abcdefghijklmnopqrstuvwxyz'
S1 = input()
from collections import Counter
SC1 = Counter(S1)

for a in alp:
    SC1.setdefault(a, 0)

for _ in range(n-1):
    S = input()
    SC = Counter(S)
    for a in alp:
        SC.setdefault(a, 0)
        SC1[a] = min(SC1[a], SC[a])

ans = ''
for a in alp:
    ans += a*SC1[a]
print(ans)


Measured memory_bytes: 9376
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);

		int r = in.nextInt();
		int D = in.nextInt();
		int x = in.nextInt();

		
		for ( int i = 0; i < 10; i++ ) {
			x = r*x - D;
			System.out.println(x);
		}

		in.close();
	}
}

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

// 表を転置する
vector<vector<char>> transpose(vector<vector<char>>);

// '.'ばかりの行を消す
vector<vector<char>> delete_white_col(vector<vector<char>>);

int main() {
  int H, W;
  cin>>H>>W;
  
  vector<vector<char>> a(H, vector<char>(W));
  for(int i=0;i<H;i++){
    string s;
    cin >> s;
    for(int j=0;j<W;j++){
      a.at(i).at(j) = s.at(j);
    }
  }
  
  a = delete_white_col(a);
  a = transpose(a);
  a = delete_white_col(a);
  a = transpose(a);
  
  for(int i=0;i<a.size();i++){
    for(int j=0;j<a.at(0).size();j++){
      cout << a.at(i).at(j);
    }
    cout << endl;
  }
}

vector<vector<char>> transpose(vector<vector<char>> a){
  int H, W;
  H = a.size();
  W = a.at(0).size();
  
  vector<vector<char>> a1(W, vector<char>(H));
  
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      a1.at(j).at(i) = a.at(i).at(j);
    }
  }
  
  return a1;
}

vector<vector<char>> delete_white_col(vector<vector<char>> a){
  vector<vector<char>> a1;
  
  for(vector<char> vec : a){
    // vecに'#'が含まれている場合true
    bool flag = false;
    for(char x : vec){
      if(x=='#'){
        flag = true;
        break;
      }
    }
    if(flag){
      a1.push_back(vec);
    }
  }
  
  return a1;
}

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

typedef long long ll;
using namespace std;
int main()
{
  ll n,a[200010];
  cin>>n;
  ll ans=0;
  a[0]=0;
  reps(i,n+1){
    cin>>a[i];
    if(a[i-1]>a[i]){
      ans+=abs(a[i-1]-a[i]);
      a[i]=a[i-1];
    }
  }

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


Measured memory_bytes: 5100
use io::*;

fn main() {
    let input = read_string();
    let mut sc = Scanner::new(&input);
    let mut n: i64 = sc.next();
    let mut na = n.abs();
    let mut d: usize;
    let mut s: i64;
    if n > 0 {
        d = 1;
        s = 1;
        na -= s;
        while na > 0 {
            s *= 4;
            d += 2;
            na -= s;
        }
    } else if n < 0 {
        d = 2;
        s = 2;
        na -= s;
        while na > 0 {
            s *= 4;
            d += 2;
            na -= s;
        }
    } else {
        println!("0");
        return;
    }
    for i in 0..d {
        let p = 2i64.pow((d - i - 1) as u32);
        if (d-i-1) % 2 == 0 && n > (p-1)/3 {
            n -= p;
            print!("1");
        } else if (d-i-1) % 2 == 1 && n < -(p-2)/3 {
            n += p;
            print!("1");
        } else {
            print!("0");
        }
    }
    print!("\n");
}

pub mod io {
    use std;
    use std::str::FromStr;

    pub struct Scanner<'a> {
        iter: std::str::SplitWhitespace<'a>,
    }

    impl<'a> Scanner<'a> {
        pub fn new(s: &'a str) -> Scanner<'a> {
            Scanner {
                iter: s.split_whitespace(),
            }
        }

        pub fn next<T: FromStr>(&mut self) -> T {
            let s = self.iter.next().unwrap();
            if let Ok(v) = s.parse::<T>() {
                v
            } else {
                panic!("Parse error")
            }
        }

        pub fn next_vec_len<T: FromStr>(&mut self) -> Vec<T> {
            let n: usize = self.next();
            self.next_vec(n)
        }

        pub fn next_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.next()).collect()
        }

        pub fn next_mat<T: FromStr>(&mut self, w: usize, h: usize) -> Vec<Vec<T>> {
            (0..h).map(|_| self.next_vec(w)).collect()
        }

        pub fn next_vec_char(&mut self) -> Vec<char> {
            self.next::<String>().chars().collect()
        }

        pub fn next_mat_char(&mut self, n: usize) -> Vec<Vec<char>> {
            (0..n).map(|_| self.next_vec_char()).collect()
        }
    }

    pub fn read_string() -> String {
        use std::io::Read;

        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }

    pub fn read_line() -> String {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    }
}


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

namespace ConsoleApplication22
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = int.Parse(Console.ReadLine());
            var b = Console.ReadLine().Split().Select(int.Parse).ToArray();

            long sum = 0;
            foreach (var i in Enumerable.Range(0, a))
            {
                sum += b[i];
            }
            int d = 1000000;
            foreach (var i in Enumerable.Range(0, a))
            {
                if (d > b[i])
                {
                    d = b[i];
                }
            }
            int e = -1000000;
            foreach (var i in Enumerable.Range(0, a))
            {
                if (e < b[i])
                {
                    e = b[i];
                }
            }
            Console.WriteLine("{0} {1} {2}", d, e, sum);
        }
    }
}

Measured memory_bytes: 10436
#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>;
using Graph = vector<vector<int>>;

int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<P>> g(n, vector<P>());
  for(int i = 0; i < m; ++i){
    int p, y;
    cin >> p >> y;
    g[p-1].push_back(P(y, i));
  }

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

  vector<pair<int, string>> snumber;
  for(int i = 0; i < n; ++i){
    int j = 0;
    for(auto itr : g[i]){
      char str[13] = {};
      sprintf(str, "%06d%06d", i+1, j+1);
      string s = string(str);
      snumber.push_back(pair<int, string>(itr.second, s));
      ++j;
    }
  }

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

  for(auto itr : snumber){
    cout << itr.second << endl;
  }
  
  return 0;
}


Measured memory_bytes: 13168
H,N=map(int,input().split())
A=[0]*N
B=[0]*N
for i in range(N):
  A[i],B[i]=map(int,input().split())

INF=10**9
dp=[INF]*(H+max(A))
# dp[x]:xダメージを与えるための最小魔力
dp[0]=0
for i in range(N):
  for j in range(H):
    if dp[j]!=INF:
      if dp[j+A[i]]>dp[j]+B[i]:
        dp[j+A[i]]=dp[j]+B[i]
print(min(dp[H:]))


Measured memory_bytes: 42220
import java.util.Scanner;

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

        int[] cities = new int[N];
        for(int i=0; i<M; i++) {
            cities[sc.nextInt()-1]++;
            cities[sc.nextInt()-1]++;
        }

        for(int i: cities) {
            System.out.println(i);
        }
    }
}


Measured memory_bytes: 21844
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)

int main(){
    int n;
    cin>>n;
    vector<int> v(n);
    rep(i,n)cin>>v[i];
    sort(all(v),greater<int>());
    
    int a=0,b=0;
    rep(i,v.size()){
        if(i%2)a+=v[i];
        else b+=v[i];
    }
    
    cout<<b-a<<endl;
}


Measured memory_bytes: 256
X = int(input())

if 400 <= X and X <= 599:
    print(8)
elif X <= 799:
    print(7)
elif X <= 999:
    print(6)
elif X <= 1199:
    print(5)
elif X <= 1399:
    print(4)
elif X <= 1599:
    print(3)
elif X <= 1799:
    print(2)
elif X <=1999:
    print(1)


Measured memory_bytes: 9172
n=int(input())
s=input()
R=[]
G=[]
B=[]
def f():
  for i in range(n):
    if s[i]=="R":
      R.append(i)
    elif s[i]=="G":
      G.append(i)
    else:
      B.append(i)
  r=len(R)
  g=len(G)
  b=len(B)
  if r==0 or g==0 or b==0:
    return 0
  else:
    ans=r*g*b
    m=0
    for j in range(1,n-1):
      for k in range(1,min(j,n-1-j)+1):
        lt=s[j-k]
        md=s[j]
        rt=s[j+k]
        if lt!=md and md!=rt and rt!=lt:
          m+=1
    return ans-m
print(f())

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

int main(){
    int x,y,r,w;
    scanf("%d %d\n", &x, &y);
    if(x<y){
        w = x;
        x = y;
        y = w;
    }
    
    r = x%y;
    
    while(r!=0){
        x = y;
        y = r;
        r = x%y;
    }
    
    printf("%d\n", y);
    
    return 0;
}



Measured memory_bytes: 2048
from fractions import gcd

n = int(input())
a = [int(i) for i in input().split()]

l = [0]
r = [0]
for i in range(n-1):
    l.append(gcd(l[i],a[i]))
    r.append(gcd(r[i],a[-1-i]))

m = 0
for i in range(n):
    m = max(m,gcd(l[i],r[-i-1]))

print(m)

Measured memory_bytes: 16132
// package app;

import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        java.util.Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if ((a*b)%2 == 0)
            System.out.println("Even");
        else
            System.out.println("Odd");
        }
}

Measured memory_bytes: 21204
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        char s[] = scan.next().toCharArray();
        if ((s[0] == s[1] && s[1] == s[2]) || (s[3] == s[2] && s[1] == s[2])) System.out.println("Yes");
        else System.out.println("No");
    }
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define all(cont) cont.begin(), cont.end()
#define foreach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define fore(i,a,b) for(int i=a,almo5t=b;i<almo5t;++i)
#define SZ(x) ((int)x.size())
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define FIN std::ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

const int N = 0;

typedef long long int ll;

using namespace std;

int main(){
    string s;cin>>s;
    int alphabet[28];
    std::fill_n(alphabet,28,0);
    bool posible = true;
    fore(i,0,SZ(s)){
        alphabet[s[i]-97]++;
        if(alphabet[s[i]-97] == 2){
            posible = false;
            break;
        }
    }
    if(posible){
        cout<<"yes";
    }else{
        cout<<"no";
    }
	return 0;
}

Measured memory_bytes: 256