akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <map>
#include <vector>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cctype>
#include <cstdlib>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define IREP(it,array) for(vector<int>::iterator it=array.begin(); it!=array.end(); ++it)
#define PREP(it,array) for(vector<P>::iterator it=array.begin(); it!=array.end(); ++it)
#define SREP(it,array) for(vector<string>::iterator it=array.begin(); it!=array.end(); ++it)

#define MP       make_pair
#define PB       push_back
#define ALL(x)   (x).begin(),(x).end()

const int INF = 1<<29;
const double EPS = 1e-9;
double zero(double d){
  return d < EPS ? 0.0 : d;
}

typedef long long LL;
typedef pair<int,int> P;


int main()
{
  cout.setf(ios::fixed, ios::floatfield);
  cout.precision(7);

  int n,m;
  cin >> n >> m;

  int d[n+1][n+1];
  REP(i,n+1){
    fill( d[i], d[i]+n+1, INF );
    d[i][i] = 0;
  }

  REP(i,m){
    int a,b,c,dd;
    scanf( "%d,%d,%d,%d", &a, &b, &c, &dd );
    d[a][b] = c;
    d[b][a] = dd;
  }
  
  int x1,x2,y1,y2;
  scanf( "%d,%d,%d,%d", &x1, &x2, &y1, &y2 );
  
  REP(k,n+1)
    REP(i,n+1)
    REP(j,n+1)
    d[i][j] = min( d[i][j], d[i][k] + d[k][j] );
  
  int res = y1 - y2 - d[x1][x2] - d[x2][x1];
  cout << res << endl;

  return 0;
}

Measured memory_bytes: 1240
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define PER(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9+5)
#define INFLL ((LL)4e18)
#define ALL(x) (x).begin(),(x).end()
#define BIT(x) (1 << (x))
using namespace std;

int main(){
	int a=0, b=0;
	REP(i, 2){
		int d;
		cin >> d;
		a+=d;
	}
	REP(i, 2){
		int d;
		cin >> d;
		b+=d;
	}
	if(a>b){
		cout << "Left" << endl;
	}else if(a<b){
		cout << "Right" << endl;
	}else{
		cout << "Balanced" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>

using namespace std;

int main() {
	int H, W;
	int c = 1;
	int d = -1;

	while (1) {

		cin >> H >> W;

		if (H == 0 && W == 0) {
			return 0;
		}

		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {

				if (c == 1) {
					cout << '#';
					c = -1;
				}
				else {
					cout << '.';
					c = 1;
				}

			}
			cout << endl;

			c = d;
			d = d *(-1);
		}

		c = 1;
		d = -1;
		cout << endl;

	}
	return 0;
}

Measured memory_bytes: 3084
function main(input) {
  input = input.trim();
  const a = input.split(" ").map(Number);
  const gou = a[0]+a[1];
  if(a[2]>=a[0]&&gou>=a[2]){
    console.log("YES");
  }else{
    console.log("NO");
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29556
def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    [N, M] = list(map(lambda x: int(x), inputs[0].split()))
    broke_steps = {}
    for b in map(lambda x: int(x), inputs[1:]):
        broke_steps[b] = True

    SSSS = 1000000007

    patterns = [1]
    for step in range(1, N + 1):
        if step in broke_steps:
            ap = 0
        elif step == 1:
            ap = 1
        else:
            ap = (patterns[step - 1] + patterns[step - 2]) % SSSS
        patterns.append(ap)

    return patterns[-1]


if __name__ == "__main__":
    first = input()
    [N, M] = list(map(lambda x: int(x), first.split()))
    inputs_str = inputs(M)
    inputs_str.insert(0, first)
    ret = solve(inputs_str)
    print(ret)


Measured memory_bytes: 22180
#include <bits/stdc++.h>
#define inf 1000000007
#define mod 1000000007
//#pragma GCC optimize(2)
//#define int long long
using namespace std;
template <typename T> void read(T &x){
	x=0;char ch=getchar();int fh=1;
	while (ch<'0'||ch>'9'){if (ch=='-')fh=-1;ch=getchar();}
	while (ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
	x*=fh;
}
template <typename T> void write(T x) {
	if (x<0) x=-x,putchar('-');
	if (x>9) write(x/10);
	putchar(x%10+'0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
int n,k;
bool vis[105];
signed main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>k;
	for(int i=1;i<=k;i++)
	{
		int d;
		cin>>d;
		for(int j=1;j<=d;j++)
		{
			int a;
			cin>>a;
			vis[a]=1;
		}
	}
	int ans=0;
	for(int i=1;i<=n;i++)
		if(!vis[i])
			ans++;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3644
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower
#include <cstdint>   // int64_t, int*_t
#include <cstdio>    // printf
#include <deque>     // deque
#include <iomanip>   // setprecision
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector
using namespace std;

int gcd(long long a, long long b) { return b != 0 ? gcd(b, a % b) : a; }
// cout << fixed << setprecision(10);

int main() {
    string S;
    cin >> S;
    int len = 0;
    int ans = 0;

    string ACGT = "ACGT";

    for(char c : S) {
        if(find(ACGT.begin(), ACGT.end(), c) != ACGT.end()){
            len++;
            ans = max(ans, len);
        }else{
            len = 0;
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define pb push_back
#define eb emplace_back
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;
void print() {
    cout << endl;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail) != 0) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
void print(vector<T> &vec) {
    for (auto& a : vec) {
        cout << a;
        if (&a != &vec.back()) cout << ' ';
    }
    cout << endl;
}

template <class T>
void print(vector<vector<T>> &df) {
    for (auto& vec : df) {
        print(vec);
    }
}

template<class T, class U>
void print(pair<T,U> p){
    cout << p.first << " " << p.second << "\n";
}
int main(){
    ll n,l; cin >> n >> l;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    vector<ll> ans;
    bool ok = false;
    ll last = 0;
    rep(i,n-1)if(a[i] + a[i+1] >= l){
        ok = true;
        last = i;
    }
    rep(i,last)ans.emplace_back(i+1);
    for(int i = n-2;last < i; i--)ans.emplace_back(i+1);
    ans.emplace_back(last+1);
    debug(last);
    if(ok){
        cout << "Possible" << endl;
        print(ans);
    }
    else cout << "Impossible" << endl;
}

Measured memory_bytes: 2548
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>


#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979
#define MAXI 7500000

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

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



int main(void) {
	int n;
	int count = 0;

	cin >> n;

		
		while (n) {
			if (n % 10 == 2) {
				count++;
			}
			n /= 10;
		}
	
	cout << count << endl;

	return 0;
}

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

using namespace std;

#define ll long long
#define rep(i,n) for(int i=1;i<=(n);i++)
#define rep0(i,n) for(int i=0;i<(n);i++)

const ll INF=1e9+7;
int n,m,minf=INF;
int main()
{
	/*freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);*/
	cin>>n>>m;
	for(int i=n/3;i<=n/3+1;i++){
		if(i==0)continue;
		int a=i*m;
		int b=(n-i)*(m/2);
		int c=(n-i)*((m+1)/2);
		int ma=max(a,max(b,c));
		int mi=min(a,min(b,c));
		minf=min(minf,ma-mi);
	}
	for(int i=n/3-1;i<=n/3+1;i++){
		if(i<=0||n-2*i<=0)continue;
		int a=i*m;
		int b=(n-2*i)*m;
		minf=min(minf,abs(a-b));
	}
	swap(n,m);
	for(int i=n/3;i<=n/3+1;i++){
		if(i==0)continue;
		int a=i*m;
		int b=(n-i)*(m/2);
		int c=(n-i)*((m+1)/2);
		int ma=max(a,max(b,c));
		int mi=min(a,min(b,c));
		minf=min(minf,ma-mi);
	}
	for(int i=n/3-1;i<=n/3+1;i++){
		if(i<=0||n-2*i<=0)continue;
		int a=i*m;
		int b=(n-2*i)*m;
		minf=min(minf,abs(a-b));
	}
	cout<<minf;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
using namespace std;

int main()
{
	int a, b, c, d;
	int m,n;
	scanf("%d %d %d %d", &a, &b, &c, &d);
	m = a + b;
	n = c + d;
	if(m > n) printf("Left\n");
	else if(m < n) printf("Right\n");
	else printf("Balanced\n");
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>

int main() {
    std::string s, t;
    std::cin >> s;
    std::cin >> t;

    std::sort(s.begin(), s.end());
    std::sort(t.rbegin(), t.rend());
    std::cout << (s < t ? "Yes" : "No") << std::endl;
}


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

uint_fast64_t A, B;

int main(){
    cin >> A >> B;
    if(A > B)swap(A, B);
    if(A == 1)
        if(B == 1)puts("1");
        else cout << B - 2 << endl;
    else cout << (A - 2) * (B - 2) << endl;
    return 0;
}

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

int n;
set <int> S;

int main()
{
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        int a; scanf("%d", &a);
        S.insert(a);
    }
    printf("%s\n", S.size() == n? "YES": "NO");
    return 0;
}


Measured memory_bytes: 9600
#include<stdio.h>
 
int main(void)
{
	long int a,b,k;
	
	scanf("%ld%ld%ld",&a,&b,&k);
	
	if(k>=a+b){
		printf("0 0");
	}else{
		if(k>=a)
			printf("%ld %ld",0,a+b-k);
		else
			printf("%ld %ld",a-k,b);
	}
	return 0;
}

Measured memory_bytes: 128
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from decimal import *
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
INF = float('inf') #無限大
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(sys.stdin.readline()) #整数読み込み
def ifn(): return float(sys.stdin.readline()) #浮動小数点読み込み
def isn(): return sys.stdin.readline().split() #文字列読み込み
def imn(): return map(int, sys.stdin.readline().split()) #整数map取得
def imnn(): return map(lambda x:int(x)-1, sys.stdin.readline().split()) #整数-1map取得
def fmn(): return map(float, sys.stdin.readline().split()) #浮動小数点map取得
def iln(): return list(map(int, sys.stdin.readline().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, sys.stdin.readline().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def m_add(a,b): return (a+b) % MOD
def print_list(l): print(*l, sep='\n')
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def No(): print('No')
 
def sieves_of_e(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n+1, i): is_prime[j] = False
    return is_prime
 
K = iin()

ans = 0
for a in range(1, K+1):
    for b in range(1, K+1):
        ab = 1
        if a == 1 or b == 1:
            ab = 1
        elif a == b:
            ab = a
        else:
            ab = math.gcd(a, b)
        for c in range(1, K+1):
            if ab == 1 or c == 1:
                ans += 1
            elif ab == c:
                ans += c
            else:
                ans += math.gcd(ab, c)
print(ans)

Measured memory_bytes: 10632
//2019.8.18 by ljz
//email 573902690@qq.com
//if you find any bug in my code
//please tell me
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define LL long long
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f
#define unl __int128
#define eps 5.6e-8
#define RG register
#define db double
#define pc(x) __builtin_popcount(x)
typedef pair<int,int> Pair;
#define mp make_pair
#define fi first
#define se second
#define pi acos(-1.0)
#define pb push_back
#define ull unsigned LL
#define gc getchar
//inline char gc() {
//    static char buf[100000],*p1,*p2;
//    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
//}
inline int read() {
    res s=0,ch=gc();
    while(ch<'0'||ch>'9')ch=gc();
    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
    return s;
}
//inline int read() {
//    res s=0,ch=gc(),w=1;
//    while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=gc();}
//    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
//    return s*w;
//}
//inline LL Read() {
//    RG LL s=0;
//    res ch=gc();
//    while(ch<'0'||ch>'9')ch=gc();
//    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
//    return s;
//}
//inline LL Read() {
//    RG LL s=0;
//    res ch=gc(),w=1;
//    while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=gc();}
//    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
//    return s*w;
//}
//inline void write(RG unl x){
//    if(x>10)write(x/10);
//    putchar(int(x%10)+'0');
//}
inline void swap(res &x,res &y) {
    x^=y^=x^=y;
}
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//clock_t start=clock();
//inline void ck(){
//    if(1.0*(clock()-start)/CLOCKS_PER_SEC>0.1)exit(0);
//}
namespace MAIN{
    int n;
    db sum;
    inline void MAIN(){
        n=read();
        for(res i=1;i<=n;i++)sum+=1.0/read();
        printf("%.10lf\n",1.0/sum);
    }
}
int main(){
//    srand(19260817);
//    freopen("signin.in","r",stdin);
//    freopen("signin.out","w",stdout);
    MAIN::MAIN();
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF -1
using namespace std;
int main(){
    int D,N;
    int T[201];
    int A[201],B[201],C[201];
    int dp[201][201]={};
    
    cin>>D>>N;
    for(int i=0;i<D;i++) cin>>T[i];
    for(int i=0;i<N;i++) cin>>A[i]>>B[i]>>C[i];
    
    for(int i=0;i<D;i++)
        for(int j=0;j<N;j++) dp[i][j]=INF;
    
    for(int i=0;i<D;i++){
        for(int j=0;j<N;j++){
            if(i==0){
                if(A[j]<=T[i] && T[i]<=B[j]){
                    dp[i][j]=0;
                }
            }
            else if(A[j]<=T[i] && T[i]<=B[j]){
                for(int k=0;k<N;k++){
                    if(dp[i-1][k]<0) continue;
                    dp[i][j]=max(dp[i][j],dp[i-1][k]+abs(C[j]-C[k]));
                }
            }
        }
    }
    
    int ans=0;
    for(int j=0;j<N;j++) ans=max(ans,dp[D-1][j]);
    
    cout<<ans<<endl;
    
    return 0;
}



Measured memory_bytes: 3240
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int n,k;
	cin>>n>>k;
	vector<int> a(n);
	map<int,int> mp;
	rep(i,n){
		cin>>a[i];
		mp[a[i]]++;
	}
	if(mp.size()<=k){
		cout<<0<<endl;
		return 0;
	}
	int cnt=mp.size()-k;
	int ans=0;
	vector<int> res;
	for(auto itr:mp){
		res.push_back(itr.se);
	}
	sort(begin(res),end(res));
	rep(i,cnt) ans+=res[i];
	cout<<ans<<endl;
}

Measured memory_bytes: 11640
// In the name of God

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define Size(x) ((int)(x).size())
typedef long long ll;
typedef long double ld;
typedef pair<int , int>pii;
const int INF = 1e9 + 10;

int n;

int main(){
	ios_base :: sync_with_stdio(false) , cin.tie(0) , cout.tie(0);
	cin >> n;
	int r = 0 , c = 0 , lst = 0;
	for(int i=0;i<n;++i){
		int R , C , t;
		cin >> t >> R >> C;
		int x = t - lst;
		lst = t;
		if(abs(R - r) + abs(C - c) > x || (abs(R-r) + abs(C-c))%2 != x%2)
			return cout << "No\n" , 0;
		r = R , c = C;
	}
	cout << "Yes\n";
	return 0;
}


Measured memory_bytes: 256
import kotlin.math.abs
import kotlin.math.min

fun main() = msolutions2020e()

@OptIn(ExperimentalStdlibApi::class)
fun msolutions2020e() {
    val n = readLine()!!.toInt()
    val xList = IntArray(n)
    val yList = IntArray(n)
    val pList = IntArray(n)
    repeat(n) { i ->
        val (x, y, p) = readLine()!!.split(" ").map { it.toInt() }
        xList[i] = x
        yList[i] = y
        pList[i] = p
    }

    val choosePatterns = 1 shl n
    // 何もしてないのときの移動距離
    val baseDistances = (0 until n).map { min(abs(yList[it]), abs(xList[it])) }.toIntArray()
    // [その集合の街を基準に『横』に線路を引いたとき][i番目の街の] = 移動距離の最小
    val costsVert = Array(choosePatterns) { baseDistances.copyOf() }
    // [その集合の街を基準に『縦』に線路を引いたとき][i番目の街の] = 移動距離の最小
    val costsHorz = Array(choosePatterns) { baseDistances.copyOf() }

    val diffVert = Array(n) { IntArray(n) { Int.MAX_VALUE } }
    val diffHorz = Array(n) { IntArray(n) { Int.MAX_VALUE } }

    for (from in 0 until n) for (to in 0 until n) {
        diffVert[from][to] = min(diffVert[from][to], abs(yList[from] - yList[to]))
        diffHorz[from][to] = min(diffHorz[from][to], abs(xList[from] - xList[to]))
    }

    for (choose in 0 until choosePatterns) {
        for (from in (0 until n)) {
            if ((choose shr from) and 1 == 0) continue
            for (to in 0 until n) {
                costsVert[choose][to] = min(costsVert[choose][to], diffVert[from][to])
                costsHorz[choose][to] = min(costsHorz[choose][to], diffHorz[from][to])
            }
        }
    }

    val answers = LongArray(n + 1) { Long.MAX_VALUE }

    for (b in 0 until (3).simplePowExact(n)) {
        var chooseVertBit = 0
        var chooseHorzBit = 0
        var bitOfChooseTypes = b
        var bitOfDigit2 = 1

        while (bitOfChooseTypes > 0) {
            when (bitOfChooseTypes % 3) {
                1 -> chooseVertBit = chooseVertBit or bitOfDigit2
                2 -> chooseHorzBit = chooseHorzBit or bitOfDigit2
            }
            bitOfDigit2 = bitOfDigit2 shl 1
            bitOfChooseTypes /= 3
        }

        var costSum = 0L
        (0 until n).forEach {
            costSum += min(costsVert[chooseVertBit][it], costsHorz[chooseHorzBit][it]).toLong() * pList[it]
        }

        val chooseCount = Integer.bitCount(chooseVertBit or chooseHorzBit)
        answers[chooseCount] = min(answers[chooseCount], costSum)
    }

    val answer = answers.joinToString(System.lineSeparator())

    println(answer)
}

private fun Int.simplePowExact(p: Int): Int {
    var x = 1
    repeat(p) { x = Math.multiplyExact(x, this) }
    return x
}


Measured memory_bytes: 62640
#include <iostream>
#include <string>
using namespace std;
int main(void){
  string s;
  cin >> s;
  bool appeared[26] = {false};
  for(int i = 0; i < s.size(); i++) appeared[s[i]-'a'] = true;
  for(int i = 0; i < 26; i++){
    if(!appeared[i]){
      char c = i+'a';
      cout << c << endl;
      return 0;
    }
  }
  cout << "None" << endl;
  return 0;
}

Measured memory_bytes: 512
package main

import (
	"bufio"
	"fmt"
	"log"
	"math"
	"os"
	"strconv"
	"strings"
)

func abs(v int64) int64 {
	if v < 0 {
		return -v
	}
	return v
}

func getans(n, k int64) int64 {
	if n > k {
		n = n % k
	}
	if n == k {
		return 0
	}
	if n <= k/2 {
		return n
	} else {
		return abs(n - k)
	}
}

func main() {
	scanner := makeWordScanner()
	n := eGetInt64(scanner)
	k := eGetInt64(scanner)
	fmt.Println(getans(n, k))
}

////////////////////////////////////////////////////////////////////////////////
// ライブラリ
////////////////////////////////////////////////////////////////////////////////
const (
	TooLarge = math.MaxInt64
	TooSmall = math.MinInt64
)

func makeScanner(maxByte int) *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]uint8, 0, 8192), maxByte)
	return scanner
}
func makeCharScanner() *bufio.Scanner {
	scanner := makeScanner(8192)
	scanner.Split(bufio.ScanRunes)
	return scanner
}
func makeWordScanner() *bufio.Scanner {
	scanner := makeScanner(8192)
	scanner.Split(bufio.ScanWords)
	return scanner
}
func eGetLine(r *bufio.Scanner) string {
	if r.Scan() {
		return r.Text()
	}
	err := r.Err()
	if err != nil {
		log.Fatal(err)
	}
	// EOF
	return ""
}
func eGetInt(r *bufio.Scanner) int {
	line := eGetLine(r)
	return eAtoi(line)
}
func eGetInt64(r *bufio.Scanner) int64 {
	line := eGetLine(r)
	return eAtoInt64(line)
}
func eGetFields(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Fields(line)
}
func eGetInts(r *bufio.Scanner) []int {
	fields := eGetFields(r)
	ints := make([]int, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoi(fields[i])
	}
	return ints
}
func eGetInt64s(r *bufio.Scanner) []int64 {
	fields := eGetFields(r)
	ints := make([]int64, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoInt64(fields[i])
	}
	return ints
}
func eGetChars(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Split(line, "")
}
func eAtoi(s string) int {
	n, err := strconv.Atoi(s)
	if err != nil {
		log.Fatal(err)
	}
	return n
}
func eAtoInt64(s string) int64 {
	n, err := strconv.ParseInt(s, 10, 64)
	if err != nil {
		log.Fatal(err)
	}
	return n
}
func pow(a, n int) int {
	if n == 0 {
		return 1
	}
	if n == 1 {
		return a
	}
	if n%2 == 1 {
		return pow((a*a), n/2) * a
	}
	return pow((a * a), n/2)
}
func powMod(a, n, mod int) int {
	if n == 0 {
		return 1 % mod
	}
	if n == 1 {
		return a % mod
	}
	if n%2 == 1 {
		return powMod((a*a)%mod, n/2, mod) * a % mod
	}
	return powMod((a*a)%mod, n/2, mod)
}

func factoricalMod(n, count, mod int) int {
	if count == 1 {
		return n % mod
	}
	return (n % mod) * (factoricalMod(n-1, count-1, mod)) % mod
}

func combinationMod(n, a, mod int) int {
	x := factoricalMod(n, a, mod)
	y := factoricalMod(a, a, mod)
	y = powMod(y, mod-2, mod)
	return ((x % mod) * (y % mod)) % mod
}
func countBitOfOn(i, numbits int) int {
	count := 0
	var bit uint64
	for bit = 0; bit < uint64(numbits); bit++ {
		t := 1 << bit
		if i&t > 0 {
			count++
		}
	}
	return count
}

type ints []int

func ToString(slice []int) string {
	format := fmt.Sprint(slice)
	return fmt.Sprint(format[1 : len(format)-1])
}


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

typedef long long int ll;

int main(){
  ll r,g,b,n;
  cin>>r>>g>>b>>n;
  ll ans=0;
  for(int i=0;i<=n/r;i++){
          for(int j=0;j<=n/g;j++)
          {
             ll t=i*r+j*g;
             if(t>n) break;
             if((n-t)%b==0) ans++;
          }
  }
  
  cout<<ans<<endl;
  
} 


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int N,p[45],t[45],i,j,R,dp[45][4];
int dfs(int n,int c)
{
	int tmp=-9999,TL=t[n+1]-t[n],res=-9999;
	if(dp[n][c]!=-9999)return dp[n][c];
	if(n==N)return dp[n][c]=p[n];
	if(c<3&&abs(p[n]-p[n+1])*(c+1)<=TL)
	{
		tmp=dfs(n+1,p[n+1]==0?0:c+1);
		if(tmp>=0)tmp+=abs(p[n]-p[n+1]);
		res=tmp;
	}
	tmp=-9999;
	if(c>0&&p[n]*(c+1)+p[n+1]<=TL)
	{
		tmp=dfs(n+1,1);
		if(tmp>=0)tmp+=p[n]+p[n+1];
		if(res==-9999&&tmp!=-9999)res=tmp;
		else if(res<0&&tmp>=0)res=tmp;
		else if(res>=0&&tmp<0)res=res;
		else res=res<tmp?res:tmp;
	}
	if(res==-9999)return -(n+1);
	return dp[n][c]=res;
}

int main()
{
	for(;scanf("%d",&N),N;)
	{
		for(i=0;i<45;i++)
			for(j=0;j<4;j++)
				dp[i][j]=-9999;
		for(i=1;i<=N;i++)
			scanf("%d%d",&p[i],&t[i]);
		R=dfs(0,0);
		printf("%s %d\n",R>=0?"OK":"NG",abs(R));
	}
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
typedef long long i64;
int main(){
    int N;
    cin >> N;
    int C[N-1],S[N-1],F[N-1];
    rep(i,N-1){
        cin >> C[i] >> S[i] >> F[i];
    }
    rep(i,N){
        if(i==N-1) cout << 0 << endl;
        else{
            int a = C[i]+S[i];
            repi(j,i+1,N-1){
                if(a<S[j]) a=S[j];
                else if(a%F[j]!=0) a+=F[j]-a%F[j];
                a+=C[j];
            }
            cout << a << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
while 1:
	W,Q = map(int,raw_input().split())
	if W == 0: break
	cat = [map(str,raw_input().split()) for i in range(Q)]
	dic = {cat[i][1]:[int(cat[i][2]),0] for i in range(Q) if cat[i][0] == "s"}
	wall = [-1]*W
	for i in range(Q):
		if cat[i][0] == "s":
			id,w = cat[i][1],int(cat[i][2])
			for j in range(W-w+1):
				if wall[j:j+w] == [-1]*w:
					wall[j:j+w] = [id]*w
					dic[id][1] = j
					print j
					break
			else:
				print "impossible"
		else:
			w,sp = dic[cat[i][1]]
			wall[sp:sp+w] = [-1]*w
	print "END"

Measured memory_bytes: 4268
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;

int main(){
    fast_io
    
    ll n, T;cin>>n>>T;
    ll t[n];
    rep(i,n) cin>>t[i];
    ll ans=0;
    rep(i,n-1){
        ans+=min(t[i+1]-t[i], T);
    }
    cout<<ans+T<<endl;

    return 0;
}

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

#define fastIO ios::sync_with_stdio(0); cin.tie(NULL);

typedef long long ll;

using namespace std;

int main(){

    fastIO

    int n; cin>>n;

    int cnt = 0;

    int a,b;

    string ans = "No";

    while(n--){

      cin>>a>>b;

      if(a!=b) cnt=0;

      if(a==b) cnt++;

      if(cnt>=3){

        ans = "Yes";

      }

    }

    cout<<ans;

   

    return 0;

}

Measured memory_bytes: 3644
import sys
input = sys.stdin.readline
N = int(input())
A = [int(input()) for _ in range(N)]
B = sorted(A,reverse=True)
m = B[0]
n = B[1]
ind = A.index(m)
if m != n:
    ans = "\n".join([str(m) if i != ind else str(n) for i in range(N) ])
else:
    ans = "\n".join([str(m)for _ in range(N)])
print(ans)

Measured memory_bytes: 27676
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;
typedef vector<string> vstring;
typedef vector<char> vchar;

typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<double, double>> vpdouble;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<bool>> vvbool;

typedef vector<vector<string>> vvstring;

const int c_YET = -1;
const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const ll MAX = 1e9;
const double PI = 3.14159265358979323846264338327950288;
//========================================================================




int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	//==================================



	double L;
	cin >> L;





	cout << pow(L / 3, 3);





}



Measured memory_bytes: 384
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<string>
#include<cstring>
#include<time.h>
#include<iomanip>
#include<list>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<bitset>
#include <queue>
#include <map>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;

#define repi(i,a,b) for(ll i = (a); i < (b); i++)
#define rep(i, n) for(ll i = 0; i < (n); ++i)
ll MOD = 1000000007;
int main() {
    int N;
    cin >> N;
    unordered_set<string> s;
    rep(i, N) {
        string str;
        cin >> str;
        s.insert(str);
    }
    cout << s.size() << endl;
    return 0;
}



Measured memory_bytes: 17692
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
const ll LIM = 1000000000000000000;
//Loop
#define REP(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define RREP(i,a,b) for(ll (i)=(a);(i)>=(b);(i)--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,n,0)
 
int main(void){
	ll n;
	ll a[100000];
	cin>>n;
	rep(i,n){
		cin>>a[i];
		if(a[i]==0){
			cout<<0<<endl;
			exit(0);
		}
	}
 
	ll ans = 1;
	rep(i,n){
		if(a[i]>LIM/ans){
			cout<<-1<<endl;
			exit(0);
		}
		ans*=a[i];
	}
 
	cout<<ans<<endl;
 
	return 0;
}

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

ll choose2(ll n) {
    return n*(n-1)/2;
}

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    vector<int> cnt(n, 0);
    rep(i,n) cnt[a[i]-1] += 1;
    // 全体を求める
    ll all = 0;
    rep(i,n) {
        if (cnt[i] < 2) continue;
        all += choose2(cnt[i]);
    }
    // 全体からk番目と同じボールの選び方を引いて、k番目以外から同じ2個のボールを選ぶ選び方
    vector<ll> ans(n,all);
    rep(k,n) {
        ans[k] -= cnt[a[k]-1] - 1;
        cout << ans[k] << endl;
    }
    return 0;
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    int a, b; cin >> a >> b;

    if(a*b %2 == 0) cout << "No" << endl;
    else cout << "Yes" << endl;
}
   

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	int N;
	long A, B, C;
	String[] s;
	List<String> result;
	boolean enable = true;

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	Main(BufferedReader in) throws IOException {
		String[] tokens = in.readLine().split(" ");
		N = Integer.parseInt(tokens[0]);
		A = Long.parseLong(tokens[1]);
		B = Long.parseLong(tokens[2]);
		C = Long.parseLong(tokens[3]);
		s = new String[N];
		for (int i = 0; i < N; ++i) {
			String line = in.readLine();
			s[i] = line;
		}
	}

	String eval(String str) {
		if (str.equals("AB")) {
			if (A > B) {
				--A;
				++B;
				return "B";
			} else {
				++A;
				--B;
				return "A";
			}
		} else if (str.equals("AC")) {
			if (A > C) {
				--A;
				++C;
				return "C";
			} else {
				++A;
				--C;
				return "A";
			}
		} else {
			if (B > C) {
				--B;
				++C;
				return "C";
			} else {
				++B;
				--C;
				return "B";
			}
		}
	}

	String eval(String current, String next) {
		if (current.equals("AB")) {
			if (A > B) {
				--A;
				++B;
				return "B";
			} else if (A < B) {
				++A;
				--B;
				return "A";
			} else {
				if (next.equals("AC")) {
					++A;
					--B;
					return "A";
				} else if (next.equals("BC")) {
					--A;
					++B;
					return "B";
				} else {
					++A;
					--B;
					return "A";
				}
			}
		} else if (current.equals("AC")) {
			if (A > C) {
				--A;
				++C;
				return "C";
			} else if (A < C) {
				++A;
				--C;
				return "A";
			} else {
				if (next.equals("AB")) {
					++A;
					--C;
					return "A";
				} else if (next.equals("BC")) {
					--A;
					++C;
					return "C";
				} else {
					++A;
					--C;
					return "A";
				}
			}
		} else {
			if (B > C) {
				--B;
				++C;
				return "C";
			} else if (B < C) {
				++B;
				--C;
				return "B";
			} else {
				if (next.equals("AB")) {
					++B;
					--C;
					return "B";
				} else if (next.equals("AC")) {
					--B;
					++C;
					return "C";
				} else {
					++B;
					--C;
					return "B";
				}
			}
		}
	}

	void calc() {
		result = new ArrayList<>(N);
		for (int i = 0; i < N - 1; ++i) {
			result.add(eval(s[i], s[i + 1]));
			if (A < 0 || B < 0 || C < 0) {
				enable = false;
				return;
			}
		}
		result.add(eval(s[N - 1]));
		if (A < 0 || B < 0 || C < 0) {
			enable = false;
		}
		
	}

	void showResult() {
		if (enable) {
			System.out.println("Yes");
			for (int i = 0; i < result.size(); ++i) {
				System.out.println(result.get(i));
			}
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 53564
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>

using std::cerr;
using std::cin;
using std::cout;
using std::endl;

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

  std::string s;
  cin>>s;
  if(s=="Sunny"){
    cout<<"Cloudy";
  }else if(s=="Cloudy"){
    cout<<"Rainy";
  }else{
    cout<<"Sunny";
  }
  cout<<endl;





  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lsb(x) (x & (-x))
#define ll long long
#define ull unsigned long long
// 217
// 44


/*const int MOD = (int) 1e9 + 7;

inline void mod(int &x) {
    if(x >= MOD)
        x -= MOD;
}

inline void add(int &x, int y) {
    x += y;
    mod(x);
}

inline void mul(int &x, int y) {
    x = (1LL * x * y) % MOD;
}*/

using namespace std;


int main() {
    //ifstream cin("A.in");
    //ofstream cout("A.out");
    int i, n;
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    cin >> n;

    if(__builtin_popcount(n) == 1) {
        cout << "No";
        return 0;
    }

    cout << "Yes\n";

    cout << 1 << " " << 2 + n << "\n";
    cout << 2 + n << " " << 3 + n << "\n";
    cout << 3 + n << " " << 1 + n << "\n";
    cout << 1 + n << " " << 2 << "\n";
    cout << 2 << " " << 3 << "\n";

    for(i = 4; i < n; i += 2) {
        cout << i << " " << i + 1 << "\n";
        cout << i << " " << n + 1 << "\n";
        cout << i + 1 + n << " " << i + n << "\n";
        cout << i + 1 + n << " " << n + 1 << "\n";
    }

    if(n % 2 == 0) {
        for(i = 4; i < n; i++) {
            int a = i, b = (n ^ i ^ 1);
            if(b > 1 && b < n && b != a) {
                if(a & 1) {
                    cout << n << " " << a + n << "\n";
                }
                else {
                    cout << n << " " << a << "\n";
                }
                if(b & 1) {
                    cout << 2 * n << " " << b + n << "\n";
                }
                else {
                    cout << 2 * n << " " << b << "\n";
                }
                return 0;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 2816
#include <iostream>
#include <fstream>
#include <vector>
#include <utility>
#include <map>
#include <set>
#include <list>
#include <deque>
#include <queue>
#include <stack>
#include <forward_list>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <string>
#include <bitset>
#include <memory>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <cstring>
#include <cstdlib>
#include <cstdint>

using namespace std;

set<int> prime;

void calc_prime(int mm) {
    int cur = 2;
    while(cur <= mm) {
        for(auto itr = prime.begin();itr != prime.end();itr++) {
            if(cur % *itr == 0)
                goto not_prime;
        }
        prime.insert(cur);
    not_prime:
        cur++;
    }
}
/*
int main(void) {
    int n,res = 0;
    cin >> n;
    if(n % 2 == 0)
        res = n;
    else
        res = 2 * n;
    cout << res << endl;
    return 0;
}
 */
int main(void ) {
    int n;
    int maxn = 0,minn = 1000000001;
    cin >> n;
    for(int i = 0;i < n;i++) {
        int t;
        cin >> t;
        maxn = max(maxn,t);
        minn = min(minn,t);
    }
    cout << maxn - minn << endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
A - Traveling Budget
https://beta.atcoder.jp/contests/abc092/tasks/abc092_a

"""
import sys
from sys import stdin
input = stdin.readline


def main(args):
    A = int(input())
    B = int(input())
    C = int(input())
    D = int(input())
    ans = min(A, B) + min(C, D)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])
    


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  vector<char> N(200010, '0');
  int sum = 0;

  for (int i = 0; i < 200010; i++) {
    cin >> N.at(i);
    sum += N.at(i) - '0';  
  }
  
  if (sum % 9 == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  
}

Measured memory_bytes: 3636
N, M = map(int, input().split())
A = sorted(list(map(int, input().split())))

bc = [list(map(int, input().split())) for _ in range(M)]

ans = sum(A)

bc = sorted(bc, key=lambda i: i[1], reverse=True)

i = 0
for b, c in bc:
    for _ in range(b):
        if A[i] > c:
            break
        ans += c - A[i]
        i += 1
        if i >= N:
            break
    else:
        continue
    break

print(ans)

Measured memory_bytes: 33640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}

int main() {
    string S;
    string A;
    cin >> S;
    if(S.length() % 2 == 0){
        cout << "No" << endl;
        return 0;
    }else{
        A = S;
        reverse(A.begin(),A.end());
        if(A == S){
            string formar = A.substr(0,A.length()/2);
            string reverseformar = A.substr(0,A.length()/2);
            reverse(reverseformar.begin(),reverseformar.end());
            
            string latter = A.substr(A.length()/2+1,A.length());
            string reverselatter = A.substr(A.length()/2+1,A.length());
            reverse(reverselatter.begin(),reverselatter.end());
            if(formar == reverseformar && latter == reverselatter){
                cout << "Yes" << endl;
            }else{
                cout << "No" << endl;
            }
        }else{
            cout << "No" << endl;
        }
        
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>

using namespace std;

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

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

  // double distance = sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));

  double distance = sqrt(pow((x1 - x2), 2) + pow((y1 - y2), 2));


  printf("%f\n", distance);
}



Measured memory_bytes: 3208
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0; i<(n); ++i)
#define REPR(i,n,m) for (int i=(n); i>=(m); --i)
using namespace std;
using LL = long long;
using LD = long double;
using PLL = pair<long long, long long>;
using PLD = pair<long double, long double>;
using VLL = vector<long long>;
using VLD = vector<long double>;
using VPLD = vector<PLD>;

const int INF = numeric_limits<int>::max();

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

    string x;
    cin >> x;

    stack<char> st;

    for (int i=0; i<x.size(); i++)
    {
        if ((x[i]=='T')&&(st.empty()||st.top()=='T')) st.push(x[i]);
        else if ((x[i]=='T')&&(st.top()=='S')) st.pop();
        else if ((x[i]=='S')) st.push(x[i]);
    }

    cout << st.size() << endl;

    return 0;
}


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

const int mod = 998244353;

inline int add(int x, int y) { return x + y >= mod ? x + y - mod : x + y; }
inline int sub(int x, int y) { return x - y >= 0 ? x - y : x - y + mod; }

const int N = 2e5 + 5;

int n, m, ans, f[N], len[N];
char str[N];

int check(int len) {
    for (int i = 0, k = 0; i < n; i += len, k ^= 1) {
        for (int j = 0; j < len; j++) {
            if ((str[j] ^ k) == (str[i + j])) { continue; }
            if ((str[j] ^ k) < (str[i + j])) { return 1; }
            return 0;
        }
    } return 1;
}
int solve(int len) {
    int res = 0;
    for (int i = 0; i < len; i++) {
        res = add(add(res, res), str[i] - '0');
    } return res + check(len);
}

int main() {
    scanf("%d%s", &n, str);
    for (int i = 1; i <= n; i++) {
        if (n % i == 0 && n / i % 2 == 1) { len[m++] = i; }
    }
    for (int i = 0; i < m; i++) {
        f[i] = solve(len[i]);
        for (int j = 0; j < i; j++) {
            if (len[i] % len[j] == 0 && len[i] / len[j] % 2 == 1) { f[i] = sub(f[i], f[j]); }
        } ans = add(ans, 1ll * len[i] * 2 % mod * f[i] % mod);
    } printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<set>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<queue>
using namespace std;

#define rep(i,n) for(long long i = 0; i < n; i++)

typedef long long ll;
typedef unsigned long long int ulli;

const ll INF = ll(1e18) + 1;

typedef struct {
	ll cost;
	ll damage;
}magic;

unsigned long long int a(ulli n, ulli b) {
	if (b <= 1) {
		return n;
	}
	else {
		return a(n * 2, b - 1);
	}
}

ll mina(ll a, ll b) {
	return (a > b) ? b : a;
}

void Main()
{
	ll n, ans = 0, min = INF;
	cin >> n;
	rep(i, n) {
		int x; cin >> x;
		if (min >= x) {
			ans++;
			min = x;
		}
	}
	cout << ans << endl;
}

int main() {
	Main();
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
#define all(v) (v).begin(),v.end()
#define fi first
#define se second
set<string> c;
map<ll,ll> mp;
const ll inf=(1e18);
const ll mod=1000000007;
const ll mod2=998244353;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
const ll MAX = 200010;//設定して

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = 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;
    }
}

// 二項係数計算
long long 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;
}
long long modpow(long long a, long long n) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
long long modinv(long long a) { //逆元
    long long  b=mod,u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= mod; 
    if (u < 0) u += mod;
    return u;
}
int main(){
ll n,a,b,c;
cin>>n>>a>>b>>c;
ll ans=0;
COMinit();
ll an=modpow(a,n),bn=modpow(b,n);
for(ll i=n;i<2*n;i++){
ll res;
res=(an*modpow(b,i-n))%mod+(bn*modpow(a,i-n))%mod;
res%=mod;res*=i;res%=mod;
(res*=COM(i-1,i-n))%=mod;
(res*=modinv(modpow(a+b,i)))%=mod;
ans+=res;
ans%=mod;
}
ans*=100;ans%=mod;
ans*=inv[a+b];ans%=mod;
cout<<ans<<endl;
}

Measured memory_bytes: 4992
#include<cstdio>
#include<algorithm>
using namespace std;
int n, m, dx[4] = { -1,1,0,0 }, dy[4] = { 0,0,-1,1 };
char p[5] = "LRDU";
struct point {
	long long x, y;
}w[1010], cur;
long long ab(long long a) { return a < 0 ? -a : a; }
long long Dist(point a, point b) {
	return ab(a.x - b.x) + ab(a.y - b.y);
}
long long d[40];
int main() {
	int i, j, ck = 0, k;
	d[0] = d[1] = 1;
	for (i = 0; i < 38; i++) {
		d[i + 2] = d[i] * 3;
	}
	scanf("%d", &n);
	int chk[2] = { 0,0 };
	for (i = 1; i <= n; i++) {
		scanf("%lld%lld", &w[i].x, &w[i].y);
		chk[((w[i].x + w[i].y) % 2 + 2) % 2] = 1;
	}
	if (chk[0] && chk[1]) {
		puts("-1");
		return 0;
	}
	if (chk[1])ck = 1;
	m = 40 - ck;
	printf("%d\n", m);
	for (i = m - 1; i >= 0; i--)printf("%lld ", d[i]);
	puts("");
	for (i = 1; i <= n; i++) {
		cur.x = 0, cur.y = 0;
		for (j = m - 1; j >= 0; j--) {
			long long Mn = 1e18;
			int pv = -1;
			for (k = 0; k < 4; k++) {
				point tp = { cur.x + dx[k] * d[j], cur.y + dy[k] * d[j] };
				long long dd = Dist(tp, w[i]);
				if (Mn > dd)Mn = dd, pv = k;
			}
			printf("%c", p[pv]);
			cur.x += dx[pv] * d[j];
			cur.y += dy[pv] * d[j];
		}
		if (Dist(cur, w[i])) {
			puts("!!!");
		}
		puts("");
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
    int n;
    cin >> n;
    map<int, int> mp;
    rep(i, n) {
        int a;
        cin >> a;
        mp[a]++;
    }
    int x = 0, y = 0, z = 0;
    for(auto&& p : mp) {
        if(p.se == 1) x++;
        else {
            y++;
            z += p.se-1;
        }
    }
    int ans = x + y;
    if(z&1) --ans;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4992