akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;

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

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

const ll INF = (1LL<<40);
const int MAX_V = 200100;

vector<ll> dp(MAX_V, INF);
vector<ll> ans(MAX_V, 0);
vector<ll> a(MAX_V, 0);

vector<vector<int>> to(MAX_V, vector<int>(0));

void dfs(int v, int p = -1){

  int ind = lower_bound(dp.begin(), dp.end(), a[v]) - dp.begin();
  ll pre_val = dp[ind];
  dp[ind] = a[v];

  ans[v] = int(lower_bound(dp.begin(), dp.end(), INF) - dp.begin())-1;

  for(auto nv : to[v]){
    if(nv == p) continue;

    dfs(nv, v);

  }

  dp[ind] = pre_val;

}

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

  int n;
  cin >> n;

  rep(i, n) cin >> a[i];

  rep(i, n-1){
    int u, v;
    cin >> u >> v;
    --u;
    --v;

    to[u].push_back(v);
    to[v].push_back(u);

  }
  dp[0] = -INF;

  dfs(0);

  rep(i, n){
    cout << ans[i] << endl;
  }
  
  return 0;
}


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

using namespace std;

#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

signed main(){

	lli n;
	cin>>n;

	map<string,lli> ans;
	for(lli i=0;i<n;i++){
		string s;
		cin>>s;

		//ここで受け取った文字列sを辞書順最小にソートする
		sort(s.begin(),s.end());
		//ここで受け取った文字列sを辞書順最小にソートする

		ans[s]++;
	}
	lli sum = 0;

  for(map<string,long long int>::iterator e=ans.begin();e!=ans.end();++e){
		lli tmp = e->second*(e->second-1)/2;
		sum += tmp;
	}
	cout<<sum<<endl;

	return 0;
}


Measured memory_bytes: 11136
//package src;

import java.util.Scanner;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.StringBuilder;
import java.math.BigInteger;

public class Main {
	static Scanner scn = new Scanner(System.in);
	static ArrayList<Integer> adj[];
	static int mod = 1000000007;

	public static void main(String[] args) {

		int h = scn.nextInt(), w = scn.nextInt();
		char arr[][] = new char[h][w];
		for(int i=0;i<h;i++)
		{
			String str=scn.next();
			arr[i]=str.toCharArray();
		}
		long memo[][]=new long[h][w];
		for(int i=0;i<h;i++)
		{
			for(int j=0;j<w;j++)
			{
				memo[i][j]=-1;
			}
		}
		System.out.println(countpath(arr, 0, 0, h, w,memo));

	}

	public static long countpath(char arr[][], int i, int j, int h, int w,long memo[][]) {
		if (i == h-1 && j == w-1) 
			return 1;
		if(i>=h||j>=w||arr[i][j]=='#')
			return 0;
		if(memo[i][j]!=-1)
			return memo[i][j];
		long a = 0, b = 0;
		if (arr[i][j] == '.') {
			a = (countpath(arr, i + 1, j, h, w,memo)) % mod;
			b = (countpath(arr, i, j + 1, h, w,memo)) % mod;
			memo[i][j]=(a+b)%mod;
		}

		return (a + b) % mod;

	}

	public static String binary(long n) {
		StringBuilder sb = new StringBuilder();
		while (n != 0) {
			sb.append(n % 2);
			n /= 2;
		}
		sb.reverse();
		return sb.toString();
	}

	public static long gcd(long a, long b) {
		if (a == 0)
			return b;
		return gcd(b % a, a);
	}

	public static String factorial(int n) {
		BigInteger fac = new BigInteger("1");
		for (int i = 1; i <= n; i++) {
			fac = fac.multiply(BigInteger.valueOf(i));
		}
		return fac.toString();
	}

}

class pair {
	int a;
	int b;
	int c;

	pair(int x, int y, int z) {
		this.a = x;
		this.b = y;
		this.c = z;
	}
}

class sorting implements Comparator<pair> {

	@Override
	public int compare(pair o1, pair o2) {
		// TODO Auto-generated method stub
		int dif = o1.b - o2.b, str = o1.a - o2.a;
		if (dif == 0) {
			if (str < 0)
				return -1;
			else
				return 1;

		} else if (dif < 0) {
			return -1;
		} else
			return 1;
	}

}


Measured memory_bytes: 49416
#include <stdio.h>
int main()
{
    long long int  n1, n2, i,gcd,lcm;
    scanf("%lld %lld", &n1, &n2);
    for (i = 1; i <= n1 && i <= n2; ++i)
    {

        if (n1 % i == 0 && n2 % i == 0)
            gcd = i;
    }
    lcm = (n1 * n2) / gcd;
    printf("%lld\n",lcm);
    return 0;
}


Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include<iostream>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<string>
#include<set>
#include<map>
#include<stdbool.h>
#include<math.h>
#include<sstream>
#include<math.h>
#include<vector>
#include<functional>
#include<queue>
#include<utility>
#include<bitset>
typedef long long ll;
#define N (1000000000+7)
#define INF 1e10
#define Length 80000
using namespace std;
typedef pair<ll, ll> P;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

bool used[110];

bool cmp(const pair<int,int> &a,const pair<int,int> &b) {
	return a.first * a.first + a.second * a.second > b.first*b.first + b.second * b.second;
}

void solve(int n) {
	vector<pair<int, int>>p(n), q(n);
	for (int i = 0;i < n;i++) {
		cin >> p[i].first >> p[i].second;
	}
	for (int i = 0;i < n;i++) {
		cin >> q[i].first >> q[i].second;
	}
	int dist = Length, flag = 0;
	int ans = 0;
	sort(p.begin(), p.end());
	for (int i = 0;i < n;i++) {
		dist = Length;
		flag = 0;
		for (int j = 0;j < n;j++) {
			if (!used[j]) {
				int x = q[j].first - p[i].first;
				int y = q[j].second - p[i].second;
				if ((x > 0) && (y > 0) && y < dist) {
					dist = y;
					flag = j;
				}
			}
		}
		if (dist < Length) {
			ans++;
			used[flag] = true;
		}
	}
	cout << ans << endl;
}

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

ll rightvalue[100010];
ll leftvalue[100010];
ll rightmaxvalue1[100010];
ll leftmaxvalue1[100010];

int ans[110];
bool flag[110] = { false };

int main(void){
	int n, num = 0, tmp = 0, index = 0;
	bool can = false;
	cin >> n;
	vector<int>a(n + 1);
	for (int i = 1;i <= n;i++) {
		cin >> a[i];
		if (a[i] > i)can = true;
	}
	if (can) {
		cout << -1 << endl;
		return 0;
	}
	for (int i = 1;i <= n;i++) {
		num = 1;
		for (int j = 1;j <= n;j++) {
			if (!flag[j]) {
				if (a[j] == num) {
					tmp = num;
					index = j;
					num++;
				}
				else num++;
			}
		}
		ans[n - i + 1] = tmp;
		flag[index] = true;
	}
	for (int i = 1;i <= n;i++)cout << ans[i] << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(int i = 0; i < x; i++)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

int main(){
    ll n; cin >> n;
    vector<P> vec;
    rep(i,n){
        ll temp; cin >> temp;
        vec.push_back(P(temp,i+1));
    }
    sort(vec.begin(), vec.end());
    rep(i,n){
        cout << vec[i].second << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1780
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

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

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

    if(a == b && b == c){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 888
// WIP

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

// Utility
#define ALL(X) (X).begin(), (X).end()
#define FOR(I, X, Y) for (int I = (X); I < (Y); I++)
using ll = int64_t;
using ull = uint64_t;
template<typename T> struct is_container {
template<typename C> static char test(typename C::const_iterator*); template<typename> static int test(...);
static bool const value = sizeof(test<T>(nullptr)) == sizeof(char) && !std::is_same<std::string, T>::value;
};
namespace std {
template<class ...Ts>        istream& operator>>(istream& i, tuple<Ts...>& x) { apply([&](auto&&... ys){ ((i >> ys), ...); }, x); return i; }
template<class T1, class T2> istream& operator>>(istream& i, pair<T1, T2>& x) { i >> x.first >> x.second; return i; }
template<class T, enable_if_t<is_container<T>::value, int> = 0>
istream& operator>>(istream& i, T& x) { for (auto& y : x) { i >> y; } return i; }
}

// Debugging
#ifndef DEBUG
#define DEBUG 0
#endif
#define dbg(X) do { if (DEBUG) { cout << #X ": " << (X) << endl << flush; } } while (0)
#define dbg2(X) do { if (DEBUG) { cout << #X ":" << endl; for (auto& __x : (X)) { cout << __x << endl << flush; } } } while (0)
#define dbgv(...) do { if (DEBUG) { cout << "(" #__VA_ARGS__ "): " << make_tuple(__VA_ARGS__) << endl << flush; } } while (0)
namespace std {
template<class ...Ts>        ostream& operator<<(ostream& o, const tuple<Ts...>& x) { o << "("; apply([&](auto&& y, auto&&... ys){ o << y; ((o << ", " << ys), ...); }, x); o << ")"; return o; }
template<class T1, class T2> ostream& operator<<(ostream& o, const pair<T1, T2>& x) { o << tie(x.first, x.second); return o; }
template<class T, enable_if_t<is_container<T>::value, int> = 0>
ostream& operator<<(ostream& o, const T& x) { o << "{"; for (auto it = x.begin(); it != x.end(); it++) { if (it != x.begin()) { o << ", "; } o << *it; } o << "}"; return o; }
}

// Main
void mainCase() {
  int k, a, b;
  cin >> k >> a >> b;
  bool res = ((a + (k - 1)) / k) * k <= b;
  cout << (res ? "OK" : "NG") << endl;
}

int main() {
  ios_base::sync_with_stdio(0); cin.tie(0);
  mainCase();
  return 0;
}

/*
python misc/run.py atcoder/abc165/a/main.cpp --check

%%%% begin
7
500 600
%%%%
OK
%%%% end
*/


Measured memory_bytes: 3548
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <cstdint>
#include <unordered_set>
#include <ctime>
#include <numeric>
#include <cstdint>

using llint = long long int;
using u64 = std::uint_fast64_t;

void solve(void){

  llint k;
  std::cin >> k;

  std::vector<bool> mod_lst(k, false);

  llint num = 7;
  llint cnt = 1;
  while(true){
    num %= k;
    if(num==0){
      std::cout << cnt << std::endl;
      return;
    }

    if(mod_lst[num]){
      std::cout << -1 << std::endl;
      return;
    }
    mod_lst[num] = true;
    num = num*10 + 7;
    cnt++;
  }

}
int main(void){
  solve();
  return 0;
}





Measured memory_bytes: 3720
<?php
fscanf(STDIN, "%d", $N);
$V = explode(" ", trim(fgets(STDIN)));
$C = explode(" ", trim(fgets(STDIN)));
$ans = 0;
for ($i = 0; $i < $N; $i++) {
    if ($V[$i] > $C[$i]) {
        $ans += $V[$i] - $C[$i];
    }
}
echo $ans;


Measured memory_bytes: 4604
import java.util.*;

class Main{
    Main(){
        Scanner SC = new Scanner(System.in);

        int A = Integer.parseInt(SC.next());
        int B = Integer.parseInt(SC.next());

        int left  = -1;
        int right = 1500;
        while(right-left>1){
            int mid = left + (right - left)/2;
            int tax = (int)( ((double)mid) * 0.08);

            if(tax >= A){
                right = mid;
            } else {
                left = mid;
            }
        }

        while(true){
            int tax = (int)(((double)right)*0.08);
            if(tax != A){
                System.out.println("-1");
                return;
            }

            tax = (int)(((double)right)*0.1);
            if(B == tax){
                System.out.println(right);
                return;
            }
            right++;
        }

    }

    public static void main(String[] args){
        Main main = new Main();
    }
}


Measured memory_bytes: 23892
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;i++)
using namespace std;

typedef long long ll;

const int maxn=200500;

int n,d[maxn],p[12];
ll c[maxn],cnt[12];

ll get(ll x){
	ll res=0;
    while (x) res+=x%10,x/=10;
    return res;
}

int main(){
	scanf("%d",&n);
	rep(i,1,n) scanf("%d %lld",&d[i],&c[i]);
	
	rep(i,0,9)
	{
		int now=i;
		do{
			now+=i;
			p[i]++;
			for(cnt[i]++; now>=10; now=(now/10)+(now%10)) cnt[i]++;
		} while (now!=i);
	}
	
	ll ans=0, now=0;
	rep(i,1,n) {
        if (c[i]<=p[d[i]]) continue;
		ans+=(c[i]-1)/p[d[i]]*cnt[d[i]];
		c[i]=(c[i]-1)%p[d[i]]+1;
	}
	rep(i,1,n)
		rep(j,1,c[i]) {
			now+=d[i];
			for(ans++; now>=10; now=(now/10)+(now%10)) ans++;
		}
	ans--;
	
	printf("%lld\n",ans);
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long LL;
typedef long double LD;


LL mod = 1000000007;

int main()
{
	LL h, a;
	cin >> h >> a;

	cout << (h/a)+(h%a ? 1 : 0) << "\n";

	
}

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

using ll = long long int;

int main() {

	ll n, a, b;
	cin >> n >> a >> b;

	if (a > b || (n == 1 && a != b)) {
		cout << 0 << endl;
		return 0;
	}

	cout << ((n-1)*b+a) - ((n-1)*a+b) + 1 << endl;

	return 0;
}

Measured memory_bytes: 256
N = int(input())
x,y,h = [0]*N,[0]*N,[0]*N

j = -1
for i in range(N):
    x[i],y[i],h[i] = map(int,input().split(" "))
    if h[i] !=  0:
        j = i

for cx in range(0,101):
    for cy in range(0,101):
        H = h[j] + abs(x[j]-cx) + abs(y[j]-cy)
        flg = True
        for i in range(N):
            if (h[i] == 0 and ((abs(x[i]-cx) + abs(y[i]-cy))) < H):
                flg = False
                break
            if (h[i] != 0 and H != (h[i] + abs(x[i]-cx) + abs(y[i]-cy))):
                flg = False
                break
        if flg:
            print("{0} {1} {2}".format(cx,cy,H))
            exit(0)


Measured memory_bytes: 43248
#include<cmath>
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cstdio>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define fori(i,k,n) for(int i=k;i<n;i++)
using namespace std;
const int dx[4] = { 0, 1, 0, -1 }, dy[4] = { 1, 0, -1, 0 };
const int dX[8] = { 0, 1, 1, 1, 0, -1, -1, -1 }, dY[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };



int main()
{
	int n, m;
	cin >> n >> m;
	while (n || m)
	{
		int a[120] = {}; int x = 0;
		int l[120] = {}; int y = 0;
		for (int i = 0; i < n; i++)
		{
			cin >> a[i];
			x += a[i];

		}
		rep(i, m)
		{
			cin >> l[i];
			y += l[i];
		}
		int an = 99999;
		int X, Y;
		rep(i, n)
		{
			rep(k, m)
			{
				if (x + l[k]-a[i] == y + a[i]-l[k])
				{
					if (an>l[k] + a[i])
					{
						an = l[k] + a[i];
						X = a[i];
						Y = l[k];
					}
				}
			}

		}
		if (an == 99999)cout << -1 << endl;
		else cout << X <<" "<< Y << endl;


		cin >> n >> m;

	}
	return 0;
}

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

    long long s[3], smin1, smin2, tmp, ans = INT_MAX;
    for(int i = 1; i <= h; i++){
        s[0] = i * w;
        s[1] = ((h - i) / 2) * w;
        if((h-i)%2==0){
            s[2] = s[1];
        }
        else{
            s[2] = ((h - i) / 2 + 1) * w;
        }
        sort(s, s+3);
        smin1 = s[2] - s[0];

        s[0] = i * w;
        s[1] = (h - i) * (w / 2);
        if(w%2==0){
            s[2] = s[1];
        }
        else{
            s[2] = (h - i) * (w / 2 + 1);
        }
        sort(s, s+3);
        smin2 = s[2] - s[0];

        tmp = min(smin1, smin2);
        ans = min(ans, tmp);
    }

    for(int i = 1; i <= w; i++){
        s[0] = i * h;
        s[1] = ((w - i) / 2) * h;
        if((w-i)%2==0){
            s[2] = s[1];
        }
        else{
            s[2] = ((w - i) / 2 + 1) * h;
        }
        sort(s, s+3);
        smin1 = s[2] - s[0];

        s[0] = i * h;
        s[1] = (w - i) * (h / 2);
        if(h%2==0){
            s[2] = s[1];
        }
        else{
            s[2] = (w - i) * (h / 2 + 1);
        }
        sort(s, s+3);
        smin2 = s[2] - s[0];

        tmp = min(smin1, smin2);
        ans = min(ans, tmp);
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include<vector>

using namespace std;
typedef long long ll;
//#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i =0;i<n;++i)
//#define mod (ll)(1e9+7)

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int num[4];
    num[0] = n/1000;
    n%=1000;
    num[1] = n/100;
    n%=100;
    num[2] = n/10;
    num[3] = n%10;
    for(int i = 0;i<8;i++){
        int tmp = num[0];
        for(int j=0;j<3;j++){
            if((i>>j)&1==1) tmp+= num[j+1];
            else tmp-=num[j+1];
        }
        if(tmp==7){
            cout << num[0];
            for(int j=0;j<3;j++){
                if((i>>j)&1==1) cout << "+" << num[j+1];
                else cout << "-" << num[j+1];
            }
            cout << "=7\n";
            return 0;
        }
    }  

    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/python3

import sys

def dprint(*args):
    pass
    #print(*args)

def solve(s_str):
    ans = 0
    s_len = len(s_str)
    for bits in range(0, 1 << (s_len - 1)):
        dprint("bits: {0:b}".format(bits))
        rev_str = list(reversed(s_str))
        #dprint(f"rev_str: {rev_str}")
        cur_num_rev_str = ""
        # 12345
        for rev_i in range(0, s_len):
            dprint("rev_i: %d" % rev_i)
            plus_index = rev_i
            cur_num_rev_str += rev_str[0]
            rev_str = rev_str[1:]
            dprint("cur_num_rev_str: %s" % cur_num_rev_str)
            if rev_i == s_len - 1 or bits & (1 << plus_index):
                ans += int(''.join(list(reversed(cur_num_rev_str))))
                cur_num_rev_str = ""
        if cur_num_rev_str != "":
            #dprint(f"ans: {ans}")
            ans += int(''.join(list(reversed(cur_num_rev_str))))
    return ans

def main():
    s_str = sys.stdin.read().rstrip()
    dprint(s_str)
    print(solve(s_str))

main()

Measured memory_bytes: 3064
#define TEMPLATE_USED
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) for(ll i=0;i<(n);++i)
#define _rep3(i,a,b) for(ll i=(ll)(a);i<(ll)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2)(__VA_ARGS__)
#define _repe2(i,n) for(ll i=0;i<=(ll)(n);++i)
#define _repe3(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);++i)
#define repe(...) _overload3(__VA_ARGS__,_repe3,_repe2)(__VA_ARGS__)
#define _rrep2(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define _rrep3(i,a,b) for(ll i=(ll)(b)-1;i>=(ll)(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2)(__VA_ARGS__)
#define _rrepe2(i,n) for(ll i=(ll)(n);i>=0;i--)
#define _rrepe3(i,a,b) for(ll i=(ll)(b);i>=(ll)(a);i--)
#define rrepe(...) _overload3(__VA_ARGS__,_rrepe3,_rrepe2)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
template<class T>
bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>
bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
template<class T>
using pq=priority_queue<T,vector<T>,greater<T>>;

void solve();

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

void solve(){
    ll n,x;cin>>n>>x;
    vl a(n);rep(i,n)cin>>a[i];

    ll ans=0;
    rep(i,1,n){
        if(a[i-1]+a[i]<=x)continue;
        ans+=a[i-1]+a[i]-x;
        a[i]=max(0LL,x-a[i-1]);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ENDL '\n'
#define print(i) std::cout << (i) << '\n'

#define int long long // at least int64 > 9*10^18
#define all(v) (v).begin(), (v).end()
/* libraries */

signed main() {
	int n,m;
	std::cin >> n >> m;
	std::vector<std::vector<int> > a(n,std::vector<int> (m));
	rep(i,n) rep(j,m) std::cin >> a[i][j];

	int min = 999;
	std::set<int> set;
	rep(i,m) set.emplace(i+1);
	rep(i,m) {
		std::vector<std::vector<int> > b(n,std::vector<int>());
		rep(x,n) rep(y,m) if(set.count(a[x][y])) b[x].emplace_back(a[x][y]);
		std::map<int,int> map;
		rep(i,n) map[b[i][0]]++;
		int max = 0;
		int maxi = 0;
		for(auto x:map) if(max<x.second) {
			max=x.second;
			maxi=x.first;
		}
		min = std::min(min,max);
		set.erase(maxi);
	}
	print(min);
	return 0;
}


Measured memory_bytes: 2248
#include<queue>
#include<math.h>
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#define inf 1<<30
#define ll long long
#define db double
#define c233 cout<<"233"<<endl
#define mem(s) memset(s,0,sizeof(s))
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
const int N=10050;
using namespace std;

struct lll{
  int x,y;
}p[N];
struct hhh{
  int a,b;
  db len;
}e[N*10];
int fa[N];
int n,m;
db sum,mst;

void fre(){
  freopen("in","r",stdin);
  freopen("out","w",stdout);
}

inline int gi(){
  int x=0,res=1;char ch=getchar();
  while(ch>'9'||ch<'0'){if(ch=='-')res*=-1;ch=getchar();}
  while(ch<='9'&&ch>='0')x=(x<<1)+(x<<3)+ch-48,ch=getchar();
  return x*res;
}

db len(lll x,lll y){
  return sqrt((1.0*(x.x-y.x)*(x.x-y.x)+1.0*(x.y-y.y)*(x.y-y.y)));
}

void init(){
  n=gi();m=gi();
  for(int i=1;i<=n;i++)
    p[i].x=gi(),p[i].y=gi();
  for(int i=1;i<=m;i++){
    e[i].a=gi(),e[i].b=gi();
    e[i].len=len(p[e[i].a],p[e[i].b]);
    sum+=e[i].len;
  }
}

int getfa(int x){
  return fa[x]==x?fa[x]:fa[x]=getfa(fa[x]);
}

void merge(int a,int b){
  int f1=getfa(a),f2=getfa(b);
  fa[f1]=f2;
}

void work(){
  for(int i=1;i<=n;i++)fa[i]=i;
  for(int i=1;i<=m;i++){
    if(getfa(e[i].a)!=getfa(e[i].b))
      merge(e[i].a,e[i].b),mst+=e[i].len;
  }
  printf("%.3lf\n",sum-mst);
}

bool mmp(hhh x,hhh y){
  return x.len>y.len;
}

int main(){
  //fre();
  init();
  sort(e+1,e+1+m,mmp);
  work();
  return 0;
}

Measured memory_bytes: 3756
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 100000000000000009
#define MOD 1000000007
#define int long long
using P = pair<int,int>;
signed main(){
  int n,k;
  cin >> n >> k;
  int ans = 0;
  rep(i,n){
    int x;
    cin >> x;
    ans += min(x,k-x)*2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int h,w;
  scanf("%d %d\n",&h,&w);
  char str[h][w];
  int i,j;
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
       scanf("%c\n",&str[i][j]);
    }
    scanf("\n");
  }
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      printf("%c",str[i][j]);
    }
    printf("\n");
    for(j=0;j<w;j++){
      printf("%c",str[i][j]);
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 1612
#include "bits/stdc++.h"

#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,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(i, (v).size()) { cout << v[i]; if (i != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

const int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
const int dy[8] = { 0,1,1,1,0,-1,-1,-1 };


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
///(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)///
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a, b, c;
	cin >> a >> b >> c;
	if (b - a == c - b)cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>
#include <regex>
#include <random>
#include <cassert>
#include <stack>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define revrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define revrepr(i, s, n) for (int i = (n) - 1; i >= s; i--)
#define debug(x) cerr << #x << ": " << x << "\n"
#define popcnt(x) __builtin_popcount(x)

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

template<class T>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

template<class T, class U>
ostream& operator <<(ostream &os, pair<T, U> p) {
    cout << '(' << p.first << ", " << p.second << ')';
    return os;
}

template<class T>
void print(const vector<T> &v, const string &delimiter) { rep(i, v.size()) cout << (0 < i ? delimiter : "") << v.at(i); cout << endl; }

template<class T>
void print(const vector<vector<T>> &vv, const string &delimiter) { for (const auto &v: vv) print(v, delimiter); }

int main() {
    int n;
    cin >> n;
    vector<int> cnt(n);
    rep(i, n - 1) {
        int p;
        cin >> p;
        p--;
        cnt[p]++;
    }
    rep(i, n) cout << cnt[i] << endl;
}

Measured memory_bytes: 4052
A,B,C,K=map(int,input().split())
s=0
if A>=K:
  s+=1*K
elif A<K and K-A<=B:
  s+=1*A+0*(K-A)
elif K-A>B:
  s+=1*A+0*B+(-1)*(K-A-B)
print(s)

Measured memory_bytes: 9184
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long int
#define fi first
#define se second
#define endl "\n"
#define all(v) v.begin(),v.end()
#define fastio ios::sync_with_stdio(0); std::cin.tie(0); std::cout.tie(0)
#define go_t int t;cin>>t;for(int tt=1;tt<=t;tt++)
#define set_ar(arr,v) memset(arr,v,sizeof(arr))
#define trace2(x, y)         cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)      cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)   cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define trace5(a, b, c, d, e)cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<endl;
typedef pair<int,int>pi;
typedef pair<ll,ll>pl;
const ll inf = 0x3f3f3f3f3f3f3f3fll;//4x10e18
const int N = 300000 , mod = 1000000007;
int main()
{
    fastio;
    int n,k;
    cin>>n>>k;
    int a[n+1];
    for(int i=1;i<=n;i++)cin>>a[i];
    int cnt = 0;
    while(100)
    {
        int temp[n+2];
        set_ar(temp,0);
        for(int i=1;i<=n;i++)
        {
            int sta = max(i - a[i],1);
            int en = min(n,i+a[i]);
            temp[sta]+=1;
            temp[en+1]-=1;
        }
        for(int i=1;i<=n;i++)
        {
            temp[i]+=temp[i-1];
            a[i] = temp[i];
        }
        cnt++;
        int mn = *min_element(a+1,a+n+1);
        if(mn==n || cnt==k)break;
    }
    for(int i=1;i<=n;i++)cout<<a[i]<<" ";
    cout<<endl;
    return 0;
}

Measured memory_bytes: 5196
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX;
#define INFL LLONG_MAX;
typedef long long ll;
using namespace std;
#define PI 3.14159265358979323846

int main(){
  double ans;
  int a,b,h,m;
  cin >> a >> b >> h >> m;
  double dh,dm;
  int min = h*60+m;
  dm = 6*m;
  dh = 0.5*min;
  double degree = abs(dm-dh);
  double r = degree * PI /180.0;

  ans=a*a+b*b-2*a*b*cos(r);

  ans = sqrt(ans);

  printf("%0.11f",ans);

}

Measured memory_bytes: 4252
/*
h s, d't skp th si tll i's sved
 * ABC141 E
 * ABC145 D
 * ABC147 F
 * ABC174 F
*/
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
int main()
{
int a,b,c;
cin>>a>>b>>c;
if(a==b && b!=c)
{
cout<<"Yes"<<endl;
}
else if(a==c && c!=b)
{
cout<<"Yes"<<endl;
}
else if(b==c && c!=a)
{
cout<<"Yes"<<endl;
}
else
{
cout<<"No"<<endl;
}
}



/*
 * ||||


 */

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

using namespace std;
#define int long long
struct str{
	int num;
	int index;
}st[2200000];
bool cmp(str a,str b){
	return a.num<b.num;
}
signed main(){
	int n;cin>>n;
	for(int i=1;i<=n;i++){
		scanf("%lld",&st[i].num);
		st[i].index=i;
	}
	sort(st+1,st+1+n,cmp);
	for(int i=1;i<=n;i++){
		int j=n;
		if(st[j].index==i){
			printf("%lld\n",st[n-1].num);
		}else{
			printf("%lld\n",st[n].num);
		}
	}
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = (a); i < int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ull << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())

using namespace std;
using i32 = int;
using i64 = long long;
using f64 = double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf64 = vector<f64>;
using vstr = vector<string>;

template<typename T, typename S> void amax(T &x, S y) { if (x < y) x = y; }
template<typename T, typename S> void amin(T &x, S y) { if (y < x) x = y; }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(16);
  int n;
  string s;
  cin >> n >> s;
  vi32 w_sum(n + 1), b_sum(n + 1);
  reps(i, n) {
    w_sum[i] = w_sum[i - 1];
    b_sum[i] = b_sum[i - 1];
    if (s[i - 1] == '.') w_sum[i]++; else b_sum[i]++;
  }
  i32 ans = 1e9;
  rep(i, n + 1) {
    i32 sum = 0;
    sum += b_sum[i] - b_sum[0];
    sum += w_sum[n] - w_sum[i];
    amin(ans, sum);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2196
#include <bits/stdc++.h>
#define endl '\n'
#define N 1000001
#define mod 1e9+7
using namespace std;
typedef long long ll;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	string s1,s2;
	cin>>s1>>s2;
	ll m=s1.size(),n=s2.size();
	ll t[m+1][n+1];
	for(ll i=0;i<m+1;i++){
	    for(ll j=0;j<n+1;j++){
	        if(i==0 || j==0)
	        t[i][j]=0;
	    }
	}
	for(ll i=1;i<m+1;i++){
	    for(ll j=1;j<n+1;j++){
	        if(s1[i-1]==s2[j-1]){
	            t[i][j]=1+t[i-1][j-1];
	        }else{
	            t[i][j]=max(t[i-1][j],t[i][j-1]);
	        }
	    }
	}
	string s;
	ll i=m,j=n;
	while(i>0 && j>0){
	    if(s1[i-1]==s2[j-1]){
	        s.push_back(s1[i-1]);
	        i--;
	        j--;
	    }else{
	        if(t[i][j-1]>t[i-1][j])
	        j--;
	        else
	        i--;
	    }
	}
	reverse(s.begin(),s.end());
	cout<<s;
	return 0;
}


Measured memory_bytes: 73976
#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define co(a) cout<<a<<endl
#define sz size()
#define bgn begin()
#define en end()
#define pb(a) push_back(a)
#define pop pop_back
#define V vector
#define P pair
#define V2(a,b,c) V<V<int>> a(b,V<int>(c))
#define V2a(a,b,c,d) V<V<int>> a(b,V<int>(c,d))
#define incin(a) int a; cin>>a
#define yuko(a) setprecision(a)
//#define min min<int>
//#define max max<int>
template<class T>
 void cou(vector<vector<T>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}
/*template<>
 void cou(vector<vector<char>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}*/
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
struct Union{
  vector<int> par;
  Union(int n){
	par= vector<int>(n, -1);
  }
  int find(int x){
    if(par[x]<0)
      return x;
    else
      return par[x]=find(par[x]);
  }
  bool same(int a,int b){
    return find(a)==find(b);
  }
  int Size(int a){
    return -par[find(a)];
  }
  void unite(int a,int b){
    a=find(a);
    b=find(b);
    if(a==b)
      return;
    if(Size(b)>Size(a))
      swap<int>(a,b);
    par[a]+=par[b];
    par[b]=a;
  }
};
int ketas(int a){
  string b=to_string(a);
  int c=0;
  fo(i,keta(a)){
    c+=b[i]-'0';
  }
  return c;
}
/*struct aa{
	vector<int> gt;
  aa(int n){
	gt= vector<int>(n, 1);
  }
	void c(V<int> d,int b){
	if(d[b]==0){
		gt[d[b]-1]++;
		gt[gt.sz-1]++;
	}
	else{
		gt[d[b]-1]++;
		c(d,d[d[b]]-1);
	}
}
void cok(int a){
	cout<<gt[a-1]<<endl;
	fo(i,a-1)
	cout<<gt[i]<<endl;
}
};
*/
signed main(){
	int a;
	cin>>a;
	if(a%ketas(a)==0)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
}

Measured memory_bytes: 512
import java.util.*

fun canBeMM(lc: Char, rc: Char): Boolean {
    val l = Integer.parseInt(lc.toString())
    val r = Integer.parseInt(rc.toString())
    if (l*10 + r > 0 && 12 >= l*10 + r) {
        return true
    }
    return false
}
fun main(args: Array<String>){
	val cin = Scanner(System.`in`)
    val s = cin.next()
    val le: Boolean = canBeMM(s[0], s[1])
    val ri: Boolean = canBeMM(s[2], s[3])

    if (le && ri) {
        println("AMBIGUOUS")
    } else if (le) {
        println("MMYY")
    } else if (ri) {
        println("YYMM")
    } else {
        println("NA")
    }
}

Measured memory_bytes: 31260
a = list(input())
b = list(input())
c = list(input())


def check(p):
    if count_a == len(a) and p == 'a':
        print('A')
        exit()
    elif count_b == len(b) and p == 'b':
        print('B')
        exit()
    elif count_c == len(c) and p == 'c':
        print('C')
        exit()


count_a = 0
count_b = 0
count_c = 0
next = a[count_a]
count_a += 1
for i in range(300):
    if next == 'a':
        check('a')
        next = a[count_a]
        count_a += 1
    elif next == 'b':
        check('b')
        next = b[count_b]
        count_b += 1
    elif next == 'c':
        check('c')
        next = c[count_c]
        count_c += 1


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


int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if(a == b) cout << c << endl;
  else if(b == c) cout << a << endl;
  else cout << b << 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;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, a, b, c, d, e;
    vector<ll> ts(5);
    cin >> n;
    REP(i, 5) cin >> ts[i];
    sort(ts.begin(), ts.end());

    if (n <= ts[0]) cout << 5 << '\n';
    else {
        if (n % ts[0]) cout << 5 + (n / ts[0]) << '\n';
        else cout << 5 + (n / ts[0]) - 1 << '\n';
    }
    return 0;
}


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

using namespace std;
int main(){
    string S,T;
    int cnt;
    
    cin >> S >> T;
    cnt =0;
    for(int i = 0; i < 3;i++){ 
        if(S[i]==T[i]) cnt++;
        
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int a,b,c,t;
	
	while(1){
		scanf("%d %d",&a,&b);
		if((a==0)&&(b==0)){
			return 0;
		}
		if(a<b){
			c=a;a=b;b=c;
		}
		for(t=0;b!=0;t++){
			a=a%b;
			c=a;a=b;b=c;
		}
		printf("%d %d\n",a,t);
	}
}

Measured memory_bytes: 600
// https://atcoder.jp/contests/abcXXX/tasks/abcXXX_x

#include <iostream>
#include <vector>
#include <tuple>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using pll = pair<ll, ll>;

static const ll INF = 1001001001;
static const ll LLINF = 1001001001001001001;

#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define RANGE(i, m, n) for(ll i = (m); i <= (n); ++i)
#define RRANGE(i, m, n) for(ll i = (m); i >= (n); --i)
#define POSITIVE(x) (x)=((x) < 0) ? 0 : (x)

ll pow(ll x, ll y) {
    ll ret = 1;
    while(y-- > 1) ret *= x;
    return ret;
}

ll gcd(ll x, ll y) {
    if (x < y) swap(x, y);
    if (y == 0) return x;
    ll r = x / y;
    return gcd(y, x-y*r);
}

int run(istream& in, ostream& out) {
    ll A, B, C;
    in >> A >> B >> C;
    if (B < A) swap(A,B);
    if (C < B) swap(B,C);
    if (B < A) swap(A,B);
    if ((A == B && B != C) || (B == C && A != B)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


int main() {
    return run(cin, cout);
}


Measured memory_bytes: 256
class SegmentTree
  def initialize(n)
    @sz=2**(Math.log(n)/Math.log(2)).ceil
    @seg=Array.new(2*@sz-1){0}
    @root=0
    @nil=0
  end

  attr_accessor :seg

  def max(a, b, i=@root, l=0, r=@sz)
    if b<=l or r<=a
      @nil
    elsif a<=l and r<=b
      @seg[i]
    else
      m=(r+l)/2
      vl=max(a, b, 2*i+1, l, m)
      vr=max(a, b, 2*i+2, m, r)
      [vl, vr].max
    end
  end

  def update(i, data)
    i+=@sz-1
    @seg[i]=data
    while i.nonzero?
      i=(i-1)/2
      @seg[i]=[@seg[2*i+1], @seg[2*i+2]].max
    end
  end

  def answer
    @seg[@root]
  end
end

Poyo=Struct.new(:val, :id)

n=gets.to_i
a=[]
n.times do |i|
  v=gets.to_i
  a<< Poyo.new(v, i)
end

b=a.sort do |el, er|
  el.val!=er.val ? el.val<=>er.val : er.id<=>el.id
end

st=SegmentTree.new(n)
b.each do |e|
  i=e.id
  st.update(i, st.max(0, i+1)+1)
end

puts st.answer

Measured memory_bytes: 19376
import java.util.Scanner;

class Main
{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		
		double r = scan.nextDouble();
		
		double men = r * r * Math.PI;
		double enn = 2 * r * Math.PI;
		
		System.out.println(String.format("%.6f", men)+" "+String.format("%.6f", enn));
	}
}


Measured memory_bytes: 28252
#include <iostream>
#include <vector>
#include <bits/stdc++.h>

using namespace std;

vector<int> dist;

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

    return gcd(b%a, a);
}

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

    for (int i=0; i<n; i++)
    {
        int a;
        cin >> a;
        dist.push_back(abs(a-x));
    }
    int g=dist[0];
    for (int i=0; i<n; i++)
    {
        g = gcd(g, dist[i]);
    }
    cout << g << "\n";
    return 0;
}


Measured memory_bytes: 892
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	int N, X, Y, Z; cin >> N >> X >> Y >> Z;
	vector<int> dp(1<<18);
	dp[1] = 1;
	int mask = (1<<18) - 1, ans = 1;
	while (N--) {
		vector<int> _dp(1<<18);
		for (int S = 0; S < 1<<18; S++)
			for (int x = 1; x <= 10; x++) {
				int _S = (S<<x & mask) + 1;
				_dp[_S] += dp[S];
				if (_dp[_S] >= MOD) _dp[_S] -= MOD;
			}
		dp = _dp;
		for (int S = 0; S < 1<<18; S++)
			if (S>>0 & 1)
				if (S>>Z & 1)
					if (S>>(Y+Z) & 1)
						if (S>>(X+Y+Z) & 1)
							dp[S] = 0;
		ans = (ll)ans * 10 % MOD;
	}
	for (int S = 0; S < 1<<18; S++)
		ans = (ans - dp[S]) % MOD;
	cout << (ans + MOD) % MOD << endl;
}


Measured memory_bytes: 2304
local h, w = io.read("*n", "*n")
local a, b = io.read("*n", "*n")
for i = 1, b do
  for j = 1, a do
    io.write(0)
  end
  for j = a + 1, w do
    io.write(1)
  end
  io.write("\n")
end
for i = b + 1, h do
  for j = 1, a do
    io.write(1)
  end
  for j = a + 1, w do
    io.write(0)
  end
  io.write("\n")
end


Measured memory_bytes: 1272
#include<bits/stdc++.h>
using namespace std;
long long dp[3][100010];

int main(void){
    int n;
    cin >> n;
    vector<long long> a(n+10), b(n+10), c(n+10);
    for(int i=1;i<=n;++i) cin >> a[i] >> b[i] >> c[i];
    for(int i=0;i<3;++i) for(int j=0;j<100010;++j) dp[i][j] = 0;
    dp[0][0] = 0;
    dp[1][0] = 0;
    dp[2][0] = 0;
    for(int i=1;i<=n;++i){
        dp[0][i] = max(dp[1][i-1] + a[i], dp[2][i-1] + a[i]);
        dp[1][i] = max(dp[0][i-1] + b[i], dp[2][i-1] + b[i]);
        dp[2][i] = max(dp[0][i-1] + c[i], dp[1][i-1] + c[i]);
    }
    cout << max(dp[0][n], max(dp[1][n], dp[2][n])) << endl;
}

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

void fnInput(int& rnLeft, int& rnRigt)
{
  cin >> rnLeft >> rnRigt;
}
  
int fnRemainMin2019(int nLeft, int nRigt)
{
  if (nLeft + 2018 < nRigt) return 0;          // 2019 で割り切れる数が存在

  int nRemMin2019 = 2018;

  for (int i = nLeft; i < nRigt; i++)
    for (int j = i + 1; j < nRigt + 1; j++)
    {
      int nRem2019 = (llong)i * j % 2019;
      nRemMin2019 = min(nRemMin2019, nRem2019);
    }

  return nRemMin2019;
}
  
int main()
{
  int nLeft, nRigt;
  fnInput(nLeft, nRigt);
  cout << fnRemainMin2019(nLeft, nRigt) << endl;

  return 0;
}

Measured memory_bytes: 256
import std.stdio, std.typecons, std.algorithm, std.conv;

alias Tuple!(int, "weight", int, "limit", string, "name") Food;

int[] ans;
double value;

double center_grav(Food[] foods, int[] arr) {
  int v, sum;
  for(int i = 0; i < arr.length; i++) {
    v += i * foods[arr[i]].weight;
    sum += foods[arr[i]].weight;
  }
  return v.to!double / sum.to!double;
}

void solve(Food[] foods, int mask, int sum, int[] order) {
  if (mask == 0) {
    double res = center_grav(foods, order.dup);
    if (res < value) {
      value = res;
      ans = order;
    }
  }
  for(int i = 0; i < foods.length; i++) {
    if (((mask >> i) & 1) == 1) {
      if (foods[i].limit < (sum - foods[i].weight)) continue;
      solve(foods, mask & ~(1 << i), sum - foods[i].weight, order ~ [i]);
    }
  }
}

void main() {
  for(int times; readf("%d\n", &times), times != 0;) {
    Food[] foods;
    for(int t = 0; t < times; t++) {
      string name;
      int weight, limit;
      readf("%s %d %d\n", &name, &weight, &limit);
      foods ~= Food(weight, limit, name);
    }
    int[] res;
    int mask = 0;
    foreach(int i, f; foods) mask |= (1 << i);
    ans = [];
    value = double.max;
    int sum = reduce!((accum, x) => accum + x.weight)(0, foods);
    solve(foods, mask, sum, res);
    foreach(i; ans) {
      writeln(foods[i].name);
    }
  }
}

Measured memory_bytes: 2056
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>

using namespace std;
typedef long long int ll;


int main(int argc, char const *argv[])
{
    ll a, b, c;
    cin >> a >> b >> c;
    if (b - a == c - b)
    {
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<iomanip>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	int y=a*b;
	if(y>c)
	cout<<c<<endl;
	else
	cout<<y<<endl;
	return 0;
}

Measured memory_bytes: 256
Sp = input()
T = input()
S = []
for i in range(len(Sp)-len(T)+1):
	for j in range(len(T)):
		if Sp[i+j] not in ("?",T[j]):
			break
	else:
		tmp = Sp[:i] + T + Sp[i+len(T):]
		S.append(tmp.replace("?","a"))

print(min(S) if S else "UNRESTORABLE")


Measured memory_bytes: 3060