akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

template<int Modulo = MOD> struct Mint {
	Int val;
	constexpr Mint(Int v = 0) noexcept : val(v% Modulo) {
		if (val < 0) v += Modulo;
	}
	constexpr int getmod() { return Modulo; }
	constexpr Mint operator - () const noexcept { return val ? Modulo - val : 0; }
	constexpr Mint operator + (const Mint& r) const noexcept { return Mint(*this) += r; }
	constexpr Mint operator - (const Mint& r) const noexcept { return Mint(*this) -= r; }
	constexpr Mint operator * (const Mint& r) const noexcept { return Mint(*this) *= r; }
	constexpr Mint operator / (const Mint& r) const noexcept { return Mint(*this) /= r; }
	constexpr Mint& operator += (const Mint& r) noexcept {
		val += r.val;
		if (val >= Modulo) val -= Modulo;
		return *this;
	}
	constexpr Mint& operator -= (const Mint& r) noexcept {
		val -= r.val;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr Mint& operator *= (const Mint& r) noexcept {
		val = val * r.val % Modulo;
		return *this;
	}
	constexpr Mint& operator /= (const Mint& r) noexcept {
		Int a = r.val, b = Modulo, u = 1, v = 0;
		while (b) {
			Int t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		val = val * u % Modulo;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr bool operator == (const Mint& r) const noexcept {
		return this->val == r.val;
	}
	constexpr bool operator != (const Mint& r) const noexcept {
		return this->val != r.val;
	}
	friend ostream& operator << (ostream& os, const Mint<Modulo>& x) noexcept {
		return os << x.val;
	}
	friend istream& operator >> (istream& is, Mint<Modulo>& x) noexcept {
		Int tmp; is >> tmp;
		x = Mint<Modulo>(tmp);
		return is;
	}
	friend constexpr Mint<Modulo> modpow(const Mint<Modulo>& a, Int n) noexcept {
		Mint res(1), tmp = a;
		while (n > 0) {
			if (n & 1) res *= tmp;
			tmp *= tmp;
			n >>= 1;
		}
		return res;
	}
};

using mint = Mint<>;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int H, W, N;
	cin >> H >> W >> N;

	vector<Int> a(N);
	for (Int i = 0; i < N; i++) {
		cin >> a[i];
	}

	vector<Int> dirx{ -1,0 };
	vector<Int> diry{ 0,-1 };

	vector<vector<Int>> color(H, vector<Int>(W, -1));

	Int flag = 1;//→方向
	Int i = 0;
	Int j = 0;
	Int k = 0;//色
	while (a[N - 1]) {
		if (a[k]) {
			if (flag) {
				color[i][j] = k;
				a[k]--;
				j++;
				if (j == W) {
					j--;
					flag = 0;
					i++;
					continue;
				}
			}
			else {
				color[i][j] = k;
				a[k]--;
				j--;
				if (j == -1) {
					j++;
					flag = 1;
					i++;
					continue;
				}
			}
		}
		else {
			k++;
		}
	}

	for (Int i = 0; i < H; i++) {
		for (Int j = 0; j < W; j++) {
			printf("%ld ", color[i][j] + 1);
		}
		printf("\n");
	}

}

Measured memory_bytes: 512
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll f(ll b,ll n){
    if(n<b)return n;
    return f(b,n/b)+n%b;
    /*ll ans=0;
    while(n>=b){
        ans+=n%b;
        n/=b;
    }
    return ans+n;*/
}
int main(void){
    ll n,s;
    
    cin>>n>>s;
    if(n<s){cout<<-1<<endl;return 0;}
    else if(n==s){cout<<n+1<<endl;return 0;}
    else{
        for(ll i=2;i*i<=n;i++){
            if(f(i,n)==s){cout<<i<<endl;return 0;}
        }
        
        for(ll i=sqrt(n);i>=1;i--){
            if((n-s)/i>0&&f((n-s)/i+1,n)==s){
                cout<<(n-s)/i+1<<endl;
                return 0;
            }
        }
    }
    cout<<-1<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>

using namespace std;

int main()
{
  int x,y;
  cin>>x>>y;
  int a=x;
  int b=0;
  int ans=0;
  if(y%2==1)
  {
    cout<<"No"<<endl;
  }
  else
  {
    for(int i=0;i<=x;i++)
    {
      if((a*2+b*4)==y)
      {
        ans++;
        cout<<"Yes"<<endl;
        break;
      }
      a--;
      b++;
    } 
    if(ans==0)
    {
      cout<<"No"<<endl;
    }
  }
}

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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

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

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF   = 1e9;
const ll  INFLL = 1e18;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

int main()
{
    ios::sync_with_stdio(false);

    ll N, A, B;
    cin >> N >> A >> B;

    ll ans;

    if (A > B) {
        cout << 0 << endl;
        return 0;
    }

    if (N == 1) {
        ans = (A == B);
    } else {
        ans = (B - A) * (N - 2) + 1;
    }

    cout << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//using Graph = vector<vector<int>>;
using P = pair<int,pair<int,int>>;
//int dy[4] = {-1,0,1,0};
//int dx[4] = {0,-1,0,1};




int main()
{
    int K,A,B;
    cin >> K >> A >> B;
    
    
    int a = A / K;
    int b = B /K;
    if(A%K == 0 || a!= b)cout << "OK" << endl;
    else cout << "NG" << endl;
    
/*
 if(data[a] == data[b])
 {
 cout << "Yes" << endl;
 }
 else
 {
 cout << "No" << endl;
 }
 */

/*
 int main()
 {
 int N;
 cin >> N;
 
 
 return 0;
 }
 */

    /*
    int N,M,Q;
    cin >> N >> M >> Q;
    
    vector<int> data(N,-1);
    
    
    
    for(int i=0;i<Q;i++)
    {
        int a,b,c,d;
        cin >> a >> b >> c >> d;
        a--;
        b--;
        
        bool A = a==-1;
        bool B = b==-1;
        if(A&&B)
        {
            data[a] = 0;
            data[b] = c;
        }
        else if(A)
        {
            
        }
        else if(B)
        {
            
        }
        else
        {
            
        }
        
    }
    
    //sort(p.begin(),p.end());
    
    for(int i=0;i<Q;i++)
    {
        
    }
        
    */
    
    return 0;
}
/*
 if(data[a] == data[b])
 {
 cout << "Yes" << endl;
 }
 else
 {
 cout << "No" << endl;
 }
 */

/*
 int main()
 {
 int N;
 cin >> N;
 
 
 return 0;
 }
 */


Measured memory_bytes: 3568
import Data.List

type Point = (Integer, Integer)

windows :: Integer -> [a] -> [[a]]
windows k xs
    | length xs < fromIntegral k = []
    | otherwise = (take (fromIntegral k) xs) : windows k (tail xs)

minArea :: [Point] -> Integer -> (Integer, Integer) -> Integer
minArea points k (x1, x2) =
    let insidePoints = filter (\(x, _) -> x1 <= x && x <= x2) points
        sortedPoints = sortBy (\(_, y1) (_, y2) -> compare y1 y2) insidePoints
        groups = windows k sortedPoints
    in if null groups
       then 40000000000000000000
       else minimum $ map area groups
    where area ps = xDist * (yDist ps)
          xDist = x2 - x1
          yDist ps = (snd $ last ps) - (snd $ head ps)

solve :: [Point] -> Integer -> Integer
solve points k =
    let xs = sort $ map fst points
        pairs = [(x1, x2) | x1 <- xs, x2 <- xs, x1 < x2]
    in minimum $ map (minArea points k) pairs

makePoint :: [Integer] -> Point
makePoint (x:y:_) = (x, y)

readIntegers :: IO [Integer]
readIntegers = map read . words <$> getLine :: IO [Integer]

readPoint :: IO Point
readPoint = makePoint <$> readIntegers

readPoints :: Integer -> IO [Point]
readPoints n
    | n <= 0 = return []
    | otherwise = do
        currPoint <- makePoint <$> readIntegers
        otherPoints <- readPoints (n - 1)
        return (currPoint : otherPoints)

main = do
    [n, k] <- readIntegers
    points <- readPoints n
    putStrLn . show $ solve points k


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

typedef long long ll;
typedef unsigned long long ull;

int main(){
    int pn[25]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97};
    int N;
    int count[25]={0};
    cin >> N;
    for(int i=1;i<=N;i++){
        int j = i;
        for(int p=0;p<25;p++){
            while(j%pn[p]==0){
                count[p]++;
                j /= pn[p];
            }
        }
    }

    ll ans = 0;
    int ov[4]={0,0,0,0};
    for(int i=0;i<25;i++){
        if(count[i]>=74) ans++;
        if(count[i]>=24) ov[0]++;
        if(count[i]>=14) ov[1]++;
        if(count[i]>= 4) ov[2]++;
        if(count[i]>= 2) ov[3]++;
    }
    ans += ov[0]*(ov[3]-1);
    ans += ov[1]*(ov[2]-1);
    ans += ov[2]*(ov[2]-1)/2*(ov[3]-2);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
//#pragma GCC target("avx2")
//#pragma GCC optimization("O3")
//#pragma GCC optimization("unroll-loops")
//assert(q==w) если q!=w --> runtime error
#include <bits/stdc++.h>

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define ub upper_bound
#define lb lower_bound
#define bit __builtin_popcount
#define memset(x) memset(x,0,sizeof(x))

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<vector<int>> matrix;

inline void boost(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

const ll maxn=2e5+123;
const ll inf=1e9+123;
const ll linf=1e18+123;
const ll mod=1e9+7;
const double eps=1e-9;
const double pi=acos(-1);
int dx[8]={0,1,-1,0,1,-1,1,-1};
int dy[8]={1,0,0,-1,1,1,-1,-1};
int q[maxn];
int main(){
    boost();
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int n,k;
    cin>>n>>k;
    ll r,s,p;
    cin>>r>>s>>p;
    string t;
    cin>>t;
    ll ans=0;
    for(int i=0;i<n;i++){
        if(i>=k && t[i]==t[i-k]){
            q[i]=q[i-k]+1;
        }
        if(i>=k && t[i]==t[i-k] && q[i]%2==1){
            continue;
        }
        cerr<<i<<" "<<t[i]<<" ";
        if(t[i]=='r'){
            ans+=p;
            cerr<<p<<"\n";
        }
        if(t[i]=='s'){
            ans+=r;
            cerr<<r<<"\n";
        }
        if(t[i]=='p'){
            ans+=s;
            cerr<<s<<"\n";
        }
    }
    cout<<ans;
	exit(0);
}


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

int H, W;
int A[100][100], B[100][100], dif[100][100];

// dp[i][j][k]: マス(i,j)で偏りkが達成可能か
bool dp[100][100][15000];

int main(){
    cin >> H >> W;
    rep(i,H) rep(j,W) cin >> A[i][j];
    rep(i,H) rep(j,W) cin >> B[i][j];
    rep(i,H) rep(j,W) dif[i][j] = abs(A[i][j]-B[i][j]);

    dp[0][0][dif[0][0]] = true;

    rep(i,H) rep(j,W) {
        rep(k, 15000){
            if(dp[i][j][k]){
                dp[i+1][j][k+dif[i+1][j]] = true;
                dp[i+1][j][abs(k-dif[i+1][j])] = true;
                dp[i][j+1][k+dif[i][j+1]] = true;
                dp[i][j+1][abs(k-dif[i][j+1])] = true;
            }
        }
    }

   rep(k,15000){
       if(dp[H-1][W-1][k]){
           cout << k << endl;
           return 0;
       }
   }

}

Measured memory_bytes: 117888
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define fore(i,a,b) for(int i=a,thxicesi=b; i<thxicesi;i++)
#define FIN ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0)
#define sz(s) int(s.size())
using namespace std;

int main()
{FIN;
    string s; cin>>s;
    if(s == "ABC"){
        cout<<"ARC\n";
    }else{
        cout<<"ABC\n";
    }
    return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <utility>
#include <algorithm>

using namespace std;

typedef long long ll;

int main() {
		int N;
		ll K;
		cin >> N >> K;
		typedef pair<ll, ll> mp;
		mp x[N];
		for (int i = 0; i < N; i++) cin >> x[i].first >> x[i].second;
		sort(x, x+N, [](const mp& a, const mp& b) {
					return a.first < b.first;
		});

		ll t = 0;
		for (int i = 0; i < N; i++) {
				t += x[i].second;
				if (t >= K) {
						cout << x[i].first << endl;
						return 0;
				}
		}
		return 0;
}


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

const int MOD = 998244353;
const int MAXN = 200005;
const int MAX = 1000005;

long long modpow(long long a, long long p){
	if(p == 0)return 1;
	if(p % 2 == 1)return a * modpow(a, p - 1) % MOD;
	
	long long r = modpow(a, p / 2);
	return r * r % MOD;
}
long long modinv(long long a){
	return modpow(a, MOD - 2);
}

int N, A[MAXN], cnt[MAX];
long long d[MAX];

int main(){
	scanf("%d", &N);
	for(int i = 0; i < N; i++){
		scanf("%d", &A[i]);
		cnt[A[i]]++;
	}
	
	long long res = 0;
	
	for(int i = MAX - 1; i > 0; i--){
		long long s = 0;
		for(int j = i; j < MAX; j += i){
			long long z = 1LL * cnt[j] * (cnt[j] - 1) / 2 % MOD;
			d[i] = (d[i] + 1LL * j * j % MOD * z) % MOD;
			
			long long c = 1LL * j * cnt[j] % MOD;
			d[i] = (d[i] + s * c) % MOD;
			s = (s + c) % MOD;
		
			if(j > i)d[i] = (d[i] - d[j] + MOD) % MOD;
		}
		res = (res + d[i] * modinv(i)) % MOD;
	}
	
	printf("%lld\n", res);
	
	return 0;
}


Measured memory_bytes: 12800
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>

#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <numeric>

#define ll long long
#define ull unsigned long long
using _loop_int = int;
#define rep(i,n) for(_loop_int i=0;i<(_loop_int)(n);i++)
using namespace std;

using Graph = vector<vector<int>>;
Graph G;
int n, m;
int a, b;
vector<bool> seen;
bool check = true;
int ans = 0;
void dfs(const Graph & G, int v) {
	seen[v] = true;
	
	for(int i=1;i<=n;i++) {
		if (seen[i] == false) {
			check = false;
			break;
		}
	}
	if (check) ans++; 
	check = true;
	for (auto next_v : G[v]) {
		if (seen[next_v]) continue;
		dfs(G, next_v);
	}
	seen[v] = false;
}

int main() {
	
	cin >> n >> m;
	Graph G(n+1);
	for (int i = 0; i < m;i++) {
		cin >> a >> b;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	
	seen.assign(n+1, false);
	
	dfs(G, 1);
	
	cout<<ans<<endl;

	return 0;
}

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

int main() {
  int a, b;
  std::cin >> a >> b;
  int rep, val;
  if (a < b) {
    val = a;
    rep = b;
  } else {
    val = b;
    rep = a;
  }
  for (int i = 0; i < rep; ++i) {
    std::cout << val;
  }
  std::cout << std::endl;
  return 0;
}  


Measured memory_bytes: 256
# from math import factorial,sqrt
# from itertools import permutations as permus
# from fractions import gcd
# from collections import deque,Counter
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import scipy as scp

# 入力の受け取り
n = int(input())
# 列ベクトルとかの受け取り
lists = [int(input()) for _ in range(n)]

ans = 0
btn = 1
if not 2 in lists:
    ans = -1
else:
    while ans <=n:
        if lists[btn-1]==2:
            ans +=1
            break
        else:
            btn = lists[btn-1]
            ans +=1
            continue
    else:
        ans = -1

print(ans)
# print("{:.10f}".format(ans))


Measured memory_bytes: 7084
#include <iostream>

using namespace std;

int main() {
  long long ans = 0;
  int N; cin >> N;
  for(int i = 1; i <= N; i++) {
    if(i % 3 == 0 || i % 5 == 0) continue;
    ans += i;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long long unsigned int llu;
#define pb push_back
#define PI 3.1415926535897932384626433832795
#define mod 1000000007
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()
#define YUGEN ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define lp(i,start,end) for(int i=start;i<end;i++)
#define MAX 105
#define BPC(x)  __builtin_popcountll(x)
#define test() ll t; cin>>t; while(t--)
#define gcd(a,b)  __gcd(a,b)
#define SIZE 26
ll gcd(ll a,ll b) {if (a==0) return b;return gcd(b%a,a);}

int main()
 {
    YUGEN;
    ll n;
    cin>>n;
    int ans=0;
    for(int i=1;i<n;i++)
    {
      ans+=(n-1)/i;
    }
    cout<<ans;
    

 }




Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define endl '\n'

using namespace std;
struct custom_hash 
{
    static unsigned long long splitmix64(unsigned long long x) 
    {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(unsigned long long x) const 
    {
        static const unsigned long long FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
mt19937 random_generator(chrono::steady_clock::now().time_since_epoch().count());

struct edge
{
	int to, cost, len;
	edge() {}
	edge(int _to, int _cost, int _len)
	{
		to = _to;
		cost = _cost;
		len = _len;
	}
};

int n, m, s; 
vector <edge> adj[53];
pair <int, int> a[53];
void read()
{
	cin >> n >> m >> s;
	for (int i = 1; i <= m; i++)
	{
		int a, b, c, d;
		cin >> a >> b >> c >> d; 
		adj[a].push_back(edge(b, c, d));
		adj[b].push_back(edge(a, c, d));
	}
	
	for (int i = 1; i <= n; i++)
	cin >> a[i].first >> a[i].second;
}

struct edge1
{
	int city, coins, len;
	edge1() {}
	edge1(int _city, int _coins, int _len)
	{
		city = _city;
		coins = _coins;
		len = _len; 
	}	
};

long long inf = 1e18; 

vector <edge1> adj1[53][103*50];
long long dist[53][103*50];
void dijkstra()
{
	for (int i = 1; i <= n; i++)
	for (int j = 0; j <= m * 50; j++)
	dist[i][j] = inf;
	
	dist[1][min(m*50, s)] = 0; 
    priority_queue <pair <long long, pair <int, int> > > q;
    q.push({0, {1, min(m*50, s)}});
    while (!q.empty())
    {
		auto curr = q.top();
		q.pop();
	 
		if (dist[curr.second.first][curr.second.second] != -curr.first)
		continue;
		
		for (auto i: adj1[curr.second.first][curr.second.second])
		if (-curr.first + i.len < dist[i.city][i.coins])
		{
			dist[i.city][i.coins] = i.len - curr.first;
			q.push({-dist[i.city][i.coins], {i.city, i.coins}});
		}
	}
}

void solve()
{
	for (int i = 1; i <= n; i++)
	for (int j = 0; j <= m * 50; j++)
	{
		for (auto k: adj[i])
		if (k.cost <= j)
		adj1[i][j].push_back(edge1(k.to, j - k.cost, k.len));
		
		adj1[i][j].push_back(edge1(i, min(j + a[i].first, m * 50), a[i].second));
	}
	
	dijkstra();
	for (int i = 2; i <= n; i++)
	{
		long long ans = inf;
		for (int j = 0; j <= m * 50; j++)
		ans = min(ans, dist[i][j]);
		
		cout << ans << endl;
	}
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	
	read();
	solve();
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define mod 998244353LL
#define IN freopen("C.in","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define INF 1000000000000000000LL
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 17
#define off (4*n)


using namespace __gnu_pbds;
using namespace std ;

typedef pair<int, int> pi ;
typedef tree< pi, null_type, less<pi>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define maxn 1000005

/*
     *os.find_by_order(k) -> returns the k'th smallest element (indexing starts from 0)
      os.order_of_key(v)  -> returns how many elements are strictly smaller than v
*/


int main()
{
    int n , k ;

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

    k-- ;

    if( k > (n-1)/2 )
    {
        printf("-1\n") ;
        return 0 ;
    }

    vector < tuple<int,int,int> > vp ;

    for(int i=n/2 + 1 , j=1 , l= 2*n + 1  ; i<=n ; i++,j++,l+=2)
    {
        vp.pb( make_tuple( i , n+j , l  ) ) ;
    }

    for(int i=1 , j= (n+1)/2+1 , l= 2*n+2 ; i <= n/2 ; i++,j++,l+=2)
    {
        vp.pb( make_tuple( i , j+n , l ) ) ;
    }

    sort( vp.begin() , vp.end() ) ;

    for( auto v: vp ) printf("%d %d %d\n" , get<0>(v)+k , get<1>(v)+k , get<2>(v)+k ) ;

    return 0 ;
}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll one = 1;
const ll INF = 9223372036854775807; //10^18
const int inINF = 2147483647; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
    int A, B;
    cin >> A >> B;
    vector<vector<char>> S(100, vector<char> (100, '#'));
    for (int i = 50; i < 100; i++) {
        for (int j = 0; j < 100; j++) {
            S[i][j] = '.';
        }
    }
    A--; B--;
    for (int i = 0; i < A; i++) {
        S[(i / 50) * 2][(i % 50) * 2] = '.';
    }
    for (int i = 0; i < B; i++) {
        S[51 + (i / 50) * 2][(i % 50) * 2] = '#';
    }
    printf("100 100\n");
    for (int i = 0; i < 100; i++) {
        for (int j = 0; j < 100; j++) {
            printf("%c", S[i][j]);
        }
        cout << endl;
    }

}

Measured memory_bytes: 3580
#include <stdio.h>

int main(void) {
  char O[51];
  char E[51];
  scanf("%s", O);
  scanf("%s", E);
  int src = 0;
  while(O[src] != '\0' && E[src] != '\0') {
    printf("%c%c", O[src], E[src]);
    src++;
  }
  if(O[src] != '\0')
    printf("%c\n", O[src]);
  else
    printf("\n");
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>

struct Node {
    int key;
    Node *p, *l, *r;
};

Node *root;

void Preorder(Node *root) {
    if (root == nullptr) {
        return;
    }
    std::cout << " " << root->key;
    Preorder(root->l);
    Preorder(root->r);

}

void Inorder(Node *root) {
    if (root == nullptr) {
        return;
    }
    Inorder(root->l);
    std::cout << " " << root->key;
    Inorder(root->r);

}


void Insert(Node* tgt) {
    Node *p = nullptr, *c = root;
    while (c != nullptr) {
        p = c;
        if (tgt->key < c->key) {
            c = c->l;
        }else{
            c = c->r;
        }
    }
    tgt->p = p;
    if (p == nullptr) {
        root = tgt;
    }else if(tgt->key < p->key) {
        p->l = tgt;
    }else{
        p->r = tgt;
    }
}

int main() {
    int n;
    std::cin >> n;
    std::vector<Node> T;
    T.reserve(n * 2);
    int c = 0;
    for (int i = 0; i < n; i++) {
        std::string s;
        int key;
        std::cin >> s;
        if (s == "print") {
            Inorder(root);
            std::cout << std::endl;
            Preorder(root);
            std::cout << std::endl;
            continue;
        }
        std::cin >> key;
        T.emplace_back(Node{0, nullptr, nullptr, nullptr});
        T[c].key = key;
        Insert(&T[c]);
        c++;
    }
    return 0;
}


Measured memory_bytes: 18504
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll LINF = 1000000000000000000; //1e18
const double EPS = 1e-10;            //

/*
1 0 = 2
2 0 = 3
3 0 = 4
1 1 = 4 = 2 * 2
1 2 = 6 2 * 3
2 2 = 9 3 * 3
3 3 = 
 */

int main(void)
{
    int n, m;
    cin >> n >> m;

    int ans = (n - 1) * (m - 1);
    cout << ans << endl;
    return (0);
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int r, g, b;
	while (cin >> r >> g >> b)
	{
		int num = r * 100 + g * 10 + b;
		if (num % 4 == 0)
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <cstdlib>
#include <sstream>
#include <bitset>
using namespace std;

typedef long long ll;

int main()
{
    int M,D;
    cin >> M >> D;
    int ans=0;
    for(int m=1; m<=M; m++){
        for(int d=1; d<=D; d++){
            int d1=d%10;
            int d2=d/10;
            if(d1>=2 && d2>=2 && d1*d2==m) ans++;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
//ABC066C
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
#include <unordered_map>
using namespace std;

int main(){
	int n;
	cin >> n;
	vector<long long int> a(n), ans(n);
	for(int i=0;i<n;i++){
		cin >> a.at(i);
	}
	if(n%2 ==  0){
		int p = n/2, d = 0;
		for(int i=0;i<n;i++){
			p += d;
			ans.at(p) = a.at(i);
			d *= -1;
			d += pow(-1,i+1);
		}
		for(int i=0;i<n;i++){
			cout << ans.at(i) << " ";
		}
	}else{
		int p = n/2, d = 0;
		for(int i=0;i<n;i++){
			p += d;
			ans.at(p) = a.at(i);
			d *= -1;
			d += pow(-1,i);
		}
		for(int i=0;i<n;i++){
			cout << ans.at(i) << " ";
		}
	}
}

Measured memory_bytes: 5248
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define pb push_back
#define INF 0x3f3f3f3
#define LINF 0x3f3f3f3f3f3f3f
#define MAXN int(2*1e5)+5
#define fim '\n'
#define ll long long
#define f first
#define s second
#define FAST cin.tie(0), cout.tie(0), ios::sync_with_stdio(0)
#define debug(x) cout << "DEBUG " << x << fim
#define debug2(x, y) cout << "DEBUG " << x << " " << y << fim
#define debug3(x, y, z) cout << "DEBUG " << x << " " << y << " " << z<< fim
#define debug4(x, y, z, o) cout << "DEBUG " << x << " " << y << " " << z<< " " << o << fim
#define max3(x, y, z) max(x, max(y, z))
#define ull unsigned long long
using namespace std;
using namespace __gnu_pbds;
typedef pair<int, int> pii;
typedef pair<string, int> psi;
typedef pair<unsigned ll, pair<int, int> > piii;
typedef pair<pair<int, int>, int> piii2;
typedef tree<int,null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> indexed_set;
const ll MOD = 1e9+7;

using namespace std;

int main() {
    int n;
    cin >> n;
    string v;
    cin >> v;

    int sum[4][n+5];
    memset(sum, 0, sizeof sum);
    for(int i = 0; i < n; i++) {
        if(i) {
            sum[0][i] += sum[0][i-1];
            sum[1][i] += sum[1][i-1];
            sum[2][i] += sum[2][i-1];
        }
        if(v[i] == 'R') {
            v[i] = 0;
            sum[0][i]++;
        }
        if(v[i] == 'G') {
           v[i] = 1;
           sum[1][i]++;
        }
        if(v[i] == 'B'){
         v[i] = 2;
         sum[2][i]++;
        }
    }

    ll ans = 0;
    for(int i = 0; i < n; i++)
        for(int j = i+1; j < n-1; j++) {
            if(v[i] == v[j])
                continue;
            for(int k = 0; k < 3; k++) {

                if(k == v[i] or k == v[j])
                    continue;

                ans += sum[k][n-1]-sum[k][j];



                if(j+(j-i) < n && v[j+(j-i)] == k)
                    ans--;

               // debug3(i, j, ans);
            }


        }
    cout << ans << endl;
}


Measured memory_bytes: 3628
w,h,n = map(int,input().split())

a1 = 0
a2 = w
a3 = 0
a4 = h
for _ in range(n):
   x,y,a = map(int,input().split())
   if a == 1:
      a1 = max(a1, x)
   if a == 2:
      a2 = min(a2, x)
   if a == 3:
      a3 = max(a3, y)
   if a == 4:
      a4 = min(a4, y)
a5 = max(a2 - a1, 0)
a6 = max(a4 -a3, 0)
print(a5*a6)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin>>n;
	int a[n],b[n],c[n],i;
	for(i=0;i<n;i++)
	{
		cin>>a[i]>>b[i]>>c[i];
	}
	int dp1[n],dp2[n],dp3[n];
	dp1[0]=a[0];
	dp2[0]=b[0];
	dp3[0]=c[0];
	for(i=1;i<n;i++)
	{
		dp1[i]=max(dp2[i-1],dp3[i-1])+a[i];
		dp2[i]=max(dp1[i-1],dp3[i-1])+b[i];
		dp3[i]=max(dp1[i-1],dp2[i-1])+c[i];
	}
	cout<<max(dp2[n-1],max(dp1[n-1],dp3[n-1]));
	return 0;
}

Measured memory_bytes: 5920
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    string s;
    cin >> s;
    if (s[2] == s[3] && s[4] == s[5]) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<functional>
#include <random>
#include<iostream>
#include<iomanip>
using namespace std;


int main() {
	long long N, K;

	cin >> N >> K;
	
	long long ans = N % K;
	if (ans > K - ans) { ans = K - ans; }
	cout << ans;
}

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

using namespace std;

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

int main(){
  long long n;
  long long i;
  cin>>n;
  for(i=1;i*i<=n;i++);
  cout<<(i-1)*(i-1)<<endl;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.util.Map.Entry;


public class  Main{
	static char[]in;
	static long [][]memo;
	static long dp(int i,int carry) {
		if(i<0) {
			return carry;
		}
		if(memo[i][carry]!=-1)return memo[i][carry];
		
		int x=(in[i]-'0');
		x+=carry;
		int newc=x/10;
		x=x%10;
		//System.out.println(x+" "+newc);
		return memo[i][carry]=Math.min(dp(i-1,newc)+x, x==0?(long)1e15:dp(i-1,newc+1)+10-x);
	}
	public static void main(String[] args) throws Exception{
		MScanner sc=new MScanner(System.in);
		PrintWriter pw=new PrintWriter(System.out);
		in=sc.nextLine().toCharArray();
		memo=new long[in.length][2];
		for(long[]i:memo)Arrays.fill(i, -1);
		for(int i=0;i<in.length;i++) {
			for(int carry=0;carry<2;carry++) {
				int x=(in[i]-'0');
				x+=carry;
				int newc=x/10;
				x=x%10;
				//System.out.println(x+" "+newc);
				long opt1=(i-1<0?newc:memo[i-1][newc])+x;
				long opt2=newc==1?(long)1e15:((i-1<0?newc+1:memo[i-1][newc+1])+10-x);
				memo[i][carry]=Math.min(opt1, opt2);
				
			}
		}
		
		pw.println(dp(in.length-1,0));
		pw.flush();
	}
	static class MScanner {
		StringTokenizer st;
		BufferedReader br;
		public MScanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}
 
		public MScanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}
 
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int[] takearr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public long[] takearrl(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public Integer[] takearrobj(int n) throws IOException {
	        Integer[]in=new Integer[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public Long[] takearrlobj(int n) throws IOException {
	        Long[]in=new Long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public String nextLine() throws IOException {
			return br.readLine();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public char nextChar() throws IOException {
			return next().charAt(0);
		}
 
		public Long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public boolean ready() throws IOException {
			return br.ready();
		}
 
		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}

Measured memory_bytes: 71052
#!/usr/bin/env python3
import sys

def solve(N: int, A: "List[int]"):
    minus_count = 0
    
    for i in range(N):
        if A[i] < 0:
            minus_count += 1

    if minus_count % 2 == 0:
        result = sum([abs(x) for x in A])
    else:
        min_A = 10000000
        min_idx = -1
        for i, x in enumerate(A):
            if abs(x) < min_A:
                min_A = abs(x)
                min_idx = i
        result = 0
        for i, x in enumerate(A):
            if i == min_idx:
                result += abs(x) * -1
            else:
                result += abs(x)
    print(result)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


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

using namespace std;


int main()
{
    int a = 0;
    int b = 0;
    int sum = 0;
    int digit = 0;
    
    while (cin >> a >> b)
    {
        sum = a + b;
        digit = 0;
        while (sum)
        {
            digit++;
            sum /= 10;
        }
        
        cout << digit << endl;
    }
    
    return 0;
}



Measured memory_bytes: 3080
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
use std::io::*;
use std::str::FromStr;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);

impl<T: PartialEq> Eq for Total<T> {}

impl<T: PartialOrd> Ord for Total<T> {
    fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering {
        self.0.partial_cmp(&other.0).unwrap()
    }
}

//const MAX:usize = 100006;
//const INF:u64 = u64::max_value();

fn main() {
    let n:i32 = read();
    let k:i32 = read();

    println!("{}", if (n+1)/2 >= k {"YES"} else {"NO"});

}


Measured memory_bytes: 4352
// C++ 14
#include <bits/stdc++.h>
using namespace std;
template <typename T>  ostream& operator<<(ostream& os, const vector<T>& v)  {  os << "[";  for (int i = 0; i < v.size(); ++i) {  os << v[i];  if (i != v.size() - 1)  os << ", ";  }  os << "]";  return os;  }
template <typename T> void print(T v, string s = "\n") { cout << v << s; }
template <typename T> void in(T& v) { cin >> v; }
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

bool check(vector<int> &F, int tx) {
  int n = F.size();
  set<int> S;
  S.insert(0);
  loop(i,0,n) {
    int d = F[i];
    set<int> NEW;
    for (auto&&s: S) {
      NEW.insert(s+d);
      NEW.insert(s-d);
    }
    
    S = NEW;
  }
  
  return S.count(tx);
}

int main() {
  string s;
  in(s);
  int tgt_x, tgt_y;
  in(tgt_x); in(tgt_y);
  int n = s.size();
  int cnt = 0;
  vector<int> F;
  loop(i,0,n) {
    if (s[i] == 'F') cnt++;
    else {
      F.push_back(cnt);
      cnt = 0;
    }
  }
  F.push_back(cnt);
  tgt_x -= F[0];
  vector<int> Fx, Fy;
  n = F.size();
  loop(i,0,n) {
    if (i==0) continue;
    if (i%2==0) Fx.push_back(F[i]);
    else Fy.push_back(F[i]);
  }
  
  if (check(Fx, tgt_x) and check(Fy, tgt_y)) print("Yes");
  else print("No");
  return 0;
}


Measured memory_bytes: 3968
macro_rules! scan_sub {
    ( $itr:ident, $t:ty ) => {
        let mut buf = String::new();
        let $itr = {
            while buf.trim().len() == 0 {
                buf = String::new();
                std::io::stdin().read_line(&mut buf).unwrap();
            }
            buf.split_whitespace().map(|n| n.parse::<$t>().unwrap())
        };
    };
}

macro_rules! scan {
    ( $x:ident; Vec<$t:ty> ) => {
        scan_sub!(itr, $t);
        let $x = itr.collect::<Vec<_>>();
    };
    ( $( $x:ident ),*; $t:ty ) => {
        scan_sub!(itr, $t);
        let mut itr = itr;
        $(
            let $x = itr.next().unwrap();
        )*
    };
}

fn main() {
    scan!(n; usize);
    scan!(s; String);

    let mut ans = 0;
    for i in 0..n-2 {
        if &s[i..i+3] == "ABC" { ans += 1; }
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int y=1,len=s.length(),i,j=len-1;
	for(i=0;i<len;i++,j--){
		if(s[i]!=s[j]){
          	y=0;
			break;
		}
	}
		int n=(len-1)/2;
		j=n-1;
		for(i=0;i<n;i++,j--){
			if(s[i]!=s[j]){
				y=0;
				break;
			}	
		}
		n=(len+3)/2-1;
		j=len-1;
		for(i=n;i<len;i++,j--){
			if(s[i]!=s[j]){
				y=0;
				break;
			}
		}
	if(y==0){
		cout<<"No"<<endl;
	}
	else{
		cout<<"Yes"<<endl;
	}
	return 0;
}

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

 int ara[1000002];

using namespace std;

int main(){
    int n; cin >> n;
    for(int i=0; i<n; i++) cin>>ara[i];
    int count =0;
    int ans = 0;
    for(int i=0; i<n-1; i++){
        if (ara[i]>=ara[i+1])  count++;
        else count=0;
        ans = max(ans, count);
    }
    cout <<ans<<endl;
}


Measured memory_bytes: 640
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		//入力値取得
		int N = scan.nextInt();

		int[] array = new int[N];

		for (int i = 0; i < N; i++) {
			array[i] = scan.nextInt();
		}

		Arrays.sort(array);

		//演算
		int result = 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 (array[i] + array[j] > array[k] && array[i] != array[j] && array[j] != array[k]) {
						result++;
					}
				}
			}
		}

		//結果出力
			System.out.println(result);
	}
}


Measured memory_bytes: 36556
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  int n;
  scanf("%d", &n);
  vector< vector<int> > abc(n, vector<int>(3));
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < 3; ++j) {
      scanf("%d", &abc[i][j]);
    }
  }

  int dp[n + 1][3];
  memset(dp, 0, sizeof(dp));

  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < 3; ++j) {
      for (int k = 0; k < 3; ++k) {
	if (k != j) {
	  dp[i + 1][j] = max(dp[i + 1][j], dp[i][k] + abc[i][j]);
	}
      }
    }
  }

  int ans = 0;
  for (int i = 0; i < 3; ++i) {
    ans = max(ans, dp[n][i]);
  }

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


Measured memory_bytes: 6912
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <set>
#include <queue>
#include <cctype>
#include <climits>
#include <stack>
using namespace std;
  
 
  
int main(){
  
    int n; 
    while(scanf("%d",&n),n){
 
        vector<pair<int,int> > rw(n);
        int sum_r=0,sum_w=0;
        for(int i=0;i<n;i++){
            cin>>rw[i].first>>rw[i].second;
            sum_r+=rw[i].first;
            sum_w+=rw[i].second;
        }
        sort(rw.begin(),rw.end(),greater< pair<int,int> >());
 
        int r0=rw[0].first;
        int r=sum_r-r0;
 
        if(r0 <= r){
            cout<<sum_r+sum_w<<endl;
        }else{
 
            int res=2*rw[0].first;
            vector<vector<bool> > dp(1001,vector<bool>(1000,false));
 
            dp[1][0]=true;
            for(int i=1;i<n;i++){
                for(int j=0;j<=1000;j++){
                    if(dp[i][j]){
                        dp[i+1][j]=true; 
                        if(j+rw[i].second<=1000)
                            dp[i+1][j+rw[i].second]=true; 
                    }
                }
            }
 
            int opt=0;
            for(int i=1;i<=r0-r;i++){
                if(dp[n][i]) opt=i;
            }
 
            res+=sum_w-opt;
            cout<<res<<endl;
 
 
 
        }
         
         
    }
}

Measured memory_bytes: 3340
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <bits/stdc++.h> 

using namespace std;

int main(){
    int N;
    cin>>N;
    int P[N],Q[N];
    for (int i=0;i<N;i++) cin>>P[i];
    for (int i=0;i<N;i++) cin>>Q[i];
    int X[N];
    for (int i=0;i<N;i++) X[i]=i+1;
    int n=1,a=0,b=0;
    bool flagP=true,flagQ=true;
    while((flagP||flagQ)&&n<1000000){
        if (flagP){
            for (int i=0;i<N;i++){
                if (X[i]!=P[i])  break;
                if (i==N-1){
                    flagP=false;
                    a=n;
                }
            }
        }
        if (flagQ){
            for (int i=0;i<N;i++){
                if (X[i]!=Q[i])  break;
                if (i==N-1){
                    flagQ=false;
                    b=n;
                }
            }
        }
        if (X[N-2]<X[N-1])swap(X[N-2],X[N-1]);
        else{
            for (int i=N-2;i>0;i--){
                int k=0;
                if (X[i-1]<X[i]){
                    for (int j=N-1;j>i-1;j--){
                        if (X[j]>X[i-1]){
                            k=j;
                            break;
                        }
                    }
                    swap(X[i-1],X[k]);
                    int d[N];
                    for (int j=0;j<N-i;j++)  d[j]=X[i+j];
                    for (int j=i;j<N;j++) X[j]=d[N-j-1];
                    break;
                }
            }
        }
        n++;
    }
    cout<<abs(a-b)<<endl;
    //cout<<a<<" "<<b<<" "<<n<<endl;
    return 0;
}

Measured memory_bytes: 3636
#include<stdio.h>
int main(void){
int A,B,i,sum=0;
  scanf("%d %d",&A,&B);
  for(i=0;i<2;i++){
    if(A>=B){
      sum+=A;
      A--;
    }
    else{
      sum+=B;
      B--;
    }
  }
  printf("%d",sum);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
const ll INF = 1e18;
/* テンプレートここまで */


int main() {
  ll a,b,c,d; cin >> a >> b >> c >> d;
  ll l = a+b;
  ll r = c+d;
  if(l==r) cout << "Balanced" << endl;
  else if (l>r) cout << "Left" << endl;
  else cout << "Right" << endl;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!
cnt = 0
s = input()
if s[0]=="A" and "C" in s[2:-1]:
    for i in s:
        if "A" <= i <= "Z":
            cnt +=1
    if cnt == 2:
        print("AC")
    else:
        print("WA")
else:
    print("WA")

Measured memory_bytes: 3188
n,k=map(int,input().split())
a=input()
ac=[0]*n
x=0
for i in range(n-1):
    if a[i]=='A' and a[i+1]=='C':
        x+=1
    ac[i+1]=x
ac[-1]=x
for i in range(k):
    l,r=map(int,input().split())
    print(ac[r-1]-ac[l-1])

Measured memory_bytes: 6060
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;

namespace codeTester.contest190810
{
    class ModelAnswerC
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine();
            int n = int.Parse(input);
            var hash = new Dictionary<string, int>();
            long ans = 0;

            for (int i = 0; i < n; i++)
            {
                var input2 = Console.ReadLine();
                char[] chars = input2.ToCharArray();
                Array.Sort(chars);
                string sorted = new string(chars);
                if (hash.ContainsKey(sorted))
                {
                    ans += hash[sorted];
                    hash[sorted]++;
                }
                else
                {
                    hash.Add(sorted, 1);
                }
            }

            Console.WriteLine(ans);
        }
    }
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;

#define sync std::ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define loopi(n) for(int i=0;i<n;i++)
#define loopj(n) for(int j=0;j<n;j++)
#define loop(a,b,c) for(int i=a;i<=b;i=i+c)

#define     deb(x)      cout<<#x<<"="<<x<<endl
#define     all(x)      (x).begin(),(x).end()
#define     reset(a)    memset(a,0,sizeof(a))
#define     sz(x)       ((int)(x.size()))
#define     pb          push_back
#define     pf          push_front
#define     pob	        pop_back
#define     pof         pop_front
#define     ins         insert
#define     F           first
#define     S           second
#define     mkp         make_pair
#define     mkt         make_tuple
#define     bitcount(x) __builtin_popcountll(x)
#define     gcd(a,b)    (__gcd(a,b))
#define     lcm(a,b)    ((a*b)/gcd(a,b))
#define PI 3.1415926535897932384626
 
const int mod = 1e9+7;
const int N = 1e5+5;

//==========================================//

void solve()
{
	int n;
	cin>>n;
	int a[n];
	loopi(n)	cin>>a[i];
	
	int x=a[0];
	ll ans=0;
	loop(1,n-1,1)
	{
		x=max(x,a[i]);
		ans=ans+(x-a[i]);
	}
	cout<<ans;
}
int main()
{
	sync;

	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
		cout<<endl;
	}
}


Measured memory_bytes: 4396
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int x,t;
  cin>>x>>t;
  cout<<max(x-t,0)<<endl;
}

Measured memory_bytes: 256
import sys
import numpy as np
import random
from decimal import Decimal
import itertools
import re
import bisect
from collections import deque, Counter
from functools import lru_cache

sys.setrecursionlimit(10**9)
INF = 10**13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
def SERIES(n): return np.fromstring(sys.stdin.buffer.read(), dtype=np.int32, sep=' ')
def GRID(h,w): return np.fromstring(sys.stdin.buffer.read(), dtype=np.int32, sep=' ').reshape(h,-1)[:,:w]
def GRIDfromString(h,w): return np.frombuffer(sys.stdin.buffer.read(), 'S1').reshape(h,-1)[:,:w]
MOD = 1000000007



def main():
	h, w, a, b = LI()

	def comb(n, r, p):
		if (r < 0) or (n < r):
			return 0
		r = min(r, n - r)
		return fact[n] * factinv[r] * factinv[n-r] % p


	p = 10 ** 9 + 7
	N = 10 ** 5 * 2
	fact = [1, 1]
	factinv = [1, 1]
	inv = [0, 1]

	for i in range(2, N + 1):
		fact.append((fact[-1] * i) % p)
		inv.append((-inv[p % i] * (p // i)) % p)
		factinv.append((factinv[-1]) * inv[-1] % p)

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


if __name__ == '__main__':
    main()

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

const int INF = 1e9+7;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)


int main() {
	int n,m;
	cin >> n >> m;
	if(n < m){
		rep(i, m) cout << n;
		cout << endl;
	}else{
		rep(i, n) cout << m;
		cout << endl;
	}

}

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

int N;
int main(){
	scanf("%d", &N);
	if (N == 1) {
		printf("Hello World\n");
	} else {
		int a, b;
		scanf("%d %d", &a, &b);
		printf("%d\n", a + b);
	}
	return 0;
}

Measured memory_bytes: 256
t1,t2=map(int,input().split())

a1,a2=map(int,input().split())
b1,b2=map(int,input().split())

a=a1-b1
b=a2-b2
#print(a,b)

ans=0

if(a*b>0):
    ans=-1
else:
    go=a*t1+b*t2
    if(go*a>0):
        ans=0
    elif(go==0):
        ans=-10
    else:
        kai=a*t1
        if(go<0):
            go*=-1
        if(kai<0):
            kai*=-1
        #print(kai//go)
        if(kai%go==0):
            ans=(kai//go)*2
        else:
            ans=(kai//go)*2+1

if(ans==-1):
    print(0)
elif(ans==-10):
    print("infinity")
else:
    print(ans)

Measured memory_bytes: 3192