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

int     main() {
        int N, M;
        cin >>N >>M;
        vector<long> a0(N);
        vector<long> a1(N);
        vector<long> a2(N);
        vector<long> a3(N);
        for (int i=0; i<N; i++) {
                long x, y, z;
                cin >>x >>y >>z;
                a0.at(i)=x+y+z;
                a1.at(i)=x+y-z;
                a2.at(i)=x-y+z;
                a3.at(i)=x-y-z;
        }
        sort(a0.begin(), a0.end());
        sort(a1.begin(), a1.end());
        sort(a2.begin(), a2.end());
        sort(a3.begin(), a3.end());
        vector<long> b(8, 0);
        for (int i=0; i<M; i++) {
                b.at(0) += a0.at(i);
                b.at(1) += a1.at(i);
                b.at(2) += a2.at(i);
                b.at(3) += a3.at(i);
                b.at(4) += a0.at(N-i-1);
                b.at(5) += a1.at(N-i-1);
                b.at(6) += a2.at(N-i-1);
                b.at(7) += a3.at(N-i-1);
        }
        for (int i=0; i<8; i++) b.at(i)=abs(b.at(i));
        sort(b.begin(), b.end());
        cout <<b.back() <<endl;
        return 0;
};

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>

using namespace std;

struct edge{
	double x1;
	double x2;
	double y1;
	double y2;
};


pair<double,double> crossing(edge e1,edge e2){
	pair<double,double> p;
	if ((e1.x2-e1.x1)*(e2.y2-e2.y1) == (e1.y2-e1.y1)*(e2.x2-e2.x1)) {
		return make_pair(10000.0,10000.0);
	}
	double k;
	double dx1 = e1.x2-e1.x1;
	double dx2 = e2.x2-e2.x1;
	double dy1 = e1.y2-e1.y1;
	double dy2 = e2.y2-e2.y1;
	k = ((e2.x1-e1.x1)*(-dy2)+(e2.y1-e1.y1)*dx2)/(dy1*dx2-dx1*dy2);
	p.first = e1.x1 + k*dx1;
	p.second = e1.y1 + k*dy1;
	return p;
}

bool inc(pair<double,double> p){
	if(p.first >= 100 || p.first <= -100 ){
		return 0;
	}
	if(p.second >= 100 || p.second <= -100){
		return 0;
	}
	return 1;
}


int main(){
	int n;
	edge e1,e2;
	while(cin >> n && n!=0){
		vector<edge> edges;
		int count = 0;
		edge e;
		for(int i=0;i<n;i++){
			if(i==0){
				count =2;
				cin >> e.x1 >> e.y1 >> e.x2 >> e.y2;
				edges.push_back(e);
			}else{
				cin >> e.x1 >> e.y1 >> e.x2 >> e.y2;
				edges.push_back(e);
				set<pair<double,double> > po_edge;
				for(int j=0;j<edges.size()-1;j++){
					pair<double,double>p;
					p = crossing(e,edges[j]);
					if(inc(p)){
						if(po_edge.count(p)==0){
							po_edge.insert(p);
							count +=1;
						}
					}
				}
				count +=1;
			}
		}
		cout << count << endl;
	}
	return 0;
}

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

int main() {
	string s; cin >> s;

	int c = s[0] - '0';

	for (int i = 1; i < s.size(); i++) {
		if (s[i] != '9') {
			c--; break;
		}
	}
	cout << c + 9 * (s.size() - 1) << endl;

	return 0;
}

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

int main(void){
    char s[256];

    scanf("%s",s);

    if(strcmp(s,"hi")==0||strcmp(s,"hihi")==0||strcmp(s,"hihihi")==0||strcmp(s,"hihihihi")==0||strcmp(s,"hihihihihi")==0){
        printf("Yes");
    }
    else{
        printf("No");
    }
    return 0;
}

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

using namespace std;

int costSum(vector<int>, int);

int main(void)
{
    int n;
    cin >> n;
    int ave = 0, min = 100, max = -100;
    vector<int> a(n);
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
        ave += a[i];
        if(a[i] < min) min = a[i];
        if(a[i] > max) max = a[i];
    }
    
    ave /= n;

    vector<int> costs(4);

    costs[0] = costSum(a, ave);
    costs[1] = costSum(a, ave + 1);
    costs[2] = costSum(a, min);
    costs[3] = costSum(a, max);

    int result = costs[0];

    for(int i = 1 ; i < 4; i++)
        if(costs[i] < result) result = costs[i];

    cout << result << endl;
   
    return 0;
}

int costSum(vector<int> a, int y)
{
    int cost = 0;
    for(int i = 0; i < a.size(); i++) cost += (a[i] - y) * (a[i] - y);
    return cost;
}

Measured memory_bytes: 256
#include <stdio.h>

int main (){
	
	char kata[1000];
	scanf ("%s", &kata);
	
	if (kata[0] == 'A' && kata [1] == 'B' && kata[2] == 'C'){
		printf ("%s", "ARC");
	}	
	else{
		printf ("ABC");
	}
	
	return 0;
}

Measured memory_bytes: 1696
#include <bits/stdc++.h>
#define REP(i, x, y) for (ll i = x; i <= y; i++)
#define BIT(t) (1ll << t)
#define PER(i, y, x) for (ll i = y; i >= x; i--)
#define vll vector<ll>
#define vvll vector<vector<ll>>
#define pll pair<ll, ll>
#define SIZE(v) ll(v.size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
using namespace std;
typedef long long ll;
//        ios::sync_with_stdio(false);
//        cin.tie(nullptr);

int main(){
        ll h, w, k;
        cin >> h >> w >> k;
        vvll grid(h+1, vll(w+1)); vvll ans(h+1, vll(w+1));
        ll cnt = 1;
        REP(i,1,h){
                REP(j,1,w){
                        char c;
                        cin >> c;
                        if(c=='.'){
                                grid[i][j] = 0;
                        }else{
                                grid[i][j] = cnt;
                                cnt++;
                        }
                }
        }
        REP(i,1,h){
                REP(j,2,w){
                        if(grid[i][j] == 0){
                                grid[i][j] = grid[i][j-1];
                        }
                }
                PER(j,w-1,1){
                        if(grid[i][j] == 0){
                                grid[i][j] = grid[i][j+1];
                        }
                }
        }
        REP(j,1,w){
                REP(i,2,h){
                        if(grid[i][j] == 0){
                                grid[i][j] = grid[i-1][j];
                        }
                }
                PER(i,h-1,1){
                        if(grid[i][j] == 0){
                                grid[i][j] = grid[i+1][j];
                        }
                }
        }
        REP(i,1,h){
                REP(j,1,w){
                        cout << grid[i][j];
                        if(j<w){
                                cout << " ";
                        }
                }
                cout << endl;
        }

}

Measured memory_bytes: 2176
#include<cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#define ll long long 
using namespace std;
inline void read(ll &k)
{
	ll f=1;char c=getchar();k=0;
	while (c<'0'||c>'9')c=='-'&&(f=-1),c=getchar();
	while (c>='0'&&c<='9')k=k*10+c-'0',c=getchar();
	k*=f;
}
ll n;
const int maxn=1e5+10;
ll a[maxn],first,second;
bool cmp(ll a,ll b)
{
	return a>b?1:0;
}
int main()
{
	read(n);
	for (int i=1;i<=n;i++)
	read(a[i]);
	sort(a+1,a+1+n,cmp);
	for (int i=1;i<=n;i++)
	if (a[i]==a[i+1]&&(!first))first=a[i],i++;
	else if (a[i]==a[i+1]&&(first)&&(!second))second=a[i],i++;
	printf("%lld\n",first*second);
}

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

long long int N[8];
long long int checksum;

long long int hex_to_long(string s){
	int n = s.size();
	long long int res = 0;
	for(int i=0; i<n; i++){
		char c = s[i];
		long long int x;
		if('0' <= c && c <= '9')
			x = c - '0';
		else
			x = c - 'a' + 10;
		res = res * 16 + x;
	}
	return res;
}

string long_to_hex(long long int l){
	string s = "";
	if(l == 0) return "0";
	while(l){
		int x = l % 16;
		if(0 <= x && x <= 9)
			s.insert(s.begin(), '0' + x);
		else
			s.insert(s.begin(), 'a' + x - 10);

		l /= 16;
	}
	return s;
}

void solve(){
	long long int K = 0;
	for(int k=0; k<32; k++){
		long long int sum = 0;
		for(int i=0; i<8; i++)
			sum += N[i];
		if(((checksum ^ sum)>>k) & 1){
			for(int i=0; i<8; i++)
				N[i] ^= 1L<<k;
			K |= (1L << k);
		}
	}
	long long int sum = 0;
	cout << long_to_hex(K) << endl;
}

int main(){
	int T; cin >> T;
	while(T--){
		string s;
		for(int i=0; i<8; i++){
			cin >> s;
			N[i] = hex_to_long(s);
		}
		cin >> s;
		checksum = hex_to_long(s);
		solve();
	}
	return 0;
}

Measured memory_bytes: 3172
#include <iostream>
using namespace std;
int main() {
	int a, b;
	char op;
	
	while(op != '?') {
		
		cin >> a >> op >> b;
		
		if (op == '+') {
			cout << a+b << endl;
		}
		if (op == '-') {
			cout << a-b << endl;
		}
		if (op == '*') {
			cout << a*b << endl;
		}
		if (op == '/') {
			cout << a/b << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3084
N=int(input())
S=input()
NS=[]
for i in range(len(S)):
  if ord(S[i])+N<=90:
    cnt=ord(S[i])+N
  else:
    cnt=ord(S[i])+N-26
  NS.append(chr(cnt))
ans = ''.join(NS)
print(ans)

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

int main(){
    ll t[2], a[2], b[2];
    cin >> t[0] >> t[1];
    cin >> a[0] >> a[1];
    cin >> b[0] >> b[1];

    ll p = (b[0]-a[0])*t[0];
    ll q = (b[1]-a[1])*t[1];
    if(p + q == 0){
        cout << "infinity\n";
    } else if (abs(q) < abs(p) || (q > 0 && p > 0) || (q < 0 && p < 0)){
        cout << 0 << endl;
    } else {
        ll dx = abs((b[1]-a[1])*t[1] + (b[0]-a[0])*t[0]);
        ll n = (abs(b[0]-a[0])*t[0]) / dx;
        if((abs(b[0]-a[0])*t[0]) == n * dx){
            cout << 2 * n << endl;
        } else {
            cout << 2 * n + 1 << endl;
        }
    }
    return 0;
}

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

using ld=long double;
using P=complex<ld>;

const int PREC=100;
const ld EPS=1e-8;

using VP = vector<P>;
struct C { P p; ld r; };
const ld eps = 1e-9, pi = acos(-1.0);
VP is_cc(C c1, C c2){
  VP res;
  ld d = abs(c1.p - c2.p);
  ld rc = (d * d + c1.r * c1.r - c2.r * c2.r) / (2 * d);
  ld dfr = c1.r * c1.r - rc * rc;
  if (abs(dfr) < eps) dfr = 0.0;
  else if (dfr < 0.0) return res; // no intersection
  ld rs = sqrt(dfr);
  P diff = (c2.p-c1.p)/d;
  res.push_back(c1.p + diff * P(rc, rs));
  if (dfr != 0.0) res.push_back(c1.p + diff * P(rc, -rs));
  return res;
}
vector<P> ccp(P x0,ld r0,P x1,ld r1){
    VP res=is_cc(C{x0,r0},C{x1,r1});
    res.push_back(x0);
    res.push_back(x1);
    return res;
}

bool check(ld h,vector<P>& p,vector<ld> &l){
    int n=p.size();
    vector<ld> tr(n);
    for(int i=0;i<n;i++){
        if(l[i]<h) return false;
        tr[i]=sqrt(l[i]*l[i]-h*h);
    }
    bool res=false;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            vector<P> testP=ccp(p[i],tr[i],p[j],tr[j]);
            for(int k=0;k<testP.size();k++){
                bool isok=true;
                for(int l=0;l<n;l++){
                    isok&=(abs(testP[k]-p[l])<tr[l]+EPS);
                }
                res|=isok;
            }
        }
    }
    return res;
}
ld solve(vector<P> &p,vector<ld> &l){
    if(p.size()==1) return l[0];
    ld lb=0;
    ld ub=1e18;
    for(int i=0;i<PREC;i++){
        ld mid=(lb+ub)/2;
        if(check(mid,p,l)){
            lb=mid;
        }
        else{
            ub=mid;
        }
    }
    return lb;
}
int main(){
    int n;
    cout<<setprecision(10)<<fixed;
    while(cin>>n,n){
        vector<P> p(n);
        vector<ld> l(n);
        for(int i=0;i<n;i++){
            ld x,y;
            cin>>x>>y>>l[i];
            p[i]=P(x,y);
        }
        cout<<solve(p,l)<<endl;
    }
    return 0;
}


Measured memory_bytes: 3300
from math import gcd, ceil
n, m = map(int, input().split())
a = list(map(int, input().split()))
a = [i // 2 for i in a]
l = 1
for i in a:
    l *= i // gcd(l, i)
for i in a:
    if l // i % 2 == 0:
        print(0)
        exit()
print(ceil((m // l) / 2))

Measured memory_bytes: 20208
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3
#define MAX_N 1000

void solve(){
   cin.tie(0);
   ios::sync_with_stdio(false);
   ll h , w;
   cin>>h>>w;
   std::vector< vector<char> > v(h,vector<char>(w));
   rep(i,h)rep(j,w) cin>>v[i][j];
   ll cnt=0;
   rep(i,h)rep(j,w) if(v[i][j] == '#') cnt++;
   if(cnt == h + w - 1) cout<<"Possible"<<endl;
   else cout<<"Impossible"<<endl;
}
int main(){
  solve();
  return 0;
}



Measured memory_bytes: 256
x=int(input())
y=1  # y個購入すると題意をみたす時、1<=y<=x//100、実際に支払い可能な金額は100＊y〜105＊y
if x<100:
  print(0)
else:
  while y<=x//100+1:
    if y*100<=x<=y*105:
      print(1)
      break
    elif y>x//100:
      print(0)
      break
    else:
      y+=1
      

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define int long long
#define float long double
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define endl '\n'
#define pii pair<int, int>
#define min3(a,b,c) min(a, min(b, c))
#define max3(a,b,c) max(a, max(b, c))
#define all(x) x.begin(), x.end()
#define fill(a,b) memset(a, b, sizeof(a))
#define sz(x) (int)x.size()
#define sp(x) setprecision(x)
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define mex 1000005
int vis[mex],mark[mex];

signed main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

    int n; cin>>n;
    int arr[n];
    for(int i=0;i<n;i++){
        int x; cin>>x;
        vis[x]++;
        if(vis[x]>1) continue;
        for(int j=2*x;j<mex;j+=x) mark[j]=1;
    }
    int ans=0;
    for(int i=0;i<mex;i++){
        if(vis[i]==1 && mark[i]==0) ans++;
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 19216
import collections
 
n = int(input())
lens = list(map(int,input().split()))
lens = collections.Counter(lens)
lens = sorted(lens.items(), key=lambda x:x[0], reverse = True)
cnt = 0
for j in lens:
  if j[1] >= 4 and cnt == 0:
    print(j[0]**2)
    break
  elif j[1] >= 2 and cnt == 0:
    cnt = j[0]
  elif j[1] >= 2 and cnt != 0:
    print(cnt * j[0])
    break
else:
    print(0)

Measured memory_bytes: 21540
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 2e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    ll w, h, x, y;
    cin >> w >> h >> x >> y;
    double ans1 = (double)(w * h) / 2;
    int ans2 = 0;
    if (w % 2 == 0 && h % 2 == 0) {
        if (w / 2 == x && h / 2 == y) {
            ans2 = 1;
        }
    }

    cout << fixed;
    cout << setprecision(10) << ans1 << " ";
    cout << ans2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;

    vector<int> d(n);
    for(int i = 0; i < n; i++){
        cin >> d.at(i);
    }

    int ans = 0;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < i; j++){
            ans += d[i]*d[j];
        }
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
#define INF 1e9

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef vector < pair<int, int> > vii;
typedef long double ld;
typedef tree<pair<int,int>, null_type, less<pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

ll n, m, x, y, xx, yy;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll MOD = 1e9+7;
	cin >> n >> m;
	for(ll i = 0; i < n; i++){
		cin >> x;
		xx+=(-(n-1)+2*i)*x;
		xx%=MOD;
	}
	for(ll i = 0; i < m; i++){
		cin >> y;
		yy+=(-(m-1)+2*i)*y;
		yy%=MOD;
	}
	cout<<(xx*yy)%MOD;
	return 0;
}


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

int main(){

  int N, M; cin >> N >> M;
  vector<int> cnt(M, 0);

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

  int ans = 0;
  for(int i = 0 ; i < M ; ++i){
    if(cnt[i] == N){
      ++ans;
    }
  }

  cout << ans << endl;

}

Measured memory_bytes: 256
N = int(input())
A = [int(x) for x in input().split()]
DP = [[0 for _ in range(2)]for _ in range(N-1)]
## 0:non operation ,1:operated

for i in range(N-1):
    if(i==0):
        DP[0][0] = sum(A[:2])
        DP[0][1] = -DP[0][0]
    else:
        DP[i][0] = max(DP[i-1])+A[i+1]
        DP[i][1] = max(DP[i-1][0]-2*A[i]-A[i+1],DP[i-1][1]+2*A[i]-A[i+1])
print(max(DP[-1]))


Measured memory_bytes: 26236
N, K = map(int, input().split())
P = tuple(map(int, input().split()))

from itertools import accumulate
E = [(1+p)/2 for p in P]
ES = list(accumulate(E))

e = ES[K-1]
for i in range(N-K):
    e = max(e, ES[K+i] - ES[i])
print(e)


Measured memory_bytes: 25316
import math
import fractions
import sys
sys.setrecursionlimit(10**9)


INF=10**20
def get_lcm(x, y):
    return (x * y) // fractions.gcd(x, y)


def solve(N: int, M: int, A: "List[int]"):
    lcm = A[0]
    for i,a in enumerate(A[1:]):
        lcm = get_lcm(a,lcm)

    if lcm % 2 == 1:
        print(0)
        exit()

    for i,a in enumerate(A):
        b = lcm // a
        if b % 2 == 0:
            print(0)
            exit()
        
    ans = math.floor(M/lcm+1/2) - math.ceil(1/lcm+1/2) + 1
    print(ans)

    
    
    return

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



if __name__ == "__main__":
    main()


Measured memory_bytes: 92728
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define FORE(v, a, b) for(int v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(int v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define LLI long long int
#define fst first
#define snd second

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(x)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> istream& operator>>(istream &is, pair<T,U> &p){is >> p.first >> p.second; return is;}

template <typename T, typename U> T& chmin(T &a, const U &b){return a = (a<=b?a:b);}
template <typename T, typename U> T& chmax(T &a, const U &b){return a = (a>=b?a:b);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

vector<int> solve(int a, int b, int n, int mask){
  if(__builtin_popcount(mask) == 1) return {a,b};

  int x,y,z;

  REP(i,n){
    if((mask&(1<<i)) and (a&(1<<i)) != (b&(1<<i))){
      x = a^(a&(1<<i));
      y = b^(b&(1<<i));

      int new_mask = mask^(1<<i);
      REP(j,n){
	if(new_mask&(1<<j)) z = x^(1<<j);
      }

      dump(mask);
      dump(new_mask);

      dump(a);
      dump(b);

      dump(x);
      dump(y);
      dump(z);

      auto ret1 = solve(x,z,n,new_mask);
      auto ret2 = solve(z,y,n,new_mask);

      for(auto &p : ret1) p |= (a&(1<<i));
      for(auto &p : ret2) p |= (b&(1<<i));

      dump(ret1);
      dump(ret2);

      for(auto p : ret2) ret1.push_back(p);
      
      return ret1;
    }
  }
}

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

  int N,A,B;
  while(cin >> N >> A >> B){
    if(__builtin_parity(A) == __builtin_parity(B)){
      cout << "NO" << endl;
    }else{
      cout << "YES" << endl;
      auto ans = solve(A,B,N,(1<<N)-1);
      for(auto &x : ans){
	dump(bitset<17>(x));
      }
      join(cout, ALL(ans));
    }
  }
  
  return 0;
}


Measured memory_bytes: 1648
from collections import Counter
N = int(input())
c = input()
counter = Counter(c)

if counter["R"] == 0 or counter["W"] == 0:
    print(0)
else:
    r_cnt = 0
    for i in range(counter["R"]):
        if c[i] == "R":
            r_cnt += 1
    print(counter["R"]-r_cnt)



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

struct Edge{int node, id;};//Edge(辺)のノードと  Edge(辺)の色

int main() {
  int N;
  cin >> N;
  vector<int> A(N), B(N), C(N-1);
  int ans = 0;
  //cout << "yah1" << endl;
  for(int i=0; i<N; i++) cin >> A.at(i);
  for(int i=0; i<N; i++){
    cin >> B.at(i);
    ans += B.at(i);
  }
  for(int i=0; i<N-1; i++) cin >> C.at(i);
  //cout << "ans : " << ans << endl;
  for(int i=0; i<N-1; i++){
    if(A.at(i+1)-A.at(i) == 1){
      //cout << " A.at(" << i << ") : " << A.at(i) << endl;
      ans += C.at(A.at(i)-1);
      //↑↑すべて1から始まっているので, 0始まりにするために-1
    }
  }
  
  cout << ans << endl;  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;

  int div = A+B-C-D;
  
  if(div > 0)
    cout << "Left" << endl;
  if(div == 0)
    cout << "Balanced" << endl;
  if(div < 0)
    cout << "Right" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define mod 1000000007
#define MOD 998244353
#define INF 40000000000000000
int dx8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int dy8[8] = {1, 1, 1, 0, -1, -1, -1, 0};
int dx4[4] = {-1, 0, 1, 0};
int dy4[4] = {0, -1, 0, 1};
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;
}
int sum(int n){
    int res=0;
    while(n>0){
        res+=n%10;
        n/=10;
    }
    return res;
}
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
signed main() {
    int n;cin>>n;
    cout<<n*32<<endl;
}



Measured memory_bytes: 3088
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 1e9 + 7;
typedef long long LL;
typedef long double LD;
typedef pair<LL, LL> PLL;
typedef pair<LD, LL> PDL;
typedef pair<LD, LD> PDD;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
//typedef boost::multiprecision::cpp_int bigint;

template<class T>
void in(T& x) {
	cin >> x;
}

template<class T1,class T2>
void in(pair<T1, T2>& p) {
	in(p.first);
	in(p.second);
}

template<class T>
void in(vector<T>& v,LL st=-1,LL en=-1) {
	if (st == -1) {
		st = 0;
		en = v.size() - 1;
	}
	for (LL n = st; n <= en; n++) {
		in(v[n]);
	}
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	LL N;
	set<LL> S;
	cin >> N;
	for (LL n = 0; n < N; n++) {
		LL a;
		cin >> a;
		if (S.find(a) != S.end()) {
			cout << "NO\n";
			return 0;
		}
		S.insert(a);
	}
	cout << "YES\n";
	return 0;
}

Measured memory_bytes: 9600
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0;i < n;i++)
#define REP(i,n,k) for(int i = n;i < k;i++)
#define P(p) cout << (p) << endl;
#define sP(p) cout << setprecision(15) << fixed << p << endl;
#define vi vector<int>
#define printv(v) for(int i = 0;i < v.size();i++)P(v[i]);
#define printt(a,b) cout << a << " " << b << endl; 
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = { 1, -1 , 0 , 0};
int dy[] = { 0,  0,  1, -1};
int MOD = 1e9 + 7;

void solve() {
    int n,k;
    cin >> n >> k;
    if(k == 1){
        P(0);
        return;
    }
    P(n-k);
}

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


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cassert>
#include <cstdio>
#include <cstring>

#define NMAX 200010

using namespace std;

char str[NMAX];
int ct[30];
int N;

typedef long long lli;

lli compute(){
	int i;
	lli tot=0;

	for(i = 0; i < N; ++i){
		tot += (i-ct[str[i]-'a']++);
	}

	return  tot+1;
}

int main(){
	scanf("%s",str);
	N = strlen(str);
	printf("%lld\n",compute());

	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  int n, k;
  cin >> n >> k;
  vi h(n);
  rep(i, n) cin >> h[i];
  sort(all(h));
  int ans = 1e9;
  rep(i, n - k + 1) ans = min(ans, h[i + k - 1] - h[i]);
  cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int h, w;
char matrix[12][12];
bool able[12][12];
void get(queue<int> &q){
    if (q.size() <= 1){
        cout << "YES" << endl;
        exit(0);
    }
    int ld = q.size();
    int el = q.front();
    q.pop();
    for (int i=0; i < q.size(); i++){
        int V = q.front();
        q.pop();
        if (able[V][el]) get(q);
        q.push(V);
    }
    if (ld % 2) get(q);
    q.push(el);
    for (int i=0; i < q.size()-1; i++){
        int V = q.front();
        q.pop();
        q.push(V);
    }
    return;
}
void solve(queue<int> &q, vector<pair<int, int> > &v){
    if (q.size() > 1){
        int ld = q.size();
        int el = q.front();
        q.pop();
        for (int i=0; i < q.size(); i++){
            int V = q.front();
            q.pop();
            v.push_back(make_pair(el, V));
            solve(q, v);
            v.pop_back();
            q.push(V);
        }
        if (ld % 2){
            v.push_back(make_pair(el, el));
            solve(q, v);
            v.pop_back();
        }
        q.push(el);
        for (int i=0; i < q.size()-1; i++){
            int V = q.front();
            q.pop();
            q.push(V);
        }
        return;
    }
    for (int i=0; i < w; i++){
        for (int j=0; j < w; j++){
            able[i][j] = true;
            for (int s=0; s < v.size(); s++){
                int a = v[s].first, b = v[s].second;
                if (matrix[a][i] != matrix[b][j]) able[i][j] = false;
                if (matrix[b][i] != matrix[a][j]) able[i][j] = false;
            }
            if (q.size() > 0){
                int e = q.front();
                if (matrix[e][i] != matrix[e][j]) able[i][j] = false;
            }
        }
    }
    queue<int> nq;
    for (int i=0; i < w; i++) nq.push(i);
    get(nq);
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> h >> w;
    for (int i=0; i < h; i++) for (int j=0; j < w; j++) cin >> matrix[i][j];
    queue<int> v;
    vector<pair<int, int> > q;
    for (int i=0; i < h; i++) v.push(i);
    solve(v, q);
    cout << "NO" << endl;
    return 0;
}



Measured memory_bytes: 256
// Example program
#include <iostream>
using namespace std;
 
int main(){
  int a,b;
  char op;
  
  cin >> a >> op >>b;
  while(op != '?'){
      if (op == '+'){
          cout << a+b << endl;
      } else if (op =='-'){
          cout << a-b << endl;
      } else if (op =='*'){
          cout << a*b << endl;
      } else if (op =='/'){
          cout << a/b << endl;
      }
      cin >> a >> op >> b;
  }    

  return 0;		 
}
		   





Measured memory_bytes: 3068
#include <stdio.h>

int main() {
	char name[101], ans[200], type;
	int n, a;
	
	while(1) {
		scanf("%s %c", name, &type);
		if(type == 'X') { break; }
		
		n = 0;
		a = 0;
		if(type == 'U') {
			while(name[n] != '\0') {
				if(n == 0 && 'a' <= name[0] && name[0] <= 'z') {
					ans[0] = name[0] - 32;
					n ++;
					a ++;
					continue;
				}
				if(name[n] == '_') {
					n ++;
					
					ans[a] = name[n] - 32;
					n ++;
					a ++;
					continue;
				}
				
				ans[a] = name[n];
				a ++;
				n ++;
			}
		}
		if(type == 'L') {
			while(name[n] != '\0') {
				if(n == 0 && 'A' <= name[0] && name[0] <= 'Z') {
					ans[0] = name[0] + 32;
					n ++;
					a ++;
					continue;
				}
				if(name[n] == '_') {
					n ++;
					
					ans[a] = name[n] - 32;
					n ++;
					a ++;
					continue;
				}
				
				ans[a] = name[n];
				a ++;
				n ++;
			}
		}
		if(type == 'D') {
			while(name[n] != '\0') {
				if(n == 0 && 'A' <= name[0] && name[0] <= 'Z') {
					ans[0] = name[0] + 32;
					n ++;
					a ++;
					continue;
				}
				if(n != 0 && 'A' <= name[n] && name[n] <= 'Z') {
					ans[a] = '_';
					a ++;
					
					ans[a] = name[n] + 32;
					a ++;
					n ++;
					continue;
				}
				
				ans[a] = name[n];
				n ++;
				a ++;
			}
		}
		
		ans[a] = '\0';
		printf("%s\n", ans);
	}
	
	return 0;
}

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

#include<iostream>

using namespace std;

int main(){
  int N;
  cin >> N;
  if(N % 2 == 0){
	  cout << (N * N) / 4 << endl;
  }
  else{
	  cout << (N / 2 * (N / 2 + 1)) << endl;
  }
}


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

int main(){
  int n;
  cin >> n;
  vector<int> x(n), y(n);
  vector<ll> h(n);
  rep(i, n) cin >> x[i] >> y[i] >> h[i];
  
  for(int tx = 0; tx <= 100; tx++){
    for(int ty = 0; ty <= 100; ty++){
      ll th = 0;
      bool can = false;
      for(int i = 0; i < n; i++){
        if(th >= 1){
          if(max(th - abs(x[i]-tx) - abs(y[i]-ty) , (ll)0) == h[i]) can = true;
          else {
            can = false;
            break;
          }
        }
        else{
          if(h[i]) th = h[i] + abs(x[i]-tx) + abs(y[i]-ty);
          else continue;
        }
      }
      if(can){
        if(max(th - abs(x[0]-tx) - abs(y[0]-ty) , (ll)0) == h[0]) can = true;
        else {
        can = false;
        }
      }
      if(can){
        cout << tx << " " << ty << " " << th << endl;
        return 0;
      } 
    }
  }
  
}

Measured memory_bytes: 256
x = int(input())

x_max = 10**5 + 3
is_prime = [True] * (x_max + 1)
is_prime[0] = False
is_prime[1] = False

for i in range(2, x_max + 1):
    for j in range(2, x_max + 1):
        ij = i*j
        if ij > x_max:
            break
        is_prime[ij] = False

for i, a in enumerate(is_prime):
    if i >= x and a:
        print(i)
        break


Measured memory_bytes: 3828
package main

import (
    "fmt"
)

func main() {
    var S string
    fmt.Scanf("%s", &S)
    af := false
    bf := false

    for _, s := range S {
        if s == 'A' {
            af = true
        }

        if s == 'B' {
            bf = true
        }
    }
    if af && bf {
        fmt.Println("Yes")
    } else {
        fmt.Println("No")
    }
}

Measured memory_bytes: 512
n, m = map(int, input().split())
A = [[0 for i in range(m)] for j in range(n)]
b = [0 for i in range(m)]
c = [0 for i in range(n)]
for i in range(n):
    A_tmp = input().split()
    for j in range(m):
        A[i][j] = int(A_tmp[j])
for k in range(m):
    b[k] = int(input())
for i in range(n):
    for j in range(m):
        c[i] = c[i] + A[i][j] * b[j]
    print(c[i])


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

int main() {
  string S;
  cin >> S;
  if(S == "RRR") {
    cout << 3 << endl;
  }
  else if(S == "RRS" || S == "SRR") {
    cout << 2 << endl;
  }
  else if(S == "SSS") {
    cout << 0 << endl;
  }
  else {
    cout << 1 << endl;
  }
}

Measured memory_bytes: 3624
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

        int s = scan.nextInt(), w = scan.nextInt();

        if(w >= s) {
            System.out.println("unsafe");
        } else {
            System.out.println("safe");
        }

        scan.close();
        return;
    }
}

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

int main() {
  int N,f;
  cin >> N;
  
  for (int n = 1; n < N+1; n++) {
    f = 0;
    for (int c = 1; c < sqrt(2*n); c++) {
      for (int b = 1; b < sqrt(2*n-c*c); b++) {
        int a = sqrt(2*n-c*c-b*b);
        if (a*a == 2*n-c*c-b*b) {
          if(a + b > c && b + c > a && c + a > b) {
	          f++;
          }
        }
      }
    }
    cout << f << endl;
  }
}

Measured memory_bytes: 3520
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll x, y;
  cin >> x >> y;
  vector<set<ll>> a(3);
  a[0] = {1, 3, 5, 7, 8, 10, 12};
  a[1] = {4, 6, 9, 11};
  a[2] = {2};
  ll tx, ty;
  rep(i, 3) {
    if(a[i].count(x)) tx = i;
    if(a[i].count(y)) ty = i;
  }
  if(tx == ty)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}
module Main where

import Data.List
import Control.Monad
import Debug.Trace
import Data.Bits
import Data.Array.MArray
import Data.Array.ST
import Control.Monad.ST
import Control.Applicative
import Data.STRef

type UnionFind s = (STArray s Int (Maybe Int), STArray s Int Int)
newUnionFind :: Int -> Int -> ST s (UnionFind s)
newUnionFind start end = liftA2 (,) (newArray (start, end) Nothing) (newArray (start, end) 1)

root :: UnionFind s -> Int -> ST s Int
root (u, t) i = do
    parent <- readArray u i
    parent <- case parent of
        Nothing -> do
            writeArray u i $ Just i
            pure i
        Just p ->
            pure p
    if parent == i then pure parent
    else do
        parent' <- root (u, t) parent
        writeArray u i (Just parent')
        pure parent'

unite :: UnionFind s -> Int -> Int -> ST s ()
unite (u, total) ix iy = do
    rx <- root (u, total) ix
    ry <- root (u, total) iy
    if rx == ry then pure ()
    else do 
        sizex <- size (u, total) rx 
        sizey <- size (u, total) ry
        if sizex < sizey then do
            -- yが高い yが親
            writeArray u rx (Just ry)
            writeArray total ry (sizex + sizey) 
        else do
            -- xが高い xが親
            writeArray u ry (Just rx)
            writeArray total rx (sizex + sizey)

same :: UnionFind s -> Int -> Int -> ST s Bool
same u x y = liftA2 (==) (root u x) (root u y)

size :: UnionFind s -> Int -> ST s Int
size (u, t) i = (root (u, t) i) >>= readArray t


solve :: Int -> [Bridge] -> [String]
solve islands bs = runST $ do
    let bs' = reverse $ tail bs
    let initialHuben = islands * (islands -1) `div` 2
    huben <- newSTRef initialHuben
    ans <- newSTRef [show initialHuben] 
    u <- newUnionFind 1 islands
    forM_ bs' $ \b -> do
        let (x, y) = b
        isSame <- same u x y 
        huben' <- readSTRef huben
        ans' <- readSTRef ans
        if huben' == 0 then
            writeSTRef ans ("0" : ans')
        else if isSame then 
            writeSTRef ans (show huben' : ans')
        else do
            huben' <- readSTRef huben
            sizex <- size u x
            sizey <- size u y
            let newHuben = huben' - sizex * sizey
            writeSTRef huben newHuben
            writeSTRef ans (show newHuben : ans')
            unite u x y
    readSTRef ans



        


type Bridge = (Int, Int)

readBridge :: IO Bridge
readBridge = do
    [s, e] <- fmap read . words <$> getLine
    pure (s, e)

main = do
    [n, m] <- fmap read . words <$> getLine
    bridges <- replicateM m readBridge
    putStrLn $ unlines $ solve n bridges


Measured memory_bytes: 73980
#include<cstdio>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
int gcd(int a, int b){
	if(a < b){
		int c = b;
		b = a;
		a = c;
	}
	int c = a % b;
	while(c != 0){
		a = b;
		b = c;
		c = a % b;
	}
	return b;
}

int main(){
  int n;
  int _x;
  cin >> n >> _x;
  vector<int> x = vector<int>(n + 1);
  x[0] = _x;
  for(int i = 0; i < n; i++){
  	cin >> x[i + 1];
  }
  sort(x.begin(), x.end());
  vector<int> dist = vector<int>(n);
  for(int i = 0; i < n; i++){
  	dist[i] = abs(x[i] - x[i + 1]);
  }
  int max_d = dist[0];
  for(int i = 0; i < dist.size() - 1; i++){
  	max_d = gcd(max_d, dist[i + 1]);
  }
  printf("%d\n", max_d);
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long x;
    cin >> x;
    int ans=0;
    double res=100;
    double tmp=res;
    long long tmp1;
    while(true){
        ans++;
        tmp += (double)tmp*(0.01);
        tmp1 = floor(tmp);
        //cout << "ans "<< ans <<"tmp" << tmp << endl;
        if(x<=tmp){
            break;
        }
        tmp = tmp1;
    }
    cout << ans << endl;

}




Measured memory_bytes: 3712
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b , a % b);
}

const ll MOD = 1000000007;
const ll MAX = 2000001;

ll mod(ll a){
  return a % MOD;
}

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

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

void nCrprep() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll nCr(ll n, ll r){
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

ll nCrcheep(ll n,ll r){
  if(r == 0) return 1;
  else if(r == 1) return n;
  else return nCrcheep(n-1,r-1)*n/r;
}

vector<pair<ll,ll>> prime_factorize(ll n){
  vector<pair<ll,ll>> res;
  
  for(ll i=2; i*i <= n; i++){
    if(n % i != 0) continue;
    
    ll ex = 0;
    while(n % i == 0){
      ex++;
      n /= i;
    }
    
    res.push_back({i,ex});
  }
  
  if(n != 1) res.push_back({n,1});
  
  return res;
  
}




int main(){
  ll n,k; cin >> n >> k;
  cout << n-k+1 << endl;
  
  
}

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

int main(){
    int a,b;
    int ans = 0;
    cin >> a >> b;
    for(int i = 1; i <= 2; i++){
        if(a >= b){
            ans += a;
            a--;
        }else{
            ans += b;
            b--;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication20
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = int.Parse(Console.ReadLine());
            int b = int.Parse(Console.ReadLine());
            int c = int.Parse(Console.ReadLine());
            Console.WriteLine(((a + b) * c) / 2);
        }
    }
}


Measured memory_bytes: 2648
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
using namespace std;
using ll = long long;

struct eratosthenes
{
    int n;
    vector<int> f;
    vector<pair<int, int>> primes;

    eratosthenes(int n) : f(n + 1)
    {
        ll i, j;
        f[0] = f[1] = -1;
        for (i = 2; i <= n; i++)
        {
            if (!f[i])
            {
                f[i] = i;
                primes.push_back(make_pair(i, 0));
                for (j = i * i; j <= n; j += i)
                {
                    if (!f[j])
                    {
                        f[j] = i;
                    }
                }
            }
        }
    }

    vector<int> genosis(int x)
    {
        vector<int> g;

        while (x != 1)
        {
            g.push_back(f[x]);
            x /= f[x];
        }

        return g;
    }

    vector<pair<int, int>> genosiscount(int x)
    {
        vector<pair<int, int>> gc;
        vector<int> g = genosis(x);

        if (g.empty() == 1)
        {
            return {};
        }

        gc.push_back(make_pair(f[x], 0));

        for (auto &i : g)
        {
            if (gc.back().first == i)
            {
                gc.back().second++;
            }
            else
            {
                gc.push_back(make_pair(i, 1));
            }
        }

        return gc;
    }
};

ll power(ll x, ll y)
{
    ll ans = 1;
    while (y)
    {
        if (y & 1)
            ans = (ans * x) % 1000000007;
        x = (x * x) % 1000000007;
        y >>= 1;
    }
    return ans;
}

int main(void)
{
    eratosthenes a(1e6 + 1);
    int N;
    int A[10010];
    int i, j;
    ll ans = 0;
    ll lcm = 1;

    cin >> N;

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

        for (auto &j : a.genosiscount(A[i]))
        {
            for (auto &k : a.primes)
            {
                if (j.first == k.first && j.second > k.second)
                {
                    k.second = j.second;
                }

                if (j.first < k.first)
                {
                    break;
                }
            }
        }
    }

    for (auto &x : a.primes)
    {
        lcm = lcm * power(x.first, x.second) % 1000000007;
    }

    for (i = 0; i < N; i++)
    {
        ll add = lcm * power(A[i], 1000000005) % 1000000007;
        ans = (ans + add) % 1000000007;
    }

    cout << ans << endl;
}

Measured memory_bytes: 5880
#include "bits/stdc++.h"
using namespace std;
int main() {
   // cout<<"Hello World!";
   int n,i,ans=0;
   cin>>n;
   int a[2*n];
   for(i=0;i<2*n;i++) cin>>a[i];
   sort(a,a+2*n);
   for(i=2*n-2;i>=0;i-=2)
   ans+=a[i];
   cout<<ans;
}


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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

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

    int n, m; cin >> n >> m;
    cout << (n - 1) * (m - 1) << endl;
    return 0;
}


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

int dice[120][6];
int i,j,k,t,clear=0;

int ue=1;
int hid=4;
int mig=3;
int mae=2;
int usi=5;
int sit=6;

void Move2(int j,int k);
void rndMove();
void eMove();
void nMove();
void sMove();
void wMove();

int main(){
	int n;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		for(j=0;j<6;j++){
			scanf("%d",&dice[i][j]);
		}
	}
	for(j=0;j<n-1;j++){
		for(k=j+1;k<n;k++){
			Move2(j,k);
		}
	}
	
	if(clear==1)printf("No\n");
	else printf("Yes\n");
	
	return 0;
}

void Move2(j,k){
	for(i=0;i<500;i++){
		rndMove();
		
		if((dice[j][0]==dice[k][ue-1])&&(dice[j][1]==dice[k][mae-1])&&
			(dice[j][2]==dice[k][mig-1])&&(dice[j][3]==dice[k][hid-1])&&
			(dice[j][4]==dice[k][usi-1])&&(dice[j][5]==dice[k][sit-1])){
			clear=1;
			break;
		}
	}
	return;
}

void rndMove(){
	int rnd=rand()%4;
		
	if(rnd==0)eMove();
	else if(rnd==1)nMove();
	else if(rnd==2)sMove();
	else wMove();
	
	return;
}

void eMove(){
	t=ue;
	ue=hid;
	hid=sit;
	sit=mig;
	mig=t;
	return;
}

void nMove(){
	t=ue;
	ue=mae;
	mae=sit;
	sit=usi;
	usi=t;
	return;
}

void sMove(){
	t=ue;
	ue=usi;
	usi=sit;
	sit=mae;
	mae=t;
	return;
}

void wMove(){
	t=ue;
	ue=mig;
	mig=sit;
	sit=hid;
	hid=t;
	return;
}


Measured memory_bytes: 2096
import numpy as np
argList = np.array([int(input()) for _ in range(5)])

#調理後次の注文までの残り時間
nokori = 10 - argList % 10
nokori[nokori==10] = 0

#調理後に一番時間が余るメニューを最後に作る
lastMenu = np.argmax(nokori)

jikan = 0
for i in range(5):
    #最後に作るメニューは　作る時間だけ加算
    if( i == lastMenu):
        jikan += argList[i]
    #それ以外は作る時間＋待機時間加算
    else:
        jikan += (argList[i] +nokori[i])
print (jikan)

Measured memory_bytes: 12432
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
 
#define INF 10000000000
#define M 1000000007

#define min(a,b) (((a)<(b))?(a):(b))
#define max(a,b) (((a)>(b))?(a):(b))

int main() {
	long N, L, Q;
	long x[100001];
	long i, j, k;
	long a, b, tmp;
	long move[100001];
	long move100[100001];
	long right;
	long ans[100001] = {0};
	
	scanf("%ld", &N);
	for(i=1;i<=N;i++) scanf("%ld", &x[i]);
	scanf("%ld", &L);
	
	right = 2;
	for(i=1;i<=N;i++) {
		for(j=right;j<=N;j++) {
			if(x[j] - x[i] > L) {
				j--;
				break;
			}
		}
		if(j > N) j = N;
		move[i] = j;
		right = j;
	}
	
	for(i=1;i<=N;i++) {
		k = i;
		for(j=0;j<100;j++) {
			if(k >= N) break;
			k = move[k];
		}
		if(j >= 100) move100[i] = k;
		else move100[i] = -1;
	}
	
	scanf("%ld", &Q);
	for(i=1;i<=Q;i++) {
		scanf("%ld %ld", &a, &b);
		if(a > b) {
			tmp = a;
			a = b;
			b = tmp;
		}
		if(L == 1) {
			ans[i] = b - a;
			continue;
		}
		
		j = a;
		while(move100[j] != -1 && move100[j] < b) {
			j = move100[j];
			ans[i] += 100;
		}
		
		for(;j<b;) {
			j = move[j];
			ans[i]++;
		}
	}
	
	for(i=1;i<=Q;i++) printf("%ld\n", ans[i]);
	
	return 0;
}

Measured memory_bytes: 3840
#include<bits/stdc++.h>
#define FOR0(i,n) for(i=0;i<n;i++)
#define FOR(i,j,n) for(i=j;i<n;i++)
#define FORD(i,j,k) for(i=j;i>=k;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 1000000000
#define ninf -1000000000
#define endl '\n' 
#define she_told_me_dont_worry ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
// Use cout.flush() for interactive problems.
// Use this for increased stack size: g++ -o a.exe -Wl,--stack=256000000 -O2 source.cpp
inline long long  MAX2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  MAX3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  MIN2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  MIN3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< ii > vii;
int main()
{
    she_told_me_dont_worry
    ll n;
    cin>>n;
    ll a[n+5], b[n+5];
    ll i;
    FOR0(i, n+1) cin>>a[i];
    FOR0(i, n) cin>>b[i];
    ll ans = 0;
    FOR0(i, n)
    {
    	ll cur = MIN2(a[i], b[i]);
    	a[i] -= cur;
    	b[i] -= cur;
    	ans += cur;
    	cur = MIN2(a[i+1], b[i]);
    	a[i+1] -= cur;
    	b[i] -= cur;
    	ans += cur;
    }
    cout<<ans<<endl;
    cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
}


Measured memory_bytes: 1792