akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    string S;
    cin >> S;

    ll res = 0;
    rep(i, S.size()) {
        res += (ll)(S[i] - '0');
    }

    if (res % 9 == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3752
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<int> a,b;
    int c;
    a.push_back(0);
    for(int i=0;i<N;i++){
        cin >> c;
        a.push_back(c);
    }
    a.push_back(0);
    int sum=0;
    for(int i=0;i<N+1;i++){
        b.push_back(abs(a[i]-a[i+1]));
        sum += b[i];
    }
    int ans=0;
    for(int i=0;i<N;i++){
        ans = sum;
        ans = ans - (b[i]+b[i+1]) + (abs(a[i+2]-a[i]));
        cout << ans << endl;
    }
}


Measured memory_bytes: 2168
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()   //reverse
#define strall(v) (v).cbegin(),(v).cend() //const_itterator
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

const int INF = 1e9+5;
int main(){
  int N;
    int t[110000], x[110000], y[110000];
    cin >> N;
    t[0] = x[0] = y[0] = 0;  // 初期状態
    for (int i = 0; i < N; ++i) cin >> t[i+1] >> x[i+1] >> y[i+1];  // 1-index にしておく

    bool can = true;
    for (int i = 0; i < N; ++i) {
        int dt = t[i+1] - t[i];
        int dist = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i]);
        if (dt < dist) can = false;
        if (dist % 2 != dt % 2) can = false;  // dist と dt の偶奇は一致する必要あり！
    }

    if (can) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 1408
sum=0
Q,H,S,D=input().split()
Q=int(Q)
H=int(H)
S=int(S)
D=int(D)

if not(1<=Q<=10**8 and 1<=H<=10**8 and 1<=S<=10**8 and 1<=D<=10**8):
	print("input error1")

QQ=Q*4
HH=H*2

QQQ=8*Q
HHH=4*H
SSS=2*S
N=int(input())

if not(1<=N<=10**9):
	print("input error2")

if N==1:
	sum=min(QQ,HH,S)
else:
	sum+=(N//2)*min(QQQ,HHH,SSS,D)
	if N%2==1:
		sum+=min(QQ,HH,S)

print(sum)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
typedef long long LL;

int main()
{
    int n;
    cin>>n;
    map<int,int>mp;
    for(int i=1;i<n;i++)
    {
        int x;
        cin>>x;
        mp[x]++;
    }
    for(int i=1;i<=n;i++)
        cout<<mp[i]<<endl;




    int ab;
    cin>>ab;
    return 0;
}


Measured memory_bytes: 12960
def main():
    s = list(map(int, input()))
    r = sum(a + b for a, b in iter_formulas(s))
    print(r)

def iter_formulas(s):
    if len(s) == 1:
        yield 0, s[0]
        return
    
    for a, b in iter_formulas(s[:-1]):
        yield a + b, s[-1]
        yield a, b * 10 + s[-1]

main()


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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;

int main() {
    int n, a, b; cin >> n >> a >> b;
    int ans = 0;
    for(int i = 1; i <= n; i++){
        int sum = 0;
        int t = i;
        while(t > 0){
            // 余りが1桁目なので加算
            sum += t % 10;
            // 霜一桁を切っていく
            t /= 10;
        }
        if(a <= sum && sum <= b){
            ans += i;
        }
    }
    cout << ans << endl;
}


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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	vector<int> a(3);
	rep(i, 3) cin >> a[i];
	int ans = inf;
	rep(ri, 51) {
		int tmp = ri;
		int cnt = 0;
		rep(i, 3) {
			if (a[i] >= tmp) cnt += a[i] - tmp;
			else cnt += (tmp - a[i]) / 2 + ((tmp - a[i]) % 2 == 0 ? 0 : 2);
		}
		mins(ans, cnt);
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
    int N;
    float a;
    cin>>N;
    if(N%2==0){
        a=(float)1/2;
    }
    else if(N%2!=0){
       a=(float)((N/2)+1)/N;
    }
    cout<<a;
    return 0;
}


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

int main(){
	int n; cin>>n;
	int ans=n;
	for(int i = 0; i <= n; i++) {
				int a = 0, b = i;
				while(b > 0) {
					a += b % 6;
					b /= 6;
				}
				b = n - i;
				while(b > 0) {
					a += b % 9;
					b /= 9;
				}
			ans=min(ans,a);
	}
	cout<<ans<<endl;
}


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

int main(){
  int N;
  cin >> N;
  int ans =0;
  int myans =0;
  for(int i=3;i<=N;i++){
//    if( i % 2 !=0){
      for(int j=1;j<=N;j++){
        if (i%j ==0){
 //         cout << i << " " << j << " " << i%j << endl;
          myans++;
        }
      }
      if(myans == 8 && i % 2 !=0){
        ans++;
//        cout << i << endl;
      }
      myans = 0;
//    }
  }
  cout << ans << endl;
  
  return 0;
}

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

using namespace std;

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

    int a,b,c;

    a=count(s.begin(),s.end(),'R');
    b=count(s.begin(),s.end(),'G');
    c=count(s.begin(),s.end(),'B');
    //cout<<a<<b<<c;
    long long ans=(long long) a*b*c;

    for(int i=0; i<n; i++)
    {
        for(int j=i+1; j<n; j++)
        {
            int k=j+(j-i);

            if(k<n && s[i]!=s[j] && s[i]!=s[k] && s[j]!=s[k])
                ans--;
        }
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 3632
/// Bismillahir Rahmanir Rahim
/* Mohammad Morsalin
   Dept of ICE, NSTU
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long
#define pb push_back
#define mp make_pair
#define endl "\n"
#define int long long
#define f0(n) for(int i=0;i<n;i++)
#define ms(x) memset(x,0,sizeof(x))
#define ms2d(x,m,n) memset(x, 0, sizeof(x[0][0]) * m * n)
#define uniq(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define pi pair<int,int>
#define tc(t) int t;cin>>t;while(t--)
#define bits(n) __builtin_popcount(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define ins insert
#define ALL(v) v.begin(),v.end()
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define fi first
#define se second
#define PI acos(-1)
#define sz(a) (int)a.size();
#define IOS ios::sync_with_stdio(false);
using namespace std;
int gcd(int a, int b) { if (a == 0) return b; return gcd(b % a, a);}
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const long long MOD = 1000000007;
double sq(double x) {return x*x;}
template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}

bool sortinrev(const pair<int,int> &a,
               const pair<int,int> &b)
{
       return (a.first > b.first);
}
signed main()
{
    IOS
    int n;
    while(cin>>n){
        map<string,int>mm;
        for(int i=0;i<n;i++){
            string s;
            cin>>s;
            mm[s]++;
        }
        cout << "AC x "<< mm["AC"]<<endl;
        cout << "WA x "<< mm["WA"]<<endl;
        cout << "TLE x "<< mm["TLE"]<<endl;
        cout << "RE x "<< mm["RE"]<<endl;
    }
    return 0;
}
///Alhamdulillah


Measured memory_bytes: 3664
$week=gets.to_i
n=i=0.to_i
 def myloop(n,i)
        if i==$week
                return n
        else
                n+=n*0.05
                j=(n % 1000).to_i
                n+=1000-j if j!= 0
                myloop(n,i+1)
        end
 end
money=myloop(100000,0).to_i
print money,"\n"

Measured memory_bytes: 6112
import numpy as np
from sys import maxsize

n = int(input())
a = np.array(list(map(int, input().split())))

cumsum = np.cumsum(a)
res = maxsize
for i in range(n-1):
    val = abs(cumsum[i] - (cumsum[-1] - cumsum[i]))
    if val < res:
        res = val

print(res)


Measured memory_bytes: 33052
#include <iostream>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <random>
#include <string>
#include <bitset>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <cstring>
#include <cstdlib>
#include <cctype>

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999

using namespace std;

typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

llong pow(int x, int n){
    llong ans = x;
    if (n == 0) return 1;

    for(int i = 0; i < n - 1; i++) {
        ans *= x;
    }

    return ans;
}

template <typename T> struct BIT { // 1-indexed
private:
    vector<T> array;
    const int n;

public:
    // 初期化
    BIT(int _n) : array(_n + 1, 0), n(_n) {}

    // 1番目からi番目までの累積和を求める
    T sum(int i) {
        T s = 0;
        while(i > 0) {
            s += array[i];
            i -= i & -i; // LSB減算
        }

        return s;
    }

    // [i, j]の要素の総和
    T sum(int i, int j) {
        T ret_i = sum(i - 1);
        T ret_j = sum(j);

        return ret_j - ret_i;
    }

    // i番目に要素xを追加
    void add(int i, T x) {
        while (i <= n) {
            array[i] += x;
            i += i & -i; // LSB加算
        }
    }
};

template <typename T> struct BIT2 { // 1-indexed
private:
    vector<vector<T> > array;
    const int n;
    const int m;

public:
    // 初期化
    BIT2(int _n, int _m) : array(_n + 1, vector<T>(_m + 1, 0)), n(_n), m(_m) {}

    // (1, 1)から(x, y)までの累積和を求める
    T sum(int x, int y) {
        T s = 0;
        for (int i = x; i > 0; i -= i & (-i)) {
            for (int j = y; j > 0; j -= j & (-j)) {
                s += array[i][j];
            }
        }

        return s;
    }

    // [(x1, y1), (x2, y2)]の要素の総和
    T sum(int x1, int y1, int x2, int y2) {
        return sum(x2, y2) - sum(x1 - 1, y2) - sum(x2, y1 - 1) + sum(x1 - 1, y1 - 1);
    }

    // (x, y)に要素kを追加
    void add(int x, int y, T k) {
        for (int i = x; i <= n; i += i & (-i)) {
            for (int j = y; j <= m; j += j & (-j)) {
                array[i][j] += k;
            }
        }
    }
};

void swap(int *X, int *Y){
    int t = *X; *X = *Y; *Y = t;
}

string toUpper(string s) {
    string t = s;
    REP(i, s.size()) {
        t[i] = toupper(s[i]);
    }
    return t;
}

string toLower(string s) {
    string t = s;
    REP(i, s.size()) {
        t[i] = tolower(s[i]);
    }
    return t;
}

int main() {
    llong n ,k, ans;
    cin >> n >> k;

    if (k % 2) {
        ans = pow(n / k, 3);
        cout << ans << endl;
    } else {
        ans = pow(n / k, 3) + pow((n + k / 2) / k, 3);
        cout << ans << endl;
    }

    return 0;
}

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

using namespace std;

int main() {

	int n;
	cin >> n;

	vector<int> a(110);

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

	sort(a.begin(), a.end());
	reverse(a.begin(), a.end());

	int b = 1;

	for (int i = 1; i < n; i++) {
		if (a.at(i - 1) > a.at(i)) {
			b++;
		}
	}

	cout << b << endl;

	return 0;

}


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

int main(void){
  int n, m, a, b, i, j;
  scanf("%d%d%d%d", &n, &m, &a, &b);
  int d[n];
  std::stack<int> s;
  for(i = 0; i < n; ++i) {
    scanf("%d", &d[i]);
    if(d[i] >= a) s.push(d[i]);
    else break;
  }
  if(n - s.size() < m) while(s.size()) {
    int p = s.top();
    if(p <= b) {
      s.pop();
    } else break;
  }
  printf("%d\n", s.size());
  return 0;
}


Measured memory_bytes: 2764
import java.util.Scanner

object Main extends App{
  val sc = new Scanner(System.in)

  val n = sc.nextInt
  val l = sc.nextInt

  val tastes = (0 until n ).map(l + _)
  val eaten = tastes.map(t => (Math.abs(t),t)).min
  val res = tastes.sum - eaten._2
  println(res)

}


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

typedef long long lint;
typedef pair<int, int> pii;

const int INF = 2e9;
const int MOD = 1e9+7;
const int MAX = 1e5+10;
const lint LNF = 2e18;

int n, m, ans, P[16];
vector<int> R[MAX];
bool on[MAX];

bool check(){
	bool la[16]={};
	for(int i=1; i<=n; i++){
		if(!on[i]) continue;
		for(int x:R[i]) la[x]=!la[x];
	}
	for(int i=1; i<=m; i++) if(la[i]!=P[i]) return false;
	return true;
}

void solve(int i){
	if(i==n+1){ ans+=check(); return; }
	solve(i+1);
	on[i]=true;
	solve(i+1);
	on[i]=false;
}

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

	cin>>n>>m;
	for(int i=1; i<=m; i++){
		int k; cin>>k;
		for(int j=1; j<=k; j++){
			int x; cin>>x; R[x].push_back(i);
		}
	}
	for(int i=1; i<=m; i++) cin>>P[i];

	solve(1);
	cout<<ans;

	return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
ll k;
int n;
bool check(ll mid,vector<ll> a, vector<ll> b){
	ll sum=0;
	for(int i=0;i<n;i++){
		sum += max(a[i] - mid/b[i],0ll);
	}
	if(sum > k ) return 0;
	else return 1;
}
int main(){
	cout << fixed << setprecision(10);
	cin >> n >> k;
	vector<ll> a(n),f(n);
	rep(i,n) cin >> a[i];
	rep(i,n) cin >> f[i];
	sort(a.begin(),a.end());
	sort(f.begin(),f.end());
	reverse(f.begin(),f.end());
	ll left = 0, right = (ll)1e13;
	ll mid;
	ll cnt = 0;
	while(cnt < 100){
		mid = (left+right)/2;
		if(check(mid,a,f)){
			right = mid;
		}
		else{
			left = mid;
		}
		cnt++;
	}
	cout << right << endl;
	return 0;
}

Measured memory_bytes: 6552
#define _USE_MATH_DEFINES
 
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>

using namespace std;

int main(){
	int data[101]={0};
	int max = 0;

	int d;
	while(cin >> d){
		data[d]++;
		if(data[d]>max){
			max=data[d];
		}
	}

	for(int i=1;i<101;i++){
		if(data[i]==max){
			cout << i << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1160
using System;

class Program {
  static void Main(string[] args) {
    string[] str = Console.ReadLine().Split();
    long a = long.Parse(str[0]);
    long b = long.Parse(str[1]);
    long x = long.Parse(str[2]);
    long rep = b / x - ((a > 0) ? (a - 1) / x : (-1));
    
    Console.WriteLine(rep);
  }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define per(i,a,b) for(int i=a;i>=b;--i)
#define repd(i,a,b) for(int i=a;i>=b;--i)
#define rvc(i,S) for(int i=0;i<(int)S.size();++i)
#define fore(i,x) for(int i = head[x] ; i ; i = e[i].next)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ll long long
#define PII pair<int,int>
#define debug(...) fprintf(stderr, __VA_ARGS__)
using namespace std;
const int maxn=100005;

int n,m;
char a[1005][1005];
int step[1005][1005];
bool vis[1005][1005];
int dire[4][2]={{1,0},{-1,0},{0,1},{0,-1}};
queue<PII> Q;
bool is_ok(int x,int y)
{  if(x<=n&&x>=1&&y<=m&&y>=1) return 1;
	return 0;
}
void bfs()
{ rep(i,1,n) rep(j,1,m) if(a[i][j]=='#')   
   {Q.push(mp(i,j));step[i][j]=0; vis[i][j]=1; }
  
  while(!Q.empty())
  	 { PII now=Q.front(); Q.pop();
        rep(i,0,3)
         { int tx=now.fi+dire[i][0],ty=now.se+dire[i][1];
           if(is_ok(tx,ty)&&(!vis[tx][ty]))
             { vis[tx][ty]=1;
               step[tx][ty]=step[now.fi][now.se]+1;
               Q.push(mp(tx,ty)); 
             } 
         }
  	 }
}
int main()
{ cin>>n>>m;
  rep(i,1,n)
   {  scanf("%s",a[i]+1);
   }
  bfs();
  int cmax=0;
  rep(i,1,n)
  rep(j,1,m)
  cmax=max(cmax,step[i][j]);

  cout<<cmax<<endl;
return 0;
}

Measured memory_bytes: 14352
#include<bits/stdc++.h>
using namespace std;
#define ll long long
namespace io{
	const int l=1<<20;
	char buf[l],*s,*t;
	inline char gc(){
		if(s==t){
			t=(s=buf)+fread(buf,1,l,stdin);
			return s==t?EOF:*s++;
		}
		return *s++;
	}
	char c;
	template<class IT>inline void gi(IT &x){
		x=0;c=gc();while(c<'0'||c>'9')c=gc();
		while('0'<=c&&c<='9'){x=(x<<1)+(x<<3)+(c^'0');c=gc();}
	}
};
using io::gi;
template<class IT>inline void cmin(IT &a,IT b){if(b<a)a=b;}
template<class IT>inline void cmax(IT &a,IT b){if(a<b)a=b;}
const ll p=998244353ll,inf=1000000000000000000ll;
const int N=200005;

int main(){
	int n;double a,s=0.0;
	scanf("%d",&n);
	while(n--){scanf("%lf",&a);s+=1.0/a;}
	printf("%lf",1.0/s);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;

int main(){
	int n, y;
	scanf("%d%d", &n, &y);
	for(int i = 0; i <= n; i++) {
		for(int j = 0; j <= n; j++) {
			int th = n - i - j;
			if(th < 0) continue;
			int money = 10000 * i + 5000 * j + 1000 * th;
			if(money == y) {
				printf("%d %d %d\n", i, j, th);
				return 0;
			}
		}
	}
	printf("-1 -1 -1\n");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int x[100];
int main() {
  int n; cin >> n;
  for (auto i = 0; i < n; i++) {
    cin >> x[i];
  }
  int res = INT_MAX;
  for (auto i = 1; i <= 100; i++) {
    int sum = 0;
    for (auto j = 0; j < n; j++) {
	    sum += (i - x[j]) * (i - x[j]);
    }
    res = min(res, sum);
  }
  printf("%d\n", res);
}
  

Measured memory_bytes: 256
import sys
import math

lines = sys.stdin.readlines()

x = lines[0].split(' ')
A =int(x[0])
B =int(x[1])
C =int(x[2])
D =int(x[3])

a = math.ceil(C/B)
b = math.ceil(A/D)

if a <= b:
    ans ='Yes'
else:
    ans ='No'

print(ans)


Measured memory_bytes: 9176
#include <iostream>
#include <algorithm>

using namespace std;

int main(int argc, char const *argv[])
{
    long long N[3];
    cin >> N[0] >> N[1] >> N[2];

    if (N[0] % 2 == 0 || N[1] % 2 == 0 || N[2] % 2 == 0)
    {
        cout << 0 << endl;
    }else
    {
        sort(N, N + 3);
        cout << N[0] * N[1] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fine cout<<"fine"<<endl;
#define ll long long int
#define pb push_back
#define FASTIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
const ll inf=(ll)2e18;
const int mod=1e9+7;
bool overflow(ll a,ll b){
    if (a <= (inf+b-1)/b) return false;
    return true;
}
vector<vector<int> > v(200005);
int main(){
FASTIO;
int n,i;
cin>>n;
int a[n];
for(i=0;i<n;i++){
    cin>>a[i];
    v[a[i]].pb(i);
}
i=1;
int x=-1;
while(1){
    auto it=lower_bound(all(v[i]),x);
    if(it==v[i].end())
        break;
    x=*it;
    i++;
}
if(i>1)
    cout<<n-i+1<<endl;
else cout<<-1<<endl;
}


Measured memory_bytes: 12032
# cf16-exhibition-final-openC - Cheating Nim
from functools import reduce
from operator import xor


def main():
    # player is second move -> make xor 0
    N, *A = map(int, open(0))
    # A.sort(reverse=1)
    X, changeable, cand = reduce(xor, A), {x ^ (x - 1) for x in A}, []
    while X:
        i = (1 << X.bit_length()) - 1
        cand.append(i)
        X ^= i
    ans = 0
    for i in cand:
        if i in changeable:
            ans += 1
        else:
            print(-1)
            return
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 7560
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

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

int a,b,c,p,q,r,s;

int main(){
	while(cin>>a>>b>>c&&a){
		int f=0;
		if(!c){p=a;q=b;r=1;s=0;f=1;}
		for(int i=1;i*i<=a;i++){
			if(a%i)continue;
			for(int j=1;j*j<=abs(c);j++){
				if(abs(c)%j)continue;
				if(c>0){
					if(i*c/j+a/i*j==b){p=i;q=j;r=a/i;s=c/j;f=1;break;}
					if(i*c/j+a/i*j==-b){p=i;q=-j;r=a/i;s=-c/j;f=1;break;}
					if(i*j+a/i*c/j==b){p=i;q=c/j;r=a/i;s=j;f=1;break;}
					if(i*j+a/i*c/j==-b){p=i;q=-c/j;r=a/i;s=-j;f=1;break;}
				}
				else{
					if(i*-c/j-a/i*j==b){p=i;q=-j;r=a/i;s=-c/j;f=1;break;}
					if(i*-c/j-a/i*j==-b){p=i;q=j;r=a/i;s=c/j;f=1;break;}
					if(i*j-a/i*-c/j==b){p=i;q=c/j;r=a/i;s=j;f=1;break;}
					if(i*j-a/i*-c/j==-b){p=i;q=-c/j;r=a/i;s=-j;f=1;break;}
				}
			}
		}
		if(!f)cout<<"Impossible"<<endl;
		else{
			if(p<r){swap(p,r);swap(q,s);}
			if(p==r&&q<s)swap(q,s);
			cout<<p<<" "<<q<<" "<<r<<" "<<s<<endl;
		}
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <stack>
#include <map>
#include <sstream>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
using namespace std;

int main(){
    int a, b, c, rec = 0, loz = 0;
    while (scanf("%d,%d,%d", &a, &b, &c) != EOF){
        if (a == b) loz++;
        else if (c*c == a*a + b*b) rec++;
    }
    cout << rec << endl << loz << endl;
}


Measured memory_bytes: 3008
//#pragma GCC optimize(2)
//#pragma GCC optimize(3)
#include <bits/stdc++.h>
#define N 100005
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<22,stdin),p1 == p2)?EOF:*p1++)
using namespace std ;
//char buf[(1 << 22)] , *p1 = buf , *p2 = buf ;
inline int read ()
{
    char c = getchar () ; int x = 0 , f = 1 ;
    while (c < '0' || c > '9') { if (c == '-') f = -1 ; c = getchar () ; }
    while (c >= '0' && c <= '9'){ x = x * 10 + c - '0' ; c = getchar () ; }
    return x * f ;
}

int n , a[N] , l , q , f[N][33] , ans ;
int main ()
{
//    freopen (".in" , "r" , stdin) ; freopen (".out" , "w" , stdout) ;
	n = read () ;
	for (int i = 1 ; i <= n ; i ++) a[i] = read () ;
	l = read () ; q = read () ;
	for (int i = 1 ; i <= n ; i ++)
	{
		f[i][0] = upper_bound (a + 1 , a + n + 1 , a[i] + l) - a - 1 ;
	}
	for (int j = 1 ; j <= 30 ; j ++)
		for (int i = 1 ; i <= n ; i ++)
			f[i][j] = f[f[i][j - 1]][j - 1] ;
	while (q --> 0)
	{
		int x = read () , y = read () ;
		if (x > y) swap (x , y) ;
		int tmp = x ;
		for (int i = 30 ; i >= 0 ; i --)
		{
			if (f[tmp][i] < y)
			{
				ans += (1 << i) ;
				tmp = f[tmp][i] ;
			}
		}
		cout << ans + 1 << "\n" ;
		ans = 0 ;
	}
}




Measured memory_bytes: 14080
#include <bits/stdc++.h>  // clang-format off
using Int = long long;
#define REP_(i, a_, b_, a, b, ...) for (Int i = (a), lim##i = (b); i < lim##i; i++)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
struct SetupIO { SetupIO() { std::cin.tie(nullptr), std::ios::sync_with_stdio(false), std::cout << std::fixed << std::setprecision(13); } } setup_io;
#ifndef dump
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Sun May 17 21:40:36 JST 2020
 **/

signed main() {
    double a, b, H, M;
    std::cin >> a >> b >> H >> M;
    double r = 2 * M_PI * std::abs(H / 12 + M / 60 / 12 - M / 60);
    std::cout << sqrt(a * a + b * b - 2 * a * b * cos(r)) << std::endl;
}


Measured memory_bytes: 4240
import java.util.Scanner;

public class Main {

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

		String s = sc.next();

		for (int i = s.length() - 1; i > 0; i--) {
			int l = s.substring(0, i).length();
			if (l % 2 == 1) {
				continue;
			}
			if (s.substring(0, l / 2).equals(s.substring(l / 2, l))) {
				System.out.println(l);
				break;
			}
		}

		sc.close();
	}

}


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

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

    int K, X;
    cin >> K >> X;
    for (int i = (X - K + 1); i < (X + K - 1); i++) {
        cout << i << " ";
    }
    cout << X + K - 1 << endl;
}

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

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  return std::accumulate(first, last, typename InputIterator::value_type());
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  int64_t h, w;
  std::cin >> h >> w;
  std::vector<std::vector<char>> s(h, std::vector<char>(w));

  for (int64_t i = 0; i < h; i++) {
    for (int64_t j = 0; j < w; j++) {
      char c;
      std::cin >> c;
      s[i][j] = c;
    }
  }

  int64_t ans = 0;
  for (int64_t i = 0; i < h; i++) {
    for (int64_t j = 0; j < w; j++) {
      if (s[i][j] == '#') {
        continue;
      }
      std::vector<std::vector<int64_t>> d(h, std::vector<int64_t>(w, h * w));
      std::queue<std::pair<int64_t, int64_t>> q;

      d[i][j] = 0;
      if (i + 1 < h && s[i + 1][j] == '.' && d[i + 1][j] == h * w) {
        q.push(std::make_pair(i + 1, j));
        d[i + 1][j] = std::min(d[i + 1][j], d[i][j] + 1);
      }
      if (0 <= i - 1 && s[i - 1][j] == '.' && d[i - 1][j] == h * w) {
        q.push(std::make_pair(i - 1, j));
        d[i - 1][j] = std::min(d[i - 1][j], d[i][j] + 1);
      }
      if (j + 1 < w && s[i][j + 1] == '.' && d[i][j + 1] == h * w) {
        q.push(std::make_pair(i, j + 1));
        d[i][j + 1] = std::min(d[i][j + 1], d[i][j] + 1);
      }
      if (0 <= j - 1 && s[i][j - 1] == '.' && d[i][j - 1] == h * w) {
        q.push(std::make_pair(i, j - 1));
        d[i][j - 1] = std::min(d[i][j - 1], d[i][j] + 1);
      }

      while (!q.empty()) {
        const auto data = q.front();
        const auto i = data.first;
        const auto j = data.second;
        q.pop();
        ans = std::max(ans, d[i][j]);
        if (i + 1 < h && s[i + 1][j] == '.' && d[i + 1][j] == h * w) {
          q.push(std::make_pair(i + 1, j));
          d[i + 1][j] = std::min(d[i + 1][j], d[i][j] + 1);
        }
        if (0 <= i - 1 && s[i - 1][j] == '.' && d[i - 1][j] == h * w) {
          q.push(std::make_pair(i - 1, j));
          d[i - 1][j] = std::min(d[i - 1][j], d[i][j] + 1);
        }
        if (j + 1 < w && s[i][j + 1] == '.' && d[i][j + 1] == h * w) {
          q.push(std::make_pair(i, j + 1));
          d[i][j + 1] = std::min(d[i][j + 1], d[i][j] + 1);
        }
        if (0 <= j - 1 && s[i][j - 1] == '.' && d[i][j - 1] == h * w) {
          q.push(std::make_pair(i, j - 1));
          d[i][j - 1] = std::min(d[i][j - 1], d[i][j] + 1);
        }
      }
    }
  }

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


Measured memory_bytes: 256
N = int(input())
ary = [[int(i) for i in input().split()] for _ in range(N)]

dp = [[0, 0, 0] for i in range(N)]
dp[0][0] = ary[0][0]
dp[0][1] = ary[0][1]
dp[0][2] = ary[0][2]

for i in range(1, N):
    for j in range(3):
        a = dp[i-1][(j+1) % 3]
        b = dp[i-1][(j+2) % 3]
        dp[i][j] = a+ary[i][j] if a > b else b + ary[i][j]

print(max(dp[N-1]))


Measured memory_bytes: 76504
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

#define SENTINEL 1000000000000000000

void merge(long long A[], long long left, long long mid, long long right){
  long long n1, n2, i, j, k;
  long long *L,*R;
  
  n1 = mid-left;
  n2 = right-mid;
  
  L = (long long*)malloc(sizeof(long long) *(n1 + 1));
  R = (long long*)malloc(sizeof(long long) *(n2 + 1));
  
  for(i = 0; i <= n1 - 1; i++){
    L[i] = A[left + i];
  }
  for(j = 0; j <= n2 - 1; j++){
    R[j] = A[mid + j];
  }
  
  L[n1] = SENTINEL;
  R[n2] = SENTINEL;
  
  i = 0;
  j = 0;
  
  for(k = left; k <= right - 1; k++){
   if(L[i] <= R[j]){
      A[k] = L[i];
      i++;
    }
    else{
      A[k] = R[j];
      j++;
    }
  }
  free(L);
  free(R);
}

void mergeSort(long long A[], long long left, long long right){
  long long mid;
  
  if(left + 1 < right){
    mid=(left + right)/2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}

int main(void){

    int N;

    scanf("%d", &N);

    long long d[N];

    for(int i = 0; i < N; i++){
        scanf("%lld", &d[i]);
    }

    mergeSort(d, 0, N);

    int ans = 1;

    for(int i = 1; i < N; i++){
        if(d[i] != d[i-1]){
            ans++;
        }
    }

    printf("%d\n", ans);

    return 0;
}

Measured memory_bytes: 1684
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
    double n;
    cin>>n;
    cout<<2.0*n*M_PI<<"\n";
}


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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int n, m, k;
string s[8];

int count(int m1, int m2) {
    int res = 0;
    rep(i, 0, n) {
        rep(j, 0, m) {
            res += (s[i][j] == '#') && !(m1 >> i & 1) && !(m2 >> j & 1);
        }
    }
    return res;
}

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

    cin >> n >> m >> k;
    rep(i, 0, n) cin >> s[i];
    int res = 0;
    rep(i, 0, 1 << n) {
        rep(j, 0, 1 << m) {
            if(count(i, j) == k) res++;
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 3608
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int n, y, max1, max2, a, b, c, maxid1, maxid2; double w1, w2;
int main() {
	while (true) {
		cin >> n;
		if (!n) { break; }
		max1 = 0; max2 = 0;
		cin >> y;
		for (int i = 0; i < n; i++) {
			cin >> a >> b >> c;
			if (c == 1 && max1 < b) {
				max1 = b; maxid1 = a;
			}
			if (c == 2 && max2 < b) {
				max2 = b; maxid2 = a;
			}
		}
		w1 = 1 + (1.0*(double)max1 / 100)*y;
		w2 = pow(1.0 + (double)max2 / 100, y);
		if (w1 > w2) { cout << maxid1 << endl; }
		else { cout << maxid2 << endl; }
	}
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define lb lower_bound
#define ub upper_bound
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
const ll LINF = (ll)(1e18 +99);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}


signed main(){
  cin.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  ll h,w,a,b,sum;cin>>h>>w>>a>>b;
  ll bac=mod-7;
  bac/=(a*b);

  sum=h*w*bac;
  VV<ll> v(h,V<ll>(w,bac));
  for (int i =a-1; i < h; i+=a)
  {
    for (int j = b-1; j < w; j+=b)
    {
        v[i][j]=-(a*b-1)*bac-1;
        sum+=v[i][j]-bac;
    }
  }

  if(sum>0){
    cout<<"Yes"<<ENDL;
    rep(i,0,h){
      rep(j,0,w){
        assert(abs(v[i][j]<=mod-7));
        cout<<v[i][j]<<' ';
      }
      cout<<ENDL;
    }
  }else{
    cout<<"No"<<ENDL;
  }
  

}
//( ・ __ ・ ) KEEP BEING ORGANIZED
//CHECK overflow,vector_size,what to output?

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

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

    if (n % 111 == 0) cout << n << endl;
    else cout << (n / 111 + 1) * 111 << endl;


    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.util.Map.Entry;
 
 
 class Main {
	 static int mod =  (int) (Math.pow(10,9)+7);
	 static List<ArrayList<Integer>>  list = new ArrayList<ArrayList<Integer>>();
    public static void main(String[] args) {
    
        Scanner sc = new Scanner(System.in);
    	String S = sc.next();
    	char[] c = S.toCharArray();
    	int[] m=new int[c.length];
    	for(int i=0;i<c.length;i++) {
    		m[i]=c[i]-'a';
    	}
    	int K = sc.nextInt();
    	for(int i=0;i<c.length-1;i++) {
    		if(m[i]!=0) {
    			if(26-m[i]<=K) {
    				K=K-26+m[i];
    				c[i]='a';
    			}
    		}
    	}
    	m[c.length-1]=(m[c.length-1]+K)%26;
    	StringBuffer ans = new StringBuffer();
    	for(int i=0;i<c.length-1;i++) {
    		ans.append(c[i]);
    	}
    	ans.append((char)(m[c.length-1]+'a'));
        System.out.println(ans);
        
        		
    }
}

Measured memory_bytes: 27040
N, M = map(int, input().split())

l = 1
r = N
for i in range(M):
    li, ri = map(int, input().split())
    l = max(l, li)
    r = min(r, ri)

ans = r - l + 1

if ans < 0:
    print(0)
else:
    print(ans)

Measured memory_bytes: 3060
h,w=map(int,input().split())
a=[list(input()) for _ in range(h)]
ans=[i for i in a if '#' in i]
s=[]
for i in range(w):
	t=0
	for j in a:
		t+=(j[i]=='#')
	if t==0:
		s+=[i]
for i in s[::-1]:
	for j in ans:
		del j[i]
for i in ans:
	print(''.join(i))

Measured memory_bytes: 65424
#include <bits/stdc++.h>
#define int long long
#define double long double
const int INF = (int) 1e9 + 9;
const int maxn = (int) 1e6 + 6;
//const mod = (int) 1e9 + 7;
using namespace std;

signed main() {
      int h, n;
      cin >> h >> n;

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

      if(sum >= h) cout << "Yes";
      else cout << "No";





return 0;

}

Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS
#include <vector>
#include <iostream>
#include <string.h>
#include <set>
#include <algorithm>
#include <cmath>
#include <queue>
using namespace std;

typedef double LD;
typedef long long LL;
typedef pair<int, int> PII;
#define MP make_pair
#define PB push_back
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, t) FOR(i,0,t)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())

const LL MOD = 1000000007;
const int INF = 1e9;
const LL LINF = 1LL * INF * INF;
const int MAXN = 100007;
const LD EPS = 1e-7;

int A[MAXN];
bool OK[MAXN];

int main()
{
	ios_base::sync_with_stdio(0);
	//freopen("In.txt", "r", stdin);
	int n, ans = 0;
	cin >> n;
	REP(i, n)
		cin >> A[i];
	sort(A, A + n);
	OK[n - 1] = true;
	LL s = 0;
	REP(i, n - 1)
	{
		s += A[i];
		OK[i] = (2 * s >= A[i + 1]);
	}
	REP(i, n)
	{
		if (OK[i])
			++ans;
		else
			ans = 0;
	}
	cout << ans;
	//cout << endl; system("pause");
	return 0;
}

Measured memory_bytes: 768
n,m=map(int,input().split())

def func(n):
    num = 1
    if n == 0:
        return 0
    else:
        for i in range(1,n+1):
            num = num*i
        return num
def func1(n):
    if n < 1:
        return 0
    elif n == 2:
        return 1
    else:
        return int(func(n)/(2*func(n-2)))

print(func1(n)+func1(m))

Measured memory_bytes: 3060
public class Main {

	public static void main(String[] args) {
		String input = new java.util.Scanner(System.in).nextLine(); 
		String[] input2 = input.split(" ");
		int a = Integer.parseInt(input2[0]);
		int b = Integer.parseInt(input2[1]);
		int c = Integer.parseInt(input2[2]);
		if(a < b && b < c)
		{
			System.out.println("Yes");
		}
		else
		{
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 17120
#include <bits/stdc++.h>
#define ll long long
#define vi vector <ll>
#define ii pair<ll,ll>
#define vii vector<ii>
#define F first
#define S second
#define INF 1000000000

using namespace std;

bool aux(ii a,ii b) {return a.first > b.first;}

int N;
vector<vi> dp;
vector<ii> elementos;
vector<int> tomados(105,0);
ll knp(int id,ll cap){
	if(id == N || cap <= 0) return 0;
	if(dp[id][cap] != -INF) return dp[id][cap];
	if(elementos[id].F > cap){
		dp[id][cap] = knp(id+1,cap);
	}
	else{
		dp[id][cap] = max(knp(id+1,cap),elementos[id].S+knp(id+1,cap-elementos[id].F));
	}
	return dp[id][cap];
}

int main() {
	ll W;
	cin >> N >> W;
	vi empty(100005,-INF);
    dp.assign(N+1,empty);
    ll p,v;
    for (int i = 0; i < N; ++i){
    	cin >> p >> v;
    	elementos.push_back({p,v});	
    }
    cout << knp(0,W) << endl;
   return 0;
}

Measured memory_bytes: 80256
A=int(input())
B=int(input())
C=int(input())
X=int(input())
x=X/50
def bcpair(y):
    count=0
    for b in range(B+1):
        if y-(2*b)>=0 and y-(2*b)<=C:
            count+=1
    return(count)
result=0
a=0
while a<=A and x-(10*a)>=0:
    result+=bcpair(x-(10*a))
    a+=1
print(result)

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

using namespace std;

#define int long long
#define all(v) begin(v), end(v)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using pint = pair<int, int>;
using tint = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int N, M, a[1<<8];
  cin >> N >> M;
  rep(i, M) cin >> a[i];
  cout << N-M-1 << endl;

  return 0;
}

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

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

#define roop(i, n) for(int i = 0;i < n;i++)

int main(void){

    int n;
    cin >> n;
    printf("%.20lf", 2*n*acos(-1));

    return 0;
}


Measured memory_bytes: 3792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	int h, w, k;
	cin >> h >> w >> k;
	char arr[h + 1][w + 1];
	for(int i = 1;i <= h;i++)
	{
		for(int j = 1;j <= w;j++)
		{
			cin >> arr[i][j];
		}
	}
	int cnt = 0;
	for(int c1 = 0;c1 < (1 << h);c1++)
	{
		for(int c2 = 0;c2 < (1 << w);c2++)
		{
			int c = 0;
			for(int i = 0;i < h;i++)
			{
				for(int j = 0;j < w;j++)
				{
					if((!(c1 & (1 << i))) && (!(c2 & (1 << j))))
					{
						if(arr[i + 1][j + 1] == '#')
							c++;
					}
				}
			}
			if(c == k)
				cnt++;
		}
	}
	cout << cnt;
	return 0;
}

Measured memory_bytes: 3644
#include <string.h>
#include <algorithm>
#include <bitset>
#include <iostream>
#include <sstream>
#include <vector>
using namespace std;
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>
inline string toString(const T &a) {
  ostringstream oss;
  oss << a;
  return oss.str();
};

typedef long long ll;

int main() {
  ll N;
  cin >> N;
  string S;
  cin >> S;

  ll ans = 0;
  for (ll i = 0; i < 10; i++) {
    for (ll j = 0; j < 10; j++) {
      for (ll k = 0; k < 10; k++) {
        string::size_type pos = S.find(i + '0');
        if (pos == string::npos) {
          continue;
        }
        pos = S.find(j + '0', pos + 1);
        if (pos == string::npos) {
          continue;
        }
        pos = S.find(k + '0', pos + 1);
        if (pos == string::npos) {
          continue;
        }
        ans++;
      }
    }
  }

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


Measured memory_bytes: 256
#include <iostream>
#include <math.h> 
#include <cmath>
using namespace std;

typedef long long ll;

// Euclid互除法の実装
// int euclid(int a, int b){
// 	int p,q,r;
// 	if(a >= b){
// 		p = a;
// 		q = b;
// 		r = a%b;
// 	}
// 	else{
// 		p = b;
// 		q = a;
// 		r = b%a;
// 	}

// 	while(1){
// 		p = q;
// 		q = r;
// 		r = p%q;

// 		if(r == 0) break;
// 	}
// 	return q;
// }

ll euclid(ll a, ll b){
	ll p,q,r;
	
	p = a;
	q = b;
	r = a%b;
	// cout << r <<endl;
	if(r == 0){
		return q;
	}
	else{
		while(1){
		p = q;
		q = r;
		r = p%q;

		if(r == 0) break;
	}
	return q;
	}
	
}



// int main(){
// 	cout << euclid(1,84)<< endl;
// 	cout << euclid(84,1) << endl;
// 	cout << euclid(72,84)<< endl;
// 	cout << euclid(84,72) << endl;
// }


//素数かどうか判定
bool IsPrime(ll num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    else if (num == 3) return true;
    else if (num % 3 == 0) return false; // 3の倍数はあらかじめ除く

    else if (num == 5) return true;
    else if (num % 5 == 0) return false; // 5の倍数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (ll i = 7; i <= (int)sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

// int main(){
// 	// for(int i = 1;i<= 50; i++){
// 	// 	cout << i<< " " << IsPrime(i) << endl;
// 	// }
// 	cout << IsPrime(101) << endl;

// }



// 約数に素数をいくつ含むか数える関数
ll num_prime(ll a){
	
	ll counter = 1;

	if(a==1){
		return 1;
	}

	else if(IsPrime(a)){
		return 2;
	}
	
	else{
		for(ll i = 2; i*i <= a; i++ ){
		if(a % i  == 0){

			if(IsPrime(i)){
				counter++;
			}
			if(IsPrime(a/i) && i != a/i){
				counter++;
			}

		}
	}

	return counter;

	}
	

}

// int main(int argc, char const *argv[])
// {
// 	double root_two = sqrt(2);
// 	double root_four = sqrt(4);
// 	cout << root_two <<" "<< (int)root_two << endl;
// 	cout << root_four <<" " << (int)root_four<<endl;
// 	// cout << IsPrime(67) << " "<< IsPrime(68); 
// 	cout << num_prime(13)<<endl; //2
// 	cout << num_prime(60)<<endl; //4


	
// }

// int main(){

// 	cout.precision(50);
// 	cout << pow(10,18) << endl; //1000000000000000000
// 	cout << pow(10,20) << endl; //100000000000000000000
// 	cout << (double)pow(10,40) << endl; //10000000000000000303786028427003666890752 ？？？　原因不明
// 	cout << (ll)pow(10,18) << endl; //1000000000000000000
// 	cout << (ll)pow(10,20) << endl; //-9223372036854775808 long long で扱えrう範囲外の数をキャストしたため
// 	cout << (ll)pow(10,40) << endl; //-9223372036854775808

// }

// int main(int argc, char const *argv[])
// {
// 	cout << num_prime(1)<< " " << num_prime(13)<< " " << num_prime(16) <<" " <<  num_prime(30) <<endl;

// 	// 1 2 2 4

	
// }


int main(){

	ll A, B;

	cin >> A >> B;

	ll gcd = euclid(A,B);

	cout << num_prime(gcd) << endl;


}

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

bool is_palindrome(string s, int l, int r) {
    while(r > l) {
        if(s[l++] != s[r--])
            return false;
    }
    return true;
}

int main() {
    string s;
    cin >> s;
    int len = s.size();
    int cond1 = ((len-1) / 2) - 1;
    int cond2 = ((len+3) / 2) - 1;
    if(is_palindrome(s, 0, len-1) && is_palindrome(s,0,cond1) && is_palindrome(s, cond2, len-1)) {
        cout << "Yes" << "\n";
    } else {
        cout << "No" << "\n";
    }
}

Measured memory_bytes: 256
require 'pp'
# IS_DEBUG = true
IS_DEBUG = false
def dputs str
	if(IS_DEBUG)
		puts str
	end
end
def dpp str
	if(IS_DEBUG)
		pp str
	end
end

require 'pp'

INT_MAX = 999999999999999999999999

N,C=gets.chomp.split(' ').map{|n| n.to_i}
A = Array.new(N)
# already sorted
0.upto(N-1){|d|
	A[d]=gets.chomp.split(' ').map{|n| n.to_i}
	A[d]<<C-A[d][0]
}
proc_a = Array.new(N)
sum = 0
0.upto(N-1){|i|
	sum += A[i][1]
	sumai = sum-A[i][0]
	prevai = (i == 0 ? sumai : proc_a[i-1])
	if(prevai < sumai)
		proc_a[i] = sumai
	else
		proc_a[i] = prevai
	end
}
dpp proc_a

proc_b = Array.new(N)
sum = 0
0.upto(N-1){|i|
	sum += A[N-1-i][1]
	sumbi = sum-A[N-1-i][2]
	prevbi = (i == 0 ? sumbi : proc_b[i-1])
	if(prevbi < sumbi)
		proc_b[i] = sumbi
	else
		proc_b[i] = prevbi
	end
}
dpp proc_b

def max(a,b,c)
	if(a > b)
		if(a > c)
			return a
		else
			return c
		end
	else
		if(b > c)
			return b
		else
			return c
		end
	end
end

# go to b and back to a
max = 0
max = max(proc_b[N-1],max,max)
dputs "only b, #{proc_b[N-1]}"
0.upto(N-2){|i|
	b = proc_b[i]
	a = proc_a[N-1-i-1]
	max = max(max, b - A[N-1-i][2] + a, b)
	dputs "b and a, #{i}, #{b - A[N-1-i][2] + a}, #{b}"
	dputs "max is #{max}"
}
# go to a and back to b
max = max(max, proc_a[N-1], max)
dputs "only a, #{proc_a[N-1]}"
0.upto(N-2){|i|
	a = proc_a[i]
	b = proc_b[N-1-i-1]
	max = max(max, a - A[i][0] + b, a)
	dputs "a and b, #{i}, #{a - A[N-1-i][0] + b}, #{a}"
	dputs "max is #{max}"
}
puts max


Measured memory_bytes: 13948
#include <cstdio>

#define Int register int

const int MAXN = 2000;
int n, m, F[MAXN * 3 + 5][MAXN * 6 + 5];
bool Vis[MAXN * 3 + 5][MAXN * 6 + 5];

inline int DFS ( const int s, const int d ) {
	if ( ! s ) return d >= 0 && ! ( d % 3 );
	if ( Vis[s][d + 3 * n] ) return F[s][d + 3 * n];
	if ( d + s < 0 ) return 0;
	int ret = DFS ( s - 1, d + 1 );
	if ( s > 1 ) ret = ( ret + ( s - 1LL ) * DFS ( s - 2, d - 1 ) ) % m;
	if ( s > 2 ) ret = ( ret + ( s - 1LL ) * ( s - 2LL ) * DFS ( s - 3, d ) ) % m;
	return Vis[s][d + 3 * n] = true, F[s][d + 3 * n] = ret;
}

inline void Work () {
	scanf ( "%d %d", &n, &m );
	printf ( "%d\n", DFS ( 3 * n, 0 ) );
}

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

Measured memory_bytes: 350336