akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define pii pair<int,int> 
#define pb push_back
#define INF INT_MAX 
#define mod 1000000007ll
#define fi first
#define se second
#define f(i,p,q) for(int i=p;i<q;i++)
#define si(a) scanf("%d",&a)
#define sii(a,b) scanf("%d %d",&a,&b)
#define siii(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define pi(a) printf("%d\n",a)
#define psi(a) printf(" %d",a)
#define poi(a) printf("%d",a)
#define sl(a) scanf("%lld",&a)
#define pl(a) printf("%lld\n",a)
#define Nline() printf("\n")
#define sstr(str) scanf("%s",str)
#define pstr(str) printf("%s\n",str)
#define SET(a) memset(a,-1,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))
#define vi vector<int>
#define vvi vector<vi>
#define all(v) (v).begin(),(v).end()
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())
#define ios ios::sync_with_stdio(false); cin.tie(0);cout.tie(NULL);
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(X) ( (X) > 0 ? (X) : ( -(X) ) )
#define S(X) ( (X) * (X) )
#define SZ(V) (int )V.size()
#define FORN(i, n) for(i = 0; i < n; i++)
#define FORAB(i, a, b) for(i = a; i <= b; i++)
#define ALL(V) V.begin(), V.end()
#define IN(A, B, C)  (B) <= (A) && (A) <= (C)
#define AIN(A, B, C) assert(IN(A, B, C))
int ar[200005];
void solve(){
      int n;cin>>n;
      f(i,2,n+1)
      {
      	int x;
      	cin>>x;
      	ar[x]++;
      }
      f(i,1,n+1)
      {
      	cout<<ar[i]<<endl;
      }
}
int main() {
    ios;
	int t=1;
	//cin>>t;
	while(t--)solve();
 
    
}


Measured memory_bytes: 4384
#include<iostream>
#include<string>
#include<typeinfo>
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
using namespace std;
typedef long long int ll;
int main()
{
	int n;
  	cin >> n;
  
	cout << n*800 - (n/15)*200 << endl;

	return 0;
}

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

#define ll long long
#define ld long double
 
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
 
#define err() cout<<"=================================="<<endl;
#define errA(A) for(auto i:A)   cout<<i<<" ";cout<<endl;
#define err1(a) cout<<#a<<" "<<a<<endl
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<endl

#define pb push_back
#define all(A)  A.begin(),A.end()
#define allr(A)    A.rbegin(),A.rend()
#define ft first
#define sd second
 
#define pll pair<ll,ll>
#define V vector<ll>
#define S set<ll>
#define VV vector<V>
#define Vpll vector<pll>
 
#define endl "\n"
 
const ll logN = 20;
const ll M = 1000000007;
const ll INF = 1e12;
#define PI 3.14159265
 
const ll N = 100005;

void solve(){
    string s;
    cin>>s;
    if(s=="ABC")    cout<<"ARC"<<endl;
    else cout<<"ABC"<<endl;
    return;
}

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll no;
    // cin>>no;
    no = 1;
    while(no--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3660
#define _USE_MATH_DEFINES

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

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

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

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

#include <ctime>
////
//#include <random>//
/////////

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
//////////////

void solve() {
	int N, L;
	cin >> N >> L;
	vector<string> S(N);
	for (int i = 0; i < N; ++i) {
		cin >> S[i];
	}
	sort(S.begin(), S.end());
	for (int i = 0; i < N; ++i) {
		cout << S[i];
	}
	cout << endl;
}

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

	solve();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<(n);++i)
#define rep2(i,a,b) for (ll i=(a);i<(b);++i)
#define debug(x) cout << #x << '=' << x << endl
#define all(v) (v).begin(),(v).end()
const ll MOD=1e9+7;
//const ll MOD=998244353;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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

struct UnionFind{
    private:
    int num;
    vector<int> par,rank,Size;
    public:
    UnionFind(int n){
        num=n;
        par.resize(n);
        rank.resize(n,0);
        Size.resize(n,1);
        rep(i,n) par[i]=i;
    }
    int root(int x){
        if (par[x]==x) return x;
        return par[x]=root(par[x]);
    }
    bool merge(int x, int y){
        x=root(x),y=root(y);
        if (x==y) return false;
        if (rank[x]<rank[y]) swap(x,y);
        if (rank[x]==rank[y]) ++rank[x];
        par[y]=x;
        Size[x]+=Size[y];
        --num;
        return true;
    }
    bool same(int x, int y){
        return root(x)==root(y);
    }
    int size(int x){
        return Size[root(x)];
    }
    int count() const{
        return num;
    }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,M; cin >> N >> M;
    if (M==N-1){
        cout << 0 << endl;
        return 0;
    }
    if (N<2*(N-M-1)){
        cout << "Impossible" << endl;
        return 0;
    }
    vector<ll> a(N);
    rep(i,N) cin >> a[i];
    UnionFind uf(N);
    rep(i,M){
        int x,y; cin >> x >> y;
        uf.merge(x,y);
    }
    map<int,Pll> m;
    rep(i,N){
        int p=uf.root(i);
        if (m[p].first==0) m[p]=Pll(a[i],i);
        else chmin(m[p],Pll(a[i],i));
    }
    vector<bool> used(N,false);
    ll ans=0,rest=2*(N-M-1);
    for (auto x:m){
        Pll p=x.second;
        used[p.second]=true;
        ans+=p.first;
        --rest;
    }
    priority_queue<ll,vector<ll>,greater<ll>> pq;
    rep(i,N) if (!used[i]) pq.push(a[i]);
    rep(i,rest){
        ans+=pq.top();
        pq.pop();
    }
    cout << ans << endl;
}

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

#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1<<29)
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int MAX =510000;
ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second < b.second;
    }
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N,A,B;
    cin>>N>>A>>B;

    if(B<A||N==0){
        cout<<0<<endl;
        return 0;
    }
    if(A==B||N==2){
        cout<<1<<endl;
        return 0;
    }
    if(N==1&&A!=B){
        cout<<0<<endl;
        return 0;
    }
    ll ans;ans=0;
    ans=B*(N-2)-A*(N-2)+1;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
import sys

N = int(input())
Ai = map(lambda x:int(x),input().split(" "))
 
def f(arg_list):
    even_arg_list = []
    for i in arg_list:
        if i % 2 == 0:
            even_arg_list.append(i/2)
        else:
            return False
    return even_arg_list


counter = 0
while True:
    Ai = f(Ai)
    if Ai == False:
        print(counter)
        sys.exit()
    counter+=1
    # print(Ai)
    

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

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

int main() {
  int N, A, B;
  cin >> N >> A >> B;

  int answerSum = 0;

for (int i= 1; i <= N; i++) {
  int calculateDigitSumBox = calculateDigitSum(i);
  if (A <= calculateDigitSumBox && calculateDigitSumBox <= B) {
    answerSum += i;
  }
}

  cout << answerSum << endl;
}


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


namespace _20180502_pra
{
    class Program
    {
        static void Main(string[] args)
        {

            int N = int.Parse(Console.ReadLine());
            int sum = 0;

            for (int i = 1; i <= N; i++)
            {
                sum += i;
            }

            Console.WriteLine(sum);


        }
    }
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0)
#define mapmax(v) v.rbegin()->first
#define mapmin(v) v.begin()->first
#define pb push_back
#define pf push_front
#define mod 1000000007
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n

typedef long long ll;

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<string> vs;

typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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

ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	ll n,k,ans;
	cin >> n >> k;
	ans=pow(n/k,3);
	if(k%2==0) ans+=pow((n+k/2)/k,3);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define ld long double
int main()
{
ll a;
cin>>a;
ll ans=0;if(a!=0){
for(ll i=0;;i++)
{if(ans>=a){cout<< i-1<<endl;break;}ans+=i;}
}else{cout<<0<<endl;}	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
judge = 0
for i in range(N):
    if A[i] % 2 == 1:
        continue
    elif A[i]%3 == 0 or A[i]%5 == 0:
        judge += 0
    else:
        judge += 1
print('APPROVED' if judge == 0 else 'DENIED')

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

using namespace std;

int sg[1000009];

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

int N, M, x, y;
scanf ("%d %d", &N, &M);
while (M --)
    scanf ("%d %d", &x, &y),
    sg[x] ^= 1, sg[y] ^= 1;
bool ok = 1;
for (int i=1; i<=N; i++)
    if (sg[i])
        ok = 0;
if (ok) printf ("YES\n");
else printf ("NO\n");
return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using namespace std;

const int INF = 2e9 + 7;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    vector<vector<int>> arr(3, vector<int>(3));
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) cin >> arr[i][j];
    }
    int n;
    cin >> n;
    for (int k = 0; k < n; k++) {
        int a;
        cin >> a;
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) if (arr[i][j] == a) arr[i][j] = -1;
        }
    }
    if ((arr[0][0] == arr[0][1] && arr[0][1] == arr[0][2]) ||
        (arr[1][0] == arr[1][1] && arr[1][1] == arr[1][2]) ||
        (arr[2][0] == arr[2][1] && arr[2][1] == arr[2][2])) {
        cout << "Yes";
        return 0;
    }
    if ((arr[0][0] == arr[1][0] && arr[1][0] == arr[2][0]) ||
        (arr[0][1] == arr[1][1] && arr[1][1] == arr[2][1]) ||
        (arr[0][2] == arr[1][2] && arr[1][2] == arr[2][2])) {
        cout << "Yes";
        return 0;
    }
    if ((arr[0][0] == arr[1][1] && arr[1][1] == arr[2][2]) || (arr[0][2] == arr[1][1] && arr[1][1] == arr[2][0])) {
        cout << "Yes";
        return 0;
    }
    cout << "No";
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
 
public class Main {
	private	static	BufferedReader	br = null;
	private	static	double[][]		cd = null;
	private	static	int[]			rr = { Integer.MAX_VALUE, Integer.MIN_VALUE };

	static {
		br = new BufferedReader(new InputStreamReader(System.in));
	}
 
    /**
     * @param args
     */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		int		size = 0;
		Data	data = null;
		DataTbl	tbl  = new DataTbl();
		
		while ((data = parseData()) != null) {
			tbl.add(data);
		}

		calcDist();

		size = tbl.size();
		for (int i = 0; i < size; i++) {
			data = tbl.get(i);
			System.out.println(solve(data));
		}
	}

	public static String solve(Data data) {
		String	res = "NA";
		double	min = Double.MAX_VALUE;
		double	tmp = 0.0;

		do {
			tmp = (double)data.cr[0]+(double)data.cr[data.cr.length-1];
			for (int i = 0; i < data.cr.length-1; i++) {
				tmp += cd[data.cr[i]-rr[0]][data.cr[i+1]-rr[0]];
			}
			min = Math.min(min, tmp);

			if (min <= data.wi) {
				res = "OK";
				break;
			}
		} while(next_perm(data.cr));

		return res;
	}

	static boolean next_perm(int[] cr) {
		int		i;
		int		j;
		int		t;
		int		l = cr.length;
		boolean	r = false;
	    
		if (l > 0) {
			for(i = l - 1; i > 0 && cr[i-1] >= cr[i]; i--);

			if (i > 0) {
				for(j = l - 1; j > i && cr[i-1] >= cr[j]; j--);

				// swap(p,j,i-1);
				t = cr[j];
				cr[j] = cr[i-1];
				cr[i-1] = t;

				for(j=l-1; i < j; i++, j--){
					// swap(p,i,j);
					t = cr[i];
					cr[i] = cr[j];
					cr[j] = t;
				}

				r = true;
			}
		}

		return r;
	}

	public static void calcDist() {
		int	sz = rr[1]-rr[0];

		cd = new double[sz+1][sz+1];
		for (int i = 0; i <= sz; i++) {
			for (int j = i; j <= sz; j++) {
				double	d = 0.0;
				if (i == j) {
					d = (double)((rr[0]+i)*2);
				} else {
					d = Math.sqrt(Math.pow((double)(rr[0]*2+j+i), 2.0)-Math.pow((double)(j-i), 2.0));
				}
				cd[i][j] = d;
				cd[j][i] = d;
			}
		}
	}

	private static Data parseData() {
		Data	data  = null;
		String	stdin  = null;

		if ((stdin = parseStdin()) != null) {
			String[]	lines = stdin.split(" ");

			data = new Data(lines.length-1);
			for(int i = 0; i < lines.length; i++) {
				if (i == 0) {
					data.wi = Integer.parseInt(lines[i]);
				} else {
					data.cr[i-1] = Integer.parseInt(lines[i]);
					rr[0] = Math.min(rr[0], data.cr[i-1]);
					rr[1] = Math.max(rr[1], data.cr[i-1]);
				}
			}
			Arrays.sort(data.cr);
		}

		return data;
	}

	private static String parseStdin() {
		String  stdin = null;

		try {
			String  tmp = br.readLine();
			if (tmp != null) {
				if (!tmp.isEmpty()) stdin = tmp;
			}
		}
		catch (IOException e) {}

		return stdin;
	}
}

class DataTbl extends ArrayList<Data> {
}

class Data {
	int			wi = 0;
	int[]		cr = null;

	Data (int cc) {
		cr = new int[cc];
	}
}

Measured memory_bytes: 19416
#include <stdio.h>

int main(){
  int n,k;
  int X[100];
  scanf("%d%d", &n,&k);
  for(int i=0;i<n;i++)scanf("%d",&X[i]);
  int dist = 0;
  for(int i=0;i<n;i++){
    if(k-X[i] < X[i]){
      dist += (k-X[i])*2;
    }else{
      dist += X[i]*2;
    }
  }
  printf("%d\n", dist);
  return 0;
}


Measured memory_bytes: 1700
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

const long long INF = 1e18;
const ll mod = 1000000007;
ll posmax[201000];
ll posmin[201000];
ll negmax[200100];
ll negmin[200100];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, K;
    cin >> N >> K;
    vector<ll> pos, neg;
    for(int i = 0; i < N; i++) {
        ll a;
        cin >> a;
        if(a >= 0) pos.push_back(a);
        else neg.push_back(-a);
    }
    sort(neg.begin(), neg.end(), greater<ll>());
    sort(pos.begin(), pos.end(), greater<ll>());
    if((K == N and neg.size() % 2 == 1) or (neg.size() == N and K % 2 == 1)) {
        ll ans = mod - 1;
        vector<ll> A;
        for(auto val : neg) A.push_back(val);
        for(auto val : pos) A.push_back(val);
        sort(A.begin(), A.end());
        for(int i = 0; i < K; i++) {
            ans = ans * A[i] % mod;
        }
        cout << ans << endl;
    } else {
        ll ans = 1;
        ll idx1 = 0;
        ll idx2 = 0;
        while(K) {
            //cerr << K << " " << idx1 << " " << idx2 << endl;
            if(K % 2 == 1) {
                K--;
                ans *= pos[idx1];
                idx1++;
                ans %= mod;
                continue;
            }
            K -= 2;
            if(idx1 + 1 >= pos.size()) {
                ans *= neg[idx2];
                ans %= mod;
                idx2++;
                ans *= neg[idx2];
                ans %= mod;
                idx2++;
                continue;
            }
            if(idx2 + 1 >= neg.size()) {
                ans *= pos[idx1];
                ans %= mod;
                idx1++;
                ans *= pos[idx1];
                ans %= mod;
                idx1++;
                continue;
            }
            if(neg[idx2]*neg[idx2+1] >= pos[idx1]*pos[idx1+1]) {
                ans *= neg[idx2];
                ans %= mod;
                idx2++;
                ans *= neg[idx2];
                ans %= mod;
                idx2++;
                continue;
            }
            if(neg[idx2]*neg[idx2+1] <= pos[idx1]*pos[idx1+1]) {
                ans *= pos[idx1];
                ans %= mod;
                idx1++;
                ans *= pos[idx1];
                ans %= mod;
                idx1++;
                continue;
            }
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 6768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define mod 1000000007
ll modpow(ll x,ll n)
{
	ll res=1;
	while(n>0)
	{
		if(n&1) res=res*x%mod;
		x=x*x%mod;
		n>>=1;
	}
	return res;
}
ll F[100005],R[100005];
void make(){
	F[0] = 1;
	for(int i=1;i<100005;i++) F[i] = F[i-1]*i%mod;
	for(int i=0;i<100005;i++) R[i] = modpow(F[i],mod-2);
}
int main(){
	make();
	int n,m; cin >> n >> m;
	if(abs(n-m) > 1){
		puts("0"); return 0;
	}
	else{
		if(n == m){
			cout << 2LL*F[n]*F[n]%mod << endl;
		}
		else{
			cout << F[max(n,m)] * F[min(n,m)] % mod << endl;
		}
	}
}

Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int s = 1,x;

bool panduan(int a,int b,int c){
	x = a;
	if(a == 1)return true;
	while(s <= b){
		if(a % b == c)return true;
		a = x;
		s++;
		a *= s;
	}
	return false;
}

int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(panduan(a,b,c))cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	
	return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
K_multi = []
K_half_multi = []
ans = 0

if K % 2 == 0:
    K_half = K // 2
    for i in range(1, N+1):
        if i % K == 0:
            K_multi.append(i)
        elif i % K == K_half:
            K_half_multi.append(i)
else:
    for i in range(1, N+1):
        if i % K == 0:
            K_multi.append(i)

ans += len(K_multi)**3
ans += len(K_half_multi)**3

print(ans)


Measured memory_bytes: 11036
ans' n _ _ [] = -1
ans' n t e (d:ds) =
  let max = t + e
      min = t - e
      rem = min `mod` d
      dmn = min `div` d
      dmx = max `div` d
  in
    if rem == 0 || dmx > dmn
    then n
    else ans' (n+1) t e ds

ans ([n,t,e]:ds:_) = ans' 1 t e ds

main = do
  c <- getContents
  let i = map (map read) $ map words $ lines c :: [[Int]]
      o = ans i
  print o



Measured memory_bytes: 4192
#pragma GCC target("avx512f,avx512dq,avx512cd,avx512bw,avx512vl")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int n = ri();
	std::string s;
	std::cin >> s;
	int64_t res = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < i; j++) {
			if (s[i] == s[j]) continue;
			for (int k = 0; k < j; k++) if (k != j + j - i && s[k] != s[i] && s[k] != s[j]) res++;
		}
	}
	printf("%" PRId64 "\n", res);
	return 0;
}


Measured memory_bytes: 3748
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
const int MOD=(int)1e9+7;
using namespace std;
int main(){
    int r,g,b;
    cin>>r>>g>>b;
    if((r*100+g*10+b)%4 == 0) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define int long long
#define p pair<int, int>
#define endl '\n'
const int INF = 1000000001;
const long double E = 0.00000001;

using namespace std;

const int C = 1000000007;

vector<int> fact = {1};

int pow1(int x, int y){
    if (y == 0){
        return 1;
    }
    if (y % 2 == 0){
        return pow1(x*x % C, y/2);
    }
    return pow1(x, y-1)*x % C;
}

void facts(int n){
    for (int q = 1; q <= n; q++){
        fact.push_back(fact.back()*q % C);
    }
}

int c(int k, int n){
    if (k > n){
        return 0;
    }
    return fact[n]*pow1(fact[k], C-2) % C*pow1(fact[n-k], C-2) % C;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int k;
    string s;
    cin >> k >> s;
    int n = s.size();
    facts(k+n);
    int ans = 0;
    for (int q = n; q <= n+k; q++){
        ans += pow1(25, q-n)*pow1(26, n+k-q) % C*c(n-1, q-1) % C;
    }
    cout << ans % C << endl;
    return 0;
}


Measured memory_bytes: 21100
#include<bits/stdc++.h>
using namespace std;
#define INS(x) x.begin(),x.end()
    

    
int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n,r;
    cin>>n>>r;

    if (n>10) n=10;
    cout<<100*(10-n)+r<<'\n';
    return 0;
}

Measured memory_bytes: 256
/*g++ file.cpp -o file.out*/
/*./file.out*/

#include <cmath>
#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;

#define LL long long
#define Mod 1000000007
#define L_Mod 17100000013

char str[100001];

int main()
{
    int mn=0;
    cin>>str;
    for(int i=0; i<strlen(str)-1; i++)
        if(str[i]!=str[i+1])
            mn++;
    cout<<mn;
    return 0;
}


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

int main() {
    ll n, k;
    cin >> n >> k;
    ll surplus = n % k;
    if (surplus*2 > k) cout << k - surplus << endl;
    else cout << surplus << endl;
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const double PI=3.14159265358979;
const int INF=1000000007;
const ll LMAX=1000000000000000001;
const ll mod=1000000007;
ll gcd(ll a,ll b){if(a<b)swap(a,b);while((a%b)!=0){a=b;b=a%b;}return b;}
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};

int main(){
  int h,n; cin>>h>>n;
  vector<int> a(n);
  vector<int> b(n);
  rep(i,n) cin>>a[i]>>b[i];
  vector<vector<int>> dp(n+1,vector<int>(h+1,INF));
  dp[0][0]=0;

  rep(i,n){
    int ch=INF;
    rep(j,h+1){
      if(j-a[i]<0){
        if(j+a[i]>=h&&j==h)
        dp[i+1][j]=min(dp[i][j],b[i]);
        else
        dp[i+1][j]=dp[i][j];
      }else{
        if(j!=h)
        dp[i+1][j]=min(dp[i][j],dp[i+1][j-a[i]]+b[i]);
        else
        dp[i+1][j]=min(dp[i][j],ch+b[i]);

        if(j+a[i]>=h)
        ch=min(ch,dp[i+1][j]);
      }
    }
  }
 /*rep(i,n+1){
    rep(j,h+1){
      if(dp[i][j]!=INF)
      cout<<dp[i][j]<<" ";
      else
      cout<<"I ";
    }
    cout<<endl;
  }*/

  cout<<dp[n][h]<<endl;

  return 0;
}


Measured memory_bytes: 39424
<?php
list($a, $b) = explode(' ', trim(fgets(STDIN)));
$d = explode(' ', trim(fgets(STDIN)));

$target = [];
$cnt = count($d);
$total = 0;
$limit = $cnt - $b;
$ans = 0.0;
for ($i = 0; $i <= $limit; $i++) {
    if ($i == 0) {
        for ($j = 0; $j < $b; $j++) {
            $total += $d[$j];
        }
    } else {
        $total -= $d[$i - 1];
        $total += $d[$i - 1 + $b];
    }

    $pcnt = $total - $b + 1;
    $max = ($total + $b) * ($pcnt/2);

    $ans2 = ($max / $pcnt);
    if ($ans < $ans2) {
        $ans = (float)$ans2;
    }
}
echo (float)$ans . PHP_EOL;

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

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

    vector<int> h(N);
    rep(i, N) cin >> h[i];

    vector<int> dp(N);
    rep(i, N) dp[i] = INT_MAX;
    dp[0] = 0;

    for (int i = 0; i < N-1; i++) {
        for (int j = 1; j <= K && i + j < N; j++) {
            dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
        }
    }
    cout << dp[N - 1] << endl;
}

Measured memory_bytes: 3988
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void){
	char *p[2]={"No","Yes"};
	int n, i;
	scanf("%d", &n);
	if(n%3!=0){
		int a;
		char f=1;
		for(i=0; i<n; i++){
			scanf("%d", &a);
			if(a!=0){f=0; break;}
		}
		puts(p[f]);
	}else{
		int a;
		int k[3]={-1,-1,-1};
		int l[3]={0,0,0};
		char f=1;
		for(i=0; i<n; i++){
			scanf("%d", &a);
			if(k[0]<0||k[0]==a) {k[0]=a; l[0]++;}
			else if(k[1]<0||k[1]==a) {k[1]=a; l[1]++;}
			else if(k[2]<0||k[2]==a) {k[2]=a; l[2]++;}
			else {f=0; break;}
		}
		n=n/3;
		if(k[1]<0){
			if(k[0]!=0) f=0;
		}else if(k[2]<0){
			if(k[0]==0){
				if(l[0]!=n||l[1]!=n*2) f=0;
			}else if(k[1]==0){
				if(l[1]!=n||l[0]!=n*2) f=0;
			}else{
				f=0;
			}
		}else{
			if((k[0]^k[1]^k[2])!=0) f=0;
			if(l[0]!=n||l[1]!=n||l[2]!=n) f=0;
		}
		puts(p[f]);
	}
}



Measured memory_bytes: 128
N=int(input())
A=[int(input()) for i in range(N)]
#print(A)
B = A.copy()
#print(B)
B.sort()


for i in range(N):
	k = A[i]
	#print(k)
	if k != B[N-1]:
		print(B[N-1])
	else:
		print(B[N-2])


Measured memory_bytes: 14108
x, k, d = map(int, input().split())
x = abs(x)
count = 0

if x - k*d > 0:
    print(x - k*d)

elif x - k*d == 0:
    print(0)

else:
    count = x//d + 1
    x -= count * d
    
    if (k - count) % 2 == 0:
        print(abs(x))
    
    else:
        print(x + d)

Measured memory_bytes: 9104
#include <iostream>
#include <cstring>
#include <string>    
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll w, h, x, y;
string str;

int main(){
	cin >> w >> h >> x >> y;
	if(2*x == w && 2*y == h){cout << double(w*h)/2 << " " << 1 << endl;}
	else{cout << double(w*h)/2 << " " << 0 << endl;}
	return 0;
}

Measured memory_bytes: 256
/*************************************************************************
  > File Name: A.cc
  > Author: Riho.Yoshioka
  > Mail:   riho.yoshioka@yandex.com
  > Created Time: Sat 16 Jul 2016 08:01:00 PM CST
*************************************************************************/
#include <bits/stdc++.h>
typedef long long LL;
using namespace std;

int main() {
  ios::sync_with_stdio(0);
  int n;
  cin >> n;
  vector<int> a;
  for (int i = 0; i < 2 * n; i++) {
    int x;
    cin >> x;
    a.push_back(x);
  }
  sort(a.begin(), a.end());
  int ans = 0;
  for (int i = 0; i < n; i++) {
    ans += a[2 * i];
  }
  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <stdlib.h>
#include <math.h>
#include <list>
#include <algorithm>

using namespace std;

int main(void){
	//FILE* fp_in = freopen("data.txt", "r", stdin);

	while( 1 ) {
		int n, m, a;
		cin >> n >> m >> a;

		if( n == 0 && m == 0 && a == 0 ) break;

		vector<int> h,p,q;

		//横線の情報を取得
		for(int i = 0; i < m; i++) {
			int h_i, p_i, q_i;
			cin >> h_i >> p_i >> q_i;
			h.push_back( h_i - 1 );
			p.push_back( p_i - 1 );
			q.push_back( q_i - 1 );
		}

		//あみだくじの高さを調べる
		int height = 0;
		for(int i = 0; i < m; i++) 
			if( height < h.at(i) ) height = h.at(i);

		//各線を管理するvector
		vector<vector<int>> lines;
		for(int i = 0; i < n; i++) {
			vector<int> newline;
			for(int j = 0; j <= height; j++)
				newline.push_back(i);
			lines.push_back(newline);
		}

		//横線セット
		for(int i = 0; i < m; i++) {
			lines.at( p.at(i) ).at( h.at(i) ) = q.at(i);
			lines.at( q.at(i) ).at( h.at(i) ) = p.at(i);
		}

		//シミュレート
		int ans = a - 1;
		for(int i = height; i >= 0; i--)
			ans = lines.at( ans ).at( i ) ;

		cout << ans + 1 << endl;
	}

	//while(1){}
	return 0;
}

Measured memory_bytes: 1616
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <set>
using namespace std;
#define ll long long
#include <cstdint>

int main() {
	int a, b;
	cin >> a >> b;
	if (a > 8 || b > 8)cout << ":(" << endl;
	else cout << "Yay!" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<unordered_map>
int res[10]={-1,-1,-1,-1,-1,-1};
using namespace std;
int main(){
	int n,m;
	scanf("%d %d",&n,&m);
	int flag=1;
	for(int i=0;i<m;i++){
		int index,num;
		scanf("%d %d",&index,&num);
		if(res[index]==-1 || res[index]==num){
			res[index]=num;
		}else {
			flag=0;
			break;
		}
	} 
	if(n>1 &&res[1]==0) flag=0;
	
	if(n>1) res[1]=max(res[1],1);
	if(flag){
		for(int i=1;i<=n;i++){
			res[i]=max(res[i],0);
			printf("%d",res[i]);
		}
		
	}else{
		printf("-1");
	}
	

	return 0;
}

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

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

mint dp[55][55][2605];

int main() {
  int n, score;
  cin >> n >> score;
  dp[0][0][0] = 1;
  rep(i,n) {
    rep(j,i+1)rep(k,score+1) {
      {
        int nj = j;
        dp[i+1][nj][k+nj*2] += dp[i][j][k];
      }
      {
        int nj = j+1;
        dp[i+1][nj][k+nj*2] += dp[i][j][k];
      }
      {
        int nj = j;
        mint x = j*2;
        dp[i+1][nj][k+nj*2] += dp[i][j][k]*x;
      }
      if (j >= 1) {
        int nj = j-1;
        mint x = j*j;
        dp[i+1][nj][k+nj*2] += dp[i][j][k]*x;
      }
    }
  }
  mint ans = dp[n][0][score];
  cout << ans.x << endl;
  return 0;
}

Measured memory_bytes: 61824
import queue

k = 0

def format_input(filename = None):
	global k
	if filename == None:
		k = int(input())

	elif filename == '__random__':
		from random import randint as rng
		k = rng(1, 10**5)
		print(k)

def get_answer():
	q = queue.Queue()
	[q.put(i) for i in range(1, 10)]
	i = 0
	while i < k:
		answer = q.get()
		child = answer * 10 + answer % 10
		if child % 10 != 0:
			q.put(child - 1)
		q.put(child)
		if child % 10 != 9:
			q.put(child + 1)
		i += 1
	return answer

if __name__ == '__main__':
	format_input()

	ans = get_answer()
	print(ans)


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

double dis(vector<int>x, vector<int>y, int p){
    double d, sum=0;
    for (int i = 0; i < x.size(); i++)
    {
        sum += pow(abs(x.at(i)-y.at(i)), (double)p);
    }
    d = pow(sum, (double)1/p);
    return d;
}

int main(){
    int n;
    cin >> n;
    vector<int> x(n), y(n);
    double d1, d2, d3, din;
    for (int i = 0; i < n; i++)
    {
        cin >> x.at(i);
    }
    for (int i = 0; i < n; i++)
    {
        cin >> y.at(i);
    }
    
    d1 = dis(x, y, 1);
    d2 = dis(x, y, 2);
    d3 = dis(x, y, 3);
    din = abs(x.at(0)-y.at(0));
    for (int i = 1; i < n; i++)
    {
        if(abs(x.at(i) - y.at(i)) > din) din = abs(x.at(i) - y.at(i));
    }
    
    cout << fixed << setprecision(10) << d1 << endl << d2 << endl << d3 << endl << din << endl;
}


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

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

    auto f = [](const int &a, const int &b) { return a > b; };
    multiset<int, decltype(f)> s(f);
    for(int i = 0, temp = 0; i < 1 << N; i++) cin >> temp, s.insert(temp);

    bool ok = true;
    vector<int> v(1 << N, 0);
    v[0] = *s.begin();
    s.erase(s.begin());
    for(int i = 0; i < N && ok; i++) {
        for(int j = 0, q = 1 << i; j < 1 << i; j++, q++) {
            auto it = s.upper_bound(v[j]);
            if(it != s.end()) {
                v[q] = *it;
                s.erase(it);
            }
            else {
                ok = false;
                break;
            }
        }
    }

    cout << (ok ? "Yes" : "No") << endl; 
    return 0;
}

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

#define inf 1072114514
#define llinf 4154118101919364364
#define mod 1000000007
#define pi 3.1415926535897932384


int round(int a,int b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;} 
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}    //最大公約数
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}     //最小公倍数
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;} //コンビネーション
int nHr(int a,int b){return nCr(a+b-1,b);}       // 重複組み合わせ
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}  //階乗
int pow(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;} // a~bまでの階乗
int dsum(int x){int r=0;while(x){r+=(x%10);x/=10;}return r;}   //数字の各位の和
int dsumb(int x,int b){int r=0;while(x){r+=(x%b);x/=b;}return r;}  // b進数の各位の和？
int sankaku(int x){return ((1+x)*x)/2;} //三角数 xまでの和

//以下long long ver
long long llmax(long long a,long long b){if(a>b){return a;}return b;}
long long llmin(long long a,long long b){if(a<b){return a;}return b;}
long long llzt(long long a,long long b){return llmax(a,b)-llmin(a,b);}
long long llround(long long a,long long b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
long long llceil(long long a,long long b){if(a%b==0){return a/b;}return (a/b)+1;}
long long llgcd(long long a,long long b){long long c;while(b!=0){c=a%b;a=b;b=c;}return a;}
long long lllcm(long long a,long long b){long long c=llgcd(a,b);a/=c;return a*b;}
long long llnCr(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
long long llnHr(long long a,long long b){return llnCr(a+b-1,b);}
long long llfact(long long a){long long i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
long long llpow(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
long long lldsum(long long x){long long r=0;while(x){r+=(x%10);x/=10;}return r;}
long long lldsumb(long long x,long long b){long long r=0;while(x){r+=(x%b);x/=b;}return r;}
long long llsankaku(long long x){return ((1+x)*x)/2;}

//double
double dbmax(double a,double b){if(a>b){return a;}return b;}
double dbmin(double a,double b){if(a<b){return a;}return b;}
double dbzt(double a,double b){return dbmax(a,b)-dbmin(a,b);}


typedef pair<int, int> ii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
#define forr(i,a,b) ; for(int i=(a); i<(b); i++)
#define clean(arr,val) memset(arr,val,sizeof(arr))
#define forn(i,n) forr(i,0,n)
#define PB push_back
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<pll> vpll;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

 
/*CODE START HERE*/
int main() {
  int a, b,c,x;
  cin >> a >> b >> c >> x;
  int ans = 0;
  forn(i,a+1){
    int f=500*i ;
    forn(j,b+1){
      int g=100*j;
      forn(k,c+1){
        int h= 50*k;
        if ( f+g+h==x){
          ans++;
        }
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3616
#!/usr/bin/env python3
import sys


def solve(N: int, X: "List[int]"):
    Y = sorted(X)
    me1 = Y[N//2]
    me2 = Y[N//2-1]

    for i in range(N):
        if X[i]<=me2:
            print(me1)
        elif X[i]>=me1:
            print(me2)

    return


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

if __name__ == '__main__':
    main()


Measured memory_bytes: 30844
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(b);i>(a);--i)
#define eper(i,a,b) for(int i=((int)(a));i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF 2000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

string s, t;
int main() {
 ios::sync_with_stdio ( false );
 cin.tie ( 0 );
    cin >> s >> t;
    rep(i, 0, s.size()) {
        string sub = s.substr(0, s.size()-1);
        s = s[s.size()-1] + sub;
        if (s == t) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
// {{{
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
// }}}

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

static constexpr int mod = (int)1e9 + 7;
static constexpr int inf = 100100100;
static constexpr ll linf = 1e18;
static constexpr double eps = 1e-9;
static constexpr double pi = 3.14159265359;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rrep(i, a) for (ll i = a; i >= 0; --i)
#define all(obj) begin(obj), end(obj)
#define rall(obj) rbegin(obj), rend(obj)
#define pb push_back
#define fst first
#define snd second

ll solve(ll X, ll Y, ll ans) {
    if (X > Y) return ans;
    return solve(X * 2, Y, ans + 1);
}


int main() {
    // cin.tie(0);
    // ios_base::sync_with_stdio(false);
    ll X, Y;
    cin >> X >> Y;
    cout << solve(X, Y, 0) << endl;
}



Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		int m = Integer.parseInt(sa[1]);
		int p = Integer.parseInt(sa[2]);
		int[] a = new int[m];
		int[] b = new int[m];
		int[] c = new int[m];
		for (int i = 0; i < m; i++) {
			sa = br.readLine().split(" ");
			a[i] = Integer.parseInt(sa[0]) - 1;
			b[i] = Integer.parseInt(sa[1]) - 1;
			c[i] = Integer.parseInt(sa[2]);
			c[i] = p - c[i];
		}
		br.close();

		List<List<Integer>> list1 = new ArrayList<>(n);
		List<List<Integer>> listn = new ArrayList<>(n);
		for (int j = 0; j < n; j++) {
			list1.add(new ArrayList<>());
			listn.add(new ArrayList<>());
		}
		for (int j = 0; j < m; j++) {
			list1.get(a[j]).add(j);
			listn.get(b[j]).add(j);
		}
		boolean[] visit1 = new boolean[n];
		boolean[] visitn = new boolean[n];
		dfs(0, -1, visit1, list1, b);
		dfs(n - 1, -1, visitn, listn, a);

		int s = 0;
		long[] d = new long[n];
		Arrays.fill(d, 1_000_000_000_000_000_000L);
		d[s] = 0;
		boolean upd = true;
		for (int i = 0; i <= n && upd; i++) {
			upd = false;
			for (int j = 0; j < m; j++) {
				if (visit1[a[j]] && visitn[b[j]]) {
					long alt = d[a[j]] + c[j];
					if (d[b[j]] > alt) {
						d[b[j]] = alt;
						upd = true;
					}
				}
			}
			if (i == n) {
				System.out.println(-1);
				return;
			}
		}
		System.out.println(Math.max(-d[n - 1], 0));
	}

	static void dfs(int x, int p, boolean[] visit, List<List<Integer>> list, int[] to) {
		visit[x] = true;
		for (int i : list.get(x)) {
			if (!visit[to[i]]) {
				dfs(to[i], x, visit, list, to);
			}
		}
	}
}


Measured memory_bytes: 27888
#include <bits/stdc++.h>
#include <math.h>
#define rep(i,n) for (int i=0;i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
 

int main() {
    ll n;
    ll inf = 1e18;
    ll ans=1;
    cin >> n;
    vector<ll> a(n);
    rep(i,n){
        cin >> a[i];
    }
    sort(ALL(a));
    rep(i,n){
        if(a[i]==0){
            cout << 0 << endl;
            return 0;
        } else if (inf/ans>=a[i]){
            ans *= a[i];
        } else {
            cout << -1  << endl;
            return 0;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 4048
/*#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <array>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <unordered_map>
#include <unordered_set>
*/

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

#define int long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())

typedef long long ll;
const ll INF = LLONG_MAX - 100;
const ll mod = 1e9 + 7;
const int MAX_N = 5e5 + 5;
int dx[] = { -1LL,0,1LL,0 }, dy[] = { 0,1LL,0,-1LL };
vector<ll> prime;

ll inv[MAX_N], fac[MAX_N];

inline ll GCD(ll a, ll b) { ll c; while (b != 0) { c = a % b; a = b; b = c; }return a; }
inline ll LCM(ll a, ll b) { return a * b / GCD(a, b); }
inline ll POW(ll a, ll b) { ll c = 1LL; while (b > 0) { if (b & 1LL) { c = a * c%mod; }a = a * a%mod; b >>= 1LL; }return c; }
inline void _nCr() { fac[0] = 1LL; for (int i = 1LL; i < MAX_N; i++) { fac[i] = fac[i - 1LL] * i%mod; }for (int i = 0; i < MAX_N; i++) { inv[i] = POW(fac[i], mod - 2); } }
inline ll nCr(ll n, ll r) { return (fac[n] * inv[r] % mod)*inv[n - r] % mod; }
inline void PRI(ll n) { bool a[n + 1LL]; for (int i = 0; i < n + 1LL; i++) { a[i] = 1LL; }for (int i = 2; i < n + 1LL; i++) { if (a[i]) { prime.pb(i); ll b = i; while (b <= n) { a[b] = 0; b += i; } } } }

vector<vector<pair<int,int> > > A(100005);
bool visited[100005];
int depth[100005];
int syoki[100005];

signed main() {
	int n,m; cin >> n >> m;
	REP (i,m) {
		int x,y,z; cin >> x >> y >> z;
		x--; y--;
		A[x].push_back({y,z});
		A[y].push_back({x,z});
	}

	queue<int> p;
	p.push(0);
	syoki[0] = 1;

	int t = INF;
	bool kiheiro = false;
	while (!p.empty()) {
		int x = p.front();
		p.pop();
		visited[x] = true;
		REP (i,A[x].size()) {
			if (!visited[A[x][i].F]) {
				visited[A[x][i].F] = true;
				syoki[A[x][i].F] = A[x][i].S - syoki[x];
				depth[A[x][i].F] = (depth[x] + 1) % 2;
				p.push(A[x][i].F);
			} else if (depth[x] == depth[A[x][i].F]) {
				kiheiro = true;
				int tmp;
				if ((A[x][i].S - (syoki[x] + syoki[A[x][i].F])) % 2 != 0) {
					cout << 0 << endl;
					return 0;
				}
				tmp = (A[x][i].S - (syoki[x] + syoki[A[x][i].F])) / 2;
				if (depth[x] == 1) tmp *= -1;
				if (t != INF) if (t != tmp) {
					cout << 0 << endl;
					return 0;
				}
				t = tmp;
			} else {
				if (A[x][i].S != (syoki[x] + syoki[A[x][i].F])) {
					cout << 0 << endl;
					return 0;
				}
			}
		}
	}

	if (kiheiro) {
		REP (i,n) {
			if (depth[i] == 0) {
				if (syoki[i] + t < 1) {
					cout << 0 << endl;
					return 0;
				}
			} else {
				if (syoki[i] - t < 1) {
					cout << 0 << endl;
					return 0;
				}
			}
		}
		cout << 1 << endl;
	} else {
		int mi = 0, ma = INF;
		REP (i,n) {
			if (depth[i] == 0) {
				mi = max(mi,-(syoki[i])+1);
			} else {
				ma = min(ma,syoki[i]-1);
			}
		}
		if (mi > ma + 1) cout << 0 << endl;
		else cout << ma - mi + 1<< endl;
	}
}


Measured memory_bytes: 9856