akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	int N, M, R; cin >> N >> M >> R;
	vector<int> r(R);
	rep(i, 0, R - 1)
	{
		int x; cin >> x;
		r[i] = x - 1;
	}

	vector<vector<ll>> dist(N, vector<ll>(N));
	rep(i, 0, N - 1)rep(j, 0, N - 1)
	{
		dist[i][j] = 2000000000;
		dist[i][i] = 0;
	}
	rep(i, 0, M - 1)
	{
		ll a, b, c; cin >> a >> b >> c;
		--a, --b;
		dist[a][b] = c;
		dist[b][a] = c;
	}
	rep(k, 0, N - 1)rep(i, 0, N - 1)rep(j, 0, N - 1) dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);

	ll ans = 2000000000;
	sort(all(r));
	do
	{
		ll tmp = 0;
		rep(i, 1, R - 1)tmp += dist[r[i]][r[i - 1]];
		ans = min(ans, tmp);
	} while (next_permutation(all(r)));

	cout << ans << endl;
}

Measured memory_bytes: 512
package main

import "fmt"

func main() {
	x := make([]int, 5)
	for i := 0; i < 5; i++ {
		fmt.Scan(&x[i])
	}
	for i := 0; i < 5; i++ {
		if x[i] != i+1 {
			fmt.Println(i + 1)
			return
		}
	}
}


Measured memory_bytes: 1752
#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
	cin.tie(0);
    ios::sync_with_stdio(false);
    long long n,ans=0;
    string s;
    cin>>n>>s;
    for(int i=1;i<n;i++){
        map<char,int> a;
        long long c=0;
        for(int j=0;j<i;j++){
            a[s[j]]=1;
        }
        for(int j=i;j<n;j++){
            if(a[s[j]]==1){
                c++;
                a[s[j]]=0;
            }
        }
        if(c>ans){
            ans=c;
        }
    }
    cout<<ans<<endl;
    return(0);
}

Measured memory_bytes: 3632
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<ctime>
#include<set>
#include<string>
using namespace std;
double eps=1e-9,pi=acos(-1.0);
struct Point
{
    double x,y;
    Point(){}
    Point(double _x,double _y){x=_x;y=_y;}
    double operator*(const Point &b){return x*b.y-y*b.x;}
    Point operator-(const Point &b){return Point(x-b.x,y-b.y);}
    Point operator+(const Point &b){return Point(x+b.x,y+b.y);}
    Point operator*(const double s){return Point(x*s,y*s);}
    double len(){return x*x+y*y;}
}p[30];
int n,Q;
double R;
Point turn(Point a,Point o,double al)
{
    double cs=cos(al),si=sin(al);
    Point ret;
    a=a-o;
    ret.x=a.x*cs-a.y*si;
    ret.y=a.x*si+a.y*cs;
    return o+ret;
}
double dis(Point a,Point b)
{
    return (a-b).len();
}
int main()
{
    while(scanf("%d%lf%d",&n,&R,&Q))
    {
        if(n==0&&Q==0)break;
        int o;
        R=R*R;
        for(int i=0;i<n;i++)
        {
            scanf("%lf%lf",&p[i].x,&p[i].y);
            if(fabs(p[i].len()-R)<eps)o=i;
        }
        //for(int i=1;i<n;i++)printf("%f\n",turn(p[i],p[0],0.0).len());
        for(int jj=1;jj<=Q;jj++)
        {
            double l=0,r=pi,m;
            int tim=90;
            while(tim--)
            {
                m=(l+r)*.5;
                int big=0;
                for(int i=0;i<n;i++)
                if(i!=o)
                {
                    if(turn(p[i],p[o],m).len()>R+eps)
                    {
                        big=1;
                        break;
                    }
                }
                //printf("m=%f big=%d\n",m,big);
                if(big)r=m;
                else l=m;
            }
            //printf("m=%f\n",m);
            Point tp=p[o];
            for(int i=0;i<n;i++)
            if(i!=o)p[i]=turn(p[i],p[o],m);
            //for(int i=0;i<n;i++)printf("%f %f %f\n",p[i].x,p[i].y,p[i].len());
            int o2=-1;
            double ma;
            for(int i=0;i<n;i++)
            if(i!=o&&fabs(p[i].len()-R)<1e-7)
            {
                //printf("i=%d\n",i);
                if(o2==-1||dis(p[i],tp)>ma)
                {
                    ma=dis(p[i],tp);
                    o2=i;
                }
            }
            printf("%.8f %.8f\n",p[o2].x,p[o2].y);
            o=o2;
        }
    }
}

Measured memory_bytes: 1256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define MOD 1000000007

int main(void){
    ll n,k;
    cin >> n >> k;
    if(n<=k){
        cout << "0\n";
        return 0;
    }
    vector<ll> H(n);
    rep(i,n) cin >> H[i];
    sort(all(H));
    ll ans=accumulate(H.begin(), H.end()-k, 0LL);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int t[10];

vector <int> ans;

bool check(int,int,int);

int main(){
	string str;
	while(cin>>str){
		for(int i=0;i<10;i++)t[i]=0;
		for(int i=0;i<13;i++)t[str[i]-'0']++;
		ans.clear();
		for(int i=1;i<=9;i++){
			if(t[i]==4)continue;
			t[i]++;
			if(check(1,0,0))ans.push_back(i);
			t[i]--;
		}
		if(ans.size()==0)cout<<0<<endl;
		else {
			for(int i=0;i<(int)ans.size();i++){
				if(i)cout<<" ";
				cout<<ans[i];
			}
			cout<<endl;
		}
	}
	return 0;
}

bool check(int x,int y,int z){
	bool flg=false;
	if(x==10){
		if(y==1&&z==4)return true;
		else return false;
	}
	if(t[x]==0)return check(x+1,y,z);

	if(t[x]>=2&&y==0){
		t[x]-=2;
		flg = check(x,1,z);
		t[x]+=2;
	}
	if(flg)return flg;

	if(t[x]>=3&&z<=3){
		t[x]-=3;
		flg = check(x,y,z+1);
		t[x]+=3;
	}
	if(flg)return flg;

	if(z<=3){
		if(x+2<=9){
			if(t[x]>=1&&t[x+1]>=1&&t[x+2]>=1){
				t[x]--;t[x+1]--;t[x+2]--;
				flg= check(x,y,z+1);
				t[x]++;t[x+1]++;t[x+2]++;
			}
		}
	}
	if(flg)return flg;

	return false;
}

Measured memory_bytes: 1204
import math
N,M = list(map(int,input().split(" ")))
ll = -10e9
rr = (10e9)
for i in range(M):
    l,r = list(map(int, input().split(" ")))
    if l > ll:
        ll = l
    if r  <  rr :
        rr = r
ans = max(rr - ll + 1,0)
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
struct Point
{
    ld x,y;
    Point():x(0),y(0){}
    Point(ld _x,ld _y):x(_x),y(_y){}
    Point operator +(const Point &p) const
    {return Point(x+p.x,y+p.y);}
    Point operator -(const Point &p) const
    {return Point(x-p.x,y-p.y);}
    ld operator *(const Point &p) const
    {return x*p.x+y*p.y;}
    ld operator %(const Point &p) const
    {return x*p.y-y*p.x;}   
    bool operator <(const Point &p) const
    {return tie(y,x) < tie(p.y,p.x);}
    bool operator ==(const Point &p) const
    {return tie(y,x) == tie(p.y,p.x);}
};
vector<Point> convex_hull(vector<Point> v)    
{
    //O(nlgn)
    sort(v.begin(),v.end(),[&](const Point &a,const Point &b){return tie(a.y,a.x) < tie(b.y,b.x);});
    v.erase(unique(v.begin(),v.end(),[&](const Point &a,const Point &b){return tie(a.y,a.x)==tie(b.y,b.x);}),v.end());
    if(v.size()<=2u) return v;

    vector<Point> up;
    for(auto p:v)
    {
        while(up.size()>=2u && (p-up.back())%(up.back()-up[up.size()-2])<0)
            up.pop_back();
        up.push_back(p);
    }
    vector<Point> dn;
    for(auto p:v)
    {
        while(dn.size()>=2u && (p-dn.back())%(dn.back()-dn[dn.size()-2])>0)
            dn.pop_back();
        dn.push_back(p);
    }
    reverse(dn.begin(),dn.end());
    up.insert(up.end(),dn.begin()+1,dn.end()-1);
    return move(up);
}

int main()
{
    int n;cin>>n;
    vector<Point> v(n);
    for(auto &p:v) cin>>p.x>>p.y;
    auto c=convex_hull(v);
    rotate(c.begin(),c.begin()+1,c.end());
    reverse(c.begin(),c.end());
    printf("%d\n",(int)c.size());
    for(auto p:c) cout<<p.x<<" "<<p.y<<endl;
    return 0;
}

Measured memory_bytes: 12948
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		for (; solver.hasNext();) {
			solver.readBody(in.readLine());
		}
	}
}

class Solver {
	int N;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	public void readHead(String str) {
		String[] strArr = str.split(" ");
		N = Integer.parseInt(strArr[0]);
		// System.out.println(N);
	}

	public boolean hasNext() {
		return cnt < 1;
	}

	private int[] a;

	public void readBody(String str) {
		String[] strArr = str.split(" ");
		int[] a = new int[N];
		for (int i = 0; i < N; i++)
			a[i] = Integer.parseInt(strArr[i]);

		int c = 1;
		int d = 0;
		for (int i = 1; i < N; i++) {
			if (a[i - 1] > a[i]) {
				if (d == 1) {
					c++;
					d = 0;
				} else
					d = -1;
			} else if (a[i - 1] < a[i]) {
				if (d == -1) {
					c++;
					d = 0;
				} else
					d = 1;
			}
		}
		System.out.println(c);
		cnt++;
	}

}


Measured memory_bytes: 38996
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<climits>
#include<queue>
#include<stack>
	
int main(){
	int ans=1;

	int n;
	std::cin>>n;
	
	while(ans*2<= n)
		ans*=2;

	std::cout<<ans<<std::endl;

	return 0;
	
	
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
using namespace std;

int main(){
    int N,h[110],dp;cin>>N>>h[0];
    dp=h[0];
    for(int i=1;i<N;++i){
        cin>>h[i];
        if(h[i]>h[i-1])dp+=h[i]-h[i-1];
    }
    cout<<dp<<endl;
    return 0;
}

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

class Sweet {
public:
    int i_, p_, q_, r_, c_;

    Sweet(int i, int p, int q, int r) {
        i_ = i;
        p_ = p;
        q_ = q;
        r_ = r;
        c_ = 4 * p + 9 * q + 4 * r;
    }

    bool canEat(int p, int q, int r, int c) {
        return p_ <= p && q_ <= q && r_ <= r && c_ <= c;
    }
};

int main() {
    int n;
    while (cin >> n, n) {
        vector<Sweet> ss;
        for (int i = 0; i < n; i++) {
            int id, p, q, r;
            cin >> id >> p >> q >> r;
            ss.push_back(Sweet(id, p, q, r));
        }
        int p, q, r, c;
        cin >> p >> q >> r >> c;
        vector<int> ans;
        for (int i = 0; i < n; i++) {
            if (ss[i].canEat(p, q, r, c)) {
                ans.push_back(ss[i].i_);
            }
        }
        if (ans.empty()) {
            cout << "NA" << endl;
            continue;
        }
        for (vector<int>::iterator it = ans.begin(); it != ans.end(); it++) {
            cout << *it << endl;
        }
    }
}

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

int main(){
    int n;
    string s;
    cin>>n>>s;
    int ans=1e9;
    vector<int> a(n+1),b(n+1);
    for(int i=1;i<=n;i++){
        if(s[i-1]=='W'){
            a[i]=a[i-1]+1;
        }else{
            a[i]=a[i-1];
        }
        if(s[i-1]=='E'){
            b[i]=b[i-1]+1;
        }else{
            b[i]=b[i-1];
        }
    }
    rep(i,n+1){
        ans = min(ans,a[i]+b[n]-b[i]);
    }
    
    cout << ans <<endl;
    
    return 0;
}



Measured memory_bytes: 3076
#include<stdio.h>
int main(void){
    int S;
    scanf("%d", &S);
    int h = S / 3600;
    int M = S % 3600;
    int m = M / 60;
    int s = M % 60;
    printf("%d:%d:%d\n", h, m, s);
    return 0;
}


Measured memory_bytes: 2052
b,r,g,c,s,t;main(){while(1){scanf("%d%d%d%d%d%d",&b,&r,&g,&c,&s,&t);if(!t)break;printf("%d\n",100-(t-s)*3+c*2+g*7+15*(6*b+4*r)+b*5+r*3);}return 0;}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vb = vector<bool>;
using vll = vector<long long>;
using vpii = vector<pair<int,int>>;
using vivi = vector<vector<int>>;
using vbvb = vector<vector<bool>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int mod = 1000000007;
const int inf = 1001001001;

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




Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
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;}
const int inf = 1001001001;

int main() {
    ll a,b,c;
    cin >> a >> b >> c;
    if(c-a-b > 0 && 4*a*b < (c-a-b)*(c-a-b)) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

typedef long long ll;
typedef long double ld;

#define pb push_back
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

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

//素数判定
bool isPrime(ll x){
    ll 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(ll n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

//桁数
int dignum(ll n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

//文字列中の特定の文字カウント
ll stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}

//階乗
ll ka(ll i){
    ll res=1;
    while(i>0){
        res=res*i;
        i--;
    }
    return res;
}
 
//ncr
ll ncr(ll x,ll y){
    ll a = x;
    ll b = 1;
    if(y>(x/2)){
        y=x-y;
    }
    for(ll i=1;i<y;i++){
        a*=x-i;
        b*=i+1;
    }
    return a/b;
}

//フィボナッチ数列 -92
ll f(ll x){
    ll dp[x+1];
    dp[1]=1;
    dp[2]=1;
    for(ll i=3;i<=x;i++){
        dp[i]=dp[i-1]+dp[i-2];
    }
    return dp[x];
}



int main(){
    int A,B,M;
    cin >> A >> B >> M;
    vector<int> a(A);
    vector<int> b(B);
    rep(i,A) cin >> a[i];

    rep(i,B) cin >> b[i];

    int x[M],y[M],c[M];
    rep(i,M){
        cin >> x[i] >> y[i] >> c[i];
    }

    ll ans = a[x[0]-1]+b[y[0]-1]-c[0];

    for(int i=0;i<M;i++){
        ll sum =a[x[i]-1]+b[y[i]-1]-c[i];
        ans = min(ans,sum);
    }

    sort(a);
    sort(b);
    ll o = a[0]+b[0];
    ans = min(ans,o);
    cout << ans << endl;
}

Measured memory_bytes: 2176
import sys
readline = sys.stdin.buffer.readline

n = int(readline())

alphabets = [chr(ord('a') + x) for x in range(26)]

def dfs(s,i):
    if len(s)==n:
        print("".join(s))
    else:
        t = min(len(set(s))+1,len(s)+1) #ループに使える文字は、現在の文字の種類+1か((a,b)の時、dは使えない)、長さ+1(1文字目は必ずa以下、2文字目は必ずb以下)の小さい方
        for i in range(t):
            dfs(s+[alphabets[i]],i) #dfsで全通り

dfs([],0)

Measured memory_bytes: 4340
#include <bits/stdc++.h>
using namespace std;
#define all(V) V.begin(),V.end()
#define ll long long
#define MOD 1000000007

int main(){
	int A, B, C, a, b, c, cnt = 0;
	cin >> A >> B >> C;
	while (cnt < 100) {
		if (A & 1)break;
		if (B & 1)break;
		if (C & 1)break;
		a = B / 2 + C / 2;
		b = A / 2 + C / 2;
		c = A / 2 + B / 2;
		A = a;
		B = b;
		C = c;
		cnt++;
	}
	if (cnt == 100)cout << -1 << endl;
	else cout << cnt << endl;
}

Measured memory_bytes: 256
/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
        Comilla  University

*/
#include<bits/stdc++.h>
#define pi 2*acos(0.0)
#define ll long long
#define pf printf
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Node struct node
#define spc " "

using namespace std;
///check n=1;
///check corner case;

int main()
{
   ll n;
   cin>>n;
   (n%2==0)? cout<<n/2<<endl : cout<<n/2+1<<endl;
return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

typedef long long ll;

int main () {
	ll n, m;
	ll a;
	ll i, j;
	ll ret = 0;
	
	cin >> n;
	cin >> m;
	for (i = 0; i<m; i++) {
		cin >> a;
		ret += a;
	}
	
	ret = n - ret;
	if ( ret < 0 ) {
		cout << -1 << endl;
	}
	else {
		cout << ret << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(int i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}
void OUT(bool b){cout<<(b?"YES":"NO")<<endl;}
void Out(bool b){cout<<(b?"Yes":"No")<<endl;}
void out(bool b){cout<<(b?"yes":"no")<<endl;}
int popcnt(int x){return __builtin_popcount(x);}
int popcnt(ll x){return __builtin_popcountll(x);}
int bsr(int x){return 31 - __builtin_clz(x);}
int bsr(ll x){return 63 - __builtin_clzll(x);}
int bsf(int x){return __builtin_ctz(x);}
int bsf(ll x){return __builtin_ctzll(x);}

/*他のライブラリを入れる場所*/

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin>>s;
	cout<<count(all(s),'2')<<endl;
	return 0;
}

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

int main()
{
    ll n, m, x;
    cin >> n >> m >> x;

    vector<vector<ll>> a(n, vector<ll>(m+1));
    rep(i, n){
        cin >> a[i][0];
        rep(j, m){
            cin >> a[i][j+1];
        }
    }

    ll min_cc = LLONG_MAX;

    for (ll i=0;i<(1<<n);i++){
        vector<ll> aa(m, 0);
        ll cc = 0;
        for(ll j=0;j<n;j++){
            if (i & (1 << j)){
                cc += a[j][0];
                rep(jj, m){
                    aa[jj] += a[j][jj+1];
                }
            }
        }

        bool flg = true;
        rep(jj, m){
            if (aa[jj] < x) {
                flg = false;
            }
        }

        if (flg){
            min_cc = min(min_cc, cc);
        }
    }


    if (min_cc == LLONG_MAX){
        cout << -1 << endl;
    }else{
        cout << min_cc << endl;
    }
}


Measured memory_bytes: 3632
from sys import stdin
sp = stdin.readline().split()
A,B,K = int(sp[0]), int(sp[1]), int(sp[2])
def div(num):
    l = []
    for itr in range(1,num+1):
        if num % itr == 0:
            l.append(itr)
    return l

al = set(div(A))
bl = set(div(B))
ans = list(al & bl)
ans = sorted(ans)
ans.reverse()
print(ans[K-1])

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

using namespace std;
 
int main() {
 int N,flag;
 cin >> N;
 flag = 0;
  
  char a[N];
  
	for (int i = 0; i < N; i++){
      cin >> a[i];
      if (a[i] == 'Y'){
        flag++;
      }
    }
  
  if (flag > 0){
    cout << "Four" << endl;
  }
  else{
    cout << "Three" << endl;
  }

}

Measured memory_bytes: 256
n = int(input())
aaa = list(map(int, input().split()))

MOD = 10 ** 9 + 7
ans = 0
m = 1
for _ in range(60):
    bit = sum(a & m for a in aaa)
    bit //= m
    non_bit = n - bit
    ans = (ans + bit * non_bit * m) % MOD
    m <<= 1
print(ans)


Measured memory_bytes: 42156
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
  int n, m;
  cin >> n >> m;
  vector<int> v(n);
  rep(i,n) cin >> v[i];
  sort(ALL(v));
  int ans = INF;
  rep(i,n-m+1) {
    int sa = abs(v[i] - v[i+m-1]);
    ans = min(ans, sa);
  }
  cout << ans << endl;
}

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

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

int main() {
    int n, l, maximum = 0, sum = 0;
    cin >> n;
    rep(i, n) {
        cin >> l;
        sum += l;
        maximum = max(maximum, l);
    }
    if(sum - maximum > maximum) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 384
#include<stdio.h>
int main(){
  int a[50],b[50],n,m,ans[50],i;

  for(i=0; i<=50; i++){
    ans[i]=0;
  }

  scanf("%d%d",&n, &m);
  for(i=0; i<m; i++){
    scanf("%d%d", &a[i],&b[i]);
    ans[a[i]]++;
    ans[b[i]]++;
  }
  for(i=1; i<=n; i++){
    printf("%d\n",ans[i]);
  }
  return 0;


}


Measured memory_bytes: 128
#!/usr/bin/env python3
# Generated by https://github.com/kyuridenamida/atcoder-tools
from typing import *
import collections
import itertools
import math
import sys

INF = float('inf')


def solve(N: int):
    return sum([i for i in range(N+1) if i % 3 * i % 5])


def main():

    sys.setrecursionlimit(10 ** 6)

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    print(f'{solve(N)}')


if __name__ == '__main__':
    main()


Measured memory_bytes: 106932
#include <algorithm>
#include <cassert>
#include <iostream>
#include <numeric>
#include <set>
#include <tuple>
#include <vector>
using namespace std;

int main() {
  int d, g;
  cin >> d >> g;
  vector<int> p(d + 1), c(d + 1);
  for (int i = 0; i < d; ++i) cin >> p[i+1] >> c[i+1];
  ++d;
  int result = numeric_limits<int>::max();
  for (int mask = 0; mask < (1<<d); ++mask) {
    int need = 0, score = 0;
    for (int i = 0; i < d; ++i){
      if(mask>>i&1) {
        need += p[i];
        score += p[i] * i * 100;
        score += c[i];
      }
    }
    for (int i = d-1; i >= 0; --i) {
      if ((~mask)>>i&1) {
        for (int t = 0; t < p[i]; ++t) {
          if (score < g) {
            score += i * 100;
            ++need;
          } else {
            break;
          }
        }
      }
    }
    if (score >= g) {
      result = min(result, need);
    }
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
  string s; cin >> s;
  bool ans = true;
  for(int i = 0; i < (s.size() - 1) / 2; i++) {
    if(s[i] != s[s.size() - 1 - i] || s[i] != s[(s.size() - 1) / 2 - 1 - i]) {
      ans = false; break;
    }
  }
  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
   
  int N,M,ans = 0;
  cin >> N >> M;
  int data[N][M];
  
  for(int i=0;i<N;i++){
      for(int j=0;j<M;j++){
          data[i][j] = 0;
      }
  }
  
  for(int i=0;i<N;i++){
      int K;
      cin >> K;
      for(int j=0;j<K;j++){
          int A_i;
          cin >> A_i;
          data[i][A_i-1] = 1;
      }
  }
  
   for(int i=0;i<M;i++){
       int sum = 0;
      for(int j=0;j<N;j++){
          if(data[j][i] == 1) sum++;
      }
      if(sum == N) ans++;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3628
// author : Kartikey Tewari
// date: 2020-02-13   23:15:27
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define endl '\n'
using namespace std;

int main()
{
    ll n,k;
    cin >> n >> k;
    ll arr[n];
    for (ll i=0;i<=n-1;i++)
    {
        cin >> arr[i];
    }   

    sort(arr,arr+n);
    if (k>=n)
    {
        cout << "0" << endl;
    }
    else
    {
        ll count=0;
        for (ll i=0;i<=n-k-1;i++)
        {
            count=count+arr[i];
        }
        cout << count << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
        String line = bufferedReader.readLine();
        int N = Integer.parseInt(line);
        String[] lines = bufferedReader.readLine().split(" ");
        List<String> Astr = Arrays.asList(lines);
        for (String s : Astr) {
            if (s.equals("0")) {
                System.out.println("0");
                return;
            }
        }
        List<BigInteger> A = Astr.stream().map(BigInteger::new).collect(Collectors.toList());
        BigInteger res = new BigInteger("1");
        BigInteger lim = new BigInteger("1000000000000000000");
        for (BigInteger a : A) {
            res = res.multiply(a);
            if (res.compareTo(lim) > 0) {
                System.out.println("-1");
                return;
            }
        }
        System.out.println(res.compareTo(lim) > 0 ? "-1" : res.toString());
    }
}


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

int main(void) {
  int n;
  cin >> n;
  
  map<char,int> m;
  for (int i = 1; i <= n; i++) {
    string s;
    cin >> s;
    m[s[0]]++;
  }
  vector<int> v;
  v.push_back(m['M']);
  v.push_back(m['A']);
  v.push_back(m['R']);
  v.push_back(m['C']);
  v.push_back(m['H']);

  ll ans=0;
  for (int i = 0; i < 5; i++) {
    for (int j = i+1; j < 5; j++) {
      for (int k = j+1; k < 5; k++) {
	ans+=(ll)v[i]*v[j]*v[k];
      }
    }
  }
  cout << ans << endl;
  
  return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;

int main(){
    int N;
    int a[10001];
    cin >> N;
    for(int i=0;i<N;i++) cin >> a[i];
    a[N]=0;
    int ans=0;
    for(int i=1;i<N;i++){
        if(a[i]==a[i-1]){
            a[i]=a[i-1]+a[i+1];
            ans++;
        }
    }

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

Measured memory_bytes: 256
// * Act locally, think globally.

#include <bits/stdc++.h>

using namespace std;

#define fastio ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)

signed main()
{
    int s, w;
    cin >> s >> w;
    if (s <= w)
    {
        cout << "unsafe";
    }
    else
    {
        cout << "safe";
    }
    return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef vector<int> vec1;
typedef vector<string> vec2;
typedef vector<double> vec3;

int main() {
  
  int r;
  cin >> r;
  double a = 2 * 3.14 * r;
  cout << a << endl;
}

Measured memory_bytes: 3780
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int i=a; i<n; i++)
#define repr(i,a,n) for(int i=a; i>=n; i--)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 999999999

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long int ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

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

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

vector<L> tangentLines(C x, C y) {
    P a = x.first, b = y.first;
    double ar = x.second, br = y.second;
    vector<L> ls;
    double d = abs(b-a);

    rep(i,0,2) {
        double sin = (ar - (1-i*2)*br) / d;
        if(!LE(sin*sin, 1)) break;

        double cos = sqrt(max(1 - sin*sin, 0.0));
        rep(j,0,2) {
            P n = (b-a) * P(sin, (1-j*2)*cos) / d;
            ls.push_back(L(a + ar*n, b + (1-i+2)*br*n));
            if(cos < EPS) break;
        }
    }
    return ls;
}

int main() {
    C a, b;
    cin >> a.fr.X >> a.fr.Y >> a.sc >> b.fr.X >> b.fr.Y >> b.sc;
    vector<L> ans = tangentLines(a, b);
    sort(ans.begin(), ans.end());
    rep(i,0,ans.size()) {
        if(abs(ans[i].fr.X) < EPS) ans[i].fr.X = 0.0;
        if(abs(ans[i].fr.Y) < EPS) ans[i].fr.Y = 0.0;
        printf("%.10f %.10f\n", ans[i].fr.X, ans[i].fr.Y);
    }
    return 0;
}

Measured memory_bytes: 3352
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = 1001002003004005006ll;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll a, b, c;
	cin >> a >> b >> c;
	if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0) {
		cout << 0 << endl;
		return 0;
	}
	ll ans = min(a * b, b * c);
	mins(ans, a * c);
	cout << ans << endl;
	return 0;
}

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

using namespace std;
#define inputInt(a) int a; cin >> a; 
#define inputInt2(a,b) int a; int b; cin >> a >> b; 
#define inputInt3(a,b,c) int a; int b; int c; cin >> a >> b >> c;
#define inputLong(a) long a;cin >> a; 
#define inputIntArray(a,N) int a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputLongArray(a,N) long a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputIntArray2(a,b,N) int a[N]; int b[N]; for(int i=0;i<N;i++){cin >> a[i] >> b[i];}
#define output(answer) cout << answer << endl;
#define fN(i,N)    for(int i=0; i<N; i++)
#define fSE(i,s,e) for(int i=s; i<=e; i++)
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i,N) for(int i=0; i<N; i++)
#define cinv(v,N) vector<int> v(N); for(int i=0; i<N; i++){ cin >> v[i]; }
#define mt make_tuple
const ll MOD2 = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

//繰り返し2乗法
ll power(ll x, ll y){//繰り返し2乗法
  if(y < 0){
    return 0;
  }else if(y == 0){
    return 1LL;
  }else if(y%2 == 0){//偶数
    return power(x,y/2)*power(x,y/2);
  }else{//奇数
    return power(x,y-1)*x;
  }
}

int main()
{
  //input
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll N; cin >> N;
  //各々の証言の数。
  vector<ll> a(N,0);
  //N人が最大N-1個のfirstはsecondであるという証言をした。
  vector<vector<pair<ll,ll>>> test(N,vector<pair<ll,ll>>(N-1,mp(-1,-1)));
  FOR(i,N){ cin >> a[i]; FOR(j,a[i]){ cin >> test[i][j].fi >> test[i][j].se; test[i][j].fi --; }}
  
  //main
  //組み合わせについてbit全探索
  ll ans = 0;
  for(int i=0; i<power(2,N); i++){//bit列。
    ll count = 0;
    
    for(int j=0; j<N; j++){//j(0...N-1)人目を検証。
      if((i>>j)%2){//j(0...N-1)人目が正直者の時。
        for(int k=0; k<a[j]; k++){//j(0...N-1)人目のk個の証言を検証
          if((i>>(test[j][k].fi))%2 != test[j][k].se){ 
            goto endloop;//多重ループを抜けるため...
          }
        }
        count ++;
      }
    }
    ans = max(ans,count);//矛盾しなかった時のみ最大値を更新。
    
    endloop: ;//何もしない
    
  }
  
  // output
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<set>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll, ll> pll;
//int dx[4] = { 1,0,0,-1 };
//int dy[4] = { 0,1,-1,0 };
#define MOD 1000000007
#define ARRAY_MAX 1005

const int INF = 1e9 + 7;

int n;
vector<pii> G[ARRAY_MAX];
int semi[ARRAY_MAX];//1-index

int dfs(int now, int pre) {

	if (semi[now] > 0) {
		return INF;
	}

	int res = 0;
	for (int i = 0; i < G[now].size(); i++)
	{
		int to = G[now][i].first;
		int cost = G[now][i].second;
		if (to == pre)
		{
			continue;
		}
		res += min(cost, dfs(to, now));
	}
	return res;
}



int main(){


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

	cin >> n;
	for (int i = 1; i <= n-1; i++)
	{
		int c;
		cin >> c;
		semi[i] = c > 0;
	}

	for (int i = 0; i < n-1; i++)
	{
		int u, v, p;
		cin >> u >> v >> p;
		G[u].push_back(pii(v, p));
		G[v].push_back(pii(u, p));
	}

	cout << dfs(0, -1) << endl;


	return 0;
}



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

int main() {
  int A, B, C, D, L, R ;
  cin >> A >> B >> C >> D ;
  L = A+B;
  R = C+D;
  if (L > R) {
  	cout << "Left" << endl;
  }
  else if(L == R){
  	cout << "Balanced" << endl;
  }
  else if(L < R){
  	cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
using P=pair<int,int>;
using lint=long long;
using ll=long long;
const lint inf=1e18+7;
const int MOD=1000000007;
signed main(){
  int n;cin>>n;
  vector<int> a(n);
  rep(i,n)cin>>a[i];
  sort(a.begin(),a.end());
  bool flag;
  if(a[0]==a[n-1]){
    flag=a[0]<=n/2;
    if(a[0]==n-1)flag=true;
  }
  else{
    int ind=0;
    rep(i,n){
      if(a[i]!=a[0]){
        ind=i;
        break;
      }
    }
    int k=ind;
    flag=a[n-1]<=k+(n-k)/2;
    if(a[n-1]<k+1)flag=false;
    if(a[0]>k-1+(n-k)/2)flag=false;
    if(n-k<2)flag=false;
    if(a[0]!=a[n-1]-1)flag=false;
  }
	if(flag){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
  return 0;
}


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

using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define pb push_back
#define endl "\n"

const ll N = 1e6 + 7;
const double PI = acos(-1);
ll mod = 1e9 + 7;
ll modexpo(ll b, ll p)
{
	ll res = 1;
	while(p)
	{
		if(p & 1)
			res *= b;
		p >>= 1;
		b *= b;
		b %= mod;
		res %= mod;
	}
	return res;
}

ll modinverse(ll b)
{
	return modexpo(b, mod-2);
}


int32_t main()
{
	
	IOS
	
	ll n, k;
	cin>>n>>k;
	ll res = 1;
	ll res2 = n - k + 1;
	ll fi = 1, fi1 = 1;
	for(int i=1;i<=k;i++)
	{
		fi *= i;
		fi %= mod;
		if(i > 1)
			fi1 = fi1 * (i-1);
		fi1 %= mod;
		ll ans = res * res2;
		ans %= mod;
		ans *= modinverse(fi1);
		ans %= mod;
		ans *= modinverse(fi);
		ans %= mod;
		res *= (k-i);
		res %= mod;
		res2 *= (n - k + 1 - i);
		res2 %= mod;
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <cstdio>
#include <algorithm>
#include <map>
#include <queue>
using namespace std;

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

double a[200010];
double r[200010];

int main() {
    int n, k;
    cin >> n >> k;
    double ans = 0.0;

    rep(i, n){
        double p;
        cin >> p;
        a[i] = (p + 1);
    }

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

    for(int i = 0; i <= n; ++i){
        double t = r[i + k] - r[i];
        ans = std::max(ans, t);
    }

    printf("%.12lf", (ans / 2.0));
}

Measured memory_bytes: 3328
#include <stdio.h>
#include <string.h>
#include <iostream>

using namespace std;

long long int dp[21];
long long int dpw[21];

int main()
{
	long long int n;
	scanf("%lld",&n);
	for(int i = 0; i <= 20; i++)
	{
		dp[i] = 0;
	}
	long long int ww;
	scanf("%lld",&ww);
	dp[ww] = 1;
	for(int i = 0; i < n - 2; i++)
	{
		for(int j = 0; j <= 20; j++)
		{
			dpw[j] = 0;
		}
		long long int w;
		scanf("%lld",&w);
		for(long long int j = 0; j <= 20; j++)
		{
			long long int t = j + w;
			if(w <= 20)
			{
				dpw[t] += dp[j];
			}
			long long int h = j - w;
			if(h >= 0)
			{
				dpw[h] += dp[j];
			}
		}
		for(long long int j = 0; j <= 20; j++)
		{
			dp[j] = dpw[j];
		}
	}
	scanf("%lld",&ww);
	printf("%lld\n",dp[ww]);
	return 0;
}

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

using lli = long long int;
using Vint = vector<int>;
using Vlli = vector<lli>;
using Wint = vector<Vint>;
using Wlli = vector<Vlli>;
using pii = pair<int, int>;
using pll = pair<lli, lli>;

const int MOD = 1e9 + 7;
const int INFi = 2e9 + 1;
const lli INFl = (lli)(9e18) + 1;
const vector<pii> DXDY = {make_pair(1, 0), make_pair(-1, 0), make_pair(0, 1), make_pair(0, -1)};

#define FOR(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define FOReq(i, a, b) for(int (i) = (a); (i) <= (b); (i)++)
#define rFOR(i, a, b) for(int (i) = (b); (i) >= (a); i--)
#define FORstep(i, a, b, step) for(int (i) = (a); i < (b); i += (step))
#define REP(i, n) FOR(i, 0, n)
#define rREP(i, n) rFOR(i, 0, (n-1))
#define vREP(i, vec) for(auto &(i) : (vec))


template <class T> inline int argmin(vector<T> vec){return min_element(vec.begin(), vec.end()) - vec.begin();}
template <class T> inline int argmax(vector<T> vec){return max_element(vec.begin(), vec.end()) - vec.begin();}
template <class T> inline void chmax(T &a, T b){a = max(a, b);}
template <class T> inline void chmin(T &a, T b){a = min(a, b);}
inline int toInt(string &s){int res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
inline int toInt(const string s){int res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
inline long long int toLong(string &s){lli res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
inline long long int toLong(const string s){lli res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
template <class T> inline std::string toString(T n){
  if(n == 0) return "0";
  std::string res = "";
  if(n < 0){n = -n;while(n != 0){res += (char)(n % 10 + '0'); n /= 10;} std::reverse(res.begin(), res.end()); return '-' + res;}
  while(n != 0){res += (char)(n % 10 + '0'); n /= 10;} std::reverse(res.begin(), res.end()); return res;
}

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


int main(void){
  int n, res = 0; cin >> n;
  Vint A(n + 1, 0), B(n + 1, 0);
  REP(i, n){
    cin >> A.at(i + 1);
    A.at(i + 1) += A.at(i);
  }
  REP(i, n){
    cin >> B.at(i + 1);
    B.at(i + 1) += B.at(i);
  }
  REP(i, n) chmax(res, B.at(n) + A.at(i + 1) - B.at(i));
  cout << res << '\n';
  return 0;
}

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

int main()
{
    int n, m;
    cin >> n >> m;
    map<int, pair<int, int>> h;
    
    for(int i = 0; i < m; i++)
    {
        int p;
        string s;
        cin >> p >> s;
        if(s == "AC")
        {
            h[p].second++;
        }
        else
        {
            if(!h[p].second)
            {
                h[p].first++;
            }
        }
    }
    int t = 0, f = 0;
    for(auto e : h)
    {
        t += (e.second.second ? 1 : 0);
        f += (e.second.second ? e.second.first : 0);
    }
    cout << t << " " << f << endl;
    
    return 0;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define Dim 200020
using namespace std;
ifstream f("A.in");
typedef long long ll;
ll poz[Dim],N,K,A[Dim],cnt,last=1,now;
bool viz[Dim];
ll V[Dim];

int main()
{
    cin>>N>>K;
    for(int i=1;i<=N;i++) cin>>A[i];
    if(K==0)
    {
        cout<<1;
        return 0;
    }
    poz[1]=0;
    viz[1]=1;
    V[0]=1;
    while(K)
    {
        now=A[last];
        K--;
        cnt++;
        if(viz[now]==0)
        {
            poz[now]=cnt;
            viz[now]=1;
            V[cnt]=now;
            last=now;
        }
        else
        {
            ll dif=cnt-poz[now];
            ll remain=K%dif;
            cout<<V[poz[now]+remain];
            return 0;
        }
    }
    cout<<now;

    return 0;
}


Measured memory_bytes: 8148
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  if(a==1){
    if(b==2){
      cout<<3;
      return 0;
    }else if(b==3){
      cout<<2;
      return 0;
    }
  }else if(a==2){
    if(b==1){
      cout<<3;
      return 0;
    }else if(b==3){
      cout<<1;
      return 0;
    }
  }else {
    if(b==2){
      cout<<1;
      return 0;
    }else if(b==1){
      cout<<2;
      return 0;
    }
  }
} 

Measured memory_bytes: 256
def shu(a,b):
	for i in range(a):
		b[i]=list(map(int,input().split()))
n,m,l = map(int,input().split())
A=[[]for i in range(n)]
B=[[]for i in range(m)]
C=[[0 for i in range(l)]for i in range(n)]
shu(n,A)
shu(m,B)
for k in range(m):
	for i in range(n):
		for j in range(l):
			C[i][j] += (A[i][k]*B[k][j])
for i in range(n):
	print(' '.join(map(str,C[i])))


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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll n, x, m;
	cin >> n >> x >> m;

	vl a(2*m);
	a[0] = x;
	FOR(i,1,2*m) a[i] = a[i-1]*a[i-1] % m;

	if (n <= 2*m) {
		ll res = 0;
		FOR(i,0,n) res += a[i];
		cout << res << endl;
	} else {
		ll res = 0;
		FOR(i,0,m) res += a[i];
		n -= m;
		ll block = a[m];
		ll j = m+1;
		while (j < 2*m && a[j] != a[m]) block += a[j++];
		res += n/(j-m) * block;
		n %= (j-m);
		FOR(i,0,n) res += a[m+i];
		cout << res << endl;
	}
}



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

int main(){
  int N,F=1;
  cin >> N;
  string S[N],T;
  cin >> S[0];
  for(int i=1;i<N;i++){
    cin >> S[i];
    if(S[i].front() == S[i-1].back()){
      F = 1;
    }else{
      F = 0;
    }
    for(int j=0;j<i;j++){
      if(S[i] == S[j]) F = 0;
    }
    if(F==0) break;
  }
  if(F==0) cout << "No" << endl;
  else cout << "Yes" << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class Main {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);

	static void solve() {
		int y = in.nextInt();
		int m = in.nextInt();
		int d = in.nextInt();

		int cnt = 0;
		for (int i=y+1; i<1000; i++) {
			for (int j=1; j<=10; j++) {
				for (int k=1; k<=(j%2 == 1 || i%3 == 0 ? 20 : 19); k++) {
					cnt++;
				}
			}
		}

		for (int j=m+1; j<=10; j++) {
			for (int k=1; k<=(j%2 == 1 || y%3 == 0 ? 20 : 19); k++) {
				cnt++;
			}
		}

		for (int k=d; k<=(m%2 == 1 || y%3 == 0 ? 20 : 19); k++) {
			cnt++;
		}

		out.println(cnt);
	}

	public static void main(String[] args) {
		long start = System.currentTimeMillis();

		int n = in.nextInt();
		while(n-- > 0) solve();
		out.flush();

		long end = System.currentTimeMillis();
		//trace(end-start + "ms");
		in.close();
		out.close();
	}

	static void trace(Object... o) { System.out.println(Arrays.deepToString(o));}
}

Measured memory_bytes: 28468
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

i64 N;
i64 a[202020];

int main() {
  cin >> N;
  vector<i64> v;
  map<i64,i64> mp;
  rep(i,0,N - 1) {
    cin >> a[i];
    v.push_back(a[i]);
    mp[a[i]]++;
  }
  i64 ans = 0;
  sort(v.rbegin(),v.rend());
  i64 MAX = 1e9;

  for(auto x : v) {
    if(mp[x] == 0) continue;
    mp[x]--;
    for(i64 b = 1;b <= MAX * 2 + 1;b <<= 1) {
      if(mp.count(b - x)) {
        if(mp[b - x] > 0) {
          mp[b - x]--;
          ans++;
        }
      }
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 15856
#include <stdio.h>

int main(void){

		 char S[3];

	scanf("%c%c%c",&S[0],&S[1],&S[2]);

    if(S[0]=='R'){
				if(S[1]=='R'){
							if(S[2]=='R')printf("3");
							else if(S[2]=='S')printf("2");
				}
				else if(S[1]=='S'){
							if(S[2]=='R')printf("1");
							else if(S[2]=='S')printf("1");
				}
				
		}
		if(S[0]=='S'){
				if(S[1]=='R'){
							if(S[2]=='R')printf("2");
							else if(S[2]=='S')printf("1");
				}
				else if(S[1]=='S'){
							if(S[2]=='R')printf("1");
							else if(S[2]=='S')printf("0");
				}
		}

return 0;

}

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

int main() {
    int N;
    cin >> N;
    vector<string> S(N);
    for (int i = 0; i < N; i++) cin >> S.at(i);

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

    cout << S.size() << endl;
}

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

int main(){
    string a,b;
    cin >> a >> b;
    int x = stoi(a+b);
    for (int i = 0; i <= 1000; i++){
        if (pow(i,2) == x){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

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

std::map<int, int> prob;

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

	for (int i = 0; i < n; ++i) {
		int d;
		std::cin >> d;
		++prob[d];
	}

	std::cin >> m;

	for (int i = 0; i < m; ++i) {
		int t;
		std::cin >> t;

		--prob[t];
		if (prob[t] < 0) {
			std::cout << "NO" << std::endl;
			return 0;
		}
	}

	std::cout << "YES" << std::endl;
}

Measured memory_bytes: 9600
#include <stdio.h>

int main()
{
	int a,b,c;
	scanf("%d %d %d", &a,&b,&c);
	if((a!=b&&a==c)|(a!=c&&a==b)||(b==c&&b!=a)){
		printf("Yes");
	}	
else {
	printf("No");
}
	
return 0;
}

Measured memory_bytes: 1688
import math

A, B = [int(i) for i in input().split()]

# resultの初期値を最低値にセット
resultTmp = B * 10
result = 0
isHit = False
isFirstHit = True
while resultTmp < B * 10 + 10:
    if math.floor(resultTmp * 0.08) == A and math.floor(resultTmp * 0.1) == B:
        isHit = True
        if isFirstHit:
            result = resultTmp
            isFirstHit = False
    resultTmp += 1

if isHit:
    print(result)
else:
    print(-1)


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

int ketasum(int n){
  int sum = 0;
  while (n > 0){
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

int main(){
  int n, k;
  cin >> n >> k;
  vector<int> l(n);
  for (int i = 0; i < n; i++) cin >> l[i];
  sort(l.begin(), l.end(), greater<int>());
  int ans = 0;
  for (int i = 0; i < k; i++){
    ans += l[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <iostream> 
#include <utility> 
using namespace std; 
int main()
{
	int n,m;
	cin>>n>>m;
    if(abs(n-m)%2!=0)
    cout<<"IMPOSSIBLE";
    else
    cout<<(n+m)/2;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,k;
ll a[200005],dp[200005];
int main()
{
	cin>>n>>k;
	for(int i=0;i<n;i++)cin>>a[i];
	dp[0]=0;
	for(int i=1;i<n;i++)dp[i]=4e18;
	for(int i=1;i<n;i++)for(int j=i-k;j<i;j++)
		if(j>=0)dp[i]=min(dp[j]+abs(a[i]-a[j]),dp[i]);
	cout<<dp[n-1];
	return 0;
}

Measured memory_bytes: 5144