akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll=int_fast64_t;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

struct modint{
    using i64=int_fast64_t;
    i64 a;
    static constexpr i64 MOD=998244353;
    modint(){a=0;}
    modint(i64 a_){
        a=a_%MOD;
        if(a<0) a+=MOD;
    }
    modint inv()const{
        i64 n=1,m=MOD-2,A=a;
        while(m){
            if(m&1)(n*=A)%=MOD;
            (A*=A)%=MOD;
            m>>=1;
        }
        modint y(n);
        return y;
    }
    bool operator==(const modint& x){
        return a==x.a;
    }
    bool operator!=(const modint& x){
        return a!=x.a;
    }
    modint& operator=(const modint& x){
        a=x.a;
        return *this;
    }
    modint operator+(const modint& x){
        modint y;
        y.a=a+x.a;
        if(y.a>MOD) y.a-=MOD;
        return y;
    }
    modint operator-(const modint& x){
        modint y;
        y.a=a-x.a;
        if(y.a<0) y.a+=MOD;
        return y;
    }
    modint operator*(const modint& x){
        modint y;
        y.a=(a*x.a)%MOD;
        return y;
    }
    modint operator/(const modint& x){
        modint y;
        y.a=(a*x.inv().a)%MOD;
        return y;
    }
    modint& operator+=(const modint& x){
        a+=x.a;
        if(a>=MOD) a-=MOD;
        return *this;
    }
    modint& operator-=(const modint& x){
        a-=x.a;
        if(a<0) a+=MOD;
        return *this;
    }
    modint& operator*=(const modint& x){
        (a*=x.a)%=MOD;
        return *this;
    }
    modint& operator/=(const modint& x){
        (a*=x.inv().a)%=MOD;
        return *this;
    }
};
istream& operator>>(istream &in,modint& x){
    int_fast64_t a_;
    in>>a_;
    modint y(a_);
    x=y;
    return in;
}
ostream& operator<<(ostream &out,const modint& x){
    out<<x.a;
    return out;
}
modint pwr(int_fast64_t a,int_fast64_t b){
    modint _;
    int_fast64_t n=1,A=a;
    while(b){
        if(b&1) (n*=A)%=modint::MOD;
        (A*=A)%=modint::MOD;
        b>>=1;
    }
    _.a=n;
    return _;
}

int main(){
    int n,a;
    vector<modint> b(1000001);
    scanf("%d",&n);
    modint ans{};
    fr(i,n) scanf("%d",&a),b[a]+=a,ans-=a;
    vector<bool> s(1000001,true);
    for(size_t p=2;p<=1000000;++p) if(s[p]){
        for(size_t i=(1000000)/p;i>0;--i){
            if(i>1) s[i*p]=false;
            b[i]+=b[i*p];
        }
    }
    Fr(i,1000000) b[i]*=b[i];
    for(size_t p=2;p<=1000000;++p) if(s[p]) for(size_t i=1;i*p<=1000000;++i) b[i]-=b[i*p];
    Fr(i,1000000) ans+=b[i]/i;
    printf("%lld\n",(ans/2).a);
}

Measured memory_bytes: 8192
n=input()
iti=int(n[-1])
if iti==2 or iti==4 or iti==5 or iti==7 or iti==9:
    print("hon")
elif iti==0 or iti==1 or iti==6 or iti==8:
    print("pon")
elif iti==3:
    print("bon")


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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define drep(i,n) for(int i = (n)-1; i >= 0; i--)
#define srep(i,s,t) for (int i = s; i < t; i++)
#define rng(a) a.begin(),a.end()
using ll = long long;

using namespace std;



int main() {
    string S;
    cin>>S;
    int n = S.length();
    vector<int>x(n);
    rep(i,n) {
        int pos = i;
        rep(j,10) {
            if(S[pos]=='R') pos++;
            else if(S[pos]=='L') pos--;
        }
        x[i] = pos;
    }
    vector<int>y(n);
    int tmp;
    rep(j,100) {
        rep(i,n) {
            tmp = x[i];
            x[i] = x[x[x[x[x[x[x[x[x[x[i]]]]]]]]]];
            y[i] = x[i];
            x[i] = tmp;
        }
        rep(i,n) x[i] = y[i];
    }
    
    vector<int>ans(n);
    rep(i,n) {
        ans[y[i]]++;
    }
    rep(i,n) cout<<ans[i]<<" ";

    return 0;
}


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

int main()
{
	unsigned long d;
	while (cin >> d) {
		unsigned long s = 0;
		for (unsigned long i = d; i + d <= 600; i += d) {
			s += (i*i*d);
		}
		cout << s << endl;
	}
	return 0;
}

Measured memory_bytes: 1156
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<complex>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define EPS (1e-10)
using namespace std;

typedef unsigned int uint;
typedef long long ll;

#define PI (3.1415926535)
#define EPS (1e-10)
bool eq(double a, double b){
  return abs(a-b) < EPS;
}

int main(){
  complex<double> p[3];
  int n; cin>>n;
  while(n --> 0){
    REP(i,3) cin>>p[i].real()>>p[i].imag();
    double ag = arg(p[0]-p[2])-arg(p[1]-p[2]);
    double r = abs(abs(p[0] - p[1]) / sin(ag) / 2.0);
    double s = r * r * sin(2*ag) / 2.0;
    complex<double> c = (p[0] + p[1]) / 2.0;
    complex<double> v = (p[0] - p[1]) * complex<double>(0,1);
    double rr = s * 2.0 / abs(p[0] - p[1]); 
    complex<double> o1 = c + rr * v / abs(v),
                    o2 = c - rr * v / abs(v), o;
    if(eq(abs(o1-p[0]),r) && eq(abs(o1-p[1]),r) && eq(abs(o1-p[2]),r)) o = o1;
    else o = o2;
    printf("%.3f %.3f %.3f\n",o.real(),o.imag(),r);
  }
  return 0;
}

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

int main(){
    int h,n , k ,s = 0 ;
    cin >> h >> n ;
    for(int i=0 ; i<n ;i++){
        cin >> k ;
        s += k ;
    }
    if(s>= h){
        cout << "Yes" <<endl ;
    }else{
        cout << "No" <<endl ;
    }
    return 0 ;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define pi acos(-1.0)
// 21837

int main()
{

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

    int t,m1,d1,m2,d2;
    cin>>m1>>d1;
    cin>>m2>>d2;

    if(d2==1)
        cout<<1<<endl;
    else
        cout<<0<<endl;

    return 0;
}



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

using namespace std;

int main()
{
	ios::sync_with_stdio(false);
  	cin.tie(0);
	
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++)
		cin >> a[i];
	vector<int> l(n), r(n);
	for (int i = 0; i < n - 1; i++)
		l[i + 1] = __gcd(l[i], a[i]);
	for (int i = n - 1; i >= 1; i--)
		r[i - 1] = __gcd(r[i], a[i]);
	int ans = 1;
	for (int i = 0; i < n; i++)
		ans = max(ans, __gcd(l[i], r[i]));
	cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1408
import sys
input=sys.stdin.readline
n = int(input())
A = list(map(int, input().split()))

l = [0] * 9
mn = 0
for i in A:
    t = min(i // 400, 8)
    l[t] += 1
for i in range(8):
    if l[i] != 0:
        mn += 1
if mn == 0:
    mn = 1
    mx = l[8]
else:
    mx = mn + l[8]

print(mn, mx)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
int main() {
    int n, m;
    cin >> n >> m;
    vector<ll> x(n), y(m);
    for(int i=0;i<n;i++) cin >> x[i];
    for(int i=0;i<m;i++) cin >> y[i];

    ll sum_x = 0, sum_y = 0;
    for(int i=0;i<n;i++) {
        sum_x += i * x[i] - (n-i-1) * x[i];
        sum_x %= mod;
    }
    for(int i=0;i<m;i++) {
        sum_y += i * y[i] - (m-i-1) * y[i];
        sum_y %= mod;
    }

    cout << sum_x * sum_y % mod << endl;
}


Measured memory_bytes: 1792
#include<stdio.h>
main()
{
	long double a, b, c, w, x, p, q, x1, x2, y1, y2;
	int i, n;
	scanf("%llf%llf%llf%llf", &x1, &y1, &x2, &y2);
	a=y1-y2;
	b=x2-x1;
	c=x1*y2-y1*x2;
	scanf("%d", &n);
	for (i=1; i<=n; i++)
	{
		scanf("%llf%llf", &w, &x);
		p=((-2*a*(a*w+b*x+c))/(a*a+b*b))+w;
		q=((-2*b*(a*w+b*x+c))/(a*a+b*b))+x;
		printf("%.9llf %.9llf\n", p, q);
	}
}


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

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

int main() {
    int k;
    std::cin >> k;
    int64_t ans = 0;
    rep(i, k){
        rep(j, k){
            rep(l, k){
                ans = ans + gcd( gcd((i + 1), (j + 1)), (l + 1) );
            }
        }
    }
    std::cout << ans << std::endl;
}



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

int main() {
    int l;
    cin >> l;
    int ok[100];
    memset(ok, -1, sizeof(ok));

    stack<int> sta;
    sta.push(0);
    rep(i, l) {
        int c;
        cin >> c;

        if (c > 0) sta.push(c);
        else {
            if (sta.top() != abs(c)) {
                cout << i+1 << endl;
                return 0;
            } else {
                sta.pop();
            }
        }

        if (c*ok[abs(c)] > 0) {
            cout << i+1 << endl;
            return 0;
        }

        ok[abs(c)] *= -1;
    }

    cout << "OK" << endl;

    return 0;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
#define ll long long int
#define endl '\n'
#define MOD 1000000007
#define pb push_back
#define ff first
#define ss second
#define con continue
#define ub upper_bound
#define lb lower_bound


using namespace std;

void solve()
{

}



int main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
    int n;
    cin >> n ;
   cout << 1-n << endl;;
}


Measured memory_bytes: 3648
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<queue>
#include<algorithm>
#include<vector>
#include<math.h>
#include<bitset>
#include<iomanip>
#include<numeric>
using namespace std;

typedef stack<int> IntStack;
typedef queue<int> IntQueue;

const double pi = 3.141592653589793;


//文字0~9をint型0~9に変換
int char_to_int(char c)
{
	if (c == '0') return 0;
	if (c == '1') return 1;
	if (c == '2') return 2;
	if (c == '3') return 3;
	if (c == '4') return 4;
	if (c == '5') return 5;
	if (c == '6') return 6;
	if (c == '7') return 7;
	if (c == '8') return 8;
	if (c == '9') return 9;
	else return -1;
}
//a^b mod MODを計算
long long int ModPower(long long int a, long long int b, long long int MOD)
{
	if (b == 0) return 1;
	else if (b % 2 == 0)
	{
		long long int d = ModPower(a, b / 2, MOD);
		return (d*d) % MOD;
	}
	else
	{
		return (a*ModPower(a, b - 1, MOD)) % MOD;
	}
}
//nCr mod MODを計算
long long int ModCombi(long long int n, long long int r, long long int MOD)
{
	if (n == 0 || r == 0) return 1;

	long long int Kn = 1, Kr = 1, Knr = 1;

	long long int temp = 1;
	for (long long int i = 1; i <= n; i++)
	{
		temp *= i;
		temp %= MOD;
		if (i == n) Kn = temp;
		if (i == r) Kr = temp;
		if (i == n - r) Knr = temp;
	}

	long long int x = ModPower(Kr, MOD - 2, MOD);
	long long int y = ModPower(Knr, MOD - 2, MOD);

	long long int ans;
	ans = Kn * x;
	ans %= MOD;
	ans *= y;
	ans %= MOD;

	return ans;
}


/*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*/

long long int gcd(long long int a, long long int b)
{
	long long int r;
	while (true)
	{
		r = a % b;
		if (r == 0) break;
		a = b;
		b = r;
	}
	return b;
}

int main()
{
	long long int A, B, C, D;
	cin >> A >> B >> C >> D;
	long long int Cm, CM, Dm, DM;

	if (A%C == 0) Cm = A / C;
	else Cm = A / C + 1;

	if (A%D == 0) Dm = A / D;
	else Dm = A / D + 1;

	CM = B / C;
	DM = B / D;

	long long int L = C * D / gcd(C, D);
	long long int Lm, LM;

	if (A%L == 0) Lm = A / L;
	else Lm = A / L + 1;
	LM = B / L;

	long long int ans;
	ans = (B - A + 1) - (CM - Cm + 1) - (DM - Dm + 1) + (LM - Lm + 1);

	cout << ans;

	return 0;
}


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

#include <iostream>
using namespace std;

int main() {
int a,b,c,d,e,f,g,s,aka;
cin>>a>>b>>c>>d>>e>>f;
    g=a+b+c+d;
    aka=a;
    if( a>b)aka=b;
    if( aka>c)aka=c;
    if( aka>d)aka=d;

    g=g-aka;
    s=e;
    if( e<f)s=f;
    cout<<g+s<<endl;
}

Measured memory_bytes: 3084
#include<bits/stdc++.h>
#define ll long long
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace std;

int main()
{
    fast_io
    ll n,m,i,j;
    cin>>m;
    cout<<24+(24-m)<<endl;

    return 0;
}





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

int main() {
    int n;
    const int price = 800;
    cin >> n;
    int x = n * price;
    int y = (n / 15) * 200;
    cout << x - y << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <math.h>
#include <map>
#include <numeric>
using namespace std;
typedef long long int ll;

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

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	while(1){
		int n; cin >> n;
		if(n==0)break;
		int m[4]={};
		x[0]=y[0]=0;
		for(int i=0;i<n-1;i++){
			int a,b; cin >> a >> b;
			x[i+1]=x[a]+dx[b];
			y[i+1]=y[a]+dy[b];
			if(x[i+1]<m[0])m[0]=x[i+1];
			if(x[i+1]>m[1])m[1]=x[i+1];
			if(y[i+1]<m[2])m[2]=y[i+1];
			if(y[i+1]>m[3])m[3]=y[i+1];
		}
		cout << m[1]-m[0]+1 << " " << m[3]-m[2]+1 << endl;
	}
}


Measured memory_bytes: 3164
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.OptionalInt;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {
	static PrintWriter out = new PrintWriter(System.out);
	public static void main(String[] args) {
		// 入力
		String n;		// 1≦N<10000
		final int k;	// 1≦K<10
		final int[] d;	// 0≦D1<D2<…<DK≦9  {D1,D2,…,DK}≠{1,2,3,4,5,6,7,8,9}
		try(Scanner scan = new Scanner(System.in)) {
			n = scan.next();
			k = scan.nextInt();
			d = new int[k];
			for (int i = 0; i < k; i++) {
				d[i] = scan.nextInt();
			}
			
		}
		
		// 嫌いでない数字の配列
		final int[] like = IntStream.range(0, 10).filter(i -> !Arrays.stream(d).anyMatch(dd -> dd == i)).toArray();
		// maxはlike[10 - k -1] minはlike[0]
		
		
		// 各位の数字
		final int[] value = new int[4];		//1≦N<10000より4桁
		
		for (int i = 0; n.length() < 4; i++) {
			n = "0" + n;
		}
		for (int i = 0; i < 4; i++) {
			value[i] = Integer.parseInt(n.substring(i, i + 1));
		}
		
		int[] result = new int[5];
		boolean top = false;	//最初の桁が現れればtrue
		boolean big = false;	//大きいことが確定すればtrue
		
		result[0] = 0;
		for (int j = 0; j < 4; j++) {
			final int i = j;
			//System.out.println(value[i]);
			if (!top && value[i] ==0) {
				result[i + 1] = 0;
				continue;
			} else {
				top = true;
			}

			if (big) {
				result[i + 1] = like[0];
			} else {
				OptionalInt temp = Arrays.stream(like).filter(likevalue -> likevalue >= value[i]).min();
				
				if (temp.isPresent()) {
					result[i + 1] = temp.getAsInt();
					big = value[i] < result[i + 1];
				} else {// value[i] > likeMax
					moveUp(result, like, i);
					big = true;
				}
			}
						
		}

		
		//数値に戻す
		// 出力
		out.println(Arrays.stream(result).reduce((start, element) -> start * 10 + element).getAsInt());
		out.flush();
	}
	
	/** 繰り上がり */
	static void moveUp(int[] result, int[] like, int i) {
		OptionalInt temp = Arrays.stream(like).filter(likevalue -> likevalue > result[i]).min();
		result[i+1] = like[0];
		if (temp.isPresent()) {
			result[i] = temp.getAsInt();		// i == 0でlike[0]==0 ? like[1] : like[0]になる
		} else {
			moveUp(result, like, i -1);
		}
	}
	
}


Measured memory_bytes: 15824
#include<iostream>
#include<cmath>

struct Point{
    Point(void){
        x=y=r=0;
    }
    double x,y;
    double r;
};

double di(struct Point a,struct Point b){
    return sqrt(pow(a.x-b.x,2)+pow(a.y-b.y,2));
}

int main(void){
    int n;
    std::cin>>n;
    struct Point a,b;
    for(int i=0;i<n;i++){
        int judge;
        std::cin>>a.x>>a.y>>a.r>>b.x>>b.y>>b.r;
        double d=di(a,b);
        if(d+b.r<a.r)
            judge=2;
        else if(d+a.r<b.r)
            judge=-2;
        else if(d<=a.r+b.r)
            judge=1;
        else
            judge=0;
        std::cout<<judge<<std::endl;
    }
    return 0;
}


Measured memory_bytes: 3168
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

vector<int> get_prime(int n){
    if(n <= 1) return vector<int>();
    vector<bool> iscomp(n+1);
    vector<int> prime;
    for (int i = 2; i <= n; ++i) {
        if(!iscomp[i]) prime.emplace_back(i);
        for (auto &&j : prime){
            if((ll)i*j > n) break;
            iscomp[i*j] = true;
            if(i % j == 0) break;
        }
    }
    return prime;
}
int main() {
    int n, p;
    auto x = get_prime(200000);
    while(cin >> n >> p, n != -1 && p != -1){
        vector<int> v;
        int cur = upper_bound(x.begin(), x.end(), n) - x.begin();
        for (int i = 0; i < p; ++i) {
            v.emplace_back(x[cur+i]);
        }
        vector<int> ans;
        for (int i = 0; i < p; ++i) {
            for (int j = i; j < p; ++j) {
                ans.emplace_back(v[i]+v[j]);
            }
        }
        sort(ans.begin(), ans.end());
        cout << ans[p-1] << "\n";
    }
    return 0;
}


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

f = True
while n>1:
  n -= 1
  if h[n-1]>h[n]:
    if h[n]==h[n-1]-1:
      h[n-1] -= 1
    else:
      f = False
      break

print('Yes' if f==True else 'No')


Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
typedef long long in;
typedef pair<in,in> ii;
#define F first
#define S second
#define sqr(x) (x)*(x)
#define pb(x) push_back(x)
#define sz(x) (in)x.size()
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,x,y) for(in i=x;i<(y);++i)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0)
/* start */

const in maxn = 2e5+9;

map<in,in> m;

int main(){
    IOS;
    in n,ans=0;
    cin >> n;
    vector<in> v(n);
    rep(i,0,n){
        cin >> v[i];
        m[v[i]]++;
    }
    for(auto it = m.begin();it!=m.end();it++){
        in count = (*it).S;
        ans+=(count)*(count-1)/2;
    }
    rep(i,0,n){
        in cur = ans;
        cur-=max(0LL,(m[v[i]])*(m[v[i]]-1)/2);
        cur+=max(0LL,(m[v[i]]-2)*(m[v[i]]-1)/2);
        cout << cur << "\n";
    }
}

Measured memory_bytes: 11136
import java.util.*;

public class Main {
	public static void main(String[] args) {

		Scanner keyboard = new Scanner(System.in);

		int N = keyboard.nextInt();
		int K = keyboard.nextInt();
		long[]A = new long[N+1]; 
		A[0] = 1;
		
		for(int n=1; n<N+1; n++) {
			A[n] = keyboard.nextLong();
		}
		
		for(int i = K+1; i<N+1; i++) {
			if(A[i]>A[i-K]) {
				System.out.println("Yes");
			}else {
				System.out.println("No");
			}
		}
		keyboard.close();
	}
}


Measured memory_bytes: 61032
// #include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <set>
#include <queue>
#include <cstdio>
#include <stack>
#include <list>
using namespace std;
#define rep(i, n) for(int i=0;i<n;i++)
#define irep(i, n) for(int i=n-1;i>=0;i--)
#define lrep(i, n) for(long long i=0;i<n;i++)
typedef long long ll;
typedef vector<long long> llv;
typedef vector<vector<long long> > llvv;
template <class T> T gcd(T n, T m){return m ? gcd(m, n%m):n;}

// bool dp(int target, vector<int> a, int i){
//     if(target == 0) return true;
//     if(i == a.size()) return false;
//     return dp(target-a[i], a, i+1) || dp(target, a, i+1);
// }

// int main(){
//     int n;cin>>n;
//     vector<int> a(n);rep(i,n){cin >> a[i];}
//     int q;cin>>q;
//     vector<int> m(q);rep(i,q){cin>>m[i];}
//     rep(i,q){
//         if(dp(m[i], a, 0) == true){cout << "yes"<<endl;}
//         else{cout<<"no"<<endl;}
//     }
// }

bool dp(int target, int a[], int i,int n){
    if(target == 0) return true;
    if(i == n) return false;
    return dp(target-a[i], a, i+1,n) || dp(target, a, i+1,n);
}

int main(){
    int n;cin>>n;
    int a[n];rep(i,n){cin >> a[i];}
    int q;cin>>q;
    int m[q];rep(i,q){cin>>m[i];}
    rep(i,q){
        if(dp(m[i], a, 0, n) == true){cout << "yes"<<endl;}
        else{cout<<"no"<<endl;}
    }
}


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

int main() {

    int N, A, B;
    cin >> N >> A >> B;

    cout << min(A*N, B) << endl;

    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <iomanip>
using namespace std;
typedef long long ll;

int main() {
    int n, v[55];
    cin >> n;
    for (int i = 0; i < n; i++) cin >> v[i];
    sort(v, v + n);

    float ans = v[0];
    for (int i = 0; i < n - 1; i++) {
        ans = (ans + v[i + 1]) / 2;
    }

    cout << setprecision(12) << ans << endl;

}

Measured memory_bytes: 256
import math
n,d = map(int,input().split())
x = [list(map(int,input().split())) for i in range(n)]
cnt = 0
for k in range(n):
  for i in range(n):
    a = 0
    if i > k:
      for j in range(d):
        a += abs(x[k][j]-x[i][j])**2
      b = math.sqrt(a)
      if int(b)**2 == a:
        cnt += 1
print(cnt)

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

#define MAXN (100010)

int n, k;
int l[MAXN], r[MAXN];
bool has[MAXN];
std::vector<int> mat[MAXN];

bool union_seg(int &lu, int &ru, int lv, int rv, int odd, bool &mark){
	if(!mark){
		lu = lv;
		ru = rv;
		mark = true;
	}
	else{
		lu = std::max(lu, lv);
		ru = std::min(ru, rv);
	}
	if(lu > ru || lu == ru && (lu & 1) != odd) return false;
	return true;
}

bool dfs1(int u, int fa, int odd){
	if(has[u] && (l[u] & 1) != odd){
		return false;
	}
	for(auto v : mat[u]){
		if(v == fa) continue;
		if(!dfs1(v, u, !odd)){
			return false;
		}
		if(!union_seg(l[u], r[u], l[v] - 1, r[v] + 1, odd, has[u])){
			return false;
		}
	}
	if(!has[u]){
		l[u] = - 1e9;
		r[u] =   1e9;
	}
	return true;
}

bool inseg(int x, int l, int r){
	return l <= x && x <= r;
}

bool dfs2(int u, int fa){
	for(auto v : mat[u]){
		if(v == fa) continue;
		if(inseg(l[u] + 1, l[v], r[v])){
			l[v] = l[u] + 1;
			if(!dfs2(v, u)){
				return false;
			}
		}
		else if(inseg(l[u] - 1, l[v], r[v])){
			l[v] = l[u] - 1;
			if(!dfs2(v, u)){
				return false;
			}
		}
		else{
			return false;
		}
	}
	return true;
}

int main(){
	scanf("%d", &n);
	for(int i = 1; i < n; ++ i){
		int u, v;
		scanf("%d%d", &u, &v);
		mat[u].push_back(v);
		mat[v].push_back(u);
	}
	scanf("%d", &k);
	for(int i = 1; i <= k; ++ i){
		int v, p;
		scanf("%d%d", &v, &p);
		l[v] = r[v] = p;
		has[v] = true;
	}
	int root;
	for(root = 1; !has[root]; ++ root);
	if(!dfs1(root, 0, l[root] & 1)){
		return printf("No\n"), 0;
	}
	if(!dfs2(root, 0)){
	    return printf("No\n"), 0;
	}
	printf("Yes\n");
	for(int i = 1; i <= n; ++ i){
		printf("%d\n", l[i]);
	}
	return 0;
}

Measured memory_bytes: 15104
#include <stdio.h>
#include <string.h>
#include <inttypes.h>

int main(void) {
	char S[128];
	uint64_t K;
	size_t len;
	size_t i;
	if (scanf("%127s", S) != 1) return 1;
	if (scanf("%" SCNu64, &K) != 1) return 1;
	len = strlen(S);
	for (i = 0; i < len; i++) {
		if (i + 1 == K) {
			printf("%c\n", (unsigned char)S[i]);
			return 0;
		}
		if (S[i] != '1') {
			printf("%c\n", (unsigned char)S[i]);
			return 0;
		}
	}
	puts("ERROR!");
	return 2;
}


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

using namespace std;
typedef long long LL;
template <typename F, typename S> std::ostream& operator<<(ostream& os, const pair<F,S>& p) {
    os << "(" << p.first << "," << p.second << ")"; return os; }
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "["; for(const T& a: v){ os << a << ", "; } os << "]"; return os; }
template <typename K, typename V> ostream& operator<<(ostream& os, const map<K,V>& m) {
    os << "{"; for(const auto& p: m){ os << p.first <<":"<< p.second << ", "; } os << "}"; return os; }


int main(){
    LL x;
    cin >> x;
    LL ans = 0;
    LL d = 0;
    if(x == 60){
        cout << 6 << endl;
        return 0;
    }else if(x == 120){
        cout << 3 << endl;
        return 0;
    }
    while(true){
        ans += 1;
        d += 180 - x;
        if(d % 360 == 0) break;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3584
#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, K;
  string S;
  cin >> N >> K >> S;

  if (K>=N) {
    cout << N << endl;
    return 0;
  }

  vector<int> C,R;
  R.push_back(0);
  if (S[0]=='0' ) C.push_back(0);
  S = S + 'Z';
  int cnt = 1;
  REP(i,N){
    if ( S[i] != S[i+1] ) {
      C.push_back(cnt);
      cnt = 1;
    } else {
      cnt++;
    }
  }
  if (S[N-1]=='0' ) C.push_back(0);
  
  REP(i, C.size())
    R.push_back( R[i]+C[i] );

  int smax = 0;
  for ( int l=0; (2*l)<R.size(); ++l ) {
    int ridx = min(2*(l+K-1)+3, (int)R.size()-1);
    smax = max( smax, R[ridx] - R[2*l] );
//    cout << "- [" << l << "," << (2*(l+K-1)+3) << "] " << R[2*(l+K-1)+3] << " - " << R[2*l] << endl;
  }
//  REP(i,R.size())
//    cout << C[i] << " " << R[i] <<endl;
  cout << smax << endl;
}


Measured memory_bytes: 1560
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<bool> vb;
#define pb push_back
#define fi first
#define se second
#define in insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int mod = 1e9 + 7;
void solve(){
    int n, m;
    cin >> n >> m;
    int c[10][10];
    for (int i = 0; i <= 9; ++i) {
        for (int j = 0; j <= 9; ++j) {
            cin >> c[i][j];
        }
    }
    vi a(10, 0);
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            int x;
            cin >> x;
            if (x == -1) continue;
            a[x]++;
        }
    }
    for (int i = 0; i <= 9; ++i) {
        for (int j = 0; j <= 9; ++j) {
            for (int k = 0; k <= 9; ++k) {
                c[j][k] = min(c[j][k], c[j][i] + c[i][k]);
            }
        }
    }
    int ans = 0;
    for (int i = 0; i <= 9; ++i) {
        ans += c[i][1] * a[i];
    }
    cout << ans;
}
int main(){
    speed;
    int t = 1;
    //cin >> t;
    for (int i = 1; i <= t; ++i) {
        solve();
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  string S;
  cin >> S;
  ll N = stoll(S);
  ll n_sum = 0;
  for (int i = 0; i < S.size(); i++) {
    n_sum += (S[i] - '0');
  }
  if (N % n_sum == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<cstring>

using namespace std;

typedef pair<int,int> P;
const int MAX = 16;
bool Mata[MAX][MAX][MAX][MAX];
P g;
int ans;

void init(){
  ans = 0;
  memset(Mata,false,sizeof(Mata));
}

void solve(int x,int y){
  
  if(x == g.first && y == g.second) ans++;
  else if(x <= g.first && y <= g.second){
    if(!Mata[x][y][x+1][y]) solve(x+1,y);
    if(!Mata[x][y][x][y+1]) solve(x,y+1);
  }
}

int main(){
  int N;
  cin >> N;
  while(N--){
    init();
    cin >> g.first >> g.second;
    int num;
    cin >> num;
    while(num--){
      P f,t;
      cin >> f.first >> f.second >> t.first >> t.second;
      Mata[f.first][f.second][t.first][t.second] = true;
      Mata[t.first][t.second][f.first][f.second] = true;
    }
    solve(0,0);
    if(ans) cout << ans << endl;
    else cout << "Miserable Hokusai!" << endl;
  }
  return 0;
}

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

int main() {
  int x;
  cin >> x;
  if (400 <= x && x <= 599) {
    cout << 8 << endl;
    return 0;
  } else if (600 <= x && x <= 799) {
    cout << 7 << endl;
    return 0;
  } else if (800 <= x && x <= 999) {
    cout << 6 << endl;
    return 0;
  } else if (1000 <= x && x <= 1199) {
    cout << 5 << endl;
    return 0;
  } else if (1200 <= x && x <= 1399) {
    cout << 4 << endl;
    return 0;
  } else if (1400 <= x && x <= 1599) {
    cout << 3 << endl;
    return 0;
  } else if (1600 <= x && x <= 1799) {
    cout << 2 << endl;
    return 0;
  } else if (1800 <= x && x <= 1999) {
    cout << 1 << endl;
    return 0;
  }
  return 0;
}

Measured memory_bytes: 3616
# coding: utf-8
import sys
# from operator import itemgetter
sysread = sys.stdin.readline
read = sys.stdin.read
sys.setrecursionlimit(10 ** 7)
#from heapq import heappop, heappush
from collections import OrderedDict, defaultdict
#import math
#from itertools import product, accumulate, combinations, product
#import bisect# lower_bound etc
#import numpy as np
#from copy import deepcopy
#from collections import deque
#import numba

def run():
    N = int(input())

    ret = 0
    for i in range(1,N+1):
        tmp = N // i
        left = i
        right = i * tmp
        ret += (left + right) * tmp // 2
    print(ret)
if __name__ == "__main__":
    run()

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

int main() {
  char b;
  cin >> b;

  if (b == 'A') cout << 'T' << endl;
  else if (b == 'C') cout << 'G' << endl;
  else if (b == 'G') cout << 'C' << endl;
  else cout << 'A' << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int N;
  cin >> N;
  double result = 0;
vector<double> v(N);
  for(int a = 0;a < N;a++)cin >> v.at(a);
  sort(v.begin(),v.end());
  for(int a = 1;a < N;a++)result += v.at(a) / pow(2,N-a);
  result += v.at(0) / pow(2,N-1);
  cout << result << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define foi(i,k,n) for(int i = (int)k; i < (int)n; ++i)

using namespace std;
using ii = pair<int,int>;
using ll = long long;

constexpr int MAXN = 5 + 1000;

int main() {
  ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
  int a,b,c; cin >> a >> b >> c;
  cout << c << " " << a << " " << b << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

int balls[100000];
int red[100000]={1};

int main(){
  int N,M;
  std::cin>>N>>M;
  std::fill(balls,balls+N,1);
  for(int i=0;i<M;i++){
    int X,Y;
    std::cin>>X>>Y;
    X--,Y--;
    red[Y]|=red[X];
    balls[X]--;
    balls[Y]++;
    if(balls[X]==0){
      red[X]=0;
    }
  }
  int sum=0;
  for(int i=0;i<N;i++){
    sum+=red[i];
  }
  std::cout<<sum<<std::endl;
  return 0;
}


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

int main() {
  int n;
  cin>>n;
  long long a[n];
  for (int i=0; i<n; i++) cin>>a[i];
  sort(a, a + n);
  if (a[0] == 0) {
    cout<<0<<endl;
    return 0;
  }
  double tmp = 0;
  for (int i=0; i<n; i++) {
    tmp += log10(a[i]);
  }
  if (tmp > 18.0) {
    cout<<-1<<endl;
    return 0;
  }
  long long ans = 1;
  long long inf = 1e18;
  for (int i=0; i<n; i++) {
    ans *= a[i];
    if (ans > inf) {
      cout<<-1<<endl;
      return 0;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 4596
from collections import deque

def dfs(graph, start, goal):
    s_stack = deque()
    g_stack = deque()
    visited = [0 for i in range(N+1)]
    s_stack.append([start,0])
    g_stack.append([goal, 0])
    visited[start] = 1 
    visited[goal] = 1 
    s_cnt = 1
    g_cnt = 1
    round = 0
    while s_stack or g_stack:
        while s_stack:
            a,cost = s_stack.popleft()
            if cost > round:
                s_stack.appendleft([a,cost])
                break
            for b in graph[a].keys():
                if not visited[b]:
                    s_stack.append([b,cost+1])
                    visited[b] += 1 
                    s_cnt += 1
        while g_stack:
            a, cost = g_stack.popleft()
            if cost > round:
                g_stack.appendleft([a,cost])
                break
            for b in graph[a].keys():
                if not visited[b]:
                    g_stack.append([b,cost+1])
                    visited[b] += 1 
                    g_cnt += 1
        round += 1
    # print(s_cnt, g_cnt)
    return s_cnt > g_cnt

N = int(input())
graph = {}
for i in range(N-1):
    a,b = map(int, input().split())
    if a not in graph:
        graph[a] = {}
    if b not in graph:
        graph[b] = {}
    graph[a][b] = graph[b][a] = 1
print('Fennec' if dfs(graph,1,N) else 'Snuke')

Measured memory_bytes: 48340
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF=2147483647;
const double pi=3.1415926535897932384626;
inline ll read(){
	ll x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-') f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
	}
	return x*f;
}
int a,b;
int main(){
	a=read(),b=read();
	printf("%d\n",a*b);
	return 0;
}

Measured memory_bytes: 3728
#include <iostream>
#include <cstring>

using namespace std;

int n, g, p, w, l;
char s[100001];

int main() {
    cin >> s;
    n = strlen(s);
    for (int i = 0; i < n; ++i) {
        if (s[i] == 'g') {
            if (p < g) ++p, ++w;
            else ++g;
        }
        else {
            if (p < g) ++p;
            else ++g, ++l;
        }
    }
    cout << w - l << '\n';
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define int long long
#define rep(i,n) for(int i=1;i<=n;i++)
const int inf = 10e9 + 1;
int a[114514];
signed main() {
	int n;
	cin >> n;
	rep(i, n) cin >> a[i];
	sort(a, a + n);
	map<int, int>mp;
	rep(i, n)mp[a[i]]++;
	int ans = 0;
	for (auto p : mp) {
		int s = p. first;
		int d = p.second;
		if (s > d)ans += d;
		else ans += d-s;
	}
	cout << ans << endl;
}


Measured memory_bytes: 7040
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
vector<int> enumdiv(int n) { 
    vector<int> S;
    for (int i = 1; 1LL*i*i <= n; i++) if (n%i == 0) { S.push_back(i); if (i*i != n) S.push_back(n / i); }
    sort(S.begin(), S.end());
    return S;
}
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/






int N, M;
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N >> M;
    auto ed = enumdiv(M);

    int ans = 1;
    fore(d, ed) if (N <= M / d) ans = d;
    cout << ans << endl;
}

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

using namespace std;
using namespace __gnu_pbds;
using ll = long long;

#define     _test int _TC; cin >> _TC; while(_TC--)
#define     CS(x) cout << "Case " << x << ": ";
#define     precision(n) cout << fixed << setprecision(n);
#define     Clear(a, b) memset(a, b, sizeof(a))
#define     sq(x) ((x) * 1LL * (x))
#define     eb emplace_back
#define     all(_n) _n.begin(), _n.end()
#define     rall(_n) _n.rbegin(), _n.rend()
#define     endl "\n"
#define     show(x) cout << x << endl
#define     nl cout << endl
#define     sz(x) int(x.size())
#define     gcd(a, b) __gcd(a, b)
#define     lcm(a, b) (abs((a) * (b)) / gcd(a, b))
#define     parity(a, b) ((a&1) ^ (b&1))
#define     make_unique(x) sort(all((x))); (x).erase(unique(all((x))), (x).end())
#define     IN(a) for(auto &it : a) cin >> it

template <typename T> void print (T t){ for(const auto &it : t) cout << it << ' '; nl; }
template <typename T> using OS = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; // order_of_key find_by_order

const    double Pi = acos(-1.0);
const    int Mod = 1e9 + 7;
const    int Inf = 1 << 30; // INT_MAX = (1LL << 31) -1 // Inf -> 1e9
const    int Maxx = 1e6 + 10;
#define int ll
/************************************[Code Starts Here]************************************/
int add(int x, int y)
{
    x += y;
    if(x > Mod) x -= Mod;
    return x;
}

void _case()
{
    int n, k; cin >> n >> k;
  
    int ans = 0, mn, mx;
    for (int i = k; i <= n+1; i++) {
        mn = (i*(i-1)/2)%Mod;
        // mx = (n*(n+1)/2 - (n-i)*(n-i+1)/2 + Mod)%Mod;
        mx = i*(2*n-i+1)/2;
        ans += (mx - mn + 1);
    }
    show(ans%Mod);
}

int32_t main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    _case();
    return 0;
}




Measured memory_bytes: 3624
n = int(input())
a = [0]*n
for i in range(n):
    a[i] = int(input())
import collections
c = collections.Counter(a)
L = set(a)
b = list(L)
count = 0
for i in range(len(b)):
    if c[b[i]]%2 == 1:
        count += 1
print(count)

Measured memory_bytes: 20196
#include<bits/stdc++.h>
#define ll long long
#define int long long int
#define MOD 1000000007
#define mkp make_pair
#define maxn 100005
#define pb push_back
#define ff first
#define ss second
#define debug1(a) cout<<a<<endl;
#define debug2(a,b) cout<<a<<' '<<b<<endl;
#define debug3(a,b,c) cout<<a<<' '<<b<<' '<<c<<endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,a,b) for(int i=a;i<b;i++)
#define pi pair<int,int>
#define pii pair<int,pi>
#define mp map<int,int>
#define ump unordered_map<int,int>
#define  vi vector<int>
#define st set<int>
#define mst multiset<int>
#define pq priority_queue
#define mpq priority_queue<int,vector<int>,greater<int> >
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define in cin>>
#define out cout<<
using namespace std;
const int infi=1e9+7;
void printVector(vector<int> v){
    for(int i=0;i<(int)v.size();i++)
        cout<<v[i]<<" ";
    out endl;
}

void printArray(int arr[],int n)
{
   for(int i=0;i<n;i++)cout<<arr[i]<<' ';
cout<<endl;
}
 set<pair<int,int>> primeset;
 vi prime_number;
void SieveOfEratosthenes(int n)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
        for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    for (int p=2; p<=n; p++)
       if (prime[p])
           primeset.insert(mkp(p,1));
}
ll modExp(ll base, ll power) {
    if (power == 0) {
        return 1;
    } else {
        ll cur = modExp(base, power / 2); cur = cur * cur; cur = cur % MOD;
        if (power % 2 == 1) cur = cur * base;
        cur = cur % MOD;
        return cur;
    }
}
//for making unordered_map with pair
struct hash_pair {
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        return hash1 ^ hash2;
    }
};
int32_t main()
{
fastio;
int a,b,c;
cin>>a>>b>>c;
debug3(c,a,b);

    return 0;
}

/*
google kick start
  cout << "Case #" << tt << ": "<<ans<<endl;
*/


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque> 
#include <string>


using namespace std;

int a, b, c, k;

void solve(int &count, int &left, int a, int step) {
	int num;
	if (a > left) {
		count = count + left * step;
		left = 0;
	} else {
		left = left - a;
		count = count + a * step;
	}
}

int main()
{
	scanf("%d%d%d%d", &a, &b, &c, &k);
	int count = 0;
	int left = k;
	if (left > 0) {
		solve(count, left, a, 1);
	}
	
	if (left > 0) {
		solve(count, left, b, 0);
	}
	
	if (left > 0) {
		solve(count, left, c, -1);
	}
	
	printf("%d\n", count);

	return 0;
}


Measured memory_bytes: 1732
import sys
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

N = int(readline())
A = list(map(int, readline().split()))

counts = {}

for a in A:
    if a not in counts:
        counts[a] = 1
    else:
        counts[a] += 1

alls = 0
for k, v in counts.items():
    if v >= 2:
        alls += v * (v - 1) // 2
for a in A:
    acc = counts[a]
    print(alls - (acc - 1))


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

#define MAX_N 20

int dp[1<<MAX_N];
int x[MAX_N][MAX_N];
int y[MAX_N];
int n;

int main(){
	while(true){
		cin>>n;
		if(n==0){break;}
		for(int i=0;i<n;i++){
			cin>>y[i];
			for(int j=0;j<n;j++){
				cin>>x[i][j];
			}
		}
		for(int i=0;i<(1<<MAX_N);i++){
			dp[i]=(1<<25);
		}
		dp[0]=0;
		for(int i=0;i<(1<<n);i++){
			for(int j=0;j<n;j++){
				if((i/(1<<j))%2==0){
					dp[i+(1<<j)]=min(dp[i+(1<<j)],dp[i]+y[j]);
					for(int k=0;k<n;k++){
						if((i/(1<<k))%2==1){
							dp[i+(1<<j)]=min(dp[i+(1<<j)],dp[i]+x[j][k]);
						}
					}
				}
			}
		}
		cout<<dp[(1<<n)-1]<<endl;
	}
	return 0;
}

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

using ll = long long;
#define rep1(n) for (ll i = 0; i < n; ++i)
#define rep2(i, n) for (ll i = 0; i < n; ++i)
#define rep3(i, a, b) for (ll i = a; i < b; ++i)
#define rep4(i, a, b, c) for (ll i = a; i < b; i += c)

int main()
{
    int N;
    cin >> N;
    vector<string> S(N);
    rep1(N)
    {
        cin >> S[i];
    }
    int ac = 0;
    int wa = 0;
    int tle = 0;
    int re = 0;
    rep1(N)
    {
        if (S[i] == "AC")
        {
            ac++;
        }
        else if (S[i] == "WA")
        {
            wa++;
        }
        else if (S[i] == "TLE")
        {
            tle++;
        }
        else if (S[i] == "RE")
        {
            re++;
        }
    }

    cout << "AC x " << ac << endl;

    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;
}

Measured memory_bytes: 6428
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
int main(void){
	int i,j,k,n,y;
	scanf("%d %d",&n,&y);
	for(i=0;i<=2000;i++){
		for(j=0;j<=2000;j++){
				k=n-i-j;
				if(i+j+k==n&&k*10000+j*5000+i*1000==y&&k>=0){
					printf("%d %d %d\n",k,j,i);
					return 0;
				}
		}
	}
	printf("-1 -1 -1\n");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
#define INF 1e9
#define pb push_back
#define mp  make_pair
#define loop(a,n) for(long long i=a;i<n;i++)
#define vil vector<long long int>
#define vi vector<int>
#define sz(v) v.size()
#define setbits(x)          __builtin_popcountll(x)
#define ff first
#define ss second
using namespace std;


ll gcd(ll a, ll b) {
  if (a == 0)return b;
  return gcd(b % a, a);
}
bool isperfect(ll n) {
  ll y = sqrt(n);
  if (n % y == 0 && y * y == n)return true;
  return false;
}
bool comp(pair<int,int> a, pair<int,int> b) {
    if(a.first == b.first) return a.second>b.second;
  return a.first < b.first;
}
 ll powi(ll a, ll b) {
  ll ans = 1;
  while (b > 0) {
    if (b & 1)ans = (ans * a);
    b = b >> 1;
    a = (a * a);
  }
  return ans;
}
bool isprime(ll n) {
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0)return false;
  }
  return true;
}
bool prime[10000000];
void seive() {

  prime[1] = true;
  for (int i = 2; i * i < 10000000; i++) {

    if (prime[i])continue;
    for (int j = i * i; j < 10000000; j += i) {
      prime[j] = true;
    }

  }
}
int main()
{
  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  int m1,d1,m2,d2;
  cin>>m1>>d1>>m2>>d2;
  int f=0;
  if(m1<=7){
   if(m1%2==0&&m1!=2){
       if(d1==30) f=1;
   }
   else if(m1%2!=0)
   {
       if(d1==31) f=1;
   }else{
       if(m1==2&&d1==28) f=1;
   }
  }else{
       if(m1%2!=0){
       if(d1==30) f=1;
   }
   else if(m1%2==0&&m1!=2)
   {
       if(d1==31) f=1;
   }
  }
   cout<<f;
      
}



  

Measured memory_bytes: 3696
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int arr[n][3];
    for(int i=0;i<n;i++){
        for(int j=0;j<3;j++){
            cin>>arr[i][j];
        }
    }
    int dp[n][3];
    for(int i=0;i<n;i++){
        for(int j=0;j<3;j++){
            if(i==0){
               dp[i][j]=arr[i][j]; 
            }
            else{
                if(j==0){
                    dp[i][j]=arr[i][j]+max(dp[i-1][1],dp[i-1][2]);
                }
                else if(j==1){
                    dp[i][j]=arr[i][j]+max(dp[i-1][0],dp[i-1][2]);
                }
                else{
                    dp[i][j]=arr[i][j]+max(dp[i-1][1],dp[i-1][0]);
                }
            }
        }
    }
    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
    return 0;
}

Measured memory_bytes: 2560
n, k = input().split()
n = int(n)
k = int(k)
A = [int(a) for a in input().split()]
m = 1000000007
inv = 0

count = 0

for i in range(n-1):
  for j in range(i+1,n):
    if A[i] > A[j]:
      inv += 1
inv2 = 0
for i in range(n):
  for j in range(n):
    if A[i] > A[j]:
      inv2 += 1

ans = inv*k + inv2*sum(range(k))

ans %= m
print(ans)



Measured memory_bytes: 43132
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
#define N 555
inline int read(){
	int x=0,f=1;
	char ch=getchar();
	while (ch<'0' || ch>'9'){
		if (ch=='-') f=-1;
		ch=getchar();
	}
	while (ch>='0' && ch<='9'){
		x=x*10+ch-'0';ch=getchar();
	}
	return x*f;
}
struct pt{
	int val,pos;
}v[N];
inline bool cmp(pt x,pt y){
	return x.val<y.val;
}
int cnt[N],ans[N*N],vis[N];
signed main(){
	int n=read();
	for (int i=1;i<=n;++i) v[i].val=read(),v[i].pos=i,vis[i]=v[i].val;
	sort(v+1,v+1+n,cmp);
	for (int i=1;i<=n;++i) cnt[i]=n;
	for (int i=1;i<=n;++i){
		int pos=v[i].pos;ans[v[i].val]=pos;cnt[pos]--;
		int tmp=v[i].val-1;int tot=pos-1;if (!tot) continue;
		for (int j=1;j<=tmp;++j){
			if (ans[j]) continue;
			ans[j]=pos;tot--;cnt[pos]--;if (tot==0) break;
		}
		if (tot>0){
			puts("No");return 0;
		}
	}
	for (int i=1;i<=n*n;++i){
		if (!ans[i]){
			int id=0;
			if (!cnt[id]){
				for (int j=1;j<=n;++j){
					if (vis[j]<i && cnt[j]) id=j;
				}
			}
			if (!id){
				puts("No");return 0;
			}
			ans[i]=id;cnt[id]--;
		}
	}
	puts("Yes");
	for (int i=1;i<=n*n;++i) printf("%d ",ans[i]);putchar('\n');
	return 0;
}


Measured memory_bytes: 2176
from numpy import*
n,k,*v=map(int,open(0).read().split())
m=0
for i in range(n):
 for j in range(min(k,n)-i+1):t=sort(v[:i]+v[:~j:-1]);m=max(m,sum(t)-sum(t[t<0][:k-i-j]))
print(m)

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

int main() {
  string s;
  cin >> s;
  int zero = 0;
  int one = 0;
  for(char c : s) {
    if (c == '0') {
      zero++;
    }else {
      one++;
    }
  }
  cout << 2*min(zero, one) << endl;
  return 0;
}



Measured memory_bytes: 512