akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <math.h>
#include <vector>
#include <queue>
#include <iomanip>
#include <string>
#include <algorithm>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep_1 (i,j,n) for(int i=j;i<n;i++)
typedef long long ll;
typedef long l;
const ll l_INF = 1010101010101010;
const int INF = 1010101010;
const int dx[4] = {-1,0,1,0};
const int dy[4] = {0,-1,0,1};
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(){
  int n,m,s,t; cin>>n>>m>>s>>t;
  s--;t--;
  //グラフを作成
  vector<vector<pll>> g_a(n);
  vector<vector<pll>> g_b(n);
  rep(i,m){
    int u,v,a,b; cin>>u>>v>>a>>b;
    u--;v--;
    g_a[u].push_back({v,a});
    g_a[v].push_back({u,a});
    g_b[u].push_back({v,b});
    g_b[v].push_back({u,b});
  }
  //円、スヌーくそれぞれでいく場合の最小距離を設定
  vll dist_a(n);
  vll dist_b(n);
  //初期値
  rep(i,n){
    dist_a[i]=l_INF;
    dist_b[i]=l_INF;
  }
  priority_queue<pll,vector<pll>,greater<pll>> q_a,q_b;
  q_a.push({0,s});
  dist_a[s]=dist_b[t]=0;
  // 優先度付きキューには (距離, 頂点番号) の組を入れる
  while(!q_a.empty()){
    ll pos = q_a.top().second; q_a.pop();
    for(ll i=0;i<g_a[pos].size();i++){
      ll to=g_a[pos][i].first, cost=g_a[pos][i].second;
      if(dist_a[to]>dist_a[pos]+cost){
        dist_a[to]=dist_a[pos]+cost;
        q_a.push({dist_a[to],to});
      }
    }
  }
  q_b.push({0,t});
  // 優先度付きキューには (距離, 頂点番号) の組を入れる
  while(!q_b.empty()){
    ll pos = q_b.top().second; q_b.pop();
    for(ll i=0;i<g_b[pos].size();i++){
      ll to=g_b[pos][i].first, cost=g_b[pos][i].second;
      if(dist_b[to]>dist_b[pos]+cost){
        dist_b[to]=dist_b[pos]+cost;
        q_b.push({dist_b[to],to});
      }
    }
  }
  vll ans(n);
  ll val=l_INF;
  for(int i=n-1;i>=0;i--){
    val=min(dist_a[i]+dist_b[i], val);
    ans[i]=1000000000000000-val;
  }
  //rep(i,n) cout<<dist_a[i]<<' '; cout<<endl;
  //rep(i,n) cout<<dist_b[i]<<' '; cout<<endl;
  rep(i,n) cout<<ans[i]<<endl;
}


Measured memory_bytes: 21492
H, W = map(int, input().split())
C = [input() for i in range(H)]

ans = ['' for i in range(H*2)]

for i in range(H):
    for j in range(W):
        ans[2 * i] += C[i][j]
        ans[2 * i + 1] += C[i][j]
for i in range(2 * H):
    print(ans[i])

Measured memory_bytes: 9112
/**************erik****************/
#include<bits/stdc++.h>
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long  int ll;
typedef unsigned long long int ull;
//map<ll,ll> mp1;
//set<int> s1;
//set<int>::iterator it;
#define maxm(a,b,c)  max(a,max(c,b))
#define minm(a,b,c)  min(a,min(c,b))
#define f(i,n)  for(ll i=0;i<n;i++)
#define rf(i,n) for(ll i=n-1;i>=0;i--)
const int mx = 100002;
int q;
vector<string> ss(mx);
vector<char> vec;
void dfs(int i, int a, int b, int c){
    if(a<0||b<0||c<0)return;
    if(i==q){
        cout<<"Yes"<<endl;
        f(i,q)cout<<vec[i]<<endl;
        exit(0);
    }
    if(ss[i]=="AB"){
        vec.push_back('A');
        dfs(i+1,a+1,b-1,c);
        vec.pop_back();
        vec.push_back('B');
        dfs(i+1,a-1,b+1,c);
        vec.pop_back();
    } else if(ss[i]=="AC"){
        vec.push_back('A');
        dfs(i+1,a+1,b,c-1);
        vec.pop_back();
        vec.push_back('C');
        dfs(i+1,a-1,b,c+1);
        vec.pop_back();
    } else {
        vec.push_back('C');
        dfs(i+1,a,b-1,c+1);
        vec.pop_back();
        vec.push_back('B');
        dfs(i+1,a,b+1,c-1);
        vec.pop_back();
    }
    return;
}
int main(){
    ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
    cin>>q;
    int a,b,c;
    cin>>a>>b>>c;
    f(i,q)cin>>ss[i];
    dfs(0,a,b,c);
    cout<<"No"<<endl;
}

Measured memory_bytes: 14460
#include <bits/stdc++.h>
#define PI 3.14159265358979323846264338327950L
#define pb push_back
#define fr first
#define sc second
#define MOD 1000000007
#define len(s) s.size()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define all(v) v.begin(), v.end()
#define f(i, a, n) for (int i = a; i < n; i++)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef map<int, int> mii;

int main()
{

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    // int t;
    // cin >> t;
    // while (t--)
    ll n;
    cin >> n;
    ll x = 100;
    int t = 0;
    while (x < n)
    {
        t++;
        x += x / 100;
    }
    cout << t;

    return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
int main () {
	long long  c[4][4];
	long long  a[4];
	long long b[4];
	for (int i=1; i<=3; i++) {
		for (int j=1; j<=3; j++) {
			cin >> c[i][j];
		}
	}
	b[1] = c[1][1];
	b[2] = c[1][2];
	b[3] = c[1][3];
	a[1] = 0;
	a[2] = c[2][2] - b[2];
	a[3] = c[3][3] - b[3];
	for (int i=1; i<=3; i++) {
		for (int j=1; j<=3; j++) {
			if (c[i][j]!=a[i]+b[j]) {
				cout << "No";
				return 0;
			}
		}
	}
	cout << "Yes";
	return 0;
}

Measured memory_bytes: 3616
n = int(input())
x, y = 0, 0
for i in range(n):
    a, b = map(int, input().split())
    lb, ub = 0, 10 ** 19
    while ub - lb > 1:
        md = (lb + ub) // 2
        if a * md >= x and b * md >= y:
            ub = md
        else:
            lb = md
    x, y = a * ub, b * ub
print(x + y)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define SZ(x) ((int)(x).size())
#define rep(i,n) for(int i=0;i<(n);++i)
#define fore(i,a) for(auto &i:a)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define ALL(x) (x).begin(),(x).end()
signed _main(); signed main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
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; }
template<class T> using v = vector<T>;
template<class T> using vv = vector<v<T>>;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
using P=pair<int,int>;

signed _main(){
  string S; cin >> S;
  int N=SZ(S);
  int ans=0;
  for (int bit = 0; bit < (1 << N-1); ++bit) {
    int left=0,right=0;
    for (int i = 0; i < N-1; ++i) {
      if (bit & (1 << i)){
        right=i;
        string s=S.substr(left,right-left+1);
        //cout << s << endl;
        ans+=stoll(s);
        left=i+1;
      }
    }
    string s=S.substr(left,SZ(S)-1-left+1);
    //cout << s.c_str() << endl;
    //cout << s << endl;
    //cout << s << endl;
    ans+=stoll(s);
  }
  cout << ans << endl;
  return 0;
}


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

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

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

using namespace std;

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

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

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

#include <map>
map<pii, int> memo;
int h, w, n;

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

int main()
{
	cin >> h >> w >> n;

	REP(_i, n)
	{
		int x, y;
		cin >> y >> x;
		y--; x--;
//		cout << "from [ " << x << " , " << y << " ]" << endl;
		REP(i, 9)
		{
			int cx = x + dx[i];
			int cy = y + dy[i];

//			cout << "  checking [ " << cx << " , " << cy << " ]" << endl;

			if (cx - 1 >= 0 && cx + 1 < w && cy - 1 >= 0 && cy + 1 < h)
			{
				memo[pii(cx, cy)]++;
			}
		}
	}

	vll ans(10, 0);
	ans[0] = ((ll)h - 2) * ((ll)w - 2);

	for (auto it = memo.begin(); it != memo.end(); it++)
	{
//		cout << "[ " << it->first.first << ", " << it->first.second << " ] : " << it->second << endl;
		ans[it->second]++;
		ans[0] -= 1;
	}

	REP(i, 10)
		cout << ans[i] << endl;
}


Measured memory_bytes: 56448
#include <stdio.h>
#include <stdlib.h>

int sort(const void *a,const void *b){
    int x = *(int*)a,y = *(int*)b;
    return x>y?1:x<y?-1:0;
}

int main(int argc, char const *argv[]) {
    int n,m;
    scanf("%d", &n);
    int a[n];

    for (int i= 0; i< n; i++) {
        scanf("%d", &a[i]);
    }

    qsort(a,n,sizeof(int),sort);
    printf("%d\n", a[n/2]- a[(n-2)/2]);
    return 0;
}


Measured memory_bytes: 892
while 1:
	a, op, b = map(str, raw_input().split())
	a = int(a)
	b = int(b)
	if op == "+":
		print a + b
	elif op == "-":
		print a - b
	elif op == "*":
		print a * b
	elif op == "/":
		print a / b
	else:
		break
		

Measured memory_bytes: 4204
#include <iostream>
#include<vector>
#include <algorithm>

using namespace std;

int n,x;
int v[30];
//vector<int> prime;
bool is_prime[1000001];

void sieve(int n){
  //  int p = 0;
  for(int i = 0;i<=n;i++){
    is_prime[i] = true;
  }
  is_prime[0] = is_prime[1] = false;
  for(int i = 2;i<=n;i++){
    if(is_prime[i]){
      for(int j = 2*i;j<=n;j+=i)
	is_prime[j] = false;
    }
  }
}
  
  

int main(){
  sieve(1000000);
  while(cin>>n>>x){
    if(n == 0 && x == 0)
      return 0;
    bool can[1000001];
    for(int i = 0;i<=x;i++)
      can[i] = false;
    for(int i = 0;i<n;i++){
      cin>>v[i];
    }
    sort(v,v+n);
    for(int i = 0;i<n;i++){
      can[v[i]]=true;
      for(int j = 0;v[i]+j<=x;j++){
	if(can[j])
	  can[j+v[i]] = true;
      }
    }
    int ans = 0;
    for(int i = 0;i<=x;i++){
      if(can[i] && is_prime[i])
	ans = i;
    }
    if(ans != 0)
      cout<<ans<<endl;
    else
      cout<<"NA"<<endl;
  }


  return 0;
}

Measured memory_bytes: 5020
//
// Created by pureZer on 2019-07-20.
//
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <vector>
#include <string>
#include <sstream>
#include <utility>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const double PI = acos(-1.0);
const int INF = 99999999;
const double eps = 1e-6;
const int maxn = 1e5+5;

int r;

int main(){
    cin >> r;
    cout << 3 * r * r << endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast") 
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define owo ios_base::sync_with_stdio(0);cin.tie(0);
#define MOD (ll)(1e9+7)
#define INF (ll)(1e18)
#define debug(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false);\
debug("%s time : %.4fs\n", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> PII;
typedef pair<int,int> pii;
typedef vector<vector<int>> vii;
typedef vector<vector<ll>> VII;
int main()
{
	ll n;
	cin>>n;
	ll ans = 0;
	for(int i=1;i<=n;i++)ans+=(n+1-i)*i;
	for(int i=0;i<n-1;i++)
	{
		ll u,v;
		cin>>u>>v;
		if(u > v)swap(u,v);
		ans-=u*(n+1-v);
	}
	cout<<ans;
}


Measured memory_bytes: 3640
data = input().split()
a = int(data[0])
b = int(data[1])
c = int(data[2])
i = 0
if a < b:
    pass
elif a > b:
    i = a
    a = b
    b = i
if b < c:
    pass
elif b > c:
    i = b
    b = c
    c = i
if a < b:
    pass
elif a > b:
    i = a
    a = b
    b = i
print(a, b, c)


Measured memory_bytes: 5596
#include <iostream>
#include <limits>
#include <algorithm>
using namespace std;

int n;
int main() {
    cin >> n;
    long long arr[n];
    long long fromLeft[n];
    long long fromRight[n];
    for (int i = 0; i < n; i++) {
      	cin >> arr[i];
        fromLeft[i] = 0;
        fromRight[i] = 0;
    }
    fromLeft[0] = arr[0];
    fromRight[n-1] = arr[n-1];
    for (int i = 1; i < n; i++) {
        fromLeft[i] = fromLeft[i-1] + arr[i];
        fromRight[n-i-1] = fromRight[n-i] + arr[n-i-1];
    }
    long long ans = numeric_limits<long long int>::max();
    for (int i = 0; i < n-1; i++) {
        ans = min(ans, abs(fromLeft[i]-fromRight[i+1]));
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;


#define ff				first
#define ss				second
#define int				long long
#define pb				push_back
#define mp				make_pair
#define pii				pair<int,int>
#define vi				vector<int>
#define mii 			map<int,int>
#define	pqb				priority_queue<int>
#define pqs				priority_queue<int,vi,greater<int> >
#define setbits(x)		__builtin_popcountll(x)
#define zrobits(x)		__builtin_ctzll(x)
#define mod				1000000007
#define inf 			1e18
#define ps(x,y)			fixed<<setprecision(y)<<x
#define mk(arr,n,type)	type *arr = new type[n]
#define w(x)			int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)


void c_p_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

}

bool isPrime(int n)
{
	if (n <= 1)
		return false;
	if (n <= 3)
		return true;
	if (n % 2 == 0 || n % 3 == 0)
		return false;
	for (int i = 5; i * i <= n; i += 6)
	{
		if (n % i == 0 || n % (i + 2) == 0)
			return false;

	}
	return true;
}

vector<int> Sieve(int n)
{
	bool prime[n + 1];
	memset(prime, true, sizeof(prime));
	for (int i = 2; i * i <= n; i++)
	{
		if (prime[i])
		{
			for (int j = i * i; j <= n; j += i)
			{
				prime[j] = false;
			}
		}
	}
	vi primes;
	for (int i = 2; i <= n; i++)
	{
		if (prime[i])
			primes.pb(i);
	}
	return primes;
}


bool cmp(pii a, pii b)
{
	if (a.ff == b.ff)
		return a.ss > b.ss;
	return a.ff < b.ff;
}
int lengthOfLongestIncreasingSubsequence(int arr[], int n)
{
	int max = 1, len = 1;
	for (int i = 1; i < n; i++)
	{
		if (arr[i] > arr[i - 1])
			len++;
		else
		{
			if (max < len)
				max = len;

			len = 1;
		}
	}
	if (max < len)
		max = len;

	return max;
}

set<int> primeFactors(int  n)
{
	set<int> factors;
	while (n % 2 == 0)
	{
		n /= 2;
		factors.insert(2);

	}
	for (int i = 3; i <= sqrt(n); i += 2)
	{
		while (n % i == 0)
		{
			factors.insert(i);
			n /= i;
		}
	}
	if (n > 2)
		factors.insert(n);
	return factors;
}

bool luckyNumber(int n)
{
	int dig;
	while (n > 0)
	{
		dig = n % 10;

		if (dig != 4 && dig != 7)
		{
			// cout << n << endl;
			return false;
		}
		n /= 10;
	}
	return true;
}
int32_t main()
{
	FIO;
// 	c_p_c();
	int k;
	cin >> k;
	int sum = 0;
	for (int i = 1; i <= k; i++)
	{
		for (int j = 1; j <= k; j++)
		{
			for (int s = 1; s <= k; s++)
				sum += __gcd(i, __gcd(j, s));
		}
	}
	cout << sum << endl;
}

Measured memory_bytes: 3624
/****Author: Barish Namazov****/
#include <bits/stdc++.h>

using namespace std;

/***TEMPLATE***/
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

#define F first
#define S second
#define pb push_back

#define endl '\n'

const int max4 = 10004;
const int maxx = 100005;
const int max6 = 1000006;
const int lg5 = 17;

const int INF = 2 * 1000000007;
const long long INFLL = 4LL * 1000000000 * 1000000000;

/***************/

int powmod (int a, int b, int mod) {
    int res = 1; a %= mod;
    for (; b; b >>= 1) {
        if (b & 1) {
            res = 1LL * res * a % mod;
        }
        a = 1LL * a * a % mod;
    }
    return res;
}
#define ll long long
ll gcd (ll a, ll b) {
    while (b > 0) {
        ll t = a % b;
        a = b, b = t;
    }
    return a;
}

int lcm (int a, int b) {
    return (a / gcd (a, b)) * b;
}

int is_prime (int n) {
    if (n <= 1 || n > 3 && (n % 2 == 0 || n % 3 == 0))
        return 0;
    for (int i = 5, t = 2; i * i <= n; i += t, t = 6 - t)
        if (n % i == 0)
            return 0;
    return 1;
}

/******Don't forget to use long long when needed!!******/

int main() {
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    ios_base :: sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    string s;
    cin >> s;
    int n = s.size();
    vector <int> v;
    for (int i = 0; i < n; i++) {
        if (v.empty()) {
            v.pb((s[i] == 'S' ? 0 : 1));
        } else {
            int cur = s[i] == 'S' ? 0 : 1;
            if (cur == 1 && v.back() == 0) {
                v.pop_back();
            } else {
                v.pb(s[i] == 'S' ? 0 : 1);
            }
        }
    }
    cout << v.size() << endl;
    return 0;
}


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

using namespace std;
using ll = long long;

const ll mod = 998244353;

int a, b;

vector<vector<ll> > dp(3001, vector<ll>(3001, -1));

ll solve(int x, int y) {
  if (dp[x][y] < 0) {
    dp[x][y] = 0;
    if (x > a) dp[x][y] += solve(x-1, y)*y%mod;
    if (y > b) dp[x][y] += solve(x, y-1)*x%mod;
    if (x > a and y > b) dp[x][y] = (dp[x][y] - solve(x-1,y-1)*(x-1)%mod*(y-1))%mod;
    if (dp[x][y] < 0) dp[x][y] += mod;
    
  }
  return dp[x][y];
}

int main() {
  int c , d;
  cin >> a >> b >> c >> d;
  dp[a][b] = 1;
  cout << solve(c,d) << endl;
}



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


public class Main {

	public static void main(String[] args) {
		Main main = new Main();
		main.convertBinaryReal();
		return;
	}
	
	//実数を2進数に変換する
	private void convertBinaryReal() {
		
		BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in)); //標準入力
		
		while (true) {
			
			try {
				
				String inputStr = bufferedReader.readLine();
				double num = Double.parseDouble(inputStr);
				
				if (num < 0) {
					break;
				}
				
				//入力された値を左シフトする
				num = num * 16;
				
				//1.0で割り切れなければ、小数部4桁に収まらない
				if(num % 1.0 != 0){
					System.out.println("NA");
					continue;
				}
				
				//入力された値が256以上なら整数部8桁に収まらない
				if(num >= 256 * 16){
					System.out.println("NA");
					continue;
				}
				
				String binary = Integer.toBinaryString((int)num);
				
				String integer = binary.substring(0, binary.length() - 4); //小数部を切り落とす
				String minority = binary.substring(binary.length() - 4, binary.length()); //整数部を切り落とす
				
				//整数部が8桁でなければ、足りない桁を0で埋める
				while(integer.length() < 8) {
					integer = "0" + integer;
				}
				
				System.out.println(integer + "." + minority);
				
			} catch (IOException e) {
				// TODO 自動生成された catch ブロック
				e.printStackTrace();
			}
			
		}
	}
}

Measured memory_bytes: 19748
#include<bits/stdc++.h>
long long int MOD = 1000000007;
using namespace std;
//g++ -std=c++14
//setprecision(10)
int main(){
	int n;
	cin >> n;
	vector <int> d;
	for(int i = 0; i < n; i++){
		int va;
		cin >> va;
		d.push_back(va);
	}
	sort(d.begin(), d.end());
	int m;
	cin >> m;
	vector <int> t;
	for(int i = 0; i < m; i++){
		int va;
		cin >> va;
		t.push_back(va);
	}
	sort(t.begin(), t.end());
	auto va = d.begin();
	for(auto itr = t.begin(); itr != t.end(); itr++){
		va = lower_bound(va, d.end(), *itr);
		//cout << *va << endl;
		if(itr == d.end() || *itr != *va){
			cout << "NO" << endl;
			return 0;
		}
		va++;
	}
	cout << "YES" << endl;
}

Measured memory_bytes: 2548
while 1:
    n = int(input())
    if n == 0:
        break
    h = [0, 0, 0, 0, 0, 0, 0 ]
    for _ in range(n):
        a = int(input())//10
        if a > 6:
            a = 6
        h[a] += 1
    for i in range(7):
        print(h[i], sep='\n')
        



Measured memory_bytes: 5616
#include<set>
#include<map>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<math.h>
#include<time.h>
#include<vector>
#include<bitset>
#include<memory>
#include<utility>
#include<fstream>
#include<stdio.h>
#include<sstream>
#include<iostream>
#include<stdlib.h>
#include<string.h>
#include<algorithm>
using namespace std;
int get_mex(int n,int k)
{
    if (k==1)
    {
        return n;
    }
    if (n<k)
    {
        return 0;
    }
    if (n%k==0)
    {
        return n/k;
    }
    int t=(n/k+1);
    t=(n%k+t-1)/t;
    return get_mex(n-t*(n/k+1),k);
}
int mex[205];
int main()
{
    #ifdef absi2011
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int n;
    scanf("%d",&n);
    int a,k;
    int i;
    for (i=0;i<n;i++)
    {
        scanf("%d%d",&a,&k);
        mex[i]=get_mex(a,k);
    }
    int x=0;
    for (i=0;i<n;i++)
    {
        x^=mex[i];
    }
    if (x==0)
    {
        puts("Aoki");
    }
    else
    {
        puts("Takahashi");
    }
    return 0;
} 


Measured memory_bytes: 384
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = (int)(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = (int)(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define REVERSE(x) reverse((x).begin(), (x).end())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << '\n'
#define endl '\n'

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-10;

constexpr int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
constexpr int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

template<typename T>
bool chmax(T& a, T b){
    if(a < b){
        a = b;
        return true;
    }
    return false;
}

template<typename T>
bool chmin(T& a, T b){
    if(b < a){
        a = b;
        return true;
    }
    return false;
}

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

    int n;
    cin >> n;

    vector<lint> d(n);
    rep(i, n){
        cin >> d[i];
    }

    lint ans = 0;
    rep(i, n){
        rep(j, i){
            ans += d[i] * d[j];
        }
    }

    cout << ans << endl;

    cout << flush;

    return 0;
}

Measured memory_bytes: 256
s=list(input())


dp=[0]*(len(s)+1)
count=0
x=0
for i in range(len(s)):
    if s[i]=='<':
        dp[i+1]=dp[i]+1

for i in range(1,len(s)+1):
    if s[-i]=='>':
        dp[-(i+1)]=max(dp[-(i+1)],dp[-i]+1)

print(sum(dp))
        
    
        
        
        
    
                
    
        

     

    

     

    


Measured memory_bytes: 26824
//
//  main.c
//  ITP1_5_C
//
//  Created by ??±??°?????? on 2015/10/10.
//  Copyright ?? 2015??´ HamadaShogo. All rights reserved.
//

#include <stdio.h>

void printChessboard(unsigned int High, unsigned int Wide);

int main(int argc, const char * argv[]) {
    unsigned int w = 1, h = 1;
    
    while (!(h == 0 && w == 0)) {
        scanf("%d %d", &h, &w);
        if(!(h == 0 && w == 0)){
            printChessboard(h, w);
        }
    }
    
    return 0;
}

void printChessboard(unsigned int High, unsigned int Wide){
    int i, j;
    
    for (i=0; i<High; i++) {
        for (j=0; j<Wide; j++) {
            if ((i+j)%2 == 0) {
                printf("#");
            }
            else{
                printf(".");
            }
        }
        puts("");
    }
    puts("");
}

Measured memory_bytes: 1016
object Main {
  def main(args: Array[String]): Unit = {
    solve
  }

  def solve(): Unit = {
    val sc = new java.util.Scanner(System.in)
    val n = sc.nextLong
    val abcde = new Array[Long](5)
    for (i <- 0 until 5) {
      abcde(i) = sc.nextLong
    }
    if (n <= abcde.min) println(5)
    else {
      if (n % abcde.min == 0) println(5L + n / abcde.min - 1)
      else println(5L + n / abcde.min)
    }
  }
}

Measured memory_bytes: 27336
#include<iostream>
#include<iomanip>
#include<stdio.h>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<string>
#include<algorithm>
#include<functional>
#include<math.h>
#include<unordered_set>
using namespace std;
 
const int MAX = 101;
 
int main() {
	int N;
	int cards[MAX] = { 0 };
 
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> cards[i];
	}
 
	sort(cards, cards + N, greater<int>());
 
	int alice = 0;
	int bob = 0;
 
	for (int i = 0; i < N; i++) {
		if (i % 2 == 0)alice += cards[i];
		else bob += cards[i];
	}
 
	cout << alice - bob << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using PL = pair<ll, ll>;
// Welcome to my source code!

int d[10000];

int main() {
    int n, x, y;
    cin >> n >> x >> y;
    x--; y--;
    for (int i = 0; i < n - 1; i++) {
        for (int j = i + 1; j < n; j++) {
            int t = min(abs(i - j), abs(i - x) + 1 + abs(y - j));
            d[t]++;
        }
    }
    for (int i = 1; i < n; i++) {
        cout << d[i] << endl;
    }
}

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

typedef long long ll;

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


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
typedef pair<int,int> P;
const int MOD = 1000000007;
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 


////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////

int n,a[3][3];
signed main(){
  rep(i,3)rep(j,3)cin>>a[i][j];
  cin>>n;
  rep(i,n){
    int b;cin>>b;
    rep(i,3)rep(j,3)if(a[i][j] == b)a[i][j] = 0;
  }
  bool b = false;
  rep(i,3){
    int cnt = 0;
    rep(j,3)if(a[i][j] == 0)cnt++;
    if(cnt == 3)b = true;
  }
  rep(i,3){
    int cnt = 0;
    rep(j,3)if(a[j][i] == 0)cnt++;
    if(cnt == 3)b = true;
  }
  if(a[0][0] == 0 && a[1][1] == 0 && a[2][2] == 0)b = true;
  if(a[0][2] == 0 && a[1][1] == 0 && a[2][0] == 0)b = true;
  if(b)cout << "Yes" << endl;
  else cout << "No" << endl;
}




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

int main(){
  char c;
  cin >> c;
  if(isupper(c)){
    cout << "A" << endl;
  }
  else{
    cout << "a" << endl;
  }

  return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define sd(a) scanf("%d",&a)
using namespace std;
int main(){
    int m,d;
    sd(m);
    sd(d);
    int ans=0;
    for(int i=1;i<=m;++i){
        for(int j=1;j<=d;++j){
            int d1=j/10;
            int d2=j%10;
            if(d1*d2==i&&d1>=2&&d2>=2)
                ans++;
        }
    }
    printf("%d\n",ans);
}


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

using namespace std;

#define int long long
#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll N=1e5+10,M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;
const int INF=1e9+7;
void add(int& a, int b) {a+=b;if(a>=mod){a-=mod;}}

#define trace(...) cerr<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
    cerr<<name<<" : "<<arg1<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
    const char *comma=strchr(names+1,',');
    cerr.write(names,comma-names)<<" : "<<arg1<<" | ";
    __f(comma+1,args...);
}

int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
//assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
ll power(ll x,ll n){ll result=1;while(n>0){if(n%2==1)result=(result*x)%mod; x=((x%mod)*(x%mod))%mod;n=n/2;}return result;}


int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    bool a=false,b=false;
    string s;
    cin >> s;
    rep(i,0,s.size()){
        if(s[i]=='A') a=true;
        else b=true;
    }
    if(a && b) cout << "Yes";
    else cout << "No";
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

void rotation_and_print(char str[8][8]);

int main(void)
{
	char str[8][8];
	int i, j;
	
	for (i = 0; i < 8; i++){
		scanf("%s", str[i]);
	}
	
	puts("90");
	rotation_and_print(str);
	
	puts("180");
	rotation_and_print(str);
	
	puts("270");
	rotation_and_print(str);
	
	return (0);
}
void rotation_and_print(char str[8][8])
{
	char tmp[8][8];
	int i, j, k, l;
	
	for (i = 0, k = 0; i < 8; i++, k++){
		for (j = 0, l = 7; j < 8; j++, l--){
			tmp[i][j] = str[l][k];
		}
	}
	
	for (i = 0; i < 8; i++){
		for (j = 0; j < 8; j++){
			str[i][j] = tmp[i][j];
		}
	}
	for (i = 0; i < 8; i++){
		for (j = 0; j < 8; j++){
			printf("%c", str[i][j]);
		}
		printf("\n");
	}
}

Measured memory_bytes: 524
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

int main()
{
    int n,ans = 1;
    string s;
    cin >> n >> s;

    for(int i = 1;i < n;++i){
        if(s[i] != s[i-1]) ans++;
    }

    printf("%d",ans);
    return 0;
}


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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i < b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = INT_MAX / 2;
const ll  inf = LLONG_MAX / 2;
const int mod = 1000000007;
const int MAX_N = 101010;
const long double PI = acos(-1);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	/*------------------------------*/

	ll n;
	cin >> n;
	vector<ll> a(n);
	bool zero = false;
	rep(i, n) {
		cin >> a[i];
		if (a[i] == 0) {
			zero = true;
		}
	}
	if (zero) {
		out(0);
		return 0;
	}

	ll x = 1;
	rep(i, n) {
		if (a[i] <= 1000000000000000000 / x) {
			x *= a[i];
		}
		else {
			out(-1);
			return 0;
		}
	}

	out(x);

	return 0;
}

Measured memory_bytes: 3976
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;

int main()
{
  int a, b, ans = 0;
  cin >> a >> b;
  for (int i = a; i <= b; i++) {
    int tmp1 = i / 10000;
    if (tmp1 == i % 10) {
      int tmp2 = i / 1000 % 10;
      int tmp3 = i / 10;
      if (tmp2 == tmp3 % 10) ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;

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

    long ans = 0;
    for (int i = 1; i <= N; i++)
      if (i % 3 != 0 && i % 5 != 0) ans += i;

    System.out.println(ans);
  }
}


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

// limit
#define mod1 22439423LL
#define mod2 42342432LL
#define mod3 56454765LL
#define mod4 66867574LL
#define oo 1000000007LL
#define OO 1000000000000000007LL

// loop
#define fto(i, x, y) for(int i = (x); i <= (y); ++i)
#define fdto(i, x, y) for(int i = (x); i >= (y); --i)
#define ftoa(i, x, y, a) for(int i = (x); i <= (y); i += a)
#define fdtoa(i, x, y, a) for(int i = (x); i >= (y); i -= a)
#define ftosqrt(i, x, y) for(int i = (x); i*i <= (y); ++i)
#define ftoit(it, var) for (__typeof(var.begin()) it = var.begin(); it != var.end(); ++it)
#define fdtoit(rit, var) for (__typeof(var.rbegin()) rit = var.rbegin(); rit != var.rend(); ++rit)

// debug
#define debug cout << "*" << endl;
#define bug1d(a, x, y) { cout << #a << ": "; fto(_, x, y) cout << a[_] << ' '; cout << endl; }
#define bug2d(a, x, y, u, v) { cout << #a << ": " << endl; fto(i, x, y) {fto(j, u, v) cout << a[i][j] << ' '; cout << endl;}; cout << endl;}
#define bug(a) cout << #a << " = " << a << endl;
#define bug2(a, b) cout << #a << " = " << a << "; "; cout << #b << " = " << b << endl;
#define bug3(a, b, c) cout << #a << " = " << a << "; "; cout << #b << " = " << b << "; "; cout << #c << " = " << c << endl;

// operation
#define mp make_pair
#define pb push_back
#define pf push_front
// structure
#define ii pair<int, int>
#define iii pair<ii, int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>
#define matrix vector<vi>

// get value
#define FF first
#define SS second

// data type
#define ll long long
#define ull unsigned long long

// function
#define lb lower_bound
#define ub upper_bound

// const value
#define pi 3.14159265358979323846264338327950288419716939937510

using namespace std;

template <class T>
T min(T a, T b, T c) {
    return min(a, min(b, c));
}

template <class T>
T min(T a, T b, T c, T d) {
    return min(a, min(b, min(c, d)));
}

template <class T>
T max(T a, T b, T c) {
    return max(a, max(b, c));
}

template <class T>
T max(T a, T b, T c, T d) {
    return max(a, max(b, max(c, d)));
}

bool cmp(const ii& a, const ii& b) {return (a.FF > b.FF || (a.FF == b.FF && a.SS >= b.SS));}
ll GCD(ll a, ll b) {return (a%b) ? GCD(b, a%b) : b;}

const string namePro = "tmp";
#define maxN 1000007

int main(){
    // #ifndef ONLINE_JUDGE
    //     freopen((namePro+".inp").c_str(), "r", stdin);
    //     freopen((namePro+".out").c_str(), "w", stdout);
    // #endif // ONLINE_JUDGE

    int a, x, y;
    scanf("%d%d%d", &a, &x, &y);

    if (abs(x-a) < abs(y-a)) cout << "A" << endl;
    else cout << "B" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MAX 1000005
#define ll long long
#define upperlimit 1000100
#define INF 1e18
#define eps 1e-8
#define endl '\n'
#define pcc pair<char,char>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tr(container,it) for(typeof(container.begin()) it=container.begin();it!=container.end();it++)
#define MOD 1000000007
#define slld(t) scanf("%lld",&t)
#define sd(t) scanf("%d",&t)
#define pd(t) printf("%d\n",t)
#define plld(t) printf("%lld\n",t)
#define mp(a,b) make_pair(a,b)
#define FF first
#define SS second
#define pb(x) push_back(x)
#define vi vector<int>
#define clr(a) memset(a,0,sizeof(a))
#define debug(a) printf("check%d\n",a)
#define csl ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
int a[1000004];
int main()
{
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=m;i++)
    {

        int x,y;
        cin>>x>>y;
        a[x]++;
        a[y]++;
    }
    bool b=true;
    for(int i=1;i<=n;i++)
    {
        if(a[i]%2!=0)b=false;
    }
    if(b)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;

}


Measured memory_bytes: 640
s = sorted(input())
if (s[0] == s[1]) and (s[2] == s[3]) and (s[0] != s[2]):
        print('Yes')
elif (s[0] == s[2]) and (s[1] == s[3]) and (s[0] != s[1]):
        print('Yse')
elif (s[0] == s[3]) and (s[1] == s[2]) and (s[0] != s[1]):
        print('Yes')
else:
    print('No')


Measured memory_bytes: 3064
#include<stdio.h>
int main(void)
{
	int a,b,i,sum;
	scanf("%d %d",&a,&b);
	i=0;
	sum=1;
	while(1){
		if(sum>=b){
			break;
		}
		sum+=a-1;
		i++;
	}
	printf("%d\n",i);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define All(v) (v).begin(),(v).end()
typedef long long ll;

int main(){
    int N;cin >> N;
    vector<int> cnt(100100,0);    
    rep(i,N){
        int a;cin >> a;
        cnt[a]++;
        if(a-1>0)cnt[a-1]++;
        cnt[a+1]++;
    }
    int res = 0;
    rep(i,100100){
        res = max(res,cnt[i]);
    }

    cout << res << endl;
    
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const long long INF = 1e18;
long long n, t;
vector<long long> A(100100, 0);

int main() {
    cin >> n >> t;
    for(int i = 0; i < n; ++i) cin >> A.at(i);

    long long Amin = INF;
    long long Bmax = 0;
    vector<long long> B(n, 0);
    for(int i = 0; i < n; ++i) {
        B.at(i) = A.at(i) - Amin;
        chmin(Amin, A.at(i));
        chmax(Bmax, B.at(i));
    }

    long long cnt = 0;
    for(int i = 0; i < n; ++i) {
        if(B.at(i) == Bmax) cnt++;
    }

    cout << cnt << endl;
}

Measured memory_bytes: 1792
IDENTIFICATION DIVISION.
       PROGRAM-ID. ABC043-B.
       DATA DIVISION.
       FILE SECTION.
       WORKING-STORAGE SECTION.
       77 INSTR PIC X(10).
       77 ANS PIC X(10) VALUE SPACE.
       77 I PIC 9(2).
       77 ANSI PIC 9(2).

       PROCEDURE DIVISION.
       MAIN-PROCEDURE.
            ACCEPT INSTR FROM SYSIN.
            PERFORM VARYING I FROM 1 BY 1
             UNTIL LENGTH OF INSTR < I
               EVALUATE INSTR(I:1)
                   WHEN "0"
                       STRING ANS  "0" DELIMITED BY SPACE
                        INTO ANS
                       END-STRING
                   WHEN "1"
                       STRING ANS  "1" DELIMITED BY SPACE
                        INTO ANS
                       END-STRING
                   WHEN "B"
                       MOVE FUNCTION STORED-CHAR-LENGTH (ANS) TO ANSI
                       IF ANSI = 0 THEN
                           CONTINUE
                       ELSE
                         MOVE SPACE TO ANS(ANSI:1)
                       END-IF
               END-EVALUATE
            END-PERFORM.
            DISPLAY ANS.
            STOP RUN.
       END PROGRAM ABC043-B.


Measured memory_bytes: 384
#include <iostream>
#include <vector>

int main()
{
	int N = 0;
	std::cin >> N;

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

	long long int c = 1;
	for (int i = 0; i < N; i++)
	{
		if (c == a[i])
		{
			b.push_back(c);
			c++;
		}
	}

	long long int K = 0;
	if (b.empty())
	{
		K = -1;
	}
	else{
		K = N - b.size();
	}

	std::cout << K << std::endl;

	return  0;
}

Measured memory_bytes: 3956
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) for(int i=(n)-1;0<=i;--i)
#define each(e,v) for(auto&& e:(v))
#define all(v) begin(v),end(v)
#define dump(x) cerr<<#x<<": "<<(x)<<endl
using namespace std;
using vint = vector<int>;
using ll = long long;
using vll = vector<ll>;
template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }
void yes() { cout << "Yes" << endl; exit(0); }
void no() { cout << "No" << endl; exit(0); }

int main() {
    int r; cin >> r;
    cout << 3 * r * r << endl;
    return 0;
}


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

#define FOR(i,l,r) for(int i = (int) (l);i < (int) (r);i++)
#define ALL(x) x.begin(),x.end()
template<typename T> bool chmax(T& a,const T& b){ return a < b ? (a = b,true) : false; }
template<typename T> bool chmin(T& a,const T& b){ return b < a ? (a = b,true) : false; }
typedef long long ll;

ll N,A,B,C,D;
const ll MAX_N = 1000;
ll dp [MAX_N + 2] [MAX_N + 1];
ll fact [MAX_N + 1],rfact [MAX_N + 1];
const ll MOD = 1e9 + 7;

ll mod_pow(ll x,ll y = MOD - 2)
{
	ll res = 1;
	while(y){
		if(y & 1){
			(res *= x) %= MOD;
		}
		(x *= x) %= MOD;
		y >>= 1;
	}
	return res;
}

int main()
{
	scanf("%lld%lld%lld%lld%lld",&N,&A,&B,&C,&D);

	fact [0] = rfact [0] = 1;
	FOR(i,1,N + 1){
		(fact [i] = fact [i - 1] * i) %= MOD;
		(rfact [i] = rfact [i - 1] * mod_pow(i)) %= MOD;
	}

	dp [A] [0] = 1;
	FOR(i,A,B + 1) FOR(j,0,N + 1){
		(dp [i + 1] [j] += dp [i] [j]) %= MOD;
		ll x = mod_pow(mod_pow(fact [i],C));
		for(ll k = C;k <= D && i * k <= N - j;k++){
			ll t = fact [N - j] * rfact [N - j - i * k] % MOD * x % MOD * rfact [k] % MOD;
			(dp [i + 1] [j + i * k] += dp [i] [j] * t % MOD) %= MOD;
			(x *= mod_pow(fact [i])) %= MOD;
		}
	}

	printf("%lld\n",dp [B + 1] [N]);

	return 0;
}


Measured memory_bytes: 8064
#include <iostream>

using namespace std;

int gcd(int p,int q)
{
	while(q!=0)
	{
		int r = p%q;
		p = q;
		q = r;
	}
	return p;
}

int main()
{
	int k;
	cin>>k;
	int ans = 0;
	for(size_t i = 0; i<k; i++)
	{
		for(size_t ii = 0; ii<k; ii++)
		{
			for(size_t iii = 0; iii<k; iii++)
			{
				int a = gcd(i+1,ii+1);
				ans += gcd(a,iii+1);
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3620
#include<stdio.h>
#include<stdlib.h>
#define Mo 1000000007;
int main()
{
	long long n,m,t,ans=1;
	scanf("%lld %lld",&n,&m);
	if(n<m){
		t=n;
		n=m;
		m=t;
	}
	if(n>m+1)
		printf("0\n");
	else{ //插空法A(m,m)A(n,n)(n-m+1)
		for(long long i=1;i<=m;i++)
 			ans=ans*i%Mo;
		ans=ans*ans%Mo;
		if(n>m)
			ans=ans*n%Mo;
		ans=ans*(m+2-n)%Mo;
		printf("%lld\n",ans);
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vc = vector<char>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using stkll = vector<pll>;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
#define rep(i, n) for (ll i = 0; i < (n); i++)
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
#ifndef ONLINE_JUDGE
    #define debug(x) cerr << #x << ": " << x << endl;
#else
    #define debug(x)
#endif

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

    string s; cin >> s;
    if(s == "ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define x first
#define y second	

#define sz(a) ((int)(a.size()))
using namespace std;
const int mod = 998244353;
int dp[3005][3005];
int mult(int a, int b)
{
	return a * (ll) b % mod;
}
int add(int a, int b)
{
	return a + b >= mod ? a + b - mod : a + b;
}
int sub(int a,  int b)
{
	return a - b < 0 ? a - b + mod : a - b;
}
int main() 
{
	int a , b , c , d;
	cin >> a >> b >> c >> d;
	dp[a][b] = 1;
	for(int i = a; i <= c; i++)
		for(int j = b; j <= d; j++)
		{
			dp[i + 1][j + 1] = sub(dp[i + 1][j + 1] , mult( i , mult( j , dp[i][j])));
			dp[i + 1][j] = add(dp[i + 1][j] , mult(dp[i][j] , j));
			dp[i][j + 1] = add(dp[i][j + 1] , mult(dp[i][j] , i));
		}
	cout << dp[c][d];
}












Measured memory_bytes: 38736
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <math.h>
#include <list>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

/*
// 最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

// 最小公倍数
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}
*/

#define MAX_V 200000

vector<pair<ll, ll>> G[MAX_V];

// ダイクストラ法
vector<ll> dijkstra(ll start) {
	vector<ll> dist(MAX_V, infll);
	dist[start] = 0; // dist[i] := start->iまでの最短距離
	priority_queue < pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>> que;
	que.push({ 0, start });
	while (!que.empty()) {
		ll cost, u; // 今までにかかった時間　現在の頂点
		cost = que.top().first, u = que.top().second;
		que.pop();
		if (dist[u] < cost) continue;
		for (auto tmp : G[u]) {
			ll v = tmp.first, time = tmp.second; // 隣接する頂点、その頂点まで行く時間
			if (dist[v] > dist[u] + time) {
				dist[v] = dist[u] + time;
				que.push({ dist[v], v });
			}
		}
	}
	return dist;
}

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

	int n;
	cin >> n;
	rep(i, n - 1) {
		ll a, b, c;
		cin >> a >> b >> c;
		G[a - 1].push_back({ b - 1, c });
		G[b - 1].push_back({ a - 1, c });
	}

	int q, k;
	cin >> q >> k;
	vector<int> x(q), y(q);
	rep(i, q) cin >> x[i] >> y[i];

	auto dist = dijkstra(k - 1);
	rep(i, q) {
		ll ans = dist[x[i] - 1] + dist[y[i] - 1];
		cout << ans << endl;
	}

	// 各aからKまでの最短距離をまず求める



	return 0;
}


Measured memory_bytes: 15088