akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int main()
{
	int d;
	cin >> d;
	if (d == 25)
		cout << "Christmas";
	else if (d == 24)
		cout << "Christmas Eve";
	else if (d == 23)
		cout << "Christmas Eve Eve";
	else if (d == 22)
		cout << "Christmas Eve Eve Eve";
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;


int main(int argc, char** argv) {
    int a, b, c, d, e, k;
    cin >> a >> b >> c >> d >> e >> k;

    bool ans{true};
    if (e-a > k) ans = false;
    cout << (ans ? "Yay!": ":(") << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll n,m;
  cin >> n >> m;
  ll ans=0;
  rep(i,n) {
    ll x;
    R x;
    if(x>=m) ans++;
  }

  pr(ans);
}

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


Measured memory_bytes: 764
input = require('fs').readFileSync('/dev/stdin', 'utf8')  
lines = input.split('\n')
N = lines.shift() * 1
arr = lines.map((a) => a * 1)
arr.sort((a,b) => b - a)
for (i=0; i<N; i++) {
    console.log(lines[i] == arr[0] ? arr[1] : arr[0])
}

Measured memory_bytes: 37936
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL)
#define MOD 1000000007
ll bigpow(ll base,ll pw,ll M)
{
	if(pw==0) return 1;
	if(pw%2==0)
	{
		ll ret=bigpow(base,pw/2,M);
		return ((ret%M)*(ret%M))%M;
	}
	else return ((base%M)*(bigpow(base,pw-1,M)))%M;

}
ll maxi(ll a,ll b)
{
    if(a>b)return a;
    return b;
}
ll mini(ll a,ll b)
{
    if(a<b)return a;
    return b;
}
ll abse(ll a)
{
    if(a<0)return -a;
    return a;
}
ll ceili(ll a,ll div)
{
    return (a+div-1)/div;
}
ll ara[405];
ll sum[405];
ll dp[405][405];
ll fsum(int i,int j)
{
    return sum[j+1]-sum[i];
}
ll f(int i,int j)
{
    if(i>=j) return 0;

    if(dp[i][j]!=-1) return dp[i][j];
    if(j-i==1) return dp[i][j]=ara[i]+ara[j];
    int k;
    ll ans=LLONG_MAX;
    for(k=i;k<j;k++)
    {
        ans=mini(ans,f(i,k)+f(k+1,j));
    }
    return dp[i][j]=ans+fsum(i,j);
}
int main(void)
{
    io;
    int T=1,cas=0;
    //cin>>T;
    while(T--)
    {
        int n,i,j;
        sum[0]=0;
         cin>>n;
         for(i=0;i<n;i++)
         {
             cin>>ara[i];
             sum[i+1]=sum[i]+ara[i];
         }
         memset(dp,-1,sizeof dp);
         cout<<f(0,n-1);

    }
}


Measured memory_bytes: 1536
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a;
		long n = sc.nextLong(), k = sc.nextLong(), b, sum = 0;
		long[] bucket = new long[100001];
		for (int i = 0; i < n; i++) {
			a = sc.nextInt();
			b = sc.nextLong();
			bucket[a] += b;
		}

		for (int i = 1; i <= 100000; i++) {
			sum += bucket[i];
			if (sum >= k) {
				System.out.println(i);
				return;
			}
		}
	}

}


Measured memory_bytes: 65468
//Card Game for Two

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

int main (){
    int N,a=0,b=0;
    cin >> N;
    vector<int> A(N);
    for(int i=0;i<N;i++){
        cin >> A.at(i);
    }
    sort(A.begin(), A.end(), greater<int>());
    for(int i =0;i<N;i++){
        if(i%2==0)a += A[i];
        else b += A[i];
    }
    cout << a-b << endl;
    return 0;
}

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

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

using namespace std;

int main(){
    int n;
    cin >> n;
    int s[100] = {0};

    rep(i,n){
        int a,v;
        cin >> a >> v;
        s[a] += v;
    }
    int ans=1;
    int sum=0;
    reep(i,1,n+1){
        if(sum<s[i]){
            ans = i;
            sum = s[i];
        }
    }

    printf("%d %d\n",ans, sum);
    return 0;
}

Measured memory_bytes: 1144
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int a = in.nextInt();
		int b = in.nextInt();
		int c = in.nextInt();
		int d[] = new int[100];
		int e;
		for(int i = 0; i < n; i++){
			d[i] = in.nextInt();
		}
		for(int i = 0; i < n; i++){
			for(int j = i + 1; j < n; j++){
				if(d[i] < d[j]){
					e = d[i];
					d[i] = d[j];
					d[j] = e;
				}
			}
		}
		for(int i = 0; i < n; i++){
			if(d[i] / b > c / a){
				c += d[i];
				a += b;
			}
		}
		System.out.println(c / a);
	}
}

Measured memory_bytes: 18264
#include<bits/stdc++.h>
#define endl enjoy_codeforces
int main(){
    int n;std::cin>>n;
    long long x=1,y=1;
    while(n--){
        long long a,b;std::cin>>a>>b;
        if(y<=(x+a-1)/a*b){
            y=(x+a-1)/a*b;
            x=(x+a-1)/a*a;
        }else{
            x=(y+b-1)/b*a;
            y=(y+b-1)/b*b;
        }
    }
    std::cout<<x+y<<'\n';
}


Measured memory_bytes: 256
fn func(input_str: &str) -> usize {
    let mut iter = input_str.split_whitespace();
    let n: usize = iter.next().unwrap().parse().unwrap();
    let m: usize = iter.next().unwrap().parse().unwrap();
    let mut cnt_s = vec![0_usize; m];
    for _ in 0..n {
        let k: usize = iter.next().unwrap().parse().unwrap();
        for _ in 0..k {
            let a: usize = iter.next().unwrap().parse().unwrap();
            cnt_s[a - 1] += 1;
        }
    }
    cnt_s.into_iter().filter(|&x| x == n).count()
}

use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    println!("{}", func(&buf[..]));
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int gcd(int x, int y) { return (x % y) ? gcd(y, x % y) : y; }
int main() {
  int n;
  cin >> n;
  int a, b;
  ll sum = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      for (int k = 1; k <= n; k++) {
        a == 0;
        a = gcd(i, j);
        b = gcd(a, k);
        sum = sum + b;
      }
    }
  }
  cout << sum;
}

Measured memory_bytes: 3628
#include <cstdio>
#include <algorithm>
using namespace std;

struct Node{
	int a,b;
}node[5];

bool cmp(Node p,Node q){
	return p.a<q.a;
}

int main(void){
	scanf("%d %d %d",&node[1].a,&node[2].a,&node[3].a);
	for(int i=1;i<=3;i++)node[i].b=i;
	sort(node+1,node+1+3,cmp);
	if(node[2].b==3)printf("Yes\n");
	else printf("No\n");
} 

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
 
using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
#define int ll
#define pb push_back
#define pii pair<int,int>
#define ff first
#define ss second
const ld pi = 3.1415926535;
typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;



signed main(){

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


	

	int r; cin>>r;
	cout<<(ld) 2* pi * (ld)r;

	

	return 0;
}

Measured memory_bytes: 3800
import bisect
import collections
import copy
import functools
import heapq
import math
import sys
from collections import deque
from collections import defaultdict
from fractions import Fraction
input = sys.stdin.readline
sys.setrecursionlimit(10**9)
INF = float("inf")
MOD = 10**9+7

N = int(input())
A = list(map(int,input().split()))
d = defaultdict(int)

if 0 in A:
    print(0)
    exit()

for i in range(N):
    d[A[i]] += 1

T = [0]
W = []
for k in d.keys():
    if d[k] > 2:
        print(0)
        exit()
    if d[k] == 2:
        T.append(k)
        T.append(24-k)
    else:
        W.append(k)
#print(T,W)

ans = []

w = len(W)
K = 2 # 選択肢の数
for i in range(K**w):
    TF=[0]*w

    for j in range(w):
        TF[w-j-1] = i % K
        i //= K
    
    l = copy.deepcopy(T)
    for j in range(w):
        if TF[j] == 1:
            l.append(24-W[j])
        else:
            l.append(W[j])
            
    l.sort()
    l.append(24)
    #print(l)
    m = 24
    for j in range(1,len(l)):
        m = min(m,l[j] - l[j-1])
    ans.append(m)

print(max(ans))

Measured memory_bytes: 79832
#include <iostream>
#include <bits/stdc++.h>
#define ll long long
#define max 1000000000000000000
using namespace std;

int main(){

    ll n,i,flag = 0;
    cin >> n;
    ll a[n],mul = 1;
    double m = 1;
    for(i=0;i<n;i++){
        cin >> a[i];
    if(a[i] == 0)
        flag = 1;
    }
    if(flag == 1)
        cout << "0" << endl;
    else{

        for(i=0;i<n;i++){
            mul *= a[i];
            m *= a[i];
            if(mul > max || m > max){
                cout << "-1" << endl;
                flag = 1;
                break;
            }
        }
        if(flag == 0)
            cout << (ll) mul << endl;
    }

 return 0;
}



Measured memory_bytes: 4408
#include <bits/stdc++.h>
using namespace std;
const int64_t INF=999999999;

int main() {
   int N;
   cin>>N;
   vector<int>L(N);
   int sum=0;
   for(int i=0;i<N;i++){
      cin>>L[i];
      sum+=L[i];
   }
   sort(L.begin(),L.end());
   if(L[L.size()-1]<sum-L[L.size()-1]){cout<<"Yes"<<endl;}
   else{cout<<"No"<<endl;}
return 0;}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define co(a) cout<<a<<endl
#define sz size()
#define bgn begin()
#define en end()
#define pb(a) push_back(a)
#define pop pop_back
#define V vector
#define P pair
#define V2(a,b,c) V<V<int>> a(b,V<int>(c))
#define V2a(a,b,c,d) V<V<int>> a(b,V<int>(c,d))
#define incin(a) int a; cin>>a
//#define min min<int>
//#define max max<int>
template<class T>
 void cou(vector<vector<T>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}
/*template<>
 void cou(vector<vector<char>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}*/
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
struct Union{
  vector<int> par;
  Union(int n){
	par= vector<int>(n, -1);
  }
  int find(int x){
    if(par[x]<0)
      return x;
    else
      return par[x]=find(par[x]);
  }
  bool same(int a,int b){
    return find(a)==find(b);
  }
  int Size(int a){
    return -par[find(a)];
  }
  void unite(int a,int b){
    a=find(a);
    b=find(b);
    if(a==b)
      return;
    if(Size(b)>Size(a))
      swap<int>(a,b);
    par[a]+=par[b];
    par[b]=a;
  }
};
int ketas(int a){
  string b=to_string(a);
  int c=0;
  fo(i,keta(a)){
    c+=b[i]-'0';
  }
  return c;
}
/*struct aa{
	vector<int> gt;
  aa(int n){
	gt= vector<int>(n, 1);
  }
	void c(V<int> d,int b){
	if(d[b]==0){
		gt[d[b]-1]++;
		gt[gt.sz-1]++;
	}
	else{
		gt[d[b]-1]++;
		c(d,d[d[b]]-1);
	}
}
void cok(int a){
	cout<<gt[a-1]<<endl;
	fo(i,a-1)
	cout<<gt[i]<<endl;
}
};
*/
signed main(){
	int a,b,c;
	cin>>a>>b>>c;
	b+=a;
	if(a<=c&&c<=b)
		cout<<"YES"<<endl;
	else
		cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,y;
    char c,d;
    cin>>n>>c>>m>>d>>y;
    if(n>2019)
        cout<<"TBD";
    else
    {
        if(m>4)
            cout<<"TBD";
        else cout<<"Heisei";
    }

}


Measured memory_bytes: 3560
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int N;
vector<int> a;

bool judge(){
    sort(a.begin(),a.end());
    int diam=a[N-1];
    int mia=0;
    if(diam%2) mia=(diam+1)/2;
    else mia=diam/2;

    if(a[N-1]!=diam||a[0]!=mia) return false;
    int numOfMia=0;
    for(int i=0;i<N;i++){
        if(a[i]!=mia) break;
        numOfMia++;
    }
    if(diam%2&&numOfMia!=2) return false;
    if(diam%2==0&&numOfMia!=1) return false;

    int num[N+10]={};
    for(int i=0;i<N;i++) num[a[i]]++;
    for(int i=mia+1;i<=diam;i++){
        if(num[i]<2) return false;
    }

    return true;
}

int main(){
  cin>>N;
  for(int i=0;i<N;i++){
      int x;
      cin>>x;
      a.push_back(x);
  }
  
  if(judge()) cout<<"Possible"<<endl;
  else cout<<"Impossible"<<endl;

  return 0;
}


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

int main() {
	int p, q, r;
	cin >> p >>  q >> r;
	printf("%d\n", p+q+r-max(p,max(q, r)));
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;


public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    //int[] d = new int[n];
    ArrayList<Integer> di = new ArrayList<>();

    for(int i = 0; i< n; i++){
    	int a = sc.nextInt();
    	if(a > 0) {
    		di.add(a);
    	}
    }
    //ArrayList<Integer> sa = new ArrayList<>();
    ArrayList<Integer> ka = new ArrayList<>();
    ka = (ArrayList<Integer>) di.clone();

    int ans = 0;
    for(int i = 0; i < di.size();i++){
    	ka.remove(0);
    	for(int j =0; j  < ka.size(); j++) {
    		ans += di.get(i) * ka.get(j);
        	}
    	}
	System.out.println(ans);
  }
}

Measured memory_bytes: 23764
n = int(input())
s = []
t = []
for i in range(n):
    tmps, tmpt = input().split()
    s.append(tmps)
    t.append(int(tmpt))
target = input()
sleep = s.index(target)
sum = 0
for i in range(sleep + 1, n):
    sum += t[i]
print(sum)

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

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int main(){
  string s;
  cin >> s;
  if(s == "ARC")
    cout << "ABC" << endl;
  else
    cout << "ARC" << endl;
  return 0;
}

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

int main() {
	int N, A;
	cin >> N;
	cin >> A;
	int k = N % 500;
	if (k <= A) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

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

int main()
{
	int a[3];
	bool seven;
	int five;

	cin >> a[0]	>> a[1] >> a[2];

	for (int i = 0; i < 3; i++){
		if (a[i] == 5) five++;
		if (a[i] == 7) seven = true;
	}
	if (five == 2 && seven == true) cout << "YES" << endl;
	else cout << "NO" << endl;
}


Measured memory_bytes: 256
x, n = [int(e) for e in input().split()]

if n == 0:
    print(x)
else:    
    p = [int(e) for e in input().split()]

    for i in range(100):
        if not (x - i) in p: 
            print(x - i)
            break
        if not (x + i) in p: 
            print(x + i)
            break
        

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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplece_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define Edge pair< i_i, int>
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; scanf("%lld", &x);
#define int2(x, y) int x, y; scanf("%lld %lld", &x, &y);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
 
//int dxy[5] = {0, 1, 0, -1, 0};
// assign


int fact[114514];

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

int extgcd(int a, int b, int &x, int &y)
{
    int d = a;
    if (b != 0) {
        d = extgcd(b, a % b, y, x);
        y -= (a / b) * x;
    } else { x = 1; y = 0; }
    return d;
}

int repow(int x, int n, int mod)
{
    if (n == 0) return 1;
    int res = repow(x * x % mod, n / 2, mod);
    if (n & 1) res = res + x % mod;
    return res;
}

int mod_inverse(int a, int m)
{
    int x, y;
    extgcd(a, m, x, y);
    return ( m + x % m ) % m;
}

int table(int n)
{
    int sum = 1;
    fact[0] = 1;
    Rep(i, n+2) {
        sum *= i;
        sum %= MOD;
        fact[i] = sum;
    }
}

int mod_fact(int n, int p, int &e)
{
    e = 0;
    if (n == 0) return 1;
    int res = mod_fact(n / p, p, e);
    e += n / p;

    if (n / p % 2 != 0) return res * (p - fact[n % p]) % p;
    return res * fact[n % p] % p;
}

int mod_comb(int n, int k, int p) {
    if (n < 0 || k < 0 || n < k) return 0;
    int e1, e2, e3;
    int a1 = mod_fact(n, p, e1), a2 = mod_fact(k, p, e2), a3 = mod_fact(n-k, p, e3);
    if (e1 > e2 + e3) return 0;
    return a1 * mod_inverse(a2 * a3 % p, p) % p;
}

int ncm(int n, int r)
{
    if (r == 0) return 1;
    return (n-r+1) * ncm(n, r-1) / r;
}


int n, p;
vi data;

signed main()
{
    cin >> n >> p;
    data = vi(n);
    rep(i, n) cin >> data[i];
    table(n);

    int o = 0, e = 0;
    rep(i, n) {
        if (data[i] % 2) {
            o++;
        } else {
            e++;
        }
    }

    int ans = 0;
    if (p) {
        rep(i, e+1) {
            for (int j = 1; j < o + 1; j += 2) {
                ans += ncm(e, i) * ncm(o, j);
            }
        }
    } else {
        rep(i, e+1) {
            for (int j = 0; j < o + 1; j += 2) {
                ans += ncm(e, i) * ncm(o, j);
            //    cout << ncm(e, i) + ncm(o, j) << endl;
            }
        }
    }
    cout << ans << endl;

    return 0;
}



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

const int64_t MOD = 1e9+7;

int64_t power_mod(int64_t num, int64_t power){
    int64_t prod = 1;
    num %= MOD;
    while(power > 0){
        if(power&1) prod = prod * num % MOD;
        num = num * num % MOD;
        power >>= 1;
    }
    return prod;
}

struct UnionFind {
    vector<int> par;
    vector<int> sz;
    vector<int> ch;

    UnionFind(int n=0){
        if(n>0) initialize(n);
    }

    void initialize(int n){
        par.resize(n);
        sz.resize(n);
        ch.resize(n);
        for(int i=0; i<n; i++){
            par[i] = i;
            sz[i] = 1;
        }
    }

    int find(int x){
        if(par[x] == x){
            return x;
        }else{
            return par[x] = find(par[x]);
        }
    }

    bool unite(int x, int y){
        x = find(x);
        y = find(y);
        if(x == y) return false;
        if(sz[x] > sz[y]) swap(x, y);
        par[x] = y;
        sz[y] += sz[x];
        return true;
    }

    bool same(int x, int y){
        return find(x) == find(y);
    }

    int size(int x){
        return sz[find(x)];
    }
};

int main(){
    string S, T;
    int N;
    cin >> S >> T >> N;
    int A = S.size(), B = T.size();
    int64_t ans = 1;
    if(N > B){
        ans = power_mod(26, (N-B+1)/2);
        N = B;
    }
    int L = A+B+2*N;
    UnionFind uf(N+26);
    for(int i=0; i<L; i++){
        int j = L-i-1;
        if(i >= j) continue;
        vector<int> num;
        for(int p : {i, j}){
            if(p < N){
                num.push_back(p);
            }else if(p < N+A){
                num.push_back(N + S[p-N] - 'a');
            }else if(p < 2*N+A){
                num.push_back(p-N-A);
            }else{
                num.push_back(N + T[p-2*N-A] - 'a');
            }
        }
        uf.unite(num[0], num[1]);
    }
    for(int i=0; i<26; i++) for(int j=0; j<26; j++) if(i!=j && uf.same(N+i, N+j)) ans = 0;
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 4524
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int n = in.nextInt();
		float[] v = new float[n];
		for (int i = 0; i < n; i++)
			v[i] = in.nextInt();
		Arrays.sort(v);
		float r = (v[0] + v[1]) / 2l;
		for (int i = 2; i < n; i++)
			r = (r + v[i]) / 2l;
		System.out.println(r);
	}
}

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

const int MAX = 100;
int main() {
	int N, x[MAX], y[MAX], h[MAX];
	cin >> N;
	for (int i = 0;i < N;++ i) cin >> x[i] >> y[i] >> h[i];
	for (int i = 0;i <= 100;++ i) {
		for (int j = 0;j <= 100;++ j) {
			for (int k = h[0], m = k + 200;k < m;++ k) {
				for (int l = 0;l < N;++ l) {
					if (max(k - abs(y[l] - i) - abs(x[l] - j), 0) != h[l]) break;
					if (l == N - 1) {
						cout << j << " " << i << " " << k;
						return 0;
					}
				}
			}
		}
	}
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

答えを決め打つとO(XYHN),2000000Nは通るね
*/

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n;
  cin >> n;
  while(n!=0){
    int a,b,c,d;
    int i;
    int o=0;
    for(a=0;a*a<=n;a++){
      for(b=a;a*a+b*b<=n;b++){
	for(c=b;a*a+b*b+c*c<=n;c++){
	  for(d=c;a*a+b*b+c*c+d*d<=n;d++){
	    if(n==a*a+b*b+c*c+d*d) o++;
	  }
	}
      }
    }
    cout << o << endl;
    cin >> n;
  }
}

Measured memory_bytes: 1160
#include <cstdio> 
#include <cstdlib> 
#include <cmath> 
#include <cstring> 
#include <climits> 
#include <cfloat> 
#include <map> 
#include <utility> 
#include <set> 
#include <iostream> 
#include <memory> 
#include <string> 
#include <vector> 
#include <algorithm> 
#include <functional> 
#include <sstream> 
#include <complex> 
#include <stack> 
#include <queue> 
#include <numeric>
#include <cassert>

#define FOR(i, min, max) for (int i = (min); i < (max); ++i) 
#define FORE(i, min, max) for (int i = (min); i <= (max); ++i) 
#define REP(i, n) for (int i = 0; i < (n); ++i) 
#define REPV(vec, i) for (int i = 0; i < (int)(vec.size()); ++i) 
#define FOR_EACH(vec, it) for (typeof((vec).begin()) it = (vec).begin(); it != (vec).end(); ++it)

using namespace std; 
static const double EPS = 1e-12; 
typedef long long ll; 

ll MOD=1000000007;
inline ll add_m(ll a, ll b) { return (a + b) % MOD; }
inline ll sub_m(ll a, ll b) { return (a - b + MOD) % MOD; }
inline ll mul_m(ll a, ll b) { return (a * b) % MOD; }

ll pow_m(ll a, ll b) {
    ll r = 1LL;
    while(b) {
        if(b & 1LL)
            r = mul_m(r, a);
        a = mul_m(a, a);
        b >>= 1;
    }
    return r;
}

int main(void)
{
    int N, K;
    cin >> N >> K;
    vector<ll> count(K+1);
    FORE(k, 1, K) {
        int c = K/k;
        count[k] = pow_m(c, N);
    }
    for (int k = K; k >= 1; --k) {
        int c = K/k;
        assert(k *c <= K);
        FORE(k2, 2, c) {
            count[k] = sub_m(count[k], count[k*k2]);
        }
    }
    ll ret = 0;
    FORE(k, 1, K) {
        ret = add_m(ret, mul_m(k, count[k]));
    }
    cout << ret << endl;
    
    return 0;
}


Measured memory_bytes: 4052
#include <iostream>
#include <thread>
#include <chrono>
#include <random>
#include <fstream>
#include <time.h>


int main()
{
    int a,b;
    bool flag = true;
    std::cin >> a >> b;

    if(a > 8 || b > 8) flag=false;



    if(flag) std::cout << "Yay!";
    else std::cout << ":(";

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
using namespace std;
typedef long long ll;
int n, a[200010];
int main() {
	cin >> n;
	for (int i = 0; i < n; i++)cin >> a[i];
	cout << a[n - 1];
	for (int i = n - 3; i >= 0; i -= 2)cout << " " << a[i];
	for (int i = n % 2; i < n; i += 2)cout << " " << a[i];
	return 0;
}


Measured memory_bytes: 2944
n,m = map(int,input().split())
num_list = list(map(int,input().split()))
num_list.sort()
d_list = []
if n >= m:
    print(0)
    
else:
    for i in range(m-1):
        tmp = num_list[i+1] - num_list[i]
        d_list.append(tmp)
    d_list.sort(reverse = True)
    print(sum(d_list[n-1:]))

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

int prime[123457 * 2], n, cnt;

void solve() {
    prime[0] = prime[1] = 1;
    for (int i = 2; i <= 123456 * 2; ++i) {
        if (prime[i] == 0) {
            for (int j = 2; i * j <= 123456 * 2; ++j) {
                prime[i * j] = 1;
            }
        }
    }
}

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

    solve();

    while (cin >> n, n) {
        cnt = 0;
        for (int i = n+1; i <= 2 * n; ++i) {
            if (i > 123456 * 2) break;
            if (prime[i] == 0) cnt++;
        }
        cout << cnt << endl;
    }

    return 0;
}

Measured memory_bytes: 4108
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner console = new Scanner(System.in);

        int a = console.nextInt();
        console.nextLine();

        String b = console.nextLine();
        char[] alphabets = b.toCharArray();

        for(int i = 0; i < alphabets.length; i++) {
            int num = alphabets[i];
            if(num + a <= 90){
                alphabets[i] = (char)(num + a);
            }else {
                alphabets[i] = (char)(65 + num + a - 91);
            }
        }
        System.out.println(alphabets);
    }
}

Measured memory_bytes: 37136
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.B
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var (A, B, C) = Read3Longs();
            var K = ReadLong();

            for (int i = 0; i < K; i++)
            {
                if (A >= B)
                {
                    B *= 2;
                }
                else if (B >= C)
                {
                    C *= 2;
                }

                if (A < B && B < C) return "Yes";
            }

            return "No";
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


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

int main()
{
    ll a,b,c,d,r,e,f;
    scanf("%d %d",&a,&b);

   for(int i=a-1;i>=0;i--)
   {
       printf("%d ",b-i);
   }
   for(int i=1;i<a;i++)
   {
       printf("%d ",b+i);
   }
}


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

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

    string s;
    cin>>s;
   // cout<<s;
    //sort(s.begin(),s.end());
    int arr[26];
    memset(arr,0,sizeof(arr));
    for(int i=0;i<s.size();i++)
        arr[s[i]-65]++;
    int c=0;
    for(int i=0;i<26;i++)
        if(arr[i]==2)
            c++;
    if(c==2)
        cout<<"Yes";
    else
        cout<<"No";
    //code goes here
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
static const int MAX = 200000;

int main()
{
	int a[MAX],n;
	cin >> n;
	int max,tmp;
	int min;
	max = -1000000000;
	for(int i=0;i<n;i++)
	{
		cin >> a[i];
	}
	min = a[0];
	for(int i=1;i<n;i++)
	{
		tmp = a[i] - min;
		if(max < tmp)
		{
			max = tmp;
		}
		if(min > a[i])
		{
			min = a[i];
		}
	}
	cout << max << endl;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define _abs(x)((x) < 0 ? (x) * -1 : (x))
#define _max(x, y)(max(0, max((x), (y))))
#define _min(x, y)(max(0, min((x), (y))))

int main()
{
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    //freopen("debug.txt", "w", stderr);

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

    int x, a, b;

    cin >> x >> a >> b;

    if (_abs(x - a) < _abs(x - b)) cout << "A" << endl;
    else cout << "B" << endl;

    return 0;
}


Measured memory_bytes: 892
#include<stdio.h>

#include<stdlib.h>

#include<string.h>


struct node{

  unsigned int key;

  struct node *next;

  struct node *prev;

};


typedef struct node * NodePointer;


NodePointer nil;


NodePointer listSearch(int key){
  NodePointer temp;
  temp=nil->next;
  while(temp !=nil && temp->key !=key){
    temp = temp->next;
  }
  return temp;

}


void init(){

  nil = malloc(sizeof(struct node));

  nil->next = nil;

  nil->prev = nil;

}


void printList(){

  NodePointer cur = nil->next;

  int isf = 1;

  while(1){

    if ( cur == nil ) break;

    if ( isf == 0)  printf(" ");

    printf("%d", cur->key);

    cur = cur->next;

    isf = 0;

  }

  printf("\n");

}


void deleteNode(NodePointer t){
  if(t==nil)return;
  t->prev->next = t->next;
  t->next->prev=t->prev;
  free(t);
  
}


void deleteFirst(){

  NodePointer t = nil->next;

  if ( t == nil ) return;

  deleteNode(t);

}


void deleteLast(){

  deleteNode(nil->prev);


}


void delete(int key){

  deleteNode(listSearch(key));

}



void insert(int key){

  NodePointer x;

  x = malloc(sizeof(struct node));

  x->key = key;

  x->next=nil->next;
  nil->next->prev=x;
  nil->next=x;
  x->prev=nil;


}


int main(){

  int key, n, i;

  int size = 0;

  char com[20];

  int np = 0, nd = 0;

  scanf("%d", &n);

  init();

  for ( i = 0; i < n; i++ ){

    scanf("%s%d", com, &key);

    if ( com[0] == 'i' ) {insert(key); np++; size++;}

    else if ( com[0] == 'd' ) {

      if (strlen(com) > 6){

if ( com[6] == 'F' ) deleteFirst();

else if ( com[6] == 'L' ) deleteLast();

      } else {

delete(key); nd++;

      }

      size--;

    }

  }


  printList();

  return 0;

}

Measured memory_bytes: 31788
//Let's join Kaede Takagaki Fan Club !!
//明日は高垣楓さんの誕生日！おめでとうございます！！！
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target ("avx")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
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 repn(i,x) for(int i=1;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 all(x) x.begin(),x.end()
template<class T>
void dmp(T a){
	rep(i,a.size()) cout << a[i] << " ";
	cout << endl;
}
template<class T>
bool chmax(T&a, T b){
	if(a < b){
		a = b;
		return 1;
	}
	return 0;
}
template<class T>
bool chmin(T&a, T b){
	if(a > b){
		a = b;
		return 1;
	}
	return 0;
}
template<class T>
void g(T &a){
	cin >> a;
}
template<class T>
void o(const T &a,bool space=false){
	cout << a << (space?' ':'\n');
}
//ios::sync_with_stdio(false);
const ll mod = 1000000007;//998244353
template<class T>
void add(T&a,T b){
	a+=b;
	if(a >= mod) a-=mod;
}
int n, v[(1<<18)+2], w[(1<<18)+2], q, rev[(1<<12)+2];
P p[(1<<10)+2][(1<<10)+2], pp[(1<<8)+2];
int len[(1<<11)+2];
int main(){
	ios::sync_with_stdio(false);
	rep(i, 12) rev[(1<<i)] = i;
	
	cin >> n;
	repn(i, n) cin >> v[i] >> w[i];
	repn(i, (1<<10)){
		if(i > n) break;
		int num = i;
		vector<P>vec;
		while(num){
			vec.pb(mp(v[num], w[num]));
			num /= 2;
		}
		int sz = vec.size();
		rep(mask, (1<<sz)){
			if(mask == 0){
				p[i][mask] = mp(0, 0);
			}
			else{
				int x = mask&-mask;
				int y = rev[x];
				p[i][mask] = p[i][mask^x];
				p[i][mask].fi += vec[y].sc;
				p[i][mask].sc += vec[y].fi;
			}
		}
		
		sort(p[i], p[i]+(1<<sz));
		len[i] = (1<<sz);
		rep(j, (1<<sz)-1) p[i][j+1].sc = max(p[i][j+1].sc, p[i][j].sc);
	}
	cin >> q;
	rep(i, q){
		int num, wei; cin >> num >> wei;
		
		vector<P>vec;
		while(num > (1<<10)){
			vec.pb(mp(v[num], w[num]));
			num /= 2;
		}
		int sz = vec.size();
		ll ans = 0;
		
		rep(mask, (1<<sz)){
			if(mask == 0){
				pp[mask] = mp(0, 0);
			}
			else{
				int x = mask&-mask;
				int y = rev[x];
				pp[mask] = pp[mask^x];
				pp[mask].fi += vec[y].sc;
				pp[mask].sc += vec[y].fi;
			}
			if(pp[mask].fi > wei) continue;
			int zan = wei - pp[mask].fi;
			int pt = upper_bound(p[num], p[num]+len[num], mp(zan+1, -1))-p[num];
			pt--;
			assert(pt >= 0);
			ans = max(ans, 1LL*pp[mask].sc + p[num][pt].sc);
		}
		
		cout << ans << '\n';
	}
}

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

int main(){
	int a[5];
	cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4];

	for(int i = 0; i < 5; i++)
		if(a[i] == 0)
			cout << i +1;



	return 0;
}

Measured memory_bytes: 3556
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1e9+7;

#define vec vector<int>
#define vecll vector<ll>
#define vpair vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>

#define rep(i,n)         for(int i=(int)0; i<(int)n; i++)
#define REP(i,m,n)       for(int i=(int)m; i<(int)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define prt(var)         cout << var << endl
#define prtd(n, var)     cout << fixed << setprecision(n) << var << endl
#define prt2(var1, var2) cout << var1 << " " << var2 << endl

//----------------------------------------------------------------

int main(void) {
  ll l, r;
  cin >> l >> r;
  if(r-l+1>2018){
    prt(0); return 0;
  }

  ll ans=2020;
  REP(i,l,r){
    REP(j,i+1,r+1){
      ll tmp = ((i%2019) * (j%2019)) % 2019;
      if(ans>tmp){
        ans = tmp;
      }
    }
  }

  prt(ans);
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<string>
#include<map>
#include<queue>
using namespace std;
#define N 3
#define N2 9

struct Puzzle{
    int f[N2];
    int space;
    string path;
    
    bool operator <(const Puzzle &p) const{
        for(int i=0;i<N2;i++){
            if(f[i]==p.f[i]) continue;
            return f[i]>p.f[i];
        }
        return false;
    }
};

static const int dx[4]={-1,0,1,0};
static const int dy[4]={0,-1,0,1};
static const char dir[4]={'u','l','d','r'};

bool isTarget(Puzzle p){
    for(int i=0;i<N2;i++){
        if(p.f[i]!=(i+1)) return false;
    }
    return true;
}

string bfs(Puzzle s){
    queue<Puzzle> Q;
    map<Puzzle,bool> V;
    Puzzle u,v;
    s.path="";
    Q.push(s);
    V[s]=true;
    
    while(!Q.empty()){
        u=Q.front(); Q.pop();
        if(isTarget(u)) return u.path;
        int sx=u.space/N;
        int sy=u.space%N;
        for(int r=0;r<4;r++){
            int tx=sx+dx[r];
            int ty=sy+dy[r];
            if(tx<0||ty<0||tx>=N||ty>=N) continue;
            v=u;
            swap(v.f[u.space],v.f[tx*N+ty]);
            v.space=tx*N+ty;
            if(!V[v]){
                V[v]=true;
                v.path+=dir[r];
                Q.push(v);
            }
        }
    }
    return "unsolvable";
}

int main(){
    Puzzle in;
    for(int i=0;i<N2;i++){
        cin>>in.f[i];
        if(in.f[i]==0){
            in.f[i]=N2;
            in.space=i;
        }
    }
    string ans=bfs(in);
    cout<<ans.size()<<endl;
    return 0;
}
    
    
    


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

using namespace std;
using namespace __gnu_pbds;

#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pi 3.141592653589793116
#define mod 1e9+7
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
int main() {
  off;
  int t;
  //cin>>t;
  t=1;
  while(t--){  
    int a[5];
    for(int i=0;i<5;i++)
        cin>>a[i];
      sort(a,a+5);
      int k;
      cin>>k;
      if(a[4]-a[0]<=k)
         {
            cout<<"Yay!";
         }
       else
         cout<<":(";  
  }
    return 0;
}

Measured memory_bytes: 256
from sys import stdin

N, K = [int(x) for x in stdin.readline().rstrip().split()]
# -1は終端
S = [int(x) for x in stdin.readline().rstrip()] + [-1]

# 連続して立っている人のカウント
straight_stand_cnt = 0

if S[0] == 0:
    straight_stand_cnt = 1

l = 0
r = 0
ans = -999

while r < N:
    # for DEBUG
    #print(l, r)
    if straight_stand_cnt <= K:
        if S[r] == 1 and S[r+1] == 0:
            straight_stand_cnt += 1

        ans = max(ans, r-l+1)
        r += 1
    else:
        if S[l] == 0 and S[l+1] == 1:
            straight_stand_cnt -= 1
        l += 1      


print(ans)


Measured memory_bytes: 45404
import sys
from math import ceil
from collections import deque

input = sys.stdin.readline

n, d, a = map(int, input().split())
xh = [list(map(int, input().split())) for _ in range(n)]
xh.sort()
q = deque()
ans = 0
dam = 0
for i in range(n):
    # attack
    while len(q) > 0:
        if q[0][0] < xh[i][0]:
            dam -= q[0][1]
            q.popleft()
        else:
            break
    xh[i][1] -= dam
    if xh[i][1] > 0:
        a_num = ceil(xh[i][1] / a)
        xh[i][1] -= a_num * a
        ans += a_num
        dam += a_num * a
        q.append((xh[i][0] + 2*d, a_num * a))
print(ans)


Measured memory_bytes: 106844
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<stack>
using namespace std;

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

int main() {
	int A, B, C, D, E, F;
	cin >> A >> B >> C >> D >> E >> F;
	
	double maxc = (double)E / (100 + E);
	double maxw = (double)F;
	double maxsw = maxc * maxw;
	double maxww = maxw - maxsw;

	

	int s = 0, w = 100 * A;
	double maxv = 0;
	for (int a = 0;a <= 30;a++) {
		for (int b = 0;b <= 30-a;b++) {

			if ((double)a*A + b*B * 100 > maxww) continue;

			for (int c = 0;c <= 3000;c++) {

				
				for (int d = 0;d <= 3000-c;d++) {

					
					if ((double)c*C + d*D > maxsw) continue;
					if ((100 * (a*A + b*B) + (c*C + d*D)) > F) continue;

					double temp = ((double)c*C + d*D) / (100 * (a*A + b*B) + (c*C + d*D));

					if (temp > maxc) continue;
					else if (temp > maxv) {
						maxv = temp;
						s = c*C + d*D;
						w = 100 * (a*A + b*B);
					}
				}
			}
		}
	}


	cout << w+s << " " << s << endl;
	return 0;
}

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

typedef long long ll;

#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e18


int main() {
    int N; cin >> N;
    int ans = 0;
    REP(i,N){
        int a; cin >> a;
        ans += a-1;
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main () {
    int x, a, b;
    cin >> x >> a >> b;
    int xa = abs(x - a), xb = abs(x - b);
    cout << (xa < xb ? 'A' : 'B') << endl;
}

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

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	int a[n];
	int total = 0;
	for (int i=0; i<n; i++) {
		cin >> a[i];
		total ^= a[i];
	}
	for (int i=0; i<n; i++) {
		cout << (total^a[i]) << ' ';
	}
}

Measured memory_bytes: 4372
/*
AizuOnline A0049
Blood Groups
*/
#include <stdio.h>


main()
{

  int type_a=0,type_b=0,type_o=0,type_ab=0;
  int sno;
  char b_type[3];

  while(EOF != scanf("%d,%s",&sno,b_type))
    {
      if(b_type[0] == 'O')
	type_o++;
      else if(b_type[0] == 'B')
	type_b++;
      else if(b_type[0] == 'A')
	{
	  if(b_type[1] == 'B')
	    type_ab++;
	  else
	    type_a++;
	}
    }
  printf("%d\n",type_a);
  printf("%d\n",type_b);
  printf("%d\n",type_ab);
  printf("%d\n",type_o);

return(0);
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x)      begin(x),end(x)

using namespace std;
using vecint = vector<int>;
using ll = int64_t;

int main()
{
  ll n,m;
  cin>>n>>m;
  using T=tuple<ll,ll>;
  priority_queue<T, vector<T>, greater<T>> q;
  REP(i,n) {
    ll a;
    cin>>a;
    q.emplace(a, 1);
  }
  REP(i,m) {
    ll b,c;
    cin>>b>>c;
    ll sum = 0;
    while (!q.empty()) {
      ll num, cnt;
      tie(num, cnt) = q.top();
      if (num >= c) {
        q.emplace(c, sum);
        break;
      }
      q.pop();
      sum += cnt;
      if (sum >= b) {
        ll rem = sum - b;
        q.emplace(c, b);
        q.emplace(num, rem);
        break;
      }
      if (q.empty()) {
        q.emplace(sum, b);
        break;
      }
    }
  }
  ll ans = 0;
  while (!q.empty()) {
    ll num,cnt;
    tie(num,cnt) = q.top();
    q.pop();
    ans += num * cnt;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 2420
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define RREP(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N, W; cin >> N >> W;
    vl w(N), v(N);
    REP(i, N) cin >> w[i] >> v[i];
    
    vvl dp(N+1, vl(W+1, 0));
    REP(i, N){
        REP(ww, W+1){
            if(ww - w[i] >= 0){
                dp[i+1][ww] = max(dp[i+1][ww], dp[i][ww-w[i]] + v[i]);
            }
            dp[i+1][ww] = max(dp[i+1][ww], dp[i][ww]);
        }
    }
    cout << dp[N][W] << endstr;
    return 0;
}


Measured memory_bytes: 80256
#include<iostream>
#include<stdio.h>
using namespace std;
int main () {
    
    int H,W;
    
    while(1) {
        
        cin >> H >> W;
        
        if (H == 0) break;
        
        for (int i = 0 ; i < H ; i ++) {
    
            for (int j = 0 ; j < W ; j ++) {
                    
                if ((i + j) % 2 == 0) {
                    
                    cout << '#';
                    
                } else {
                    
                    cout << '.';
                    
                }
            
            }
            
            cout << endl;
            
        }
        
        cout << endl;
            
    }
    
    return 0;

}




Measured memory_bytes: 3072
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

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

int main(){
	string str1,str2;
	while(cin>>str1>>str2){
		if(str1==str2&&str1=="0")break;
		int hit = 0;
		map<char,int> data;
		for(int i=0;i < 4;i++){
			if(str1[i]==str2[i]){
				hit++;
			}else{
				data[str1[i]]++;
				data[str2[i]]++;
			}
		}
		int blow = 0;
		map<char,int>:: iterator it =data.begin();
		while(it !=data.end()){
			if(it->second>=2){
				blow++;
			}
			it++;
		}
		cout <<hit<<" "<<blow<<endl;
	}
	return 0;
}

Measured memory_bytes: 1192