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

using namespace std;

int main() {
    string S;
    cin >> S;

    int a = (S[0]-'0')*10 + (S[1]-'0');
    int b = (S[2]-'0')*10 + (S[3]-'0');
    
    bool ok1 = (1 <= b && b <= 12);
    bool ok2 = (1 <= a && a <= 12);

    if(ok1 && ok2) {
        cout << "AMBIGUOUS" << endl;
    } else if(ok1) {
        cout << "YYMM" << endl;
    } else if(ok2) {
        cout << "MMYY" << endl;
    } else {
        cout << "NA" << endl;
    }

    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
using lint = long long;//
template <typename T>
T sq (T x) {
    return x * x;
}

signed main () {
    vector<int> A(3);
    rep(i,3){
        cin >> A.at(i);
    }
    if(count(all(A),5) == 2 && count(all(A),7) == 1 ){
        cout << "YES" <<endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}



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

int main()
{
    int n;
    int m;
    int l;
    cin >>n>>m>>l;
    int a[n][m];
    for (int i=0;i<n;i++){
        for (int j=0;j<m;j++){
            cin>>a[i][j];
        }
    }
    int b[m][l];
    for (int i=0;i<m;i++){
        for (int j=0;j<l;j++){
            cin>>b[i][j];
        }
    }
    long c[n][l]={0};
    for (int i=0;i<n;i++){
        for (int j=0;j<l;j++){
            c[i][j]=0;
            for (int k=0;k<m;k++){
                c[i][j]+=a[i][k]*b[k][j];
            }
        }
    }
    for (int i=0;i<n;i++){
        for (int j=0;j<l;j++){
            cout<< c[i][j];
            if (j!=l-1){
                cout <<" ";
            }
        }cout<<endl;
    }
   
    return 0;
}


Measured memory_bytes: 3212
#include<iostream>
#include<sstream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<cfloat>
#include<functional>
#include<map>
#include<string>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<deque>
#include<set>
#include<bitset>
#include<list>
#include<numeric>
#include<complex>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<long long, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<long long, long long> ll_ll;
typedef pair<double, double> d_d;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define rep2d(i, j, n) for(i = 0;i < n;++i)for(j = i + 1;j < n;++j)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define sc(x) cin >> x
#define sc2(x, y) cin >> x >> y
#define sc3(x, y, z) cin >> x >> y >> z
#define scn(n, a) rep(i, n)cin >> a[i]
#define sc2n(n, a, b) rep(i, n)cin >> a[i] >> b[i]
#define pri(x) cout << x << "\n"
#define pri2(x, y) cout << x << " " << y << "\n"
#define pri3(x, y, z) cout << x << " " << y << " " << z << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << x << "\n"
#define debug2(x, y) cout << " --- " << x << " " << y << "\n"
#define debug3(x, y, z) cout << " --- " << x << " " << y << " " << z << "\n"
#define debugn(i, n, a) rep(i, n)cout << " --- " << a[i] << "\n";
#define debugin(i, n, a) rep(i, n)printf(" --- %10d\n", a[i])
#define debugi2n(i, n, a, b) rep(i, n)printf(" --- %10d %10d\n", a[i], b[i])
#define debugiin(i, n, a) rep(i, n)printf(" --- %10d %10d\n", a[i].first, a[i].second)
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)

int use[10];
int s, tmp;

int dfs(int n, int now){
  if(n < 0)return 0;
  if(n == 0 && s == now)return 1;
  if(n == 0 && s != now)return 0;
  int i, j, smin = 0, smax = 0;

  j = tmp;
  rep(i, 10){
    if(!use[i])smin += i * j--;
    if(smin + now > s)return 0;
    if(j == tmp - n)break;
  }
  if(smin + now == s)return 1;
  j = tmp;
  per(i, 10){
    if(!use[i])smax += i * j--;
    if(j == tmp - n)break;
  }
  if(smax + now < s)return 0;
  if(smax + now == s)return 1;

  int res = 0;
  rep(i, 10)if(!use[i]){
    if((tmp - n + 1) * i + now > s)return res;
    use[i] = tmp - n + 1;
    res += dfs(n - 1, now + i * (tmp - n + 1));
    use[i] = 0;
  }
  return res;
}

signed main(void){
  int i, j;
  int n;
  for(int testcase = 0;scanf("%d%d", &n, &s) != EOF;testcase++){
    rep(i, 10)use[i] = 0;
    tmp = n;
    if(n > 10)pri(0);
    else pri(dfs(n, 0));

//*/

//*/ break;
  }
  return 0;
}

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

int main()
{
	int x1,y1,x2,y2,x3,y3,x4,y4;
	cin>>x1>>y1>>x2>>y2;
	
	x3=x2-(y2-y1);
	y3=y2+(x2-x1);
	x4=x1-(y2-y1);
	y4=y1+(x2-x1);
	
	cout<<x3<<" "<<y3<<" "<<x4<<" "<<y4<<endl;
	
	return 0;
}


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

int main()
{
    string O, E;
    cin >> O >> E;

    while (!O.empty())
    {
        cout << O.front();
        O = O.substr(1, O.size() - 1);
        if (!E.empty())
        {
            cout << E.front();
            E = E.substr(1, E.size() - 1);
        }
    }
    cout << endl;
}


Measured memory_bytes: 256
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)
# INF =  float("inf")
INF = 10**18
import bisect
import statistics
mod = 10**9+7
# mod = 998244353

# リストのlcm
def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

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

c = B // C - (A-1) // C
d = B // D - (A-1) // D
e = B // lcm_base(C, D) - (A-1) // lcm_base(C, D)

print(B-A+1 - (c+d-e))


Measured memory_bytes: 77432
#include <stdio.h>
int main(){
	int x,y;
	scanf("%d %d",&x,&y);

	int d;
	while(1){
		d=x%y;
		x=y;
		y=d;
		if(d==0) break;
	}
	printf("%d\n",x);
	return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

const int INF = 1001001001;

int main(){
    while(true){
        int n, k; cin >> n >> k;
        if(n==0 && k==0) break;
        vector<int> a(n);
        rep(i,n) cin >> a[i];
        vector<int> sum(n+1,0);
        rep(i,n) sum[i+1] = sum[i] + a[i];
        int ans = -INF;
        for(int i = 0; i <= n-k; ++i){
            ans = max(ans, sum[i+k] - sum[i]);
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define loop(i,a,b) for(ll i=a; i<b; i++)
#define revloop(i,a,b) for(ll i=a; i>=b; i--)
#define pb push_back
#define vl vector<ll>
#define vvl vector<vl>
#define pl pair<ll,ll>
#define vpl vector<pl>
#define all(c) (c).begin(), (c).end()
#define sz(a) ((a).size())
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i!=(c).end(); i++))
#define mp make_pair
#define ss second
#define ff first
#define ld long double
const ll INF = 1e13;
const ll N = 301;
const ll mod= 1000000007;
bool prime(ll x)
{
	if(x<2) return false;
	for(ll i=2; i*i<=x; i++) if(x%i==0) return false;
	return true;
}
vl fac(N);
void fact()
{
	fac[0]=1;
	loop(i,1,N) fac[i]=(fac[i-1]*i)%mod;
}

void solve()
{
  ll n,k;
  cin>>n>>k;
  vl a(n), dp(k+1,0);
  loop(i,0,n) cin>>a[i];
  loop(i,0,k+1) loop(j,0,n) if(i-a[j]>=0 && !dp[i-a[j]]) dp[i]=1;
  if(dp[k]) cout<<"First";
  else cout<<"Second";

}

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t=1;
    //cin>>t;
    while(t--) solve();
 return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define niv vector<int>
#define LL long long
#define IT iterator
#define PB(a) push_back(a)
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int  n;
int res[505][505];
void dfs(int start,int to,int index){
	if(to-start+1<=1) return;
	for(int i=start;i<to;i++)
		for(int j=i+1;j<=to;j++) {res[i][j]=index;
		}
	int mid=(start+to)>>1;
	dfs(start,mid,index+1),dfs(mid+1,to,index+1);
}
int main(){
	cin>>n;
	dfs(1,n,1);
 
	for(int i=1;i<n;i++)
        for(int j=i+1;j<=n;j++)
	cout<<res[i][j]<<" ";
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
int main()
{
    ll n ,k ;
    cin >> n >> k;
    vector<ll> Right;
//    Right.push_back(0);
    string s;
    cin >> s;
    ll ans=0;
    for(ll i=1;i<=n;i++)
    {
        if(s[i-1]=='R')
        {
            Right.push_back(i);
        }
        
        
    }
    for(ll i=0;i<n;i++)
    {
        if(s[i]==s[i+1] && i+1<n && s[i]=='R')
        {
            ans++;
        }
        if(s[i]==s[i-1]&& s[i]=='L' && i-1>=0)
        {
            ans++;
            
        }
    }
    vector<ll> diff;
    cout << min(ans+2*k,n-1);
}


Measured memory_bytes: 4452
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring> 
using namespace std;

long long dp[1005][1005],h,w;
char s[1005][1005];
int main(){
	scanf("%d%d\n",&h,&w);
	for (int i=1;i<=h;i++){
		for (int j=1;j<=w;j++){
			scanf("%c",&s[i][j]);
		}
		if (i < h)
		scanf("\n");
	}
	dp[1][1]=1;
	for (int i=1;i<=h;i++){
		for (int j=1;j<=w;j++){
			if (s[i][j] == '.' && (i!= 1 || j != 1))
			dp[i][j]=(dp[i-1][j]+dp[i][j-1])%(1000000007);
		}
	}
	printf("%lld\n",dp[h][w]%(1000000007));
	return 0;
} 

Measured memory_bytes: 8960
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<cstring>
#include<queue>
using namespace std;
#define INF 100000000
int max(int a,int b){
	if(a>b){
		return a;
	}else{
		return b;
	}
}

int main(){
	while(1){
		int n,m,sum=0;
		int d[10000],p[10000];
		cin>>n>>m;
		if(n==0&&m==0)break;
		for(int i=0;i<n;i++){
			cin>>d[i]>>p[i];
			sum+=d[i];
		}
		if(sum<=m){
			cout<<'0'<<endl;
			continue;
		}
		while(m>0){
			int a=0,b=0,flg=0;
			for(int i=0;i<n;i++){
				if(a<p[i]){
					a=p[i];b=i;flg=1;
				}
			}
			if(flg==0)break;
			if(m>=d[b]){
				p[b]=-1;m-=d[b];d[b]=0;
			}else{
				d[b]-=m;m=0;break;
			}
		}
		sum=0;
		for(int i=0;i<n;i++){
			if(p[i]>0){
				sum+=p[i]*d[i];
			}
		}
		cout<<sum<<endl;
	}
	return 0;
}	

Measured memory_bytes: 1236
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, u, v = mapint()
query = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = mapint()
    query[a-1].append(b-1)
    query[b-1].append(a-1)

from collections import deque
def dfs(start):
    Q = deque([start])
    dist = [10**18]*N
    dist[start] = 0
    while Q:
        now = Q.pop()
        for nx in query[now]:
            if dist[nx]>=10**18:
                dist[nx] = dist[now] + 1
                Q.append(nx)
    return dist

taka = dfs(u-1)
aoki = dfs(v-1)
ans = 0

for i in range(N):
    t, a = taka[i], aoki[i]
    if t<=a:
        ans = max(ans, a-1)
print(ans)

Measured memory_bytes: 89088
#include <iostream>
#include <string>
#include <algorithm> 
#include <cstdlib>
using namespace std;
int main(){
    int n;
    cin >> n;  
    for(int i=1;i<10;i++){
        if(111*i>=n){
            cout << 111*i << endl;
            break;
        }
    }
}

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

class program
{
    static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        var l = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        Array.Sort(l);
        int ans = 0;
        for(int i = 0; i < n; i++)
        {
            for (int j = i+1; j < n; j++)
            {
                for (int k = j+1; k < n; k++)
                {
                    if(l[i] != l[j] && l[j] != l[k] && l[k] != l[i])
                    {
                        if (l[k] < l[j] + l[i]) ans++;
                    }
                }
            }
        }
        Console.Write(ans);
                
    }
}

Measured memory_bytes: 28216
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

int N;
vector<ll> A,B,C;

int main(){
  cin>>N;
  for(int i=0;i<N;i++){
    ll temp;
    cin>>temp;
    A.push_back(temp);
  }
  for(int i=0;i<N;i++){
    ll temp;
    cin>>temp;
    B.push_back(temp);
  }
  for(int i=0;i<N;i++){
    ll temp;
    cin>>temp;
    C.push_back(temp);
  }

  sort(A.begin(),A.end());
  sort(B.begin(),B.end());
  sort(C.begin(),C.end());

  ll ans=0;

  for (int i=0;i<N;i++) {
    ll m = B[i];
    ll u = lower_bound(A.begin(),A.end(),m) - A.begin();
    ll l = C.end() - upper_bound(C.begin(),C.end(),m);
    ans+=u*l;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define dbg(x...) do { cout << "\033[32;1m" << #x <<" -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<class T, class... Ts> void err(const T& arg,const Ts&... args) { cout << arg << " "; err(args...); }

typedef long double db;
const db eps = 1e-12;
const db pi = acosl(-1.0);
inline int sgn(db x) {if(fabs(x) < eps) return 0; return x < 0 ? -1 : 1;}
struct Point {
    db x, y;
    Point(){}
    Point(db x, db y):x(x), y(y){}
    void input(){
        cin >> x >> y;
    }
    Point operator + (const Point &b) const {
        return Point(x + b.x, y + b.y);
    }
    Point operator - (const Point &b) const {
        return Point(x - b.x, y - b.y);
    }
    db operator ^ (const Point &b) const {
        return x * b.y - y * b.x;
    }
    db operator * (const Point &b) const {
        return x * b.x + y * b.y;
    }
    Point operator * (const db k){
        return Point(x * k, y * k);
    }
    Point operator / (const db k){
        return Point(x / k, y / k);
    }
    db len2(){
        return x * x + y * y;
    }
    db len(){
        return sqrtl(len2());
    }
};
struct Line{
    Point s, e;
    Line(){}
    Line(Point s, Point e) :s(s), e(e){}
    void input(){s.input(), e.input();}
    Point getPointProgLine(Point p){
        Point a = e - s, b = p - s;
        return s + ((a * (a * b)) / a.len2());
    }
}l;

int main(){
#ifndef ONLINE_JUDGE
// freopen("i.in","r",stdin);
//  freopen("o.out","w",stdout);
#endif
    l.input();
    int q;scanf("%d", &q);
    while(q -- ){
        Point p; p.input();
        p = l.getPointProgLine(p);
        cout << fixed << setprecision(10) << p.x << ' ' << p.y << endl;
    } 

    return 0;
}


Measured memory_bytes: 3356
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.ABC_149
{
    class A
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            string[] st = Read().Split();
            WriteLine(st[1] + st[0]);
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


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

int check(char c) {
 return (c=='A' || c=='T' || c=='G' || c=='C' );
}

int main() {
  	int ans = 0;
  string s;
  cin >> s;
  
  int i=0;
  while (i < (int) s.size()) {
  	int cnt = 0;
    if (!check(s[i])) ++i;
    else {
    	while (i<(int) s.size() && check(s[i])) {++cnt; ++i;}
    }
    
    if (cnt > ans) ans = cnt;
  }
  cout << ans ;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

int main()
{
	LL N;
	in >> N;
	std::vector<LL>A(N), B(N);
	rep(i, N) in >> A[i];
	rep(i, N) in >> B[i];


	std::vector<LL>want, over;
	rep(i, N)
	{
		if (A[i] < B[i]) want.push_back(B[i] - A[i]);
		if (A[i] > B[i]) over.push_back(A[i] - B[i]);
	}
	std::sort(want.begin(), want.end());
	std::sort(over.rbegin(), over.rend());

	LL sum = 0, ans = want.size();
	rep(i, want.size()) sum += want[i];
	rep(i, over.size())
	{
		if (sum <= 0) break;
		sum -= over[i];
		++ans;
	}
	if (sum > 0) ans = -1;

	out << ans << std::endl;
}


Measured memory_bytes: 2812
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
using namespace std;
#define INF 0x3f3f3f3f
const int maxn=1e5+10;
#define _rep(i,a,b) for(int i=(a);i<=(b);++i)
int n,k,mp[300],f[maxn];
char win[300];
bool v[maxn];
string T;

int main()
{
    #ifdef __LOCAL__
        freopen("1.in","r",stdin);
        freopen("1.out","w",stdout);
    #endif
    
    cin>>n>>k;
    cin>>mp['r']>>mp['s']>>mp['p'];
    cin>>T;
    win['r']='p',win['s']='r',win['p']='s';
    int len=T.size();
    for(int i=0;i<k;i++)
        f[i]=f[i-1]+mp[win[T[i]]],v[i]=1;
    for(int i=k;i<len;i++)
    {
        if(T[i]==T[i-k]&&v[i-k])
        {
            f[i]=f[i-1];
            continue;
        }        
        f[i]=f[i-1]+mp[win[T[i]]];
        //cout<<i<<" "<<f[i]<<endl;
        v[i]=1;
    }
    cout<<f[len-1];
    return 0;
}

Measured memory_bytes: 924
n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))
min_abs = abs(a - (t - h[0]*0.006))
ans = 0
for i in range(1, n):
    tmp = abs(a - (t - h[i]*0.006))
    if min_abs > tmp:
        min_abs = tmp
        ans = i
print(ans + 1)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int,int>;
#define rep(i,n) for(int i=0; i<n; i++)
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてから使う
#define INF 2147483647
#define LLINF 9223372036854775807LL

int main(){
  ll a;
  double b;
  cin>>a>>b;
  a *= (ll)(b*100+0.5);
  cout << a/100 << endl;
}

Measured memory_bytes: 3724
while True:
    n = int(input())
    if n == 0:
        break
    Lis = []
    for i in range(n):
        num = int(input())
        Lis.append(num)
        Lis = sorted(Lis)
    ans = 0
    for j in range(n - 1):
        ans += Lis[j] * (n -  1 - j)
    print(ans)

Measured memory_bytes: 7884
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<char> vchar;
typedef vector<vector<char>> vvchar;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef priority_queue<long long> prque;
#define ain(i,n,a) for(long long i=0;i<(long long)(n);i++){cin>>a[i];}
#define aout(i,n,a) for(long long i=0;i<(long long)(n);i++){if(i){cout<<" ";}cout<<a[i];if(i==n-1){cout<<endl;}}
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define vsort(v) sort((v).begin(),(v).end())
#define vrsort(v) sort((v).rbegin(),(v).rend())
#define vreverse(v) reverse((v).begin(),(v).end())
#define pf(a) push_front(a)
#define pb(a) push_back(a)
#define INF 1998021900
#define MOD 1000000007
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  //input
  ll i,n;cin>>n;vll a(n+1),b(n);ain(i,n+1,a);ain(i,n,b);
  //caricurate
  ll ans=0;
  rep(i,n){
  if(a[i]<=b[i]){ans+=a[i];b[i]-=a[i];a[i]=0;}else{a[i]-=b[i];ans+=b[i];b[i]=0;continue;}
  if(a[i+1]<=b[i]){ans+=a[i+1];b[i]-=a[i+1];a[i+1]=0;}else{a[i+1]-=b[i];ans+=b[i];b[i]=0;}
  }
  //output
  cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

vector<pair<ll,pair<ll,ll>>> event;
set<ll> st;

int main(){
  ll N,Q,S,T,X,D;
  cin >> N >> Q;
  rep(i,N){
    cin >> S >> T >> X;
    event.pb(mp(S-X,mp(1,X)));
    event.pb(mp(T-X,mp(0,X)));
  }
  sort(ALL(event));
  X=0;
  rep(i,Q){
    cin >> D;
    if(X!=2*N){
      while(event[X].fr<=D){
        auto Y = event[X];
        if(Y.sc.fr){
          st.insert(Y.sc.sc);
        }
        else{
          st.erase(Y.sc.sc);
        }
        X++;
        if(X==N*2){
          break;
        }
      }
    }
    if(st.size()>0){
      cout << *st.begin() << endl;
    }
    else{
      cout << -1 << endl;
    }
  }
}


Measured memory_bytes: 20712
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
int main()
{
	long long a,b;
	int k;
	cin>>a>>b>>k;
	for(int i=1;i<=k;i++)
	{
		if(i%2==1)
		{
			if(a%2==1)
			{
				a--;
				int t=a/2;
				a-=t;
				b+=t;
			}
			else
			{
				int t=a/2;
				a-=t;
				b+=t;
			}
		}
		else
		{
			if(b%2==1)
			b--;
			int t=b/2;
			b-=t;
			a+=t;
		}
	}
	cout<<a<<" "<<b<<endl;
	return 0;
}

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

//flagを用いたバブルソート
int bubbleSort(int A[], int N){
    int sw = 0;
    bool flag = 1;
    for(int i = 0; flag; i++){
        flag = 0;
        for(int j = N - 1; j >= i + 1; j--){
            if(A[j] < A[j - 1]){
                //隣接要素を交換する
                swap(A[j], A[j-1]);
                flag = 1;
                sw++;
            }
        }
    }
    return sw;
}

int main(){
    int A[100], N, sw;
    cin >>N;
    for(int i = 0; i < N; i++)cin >>A[i];

    sw = bubbleSort(A, N);
    for(int i = 0; i < N; i++){
        if(i) cout << " ";
        cout << A[i];
    }
    cout << endl;
    cout << sw << endl;

    return 0;
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
#define MAX 100005
using namespace std;

int arr[MAX];

int main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin);
    //     freopen("output.txt", "w", stdout);
    // #endif
    int n, k;

    cin>>n>>k;

    for(int i = 0; i < n; i++){
        cin>>arr[i];
    }

    int Min = 1e9;

    sort(arr, arr + n);

    for(int i = 0; i <= n - k; i++){
        int temp = arr[i+k-1] - arr[i];
        Min = min(Min, temp);
    }

    cout<<Min<<endl;

    return 0;
}

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

int main(){
  string S;
  cin >> S;
  int L = S.size();
  string ans = "No";
  int ant = 0;
  int cnt1=0;
  for(int i=0; i<L/2; i++){
    if(S.at(i)==S.at(L-i-1)) cnt1++;
  }
  if(cnt1==L/2) ant++;

  int cnt2=0;
  for(int i=0; i<(L-1)/4; i++){
    if(S.at(i)==S.at((L-1)/2-i-1)) cnt2++;
  }
  if(cnt2==(L-1)/4) ant++;

  int cnt3=0;
  for(int i=(L+3)/2-1; i<L; i++){
    if(S.at(i)!=S.at(L-i-1)) cnt3++;
  }
  if(cnt3==0) ant++;
  if(ant==3) ans = "Yes";
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>


using namespace std;


int main(){

long int a;
long int b;
long int c;
	
cin >> a >> b >> c;
long int maxAnti = (a + b + 1);
long int answer;
if(maxAnti >= c){
	answer = (c + b);
}
else{
	answer = maxAnti + b;
	
}

cout << answer << endl;




}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(void){
    int i,tmp,ball[3]={};
    char change[3];
    
    ball[0]=1;
    while(gets(change) != '\0'){
        if(strcmp(change,"A,B")==0 || strcmp(change,"B,A")==0){
            tmp=ball[0];
            ball[0]=ball[1];
            ball[1]=tmp;
        }
        if(strcmp(change,"B,C")==0 || strcmp(change,"C,B")==0){
            tmp=ball[1];
            ball[1]=ball[2];
            ball[2]=tmp;
        }
        if(strcmp(change,"A,C")==0 || strcmp(change,"C,A")==0){
            tmp=ball[0];
            ball[0]=ball[2];
            ball[2]=tmp;
        }
        
        //for(i=0;i<3;i++){
        //    printf("%d ",ball[i]);
        //}
        //puts("");
        
    }
    for(i=0;i<3;i++){
        if(ball[i]==1)printf("%c\n",'A'+i);
    }
    
    return 0;
    
}

Measured memory_bytes: 524
S = input()
dp = [[0 for _ in range(13)] for _ in range(2)]
dp[0][0] = 1
bit = 0
for c in S:
    if c == '?':
        for k in range(13):
            for s in range(10):
                dp[bit^1][(10*k+s) % 13] += dp[bit][k]
    else:
        for k in range(13):
            dp[bit^1][(10*k+int(c)) % 13] += dp[bit][k]
    
    for k in range(13):
        dp[bit^1][k] %= (10 ** 9 + 7)
        dp[bit][k] = 0
    bit ^= 1
print(dp[bit][5])    
        

Measured memory_bytes: 43304
#include <stdio.h>
int main(void){
int a,b,c;
scanf("%d",&a);
scanf("%d",&b);
scanf("%d",&c);
if((a==b && b==c) ||(a!=b&&b!=c && a!=c)){
  printf("No");
}else{
  printf("Yes");
}
return 0;
}


Measured memory_bytes: 1704
#include<cmath>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
using namespace std;

const int inf = 0x3f3f3f3f;
typedef long long ll;
const double pi=4*atan(1.0);
int sum[200005];
int main()
{
    int n;
    cin>>n;
    for(int i=0; i<n-1; i++)
    {
        int a;
        scanf("%d",&a);
        sum[a]++;
    }
    for(int i=1; i<=n; i++)
        printf("%d\n",sum[i]);
    return 0;
}



Measured memory_bytes: 4608
#include<bits/stdc++.h>
using namespace std;
const long long  MAXN = 1e5;
int w[MAXN];
long long v[MAXN];
long long dp[105][100005];
int N;
int W;
int main(){
	cin>>N>>W;
	for(int i = 1; i <= N; i++){
		cin>>w[i]>>v[i];
	}
	for(int i = 1; i <= N; i++){
		for(int j = 0; j <= W; j++){//容量 
			if(j < w[i]){//容量不够 
				dp[i][j] = dp[i - 1][j]; 
			}else{
				dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w[i]] + v[i]);
			}
		}
	}
	cout<<dp[N][W]<<endl;
	return 0; 
} 

Measured memory_bytes: 79360
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do { (t*=10)+=ch-'0'; ch=getchar(); } while ('0'<=ch&&ch<='9'); t*=f;
}
typedef long long ll;
const ll INF=1LL<<55;
const int maxn=(2e5)+10;
int n,m,L,vis[310];
pair<ll,ll> d[310][310],A;
queue<int> q;
int w[maxn];
int head[maxn],nxt[maxn],tot,to[maxn];
void add(int x,int y,int z) {
	tot++; nxt[tot]=head[x];
	head[x]=tot; to[tot]=y; w[tot]=z;
}
void solve(int s) {
	for (int i=1;i<=n;i++) d[s][i].first=INF;
	d[s][s]=make_pair(0,L);
	q.push(s);
	while (!q.empty()) {
		int u=q.front(); q.pop(); vis[u]=0;
		for (int i=head[u],v;i;i=nxt[i]) {
			v=to[i];
			if (w[i]>L) continue;
			A=make_pair(d[s][u].first,d[s][u].second-w[i]);
			if (A.second<0) A.first++,A.second=L-w[i];
			if (A.first<d[s][v].first||(A.first==d[s][v].first&&A.second>d[s][v].second)) {
				d[s][v]=A;
				if (!vis[v]) vis[v]=1,q.push(v);
			}
		}
	}
}
int main() {
//	freopen("1.txt","r",stdin);
	read(n); int x,y; ll z;
	read(m);
	read(L);
	while (m--) {
		read(x); read(y); read(z);
		add(x,y,z); add(y,x,z);
	}
	for (int i=1;i<=n;i++) solve(i);
	read(m);
	while (m--) {
		read(x); read(y);
		if (d[x][y].first==INF) printf("-1\n");
		else printf("%lld\n",d[x][y].first);
	}
	return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define FOR(i, x, y) for(ll i = x; i < y; i++)
#define endll cout << "\n"
#define For(n) for(ll i = 0; i < n; i++)
const ll maxn = 100000 + 100;
const ll inf = 1e9;
bool visit[maxn];
ll dp[maxn];
vector < pair < ll , ll >  > g[maxn];
void bfs(ll v)
{
    queue < ll > q;
    q.push(v);
    visit[v] = 1;
    while(q.size() > 0)
    {
        ll u = q.front();
        q.pop();
        for(ll i = 0; i < g[u].size(); i++)
        {
            if(!visit[g[u][i].ff])
            {
                visit[g[u][i].ff] = 1;
                dp[g[u][i].ff] = dp[u] + g[u][i].ss;
                q.push(g[u][i].ff);
            }
        }
    }
}
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    ll n;
    cin >> n;
    for(ll i = 0; i < n - 1; i++)
    {
        ll u, v, w;
        cin >> u >> v >> w;
        g[u].pb({v, w});
        g[v].pb({u, w});
    }
    ll q, k;
    cin >> q >> k;
    bfs(k);
    while(q --)
    {
        ll x, y;
        cin >> x >> y;
        cout << dp[x] + dp[y] << endl;
    }
    return 0;
}


Measured memory_bytes: 10112
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S, T;
    cin >> S >> T;
    vector<string> K;
    for (int i = 0; i < S.size() - T.size() + 1; ++i) {
        string tmp = S;
        bool ok = true;
        for (int j = 0; j < T.size();j++) {
            if(S[i + j] == T[j]){
                continue;
            }else if(S[i + j] == '?'){
                tmp[i + j] = T[j];
            }else {
                ok = false;
                break;
            }
        }
        if(ok) {
            K.push_back(tmp);
        }
    }
    if(K.empty()){
        cout << "UNRESTORABLE" << endl;
        return 0;
    }
    sort(K.begin(), K.end());
    for (int i = 0; i < S.size(); ++i) {
        if(K[0][i] == '?'){
            K[0][i] = 'a';
        }
    }
    cout << K[0] << endl;
    return 0;
}

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

int main() {
  int n;
  cin>>n;
  bool ans=false;
  int a,b,c;
  a=n/100;
  b=(n-100*a)/10;
  c=n%10;
  if(a==7) ans=true;
  if(b==7) ans=true;
  if(c==7) ans=true;
    
   if(ans) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}




 




Measured memory_bytes: 3612
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;


void solve(long long N, std::vector<long long> P){
    int min_,max_;
    min_ = 10000000;
    max_ = 0;
    int ans =0;
    REP(i, N){
        if(min_>P[i]){
            ans++;
            min_ = P[i];
        }
    }
    cout<<ans<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> P(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&P[i]);
    }
    solve(N, std::move(P));
    return 0;
}


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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main()
{
    int a, b;
    cin >> a >> b;
    OP(max(a * b, max(a + b, a - b)));
    return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
arr = [[0,0] for _ in range(N)]

if M == 0:
    print("0 0")
    exit()

for i in range(M):
    p, S = map(str, input().split())
    p = int(p)
    if S == "WA":
        if arr[p-1][1] == 0:
            arr[p-1][0] += 1
    elif S == "AC":
        arr[p-1][1] = 1

ac_sum = 0
wa_sum = 0

for j in range(N):
    ac_sum += arr[j][1]
    if arr[j][1] == 1:
        wa_sum += arr[j][0]

print(str(ac_sum) + ' ' + str(wa_sum))

Measured memory_bytes: 13172
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>

int n;
int main(){
	while(std::cin >> n){
		std::vector<long long> v(n);
		long long sum = 0;
		for(int i=0;i<n;i++){
			std::cin >> v[i];
			sum += v[i];
		}
		long long min = *std::min_element(v.begin(),v.end());
		long long max = *std::max_element(v.begin(),v.end());
		//long long sum = std::accumulate(v.begin(),v.end(),0);
		std::cout << min << " " << max << " " << sum << std::endl;			
	}
}


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

int main(){
    int n, h, ans=0, ma=0;
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> h;
        if(ma<=h){
            ans++;
            ma=h;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import sys
from collections import defaultdict, deque, Counter
import math

# import copy
from bisect import bisect_left, bisect_right
import heapq

# sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline

getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = 10 ** 20
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)


def nck(n, k, kaijyo):
    return (npk(n, k, kaijyo) * divide(kaijyo[k])) % MOD


def npk(n, k, kaijyo):
    if k == 0 or k == n:
        return n % MOD
    return (kaijyo[n] * divide(kaijyo[n-k])) % MOD


def kaijyo(n):
    ret = [1]
    for i in range(1, n + 1):
        ret.append((ret[-1] * i)% MOD)
    return ret

def solve():
    n, k = getList()
    nums = getList()
    # pro = [1]
    # for num in nums:
    #     pro.append(pro[-1] * num)
    # print(pro)
    for i in range(n - k):
        # print(i)
        # ku = pro[k+i] / p/] / pro[i+ 1]
        if nums[i] < nums[i+k]:
            print("Yes")
        else:
            print("No")
if __name__ == "__main__":
    # main()
    solve()

Measured memory_bytes: 92292
#include <iostream>
using namespace std;
int main(void){
    int n;
    cin >> n;
    long tmp = 1000000007;
    long mod8,mod9,mod10;
    mod8 = 1;
    mod9 = 1;
    mod10 = 1;
    for(int i=0;i<n;i++){
        mod8  = (mod8*8)%tmp;
        mod9  = (mod9*9)%tmp;
        mod10 = (mod10*10)%tmp;
    }
    long res = (mod10 - 2*mod9 + mod8)%tmp;
    if (res < 0){res+=tmp;}
    cout << res << endl;
}


Measured memory_bytes: 3584
#include <stdio.h>

int main (void){
	int H[100],W[100];
	int dataset = 0;
	while (H != 0 && W !=0){
		
		scanf("%d %d", &H[dataset], &W[dataset]);
		if (H[dataset] == 0 && W[dataset] == 0) break;
		dataset++;
	}
//	printf("%d", dataset);
	for (int data = 0; data < dataset; data++){
				
		for (int i = 0; i < H[data]; i++){
			for (int j = 0; j < W[data]; j++){
				printf ("#");
			}
			printf("\n");
		}
		printf("\n");
	}
	
	return 0;
	
}


Measured memory_bytes: 2112
h, w, a, b = map( int, input().split() )

SIZE = h+w+2
MOD = 10**9 + 7
MOD_Farmer = 10**9+5

fact = [0] * SIZE
inv = [0] * SIZE
fact_inv = [0] * SIZE

# prepare --------------------------------
inv[0] = 0
inv[1] = 1
fact[0] = fact[1] = 1
fact_inv[0] = fact_inv[1] = 1
for i in range( 2, SIZE ):
  inv[i] = MOD - (MOD//i)*inv[MOD%i]%MOD
  fact[i] = fact[i-1] * i % MOD
  fact_inv[i] = fact_inv[i-1] * inv[i] % MOD
#  fact_inv[i] = fact[i] **( 10**4 ) \
#              * fact[i] **( 10**5 ) \
#              * fact[i] ** 5 % MOD % MOD
# ----------------------------------------
def comb( n, r ):
  if r >= 0 and n >= 0:
    return fact[n] * fact_inv[n-r]%MOD * fact_inv[r]%MOD
  else :
    return 0.0
# ----------------------------------------

#print( fact_inv )

ans = 0
for i in range( h-a ):
    ans += comb(i+b-1, b-1) * comb(h-i-1+w-b-1,w-b-1)
    ans %= MOD
print( ans )

Measured memory_bytes: 26788
#include <bits/stdc++.h>
using namespace std;
int main()
{
	long long n,k;
	cin>>n>>k;
	long long ans=n/k;
	long long t;
	if (k!=1) t=n/(k/2)-ans;
	else t=0; 
	if(k%2==1) cout <<ans*ans*ans<<endl;
	else  cout <<ans*ans * ans + t*t*t<<endl;
	return 0;
}

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

using namespace std;
const int dx[]={1,0,-1,0,1,-1,-1,1,0};
const int dy[]={0,1,0,-1,1,1,-1,-1,0};
const int INF = 1e9+101;
const long long LINF = 1e18;
const double EPS = 1e-8;
#define pb push_back
#define mk make_pair
#define fr first
#define sc second
#define reps(i,j,k) for(int i = (j); i < (k); ++i)
#define rep(i,j) reps(i,0,j)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll, ll> Pll;
typedef pair<Pii,int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
template<class T>
ostream& operator<<(ostream &out, const vector<T> &v){
	out << "{";
	rep(i,v.size()){
		out << v[i] <<", ";
	}
	return out << "}";
}
int main() {
    ll N;
	cin >> N;
	vector<long long> a;
	rep(i,N){
		ll tmp;
		cin >> tmp;
		a.pb(tmp);
	}
	a.pb(INF);
	sort(all(a));
	ll ret = 0;
	rep(i,N){
		reps(j,i+1,N) {
			ll lt = a[j]-a[i]+1;
			ll rt = a[j]+a[i];
			auto lidx = lower_bound(all(a),lt);
			auto ridx = lower_bound(all(a),rt)-1;
			if(ridx < lidx) {
				continue;
			}
			ll ans = 0;
			if (ridx - a.begin() < N && lidx - a.begin() < N){
				ans += (ridx - a.begin()) - (lidx-a.begin()) + 1;
			}
			if (ridx - a.begin() < N && lidx - a.begin() < N && lidx-a.begin() <= i && i <= ridx-a.begin()){
				--ans;
			}
			if (ridx - a.begin() < N && lidx - a.begin() < N && lidx-a.begin() <= j && j  <= ridx-a.begin()) {
				--ans;
			}
			//cout << "[" << i << "," << j << "] " << lidx-a.begin() << " " << ridx-a.begin() << " " << ans << endl;
			ret += max(0LL,ans);
		}
	}
	cout << ret/3 << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int min = 100;
		for(int i = 0; i < N; i++) {
			long A = sc.nextLong();
			int count = 0;
			for(;A % 2 == 0;count++) {
				A /= 2;
			}
			min = Math.min(min, count);
		}
		System.out.println(min);
	}
}


Measured memory_bytes: 21204
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>

using namespace std;
using ll = long long;

#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    ll N; cin >> N;
    
    repf(h,1,3501) repf(n,h,3501) {
        ll a = 4*h*n-(h+n)*N;
        ll b = h*n*N;
        if (a > 0 && b%a == 0) {
            cout << h << ' ' << n << ' ' << b/a << endl;
            return 0;
        }
    }
    return 0;
}

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

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

    int N;
    cin >> N;
    vector<int> A(N);
    vector<int> sortedA(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        sortedA[i] = A[i];
    }
    sort(sortedA.begin(), sortedA.end(), greater<int>());
    int biggest = sortedA[0];
    int bigger = sortedA[1];
    for (int i = 0; i < A.size(); i++) {
        if (A[i] == biggest)
            cout << bigger << endl;
        else
            cout << biggest << endl;
    }
}

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

int main()
{
    std::vector<int> num_bridges(4);

    for (int i = 0; i < 3; i++) {
        int a, b;
        std::cin >> a >> b;

        a--;
        b--;
        num_bridges[a]++;
        num_bridges[b]++;
    }

    for (auto elem : num_bridges) {
        if (elem > 2) {
            std::cout << "NO" << std::endl;
            return 0;
        }
    }

    std::cout << "YES" << std::endl;
}


Measured memory_bytes: 256
// #pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
#include<iostream>
#include<fstream>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int mod=1e9+7;
const ll infll=1e18+9;
const int infint=1e9+7;
const int MAXN=1e6+7;
const double eps=1e-9;
const long double pi=3.1415926535897932384626433832795;
const long double e=2.71828182845904523536028747135266;
inline ll read()
{
    ll kr=1,xs=0;char ls;ls=getchar();
    while(!isdigit(ls)){
        if(!(ls^45)) kr=-1;ls=getchar();
    }
    while(isdigit(ls)){
        xs=(xs<<1)+(xs<<3)+(ls^48);ls=getchar();
    }
    return xs*kr;
}
// inline __int128 read128()
// {
//     __int128 kr=1,xs=0;char ls;ls=getchar();
//     while(!isdigit(ls)){
//         if(!(ls^45)) kr=-1;ls=getchar();
//     }
//     while(isdigit(ls)){
//         xs=(xs<<1)+(xs<<3)+(ls^48);ls=getchar();
//     }
//     return xs*kr;
// }
inline ull readull()
{
    ull xs=0;char ls;ls=getchar();
    while(!isdigit(ls)) ls=getchar();
    while(isdigit(ls)){
        xs=(xs<<1)+(xs<<3)+(ls^48);ls=getchar();
    }
    return xs;
}
inline void writeull(ull x){
    if(x<0){x*=-1;putchar('-');}
    if(x>=10) writeull(x/10);
    putchar('0'+x%10);
}
inline void write(ll x){
    if(x<0){x*=-1;putchar('-');}
    if(x>=10) write(x/10);
    putchar('0'+x%10);
}
// inline void write(__int128 x){
//     if(x<0){x*=-1;putchar('-');}
//     if(x>=10) write(x/10);
//     putchar('0'+x%10);
// }
///////////////////////////////////////////////////////////////////////////////////////
int pri[MAXN],cnt,vis[MAXN],a[MAXN],n;

int gcd(int a,int b)
{
    return b>0?gcd(b,a%b):a;
}
void getp(int nn)
{
    for (int i=2;i<=nn;i++){
        if(!vis[i]) pri[cnt++]=i;
        for (int j=0;j<cnt;j++){
            if(1ll*i*pri[j]>nn) break;
            vis[i*pri[j]]=1;
            if(i%pri[j]==0) break;
        }
    }
}
unordered_map<int,int> q;
int check()
{
    q.clear();
    for (int i=1;i<=n;i++){
        int x=a[i];
        if(!vis[a[i]]) {
            if(q[a[i]]&&a[i]!=1) return 0;
            q[a[i]]=1;
            continue;
        }
        for (int j=0;j<cnt&&pri[j]<=x;j++){
            if(x%pri[j]==0){
                if(q[pri[j]]) return 0;
                q[pri[j]]=1;
            }
            while(x%pri[j]==0) x/=pri[j];
        }
        if(x>1) {
            if(q[x]) return 0;
            q[x]=1;
        }
    }
    return 1;
}
int check1()
{
    int ans=0;
    for (int i=1;i<=n;i++) ans=gcd(ans,a[i]);
    if(ans==1) return 1;
    else return 0;
}
int main()
{
    int t=1;
    // t=read();
    while(t--){
        getp(1000000);
        n=read();
        for (int i=1;i<=n;i++){
            a[i]=read();
        }
        if(check()) printf("pairwise coprime\n");
        else if(check1()) printf("setwise coprime\n");
        else printf("not coprime\n");
    }
    return 0 ;
}

/*
6
011000010010000001100001011000010000101001100001
*/


Measured memory_bytes: 11756
a=list(input())
b=list(input())
c=list(input())
temp="a"
la,lb,lc=len(a),len(b),len(c)
while True:
  try:
    if temp=="a":
      temp=a.pop(0)
    elif temp=="b":
      temp=b.pop(0)
    elif temp=="c":
      temp=c.pop(0)
  except:
    print(temp.upper())
    break

Measured memory_bytes: 3064
#include<math.h>
#include<iostream>

using namespace std;

int main()
{
	int x1,y1,x2,y2;
	double d,x,y;

	cin >> x1 >> y1 >> x2 >> y2;

	x = (x2-x1)*(x2-x1);

	y = (y2-y1)*(y2-y1);


	d = sqrt((x+y));

	cout << d << endl ;

	return 0;
}

Measured memory_bytes: 1232
n=int(input())
d=list(map(int,input().split()))
s=[]
count=0
for i in range(1,n-1):
  s.append(d[i])
  s.append(d[i-1])
  s.append(d[i+1])
  s.sort()
  if s[1]==d[i]:
    count+=1
  s=[]
print(count)

Measured memory_bytes: 3064
import java.util.*
import kotlin.comparisons.*

fun main(args : Array<String>) {
  var (n, m) = readLine()!!.split(' ').map(String::toInt)
  val cards = TreeMap<Int, Int>(reverseOrder())
  readLine()!!.split(' ').forEach {
    val a = it.toInt()
    cards[a] = cards.getOrElse(a, { 0 }) + 1
  }
  repeat(m) {
    val (b, c) = readLine()!!.split(' ').map(String::toInt)
    cards[c] = cards.getOrElse(c, { 0 }) + b
  }
  var ans = 0L
  exit@for ((k, v) in cards) {
    for (i in 1..v) {
      if (n-- == 0) break@exit
      ans += k
    }
  }
  println(ans)
}


Measured memory_bytes: 89256