akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define ff first
#define ss second
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
int main()
{
    ll n;
    cin>>n;
    vector<ll> arr(n);
    unordered_map<ll,ll> ump;
    ll sum=0;
    for(ll i=0;i<n;i++)
    {
        cin>>arr[i];
        sum+=arr[i];
        ump[arr[i]]++;
    }
    ll q;
    cin>>q;
    while(q--)
    {
        ll a,b;
        cin>>a>>b;
        ll val=ump[a];
        sum+=(val*(b-a));
        cout << sum << endl;
        ump[b]+=val;
        ump[a]=0;
    }
}

Measured memory_bytes: 7724
import java.math.*;
import java.util.*;
import static java.lang.System.*;

public class Main {
	//初期フィールド・メソッド---------------------------------------------
	static Scanner sc = new Scanner(System.in);
	static int min(int... ar) {Arrays.sort(ar); return ar[0];}
	static int max(int... ar) {Arrays.sort(ar); return ar[ar.length-1];}
	//------------------------------------------------------------


	//フィールド追加場所-----------------------------------------------
	//------------------------------------------------------------


	//メソッド追加場所------------------------------------------------
	//------------------------------------------------------------


	//mainメソッド---------------------------------------------------
	public static void main(String[] args) {
		
		int n = sc.nextInt();
		
		for (int i=0; i<n; i++) {
			
			char[] train = new char[200];
			Arrays.fill(train,'-');
			int pos = 100;
			
			String s = sc.next();
			train[pos] = s.charAt(0);
			
			for (int j=1; j<s.length();) {
				char c1 = s.charAt(j); j++;
				char c2 = s.charAt(j); j++;
				char car = s.charAt(j); j++;
				
				if (c1=='-' && c2=='>') {
					pos++;
					train[pos] = car;
				}
				else {
					pos--;
					train[pos] = car;
				}
			}
			
			for (int k=50; k<150; k++) {
				if (train[k]!='-') out.print(train[k]);
			}
			out.println();
		}

		
	}
	//------------------------------------------------------------
}


Measured memory_bytes: 27824
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
//#include <random>
#include <map>
#include <set>
//#include <unordered_map>
#include <cstdlib>
#include <functional>
#include <time.h>
//#include <chrono>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <iostream>
#include <limits>
#include <numeric>
//#include <type_traits>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define MOD 1000000007
#define SORT(s) sort(s.begin(), s.end());
#define REVERSE(s) reverse(s.begin(), s.end());
#define SUM(s) accumulate(s.begin(), s.end(), 0LL);
#define P pair<int,int>
#define mp make_pair
#define valid(x,y,h,w) (0<=x&&x<h&&0<=y&&y<w)
//#define int ll
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
int ndx[8] = { 0,1,0,-1, 1,1,-1,-1 };
int ndy[8] = { 1,0,-1,0, 1,-1,-1,1 };
double pi = 3.141592653589793;
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }
double log(double a, double b) { return log(b) / log(a); }


int main() {
	
	int ans = 0;
	int l, r, d;
	cin >> l >> r >> d;
	FOR(i, l, r+1) {
		if (i%d == 0)ans++;
	}
	cout << ans << endl;
}








Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int N,K,d;

    cin>>N;
    cin>>K;
    int a[100]={0};
    for(int i=0;i<K;i++) {
        cin>>d;
        for(int j=0;j<d;j++){
            int ak; 
            cin>>ak;
            a[ak-1]++;
        }   
    }   
    int cnt=0;
    for(int i=0;i<N;i++){
        if(a[i]==0) cnt++;
    }   
    cout<<cnt<<endl;


}


Measured memory_bytes: 3648
#!/usr/bin/env python
n = int(input())
a = list(map(int, input().split()))

money = 1000
kabu = 0 

for i in range(n-1):
    s = a[i]
    t = a[i+1]
    if s < t:
        k = money//s
        money %= s
        money += k*t 

print(money)


Measured memory_bytes: 9088
# include <bits/stdc++.h>
# define speed ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
# pragma GCC target("avx2")
# pragma GCC optimize("O3")
# pragma GCC optimize("unroll-loops")
# define int long long
  
using namespace std;
  
const int N = 1e3 + 7;
const int mod = 1e9 + 7;

int32_t main() {
    speed;
    string s;
    cin >> s;
    int n = s.size();
    vector < int > l, r, ans(n);
    for ( int i = 0; i < n; i++ ) {
        if ( s[i] == 'L' ) {
            l.push_back( i );
        }
        else {
            r.push_back( i );
        }
    } 
    for ( int i = 0; i < n; i++ ) {
        if ( s[i] == 'R' ) {
            int ind = upper_bound( l.begin(), l.end(), i ) - l.begin();
            int j = l[ind];
            int dist = j - i;
            if ( dist & 1 ) {
                ans[j - 1]++;
            }
            else {
                ans[j]++;
            }
        }
        else {
            int ind = lower_bound( r.begin(), r.end(), i ) - r.begin();
            int j = r[ind - 1];
            int dist = j - i;
            if ( dist & 1 ) {
                ans[j + 1]++;
            }
            else {
                ans[j]++;
            }
        }
    }
    for ( auto i: ans ) {
        cout << i << ' ';
    }
}


Measured memory_bytes: 5344
n,x,y = list(map(int,input().split()))

ans = [0]*(n-1)
for i in range(1,n):
    for j in range(i+1,n+1):
        dis = min(abs(j-i),abs(x-i)+abs(y-j)+1,abs(y-i)+abs(x-j)+1)
        ans[dis-1]+=1

for i in ans:
    print(i)

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

int main(){
  string s;
  cin >> s;
  
  int ans = 0, count = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i]=='A' || s[i]=='C' || s[i]=='G' || s[i]=='T') {
      count ++;
      ans = max(ans, count);
    }
    else {
      count = 0;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>

#include<cmath>

#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;

ll a[200000+5],b[200000+5],f[200000+5];
ll n,k,tot,ans;

bool cmp(ll a,ll b)
{
	return a>b;
}

bool Check(ll x)
{
	for(int i=1;i<=n;i++)

		b[i]=x/f[i];//使a[i]小于等于x达到的上界 

	ll res=0;

	for(int i=1;i<=n;i++)

		res+=max(0ll,a[i]-b[i]);

	return res<=k;
}

ll ju()
{
	ll l=0,r=(ll)1e12;

	while(l+1<=r)

	{

		ll mid=(l+r)>>1; 

		if(Check(mid))

			r=mid;

		else

			l=mid+1;

	}

	return r;

}

int main()
{

	scanf("%lld%lld",&n,&k);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
		tot+=a[i];
	}

	for(int i=1;i<=n;i++)
		scanf("%lld",&f[i]);

	if(tot<=k)//个人值可被减完 
	{
		printf("0\n");

		return 0;
	}
	sort(a+1,a+n+1);
	sort(f+1,f+n+1,cmp);
	printf("%lld\n",ju());
	return 0;

}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define pub push_back
#define pob pop_back
#define mp make_pair

using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie();
	
	ll n, k, x, y;
	cin >> n >> k >> x >> y;
	cout << x * min(n, k) + y * max(0LL, n - k);
	
	return 0;
}


Measured memory_bytes: 256
#if defined(LOCAL)
#define PROBLEM_NAME "a"
const double _max_double_error = 1e-9;
#include "testutils.h"
#define L(x...) (debug(x, #x))
#define I(x, ...) (x)
#define C(x...) CHECK(x)
#else
#define L(x, ...) (x)
#define I(x, ...) (x)
#define C(x, ...) ;
#include <bits/stdc++.h>
#endif

using namespace std;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using ii = pair<int,int>; using lu = unsigned long long; using l = long long;
using vs = vector<string>; using vii = vector<ii>;
using vl = vector<l>; using vvl = vector<vl>; using vvvl = vector<vvl>;
using ll = pair<l,l>; using vll = vector<ll>; using vvll = vector<vll>;
using vb = vector<bool>; using vvb = vector<vb>;
using vd = vector<double>; using vvd = vector<vd>;
using mll = unordered_map<l, l>;
const l INF = numeric_limits<l>::max();
const double EPS = 1e-10; static constexpr auto PI = acos(-1);
const l e0=1, e3=1000, e5=100000, e6=10*e5, e7=10*e6, e8=10*e7, e9=10*e8;
const char lf = '\n';
#define all(x) begin(x), end(x)
#define F(a,b,c) for (l a = l(b); a < l(c); a++)
#define B(a,b,c) for (l a = l(c) - 1; a >= l(b); a--)
#define VVL(x, a, b, i) vvl x(a, vl(b, l(i)));
#define VVVL(x, a, b, c, i) vvvl x(a, vvl(b, vl(c, l(i))));

const l MOD = e9 + 7;

void solve(istream& cin, ostream& cout) {
  l a, b, c; cin >> a >> b >> c;
  cout << max({a, b, c}) - min({a, b, c}) << lf;
}

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  cout << fixed << setprecision(15);
#if defined(LOCAL)
  // _generate_random_test = generate_random;
  // _solve_brute = solve_brute;
  // _player_b = player_b;
  // _custom_solution_checker = solution_checker;
  maybe_run_tests(cin, cout);
#else
  solve(cin, cout);
#endif
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) --> {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

int main()
{
    string o, e;
    cin >> o >> e;
    rep(i, 0, e.size())
        cout << o[i] << e[i];
    if (o.size() != e.size())
        cout << o[o.size()-1];
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
int i;
long n,sum=0,T,max,min;
scanf("%ld",&T);
for(i=1; i<=T; i++)
{
scanf("%lld ",&n);
if(i==1)
max=min=n;
if(max<n)
max=n;
else if(min>n)
min=n;
sum=sum+n;
}
printf("%d %d %lld\n",min,max,sum);
return 0;
}


Measured memory_bytes: 2136
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**7)
import bisect
import heapq
import itertools
import math
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from math import gcd
from operator import add, itemgetter, mul, xor
def cmb(n,r,mod):
  bunshi=1
  bunbo=1
  for i in range(r):
    bunbo = bunbo*(i+1)%mod
    bunshi = bunshi*(n-i)%mod
  return (bunshi*pow(bunbo,mod-2,mod))%mod
mod = 10**9+7
def I(): return int(input())
def LI(): return list(map(int,input().split()))
def MI(): return map(int,input().split())
def LLI(n): return [list(map(int, input().split())) for _ in range(n)]

#bisect.bisect_left(list,key)はlistのなかでkey未満の数字がいくつあるかを返す
#つまりlist[i] < x となる i の個数
#bisect.bisect_right(list, key)はlistのなかでkey以下の数字がいくつあるかを返す
#つまりlist[i] <= x となる i の個数
#これを応用することで
#len(list) - bisect.bisect_left(list,key)はlistのなかでkey以上の数字がいくつあるかを返す
#len(list) - bisect.bisect_right(list,key)はlistのなかでkeyより大きい数字がいくつあるかを返す
#これらを使うときはあらかじめlistをソートしておくこと！
n,x,t = MI()
print(t*math.ceil(n/x))


Measured memory_bytes: 10032
/*
 * author :Sadik Hassan
 *
*/
#include "bits/stdc++.h"
using namespace std;
#define ll            long long
#define nl            "\n"
#define pb            push_back
#define fi            first
#define se            second
#define PI            (acos(-1.0))
#define _SAD()        ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
#define rep(i,a,n)    for(int i=a;i<n;i++)
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
#define TSFL(s)       transform(s.begin(),s.end(),s.begin(),::toupper);
#define TSFH(s)       transform(s.begin(),s.end(),s.begin(),::tolower);
typedef vector<int> vi;
typedef vector<ll> vii;
typedef set<int> si;
typedef set<ll> sii;
/*---------------------------------------------------------------------*/

const int N = 2e5+10;
const int INF = (int)1e9+5;

int main()
{
    _SAD()
    int n;
    cin>>n;
    ll ans=0;
    rep(i,1,n+1)
    {
        for(int j=1;j<=n;j++)
        {
            for(int k=1;k<=n;k++)
            {
                ans+=__gcd(__gcd(i,j),k);
            }
        }
    }
    cout<<ans<<nl;
    return 0;
}


Measured memory_bytes: 3636
#include <stdio.h>
#include <stdlib.h>
typedef struct data{
  int u,v,w;
}data;
int adj[10001];
int cmp(void const *a,void const *b){
  return ((data*)a)->w > ((data*)b)->w;
}
int sc(int x){
  if(adj[x]==-1)return x;
  else{
    adj[x]=sc(adj[x]);
    return adj[x];
  }
}
int Union(int x,int y){
  adj[x]=y;
}
int main(){
  int i,n,u,v,w,sum,m,C,k;
  data E[100001];
  scanf("%d%d",&n,&m);

  for(i=0;i<=n;i++){
    adj[i]=-1;
  }
  i=0;
  for(i=0;i<m;i++){
    scanf("%d%d%d",&u,&v,&w);
    E[i].u=u;
    E[i].v=v;
    E[i].w=w;
  }
  qsort(E,m,sizeof(data),cmp);

  int selected = 0;
  i=0;
  sum=0;
  while(selected<n-1){
    if(sc(E[i].u)!=sc(E[i].v)){
      selected++;
      sum+=E[i].w;
      Union(sc(E[i].u),sc(E[i].v));
    }
    i++;
  }
  printf("%d\n",sum);
  return 0;
}



Measured memory_bytes: 4764
class Main {

	public static void main(String[] args)
	{
		for(int i = 1; i < 10; ++i)
		{
			for(int j = 1; j < 10; ++j)
			{
				System.out.println(Integer.toString(i)+"x"+Integer.toString(j)+"="+Integer.toString(i*j));
			}
		}
	}
} 

Measured memory_bytes: 16868
#include<iostream>
#include<vector>
using namespace std;
struct Coordinate {
	long double x;
	long double y;
};
int main() {
	short int n;
	cin >> n;
	vector<bool>l;
	for (int i = 0; i < n; i++){
		Coordinate A, B, C, D;
		cin >> A.x >> A.y >> B.x >> B.y;
		long double Inclination_of_AB = (B.y - A.y) / (B.x - A.x);
		cin >> C.x >> C.y >> D.x >> D.y;
		long double Inclination_of_CD = (D.y - C.y) / (D.x - C.x);
		l.push_back(Inclination_of_AB == Inclination_of_CD);
	}
	for (bool i : l) {
		if (i) cout << "YES";
		else cout << "NO";
		cout << endl;
	}
	return 0;
}

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

#define vl vector<ll>
#define vs vector<string>
#define vll vector< vector<ll> >
#define pll pair<ll,ll>
#define pls pair<ll,string>
#define psl pair<string,ll>
#define tll tuple<ll, ll, ll>
#define vp vector< pair<ll,ll> >
#define vt vector< tuple<ll, ll, ll> >
#define all(c) c.begin(),c.end()

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
 
const ll inf = 1000000001;
const ll INF = 1e18;
const ll MOD = 1000000007;
#define NN 2020202

//command
//c++ atcoder.cpp -std=c++14
//./a.out

//cout << setprecision(12) << ans << endl;

int main(){
  string s;
  cin >> s;
 
  ll start = 0;
  ll end = s.length() - 1;
  
  ll ans = 0;
  while (end >= start){
    if (s[start] != s[end]) ans += 1;
    end -= 1;
    start += 1;
  }
 
  cout << ans << endl;
}

Measured memory_bytes: 256
inputNum = input().split()

x = int(inputNum[0])
y = int(inputNum[1])

def gcd(x, y):
    if x < y:
        x, y = y, x

    if x%y != 0:
        return gcd(y, x%y)

    else:
        return y

print(str(gcd(x, y)))



Measured memory_bytes: 5600
a,b = map(int,input().split())
low = int(min(a//0.08,b//0.1))
high = int(max((a+1)//0.08,(b+1)//0.1))
for i in range(low,high+1):
    if int(i*0.08)==a and int(i*0.1)==b:
        print(i);  break
else:
    print(-1)

Measured memory_bytes: 9184
#include <bits/stdc++.h>
#define dum(x) cout<<#x<<'='<<x<<endl
#define ll long long
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<vector<int>> fv(n, vector<int>(10));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 10; j++) {
      cin >> fv.at(i).at(j);
    }
  }
  vector<vector<int>> pv(n, vector<int>(11));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 11; j++) {
      cin >> pv.at(i).at(j);
    }
  }

  int ans = -1000000000;
  for (int b = 1; b < (1 << 10); b++) {
    int cc = 0;
    for (int i = 0; i < n; i++) {
      int c = 0; // 同じ時間帯に開店してる数
      for (int j = 0; j < 10; j++) {
        if ((b & (1 << j)) && fv.at(i).at(j)) c++;
      }
      cc += pv.at(i).at(c);
    }
    ans = max(ans, cc);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
    ll num;
    cin>>num;
    ll ans=num+1;
    for(ll i=1; i*i<=num; i++){
    	if(num%i==0){
    		ans=min(ans,i+num/i);
		}
	}
	cout<<ans-2;
	return 0;
}

Measured memory_bytes: 3532
#include<iostream>
#include<stdio.h>
using namespace std;

int main(){
    int h, w;
    for (int i = 0; ; i++)
    {
        cin>>h>>w;
        if (h == 0 && w == 0)
        {
            break;
        }

        for (int j = 0; j < h; j++)
        {
            for (int k = 0; k < w; k++)
            {
                if ((j + k)%2 == 0)
                {
                    cout<<"#";
                }
                else
                {
                    cout<<".";
                }
            }
            cout<<endl;
        }
       cout<<endl; 
    }
}


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

int main(){
    char c[2][3];
    rep(i,2)rep(j,3) cin >> c[i][j];
    if(c[0][0] == c[1][2] && c[0][1] == c[1][1] && c[0][2] == c[1][0]) cout << "YES" << endl;
    else cout << "NO" << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
#include <random>

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

const int L=1e5+10;
vector<int> edge[L];
int A[L];
int B[L];
int root;
P depth[L];
P f(int a){
	if(depth[a].first!=-1){
		return depth[a];
	}
	if(a==root){
		return depth[a]=P(0,0);
	}
	P r=P(-1,-1);
	for(auto e:edge[a]){
		r=max(r,P(f(e).first+1,e));
	}
	return depth[a]=r;
}
int main() {
	int N,M;
	cin >> N >> M;
	for(int i=0;i<N-1+M;i++){
		int a,b;
		cin >> a >> b;
		A[i]=a;
		B[i]=b;
		edge[b].push_back(a);
	}
	memset(depth,-1,sizeof(depth));
	for(int i=1;i<=N;i++){
		if(edge[i].size()==0){
			root=i;
			break;
		}
	}
	for(int i=1;i<=N;i++){
		cout << f(i).second << endl;
	}




	return 0;
}



Measured memory_bytes: 11776
from functools import reduce


def modcombination(n, k, mod):
    # nCk % mod
    num = reduce(lambda x, y: x * y % mod, range(n, n - k, -1))
    den = reduce(lambda x, y: x * y % mod, range(1, k + 1))
    return num * pow(den, mod - 2, mod) % mod


if __name__ == '__main__':
    MOD = 10 ** 9 + 7
    x, y = map(int, input().split())
    if (x + y) % 3 != 0:
        print(0)
        exit(0)

    m = (2 * x - y) // 3
    n = x - (2 * m)
    if n < 0 or m < 0:
        print(0)
        exit(0)
    if n == 0 or m == 0:
        print(1)
        exit(0)
    print(modcombination(n + m, n, MOD) % MOD)


Measured memory_bytes: 3572
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let h: usize = itr.next().unwrap().parse().unwrap();
    let w: usize = itr.next().unwrap().parse().unwrap();
    let g: Vec<Vec<char>> = (0..h)
        .map(|_| itr.next().unwrap().chars().collect())
        .collect();

    let dx: Vec<isize> = [0, -1, 0, 1].to_vec();
    let dy: Vec<isize> = [1, 0, -1, 0].to_vec();
    for y in 0..h {
        for x in 0..w {
            if g[y][x] == '#' {
                let mut ok = false;
                for i in 0..4 {
                    let nx = x as isize + dx[i];
                    let ny = y as isize + dy[i];
                    if 0 <= nx && nx < w as isize && 0 <= ny && ny < h as isize {
                        if g[ny as usize][nx as usize] == '#' {
                            ok = true;
                        }
                    }
                }
                if !ok {
                    println!("No");
                    return;
                }
            }
        }
    }
    println!("Yes");
}


Measured memory_bytes: 2184
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] list = new int[n];
        for(int i=0; i<n; i++){
            list[i] = scan.nextInt();
        }

        int minindex;
        int min;
        int max = list[n-1];
        int diff = max-list[0];
        for(int m=n; m>0; ){
            if(m==1){
                if(diff<list[1]-list[0]){
                    diff = list[1]-list[0];
                }
                m--;
            }
            minindex = 0;
            min = list[0];
            for (int i = 0; i < m; i++) {
                if (list[i] < min) {
                    minindex = i;
                    min = list[i];
                }
            }
            if (minindex == m-1) {
                if(diff<min-list[m-2]){
                    diff = min-list[m-2];
                }
                m--;
            } else {
                max = list[minindex+1];
                for (int i = minindex + 1; i < n; i++) {
                    if (list[i] > max) {
                        max = list[i];
                    }
                }
                if(diff<max-min){
                    diff = max-min;
                }
                m = minindex;
            }
        }
        System.out.println(diff);
    }
}



Measured memory_bytes: 100628
use std::io::stdin;
use std::str::FromStr;

fn read_line<T>() -> Vec<T>
where
    T: FromStr,
    <T as std::str::FromStr>::Err: std::fmt::Debug,
{
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    s.trim()
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect()
}

fn read_str_as_char_vec() -> Vec<char> {
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    s.trim().chars().collect()
}

fn read_str_as_T<T>() -> T
where
    T: FromStr,
    <T as std::str::FromStr>::Err: std::fmt::Debug,
{
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    s.trim().parse().unwrap()
}

fn main() {
    let k: usize = read_line()[0];
    let s = read_str_as_char_vec();
    if s.len() <= k {
        let res_s: String = s.into_iter().collect();
        println!("{}", res_s);
    } else {
        let res_s: String = (*(&s[..k])).into_iter().collect();
        println!("{}...", res_s);
    }
}


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

int main(){
  string s;
  cin >> s;
  int answer;
  if(s == "SUN")answer = 7;
  if(s == "MON")answer = 6;
  if(s == "TUE")answer = 5;
  if(s == "WED")answer = 4;
  if(s == "THU")answer = 3;
  if(s == "FRI")answer = 2;
  if(s == "SAT")answer = 1;
  
  cout << answer << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    ll r;
    cin>>r;
    cout<<fixed<<setprecision(10)<<3.1415926535*2.*r<<endl;
}


Measured memory_bytes: 3764
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;

typedef long long Int;
typedef pair<Int,Int> P;
#define print(x) cout<<(x)<<endl

#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10
#define MOD 1000000007



int main() {
	char x, y, z;
	cin >> x >> y >> z;
	if (x == y || y == z || z == x)print("No");
	else print("Yes");



	return 0;
}

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

int gcd(int a, int b)
{
    // 2つの数が与えられた時のgcd
    // a > bと考える
    if (b == 0)
    {
        return a; // aの体力が残っている
    }
    else
    {
        gcd(b, a % b); // aがbで引かれまくって小さくなった方
    }
}

int gcd(vector<int> a)
{
    // 複数の数のgcdを求める
    int ans = a[0];
    for (int i = 1; i < a.size(); i++)
    {
        ans = gcd(ans, a[i]);
    }
    return ans;
}

int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    int ans = gcd(A);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int N;
  cin>>N;
  vector<int>arr(N+1);
  for(int i=2; i<=N; i++)
    cin>>arr[i];
  vector<int>fq(N+1);
  for(int i=2; i<=N+1; i++)
  {
    fq[arr[i]]++;
  }
  for(int i=1; i<=N; i++)
    cout<<fq[i]<<"\n";
  return 0;
}

Measured memory_bytes: 4764
#include <iostream>




using namespace std;
int A, B;



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


	if (A < B) {
		swap(A, B);
	}

	int a = A;
	int b = B;

	int r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}

	long long ans = (A*(long long)B) / b;


	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <cctype>
#include <tuple>
#include <array>
#include <climits>
#include <bitset>
#include <cassert>


// BEGIN CUT HERE
#ifdef _MSC_VER
#include <agents.h>
#endif
// END CUT HERE 

#define FOR(i, a, b) for(int i = (a); i < (int)(b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define REV(v) v.rbegin(), v.rend()
#define MEMSET(v, s) memset(v, s, sizeof(v))
#define UNIQUE(v) (v).erase(unique(ALL(v)), (v).end())
#define MP make_pair
#define MT make_tuple

using namespace std;

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

vector<P> G[1010];

int a[1010];

int rec(int p, int v){
	int res = 0;
	for (auto e : G[v]){
		if (e.first == p) continue;
		int cost = e.second;
		if (!a[e.first]) cost = min(cost, rec(v, e.first));
		res += cost;
	}
	return res;
}

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

	cout << rec(-1, 0) << endl;

	return 0;
}

Measured memory_bytes: 1268
#include <iostream>

using namespace std;

int main()
{
    int x[]={2,3,4,5,6,7,8,9,10,11,12,13,1};
    int i=0;
    int m,n,o,p;
    cin>>m>>n;
    for (i=0;i<13;i++){
        if (x[i]==m)
            o=i;}
    for (int j=0;j<13;j++){
        if (x[j]==n)
            p=j;}
    if (o>p)
        cout<<"Alice";
    else if (o==p)
        cout<<"Draw";
    else if (p>o)
        cout<<"Bob";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
char s[111111];
bool a[111111];
bool chk2(bool mid,bool response,bool lef,bool rig){
	if(mid)return response == (lef == rig);
	return response != (lef == rig);
}
bool chk(bool p1,bool p2){
	a[0] = p1;
	a[1] = p2;
	for(int i=2; i<n; i++){
		if(a[i-1]){
			if(s[i-1] == 'o')
				a[i] = a[i-2];
			else
				a[i] = !a[i-2];
		}else{
			if(s[i-1] == 'o')
				a[i] = !a[i-2];
			else
				a[i] = a[i-2];
		}
	}
	if(chk2(a[0],s[0]=='o',a[1],a[n-1]) && chk2(a[n-1],s[n-1]=='o',a[0],a[n-2])){
		for(int i=0; i<n; i++)
			putchar(a[i]?'S':'W');
		puts("");
		return true;
	}
	return false;
}
int main(){
	scanf("%d%s",&n,s);
	if(!chk(0,0) && !chk(0,1) && !chk(1,0) && !chk(1,1))
		puts("-1");
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; ++i)
#define repR(i, n) for(ll i = n; i >= 0; ++i)
#define FDS(i, n) for(ll i = 0; i < n; ++i)
#define FDSR(i, n) for(ll i = n; i >= 0; ++i)
#define FOR(i, m, n) for(ll i = m; i < n; ++i)
#define FORR(i, m, n) for(ll i = m;i >= n;--i)
#define VSORT(v) sort(v.begin(), v.end());
#define VREV(v) reverse(v.begin(), v.end());
#define INF 999999999
#define itn ll
#define ednl endl
using namespace std;
typedef long long ll;template<typename Typell>Typell G_C_D(Typell a, Typell b){if (a < 0) a = -a;if (b < 0) b = -b;while (b != 0) {a %= b;if (a == 0) return b;b %= a;}return a;}template<typename Typell>
Typell G_C_D(const std::vector<Typell> &list){Typell a = list[0];for (size_t i = 1; i < list.size(); ++i) {a = G_C_D(a, list[i]);}return a;}template<typename Typell>Typell L_C_M(Typell a, Typell b) {if( a == 0 && b == 0)return 0;return a / G_C_D(a, b) * b;}
template<typename Typell>Typell L_C_M(const std::vector<Typell> &list){Typell a = list[0];for (size_t i = 1; i < list.size(); ++i) {a = L_C_M(a, list[i]);}return a;}
const int mod = 1000000007; 

long long inv[9999999],fact[9999999],ifact[9999999];
long long comb(ll n, ll k)
{
	return fact[n] * ifact[k] % mod * ifact[n-k] % mod;
}



int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	
	inv[1] = fact[0] = fact[1] = ifact[0] = ifact[1] = 1;
	for (int i=2;i<9999999;i++){
		inv[i] = (mod - mod / i) * inv[mod % i] % mod;
		fact[i] = fact[i-1] * i % mod;
		ifact[i] = ifact[i-1] * inv[i] % mod;
	}
	
	ll N,K;
	cin>>N>>K;
	ll B=K;
	ll A=N-K;
	for(int i=1;i<=K;i++){
	    ll ans=0;
	    if(A+1>=i&&B-1>=i-1){
		ans=comb(A+1,i)*comb(B-1,i-1);
	    }
	    else ans=0;
		ans%=mod;
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 234624
#include <algorithm>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <deque>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <ratio>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = long long;
using ull = unsigned long long;
template<class T> using v = vector<T>;
template<class T, class U> using p = pair<T, U>;

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

template<class T> T read() { T x{}; cin >> x; return x; }
template<class T> v<T> read(int N){ v<T> x(N); REP(i, N) cin >> x[i]; return x; }

template<class T>
void write(const T &x){ cout << x << endl; }
void write(double x){ printf("%.15f\n", x); }

const ull MOD = 1000'000'007;


int main(){
    ll H, W, N;
    cin >> H >> W >> N;
    ll x = max(H, W);
    cout << (N + x - 1) / x << endl;
}



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

/*
 bit全探索
 ビット演算

 (1<<n) ＝2^n (全探索)


*/
int main() {

    string s;
    cin >> s;
    int n = s.size();
    ll sum = 0;
    for(int bit = 0; bit < (1 << (n - 1)); bit++){
        ll cur = 0;
        for(int i = 0; i < n; i++){
            cur = cur * 10 + (s[i] - '0');
            if(bit & (1 << i)){
                sum += cur;
                cur = 0;
            }
        }
        sum += cur;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<algorithm>
#include<queue>
#include<vector>

int main() {
  int num, limit;
  std::map<int,int> data;
  std::cin >> num >> limit;
  for (int i=0; i<num; i++) {
    int temp_num;
    std::cin >> temp_num;
    if(data.count(temp_num)) {
      data.at(temp_num)++;
    }
    else {
      data[temp_num] = 1;
    }
  }
  
  std::priority_queue<int, std::vector<int>, std::greater<int>> queue;
  for (auto p:data) {
    int temp_num = p.second;
    queue.push(temp_num);
  }
  
  int sum=0;
  if(data.size() <= limit) {
    std::cout << 0 << std::endl;
  }
  else {
    for (int i=0; i<data.size()-limit; i++) {
      sum += queue.top();
      queue.pop();
    }
    std::cout << sum << std::endl;
  }
}


Measured memory_bytes: 10748
//#pragma GCC optimize ("Ofast")
#include <iostream>
#include <vector>
using namespace std;
using int64 = int64_t;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
#define print(x) cout << (x) << '\n'
#define all(v) (v).begin(), (v).end()
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define fi first
#define se second

const int MAX = 2e5;
const int MOD = 1e9 + 7;
int64 fac[MAX] = {}; int64 inv[MAX] = {}; int64 finv[MAX] = {};

void make_table(){
    fac[0] = 1; fac[1] = 1;
    finv[0] = 1; finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; ++i) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

int64 com(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

vector<pll> prime_fact(int64 n){
    vector<pll> res;
    for (int64 i = 2; i * i <= n; ++i){
        if (n % i != 0) continue;
        int cnt = 0;
        while (n % i == 0){
            n /= i; ++cnt;
        }
        res.EB(i, cnt);
    }
    if (n != 1) res.EB(n, 1);
    return res;
}

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

  make_table();
  int64 n, m; cin >> n >> m;
  vector<pll> v = prime_fact(m);
  
  int64 ans = 1LL;
  
  for (auto x : v){
    ans = ans * com(x.se + n - 1, x.se) % MOD;
  }
  print(ans % MOD);

  return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include <cstdio>
#include <string.h>
#include <vector>
#include <limits>
#include <algorithm>
#include <stdlib.h>
#include <math.h>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <assert.h>
#include <sstream>
#include <type_traits>
#define SET(x,y) x |= (1 << y)
#define CLEAR(x,y) x &= ~(1<< y)
#define READ(x,y) ((0u == (x & (1<<y)))?0u:1u)
#define TOGGLE(x,y) (x ^= (1<<y))
#define watch(x) cout << (#x) << " is " << (x) << endl
#define pb push_back
#define mp make_pair
#define si(n) scanf("%d",&n)
#define sf(n) scanf("%f",&n)
#define sl(n) scanf("%lld",&n)
#define slu(n) scanf("%llu",&n)
#define sd(n) scanf("%lf",&n)
#define ss(n) scanf("%s",n)
#define pnl printf("\n")
#define ll long long
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pF first
#define pS second
#define CL(a,b) memset(a,b,sizeof(a))
#define sqr(x) ((x)*(x))
#define intLIMIT numeric_limits<int>
#define longLIMIT numeric_limits<long long>
#define GCD(a,b) __gcd((a),(b))
#define dbl(x) (double)(x)
#define vi vector <int>
#define vii vector < pair <int, int> >
#define vll vector <long long>
#define allof(x) (x).begin(), (x).end()
#define fastCin cin.sync_with_stdio(0);cin.tie(0)
#define scanUnsigned(x) do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
#define printArr(a,l) cout<<#a<<": ";for(int i=0;i<(l);i++){cout<<a[i]<<" ";}cout<<endl
#define print2dArr(a,r,c) cout<<#a<<":\n";for(int i=0;i<(r);i++){for(int j=0;j<(c);j++){cout<<a[i][j]<<" ";}cout<<endl;}
char _;
using namespace std;
void PRINT (int x, int y) { for (int i = y-1; i >= 0; i--) { cout << READ(x,i); } cout << endl; }

vector<string>vec_splitter(string s){s+=',';vector<string>res;while(!s.empty()){res.push_back(s.substr(0,s.find(',')));s=s.substr(s.find(',')+1);}
return res;}
void debug_out(vector<string>__attribute__((unused))args,__attribute__((unused))int idx,__attribute__((unused))int LINE_NUM){cerr<<endl;}
template<typename Head,typename...Tail>void debug_out(vector<string>args,int idx,int LINE_NUM,Head H,Tail...T){if(idx>0)cerr<<", ";else cerr<<"Line("<<LINE_NUM<<") ";stringstream ss;ss<<H;cerr<<args[idx]<<" = "<<ss.str();debug_out(args,idx+1,LINE_NUM,T...);}
#ifdef LOCAL_DBG
#define dbg(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define dbg(...) 42
#endif

int main () {
	fastCin;
	ll p[2][2] = {0};
	for (int x = 0; x < 2; x++) {
		for (int i = 0; i < 2; i++) {
			cin >> p[x][i];
		}
	}
	ll ans = longLIMIT::min();
	for (int x = 0; x < 2; x++) {
		for (int i = 0; i < 2; i++) {
			ans = max (ans, p[0][x]*p[1][i]);
		}
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 3196
#include <bits/stdc++.h>
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FSP(x) fixed << setprecision(x)
using namespace std;
using ll = long long;
constexpr ll INF = LLONG_MAX;
constexpr long double PI = acosl(-1);
void Yes() {cout << "Yes\n";}
void No() {cout << "No\n";}
void YES() {cout << "YES\n";}
void NO() {cout << "NO\n";}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	//constexpr ll P = 1e9 + 7;
	//constexpr ll P = 998244353;

	ll n, m;
	cin >> n >> m;
	set<pair<ll, ll>> st;
	while (m--) {
		ll a, b;
		cin >> a >> b;
		a--; b--;
		st.insert({a, b});
		st.insert({b, a});
	}

	for (ll i = 1; i < n - 1; i++) {
		if (st.find({0, i}) != st.end() && st.find({i, n - 1}) != st.end()) {
			cout << "POSSIBLE" << endl;
			return 0;
		}
	}
	cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 28604
// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬████╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  int n;
  cin >> n;

  vector<int> a(n+1);
  REP(i,n+1) cin >> a[i];
  
  vector<int> b(n);
  REP(i,n) cin >> b[i];
  
  int ans = 0;
  REP(i,n){
    ans += min(a[i],b[i]);
    b[i] -= a[i];
    if(b[i] > 0){
      ans += min(a[i+1],b[i]);
      a[i+1] = max(a[i+1]-b[i],0LL);
    }
  }

  cout << ans << endl;


  return 0;
}

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

int main()
{
  int N;  
  vector<int> bangou(3000000);
  vector<int> d(3000000);

  cin >> N;

  for(int i=1; i<N; i++)
  {
      cin >> bangou.at(i);
  }

  for(int i=1; i<N; i++)
  {
      d.at(bangou.at(i))=d.at(bangou.at(i))+1;
  }

  for(int i=1; i<=N; i++)
  {
      cout << d.at(i) << endl;
  }

}


Measured memory_bytes: 26580
while 1:
  n, a, b, c, x = map(int, raw_input().split())
  if not n:
    break
  i = f = 0
  y = map(int, raw_input().split())
  while f <= 10000:
    if x == y[i]:
      i += 1
    x = (a * x + b) % c
    if i == n:
      print f
      break
    f += 1
  else:
    print -1

Measured memory_bytes: 4212
#include <stdio.h>

int main(void){
	int n, a, b, i, c, s=0;
	scanf("%d %d %d", &n, &a, &b);

	for(i = 1;i <= n;++i){
		if(i >= 10000){
			c = 1;
		}else if(i >= 1000){
			c = (i / 1000) + ((i % 1000) / 100) + ((i % 100) / 10) + (i % 10);
		}else if(i >= 100){
			c = (i / 100) + ((i % 100) / 10) + (i % 10);
		}else if(i >= 10){
			c = (i / 10) + (i % 10);
		}else{
			c = i;
		}

		if(c >= a && c <= b) s+= i;
	}

	printf("%d\n", s);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N; cin >>N;
  vector<long long>A(N+1);
  for(int i=0;i<N+1;i++)cin>>A.at(i);
  vector<long long>B(N+1);
  for(int i=0;i<N;i++)cin>>B.at(i);
  
  long long kotae=0;
  for(int i=0;i<N;i++){
    kotae+=min(A.at(i),B.at(i));
    B.at(i)=B.at(i)-min(A.at(i),B.at(i));
    kotae+=min(A.at(i+1),B.at(i));
    A.at(i+1)=A.at(i+1)-min(A.at(i+1),B.at(i));
  }
  cout <<kotae<<endl;
  return 0;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> adj[N];
  int height[N];
  for (int i = 0; i < N; ++i) {
    cin >> height[i]; 
  }
  for (int i = 0; i < M; ++i) {
    int u, v;
    cin >> u >> v;
    --u, --v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  int ans = 0;
  for (int i = 0; i < N; ++i) {
    bool allHigher = true;
    for (auto &it : adj[i]) {
      allHigher &= height[i] > height[it];
    }
    ans += allHigher;
  }
  cout << ans << '\n';
  return 0;
}


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

using namespace std;
int main() {
    int n;
    bool color[8] = {};
    int any_color = 0;
    int num_color = 0;;

    cin >> n;

    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        if (a >= 3200) {
            any_color++;
        } else {
            color[a/400] = true;
        }
    }

    for (int i = 0; i < 8; i++) {
        if (color[i]) num_color++;
    }

    cout << max(1, num_color) << " " << any_color+num_color << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<cmath>
#include<iomanip>
using namespace std;
using ll = long long;
const int mod = 1000000007;

int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if (abs(a-c)<=d || (abs(a-b)<=d && abs(b-c) <=d)){
    cout<<"Yes"<<endl;
  }
  else cout<<"No"<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <set>
#include <map>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>

using namespace std;

const int N = 300100;

int n, m, a, b;
vector <int> g[N];
multiset <int> ms;

int main() {

	scanf("%d %d", &n, &m);

	for (int i = 0; i < n; i++) {
		scanf("%d %d", &a, &b);
		if (a <= m) g[m - a].push_back(b);
	}

	long long res = 0;

	for (int i = m; i >= 0; i--) {
		for (int j = 0; j < g[i].size(); j++) ms.insert(-g[i][j]); 
		if (ms.size() > 0) {
			multiset <int>::iterator it = ms.begin();
			res -= (*it);
			ms.erase(it);
		}
	}

	printf("%lld\n", res);

	return 0;

}

Measured memory_bytes: 12416
#include <stdio.h>
const int N = 105; 
int main()
{
	int n, a[N] = {0};
	scanf("%d", &n);
	for(int i = 0; i < n; i++) 
	{
		scanf("%d", &a[i]);
	}
	for(int i = n - 1; i >= 0; i--) 
	{
		if(i)
		{
			printf("%d ", a[i]);
		}
		else
		{
			printf("%d\n", a[i]);
		}
	}
	return 0;
	
	
	
} 


Measured memory_bytes: 2720
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}
 
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=std::sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}
 
long long gcd_(long long a, long long b){
  if(a<b){
    std::swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
//using namespace std;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;
 
int main(){
  using namespace std;
  int n, m;
  cin>>n>>m;
  int ans = n * (n - 1) / 2 + m * (m - 1) / 2;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
def input():
    import sys
    return sys.stdin.readline().rstrip()


def main():
    import math
    import collections
    import itertools

    n, m = map(int, input().split())
    if n == 1 or m == 1:
        if n == 1 and m == 1:
            print(1)
        else:
            print(max(n, m) - 2)    
    else:
        print((n - 2) * (m - 2))



if __name__ == '__main__':
    main()

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pi;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  string s;
  int k;
  cin >> s >> k;
  if (s.size() == 1) {
    cout << k/2 << '\n';
    return 0;
  }
  int n = (int)s.size();
  int val0 = 0;
  int val1 = 1;
  bool fff = false;
  for (int i = 0; i < n-1; ++i) {
    if (s[i] == s[i+1]) {
      ++val0;
      ++i;
      if (i == n-1) fff = true;
    }
  }
  bool f2 = false;
  for (int i = 1; i < n-1; ++i) {
    if (s[i] == s[i+1]) {
      ++val1;
      ++i;
      if (i == n-1) f2 = true;
    }
  }
  if (s[0] != s.back()) fff = true;
  if (fff) {
    cout << (ll)val0*(ll)k << '\n';
    return 0;
  }
  if (f2) {
    ll res = (ll)(val0 + val1)*(ll)(k/2);
    if (k%2) res += val0;
    cout << res << '\n';
    return 0;
  }
  cout << (ll)val0 + (ll)val1*(ll)(k-1) << '\n';
}


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

using namespace std;
int main()
{
string s;
cin>>s;
    
    int len=s.size();
    int sum=0;
    for(int i=0;i<len;i++)
    {sum+=s[i]-'0';
    }
    if(sum%9==0){
        cout<<"Yes";
    }else{
        cout<<"No";
    }

  return 0;
}

Measured memory_bytes: 3728
/*
  AtCoder Regular Contest 099
  D - Sunuke Numbers
*/

#include<iostream>
using namespace std;

unsigned long long K;

unsigned long long calcSunuke(unsigned long long n) {
  unsigned long long sunuke = 0;
  while (n != 0) {
    sunuke += n % 10;
    n /= 10;
  }
  return sunuke;
}

bool check(unsigned long long n, unsigned long long base) {
  return n * calcSunuke(n + base) <= calcSunuke(n) * (n + base);
}

int main() {
  scanf("%llu", &K);

  unsigned long long c = 0;
  unsigned long long n = 0;
  unsigned long long base = 1;

  while (1) {
    if (K <= c) break;
    
    if (!check(n + base, base)) base *= 10;

    n += base;
    printf("%llu\n", n);
    ++c;
  }
  return 0;
}

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

a = []
b = []
l.sort(reverse=True)
for i, r in enumerate(l, start=1):
    if i % 2 == 1:
        a.append(r)
    else:
        b.append(r)
print(sum(a) - sum(b))

Measured memory_bytes: 3060
use std::io::*;
use std::str::*;
//use std::collections::HashSet;


fn read<T: FromStr>(s: &mut StdinLock) -> T {
    let s = s.by_ref().bytes().map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok().unwrap()
}

 

fn main() {
 
    let s = stdin();
    let mut s = s.lock();
    let s = &mut s;

	let n = read::<usize>(s);
	for _i in 0 .. n {
		print!("ACL");
	}
	println!();	
}



Measured memory_bytes: 2068