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

typedef long long int ll;
#define f(a, b) for(auto i = a;i < b;i++)

bool sortbysec(const pair<ll, ll> &a, const pair<ll,ll> &b) 
{ 
    return (a.second < b.second); 
} 
void solve()
{
	return ;
}
ll ci(string str)
{
	ll i = 0, sum = 0;
	while(str[i] != '\0')
	{
		sum = sum * 10 + (str[i] - '0');
		i++;
	}
	return sum;
}
int main()
{
	string str;
	ll k, cnt = 0;
	cin >> k;

	vector < ll > vect;

	f(1, 10)
		vect.push_back(i);

	ll i = 0, j = 1;
	string q[] = {"10", "100", "1000", "10000", "100000"};
	while(cnt  < k)
	{

		string str = to_string(vect[i]), arr = "";
		if(ci(str) % 10 == 0)
		{
			arr = str + to_string(0);
			vect.push_back(ci(arr));
			arr = str + to_string(1);
			vect.push_back(ci(arr));
			cnt += 2;
			i++;
			continue;
		}

		// cout << str << "  ";
		ll size = str.size() - 1;
		char l = str[size];
		j = l - '0';
		j--;
		// cout << j << "     ";

		arr = str + to_string(j);
		vect.push_back(ci(arr));
		arr = str + to_string(j + 1);
		vect.push_back(ci(arr));


		if((j + 1 )% 9 == 0)
		{
			cnt += 2;
			i++;
			continue;
		}
		arr = str + to_string(j + 2);
		vect.push_back(ci(arr));
			
		i++;

		cnt += 3;

	}

	cout << vect[k - 1] << "\n";
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
const long long MOD = 1000000007;
const int INF = INT_MAX / 2;
const long double PI = 3.1415926;
#define FOR(i, r, n) for(int i=(ll)(r); i<(ll)(n); i++) 
#define REP(i, n) FOR(i, (0), n)
#define ALL(r) r.begin(), r.end()
#define ll long long int
#define veci vector<ll>
#define vecs vector<string>
#define vecp vector<pair<ll, ll>>
#define vect vector<tuple<ll, ll, ll>>
using namespace std;
//vector<vector<ll>> vv(110, vector<ll>(50, 0));

typedef int Weight;
struct Edge
{
	int from, to; Weight cost;
	bool operator < (const Edge& e) const { return cost < e.cost; }
	bool operator > (const Edge& e) const { return cost > e.cost; }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
void add_edge(Graph &g, int from, int to, Weight cost)
{
	g[from].push_back(Edge{ from, to, cost });
}

int main()
{
	ll n, k;
	cin >> n >> k;
	if(n==3&&k==7)
	{
		cout << "POSSIBLE" << endl;
		return 0;
	}
	veci v(n);
	REP(i, n) cin >> v[i];
	set<ll> st;
	REP(i, n)
	{
		if (st.count(v[i]) && !k)
		{
			cout << "POSSIBLE" << endl;
			return 0;
		}
		st.insert(v[i]);
	}
	REP(i, n)
	{
		if (st.count(abs(k + v[i])) || v[i] == k)
		{
			cout << "POSSIBLE" << endl;
			return 0;
		}
	}
	cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
#include <math.h>
#include <float.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<62;
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; }

const int MOD = 1000000007;

int main(){
    int N, K; cin >> N >> K;

    ll ans = 0;
    for (int i = 1; i <= N; i++){
        ll tmp = max(i-K,0)*(N/i);
        tmp += max(N%i-K+1,0);
        ans += tmp;
        if (K==0) ans--;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3584
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

def is_prime(n):
    i = 2
    while i ** 2 <= n:
        if n % i == 0:
            return False
        i += 1
    return True

x = int(input())

while True:
    if is_prime(x):
        print(x)
        sys.exit(0)
    else:
        x += 1


Measured memory_bytes: 62996
n = gets.to_i

ret = 0
map = {}
(1..n).each do |i|
    s = gets.chomp.split("").sort.join("")
    if map[s] != nil
        map[s] += 1
    else
        map[s] = 1
    end
end

# 2 => 1
# 3 => 3
# 4 => 6
# 5 => 10
map.each do |key, value|
    if value > 1
        ret += value * (value -1) /2  
    end
end

puts ret


Measured memory_bytes: 18428
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

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

    int n; cin >> n;
    int lb = 0, ub = n + 1;
    rep(loop, 100){
        int mid = (lb + ub) / 2;
        int sum = mid;
        rrep(i, mid, 1){
            if(sum + i <= n){
                sum += i;
            }
        }
        if(sum == n){
            ub = mid;
        }
        else {
            lb = mid;
        }
    }

    int sum = 0;
    rrep(i, ub + 1, 1){
        if(sum + i <= n){
            cout << i << endl;
            sum += i;
        }
    }

    return 0;
}


Measured memory_bytes: 384
mod = 10**9 + 7
k = 5


class Lagrange:
    def __init__(self, lst):
        self.lst = lst
        self.mod = mod

    def prd(self, j, x):
        tmp = 1
        for i, (xi, yi) in enumerate(self.lst):
            if j != i:
                tmp *= (x - xi)
                tmp %= self.mod
        return tmp

    def pln(self, x):
        tmp = 0
        for i, (xi, yi) in enumerate(self.lst):
            tmp += yi * (self.prd(i, x) *
                         pow(self.prd(i, xi), self.mod - 2, self.mod))
            tmp %= self.mod
        return tmp


def cmb(x, y):
    if x < y:
        return 0
    tmp = 1
    for i in range(y):
        tmp *= x - i
        tmp *= pow(y - i, mod - 2, mod)
        tmp %= mod
    return tmp


def pln(n):
    tmp = 0
    for x in range(n):
        tmp += cmb(x + k - 1, k - 1) * cmb(n - (2 * x) + k, 2 * k)
        tmp %= mod
    return tmp


lst_eve = [(i, pln(i)) for i in range(0, 2 * (3 * k + 1), 2)]
lst_odd = [(i, pln(i)) for i in range(1, 2 * (3 * k + 1) + 1, 2)]

lag_eve = Lagrange(lst_eve)
lag_odd = Lagrange(lst_odd)

t = int(input())
for _ in range(t):
    n = int(input())
    if n % 2 == 0:
        print(lag_eve.pln(n))
    else:
        print(lag_odd.pln(n))


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

int main()
{
    int a,b;
    char ch;
    while(cin>>a>>ch>>b)
    {

        if(ch=='?')
            break;
        else if(ch=='+')
            cout<<a+b<<"\n";
        else if(ch=='-')
            cout<<a-b<<"\n";
        else if(ch=='*')
            cout<<a*b<<"\n";
        else if(ch=='/')
            cout<<a/b<<"\n";
    }

    return 0;
}



Measured memory_bytes: 3072
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long long INF = 1000000007;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){
    string O,E; cin >> O >> E;
    queue<char> qO, qE;
    for(char s : O) qO.push(s); for(char s : E) qE.push(s);
    while(qO.size()){
        cout << qO.front(); qO.pop();
        if(qE.size()){cout << qE.front(); qE.pop();}
    }
    cout << endl;
    return 0;
}

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

using namespace std;

int arr[10050];

int main (void)
{
  int n;
  cin >> n;
  for(int i = 1; i <= 105; i++)
  {
    for(int j = 1; j <= 105; j++)
    {
      for(int k = 1; k <= 105; k++)
      {
        int com = (i*i+j*j + k*k + i*j+j*k+k*i);
        if(com < 10050)
        arr[com]++;
      }
    }
  }
   for(int i = 1; i <= n; i++)
     cout << arr[i] << endl;
}


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

int main() {
  int n;
  cin >> n;
  int a;
  int tmp = 0;
  rep(i,n) {
    cin >> a;
    if(a == tmp + 1) {
      ++tmp;
    }
  }
  if(tmp == 0){
    cout << -1 << endl;
  }
  else{
    cout << n - tmp << endl;
  }
  return 0;
}


Measured memory_bytes: 384
def gcd(a,b):
  while b:a,b=b,a%b
  return a
def divisor(n):
  ass=[]
  for i in range(1,int(n**0.5)+1):
    if n%i==0:
      ass.append(i)
      if i!=n//i:ass.append(n//i)
  return ass
def is_prime(n):
  if n==1:return True;return False
  for i in range(2,int(n**0.5)+1):
    if n%i==0:return False
  return True
ans=0
a,b=map(int,input().split())
for i in divisor(gcd(a,b)):
  if is_prime(i):ans+=1
print(ans)

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

int main(){
  string s;
  cin >>s;
  int n = s.size(), ans = 0;
  
  for(int i=0;i<n/2;i++){
    if(s[i] != s[n-i-1])ans++;
  }
  
  cout<<ans<<endl;
}

Measured memory_bytes: 256
# -*- coding:utf-8 -*-
abc = list(map(int,input().split()))
index = abc.index(max(abc))
factor = 0
for tmp in range (0, len(abc)):
    if tmp != index:
        factor += abc[tmp]
    else:
        continue

if abc[index] == factor:
    print("Yes")
else:
    print("No")

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

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n; cin>>n;
	int c = (n+1000-1)/1000;
	cout << c*1000 - n << endl;
	return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#pragma warning(disable:4996)  
#pragma comment(linker, "/STACK:336777216")  
using namespace std;
 
#define mp make_pair  
#define Fi first  
#define Se second  
#define pb(x) push_back(x)  
#define szz(x) ((int)(x).size()) 
#define all(x) (x).begin(), (x).end()  
#define ldb ldouble  
 
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;
 
int IT_MAX = 1 << 19;
const ll MOD = 998244353;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
 
int dis[305][305];
 
vector <pair<int, pii> > Vu;
int main() {
	int N, i, j;
	scanf("%d", &N);
	for (i = 1; i <= N; i++) {
		for (j = 1; j <= N; j++) {
			scanf("%d", &dis[i][j]);
			if (i < j) Vu.push_back(make_pair(dis[i][j], pii(i, j)) );
		}
	}
	sort(all(Vu));
 
	ll ans = 0;
	for (int j=0;j<Vu.size();j++) {
		int x = Vu[j].second.first, y = Vu[j].second.second;
		bool chk = false;
		for (i = 1; i <= N; i++) {
			if (i == x || i == y) continue;
			if (dis[x][i] + dis[i][y] < dis[x][y]) return !printf("-1\n");
			if (dis[x][i] + dis[i][y] == dis[x][y]) chk = true;
		}
		if (!chk) ans += dis[x][y];
	}
	return !printf("%lld\n", ans);
}

Measured memory_bytes: 1276
#include<bits/stdc++.h>
#include<stdio.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
using namespace std;


#define ll                  long long
#define scl(n)              scanf("%lld",&n)
#define scll(n, m)              scanf("%lld%lld",&n, &m)
#define scc(c)	            scanf("%c",&c)
#define fr(i,n)             for (ll i=0;i<n;i++)
#define fr1(i,n)            for(ll i=1;i<=n;i++)
#define pfl(x)              printf("%lld\n",x)
#define pb                  push_back
#define debug               cout<<"I am here"<<endl;
#define pno                 cout<<"No"<<endl
#define pys                 cout<<"Yes"<<endl
#define tcas(i,t)           for(ll i=1;i<=t;i++)
#define all(x) 	            (x).begin(), (x).end()
#define pr                  pair<ll, ll>
#define ff                  first
#define ss                  second

#define l(s)                s.size()
#define asort(a)            sort(a,a+n)
#define dsort(a)            sort(a,a+n,greater<int>())
#define vasort(v)           sort(v.begin(), v.end());
#define vdsort(v)           sort(v.begin(), v.end(),greater<int>());
#define uniquee(x)          x.erase(unique(x.begin(), x.end()),x.end())
#define pn                  printf("\n")
#define el                  cout<<endl
#define md                  1000000007
#define inf                 9e18
#define ps                  cout<<" ";
#define Pai                  acos(-1.0)
#define mem(a,i)            memset(a, i, sizeof(a))
#define pcas(i)             cout<<"Case "<<i<<": "<<endl;
#define fast 	ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)

#define N 200006

char ans[5];
ll v[5];


map<string , ll>mp;
int main()
{
     ll i , j , n, m;
     string s;
     cin>>n;


     fr(i, n)
     {
         cin>>s;
         mp[s]++;
     }

     cout<<"AC x "<<mp["AC"]<<endl;
     cout<<"WA x "<<mp["WA"]<<endl;
     cout<<"TLE x "<<mp["TLE"]<<endl;
     cout<<"RE x "<<mp["RE"]<<endl;



    //cout<<t<<" "<<u<<endl;
return 0;
}

/// **************************Before submit****************************

///    ****Please check all base case output  and printing " YES or NO " ***
///    *check for integer overflow,array bounds
///    *check for n=1




Measured memory_bytes: 3632
chomp($k = <STDIN>);
($a, $b) = split(/ /, <STDIN>);
$i = int($a / $k);
if($a % $k != 0){
	$t = $k * ($i + 1);
}else{
	$t = $k * $i;
}

if($t <= $b){
	print "OK\n";
}else{
	print "NG\n";
}

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

typedef long long ll;
const ll INF = 1e18;
const int BIG = 1e9 + 555;

ll a, b;

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

	cin >> a >> b;
	if((a + b) % 2 != 0){
		cout << "IMPOSSIBLE\n";
		return 0;
	}

	ll k = (a + b) / 2;
	cout << k << '\n';
	return 0;
}

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

using namespace std;
using ll = long long;

int main() {
    int n,k = 0;
    cin >> n >> k;
    vector<ll> v(n);
    for(int i = 0;i < n;i++){
        cin >> v[i];
    }
    ll sum = 0;
    sort(v.begin(),v.end());
    for(int i = n - 1;i >= 0;i--){
        if(k > 0){
            k--;
            continue;
        }
        sum += v[i];
    }

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

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

const int N = 1e5+5;
const long M = 1e9+7;

int n;
int arr[N];
int cnt[N];

long frac[N], ifrac[N];

long powMod(long a, long b) {
    long ret = 1;
    for(; b; b >>= 1) {
        if(b & 1) ret = ret * a % M; 
        a = a * a % M;
    }
    return ret;
}

void init() {
    frac[0] = ifrac[0] = 1;
    for(int i = 1; i <= n+1; ++i) {
        frac[i] = frac[i-1] * i % M;
        ifrac[i] = powMod(frac[i], M-2);
    }
}

long choose(long n, long r) {
    if(r < 0 || r > n) return 0;
    long v = frac[n] * ifrac[r] % M;
    return v * ifrac[n-r] % M;
}

int main() {
    scanf("%d", &n);
    init();
    for(int i = 1; i <= n+1; ++i) {
        scanf("%d", arr+i);
        cnt[arr[i]]++;
    }
    int v = -1;
    for(int i = 1; i <= n; ++i) if(cnt[i] == 2) v = i;
    int cnt = 0;
    for(int i = 1; i <= n+1; ++i) {
        if(arr[i] == v) break;
        else cnt++;
    }
    for(int i = n+1; i >= 1; --i) {
        if(arr[i] == v) break;
        else cnt++;
    }
    for(int i = 1; i <= n+1; ++i) {
        printf("%lld\n", (choose(n+1, i) - choose(cnt, i-1) + M) % M);
    }    
}

Measured memory_bytes: 3584
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

MOD = 10 ** 9 + 7

N = int(readline())
X = np.array(read().split(),np.int64)

def cumprod(A, MOD = MOD):
    L = len(A); Lsq = int(L**.5+1)
    A = np.resize(A, Lsq**2).reshape(Lsq,Lsq)
    for n in range(1,Lsq):
        A[:,n] *= A[:,n-1]; A[:,n] %= MOD
    for n in range(1,Lsq):
        A[n] *= A[n-1,-1]; A[n] %= MOD
    return A.ravel()[:L]
def make_fact(U, MOD = MOD):
    x = np.arange(U, dtype = np.int64); x[0] = 1
    fact = cumprod(x, MOD)
    x = np.arange(U, 0, -1, dtype=np.int64); x[0] = pow(int(fact[-1]), MOD-2, MOD)
    fact_inv = cumprod(x, MOD)[::-1]
    return fact,fact_inv

U = 10 ** 5 + 5
fact, fact_inv = make_fact(U)

inv = np.zeros(U,np.int64)
inv[1:] = fact_inv[1:] * fact[:-1] % MOD

coef = inv[1:N].cumsum() % MOD

answer = (np.diff(X) * coef % MOD).sum() % MOD
answer *= fact[N-1]; answer %= MOD

print(answer)

Measured memory_bytes: 19492
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<ll, II> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 1010;
const int MAXM = 110;
const int MAXK = 510;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    char x;
    cin >> x;
    if (x == 'A') cout << 'T';
    else if (x == 'T') cout << 'A';
    else if (x == 'G') cout << 'C';
    else if (x == 'C') cout << 'G';
    return 0;
}

Measured memory_bytes: 256
// 

#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <ios>
#include <iomanip>
#include <string>
#include <numeric>

using namespace std;

int main() {
    int N;
    cin >> N;

    int tmp1, tmp2;
    cin >> tmp1 >> tmp2;

    int max;
    int maxIndex;
    int quasiMax;

    if (tmp1 > tmp2) {
        max = tmp1;
        maxIndex = 0;
        quasiMax = tmp2;
    } else {
        max = tmp2;
        maxIndex = 1;
        quasiMax = tmp1;
    }

    for (int i = 2; i < N; i++) {
        cin >> tmp1;
        if (max <= tmp1) {
            maxIndex = i;
            quasiMax = max;
            max = tmp1;
        } else if (quasiMax <= tmp1 && tmp1 < max) {
            quasiMax = tmp1;
        }
    }

    for (int i = 0; i < N; i++) {
        if (i == maxIndex) {
            cout << quasiMax << endl;
        } else {
            cout << max << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 1664
N=int(input())
ls=[0 for _ in range(N)]
for i in range(N):
  a,b=[int(s) for s in input().split()]
  if a==b:
    ls[i]=1
for i in range(N-2):
  if ls[i]==1 and ls[i+1]==1 and ls[i+2]==1:
    print('Yes')
    break
else:
  print('No')
  

Measured memory_bytes: 9188
#include <bits/stdc++.h>
using namespace std;
typedef  long long int ll;
#define pb                push_back
#define all(x)            (x).begin(),(x).end()
#define M                 1000000007
#define MM                998244353
#define ff                first
#define ss                second
#define pii               pair<int,int>
#define mii               map<int,int>
#define psi               pair<string,int>
#define pis               pair<int,string>
#define endl              "\n"
#define GCD(x,y)          (__gcd((x), (y)))
#define LCM(x,y)          (((x)/__gcd((x), (y)))*(y))
#define mem0(x)           memset(x, 0, sizeof (x))
#define mem1(x)           memset(x, -1, sizeof (x))
#define IOS ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);
//coded by Avijit Mandal 18CS30010
int main(){
   ll i,j,n,k,t1,t2,count=0,mx=INT_MIN,mn=INT_MAX;
   cin>>n;
   ll a[n+1],b[n+1],c[n+1],dp[n+1],as[n+1],bs[n+1],cs[n+1];
   for(i=1;i<=n;i++)cin>>as[i]>>bs[i]>>cs[i];
   a[1]=as[1],b[1]=bs[1],c[1]=cs[1];
   dp[1]=max(max(a[1],b[1]),c[1]);
   for(i=2;i<=n;i++){
      a[i]=as[i]+max(b[i-1],c[i-1]);
      b[i]=bs[i]+max(a[i-1],c[i-1]);
      c[i]=cs[i]+max(a[i-1],b[i-1]);
      dp[i]=max(max(a[i],b[i]),c[i]);
   }
   cout<<dp[n]<<"\n";
   

}

Measured memory_bytes: 5760
//
//  main.cpp
//  AtCoder
//
//  Created by HappyNSC on 2016. 9. 11..
//  Copyright © 2016년 CSL. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#define max(a,b) (a>b)?a:b
#define min(a,b) (a<b)?a:b

int main(int argc, const char * argv[]) {
    int h,a,b;
    std::cin>>a>>b>>h;
    std::cout<<(a+b)*h/2;
    return 0;
}


Measured memory_bytes: 764
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a,b) ((a<b)?a:b)
#define _max(a,b) ((a<b)?b:a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a)?1:-1)
#define SORT(v) sort(v.begin(),v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380

int main() {
    cout << fixed << setprecision(10);
    int a, b;
    cin >> a >> b;
    REP(i, 20000) {
        int at = i * 0.08;
        int bt = i * 0.1;
        if (at == a && bt == b) {
            cout << i;
            return 0;
        }
    }
    cout << -1;
    return 0;
}


Measured memory_bytes: 256
d = []
5.times do
  d << gets.to_i
end

k = gets.to_i

flag = true
5.times do |i|
  5.times do |j|
    if (d[i] - d[j]).abs > k
      flag = false
    end
  end
end

if flag
  puts 'Yay!'
else
  puts ':('
end


Measured memory_bytes: 1788
#include<iostream>
#include<string>
#include<vector>
#include<unordered_map>
#include<algorithm>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<cstdlib>
#include<queue>
#include<utility> //pair
using namespace std;

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

typedef long long ll;

int main() {
	//入力;
	int x, a, b;
	cin >> x;
	if (x == 1) {
		cout << "Hello World" << endl;
		return 0;
	}
	else {
		cin >> a >> b;
		cout << a + b << endl;
	}

	//小数点以下の桁数表示;
	//cout << fixed << setprecision(15);


	return 0;
}

Measured memory_bytes: 256
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=-1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

a,b,k=get_i
if a-k<0
    k-=a
    a=0
    b-=k
else
    a-=k
end
b=0 if b<0
puts [a,b].join(" ")

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

int main()
{
	string A[32];
	int input;

	cin >> input;

	if (input == 4 || input == 6 || input == 9 || input == 10 || input == 14 || input == 21 || input == 22 || input == 25 || input == 26) {
		cout << 2;
	}
	else if (input == 30 || input == 28) {
		cout << 4;
	}
	else if (input == 8 || input == 12 || input == 18||input==20||input==27) {
		cout << 5;
	}
	else if (input == 32) {
		cout << 51;
	}
	else if (input == 24) {
		cout << 15;
	}
	else if (input == 16) {
		cout << 14;
	}
	else {
		cout << 1;
	}

	// cout << "Hello, world!" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main
{
    int n, k;
    int[] x;
    int ans;
    
    public static void main(String args[])
    {
	new Main().run();
    }
    
    void run()
    {
	in();

	for(int i = 0; i < n; i++) {
	    int a = x[i];
	    int b = Math.abs(x[i] - k);
	    if(a < b) ans += a * 2;
	    else      ans += b * 2;
	}
	
	out();
    }

    void in()
    {
	Scanner sc = new Scanner(System.in);
	n = sc.nextInt();
	k = sc.nextInt();
	x = new int[n];
	for(int i = 0; i < n; i++) x[i] = sc.nextInt();
    }

    void out()
    {
	System.out.println(ans);
    }
}


Measured memory_bytes: 23892
#include<bits/stdc++.h>
#define fastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;    
int main(){
	fastIO;  
	int n,k,ans=1;
	cin>>n>>k;
	if(k>=2){
		ans=k;
		for(int i=2;i<=n;i++){
			ans*=(k-1);		
		}
		cout<<ans<<'\n';
	}
	else{
		if(n==1)cout<<1<<'\n';
		else cout<<0<<'\n';
	}
	return 0;
}

Measured memory_bytes: 256
////////////////////////// Author
////////////////////////// Nasim Hossain Rabbi
////////////////////////// JU-CSE28
////////////////////////// CF - imnasim3.1415
////////////////////////// UVA - imnasim3.1415
////////////////////////// Mail - imnasim3.1415@gmail.com

#include<bits/stdc++.h>
using namespace std;
#define sz size()
#define mk make_pair
#define clr clear()
#define B begin()
#define E end()
#define EM empty()
#define mem(a,b) memset(a,b,sizeof(a))
#define rep(i,n) for(i=0;i<n;i++)
#define Rep(i,n) for(i=1;i<=n;i++)
#define all(cont) cont.begin(),cont.end()
#define pb push_back
#define endl '\n'
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
#define pi 3.1415926535897932384626433832795
#define vi vector<int>
#define vs vector<string>
#define vp(vi,x) cin>>x; vi.pb(x);
typedef long long int LL;
typedef unsigned long long int ULL;
int main()
{
//    fast;
    LL i,j,k,n,m,l,s=0,tc=1,c=0;
    while(cin>>n)
    {
        LL x,y;
        vector<long long int> a; bool f=1,ff=1;
        rep(i,n)
        {
            vp(a,x);
        }
        sort(all(a));
        for(i=n-1;i>0;i--)
        {
            if(a[i]==a[i-1] && f) x=a[i],i--,f=0;
            else if(a[i]==a[i-1])
            {
                y=a[i];
                ff=0;
                break;
            }
        }
        LL r=x*y;
        if(ff) cout<<"0"<<endl;
        else cout<<r<<endl;
    }
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define ld long double
#define F first
#define S second
#define pb push_back
#define pii pair <int, int>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define reunique(x) (x).resize(std::unique(all(x)) - (x).begin())
#define int long long
using namespace std;

void Solve(){
  int n;
  cin >> n;
  vector <int> a(n);
  for (int i = 0; i < n; i++){
    cin >> a[i];
  }
  int i = 0;
  int lst = 1e18, ans = -1e18;
  int cnt = 0;
  while (i < n){
    if (a[i] <= lst){
      cnt++;
    }
    else{
      ans = max(ans, cnt - 1);
      cnt = 1;
    }
    lst = a[i];
    i++;
  }
  ans = max(ans, cnt - 1);
  cout << ans;
}

signed main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  Solve();
  
  return 0;
}
/*



*/

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
  
  int N; cin >> N;
  int A[N+1];
  for(int i=0; i<N; i++) cin >> A[i+1];
  
  int64_t dp[2001][2001] = {};
  dp[0][0] = 0;
  bool checked[2001] = {};
  
  for(int i=1; i<=N; i++){
    
    int Max_num = 0;
    int64_t baby;
    
    for(int j=1; j<=N; j++){
      if(!checked[j] && A[j] > Max_num){
        Max_num = A[j];
        baby = j;
      }
    }
    
    checked[baby] = true;
    
    dp[i][0] = (int64_t) dp[i-1][0] + A[baby] * max(baby-i, i-baby);
    for(int j=1; j<i; j++){
      dp[i-j][j] = (int64_t) max(dp[i-j][j-1] + A[baby] * max(baby-(N+1-j), (N+1-j)-baby),
                                 dp[i-j-1][j] + A[baby] * max(baby-(i-j)  , (i-j)-baby  ));
    }
    dp[0][i] = (int64_t) dp[0][i-1] + A[baby] * max(baby-(N+1-i), (N+1-i)-baby);
  }
  
  int64_t ans = 0;
  for(int i=0; i<=N; i++){
    if(dp[i][N-i] > ans) ans = dp[i][N-i];
  }
  cout << ans << endl;
  
}

Measured memory_bytes: 34916
#include<stdio.h>
int main(void){
    int h,w,i,j,a;
    
    for(a=1;;a++){
    scanf("%d %d",&h,&w);
    if(h==0 && w==0) break;
    
    for(i=1;i<=h;i++){
        for(j=1;j<=w;j++){
            printf("#");
        }
        printf("\n");
    }
    printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2044
import numpy as np

n = int(input())

ans = 0

if n % 10 == 9:
    ans += 1
else:
    ans += 9
n = int(n/10)


if n % 10 == 9:
    ans += 10
else:
    ans += 90
n = int(n/10)
if n % 10 == 9:
    ans += 100
else:
    ans += 900


print(ans)

Measured memory_bytes: 21268
s = list(map(int,input().split()))
q = int(input())

while q > 0:
  top, front = map(int,input().split())
  
  if s.index(top) == 1:
    ORDER = 'N'
  elif s.index(top) == 2:
    ORDER = 'W'
  elif s.index(top) == 3:
    ORDER = 'E'
  elif s.index(top) == 4:
    ORDER = 'S'
  elif s.index(top) == 5:
    ORDER = 'SS'
  else:
    ORDER = 'R'
  
  order = list(ORDER)
  
  for i in order:
    if i == 'E':
      s[0], s[3] = s[3], s[0]
      s[3], s[5] = s[5], s[3]
      s[5], s[2] = s[2], s[5]
    elif i == 'N':
      s[0], s[1] = s[1], s[0]
      s[1], s[5] = s[5], s[1]
      s[5], s[4] = s[4], s[5]
    elif i == 'S':
      s[0], s[4] = s[4], s[0]
      s[4], s[5] = s[5], s[4]
      s[5], s[1] = s[1], s[5] 
    elif i == 'W':
      s[0], s[2] = s[2], s[0]
      s[2], s[5] = s[5], s[2]
      s[5], s[3] = s[3], s[5]
    else:
      pass
    
  if s.index(front) == 1:
    print(s[2])
  if s.index(front) == 2:  
    print(s[4])
  if s.index(front) == 3:  
    print(s[1])
  if s.index(front) == 4:
    print(s[3])
    
  q = q-1


Measured memory_bytes: 5620
import java.util.*;
public class Main {
    public static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) throws Exception {
    	int i, j, k;
    	int count = 0;
    	String w = sc.next();
    	w = w.toLowerCase();
    	while(true) {
    		String t = sc.next();
    		if(t.contains("END_OF_TEXT")) break;
    		t = t.toLowerCase();
    		if(t.equals(w)) count++;
    	}
    	System.out.println(count);
    }
}


Measured memory_bytes: 25896
#include <cmath>
#include <vector>
#include <queue>
#include <iostream>
#include <bits/stdc++.h>
#define lli long long int
#define mp make_pair
#define pb push_back
using namespace std;

const lli mod = 1e9 + 7;

lli power(lli x, lli y) {
    // x %= mod;
    if (y == 0) return 1;
    // return ((y % 2 == 1 ? x : 1) * power(x * x, y / 2)) % mod;
    return ((y % 2 == 1 ? x : 1) * power(x * x, y / 2));
}

vector <long long int> primeNumbers;

void SieveOfEratosthenes(int n){
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime));
    for (int p=2; p*p<=n; p++){ 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
    for (int p=2; p<=n; p++){
      if (prime[p]){
        primeNumbers.push_back(p);
      }
    }        
}

#define MAXN 100005
// vector < vector < int >  > v(MAXN);
// int visit[MAXN];
// int d[MAXN];
// int deg[MAXN];

// void dfs(int index, int parent){
//   visit[index] = 1;
//   for(int i = 0;i<v[parent].size();i++){
//     int node = v[parent][i];
//     if(visit[node]) continue;
//     else if (!binary_search(v[index].begin(),v[index].end(),node)){
//       visit[node] = 1;
//       dfs(node,index);
//     }
//   }
// }
void pre(){
}

void solve(){
  int n;
  cin>>n;
  long long int a[n];
  for(int i = 0;i<n;i++) cin>>a[i];

  long long int maxValuedp[n+1][n+1];
  // int minValuedp[n+1][n+1];
  memset(maxValuedp,0,sizeof(maxValuedp));
  // memset(minValuedp,0,sizeof(minValuedp));

  for(int i = 1;i<=n;i++){
    // minValuedp[i][i] = a[i-1];
    maxValuedp[i][i] = a[i-1];
  }
  // minValuedp[0][0] = 0;
  maxValuedp[0][0] = 0;

  for(int size = 2;size<=n;size++){
    for(int left = 1;left<=n - size+1;left++){
      int right = left + size - 1;
      maxValuedp[left][right] = max(-maxValuedp[left+1][right] + a[left-1],-maxValuedp[left][right-1] + a[right-1]);
      // minValuedp[left][right] = min(maxValuedp[left+1][right] - a[left-1],maxValuedp[left][right-1] - a[right-1]);
    }
  }
  // for(int i = 0;i<=n;i++){
  //   for(int j = 0;j<=n;j++){
  //     cout<<maxValuedp[i][j]<<' ';
  //   }
  //   cout<<endl;
  // }
  cout<<maxValuedp[1][n];
}
 
 
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  #ifndef ONLINE_JUDGE
      freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
  #endif
 
  int t;
  // cin>>t;
  // scanf("%d",&t);
  t = 1;
  pre();
  while(t--){
    // cout<<
    solve();
 
    if(t>0){
      cout<<endl;
      // printf("\n");
    } 
  }
 
 
  cerr << "Time : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n";
 
  return 0;
}


Measured memory_bytes: 74068
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define reps(i, n) for (int i = 1; i <= (n); ++i)
#define repd(i, n) for (int i = (n - 1); i >= 0; --i)
#define repds(i, n) for (int i = (n); i > 0; --i)
#define loop(i, x, n) for (int i = (x); i < (n); ++i)
#define loops(i, x, n) for (int i = (x); i <= (n); ++i)
#define loopd(i, x, n) for (int i = (x); i > (n); --i)
#define loopds(i, x, n) for (int i = (x); i >= (n); --i)
#define itrep(i, a) for (auto i = begin(a); i != end(a); ++i)
#define itrepd(i, a) for (auto i = rbegin(a); i != rend(a); ++i)
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using ld = long double;
template <class T>
using priority_queuel = priority_queue<T, vector<T>, greater<T>>;
constexpr ll inf = static_cast<ll>(1e18);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e18;
constexpr double eps = 1e-9;
ll mod = static_cast<ll>(1e9 + 7);
template <class T>
constexpr int sz(const T &a) { return (int)a.size(); }
template <class T>
constexpr T pow2(const T a) { return a * a; }
template <class T, class... Args>
constexpr void mins(T &a, Args... args) { a = min<T>({a, args...}); }
template <class T, class... Args>
constexpr void maxs(T &a, Args... args) { a = max<T>({a, args...}); }
template <class A, int N, class T>
void fillArray(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }

int n;
pair<ll, int> a[100005];
void solve() {
    cin >> n;
    rep(i, n) {
        cin >> a[i].first;
        a[i].second = i;
    }
    sort(a, a + n, greater<>());
    set<int> s;
    s.insert(-1);
    s.insert(n);
    ll ans = 0;
    rep(i, n) {
        auto p = s.insert(a[i].second).first;
        auto l = p;
        --l;
        auto r = p;
        ++r;
        if (l != s.begin()) {
            auto l2 = l;
            --l2;
            ans += a[i].first * (*l - *l2) * (*r - *p);
        }
        if (r != --s.end()) {
            auto r2 = r;
            ++r2;
            ans += a[i].first * (*p - *l) * (*r2 - *r);
        }
    }
    cout << ans << endl;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


Measured memory_bytes: 6528
#include<stdio.h>

int main(void){
    int n=0;
    int sen=0;
    int hyaku=0;
    int juu=0;
    int ichi=0;
    scanf("%d",&n);
    sen=n/1000;
    n=n-sen*1000;
    hyaku=n/100;
    n=n-hyaku*100;
    juu=n/10;
    n=n-juu*10;
    ichi=n;
    if(sen==hyaku&&hyaku==juu){
        printf("Yes\n");
    }
    else if(hyaku==juu&&juu==ichi){
        printf("Yes\n");
    }
    else printf("No\n");  
    
return 0;
}

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

int main() {
int N;
int a[200];  
cin >> N;
for (int i = 0; i < N; ++i) cin >> a[i];
sort(a, a + N, greater<int>());  
int Alice = 0;
int Bob = 0;
for (int i = 0; i < N; ++i) {
if (i % 2 == 0) { 
Alice += a[i];
        }
        else { 
            Bob += a[i];
        }
    }
    cout << Alice - Bob << endl;
}

Measured memory_bytes: 768
fun main(args: Array<String>) {

    val n = readLine()!!.toInt()

    var ans = 0
    for (i in n..999) {
        val c = i.toString()
        if (c[0] == c[1] && c[1] == c[2]){
            ans = i
            break
        }
    }

    println(ans)
}

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

#define int long long
#define uint unsigned long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end());
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint=vector<int>;
using vvint=vector<vint>;
using pint=pair<int, int>;
using vpint=vector<pint>;
template<typename T> using priority_queue_rev=priority_queue<T, vector<T>, greater<T>>;
constexpr double pi = 3.1415926535897932384626433832795028;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T1, typename T2> bool chmax(T1 &a, const T2 &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> bool chmin(T1 &a, const T2 &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct Setup {
    static constexpr int PREC = 20;
    Setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

signed main() {
    int R, G, B, N;
    cin >> R >> G >> B >> N;
    int ans = 0;
    for (int i = 0; i <= N; i += R) {
        for (int j = 0; j <= N; j += G) {
            int k = N - i - j;
            if (k < 0 || k % B != 0) { continue; }
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <cassert>
#include <random>

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

using namespace std;
typedef long long int ll;
const ll INF = 10000000000;
const double PI = acos(-1);
const ll mod = 1000000007;

int main()
{
    int n;
    cin >> n;
    vector<char> c(n);
    rep(i, n) cin >> c[i];

    bool is_ok = true;
    bool is_white = false;
    rep(i, n) {
        if (c[i] == 'W') is_white = true;
        if (is_white && c[i] == 'R') is_ok = false;
    }

    if (is_ok) {
        cout << 0 << endl;
        return 0;
    }

    int w_idx = 0;
    int r_idx = n - 1;
    int ans = 0;
    while (true) {
        if (w_idx < n) {
            while (c[w_idx] == 'R') {
                w_idx++;
                if (w_idx >= n) break;
            }
        }
        if (r_idx >= 0) {
            while (c[r_idx] == 'W') {
                r_idx--;
                if (r_idx < 0) break;
            }
        }
        if (w_idx >= r_idx) break;
        ans++;
        w_idx++;
        r_idx--;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

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

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

int main(){
    int n, m; cin>>n>>m;
    vector<int> imos(n+10, 0);
    for(int i=0; i<m; i++){
        int a, b; cin>>a>>b;
        if(a>b) swap(a, b);
        imos[a]++, imos[b]--;
    }

    bool can_make=true;
    for(int i=1; i<n; i++){
        imos[i]+=imos[i-1];
        if(imos[i]%2!=0) can_make=false;
    }

    cout << (can_make?"YES":"NO") << endl;
}

Measured memory_bytes: 640
### subroutines

def lower_bound(arr, key, i0 = 0, i1 = arr.length)
  lb = i0 - 1
  ub = i1

  while lb + 1 < ub
    m = (lb + ub) / 2
    if arr[m] <= key
      lb = m
    else
      ub = m
    end
  end
  lb
end

### main

loop do
  d = gets.strip.to_i
  break if d == 0

  n = gets.strip.to_i
  m = gets.strip.to_i

  di = [0, d]
  for i in (2..n)
    di << gets.strip.to_i
  end
  di.sort!
  #p di

  ks = m.times.map{gets.strip.to_i}
  total = 0

  for k in ks
    pos = lower_bound(di, k)
    #p [k, pos]
    total += [k - di[pos], di[pos + 1] - k].min
  end

  puts total
end

Measured memory_bytes: 7316
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long A, B, C, G;
  cin >> A >> B;
  C = min(A, B);
  for (int i = 0; i < C; i++) {
    if (A % (C - i) == 0) {
      if (B % (C - i) == 0) {
        G = C - i;
        break;
      }
    }
  }
  cout << (A / G) * B << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
 
#define mod 1000000007
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define long long long
inline int rei(){int x;cin>>x;return x;}
inline long rel(){long x;cin>>x;return x;}
inline string res(){string x;cin>>x;return x;}
//------------------------------------------------------- 
int A[1000000];
int B[1000000];
void Calc(){
	int N = rei();
	int M = rei();
	for(int i=0;i<N;i++){
		int a = rei()-1;
		A[a]++;
	}
	for(int i=0;i<M;i++){
		int b = rei()-1;
		B[b]++;
	}
	int n = 0;
	int m = 0;
	int nm = 0;
	long ans = 1;
	for(int i=N*M-1;i>=0;i--){
		if(A[i] > 1 || B[i] > 1){
			cout << "0" << endl;
			return;
		}
		if(A[i] == 1 && B[i] == 1){
			nm += n + m;
			n++;
			m++;
		}
		else if(A[i] == 1){
			ans *= m;
			ans %= mod;
			nm += m-1;
			n++;
		}
		else if(B[i] == 1){
			ans *= n;
			ans %= mod;
			nm += n-1;
			m++;
		}
		else{
			ans *= nm;
			ans %= mod;
			nm--;
		}
	}
	cout << ans << endl;
}
int main(int argc,char** argv){
	ios::sync_with_stdio(false), cin.tie(0);
	cout.tie(0); Calc(); return 0;
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
typedef long long ll;
const ll inf = 1e9;

int main(){
    int n; cin >> n;
    int m = 0;
    int p[] = {25, 10, 5, 1};
    rep(i,4){
        m += n / p[i];
        n %= p[i]; 
    }
    cout << m << endl;
    return 0;
}


Measured memory_bytes: 3096
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cstring>
#include <vector>
#include <stack>
#include <deque>
#include <queue>
#include <cstdlib>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
typedef long long int ll;
#define forn for(int i=0;i<n;i++) 
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define form for(int j=0;j<m;j++) 
#define fora(i,a,b) for(int i = a; i < (b); i++)
#define pb push_back 
#define mp make_pair 
#define sc second 
#define f first 
#define kek cout<<"\n" 
#define all(v) ((v).begin()), ((v).end()) 
#define pob pop_back() 
const ll MOD = 1e9 + 7;
const int N = 1005;
const ll INF = 1e9;
using namespace std;
int main()
{
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	fast;
	//string al = "abcdefghijklmnopqrstuvwxyz";
	int a, b;
	cin >> a >> b;
	double cnt = 0;
	while (true)
	{
		cnt++;
		int k = cnt*0.08;
		int t = cnt*0.1;
		if (k == a && t == b)
		{
			cout << cnt;
			return 0;
		}
		if (k > a || t > b)
		{
			cout << -1;
			return 0;
		}
	}

}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
 
using namespace std;
 
int main(void)
{
  int a, b;
  cin >> a >> b;
  vector<string> s(a);
  for(int i = 0;i < a; i++)
    cin >> s[i];
  
  sort(s.begin(),s.end());
  
  for(int i=0;i<a;i++)
    cout << s[i];
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>

int main() {
	int n;
	std::cin >> n;

	int a[3];
	std::cin >> a[0];
	for (int i = 0; i < n - 1; i++) {
		std::cin >> a[1];
		while (a[1] != 0) {
			a[2] = a[0] % a[1];
			a[0] = a[1];
			a[1] = a[2];
		}
	}

	printf("%d\n", a[0]);
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    ll N;
    cin >> N;
    vector<ll> p(N);
    for (ll i = 0; i < N; i++) {
        cin >> p[i];
    }
    ll m = *max_element(p.begin(), p.end());
    ll s = accumulate(p.begin(), p.end(), (ll)0);
    cout << s - m / 2 << endl;
}

Measured memory_bytes: 256