akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstdint>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <utility>
#include <limits>
#include <list>
#include <type_traits>

/* template start */
 
#define rep(i, a, b) for (long long i = (a); (i) < (b); (i)++)
#define all(i) i.begin(), i.end()

#ifdef LOCAL
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  if(sizeof...(t)>0)std::cout<<" :";
  debug_out(t...);
}
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}

template<typename Num>
constexpr Num mypow(Num a, long long b) {
  if(b==0)return 1;
  if (a==0)return 0;
  Num x = 1;
  while (b > 0) {
    if(b & 1)x*=a;
    a*=a;
    b >>= 1;
  }
  return x;
}

/* template end */

using ll=long long;
using i64=std::int_fast64_t;
using u64=std::uint_fast64_t;

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

  ll n,k;
  std::cin>>n>>k;

  std::set<ll> hate;
  rep(i,0,k){
    ll d;
    std::cin>>d;
    hate.emplace(d);
  }

  rep(i,n,1000*n){
    ll num=i;
    bool isok=true;
    while(num>0&&isok){
      ll digit=num%10;
      num/=10;
      if(hate.find(digit)!=hate.end())isok=false;
    }
    if(isok){
      std::cout<<i<<"\n";
      return 0;
    }
  }
  
  return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

typedef long long ll;

struct q
{
	ll t,a,b;
};

vector <q> query;
vector <ll> cor;

ll segTree[200010];
void update(int i, ll v)
{
	while (i <= 200001)
	{
		segTree[i] += v;
		i += i & -i;
	}
}

ll getVal(int i)
{
	ll res = 0;
	while (i)
	{
		res += segTree[i];
		i -= i & -i;
	}
	return res;
}

ll getVal(int i, int j)
{
	return getVal(j) - getVal(i - 1);
}

int sz = 447;
int cnt[250001];
int bucket[448];

int getIndex(ll a)
{
	return lower_bound(cor.begin(),cor.end(),a) - cor.begin();
}

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

	//freopen("in/random_small_01", "r", stdin);
	int Q; cin >> Q;
	while (Q--)
	{
		q cq;
		cin >> cq.t;
		if (cq.t == 1)
		{
			cin >> cq.a >> cq.b;
			cor.push_back(cq.a);
		}
		
		query.push_back(cq);
	}

	sort(cor.begin(), cor.end());
	cor.erase(unique(cor.begin(), cor.end()), cor.end());

	int csz = 0;
	ll curB = 0;
	for (int i = 0; i < query.size(); i++)
	{
		if (query[i].t == 1)
		{
			ll idx = getIndex(query[i].a)+1;
			update(idx, query[i].a);

			cnt[idx]++;
			bucket[idx / sz]++;

			curB += query[i].b;
			csz++;
		}
		else
		{
			int k = csz / 2 + 1;

			int cSum = 0;

			int j = 447;
			for (; j >= 0; j--)
			{
				if (cSum + bucket[j] >= k) break;
				cSum += bucket[j];
			}

			int i = (j + 1)*sz - 1;
			for (; i >= 0; i--)
			{
				if (cSum + cnt[i] >= k) break;
				cSum += cnt[i];
			}

			ll x = cor[i - 1];

			cSum += cnt[i];
			ll lsum = getVal(1, i - 1);
			lsum = (csz-cSum) * x - lsum;

			ll rsum = getVal(i , 200001);
			rsum -= cSum * x;

			ll fx = lsum + rsum + curB;

			cout << x << ' ' << fx << '\n';
		}
	}
}

Measured memory_bytes: 11436
#include <bits/stdc++.h>
#define INF LLONG_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(int i=0; i<n; ++i)
#define MOD 1000000007
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if(a>b) {a=b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if(a<b) {a=b; return true;} return false;}

int main() {
  int N; cin >> N;
  vector<vector<int>> A(2, vector<int>(N));
  rep(i, 2) {
    rep(j, N) cin >> A[i][j];
  }
  int ans = 0;
  rep(n, N){
    int tmp = 0;
    for(int i=0; i<=n; ++i) { tmp += A[0][i]; }
    for(int i=n; i<N; ++i) { tmp += A[1][i]; }
    chmax(ans, tmp);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		String a = sc.next(), b = sc.next();
		if(a.length() < b.length())System.out.print("LESS");
		else if(a.length() > b.length())System.out.print("GREATER");
		else if(a.compareTo(b)<0)System.out.print("LESS");
		else if(a.compareTo(b)>0)System.out.print("GREATER");
		else System.out.print("EQUAL");
	}

}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  int N;
  cin>>N;
  cout<<180*(N-2)<<endl;
  return 0;
}


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

using namespace std;
using ull = unsigned long long;
using ll = long long;
using lli = long long int;
using ld = long double;
using pa = pair<int,int>;
using ppa = pair<pa,int>;
#define SORT(v, n) sort(v, v+n);
#define ALL(v) v.begin(),v.end()
#define VSORT(v) sort(ALL(v))
#define GRESORT(v) sort(ALL(v),greater<ll>())
#define REVERSE(v) reverse(ALL(v))
#define overlap(v) v.erase(unique(ALL(v)),v.end())
#define debug(x) cout << #x << ": " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i = (b-1); i >= a; i--)
#define rrep(i,n) RFOR(i,0,n)
#define INF 999999999
#define mins(a,b) a = min(a,b)
#define maxs(a,b) a = max(a,b)

//4近傍
//int dy[]={0, 0, 1, -1};
//int dx[]={1, -1, 0, 0};

//8近傍
int dy[]={0,0,1,-1,1,1,-1,-1};
int dx[]={1,-1,0,0,1,-1,1,-1};

ll mod = 1000000007;

void solve() {
    string s; cin >> s;
    int n = s.size();
    ll ans = 0;
    rep(i,1 << (n - 1)) {
        string t;
        rep(j, n) {
            t += s[j];
            if (i & (1 << j)) {
                t += ' ';
            }
        }

        istringstream is(t);
        ll sum = 0;
        ll cur;
        while(is >> cur){
            sum += cur;
        }
        //debug(sum);
        ans += sum;
    }
    cout << ans << endl;
}

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

    solve();

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(void){
	string o, e, p;
	cin >> o >> e;
	for(int i = 0; i < o.size(); i++){
		p += o[i];
		if(i < e.size()){
			p += e[i];
		}
	}
	cout << p << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  for(int i=1; i<=9; i++) {
    for(int j=1; j<=9; j++) {
      if(i*j == n) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
typedef long long lint;

int main(){
    double a,b,c,d;
    cin>>a>>b>>c>>d;
    if(c==a/2 && d==b/2){
        cout<<(a*b/2)<<" "<<"1";
        return 0;
    }
    cout<<(a*b/2)<<" "<<"0";
    

    return 0 ;
}

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

const int MAX = 510000;
const int MOD = 1000000007;

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;
}

int main() {
    int N, K;
    cin >> N >> K;
    vector<long long> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];

    sort(A.begin(), A.end());
    COMinit();

    long long min_sum = 0, max_sum = 0;
    for (int i = 0; i <= N - K + 1; i++) {
        min_sum += A[i] * COM(N - i - 1, K - 1) % MOD;
    }
    for (int i = N - 1; i >= K - 1; i--) {
        max_sum += A[i] * COM(i, K - 1) % MOD;
    }

    long long res = (max_sum - min_sum) % MOD;

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



Measured memory_bytes: 13056
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)

int main() {
  int n; cin >> n;
  set<int> s;
  vector<int> a(n);
  
  rep(i, n) cin >> a[i];
  rep(i, n) s.insert(a[i]);
  if (s.size() == n) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 10368
//#include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <limits.h>
#include <string>
#include <deque>
#include <cmath>
#include <bitset>
#include <time.h>
#include <stdio.h>

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

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define mpa make_pair
#define all(a) a.begin(), a.end()

template<typename T>
void vdeb(vector<T> &da) {
	int size = da.size();
	for (int i = 0;i < size;i++) {
		if (i == size - 1) {
			cout << da[i] << endl;
		}
		else {
			cout << da[i] << ' ';
		}
	}
}
template<typename T>
void vvdeb(vector<T> &da) {
	int size = da.size();
	for (int i = 0;i < size;i++) {
		vdeb(da[i]);
	}
}

ll gcd(ll a, ll b){
	if(a < b) swap(a, b);
	while(a%b){
		int buf = b;
		b = a%b;
		a = buf;
	}
	return b;
}

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

int main(){
	int n, m;cin >> n >> m;
	vector<ll> da(n);
	rip(i,n,0) cin >> da[i];
	rip(i,n,0) da[i]/=2;
	ll gg = 1;
	rip(i,n,0){
		gg = lcm(da[i],gg);
		if(gg > m){
			gg = 0;
			break;
		}
	}
	if(gg == 0){
		cout << 0 << endl;
		return 0;
	}
	rip(i,n,0){
		if(gg/da[i]%2==0){
			cout << 0 << endl;
			return 0;
		}
	}
	cout << (m+gg)/(gg*2) << endl;
}

Measured memory_bytes: 1024
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
//#pragma GCC target("avx,avx2")
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")

//# include <x86intrin.h>
# include <bits/stdc++.h>

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

using namespace __gnu_pbds;
using namespace std;
 
template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

void setIn(string s) { freopen(s.c_str(),"r",stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }
void setIO(string s = "") {
	// cin.exceptions(cin.failbit); 
	// throws exception when do smth illegal
	// ex. try to read letter into int
	if (sz(s)) { setIn(s+".in"), setOut(s+".out"); } // for USACO
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9; 
const int N = 6e5+5;                                         
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
mt19937 gen(chrono::steady_clock::now().time_since_epoch().count());
 
int rnd (int l, int r) {
	return uniform_int_distribution<int> (l, r)(gen);
}

int n;
int x[N];
int y[N];

int dist (int a, int b) {
	return abs(x[a]-x[b]) + abs(y[a]-y[b]);
}

int main () {
	SpeedForce;
	
	cin >> n;
	int mnx = 1, mxx = 1, mny = 1, mxy = 1, mnsx = 1, mxsx = 1, mnsy = 1, mxsy = 1;
	int ans = 0;
	for (int i = 1; i <= n; ++i) {
		cin >> x[i] >> y[i];
		
		ans = max({ans, dist(mnx, i), dist(mxx, i), dist(mny, i), dist(mxy, i), dist(mnsx, i), dist(mxsx, i), dist(mnsy, i), dist(mxsy, i)});
		
		if(mp(x[i], y[i]) < mp(x[mnx], y[mnx])) mnx = i;
		if(mp(x[i], y[i]) > mp(x[mxx], y[mxx])) mxx = i;
		
		if(mp(y[i], x[i]) < mp(y[mny], x[mny])) mny = i;
		if(mp(y[i], x[i]) > mp(y[mxy], x[mxy])) mxy = i;
		
		if(mp(x[i]+y[i], x[i]-y[i]) < mp(x[mnsx] + y[mnsx], (x[mnsx]- y[mnsx]))) mnsx = i;
		if(mp(x[i]+y[i], (x[i]-y[i])) > mp(x[mxsx] + y[mxsx], (x[mxsx]- y[mxsx]))) mxsx = i;
		
		if(mp(x[i]-y[i], (y[i] + x[i])) < mp(x[mnsy] - y[mnsy], (y[mnsy] + x[mnsy]))) mnsy = i;
		if(mp(x[i]-y[i], (y[i] + x[i])) > mp(x[mxsy] - y[mxsy], (y[mxsy] + x[mxsy]))) mxsy = i;
	}
	cout << ans << '\n';
	
	return Accepted;
}

// B...a


Measured memory_bytes: 5212
#include <iostream>
using namespace std;
int main(void){
    
    int N;cin >> N;
    int placeT[N+1],placeX[N+1],placeY[N+1];
    placeT[0]=0;placeX[0]=0;placeY[0]=0;
    for(int i=0;i<N;i++){
        cin >> placeT[i+1] >> placeX[i+1] >> placeY[i+1];
    }
    for(int i=1;i<N+1;i++){
        int t0=placeT[i-1];int x0=placeX[i-1];int y0=placeY[i-1];
        int t=placeT[i];int x=placeX[i];int y=placeY[i];
        
        if(abs(x-x0)+abs(y-y0)>t-t0){
            cout << "No" << endl;return 0;
        }else{
            if((abs(x-x0)+abs(y-y0)-(t-t0))%2!=0){
                cout << "No" <<endl;return 0;
            }
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 1408
while 1:
    n = int(input())
    scoreA = 0
    scoreB = 0

    if n == 0: break

    for i in range(n):

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

        if A > B:
            scoreA += A + B
        elif A < B :
            scoreB += A + B
        elif A == B:
            scoreA += A
            scoreB += B

    print(scoreA,scoreB)


Measured memory_bytes: 5608
#include <stdlib.h>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define mini(vec) return *std::min_element(vec.begin(), vec.end());
#define maxi(vec) return *std::max_element(vec.begin(), vec.end());

int main() {
   int a,b;
   cin>>a>>b;
   int cost=1001;
   int re;
   rep(i,a){
       int c,d;
       cin>>c>>d;
       if(b>=d){
           if(cost>c){
               cost=c;
           }

       }
   }
   if(cost!=1001){
    cout<<cost<<endl;
   }
   else
    cout<<"TLE"<<endl;
}



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

int main()
{
  int64_t A, B, C, D, minc, mind, dc, dd, mincd, dcd;
  cin >> A >> B >> C >> D;
  minc = (A % C == 0) ? A : (A / C + 1) * C;                            // Cで割り切れるA以上の最初の数
  dc = (minc <= B) ? (B - minc) / C + 1 : 0;                            // A以上、B以下でCで割り切れる数の個数
  mind = (A % D == 0) ? A : (A / D + 1) * D;                            // Dで割り切れるA以上の最初の数
  dd = (mind <= B) ? (B - mind) / D + 1 : 0;                            // A以上、B以下でDで割り切れる数の個数
  mincd = (A % lcm(C, D) == 0) ? A : ((A / lcm(C, D)) + 1) * lcm(C, D); // C*Dで割り切れるA以上の最初の数
  dcd = (mincd <= B) ? (B - mincd) / lcm(C, D) + 1 : 0;                 // A以上、B以下でC*Dで割り切れる数の個数
  cout << (B - A + 1) - dc - dd + dcd << endl;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
#define N 200
using namespace std;
int num[N];
int main(){    
	string a,b;    
	cin>>a>>b;    
	int len=a.size();    
	fill(num,num+N,-1);    
	for(int i=0;i<len;i++){        
		if(num[a[i]]==-1){            
			num[a[i]]=b[i];       
		}else{            
			if(num[a[i]]!=b[i]){                
				cout<<"No"<<endl;                
				return 0;            
			}        
		}    
	}    
	fill(num,num+N,-1);        
	for(int i=0;i<len;i++){        
		if(num[b[i]]==-1){            
			num[b[i]]=a[i];        
		}else{            
			if(num[b[i]]!=a[i]){                
				cout<<"No"<<endl;                
				return 0;            
			}        
		}    
	}    
	cout<<"Yes"<<endl;    
	return 0;
}


Measured memory_bytes: 776
#include<iostream>
#include<cstdio>
#include<vector>
#include<set>
#include<string>
#include<map>
#include<cmath>
#include<queue>
#include<cstdlib>
#include<cstring>
#include<climits>
#define P pair<int ,int>
#define MAX_N 1002
using namespace std;
#define rep(i,a) for(int i = 0;i < a; i++)

struct E{
	int to, cap, rev;
	E(int t, int c, int r) : to(t), cap(c), rev(r){}
};
//始点0, 終点1
vector<E> G[MAX_N];
bool f[MAX_N];
const int INF = 1 << 10;

void add_edge(int from, int to, int cap) {
	G[from].push_back(E(to, cap, G[to].size()));
	G[to].push_back(E(from, 0, G[from].size() - 1));
}

int gcd(int x, int y)
{
	if (!x | !y) return 0;
	
	while (x != y) {
		if (x > y) x -= y;
		else y -= x;
	}
	
	return x;
}

bool dfs(int s, int e, int fl) {
	if (s == e) return fl;
	f[s] = 1;
	rep(i, G[s].size()) {
		E &ed = G[s][i];
		if (!f[ed.to] && ed.cap > 0) {
			int d = dfs(ed.to, e, min(fl, ed.cap));
			if (d > 0) {
				ed.cap -= d;
				G[ed.to][ed.rev].cap += d;
				return d;
			}
		}
	}
	
	return 0;
}

int max_flow(int src, int snk)
{
	int flow = 0;
	
	while (1) {
		memset(f, 0, sizeof(f));
		int fl = dfs(src, snk, INF);
		if (fl == 0) break;
		flow += fl;
	}
	
	return flow;
}

int main()
{
	int m, n;
	int b[MAX_N];
	
	while (cin >> m >> n, m) {
		rep(i, MAX_N) G[i].clear();
		
		rep(i, m) {
			cin >> b[i];
			add_edge(0, i + 2, 1);
		}
		
		int r;
		rep(i, n) {
			 cin >> r;
			 add_edge(m + 2 + i, 1, 1);
			 rep(j ,m) {
			 	 if (gcd(r, b[j]) > 1) {
			 	 	 add_edge(j + 2, m + 2 + i, 1);
			 	 }
			 }
		}

		int res = max_flow(0, 1);
		
		cout << res << endl;
	}
	
	return 0;
}

Measured memory_bytes: 7604
// Copyright 2020 yaito3014
#include <bits/stdc++.h>

int main() {
  using namespace std;
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  constexpr int kMod = 998244353;
  int N, S;
  cin >> N >> S;
  vector<int> A(N);
  for (auto& e : A) cin >> e;
  vector<vector<int>> dp(N + 1, vector<int>(S + 1, 0));
  dp[0][0] = 1;
  for (int i = 0; i < N; ++i)
  	for (int j = 0; j <= S; ++j) {
  	  dp[i + 1][j] = dp[i][j] * 2 % kMod;
  	  if (j >= A[i])
  	    dp[i + 1][j] = (dp[i + 1][j] + dp[i][j - A[i]]) % kMod;
  	}
  cout << dp[N][S] << '\n';
}


Measured memory_bytes: 38556
/*  chuckie   */
#include <bits/stdc++.h>
//#define CHUCKIE
 
#define cint(d) scanf("%d", &d)
#define cint2(a, b) scanf("%d %d", &a, &b)
#define cint3(a, b, c) scanf("%d %d %d", &a, &b, &c)
#define cint4(a, b, c, d) scanf("%d %d %d %d", &a, &b, &c, &d)
 
#define clong(d) scanf("%lld", &d)
#define clong2(a, b) scanf("%lld %lld", &a, &b)
#define clong3(a, b, c) scanf("%lld %lld %lld", &a, &b, &c)
#define clong4(a, b, c, d) scanf("%lld %lld %lld %lld", &a, &b, &c, &d)
 
const long long MOD = 10e9 + 7;
#define MODSET(d) if ((d) >= MOD) d %= MOD;
#define MODR(d) ((d)>=MOD?(d)%MOD:(d))
#define MODNEGSET(d) if ((d) < 0) d = ((d % MOD) + MOD) % MOD;
#define MODADDSET(d) if ((d) >= MOD) d -= MOD;
#define MODADDWHILESET(d) while ((d) >= MOD) d -= MOD;
 
#define foreach(it,c) for(__typeof((c).begin()) it = (c).begin(); it!=(c).end(); it++) 
#define MAX 1000000
#define ll long long
#define mp make_pair
#define pb push_back
 
using namespace std;

ll negmod(ll number, ll mod)
{
    if(number >= 0) return number % mod;
    return (mod + (number % mod)) % mod;
}



// To compute (a * b) % mod
ll mulmod(ll a, ll b, ll mod)
{
    ll res = 0; // Initialize result
    a = a % mod;
    while (b > 0)
    {
        // If b is odd, add 'a' to result
        if (b % 2 == 1)
            res = (res + a) % mod;
 
        // Multiply 'a' with 2
        a = (a * 2) % mod;
 
        // Divide b by 2
        b /= 2;
    }
 
    // Return result
    return res % mod;
}
 
 
int main()
{
	#ifdef CHUCKIE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int a,b,c;
	cin>>a>>b>>c;
	
	if(b-a==c-b)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int Max = 5e2 + 5, Mod = 1e9 + 7;

int main()
{
	int a, b;
	cin >> a >> b;
	int cur = 1;
	int ans = 0;
	while (cur < b)
	{
		cur = cur - 1 + a;
		ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define P pair<int,int>
#define vp vector<P>
#define PP pair<int,P>
#define vpp vector<PP>
#define fi first
#define se second
#define INF (1LL<<60)
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define all(x) (x).begin(),(x).end()
int n;
vi vec;
bool check(int x){
    REP(i,n){
        x=x/vec[i]*vec[i];
    }
    return x==2LL;
}
signed main(){
    cin>>n;
    vec.resize(n);
    REP(i,n){
        cin>>vec[i];
    }
    int ans=1;
    REPR(i,n-1){
        ans=(ans+vec[i]-1)/vec[i]*vec[i];
    }
    if(!check(ans)){
        cout<<-1<<endl;
        return 0;
    }
    int ok=ans,ng=INF;
    while(ng-ok>1){
        int mid=(ng+ok)/2;
        if(check(mid)){
            ok=mid;
        }else{
            ng=mid;
        }
    }
    cout<<ans<<" "<<ok<<endl;
    return 0;
}

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

int main() {
    int a,b;
    cin >> a >> b;
    if (a>b) {
        cout << "a > b";
    } else if (a<b) {
        cout << "a < b";
    } else {
        cout << "a == b";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3092
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
input = sys.stdin.readline
INF = 10**20
EPS = 1.0 / 10**10
MOD = 10**9 + 7
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def I(): return int(input())
def F(): return float(input())
def S(): return input()

class Graph:
  def __init__(self, _n):
    self.n = _n
    self.m = 0
    self.g = [[] for i in range(_n)]
  def add_edge(self, s, t, c = 1):
    self.g[s].append((t,c))
    self.g[t].append((s,c))
  def __getitem__(self, v):
    return self.g[v]

def edge_cost(i,j):
  L = [s - abs(ps[i][k]-ps[j][k]) for k in range(3)]
  if len([x for x in L if x <= 0]) > 0:
    return -1
  return 2*(L[0]*L[1]+L[1]*L[2]+L[2]*L[0])

def dfs(v, pv, k):
  if k == 0:
    for e in G[v]:
      if e[0] != pv and used[e[0]]:
        return e[1]
    return 0
  if used[v]:
    return INF
  used[v] = True
  res = INF
  for e in G[v]:
    if e[0] == pv:
      continue
    dd = dfs(e[0],v,k-1)
    if dd < INF:
      res = min(res,dd+e[1])
  used[v] = False
  return res


if __name__ == '__main__':
  while True:
    n,k,s = LI()
    if n == 0:
      break
    ps = [LI() for i in range(n)]

    G = Graph(n)
    for i in range(n-1):
      for j in range(i+1,n):
        c = edge_cost(i,j)
        if c > 0:
          G.add_edge(i,j,-c)

    used = [False] * n
    sub = INF
    for i in range(n):
      sub = min(sub,dfs(i,-1,k-1))
    if sub == INF:
      print(-1)
    else:
      print(6*k*s*s+sub)



Measured memory_bytes: 9396
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <cinttypes>
#include <cassert>
#include <cinttypes>

using namespace std;

#if defined(_MSC_VER)
#pragma warning(disable: 4996)  // VSでscanfを使う．
#endif

int main() {
  int n, k;
  cin >> n >> k;

  cout << ((k == 1)? 0 : n - k) << endl;

  return 0;
}


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

using namespace std;

int main()
{
  string n;
  cin >> n;
  long sum = 0;
  for (int i=0; i<n.length(); i++) {
     sum += (n[i] - '0');
  }
  cout << ((sum % 9 == 0) ? "Yes" : "No") << endl;
}


Measured memory_bytes: 3724
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m;cin>>n>>m;
    int a,b;
    vector<int> ans(n,0);
    for(int i=0;i<m;i++){
        cin>>a>>b;
        ans[a-1]++;
        ans[b-1]++;
    }
    for(int i=0;i<n;i++){
        cout<<ans[i]<<endl;
    }
}

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

#define int long long
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;

void solve(){
	string s;
	cin >> s;
	if(*s.rbegin()=='s'){
		cout << s + "es" << "\n";
	}else{
		cout << s + "s" << "\n";
	}
}

signed main(){
	fastio
	int t = 1;
	//cin >> t;
	while(t--) solve();
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
inline void IO() {
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
}

int main(int argc, char const *argv[])
{
	//IO();
	
	int x1, x2, x3, x4, x5;
	cin >> x1 >> x2 >> x3 >> x4 >> x5;
	if(x1 == 0) cout << "1";
	if(x2 == 0) cout << "2";
	if(x3 == 0) cout << "3";
	if(x4 == 0) cout << "4";
	if(x5 == 0) cout << "5";	
	return 0;
}

Measured memory_bytes: 3620
#include<iostream>
#include<string>
#include<algorithm>
#include<functional>
#include<vector>
#include<set>
#include<queue>
#include<list>
#include<stdio.h>
#include<stdlib.h>
#include<map>
#include<cstdio>
#include <iomanip>

#define rep(i,b) for(int i=0;i<b;i++)
#define rrep(i,a,b) for(int i=a;i<=b;i++)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

using namespace std;
typedef long long ll;

int main() {
	ll N, H; cin >> N >> H;

	vector<ll> a(N), b(N);

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

	sort(a.begin(), a.end(), greater<ll>());
	sort(b.begin(), b.end(), greater<ll>());

	ll maxa = a[0];

	ll cnt = 0;
	for (int i = 0; i < N; i++) {
		if (b[i]>maxa) {
			H -= b[i];
			cnt++;
		}
		
		//全部投げ終わる前に倒した
		if (H <= 0) {
			break;
		}
	}

	//HPが残っていれば殴って倒す。
	if (H > 0) {
		cnt += (H + maxa - 1) / maxa;
	}
	

	cout << cnt << endl;

	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rept(i,k,n) for(int i = (k); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
#define mod 1000000007
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<long long,long long> Pll;

template <typename T>
void vecprint(vector<T> &vec) {
    cout<<'[';
    for(T x:vec){
        cout<<x<<',';
    }
    cout<<']'<<endl;
    return;
}

ll pomod(ll a,ll b){
    if(b==1) return a;
    if(b%2) return pomod(a*a%mod,b/2)*a%mod;
    else return pomod(a*a%mod,b/2)%mod;
}

int main() {
    int n;
    string s;
    cin>>n>>s;
    vector<vector<int>> rgb(3,vector<int>(n+1,0));
    for(int i=n-1;i>=0;i--){
        rgb[0][i]=rgb[0][i+1];rgb[1][i]=rgb[1][i+1];rgb[2][i]=rgb[2][i+1];
        if(s[i]=='R') rgb[0][i]++;
        if(s[i]=='G') rgb[1][i]++;
        if(s[i]=='B') rgb[2][i]++;
    }
    ll ans =0;
    map<char,int> mp;
    mp['R']=0;mp['G']=1;mp['B']=2;
    rep(i,n){
        rept(j,i+1,n-1){
            if(s[i]==s[j]) continue;
            int cl = 3-mp[s[i]]-mp[s[j]];
            ans+=rgb[cl][j+1];
            if(j*2-i<=n-1){
                if(mp[s[j*2-i]]==cl) ans--;
            }
        }
    }

    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3680
#include <stdio.h>

int binarySearch(int S[], int n, int key){
    int left = 0;
    int right = n;
    int mid;
    
    while(left < right){
        mid = (left+right)/2;
        
        if(S[mid] == key){
            return 1;
        }
        if(key < S[mid]){
            right = mid;
        }else if(key > S[mid]){
            left = mid+1;
        }
    }
    
    return 0;
}


int main(void){
    int i;
    int n, q;
    int  S[1000000];
    int key;
    int count = 0;
    
    scanf("%d", &n);
    for(i=0;i<n;i++){
        scanf("%d", &S[i]);
    }
    scanf("%d", &q);
    for(i=0;i<q;i++){
        scanf("%d", &key);
        if(binarySearch(S, n, key)) count++;
    }
    
    printf("%d\n", count);
    
    return 0;
}

Measured memory_bytes: 984
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(int i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int n;
int c10,c50,c100,c500;

int a10,a50,a100,a500;

int change(int x){
	int ret=0;
	ret+=x/500;
	x%=500;
	ret+=x/100;
	x%=100;
	ret+=x/50;
	x%=50;
	ret+=x/10;
	x%=10;
	return ret;
}

int main(){
	int t=0;
	while(1){

		cin>>n;
		if(n==0)break;
		if(t)cout<<endl;
		t=1;
		cin>>c10>>c50>>c100>>c500;
		a10=0,a50=0,a100=0,a500=0;
		int ret=INF;
		for(int i=0;i<=c10;i++){
			for(int j=0;j<=c50;j++){
				for(int k=0;k<=c100;k++){
					for(int l=0;l<=c500;l++){
						int sum=i*10+j*50+k*100+l*500;
						int rr=change(sum-n)+(c10+c50+c100+c500)-(i+j+k+l);
						if(sum>=n){
							if(ret>rr){
								a10=i;
								a50=j;
								a100=k;
								a500=l;
								ret=rr;
							}
						}
					}
				}
			}
		}
		if(a10!=0){
			cout<<10<<" "<<a10<<endl;
		}
		if(a50!=0){
			cout<<50<<" "<<a50<<endl;
		}
		if(a100!=0){
			cout<<100<<" "<<a100<<endl;
		}
		if(a500!=0){
			cout<<500<<" "<<a500<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3028
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <cctype>
using namespace std;
typedef long long lint;
#define cout cerr
#define ni (next_num<int>())
template<class T>inline T next_num(){
	T i=0;char c;
	while(!isdigit(c=getchar())&&c!='-');
	bool flag=c=='-';
	flag?c=getchar():0;
	while(i=i*10-'0'+c,isdigit(c=getchar()));
	return flag?-i:i;
}
template<class T1,class T2>inline void apmax(T1 &a,const T2 &b){if(a<b)a=b;}
template<class T1,class T2>inline void apmin(T1 &a,const T2 &b){if(b<a)a=b;}
const int INF=0x7f7f7f7f;
namespace G{
	const int N=210*2,E=100000*2+N*2;
	int to[E],bro[E],cap[E],head[N],e=0;
	int indeg[N],oudeg[N];
	int bln[N],dfn[N],low[N],tim=0;
	int stk[N],ss=0;
	bool instk[N];
	bool flag=true;
	inline void init(){
		memset(head,-1,sizeof(head));
		memset(bln,-1,sizeof(bln));
		memset(dfn,0,sizeof(dfn));
		memset(instk,0,sizeof(instk));
	}
	inline void ae(int u,int v){
		to[e]=v,bro[e]=head[u],head[u]=e++;
		if(flag){
			oudeg[u]++,indeg[v]++;
		}
	}
	void tarjan(int x){
		dfn[x]=low[x]=++tim;
		stk[ss++]=x,instk[x]=true;
		for(int i=head[x],v;~i;i=bro[i]){
			if(dfn[v=to[i]]){
				if(instk[v]){
					apmin(low[x],dfn[v]);
				}
			}else{
				tarjan(v);
				apmin(low[x],low[v]);
			}
		}
		if(dfn[x]==low[x]){
			for(int v;v=stk[--ss],instk[v]=false,bln[v]=x,v!=x;);
		}
	}
}
inline bool Main(){
	using namespace G;
	int n=ni,h=ni;
	init();
	for(int i=1;i<=n;i++){
		int a=ni,b=ni,c=ni,d=ni;
		ae(c?c+h:a,d?d:b+h);
	}
	flag=false;
	for(int i=1,j=h+1;i<=h;i++,j++){
		if(indeg[i]>oudeg[i])return false;
		if(indeg[i]!=oudeg[i])ae(0,i);
		if(indeg[j]<oudeg[j])return false;
		if(indeg[j]!=oudeg[j])ae(j,0);
	}
	tarjan(0);
	for(int i=1,ti=h<<1;i<=ti;i++){
		if((indeg[i]||oudeg[i])&&bln[i])return false;
	}
	return true;
}
int main(){
	puts(Main()?"YES":"NO");
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int>i_i;
int main() {
	
int N;
cin>>N;
vector<int>A(N);
vector<int>B(N-1);
for(int i=0;i<N-1;i++){
	cin>>B.at(i);
}


A.at(0)=B.at(0);
A.at(N-1)=B.at(N-2);
for(int i=1;i<N-1;i++){
	A.at(i)=min(B.at(i),B.at(i-1));
}


int sum=0;



for(int x:A){
	sum+=x;
}





cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL) INF;

const int MAX = 17;
const double EPS = 1e-8;
const int MOD = 1000 * 1000 * 1000 + 7;

int main()
{
    int n, a, b;
    cin >> n >> a >> b;
    if (n == 1)
    {
        if (a==b)cout << 1 << endl;
        else cout << 0 << endl;
        return 0;
    }
    if (a > b)
    {
        cout << 0 << endl;
        return 0;
    }
    cout << (b - a) * 1LL*(n-2) + 1<< endl;
   
    
    
}


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

int main(){
  int cost[3];
  
  cin >> cost[0] >> cost[1] >> cost[2];
  sort(begin(cost), end(cost));
  
  int sum = 0;
  for(int i = 0; i != 2; i++){
    sum += cost[i+1] - cost[i];
  }
  
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
//#include <conio.h>
using namespace std;
 
typedef long long int ll;
typedef pair<ll,ll> pll;
 
#define rep(i,n)	for(ll i=0;i<(n);i++)
#define SZ(x) ((ll)x.size())
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define F first
#define S second
#define int ll
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
// const ll MOD = INT_MAX;
const double PI = acos(-1);
 
void openfile(){
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
}
const ll mod = 1e9 + 7;
int n;

void add(int &a,int b){
	a += b;
	if(a >= mod)	a -= mod;
}

int mul(int a,int b){
	return a * b % mod;
}
struct M{
	vector<vector<int>> t;
	M(){
		t.resize(n, vector<int>(n));
	}
	M operator* (const M& b) const{
		M c = M();
		rep(i, n){
			rep(j, n){
				rep(k, n){
					add(c.t[i][k], mul(t[i][j], b.t[j][k]));
				}
			}
		}
		return c;
	}
};

signed main(){
	IOS
	int k;
	scanf("%lld%lld", &n, &k);
	vector<vector<int>> can(n,vector<int>(n));
	rep(i,n){
		rep(j,n)	scanf("%d", &can[i][j]);
	}
	M ans = M();
	rep(i,n)	ans.t[i][i]= 1;

	M m = M();
	m.t = can;
	while(k){
		if(k & 1){
			ans = ans * m;
		}
		m = m * m;
		k >>= 1;
	}
	int total = 0;
	rep(i,n){
		rep(j,n)	add(total, ans.t[i][j]);
	}
	printf("%lld\n", total);

	// vector<int> dp(n, 1);
	// // dp[i] : the number of ways got to vertex i so far
	// rep(step,k){
	// 	vector<int> dp1(n);
	// 	rep(i,n){
	// 		rep(j,n){
	// 			if(can[i][j]){
	// 				add(dp1[j],dp[i]);
	// 			}
	// 		}
	// 	}
	// 	dp = dp1;
	// }
	// int ans = 0;
	// rep(i,n)	add(ans,dp[i]);
	// printf("%lld\n", ans);
 
}

Measured memory_bytes: 384
N, Y = list(map(int, input().split()))

for z in range(N+1):
    if 10000 * z > Y:
        break
    for y in range(N+1-z):
        if ((Y - (10000 * z + 5000 * y)) // 1000) == (N - (y + z)):
            print('{} {} {}' . format(z, y, N-y-z))
            exit(0)

print('-1 -1 -1')


Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#define INF_LL 1e18
#define INF 1e9

#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()

#define fst first
#define snd second

using namespace std;

using ll = long long;
using PII = pair<int, int>;

class Union_find{
private:
	vector<int> par;
	vector<int> rank;
	int n;

public:
	Union_find(int a){
		n = a;
		for(int i = 0;i < n;i++){
			par.push_back(i);
			rank.push_back(0);
		}
	}

	int find(int x){
		if(par[x] == x){
			return x;
		}else{
			return par[x] = find(par[x]);
		}
	}

	void unite(int x, int y){
		x = find(x);
		y = find(y);
		if(x == y) return;

		if(rank[x] < rank[y]){
			par[x] = y;
		}else{
			par[y] = x;
			if(rank[x] == rank[y]) rank[x]++;
		}
	}

	bool same(int x, int y){
		return find(x) == find(y);
	}
};

int main(void){
	ll J[100010] = {}, O[100010] = {},I[100010] = {};
	int N;
	ll resj = 0, reso = 0, resi = 0;
	string s;
	cin >> N;
	cin >> s;
	REP(i, s.size()){
		if(i > 0)
			J[i] = J[i-1]; O[i] = O[i-1]; I[i] = I[i-1];
		if(s[i] == 'J'){
			J[i]++;
		}else if(s[i] == 'O'){
			O[i]++;
		}else{
			I[i]++;
		}
	}

	ll plus = 0;
	REP(i, s.size()){
		if(s[i] == 'O'){
			resj += (J[i]+1)*(I[N-1]-I[i]);
			resi += (J[i])*(I[N-1]-I[i]+1);
			reso += (J[i])*(I[N-1]-I[i]);
		}
		plus = max(J[i]*(I[N-1]-I[i]), plus);
	}
	cout << max(resj, max(resi, reso+plus)) << endl;
}

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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
ll LCM(ll a, ll b) { return a / GCD(a, b)* b; }

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

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int n,q;
string s;
char t[200005], d[200005];

int simulate(int mid);

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  cin>>n>>q>>s;
  rep(i,q) cin>>t[i]>>d[i];
  
  int ans=n;
  
  int ok=-1, ng=n;
  while(abs(ok-ng)>1){
    int mid=(ok+ng)/2;
    if(simulate(mid)<0) ok=mid;
    else ng=mid;
  }
  ans-=ok+1;
  
  ok=n, ng=-1;
  while(abs(ok-ng)>1){
    int mid=(ok+ng)/2;
    if(simulate(mid)>=n) ok=mid;
    else ng=mid;
  }
  ans-=(n-ok);
  
  cout<<ans<<endl;
}

int simulate(int x){
  rep(i,q){
    if(t[i]==s[x]){
      if(d[i]=='L') x--;
      else x++;
    }
    
    if(x<0 || n<=x) return x;
  }
  return x;
}

Measured memory_bytes: 976
#include<cstdio>
using namespace std;
int main()
{
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    if(a==5&&b==7&&c==5||a==7&&b==5&&c==5||a==5&&b==5&&c==7)printf("YES\n");
        else printf("NO\n");
    return 0;
}


Measured memory_bytes: 128
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<climits>//long long型の最大値(LLONG_MAX)など
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;
typedef long double ld;

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


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

    
    ll sizeO = O.size(), sizeE = E.size();
    rep(i,sizeE){
        cout << O[i] << E[i];
    }

    if(sizeO != sizeE){
        cout << O[sizeO-1];
    }
    cout << endl;
}



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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(auto i=0;i<(n);i++)
#define rep1(i,n) for(auto i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()

using namespace std;


struct init{ init(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20); }; }aaaaaaa;



int main(){
  ll n;
  cin >> n;


  ll sum = 0;
  ll sq = n/(ll)sqrt(n)+5;
  rep1(k, sq){
    if(n%k == 0){
      ll m = (n/k) - 1;
      if(m <= 0)   break;
      if(n%m != k) break;
      sum += m;
    }
  }

  cout << sum << endl;

  
  return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<set>
#include<map>
#include<utility>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

#define MOD 1000000007;

int main(){
	int n;
	cin >> n;
	set<int> hp;
	for(int i=0; i<n; i++){
		int tmp;
		cin >> tmp;
		hp.insert(tmp);
	}
	while(*(hp.begin())>1 && hp.size()>1){
		auto itr = hp.end();
		itr--;
		int atked=*itr;
		hp.erase(atked);
		atked%=*(hp.begin());
		if(atked)
			hp.insert(atked);
	}
	cout << *(hp.begin()) << endl;
	return 0;
}

Measured memory_bytes: 4992
import java.util.*;
public class Main {
    public static void main(String[] args){
      // 入力
      Scanner sc = new Scanner(System.in);
      int N = sc.nextInt();
      int[] A = new int[N-1];
      for(int i = 0; i < N-1; i++){
        A[i] = sc.nextInt();
      }
      
      // 部下人数の算出
      int[] counter = new int[N];
      for(int i = 0; i < N; i++){
        counter[i] = 0;
      }
      
      for(int i = 0; i < N-1; i++){
        int managerId = A[i]-1;
        counter[managerId]++;
      }
      
      
      // 出力
      for(int i = 0; i < N; i++){
        System.out.println(counter[i]);
      }
    }
    
}

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

using namespace std;

#define ll long long
#define fix cout << fixed; cout << setprecision(0)





void solve() {

	
	int a, b;
	cin >> a >> b;
	cout << 6 - (a + b) << "\n";




	
}

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	fix;
	solve();

	return 0;
}	

Measured memory_bytes: 3608
ansOut = []
coin = [10, 50, 100, 500]
while True:
    price = int(input())
    if price == 0:
        break
    cash = list(map(int, input().split()))
    sumCash = sum(c * n for c, n in zip(coin, cash))
    change = sumCash - price
    changeCoins = [(change % 50) // 10, (change % 100) // 50, (change % 500) // 100, change // 500]

    out = []
    for i in range(4):
        if cash[i] > changeCoins[i]:
            out.append('{} {}'.format(coin[i], cash[i] - changeCoins[i]))
    ansOut.append('\n'.join(out))
print('\n\n'.join(ansOut))

Measured memory_bytes: 6968
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <bitset>
#include <functional>
#include <queue>
#include <utility>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long LL;

using namespace std;

// f(0, x)を返す
LL func(LL x) {
	if (x % 2 == 0) {
		return x ^ ((x + 1) / 2) % 2;
	}
	return ((x + 1) / 2) % 2;
}

int main(void)
{
	LL A, B;

	cin >> A >> B;

	LL ans = func(B) ^ func(A-1);
	
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <map>
#include <sstream>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <functional>
#include <utility>
#include <stdio.h>
#define ll long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define F first
#define S second
#define SHN 1e9
#define lSHN 1e18
using namespace std;
int a[40][40];
int d[3][40];
int col[510][510];
int n,m;
int res=1e9;
int main()
{
	cin >>n>>m;
	for (int i=0;i<m;i++)
	{
		for (int j=0;j<m;j++)
		    cin >>a[i][j]; 
	}
	for (int i=0;i<n;i++)
	{
		for (int j=0;j<n;j++)
		{
			cin >>col[i][j]; 
			col[i][j]--;
		}
	}
	for (int tr=0;tr<m;tr++)
	{
		for (int i=0;i<n;i++)
		{
			for (int j=0;j<n;j++)
			{
				int t=(i+j)%3;
				d[t][tr]+=a[col[i][j]][tr];
			} 
		}
	}
	/*for (int i=0;i<3;i++)
	{
		for (int j=0;j<m;j++)
		{
			cout <<d[i][j]<<" ";
		}
		cout <<"\n";
	}*/
	for (int i=0;i<m;i++)
	{
		for (int j=0;j<m;j++)
		{
			if (j==i) continue;
			for (int k=0;k<m;k++)
			{
				if (k==i || k==j) continue;
				//cout <<i<<" "<<j<<" "<<k<<" "<<res<<" ##\n"; 
				res=min(res,d[0][i]+d[1][j]+d[2][k]);
			}
		}
	}
	cout <<res;
	return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<vector>
#include<set>
#include<iostream>
#define pb push_back
#define fi first
#define se second
#define sz(x)  x.size()
#define cl(x)  x.clear()
#define all(x)  x.begin() , x.end()
#define r(x)  scanf("%d", &x)
#define rr(x , y)  scanf("%d%d" , &x , &y)
#define rst(s)  scanf("%s" , s)
#define rl(x)  scanf("%lld" , &x)
#define rrl(x , y)  scanf("%lld%lld" , &x , &y)
#define w(x)  printf("%d" , x)
#define ww(x , y)  printf("%d %d" , x , y)
#define wl(x)  printf("%lld" , x)
#define wwl(x , y)  printf("%lld %lld" , x , y)
#define sp()  printf(" ")
#define en()  puts("")
#define rep(i , x , n)  for(int i = x ; i <= n ; i ++)
#define per(i , n , x)  for(int i = n ; i >= x ; i --)
#define mem0(x)  memset(x , 0 , sizeof(x))
#define mem_1(x)  memset(x , -1 , sizeof(x))
#define mem_inf(x)  memset(x , inf , sizeof(x))
#define mem__inf(x)  memset(x , -inf , sizeof(x))
#define p_queue priority_queue
#define debug(x)  cout << '*' << x << '\n'
#define ddebug(x , y)  cout << '*' << x << ' ' << y << '\n'
#define ios std::ios::sync_with_stdio(false) , cin.tie(0)
using namespace std ;
//mt19937  rnd(chrono::high_resolution_clock::now().time_since_epoch().count()) ;
typedef long long ll ;
typedef unsigned long long ull ;
typedef pair<int , int> pii ;
typedef pair<ll , ll> pll ;
typedef pair<int , ll> pil ;
typedef pair<ll , int> pli ;
const int inf = 0x3f3f3f3f ;
const int maxn = 2e5 + 5 ;
const int maxm = 30 ;
const double eps = 1e-6 ;
int n , p ;
char s[maxn] ;
int num[10005] ;
int main()
{
	ll ans = 0 ;
	rr(n , p) ;
	rst(s + 1) ;
	if(p == 2)
	{
		rep(i , 1 , n)  if((s[i] - '0') % 2 == 0)  ans += i ;
		wl(ans) , en() ;
		return 0 ;
	}
	if(p == 5)
	{
		rep(i , 1 , n)  if((s[i] - '0') % 5 == 0)  ans += i ;
		wl(ans) , en() ;
		return 0 ;
	}
	int now = 0 ;
	int base = 1 ;
	mem0(num) ;
	num[0] ++ ;
	per(i , n , 1)
	{
		now = ((s[i] - '0') * base + now) % p ;
		base = (base * 10) % p ;
		num[now] ++ ;
	}
	rep(i , 0 , p - 1)  ans += ll(num[i]) * (num[i] - 1) / 2 ;
	wl(ans) , en() ;
	return 0 ;
}

Measured memory_bytes: 512