akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 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 f(int x) {
    int res = 0;
    while (x%2 == 0) {
        x /= 2;
        res++;
    }
    return res;
}

int main() {
	int n, m;
	cin >> n >> m;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    rep(i,n) {
        if (a[i]%2 ==1) {
            cout << 0 << endl;
            return 0;
        }
        a[i] /= 2;
    }

    int t = f(a[0]);
    rep(i,n) {
        if (f(a[i]) != t) {
            cout << 0 << endl;
            return 0;
        }
        a[i] >>= t; // a[i] /= 2^t
    }
    m >>=t;

    ll l = 1;
    rep(i,n) {
        l = lcm(l, a[i]);
        if (l > m) {
            cout << 0 << endl;
            return 0;
        }
    }
    m /= l;
    int ans = (m+1)/2;
	cout << ans << endl;
	return 0;
}


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

const int maxn=(1<<21)-1,mod=1e9+7;
int n;
int a[32][32];
int dp[maxn+5];
int tmp[32];

int lowbit(int x){
	return x&(-x);
}

int main(){
	cin>>n;
	for(int i=0;i<n;++i){
		for(int j=0;j<n;++j){
			cin>>a[i][j];
			if(a[i][j]) tmp[i]|=(1<<j);
		}
	}
	dp[0]=1;
	for(int i=1;i<(1<<n);++i){
		int cnt=-1;
		int tt=i;
		while(tt) tt&=(tt-1),cnt++;
		tt=tmp[cnt];
		while(tt){
			int n_ow=lowbit(tt);
			tt=tt^n_ow;
			if((n_ow|i)==i) dp[i]+=dp[i^n_ow],dp[i]%=mod;
		}
	}
	cout<<dp[(1<<n)-1]<<"\n";
	return 0;
}

Measured memory_bytes: 8448
A, B, C, D = map(int, input().split())

import fractions
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)
div_c = B // C
div_d = B // D
cd = lcm(C, D)
div_cd = B // cd
B_ = B - (div_c + div_d - div_cd)

A -= 1
div_c2 = A // C
div_d2 = A // D
div_cd2 = A // cd
A_ = A - (div_c2 + div_d2 - div_cd2)

print(B_ - A_)

Measured memory_bytes: 5460
d, g = map(int, input().split())
pc = [list(map(int, input().split())) for i in range(d)]

ans = float("inf")

for bit in range(1 << d):
    count = 0
    sum = 0
    nokori = set(range(1, d + 1))

    for i in range(d):
        if bit & (1 << i):
            sum += pc[i][0] * (i + 1) * 100 + pc[i][1]
            count += pc[i][0]
            nokori.discard(i + 1)

    # G 点に満たなければ nokori のうち一番大きいものを解く
    if sum < g:
        use = max(nokori)
        n = min(pc[use - 1][0], -(-(g - sum) // (use * 100)))
        count += n
        sum += n * use * 100

    if sum >= g:
        ans = min(ans, count)

print(ans)

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

int main() {

    int P, Q, R;

    std::cin >> P >> Q >> R;

    int min1 = P+Q;
    int min2 = P+R;
    int min3 = Q+R;
    int ans = std::min(std::min(min1, min2), min3);

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl			"\n"
#define ll				long long
#define all(v)			((v).begin()), ((v).end())
#define sz(v)			((int)((v).size()))
#define clr(v, d)		memset(v, d, sizeof(v))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)
#define vi				vector <int>
#define vl				vector <ll>
#define ii				pair <ll,ll>
#define vii				vector <ii>
#define ull				unsigned long long
const double PI = 2 * acos(0.0);
void run() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr), cout.tie(nullptr);
}
const int M = 1e5;
int n;
vi v;
int dp[M + 9];
int sol(int i) {
	if (i > n)
		return 1e9;
	if (i == n)
		return 0;
	int &ret = dp[i];
	if (~ret)
		return ret;
	return ret = min(sol(i + 1) + abs(v[i] - v[i + 1]),
	        sol(i + 2) + abs(v[i] - v[i + 2]));
}
int main() {
	run();
	cin >> n;
	v.resize(n);
	lp(i,n)
		cin >> v[i];
	v.push_back(v.back());
	clr(dp, -1);
	cout << sol(0);
	return 0;
}



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


Measured memory_bytes: 4776
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main()
{
  ll N;
  cin >> N;
  vector<ll> P(N);
  for (int i=0; i<N; i++){
    cin >> P[i];
  }
  vector<ll> Q(N);
  for (int i=0; i<N; i++){
    cin >> Q[i];
  }
 
  vector<ll> v(N, 0);
  for (int i=0; i<N; i++) {
    v[i] = i+1;
  }
 
  ll a = 0, b = 0;
  ll i = 0;
  do {
    i++;
    if (v == P) a = i;
    if (v == Q) b = i;
  } while (next_permutation(v.begin(), v.end()));
  cout << abs(a-b) << endl;
 
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <functional>
#include <iostream>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
int t[100001],a[100001];
int l[100001],r[100001];
int main(void){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&t[i]);
	}
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	l[0]=t[0];
	r[0]=t[0];
	bool flag=true;
	for(int i=1;i<n;i++){
		if(t[i-1]<t[i]){
			l[i]=t[i];
			r[i]=t[i];
		}else if(t[i-1]==t[i]){
			l[i]=1;
			r[i]=t[i];
		}else flag=false;
	}
	if(l[n-1]>a[n-1] || r[n-1]<a[n-1])flag=false;
	l[n-1]=a[n-1];
	r[n-1]=a[n-1];
	for(int i=n-2;i>=0;i--){
		if(a[i+1]<a[i]){
			if(l[i]>a[i] || r[i]<a[i])flag=false;
			l[i]=a[i];
			r[i]=a[i];
		}else if(a[i+1]==a[i]){
			l[i]=max(1,l[i]);
			r[i]=min(a[i],r[i]);
		}else flag=false;
	}
	ll cnt=1;
	for(int i=0;i<n;i++){
		ll sa=r[i]-l[i];
		if(sa<0)flag=false;
		else{
			sa=sa+1LL;
			cnt=cnt*sa%MOD;
		}
	}
	printf("%lld\n",flag?cnt:0);
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <math.h>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

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

typedef long long lint;

using namespace std;

int main(){
  int n;
  cin>>n;
  int a[n];
  REP(i,n)cin>>a[i];
  for(int i=n-1;i>=0;i-=2)cout<<a[i]<<" ";
  for(int i=n%2;i<n;i+=2)cout<<a[i]<<" ";
  cout<<endl;
  return 0;
}


Measured memory_bytes: 2944
import collections
n = int(input())
v = list(map(int, input().split()))
even = []
odd = []
for i in range(n):
    if i % 2 == 0:
        even += [v[i]]
    else:
        odd += [v[i]]
even_dict = collections.Counter(even)
odd_dict = collections.Counter(odd)
max_even = max(even_dict.items(), key = lambda x:x[1])
max_odd = max(odd_dict.items(), key = lambda x:x[1])
#最高の値が同じでない
if max_even[0] != max_odd[0]:
    print(len(even) - max_even[1] + len(odd) - max_odd[1])
else:
    #同じだった場合
    if max_even[1] == len(even) and max_odd[1] == len(odd):
        second_even = (-1,0)
        second_odd = (-1,0)
    elif max_even[1] == len(even):
        second_even = (-1,0)
        second_odd = max([i for i in odd_dict.items() if i != max_odd], key = lambda x:x[1])
    elif max_odd[1] == len(odd):
        second_even = max([i for i in even_dict.items() if i != max_even], key = lambda x:x[1])
        second_odd = (-1,0)
    else:
        second_even = max([i for i in even_dict.items() if i != max_even], key = lambda x:x[1])
        second_odd = max([i for i in odd_dict.items() if i != max_odd], key = lambda x:x[1])
    #二つ目に大きいやつも同じかどうか
    if second_even[1] > second_odd[1]:
        print(len(even) - second_even[1] + len(odd) - max_odd[1])
    else:
        print(len(even) - max_even[1] + len(odd) - second_odd[1])




Measured memory_bytes: 19032
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0; i<(int)n; i++)
#define REPR(i, n) for(int i=(int)n-1; i>=0; i--)
#define FOR(i, m, n) for(int i=(int)m; i<(int)n; i++)
#define FORR(i, m, n) for(int i=(int)m-1; i>=(int)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
typedef long long ll;
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }


const string NO = "IMPOSSIBLE";

void solve(long long A, long long B){
	ll K = (abs(A)+abs(B)) / 2;
	if (abs(A-K) == abs(B-K)) cout << K << "\n";
	else cout << NO << "\n";
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 256
S = input()

B_num = S.count("B")
W_num = S.count("W")

B_start = W_num # 一番左のBがいていいindex

res = 0
for i in range(B_start + 1):
    if i == len(S):
        break
    if S[i] == "B":
        res += B_start - i
        B_start += 1
        while(B_start < len(S) and S[B_start] == "B"):
            B_start += 1

print(res)

Measured memory_bytes: 3500
#include<iostream>
#include<string>
#include<vector>
#include <algorithm>
using namespace std;
int main() {
    int N;
    cin >> N;
    vector<int> L(N);
    for(int i=0;i<N;i++){
        int l;
        cin >> l;
        L.at(i) = l;
    }
    int count = 0;
    bool judge = false;
    for(int i=0;i<N-2;i++){
        for(int j=i+1;j<N-1;j++){
            for(int l=j+1;l<N;l++){
                if( ( ( (L.at(i)) != (L.at(j)) ) && ( (L.at(i) )!= ( L.at(l) ) ) )&&( (L.at(j) ) != ( L.at(l)) ) ){
                    vector<int> L_1(3);
                    L_1.at(0) = (L.at(i));
                    L_1.at(1) = (L.at(j));
                    L_1.at(2) = (L.at(l));
                    sort(L_1.begin(), L_1.end());
                    if((L_1.at(0) + L_1.at(1))>(L_1.at(2))){
                        count = count + 1;
                    }
                }
            }
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 3628
///Energy Drink Collector
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize (2)
#pragma G++ optimize (2)
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define wuyt main
typedef long long ll;
#define HEAP(...) priority_queue<__VA_ARGS__ >
#define heap(...) priority_queue<__VA_ARGS__,vector<__VA_ARGS__ >,greater<__VA_ARGS__ > >
template<class T> inline T min(T &x,const T &y){return x>y?y:x;}
template<class T> inline T max(T &x,const T &y){return x<y?y:x;}
//#define getchar()(p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2) ? EOF : *p1++)
//char buf[(1 << 21) + 1], *p1 = buf, *p2 = buf;
ll read(){ll c = getchar(),Nig = 1,x = 0;while(!isdigit(c) && c!='-')c = getchar();
if(c == '-')Nig = -1,c = getchar();
while(isdigit(c))x = ((x<<1) + (x<<3)) + (c^'0'),c = getchar();
return Nig*x;}
#define read read()
const ll inf = 1e15;
const int maxn = 2e5 + 7;
const int mod = 1e9 + 7;
#define start int wuyt()
#define end return 0
struct node{
    ll a;
    ll b;
}cnt[maxn];
bool cmp(node x,node y){
    return x.a<y.a;
}
ll n,m,ans,sum;
start{
    n=read,m=read;
    for(int i=1;i<=n;i++)
    {
        cnt[i].a=read;
        cnt[i].b=read;
    }
    sort(cnt+1,cnt+1+n,cmp);
    for(int i=1;i<=n;i++)
    {
        if(sum+cnt[i].b>=m){
            ans+=cnt[i].a*(m-sum);
            break;
        }
        else{
            sum+=cnt[i].b;
            ans+=cnt[i].a*cnt[i].b;
        }
    }
    printf("%lld\n",ans);
	end;
}


Measured memory_bytes: 1792
// A.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>

using namespace std;

int main(int argc, char *argv[]) {
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	bool ans = a[0] == a[1] && a[1] == a[2];
	cout << (ans ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3

S = input()
Q = int(input())

reverse = False

mae = []
ushiro = []

for i in range(Q):
    query = input()
    if query == "1":
        reverse = not reverse

    else:
        a,b,c = list(query.split())
        if (b == "1" and not reverse) or (b == "2" and reverse):
            mae.append(c)
        else:
            ushiro.append(c)

if reverse:
    origin = [S[::-1]]
    ans = ushiro[::-1]
    ans.extend(origin)
    ans.extend(mae)
    print(''.join(ans))
else:
    ans = mae[::-1]
    origin = [S]
    ans.extend(origin)
    ans.extend(ushiro)
    print(''.join(ans))


Measured memory_bytes: 7280
use scanner::Scanner;
use std::cmp::max;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.read();
    let mut a = 1u64;
    let mut b = 1u64;
    let mut ans = 1;
    for _ in 0..n {
        let x: u64 = sc.read();
        let y: u64 = sc.read();
        ans = max(if a % x == 0 { a / x } else { a / x + 1 }, if b % y == 0 { b / y } else { b / y + 1 });
        a = ans * x;
        b = ans * y;
    }
    println!("{}", a + b);
}

mod scanner {
    pub struct Scanner<'a> {
        s: String,
        words: ::std::str::SplitWhitespace<'a>,
    }

    impl<'a> Scanner<'a> {
        pub fn new() -> Scanner<'a> {
            let s = String::new();
            let words = unsafe { ::std::mem::transmute(s.split_whitespace()) };
            Scanner { s: s, words: words }
        }

        pub fn read<T: ::std::str::FromStr>(&mut self) -> T {
            match self.words.next() {
                Some(x) => x.parse().ok().unwrap(),
                None => {
                    self.load();
                    self.read()
                }
            }
        }

        fn load(&mut self) {
            self.s.clear();
            ::std::io::stdin().read_line(&mut self.s).unwrap();
            self.words = unsafe { ::std::mem::transmute(self.s.split_whitespace()) };
        }
    }
}


Measured memory_bytes: 4352
#include<iostream>
#include<algorithm>
using namespace std;
#define mod 1000000007

int totpath(char **mat,int r,int c)
    {
        int res[r][c];
        int f=1;
        //cout<<mat[0][c-1]<<"\n";
        for(int i=r-1;i>=0;i--)
          {
              if(mat[i][c-1]=='#')
                   {
                       f=0;
                       res[i][c-1]=0;
                       //cout<<res[i][c-1];
                       continue;
                   }
              if(f)       
                 res[i][c-1]=1;
              else
                 res[i][c-1]=0;
              //cout<<res[i][c-1];     
          }
        //cout<<"\n";  
        f=1;  
        for(int i=c-1;i>=0;i--)
          {
              if(mat[r-1][i]=='#')
                   {
                       f=0;
                       res[r-1][i]=0;
                       //cout<<res[r-1][i];
                       continue;
                   }
              if(f)       
                 res[r-1][i]=1;
              else
                 res[r-1][i]=0;
              //cout<<res[r-1][i];     
          }
        //cout<<"\n";  
        for(int i=r-2;i>=0;i--)
         {
             for(int j=c-2;j>=0;j--)
              {
                  if(mat[i][j]=='#')
                     res[i][j]=0;
                  else
                     res[i][j]=(res[i+1][j]+res[i][j+1])%mod;
                  //cout<<res[i][j];     
              }
             //cout<<"\n"; 
         }
        return res[0][0]; 
    }

int main()
   {
       int n,m;
       cin>>n>>m;
       char **mat=new char*[n];
       for(int i=0;i<n;i++)
          mat[i]=new char[m];
       for(int i=0;i<n;i++)
          for(int j=0;j<m;j++)
              cin>>mat[i][j];
       cout<<totpath(mat,n,m);        
   }

Measured memory_bytes: 5120
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, s, n) for (int i = (s); i < (n); ++i)
#define rrep(i, n, g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define len(x) (int)(x).size()
#define dup(x, y) (((x) + (y)-1) / (y))
#define pb push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int x, a, b;
  cin >> x >> a >> b;
  if (abs(x - a) > abs(x - b))
    cout << "B" << endl;
  else
    cout << "A" << endl;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
#define int long long
#define f(i,n) for(int i=0;i<(n);i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
signed main(){
	int a,b,c;
	cin>>a>>b>>c;
	cout<<max((int)(0),(b+c)-a)<<endl;
	return 0;
}


Measured memory_bytes: 256
// J'aime
// Chemise Blanche

#include <bits/stdc++.h>
using namespace std;

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr << __LINE__ << " > " << #x << " = " << (x) << endl

void MAIN() {
  int a; string s;
  cin >> a >> s;
  if (a < 3200) cout << "red" << '\n';
  else cout << s << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


Measured memory_bytes: 3520
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
    // Write Your Code Below
   ll a, b;
   cin >> a >> b;
   cout << fixed <<setprecision(10);
   double x; x = 1/double(a) + 1/double(b);
   double ans; ans = 1/double(x);
    cout << ans << endl; 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
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() {
    string a,b;cin>>a>>b;
    string c=a+b;
    int d=stoi(c);
    int e=sqrt(d);
    if(d==e*e){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n;
int main()
{
    scanf("%lld",&n);
    ll ans=0;
    for(ll i=2;i*i<=n;i++)
        if(n%i==0)
        {
            ll tot=0;
            while(n%i==0) n/=i,tot++;
            ll t=1;
            while(tot>=t)
                tot-=t,t++,ans++;
        }
    if(n>1) ans++;
    printf("%lld\n",ans);
}


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


int main() {
   string move; 
   int x = 0;
   int i = 0;

   while(cin){
    cin >> move[i];
    i++;
   }
   
   for(int j = 0; j < i; j++){
    if(j%2==0 && move[j] =='L'){
        x++;
    }
    if(j%2==1 && move[j]=='R'){
        x++;
    }
   }

   if(x > 0){
       cout << "No" << endl;
   }
   else{
       cout << "Yes" << endl;
   }
}

Measured memory_bytes: 256
inputs = raw_input().replace("\n", "").split(" ")
N, K = map(int, inputs)
r = N // K 
q = N % K 

n_0_a = r

if K % 2 == 0:
    half_K = K / 2
    hasuu = 1 if half_K <= q else 0
    n_k_2_a = r + hasuu
else:
    n_k_2_a = 0

out = (n_0_a ** 3) + (n_k_2_a ** 3)
print out

Measured memory_bytes: 2568
h,w=map(int,input().split())
a=[input() for i in range(h)]
mod=10**9+7
d=[[0]*w for i in range(h)]
d[0][0]=1
for i in range(h):
    for j in range(w):
        if i+1<h and a[i+1][j]==".":
            d[i+1][j]+=d[i][j]
            d[i+1][j]%=mod
        if j+1<w and a[i][j+1]==".":
            d[i][j+1]+=d[i][j]
            d[i][j+1]%=mod
print(d[-1][-1])

Measured memory_bytes: 43712
// c
#include <iostream>
#include <set>
using namespace std;
int n,x;
int main()
{
    cin>>n;
    set<int>s;
    for(int i=0;i<n;++i){
        cin>>x;
        s.insert(x);
    }if(s.size()!=n)cout<<"NO"<<endl;
    else cout<<"YES"<<endl;

    return 0;
}


Measured memory_bytes: 9600
def ascend(a,b):
    mini = min(A[a:a+L])
    ans[a] = mini
    for i in range(a+1,b):
        if A[i+L-1] <= mini : mini = A[i+L-1]
        elif A[i-1] == mini : mini = min(A[i:i+L])
        ans[i] = mini

def descend(a,b):
    mini = min(A[b-1:b+L-1])
    ans[b-1] = mini
    for i in range(b-2,a-1,-1):
        if A[i] <= mini : mini = A[i]
        elif A[i+L] == mini: mini = min(A[i:i+L])
        ans[i] = mini
    
[N,L] = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
ans = [None]*(N-L+1)
count = 0;
if N > 10 ** 4:
    for i in range(100):
        if A[i+1] > A[i] : count += 1
    if count > 80 : descend(0, N-L+1)
    else : ascend(0,N-L+1)
else :
    ascend(0, N-L+1)
for i in ans[:-1] : print(i, end=" ")
print(ans[-1])

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

int main()
{
    int n;
    int a[10005];
    int ans = 0;

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

    for (int i = 0; i < n; i++) {

        int cnt = 0;
        while(a[i] % 2 == 0) {
            cnt++;
            a[i] /= 2;
        }

        ans += cnt;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.Scanner;

class Main {
    private static void solve() {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();

        for (int i = 0; i < n; i++) {
            BigInteger a = new BigInteger(scanner.next());
            BigInteger b = new BigInteger(scanner.next());
            BigInteger sum = a.add(b);
            if (sum.toString().length() > 80) {
                System.out.println("overflow");
            } else {
                System.out.println(sum);
            }
        }
    }

    public static void main(String... args) {
        solve();
    }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
#define vi vector<ll>
#define vpi vector<pair<ll,ll> >
#define mpi map<ll,ll>
#define  si set<ll>
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define reP(i,a,n) for(ll i=a;i<=n;i++)
#define YES cout<<"YES\n";
#define NO cout<<"NO\n";
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define st string
#define sz size()
#define case(i,n) Case<<" "<<i<<": "<<n<<endl;
#define tc ll t;cin>>t;while(t--)
int main()
{
    ll n;
    cin>>n;
    ll ara[n+1],sum=0;
    memset(ara,0,sizeof(ara));
    for(ll i=1; i<=n; i++)
    {
        for(ll j=i; j<=n; j+=i)
        {
            ara[j]++;
        }

    }
    for(ll i=1; i<=n; i++)
        sum+=(i*ara[i]);


    cout<<sum<<endl;

}


Measured memory_bytes: 81740
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////
#define R(i,n) for(int i=0;i<(n);++i)
/////////
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
template<typename T>
void chmax(T& a, T b) {
	a = max(a, b);
}

template<typename T>
void chmin(T& a, T b) {
	a = min(a, b);
}

template<typename T>
void IN(vector<T> &A,int N=-1) {
	if (N == -1) {
		N = A.size();
	}
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
}

template<typename T>
void SO(vector<T> &A,bool F=false) {
	sort(A.begin(), A.end());
	if (F) {
		reverse(A.begin(), A.end());
	}
}
//////////////

void solve() {
	string S;
	cin >> S;
	string ans="ABC";
	if (S == "ABC") {
		ans = "ARC";
	}
	cout << ans << endl;
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}

Measured memory_bytes: 3652
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <vector>
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define C 1000000007
int A[4002] = { 0 };

void add(int i, int x) {
	A[i] += x;
}

int sum(int t) {
	int Sum = 0;
	for (int i = 0; i <= t; i++)
		Sum += A[i];
	return Sum;
}

int main() {

	int N, K;
	long long int count1 = 0;
	int count2 = 0;
	int B[4002] = { 0 };
	scanf("%d %d", &N, &K);
	for (int i = 0; i < N; i++) {
		scanf("%d", &B[i]);
	}

	for (int i = 0; i < N; i++) {
		add(B[i], 1);
		count1 += i + 1 - sum(B[i]);
		B[N + i] = B[i];
	}
	count2 = count1;
	for (int i = N; i < 2 * N; i++) {
		add(B[i], 1);
		count2 += i + 1 - sum(B[i]);
	}
	long long int T = count2 - count1 * 2;
	
	long long ans2;
	if(K%2==0)ans2 = (T * (K/2) % C) *(K - 1) % C;
	else ans2 = (T * ((K-1)/2) % C) *K % C ;
	printf("%lld", ((count1*K % C )+ ans2)% C);
//	printf("%d", count);
	return 0;
}

Measured memory_bytes: 128
import math
N = int(input())
if N == 2:
    print(1)
else:
    ans = [N-1,N]

    #N-1
    for i in range(2,int(math.sqrt(N-1)+1)):
        if (N-1) % i == 0:
            ans.append(i)
            if i != (N-1)//i:
                ans.append((N-1)//i)

    #N
    for j in range(2,int(math.sqrt(N))+1):
        if N % j == 0:
            n1 = N
            n2 = N
            while n1 % j == 0:
                n1 = n1/j
            if n1 % j == 1:
                ans.append(j)
            if j != N//j:
                while n2 % N//j == 0:
                    n2 = n2*j//N
                if n2 % j == 1:
                    ans.append(N//j)
        
    print(len(ans))

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

typedef long long ll;
const int maxn=4e3+10,mod=998244353;
int n,k;
ll cc[maxn][maxn];

inline ll c(int n,int m){
	if(n<0||m<0)
		return 0;
	return cc[n][m];
}
inline ll f(int n,int k){
	return c(n+k-1,n);
}
inline ll calc(int sum){
	ll res=0;
	int cnt1=0,cnt2=0;
	for(int i=1;i<=k&&i<sum-i;++i)
		if(sum-i<=k)
			++cnt1;
	cnt2=k-cnt1*2;
	if(sum&1)
		for(int i=0,x=1;i<=cnt1;++i,x=x*2%mod)
			(res+=c(cnt1,i)*x%mod*f(n-i,i+cnt2))%=mod;
	else{
		--cnt2;
		for(int i=0,x=1;i<=cnt1;++i,x=x*2%mod){
			(res+=c(cnt1,i)*x%mod*f(n-i,i+cnt2))%=mod;
			(res+=c(cnt1,i)*x%mod*f(n-1-i,i+cnt2))%=mod;
		}
	}
	return res;
}

int main(){
	for(int i=0;i<maxn;++i){
		cc[i][0]=1;
		for(int j=1;j<=i;++j)
			cc[i][j]=(cc[i-1][j-1]+cc[i-1][j])%mod;
	}
	cin>>k>>n;
	for(int i=2;i<=2*k;++i)
		cout<<calc(i)<<endl;
	return 0;
}

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

const double PI = 3.14159265358979323846;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
//const ll mod = 1e10;
typedef priority_queue<string, vector<string>, greater<string> > PQ_ASK;

#include <iostream>
#include <vector>

using namespace std;

ll check(int n, ll mid, ll k, vector<ll> &skills, vector<ll> &foods) {
    ll sum = 0;
    rep(i, n) {
        ll ns = mid / foods[i];
        if (ns < skills[i]) {
            sum += (skills[i] - ns);
        }
    }
    return k >= sum;
}

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

    vector<ll> skills(n), foods(n);
    rep(i, n) cin >> skills[i];
    rep(i, n) cin >> foods[i];

    sort(skills.begin(), skills.end());
    sort(foods.rbegin(), foods.rend());

    bool b = check(n, 0, k, skills, foods);
    if (b) {
        cout << 0 << endl;
        ret();
    }

    ll floor = 0, ceil = INF;

    while (floor + 1 < ceil) {
        ll mid = (floor + ceil) / 2;
        bool b = check(n, mid, k, skills, foods);
        if (b) {
            ceil = mid;
        } else {
            floor = mid;
        }
    }
    cout << ceil << endl;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define se second
#define fi first
#define pb push_back
const int N=1e5 + 5;
int a[N],b[N];

int ask(int n){

	cout << n << endl;
	string s;
	cin >> s;
	if(s == "Vacant") exit(0);
	return s == "Male";
}

int main(){

//	freopen("in.txt","r",stdin);

	int n;
	cin >> n;
	int l=0,r=n - 1,sl=ask(l),sr=ask(r);
	while(l <= r){
		int mid=(l + r) / 2;
		int temp=ask(mid);
		if((0 == (mid & 1) && temp != sl) || ((mid & 1) && temp == sl)) r=mid
			- 1;
		else l=mid + 1;
	}

	return 0;

}


Measured memory_bytes: 852
// https://cses.fi/problemset/task/1734/
#include <bits/stdc++.h>

using namespace std;
using iii = tuple<int, int, int>;
using mii = map<int, int>;
using vi = vector<int>;
using viii = vector<iii>;

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, q, a, b;
  cin >> n >> q;
  vi x(n);
  mii m;
  for (int i = 0; i < n; i++) {
    int y;
    cin >> y;
    if (m.count(y)) x[i] = m[y];
    else x[i] = m.size(), m[y] = x[i];
  }
  viii y(q);
  for (int i = 0; i < q; i++) {
    cin >> a >> b;
    y[i] = {a-1, b, i};
  }
  int k = sqrt(n);
  sort(y.begin(), y.end(), [&](iii x, iii y) -> bool {
    int a1, b1, i1, a2, b2, i2;
    tie(a1, b1, i1) = x;
    tie(a2, b2, i2) = y;
    int a1q = a1/k, a2q = a2/k;
    if (a1q < a2q) return true;
    if (a1q > a2q) return false;
    return b1 < b2;
  });
  vi res(q);
  vi count(m.size());
  int l = 0, r = 0, ans = 0;
  for (iii z : y) {
    int i;
    tie(a, b, i) = z;
    while (r < b) if (++count[x[r++]] == 1) ans++;
    while (r > b) if (--count[x[--r]] == 0) ans--;
    while (l < a) if (--count[x[l++]] == 0) ans--;
    while (l > a) if (++count[x[--l]] == 1) ans++;
    res[i] = ans;
  }
  for (int z : res) cout << z << '\n';
}


Measured memory_bytes: 38948
import java.util.Scanner;
 public class Main {
 public static void main(String[] args){
 Scanner sc = new Scanner(System.in);
 int a = sc.nextInt();
 int b = sc.nextInt();
 int area = a*b;
 int length = 2*(a+b);
 System.out.println(area + " " + length);
 }
}

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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q>
ostream& operator << (ostream& os, pair<P, Q> p)
{
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template<typename T>
ostream& operator << (ostream& os, vector<T> v)
{
  os << "(";
  each (i, v) os << i << ",";
  os << ")";
  return os;
}

const int N = 2 * 1e5 + 5;
const int M = 'z' + 5;
int g[N][M];

const int inf = 1 << 28;
int memo[N];
int path[N];
int rec(int curr)
{
  int& ret = memo[curr];
  if (ret != -1) return ret;

  for (char c = 'a'; c <= 'z'; ++c) {
    if (!g[curr][c]) {
      path[curr] = -1 * int(c);
      return ret = 0;
    }
  }

  int mn = inf;
  for (char c = 'a'; c <= 'z'; ++c) {
    int len = rec(g[curr][c]) + 1;
    if (len < mn) {
      mn = len;
      path[curr] = g[curr][c];
    }
  }
  return ret = mn;
}

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  string s;
  while (cin >> s) {
    s = "@" + s;

    fill(&g[0][0], &g[N - 1][M - 1] + 1, 0);
    for (int i = s.size() - 2; 0 <= i; --i) {
      for (char c = 'a'; c <= 'z'; ++c) {
        g[i][c] = g[i + 1][c];
      }
      g[i][s[i + 1]] = i + 1;
    }

    fill(memo, memo + N, -1);
    fill(path, path + N, -1);
    rec(0);
    string t;
    for (int i = 0; ; i = path[i]) {
      if (i < 0) {
        t += abs(i);
        break;
      }
      t += s[i];
    }
    cout << t.substr(1) << endl;
  }

  return 0;
}


Measured memory_bytes: 101712
fun main(args: Array<String>) {
    // Your code here!
    val n = readLine()!!.toLong()
    val list  = readLine()!!.split(" ").map{it.toLong()}.sorted()
    val arc = n / 2
    val abc = (n / 2) - 1 
    var cnt = list[arc.toInt()] - list[abc.toInt()]
    
    
    print(cnt)
}



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

#define vec              vector<int>
#define vecll            vector<ll>
#define vecd             vector<double>
#define vecst            vector<string>
#define vecb             vector<bool>
#define v2(v,n,m,init)   vector<vector<int>>  v(n, vector<int>(m, init))
#define vb2(v,n,m,init)  vector<vector<bool>> v(n, vector<bool>(m, init))
#define vll2(v,n,m,init) vector<vector<ll>>   v(n, vector<ll>(m, init))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << (var) << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << (var);
#define prt2(v1, v2)     cout << (v1) << " " << (v2) << "\n"
#define prt3(v1, v2, v3) cout << (v1) << " " << (v2) << " " << (v3) << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
template <typename T>
bool chmax(T &a, const T& b){if(a<b){a=b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T& b){if(a>b){a=b; return true;} return false;}
//------------------------------------------------------------------

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

	if(n==0){
		prt(0);
		return 0;
	}
	string ans;
	ll b=1, bd=2;
	while(n!=0){
		if(n%bd!=0) ans.push_back('1'), n-=b;
		else ans.push_back('0');
		b*=-2;
		bd*=2;
	}
	reverse(all(ans));
	prt(ans);
}


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

int main() {
  int N,K,x = 1;
  cin >> N >> K;
  for(int i = 0; i < N;i++){
    
    if( x*2 >= x + K){
      
    x += K; 
      
    }
    
    else{
      
      x *= 2;
      
    }
    
  }
  
   cout << x << endl;
  
}
 
  
  
  
 


Measured memory_bytes: 256
n = int(input())
h = [ int(x) for x in input().split() ]

cnt = 0
while True:
    if max(h) == 0:
        break
    idx = 0
    while idx < n:
        if h[idx] == 0:
            idx += 1
        else:
            cnt += 1
            while idx < n and h[idx] != 0:
                h[idx] -= 1
                idx += 1

print(cnt)

Measured memory_bytes: 3064
//============================================================================
// Name        : AOJ.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

int main() {
	double X1,X2,Y1,Y2;
	double A=0;
	cin>>X1>>Y1>>X2>>Y2;

	A=sqrt((X1-X2)*(X1-X2)+(Y1-Y2)*(Y1-Y2));

	printf("%lf\n",A);
	return 0;
}

Measured memory_bytes: 3248
use proconio::input;

fn main() {
    input! {
        n: usize,
        a: [usize; n],
    }
    println!(
        "{}",
        a.iter()
            .enumerate()
            .filter(|(i, &ai)| i % 2 == 0 && ai % 2 == 1)
            .count()
    );
}


Measured memory_bytes: 2124
#include <cstdio>
#include <algorithm>

using namespace std;

int n, k;

int main() {

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

    if (k == 1) {
        puts("0");
    } else {
        int x = k - 1;
        int y = n - x;
        printf("%d\n", y - 1);
    }

    return 0;

}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  int w,h,x,y,r;
  cin>>w>>h>>x>>y>>r;
  if(x-r<0||x+r>w||y-r<0||y+r>h)cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
}

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

using namespace std;

int max(int *arr, int n)
{
    int max=arr[0];
    for (int i=1;i<n;i++)
    {
        if (arr[i]>max)
            max=arr[i];
    }
    return max;
}

int main()
{
    char S[100];
    int N, a[101];
    a[0]=0;
    cin>>N>>S;
    for (int i=0; i<N; i++)
    {
        if (S[i]=='I')
            a[i+1]=a[i]+1;
        else if (S[i]=='D')
            a[i+1]=a[i]-1;
    }
    int R=max(a,N+1);
    cout<<R;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <cstdio>
#include<string>
#include<stack>
#include<queue>
#include<stdio.h>
#include <algorithm>
#include<set>
#include<vector>

#define _CRT_SECURE_NO_WARNINGS

using namespace std;
struct Human
{
	int age;
	double weight;
	char name[256];
};

int findSumOfDigits(int n) {
	int sum = 0;
	while (n > 0) { // n が 0 になるまで
		sum += n % 10;
		n /= 10;
	}
	return sum;
}

int main()
{
	//cin>>N;
	// for (int i = 0; i < N; ++i) cin >> A[i];
	//while(true){break; ++res;}
	//cout << res << endl;
	//sort(a, a+N, greater<int>()) 大きい順ソート sort(v.begin(), v.end()); // vector
	//set<int>values; values.insert() values.size()
	//map<string,int>salary; salary["John"] = 1400;
	// string num = to_string(counter);

	int l[10000];
	int n[10000];
	int v[3];
	int a, b, c, d;
	int sum = 0;
	int count=0;
	int kari = 0;
	int w, h;
	int x, y, r;
	vector<string> lang;
	vector<int> data;
	string s; // s.size() to_string char string %s

	while (1)
	{
		cin >> l[count]>>n[count];
		count = count + 1;
		if (l[count-1] == 0 && n[count-1]==0) break;
	}

	for (int i = 0; i < count-1; i++)
	{
		cout << min(l[i],n[i]) <<" " << max(l[i], n[i]) << endl;
	}
	return 0;
}


Measured memory_bytes: 3108
#if __has_include("../library/Basic/Debug.hpp")

#include "../library/Basic/Debug.hpp"

#else

/* ----- Header Files ----- */
// IO
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm
#include <algorithm>
#include <cmath>
#include <numeric>

// container
#include <vector>
#include <string>
#include <tuple>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>

// others
#include <random>
#include <limits>
#include <functional>
#include <ctime>
#include <cassert>
#include <cstdint>

/* ----- Type Alias ----- */
using Int = long long int;
using Real = long double;
using std::pair;
using std::string;
using std::tuple;
using std::vector;
template <class T>
using MaxHeap = std::priority_queue<T>;
template <class T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template <class T>
T genv(T v) { return v; }

template <class T, class... Ts>
auto genv(size_t l, Ts... ts) {
    return vector<decltype(genv<T>(ts...))>(l, genv<T>(ts...));
}

template <class Cost = Int>
struct Edge {
    Int src, dst;
    Cost cost;
    Edge(Int src = -1, Int dst = -1, Cost cost = 1)
        : src(src), dst(dst), cost(cost){};

    bool operator<(const Edge<Cost>& e) const { return this->cost < e.cost; }
    bool operator>(const Edge<Cost>& e) const { return this->cost > e.cost; }
};

template <class Cost = Int>
using Edges = vector<Edge<Cost>>;
template <class Cost = Int>
using Graph = vector<vector<Edge<Cost>>>;

#endif

/* ----- Misc ----- */
void fastio() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
}

struct Fout {
    Int precision;
    Fout(Int precision) : precision(precision) {}
};
std::ostream& operator<<(std::ostream& os, const Fout& fio) {
    os << std::fixed << std::setprecision(fio.precision);
    return os;
}


/* ----- Constants ----- */
// constexpr Int INF = std::numeric_limits<Int>::max() / 3;
// constexpr Int MOD = 1000000007;
// const Real PI = acos(-1);
// constexpr Real EPS = 1e-10;
// std::mt19937 mt(int(std::time(nullptr)));

int main() {
    int x, a, b, n;
    std::cin >> x >> a >> b >> n;
    for (int i = 0; i < n; ++i) {
        string s;
        std::cin >> s;
        if (s[0] == 'n') {
            x = std::max(0, x + a);
        } else if (s[0] == 't') {
            x = std::max(0, x + b);
        } else {
            x = 0;
        }
    }

    std::cout << x << std::endl;
    return 0;
}



Measured memory_bytes: 3212
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	n := getInt()
	k := getInt()
	x := getInt()
	y := getInt()

	fmt.Println(min(k, n)*x + max((n-k), 0)*y)
}

func min(ns ...int) int {
	min := ns[0]
	for i := 1; i < len(ns); i++ {
		if min > ns[i] {
			min = ns[i]
		}
	}
	return min
}

func max(ns ...int) int {
	max := ns[0]
	for i := 1; i < len(ns); i++ {
		if max < ns[i] {
			max = ns[i]
		}
	}
	return max
}

// -----------------------------------------

var scanner = wordScanner()

func wordScanner() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}

func getInt() int {
	scanner.Scan()
	i, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getIntSlice(n int) []int {
	is := make([]int, n)
	for i := range is {
		is[i] = getInt()
	}
	return is
}

func getString() string {
	scanner.Scan()
	s := scanner.Text()
	return s
}


Measured memory_bytes: 640
#include <stdio.h>

int main(void) {
  int i, ans = 0, x = 0, n;
  scanf("%d", &n);
  char s[n + 10];
  scanf("%s", s);
  for(i = 0; i < n; ++i) {
    if(s[i] == 'I') x++;
    else x--;
    if(ans < x) ans = x;
  }
  printf("%d", ans);
  return 0;
}

Measured memory_bytes: 128
import sys

n, y = map(int, sys.stdin.readline().split())
y //= 1000; y -= n

def main():
    for i in range(n + 1):
        if 9 * i > y: break
        if (y - 9 * i) % 4: continue
        j = (y - 9 * i) // 4
        if (i + j > n): continue
        k = n - i - j
        print(i, j, k)
        return
    print(-1, -1, -1)

if __name__ ==  '__main__':
    main()

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

using namespace std;

#define MAX(a,b) ((a)>(b)?(a):(b))

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

    vector<long long> A(N);

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

    long long dp[3][N];

    for(int i=0; i<N; ++i) {
        dp[0][i]=A[i];
        dp[1][i]=MAX(A[i],A[(i+1)%N]);
    }

    for(int i=2; i<N; ++i) {
        for(int j=0; j<N; ++j) {
            long long temp1,temp2;
            temp1=A[j]+(A[(j+1)%N]>A[(j+i)%N]?dp[(i+1)%3][(j+2)%N]:dp[(i+1)%3][(j+1)%N]);
            temp2=A[(j+i)%N]+(A[j]>A[(j+i-1)%N]?dp[(i+1)%3][(j+1)%N]:dp[(i+1)%3][j]);
            dp[i%3][j]=MAX(temp1,temp2);
        }
    }

    long long ans=0;

    for(int i=0; i<N; ++i) {
        ans=MAX(ans,dp[(N-1)%3][i]);
    }

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 3168
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define reptr(i,n) for(int (i)=(n);(i)>=0;--(i))
#define All(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
const ll KEY = 998244353;
using namespace std;

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if((a<c && c<b) || (b<c && c<a)) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
from sys import stdin
ans=0
c=0
N = int(input().rstrip())
for i in range(N):
  c=0
  i+=1
  if i%2==1:
    for j in range(i):
      j+=1
      if i%j==0:
        c+=1
  if c==8:
    ans+=1

print(ans)

Measured memory_bytes: 63952
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const ll mod=1e9+7;

int main(){
  int k,x;
  cin >> k >> x;
  int st,end;
  if(x+k-1 > 1000000){
    end = 1000000;
  }else{
    end = x+k-1;
  }

  if(x-k+1 < -1000000){
    st = 1000000;
  }else{
    st = x-k+1;
  }

  for(int i = st; i <= end; i++){
    printf("%d ", i);
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

ll d[300][300];
ll V;
vector<int> v;

void warshall_floyd(){
  rep(k,V){
    rep(i,V){
      rep(j,V)d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
    }
  }
}

int main(){
  rep(i,300){
    rep(j,300){
      if(i!=j)d[i][j]=inf;
    }
  }
  ll m,R;
  cin >> V >> m >> R;
  ll r[R];
  rep(i,R){
    cin >> r[i];
    r[i]--;
  }
  ll a[m],b[m],c[m];
  rep(i,m){
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;
    b[i]--;
    d[a[i]][b[i]]=min(d[a[i]][b[i]],c[i]);
    d[b[i]][a[i]]=min(d[b[i]][a[i]],c[i]);
  }
  warshall_floyd();
  ll ans=inf;
  rep(i,R){
    v.push_back(r[i]+1);
  }
  sort(v.begin(),v.end());
  while(next_permutation(v.begin(),v.end())){
    ll temp=0;
    rep(i,R-1)temp+=d[v[i]-1][v[i+1]-1];
    ans=min(ans,temp);
  }
  cout << ans << endl;
return 0;}

Measured memory_bytes: 1408