akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2) % mod;
}
/*--------Library Zone!--------*/

int n, a[3005];
int dp[3005][3005][2];
int solve(int le, int ri, bool x) {
	if (ri - le == 0)return 0;
	if (dp[le][ri][x] != inf)return dp[le][ri][x];
	int res;
	if (!x) {
		res = -inf;
		res = max(res, a[le] + solve(le + 1, ri, 1));
		res = max(res, a[ri - 1] + solve(le, ri - 1, 1));
	}
	else {
		res = inf;
		res = min(res, solve(le + 1, ri, 0) - a[le]);
		res = min(res, solve(le, ri - 1, 0) - a[ri - 1]);
	}
	dp[le][ri][x] = res;
	return res;
}
signed main() {
	cin >> n;
	rep(i, n)cin >> a[i];
	rep(i, n + 1)rep(j, n + 1)rep(k, 2)dp[i][j][k] = inf;
	cout << solve(0, n, 0) << endl;
}

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

int main() {
	int n;
	cin >> n;
	vector<int>a, b, c;
	a.push_back(0);
	b.push_back(0);
	c.push_back(0);
	for (int i = 1; i < n + 1; i++) {
		int x;
		cin >> x;
		a.push_back(x);
	}
	for (int i = 1; i < n + 1; i++) {
		int x;
		cin >> x;
		b.push_back(x);
	}
	for (int i = 1; i < n; i++) {
		int x;
		cin >> x;
		c.push_back(x);
	}
	int sum = 0;
	for (int i = 1; i < n + 1; i++) {
		sum += b[a[i]];
		if (i > 1) {
			if (a[i] - a[i - 1] == 1) sum += c[a[i] - 1];
		}
	}
	cout << sum << endl;
	return 0;
}

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

vector<int> to[100010];
const int INF=INT_MAX;

int main(){
  int n,m;
  cin>>n>>m;
  vector<int> past(n);
  rep(i,m){
    int a,b;
    cin>>a>>b;
    a--;b--;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  rep(i,n){
    past[i]=INF;
  }
  past[0]=0;
  queue<int> q;
  q.push(0);
  while(!q.empty()){
    int now=q.front(); q.pop();
    for(auto x : to[now]){
      if(past[x]!=INF) continue;
      past[x]=now;
      q.push(x);
    }
  }
  cout<<"Yes"<<endl;
  for(int i=1; i<n; i++){
    cout<<past[i]+1<<endl;
  }
}


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

#define MOD 1000000007
#define ll long long int
#define vi vector<int>
#define vii vector< vector<int> >
#define PI 3.1415926535897932384626433832795

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin >> n;
	long double ONE = 1;
	long double want = ((long double) 4)/n;
	for(int h = 1; h <= 3500; h++) {
		for(int w = 1; w <= 3500; w++) {
			long double h1 = ONE/h;
			long double w1 = ONE/w;
			long double need = want-h1-w1;
			long double about = ONE/need;
			ll int1 = floor(about);
			ll int2 = ceil(about);
			if(int1 > 0 && about-int1 < 0.00000001) {
				cout << h << " " << w << " " << int1;
				return 0;
			}
			if(int2 > 0 && int2-about < 0.00000001) {
				cout << h << " " << w << " " << int2;
				return 0;
			}
		}
	}
	return 0;
}



Measured memory_bytes: 384
N=int(input())

import itertools

ITER=[]
for i in range(3,10):
    ITER+=list(itertools.product([3,5,7],repeat=i))

def number(iter):
    
    s=""
    for l in iter:
        s+=str(l)
    return  int(s)
    
ANS=0
for iter in ITER:
    if 3 in iter and 5 in iter and 7 in iter:
        if number(iter)<=N:
            ANS+=1

print(ANS)

Measured memory_bytes: 7028
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MAX_N 1000
ll N,V,ans=0;
ll a[MAX_N];
ll b[MAX_N];
ll c[MAX_N];
ll d[MAX_N];
map<ll,ll> t;
  
int main(){
  scanf("%lld %lld",&N,&V);
  for(int i=0;i<N;i++)scanf("%lld",&a[i]);
  for(int i=0;i<N;i++)scanf("%lld",&b[i]);
  for(int i=0;i<N;i++)scanf("%lld",&c[i]);
  for(int i=0;i<N;i++)scanf("%lld",&d[i]);
  for(int i=0;i<N;i++)
    for(int j=0;j<N;j++)
      t[ a[i]+b[j] ]++;
  for(int i=0;i<N;i++)
    for(int j=0;j<N;j++)
      ans+=t[V-c[i]-d[j]];
  printf("%lld\n",ans);
  return 0;
}

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

int main(void) {
  string s;
  cin >> s;
  for (int i = 0; i < (int)s.length(); i++) {
    cout << "x";
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N = 13;
#define fr(i,low,up) for(register int i = low;i <= up; ++i)
#define nfr(i,low,up) for(register int i = low;i >= up; --i)

int f[1<<N],n,m,a[1001],b[1001];
vector<int> c[1001];

inline void upd(int &x,int y){
   if(y < x)x = y;
}

int main(){
   scanf("%d%d",&n,&m);
   memset(f,0x3f,sizeof f);
   f[0] = 0;
   fr(i,1,m){
      scanf("%d%d",a+i,b+i);
      int t = 0;
      fr(j,1,b[i]){
         int c; scanf("%d",&c);
         t |= (1<<(c-1));
      }
      nfr(j,(1<<n)-1,0){
         upd(f[j|t],f[j]+a[i]);
      }
   }
   if(f[(1<<n)-1] == 0x3f3f3f3f)puts("-1"); 
   else printf("%d\n",f[(1<<n)-1]);
   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define all(x) (x).begin(), (x).end()
#define MOD 1000000007
vector<double> Dijkstra_list(int n, int s,
                             vector<vector<pair<double, double>>> &Edge) {
    vector<bool> visited(n, false); //確定済み
    vector<double> d(n, DBL_MAX);
    priority_queue<pair<double, double>, vector<pair<double, double>>,
                   greater<pair<double, double>>>
        que; //頂点とsからの距離
    d[s] = 0;
    que.push(make_pair(0, s));
    while(!que.empty()) {
        auto now = que.top();
        que.pop();
        visited[now.second] = true;
        for(auto e : Edge[now.second]) {
            if(visited[e.second])
                continue;
            if(d[e.second] > d[now.second] + e.first) {
                d[e.second] = d[now.second] + e.first;
                que.push(make_pair(d[e.second], e.second));
            }
        }
    }
    return d;
}
double dis(double x, double y, double v, double w, double r1, double r2) {
    double tmp = sqrt((x - v) * (x - v) + (y - w) * (y - w));
    return max(0.0, tmp - r1 - r2);
}
int main() {
    double x, y, s, t;
    cin >> x >> y >> s >> t;
    int n;
    cin >> n;
    vector<vector<pair<double, double>>> edge(n + 2);
    vector<pair<double, double>> point(n + 2);
    vector<double> r(n + 2, 0);
    point[0] = make_pair(x, y);
    for(int i = 1; i <= n; i++) {
        cin >> point[i].first >> point[i].second >> r[i];
    }
    point[n + 1] = make_pair(s, t);
    for(int i = 0; i <= n + 1; i++) {
        for(int j = 0; j <= n + 1; j++) {
            if(i != j) {
                edge[i].push_back(
                    make_pair(dis(point[i].first, point[i].second,
                                  point[j].first, point[j].second, r[i], r[j]),
                              j));
            }
        }
    }
    auto ans = Dijkstra_list(n + 2, 0, edge);
    cout << fixed << setprecision(15) << ans.back() << endl;
}


Measured memory_bytes: 22396
s = input()
count_2 = 0
count_1 = 0
sum_2 = 0
sum_1 = 0
for i in range(0,len(s),2):
    sum_2 += 1
    if s[i] == "0":
        count_2 += 1
for i in range(1, len(s), 2):
    sum_1 += 1
    if s[i] == "0":
        count_1 += 1
p1 = sum_1 - count_1 + count_2
p2 = sum_2 - count_2 + count_1
if p1 <= p2:
    print(p1)
else:
    print(p2)

Measured memory_bytes: 39536
#include <iostream>
#include <string>
#include <list>

using namespace std;

int main()
{
    int n, k;
    int a[100010];
    int ans = 0;

    cin >> n >> k;

    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (a[i] >= k) {
            ans++;
        }
    }

    cout << ans << endl;

}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
using Graph = vector<vector<int>>;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;

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

    long double ans = 0;
    for(int p = 1; p <= n; p++){
        int tmp = p, cnt = 0;
        while (tmp < k){
            tmp *= 2;
            cnt++;
        }
        long double res = 1 / pow(2, cnt);
        ans += res;
    }

    cout << fixed << setprecision(15) << ans / n << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define mo 1000000007

using namespace std;

int gcdExtended(ll a, ll b, ll *x, ll *y); 

ll modInverse(ll b, ll m) 
{ 
	ll x, y; 
	ll g = gcdExtended(b, m, &x, &y); 
	if (g != 1) 
		return -1; 
	return (x%m + m) % m; 
} 

ll modDivide(ll a, ll b, ll m) 
{ 
	a = a % m; 
	ll inv = modInverse(b, m); 
	return (inv * a) % m; 
} 

int gcdExtended(ll a, ll b, ll *x, ll *y) 
{ 
	if (a == 0) 
	{ 
		*x = 0, *y = 1; 
		return b; 
	} 

	ll x1, y1;
	int gcd = gcdExtended(b%a, a, &x1, &y1); 
	*x = y1 - (b/a) * x1; 
	*y = x1; 

	return gcd; 
} 

ll solve(ll n,ll r)
{
    ll temp = 1;
    for(ll i=1;i<=r;i++)
    {
        temp = ((modDivide(n-i+1,i,mo))*(temp%mo))%mo;
    }
    return temp;
}

int main() 
{ 
    ll x,y,a,b;
    cin >> x >> y;
    if((2*x-y)%3==0)
    {
        a = (2*x-y)/3;
        b = a+y-x;
        if(a>=0 && b>=0)
        {
            ll n,r;
            n = a+b;
            r = min(a,b);
            cout << solve(n,r);
        }
        else cout << 0;
    }
    else cout << 0;


	return 0; 
} 


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<60;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using Graph = vector<vector<int>>;

typedef pair<int, int> P;
typedef priority_queue<int, vector<int>, greater<int>> PQ;
const int MOD = 1000000007;


int main(){
    int N, M, Q; cin >> N >> M >> Q;
    vector<int> L(M), R(M);
    rep(i,M) cin >> L[i] >> R[i];


    vector<vector<int>> S(N+1, vector<int>(N+1,0));
    rep(i,M) S[L[i]][R[i]]++;

    rep(i,N){
        rep(j,N){
            S[i+1][j+1] += S[i][j+1] + S[i+1][j] - S[i][j]; 
        }
    }

    vector<int> p(Q), q(Q);
    rep(i,Q) cin >> p[i] >> q[i];

    rep(i,Q){
        int ans = S[q[i]][q[i]] - S[q[i]][p[i]-1] - S[p[i]-1][q[i]] + S[p[i]-1][p[i]-1];
        printf("%d\n", ans);
    }
}

Measured memory_bytes: 6676
#include<stdio.h>

int main(){
	int n,m,b=0;
	int a[1000];
   int t=0;

	scanf("%d %d",&n,&m);

	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
		t=t+a[i];
	}
	for(int i=0;i<n;i++){
		if(a[i]*4*m>=t){
         b++;
      }
   }

	if(b>=m){
      printf("Yes");
   }else{
      printf("No");
   }
   
   return 0;
}


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

using namespace std;

#define endl "\n"
#define rep(i, a, b) for (auto i = (a); i < (b); ++i)
#define rrep(i, a, b) for (auto i = (a); i > (b); --i)

void solve(int &n)
{
  int a[10][5];
  rep(i, 0, 10) rep(j, 0, 5) a[i][j] = -1;
  rrep(i, n - 1, -1)
  {
    rep(j, 0, 5)
    {
      cin >> a[i][j];
    }
  }
  bool change = true;
  int ans = 0;
  while (change)
  {
    change = false;
    int b[10][5];
    rep(i, 0, 10) rep(j, 0, 5) b[i][j] = -1;
    rep(i, 0, 10)
    {
      rrep(len, 5, 2)
      {
        rep(start, 0, 5 - len + 1)
        {
          bool ok = true;
          int now = a[i][start];
          rep(j, start, start + len)
          {
            if (now != a[i][j] || now == -1)
            {
              ok = false;
            }
          }
          if (ok)
          {
            change = true;
            rep(j, start, start + len)
            {
              ans += a[i][j];
              a[i][j] = -1;
            }
          }
        }
      }
    }
    rep(j, 0, 5)
    {
      int go = 0;
      rep(i, 0, 10)
      {
        if (a[i][j] != -1)
        {
          b[go][j] = a[i][j];
          go++;
        }
      }
    }
    rep(i, 0, 10) rep(j, 0, 5) a[i][j] = b[i][j];
  }
  cout << ans << endl;
}

int main()
{
  int n;
  while (cin >> n, n)
  {
    solve(n);
  }
}


Measured memory_bytes: 3084
N=int(input())
ABC=[]
for i in range(N):
    ABC.append(list(map(int,input().split())))
Happy=[[0,0,0] for i in range(N)]
Happy[0]=ABC[0]
for i in range(1,N):
    for j in range(3):
        if j==0:
            Happy[i][j]=max(Happy[i-1][1],Happy[i-1][2])+ABC[i][j]
        if j==1:
            Happy[i][j]=max(Happy[i-1][0],Happy[i-1][2])+ABC[i][j]
        if j==2:
            Happy[i][j]=max(Happy[i-1][0],Happy[i-1][1])+ABC[i][j]
print(max(Happy[N-1]))

Measured memory_bytes: 76248
from collections import Counter

H, W = map(int, input().split())
cnt = Counter()

for _ in range(H):
    cnt.update(Counter(input()))

H_r = H % 2
W_r = W % 2

if H_r == 0 and W_r == 0:
    cnt1 = cnt2 = 0
    cnt4 = (H * W) // 4
elif H_r == 1 and W_r == 0:
    cnt1 = 0
    cnt2 = W // 2
    cnt4 = (W // 2) * (H // 2)
elif H_r == 0 and W_r == 1:
    cnt1 = 0
    cnt2 = H // 2
    cnt4 = (W // 2) * (H // 2)
else:
    cnt1 = 1
    cnt4 = (W // 2) * (H // 2)
    cnt2 = ((H * W) - cnt4 * 4 - cnt1 * 1) // 2

odd = 0
for c in cnt.values():
    while c >= 4 and cnt4 > 0:
        c -= 4
        cnt4 -= 1
    while c >= 2 and cnt2 > 0:
        c -= 2
        cnt2 -= 1
    while c >= 1 and cnt1 > 0:
        c -= 1
        cnt1 -= 1
print('Yes' if cnt1 == cnt2 == cnt4 == 0 else 'No')


Measured memory_bytes: 3316
/*
　　　　　　 ＿＿
　　　　　／＞　　 フ
　　　　　|   _　 _l  
　 　　　／` ミ＿x ノ   Zzz..
　　 　 /　 　 　 |   コード見ちゃだめ！！
　　　 /　 ヽ　　  ﾉ
　 　 │　　|　|  |   
　／￣|　　 |　|  |
　| (￣ヽ＿_ヽ_)_ _)
　＼二つ
*/

#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define SORT(a) sort((a).begin(),(a).end())
#define RSORT(a) reverse((a).begin(),(a).end())

int main(){
    int n;
    cin>>n;
    vector<int>s(5);
    for(int i=0;i<n;i++) {
        string k;
        cin>>k;
        if(k[0]=='M') s[0]++;
        if(k[0]=='A') s[1]++;
        if(k[0]=='R') s[2]++;
        if(k[0]=='C') s[3]++;
        if(k[0]=='H') s[4]++;
    }
    ll total=0;
    for(int i=0;i<3;i++){
        for(int j=i+1;j<4;j++){
            for(int k=j+1;k<5;k++){
                total+=(ll)s[i]*s[j]*s[k];
            }
        }
    }
    cout<<total<<endl;
    return 0;


}



Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
)

var (
	read  = bufio.NewReader(os.Stdin)
	write = bufio.NewWriter(os.Stdout)
)

func yesno(result bool) {
	if result {
		fmt.Fprintln(write, "Yes")
	} else {
		fmt.Fprintln(write, "No")
	}
}

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

func lcm(a, b int) int {
	return a / gcd(a, b) * b
}

func main() {
	defer write.Flush()

	var a, b int
	fmt.Fscan(read, &a, &b)

	fmt.Fprintln(write, lcm(a, b))
}


Measured memory_bytes: 640
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] B = new int[N-1];
		for(int i=0;i<N-1;i++){
			B[i] = sc.nextInt();
		}
		int result = B[0] + B[N-2];
		for(int i=0;i<N-2;i++){
			result += Math.min(B[i],B[i+1]);
		}
		System.out.println(result);
	}
}

Measured memory_bytes: 21844
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		
		
		for (int i=0; i<1001; i++) {
			if(i*8/100==A && i*10/100==B){
				System.out.println(i);
				return;
			}
		}
		System.out.println(-1);
	}
}

Measured memory_bytes: 22612
/*#include <bits/stdc++.h>
using namespace std;
string ans,s[3055][3055],s1,s2;
int dp[3055][3055],n,m,ma;
int main()
{

    cin>>s1>>s2;
    if (s1.size()>s2.size()) swap(s1,s2);
    n=s1.size();
    m=s2.size();
    for (int i=0;i<n;i++)
    {
        for (int j=0;j<m;j++)
        {
            dp[i+1][j+1]=dp[i][j+1];
            s[i+1][j+1]=s[i][j+1];
            if (s1[i]==s2[j])
            {
                    dp[i+1][j+1]++;
                    s[i+1][j+1]=s[i+1][j+1]+s1[i];
            }
            if (dp[i+1][j+1]<=dp[i+1][j])
            {
                s[i+1][j+1]=s[i+1][j];
                dp[i+1][j+1]=dp[i+1][j];
            }
            //cout<<s[i+1][j+1]<<dp[i+1][j+1]<<" ";
        }

    }
    for (int i=0;i<=m;i++)
    {
        if (dp[n][i]>ma)
        {
            ma=dp[n][i];
            ans=s[n][i];
        }
    }
    cout<<ans;
}*/
#include<bits/stdc++.h>
using namespace std;
int n,tu;
long long dp[3009][3009],a[3009],ans;
int main()
{

    cin>>n;
    tu=n%2;
    for (int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for (int i=n;i>=0;i--)
    {
        for (int j=0;j<n;j++)
        {
            if (tu==(j+1)%2) dp[i][i+j]=max(dp[i][i+j-1]+a[i+j],dp[i+1][i+j]+a[i]);
            else dp[i][i+j]=min(dp[i+1][i+j]-a[i],dp[i][i+j-1]-a[i+j]);
           // cout<<i<<" "<<i+j<<"  "<<dp[i][i+j]<<endl;
        }
    }
    cout<<dp[0][n-1];
}


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

int main(){
	int n;
	cin >> n;
	int v[n], c[n], sum=0;
	
	for (int i=0; i<n; i++){
		cin >> v[i];
	}
	
	for (int i=0; i<n; i++){
		cin >> c[i];
	}
	
	for (int i=0; i<n; i++){
		if (v[i]-c[i]>0){
			sum += v[i]-c[i];
		}
	}
	
	cout << sum;
	return 0;
}

Measured memory_bytes: 256
#![allow(unused_imports, unused_variables, dead_code)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

trait InputValue {
    fn parse(s: &str) -> Self;
}

fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

macro_rules! parse_single_value {
        ($($t:ty),*) => {
            $(
                impl InputValue for $t {
                    fn parse(s: &str) -> $t { s.parse().unwrap() }
                }
            )*
    	}
    }
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
    	($($t:ident),*) => {
    		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
    			fn parse(s: &str) -> ($($t),*) {
    				let mut tokens = s.split_whitespace();
    				let t = ($($t::parse(tokens.next().unwrap())),*);
    				t
    			}
    		}
    	}
    }
parse_tuple!(A, B);
parse_tuple!(A, B, C);

// ===

const MOD: i64 = 1000000007;

fn main() {
    let n: usize = read();
    let mut ans: i64 = 1;
    let mut isp: Vec<bool> = vec![true; 1010];
    for i in 2..isp.len() {
        if !isp[i] {
            continue
        }

        let mut cantake = 0;
        let mut nn = n;
        while nn >= 1 {
            cantake += nn / i;
            nn /= i;
        }
        ans *= (cantake + 1) as i64;
        ans %= MOD;


        let mut ii = i * i;
        while ii < isp.len() {
            isp[ii] = false;
            ii += i;
        }
    }
    println!("{}", ans);
}

Measured memory_bytes: 4352
n, k = map(int, raw_input().split())
a = []
for i in range(n):
    a.append(int(raw_input()))

def calcNum(p):
    i = 0
    for j in range(k):
        s = 0
        while s + a[i] <= p:
            s += a[i]
            i += 1
            if i == n:
                return n
    return i

max_weight = sum(a)
left = 0
right = max_weight
ans = 0
while left < right:
    mid = int((left + right) / 2)
    if calcNum(mid) >= n:
        right = mid
    elif calcNum(mid) < n:
        left = mid + 1
print right

    

Measured memory_bytes: 12648
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <bitset>

using namespace std;
typedef pair<int, int> Pi;
typedef long long ll;
#define pii Pi
#define pll PL
#define Fi first
#define Se second
#define pb(x) push_back(x)
//#define sz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
typedef tuple<int, int, int> t3;
typedef pair<ll, ll> pll;
typedef long double ldouble;
typedef pair<double, double> pdd;

const double PI = acos(-1);
const double EPS = 1e-9;

const int MX = 1<<20;
const int MM = 1000000007;

int T[MX];
int msk[MX], val[MX];
int N, M, K;

int nxt(int i, int v){
	return ((i + (1<<v)) | (i^1<<v)) & ((1<<N)-1);
}

int main()
{
	scanf("%d%d%d", &N, &M, &K); N--;
	for(int i = 1; i <= K; i++){
		int a, b, c;
		scanf("%d%d%d", &a, &b, &c);
		msk[a] |= 1<<b-1;
		val[a] |= c<<b-1;
	}

	for(int i = 0; i < 1<<N; i++){
		if( val[1] == (msk[1]&i)) T[i] = 1;
	}
	for(int t = 2; t <= M; t++){
		for(int v = N-1; v >= 0; v--){
			for(int i = 0; i < 1<<N; i++){
				if( i&1<<v ) T[i] = (T[i] + T[nxt(i, v)]) % MM;
			}
		}
		
		for(int i = 0; i < 1<<N; i++){
			if( val[t] != (msk[t]&i) ) T[i] = 0;
		}
	}
	int ans = 0;
	for(int i = 0; i < 1<<N; i++) ans = (ans + T[i]) % MM;
	printf("%d\n", ans);
}


Measured memory_bytes: 6400
#include <iostream>

#include <algorithm>
#include <cmath>
#include<string>
#include<array>
#include<vector>
#include<functional>
#include<unordered_map>
#include<map>
#include<numeric>
#include<limits>
#include<utility>
#include<queue>
#include<random>

using namespace std;
typedef long long LL;

int main() {


	int a, b,c;
	//----------------------
	LL n, X, Z,A,B,N,ans1,ans2,i,m,C,D;
	LL ans, count=0 ;
	bool f=true;
	string s;

	cin >> A>> B;
	
	//B = (a+score)/2;

	ans = 2 * B - A;
	

	
	

	

	cout << ans << endl;

	
	//------------------------
	//cin >> Z;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int N, i, j;
  int p = 0;
  int w = 0;
  int g = 0;
  int y = 0;

  scanf("%d", &N);
  
  char a[101];
  for(i = 0; i < N; i++){
    scanf("%s", &a[i]);
  }
  
  for(j = 0; j < N; j++){
    if(a[j] == 'P'){
      p++;
    }
    else if(a[j] == 'W'){
      w++;
    }
    else if(a[j] == 'G'){
      g++;
    }
    else if(a[j] == 'Y'){
      y++;
    }
  }
  
  if(0 < p && 0 < w && 0 < g && 0 < y){
    printf("Four\n");
  }
  else{
    printf("Three\n");
  }
  
  return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

const ld eps = 1e-9, pi = acos(-1.0);

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

    ld r;
    cin >> r;
    cout << fixed << setprecision(10) << r * r * pi << " " << 2 * r * pi << endl;
}



Measured memory_bytes: 3248
#include<stdio.h>
int main(void)
{
        int a,b,c,x;
        int i=0,j,k;
        int n=0;
        scanf("%d%d%d%d",&a,&b,&c,&x);
        while((i!=a+1)&&(x-500*i>=0)){
                j=0;
                while((j!=b+1)&&(x-500*i-100*j>=0)){
                        k=0;
                        while((k!=c+1)&&(x-500*i-100*j-50*k>=0)){
                                if(500*i+100*j+50*k==x) n++;
                                k++;
                        }
                        j++;
                }
                i++;
        }
        printf("%d\n",n);
        return 0;
}


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

public class Main{
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] array = in.readLine().split("");
    System.out.println(array[2].equals(array[3]) 
                       && array[4].equals(array[5])?"Yes":"No");
  }
}

Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
int main() {
    double l,b,x,y,i,j;
    double p,q,ans;
    cin>>l>>b>>x>>y;
    p=l/2;
    q=b/2;
    ans=l*b/2;
    cout<<ans<<' ';
    if(x==p&&y==q)
        cout<<1;
    else
        cout<<0;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <map>
using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

LL k, a, b;

int main(){
	scanf(" %lld %lld %lld", &k, &a, &b);
	if(b >= a + 2){
		if(k <= a) printf("%lld\n", 1 + k);
		else{
			LL sum = b;
			k = k - (a + 1);
			sum += (k & 1);
			sum += (k / 2) * (b - a);
			printf("%lld\n", sum);
		}
	}
	else printf("%lld\n", 1 + k);
}

Measured memory_bytes: 256
import copy
n=int(input())

x=list(map(int,input().split()))
b=copy.copy(x)
x.sort()
med=(x[n//2-1]+x[n//2])/2
for i in range(n):
    if b[i]<med:
        print(x[n//2])
    else:
        print(x[n//2-1])

Measured memory_bytes: 25732
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}

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; }
template<class T>
void Add(T &a, const T &b, const T &mod = 1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}
////////////////////////////////////////
ll ans = 0;
void dfs(ll sum,ll s ,ll f ,ll t,ll n,ll i) {
	if (sum > n)return;
	if (s > 0 && f > 0 && t > 0) {
		ans++;
	}
	dfs(sum + 7 * pow(10, i), s + 1, f, t, n, i + 1);
	dfs(sum + 5 * pow(10, i), s, f + 1, t, n, i + 1);
	dfs(sum + 3 * pow(10, i), s, f, t + 1, n, i + 1);
}
int main() {
	ll N; cin >> N;
	dfs(0, 0, 0, 0, N, 0);
	cout << ans << endl;
	return 0;
}



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

#define forn(i,n) for(int i=0;i<(int)(n);i++)
#define si(c) ((int)(c).size())
#define forsn(i,s,n) for(int i = (int)(s); i<((int)n); i++)
#define dforsn(i,s,n) for(int i = (int)(n)-1; i>=((int)s); i--)
#define all(c) (c).begin(), (c).end()
#define D(a) cerr << #a << "=" << a << endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

#ifdef LOCAL
#define i64 "%lld"
#else
#define i64 "%I64d"
#endif

typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;

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

    int a,b; cin >> a >> b;
    if (a <= 0 && b >= 0) cout << "Zero" << endl;
    else {
        if (a > 0) cout << "Positive";
        else {
            a = b-a+1;
            if (a&1) cout << "Negative";
            else cout << "Positive";
        }
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
//#pragma GCC optimize(3)
#pragma comment(linker,"/stack:16777216")
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<functional>
#include<utility>
#include<algorithm>
#include<sstream>
#include<cstring>
#include<cmath>
#include<cctype>
#include<exception>
#include<climits>
#include<cfloat>
#include<iomanip>
#include<bitset>
#include<streambuf>
#include<cstdlib>
#include<ctime>
//#include"functions.h"
//#include"highprecision.h"
#define pb push_back
#define pf push_front
#define ppb pop_back
#define mp make_pair
#define np next_permutation
#define fi first
#define sc second
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vector<int> >
#define vpi vector<pair<int,int> >
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pff pair<float,float>
#define pdd pair<double,double>
#define psi pair<string,int>
#define pis pair<int,string>
#define ppi pair<pii,int>
#define pdi pair<pii,pii>
#define LN 84757
#define INF 1e9
#define LLINF 1e18
#define MAXINT 0x7fffffff
#define MAXLL 0x7fffffffffffffff
#define EPS 1e-5
#define DEPS 1e-9
#define LDEPS 1e-13
#define MOD 1000000007
#define E 2.7182818284
#define PI 3.1415926535
#define rep(a,b) for(int a=0;a<b;a++)
#define forn(a,n) for(int a=1;a<=n;a++)
#define forr(a,n) for(int a=n;a>=0;a--)
#define repn(a,n,p) for(int a=0;a<n;a+=p)
#define foreach(a,b) for(__typeof(b.begin())a=b.begin();a!=b.end();a++)
#define fillemp(a) memset(a,0,sizeof(a))
#define fillinf(a) memset(a,0x3f,sizeof(a))
#define frestream freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define stdf(a,b) freopen(a,"r",stdin);freopen(b,"w",stdout);
#define inputf(a) freopen(a,"r",stdin);
#define outputf(a) freopen(a,"w",stdout);
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define MOD 1000000007
typedef long long ll;
typedef long double ld;
using namespace std;

int main(int argc,char** argv){
	string s;
	cin>>s;
	if(s=="MON")cout<<6;
	if(s=="TUE")cout<<5;
	if(s=="WED")cout<<4;
	if(s=="THU")cout<<3;
	if(s=="FRI")cout<<2;
	if(s=="SAT")cout<<1;
	if(s=="SUN")cout<<7;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] array = new int[3];
		
		for (int i = 0; i < N; i++) {
			array[0] = sc.nextInt();
			array[1] = sc.nextInt();
			array[2] = sc.nextInt();
			
			int temp;
			if (array[0] > array[1]) {
				temp     = array[0];
				array[0] = array[1];
				array[1] = temp;
			} 
			if (array[1] > array[2]) {
				temp     = array[1];
				array[1] = array[2];
				array[2] = temp;
			}
			
			if (array[2]*array[2] ==  array[1]*array[1] + array[0]*array[0]) {
				System.out.println("YES");
			} else {
				System.out.println("NO");
			}
		}
		
	}

}

Measured memory_bytes: 23396
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pint pair<int, int>
#define pll pair<ll, ll>
#define vint vector<int >
#define vll vector<ll >
#define ALL(x) (x).begin(), (x).end()
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i,n) for (int i = 0; i < (n); ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    ll a=0,b=0;
    string string_b;
    cin >> a >> string_b;
    //cout << string_b << "\n";
    b += (int(string_b[0])-48) * 100;
    b += (int(string_b[2])-48) * 10;
    b += (int(string_b[3])-48);
    cout << a*b/100 << "\n";
    return 0;
}

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

const int MAXN = 26;
int alphabet[MAXN];


void clean()
{
    for(int i = 0; i < MAXN; ++i) alphabet[i] = 0;
}

int main()
{
    string in;
    bool out = false;
    cin >> in;
    clean();
    for(int i = 0; i < in.size() && !out ; ++i)
    {
        int pos  = in[i] - 'a';
        alphabet[pos]++;
        if(alphabet[pos] > 1)
        {
            out = true;
            cout << "no" << endl;
        }
    }

    if(!out) cout << "yes" << endl;
    
    return 0;
}

Measured memory_bytes: 256
/*  Success may not come to me immediately,
 *  but it will come definitely....
 */
#include <bits/stdc++.h>
//=====================================================================
using namespace std;
//=====================================================================
#define opt ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
//=====================================================================
#define li      int64_t
#define ld      double_t
#define ulli    uint64_t
//=====================================================================
#define rep(i,a,b)  for(i=a;i<b;i++)
#define repr(i,a,b) for(i=a;i>b;i--)
#define repi(i,v)   for(i=v.begin();i!=v.end();i++)
#define repir(i,v)  for(i=v.rbegin();i!=v.rend();i++)
#define elif        else if
#define mset(a,b)   memset(a,b,sizeof(a))
#define nl          cout<<'\n'
//=====================================================================
typedef vector<li>       vli;
typedef vector<string>   vstr;
typedef pair<li,li>      pli;
typedef pair<li,pli >    ppli;
typedef pair<li,ppli >   pppli;
typedef vector<pli >     vpli;
typedef vector<ppli >    vppli;
typedef vector<pppli >   vpppli;
//=====================================================================
#define pb  push_back
#define pob pop_back
#define pf  push_front
#define pof pop_front
#define all(v)  v.begin(),v.end()
#define itr iterator
#define rtr reverse_iterator
#define sz  size()
#define lb  lower_bound
#define ub  upper_bound
#define bs  binary_search
#define mp  make_pair
#define F   first
#define S   second
//=====================================================================
#define mod (li)(1e9+7)
#define inf (li)(1e18)
#define MX1 (li)(1e5+5)
#define MX2 (li)(1e6+5)
#define pi  acos(-1)
//=====================================================================
li power(li a,li b){li ans=1;while(b){if(b&1){ans=(ans*a)%mod;}
a=(a*a)%mod;b>>=1;}return ans;}
//=====================================================================
li mmi(li n){return power(n,mod-2);}
//=====================================================================
li two(li n){return (1LL<<n);}
//=====================================================================
void onbit(li &n,li x){n|=two(x);}
//=====================================================================
void offbit(li &n,li x){n&=~two(x);}
//=====================================================================
li cntbit(li n){li res=0;while(n and ++res)n-=n&-n;return res;}
//=====================================================================
li dx[]={-1,0,1,0},dy[]={0,-1,0,1};
//=====================================================================
/*------------------------MAIN CODE BEGINS NOW!------------------------*/

void solve(){
  li n;cin>>n;
  while(n){
    if(n%10==9){
      cout<<"Yes";
      return ;
    }
    n/=10;
  }
  cout<<"No";
}
  
int main(){
  opt
  #ifndef ONLINE_JUDGE
  #endif
  li t=1;
  //cin>>t;
  while(t--){
    solve();
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string s;
char pd[15]={'k','e','y','e','n','c','e'};
int a,b,c,x,y;
int main()
{
	getline(cin,s);
	a=s.size();a--;
	if(s[0]==pd[0]&&s[a]!=pd[6])
	{
		for(int i=0;i<=6;i++)
		{
			if(s[i]!=pd[i])
			{
				cout<<"NO";
				return 0;
			}
		}
		cout<<"YES";
	}
	else if(s[0]!=pd[0]&&s[a]==pd[6])
	{
		for(int i=0;i<=6;i++)
		{
			if(s[a-i]!=pd[6-i])
			{
				cout<<"NO";
				return 0;
			}
		}
		cout<<"YES";
	}
	else if(s[0]==pd[0]&&s[a]==pd[6])
	{
		for(int i=0;i<=15;i++)
		{
			if(s[x]==pd[x])
			{
				x++;
			}
			if(x+y==6)
			{
				cout<<"YES";
				return 0;
			}
			if(s[a-y]==pd[6-y])
			{
				y++;
			}
			if(x+y==6)
			{
				cout<<"YES";
				return 0;
			}
		}
		cout<<"NO";
	}
	else
	{
		cout<<"NO";
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
using namespace std;
long long a[100010];
map<long long , long long> mp1 , mp2;
int main()
{
	long long n;	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	long long max1=0 , max2=0;
	for(int i=1;i<=n;i+=2){
		mp1[a[i]]++;
		if(mp1[a[i]]>mp1[max1])
			max1=a[i];
	}
	for(int i=2;i<=n;i+=2){
		mp2[a[i]]++;
		if(mp2[a[i]]>mp2[max2])
			max2=a[i];
	}
	if(max1==max2){
		long long x1=0 , x2=0;
		for(int i=2;i<=n;i+=2)
			if(a[i]!=max2)
				x1=max(x1 , mp2[a[i]]);
		for(int i=1;i<=n;i+=2)
			if(a[i]!=max1)
				x2=max(x2 , mp1[a[i]]);
		
		if(mp1[max1]>mp2[max2])
			cout<<n-(mp1[max1]+x2)<<endl;
		else if(mp1[max1]<mp2[max2])
			cout<<n-(mp2[max2]+x1);
		else if(x1>=x2)
			cout<<n-(x1+mp2[max2])<<endl;
		else
			cout<<n-(x2+mp1[max1])<<endl;
	}
	else
	{
		cout<<n-(mp1[max1]+mp2[max2])<<endl;
	}
}

Measured memory_bytes: 7296
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<int>A(N);
  for (int i=0; i<N; i++)cin>>A[i];
  int MAX=abs(A[0]-A[1]);
  for (int i=0; i<N; i++){
    for (int j=i+1; j<N; j++){
      if (MAX<abs(A[i]-A[j])){
        MAX=abs(A[i]-A[j]);
      }
    }
  }
  cout<<MAX<<endl;
}

      

Measured memory_bytes: 3596
# -*- coding: utf-8 -*-


def main():
    n = int(input())
    h = list(map(int, input().split()))
    highest = 0
    ans = 0

    for i in range(n):
        if h[i] >= highest:
            ans += 1
            highest = h[i]

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;



int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int x, y;
    cin >> x >> y;

    int res = max(0, 3 + 1 - x) + max(0, 3 + 1 - y);
    if (x == 1 && y == 1) {
        res += 4;
    }
    res *= 100000;
    cout << res << '\n';
    
    return 0;
}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#include<random>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (int)(Y);++(X))
#define reps(X,S,Y) for (int (X) = (int)(S);(X) < (int)(Y);++(X))
#define rrep(X,Y) for (int (X) = (int)(Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (int)(Y)-1;(X) >= (int)(S);--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define Endl endl
#define NL <<"\n"

using namespace std;
using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
template<class T> using vv=vector<vector<T>>;
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
//#undef NUIP
#ifdef NUIP
#include "benri.h"
#else
#define out(args...)
#endif
#ifdef __cpp_init_captures
template<typename T>vector<T> table(int n, T v){ return vector<T>(n, v);}
template <class... Args> auto table(int n, Args... args){auto val = table(args...); return vector<decltype(val)>(n, move(val));}
#endif
const ll MOD=1e9+7; //998244353

int main(){
  ios_base::sync_with_stdio(false); cin.tie(0);
  cout<<fixed<<setprecision(0);
	int n;
	cin>>n;
	int m=360;
	int g=__gcd(n,m);
	cout<<m/g NL;
  return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
const ll INF = 1000000001;
vector<ll>h;
ll a,b,n;
bool isAbleToBeatAllMonsters(ll k){
    ll tmp = 0;
    ll remaining = 0;
    REP(i,n){
        remaining = h[i]-b*k;
        if(remaining>0)tmp += (remaining+(a-b-1))/(a-b);
    }
    return (tmp <= k);
}

ll binarysearch(ll ok, ll ng){
    while(llabs(ok-ng)>1){
        ll mid = (ok+ng)/2;
        if(isAbleToBeatAllMonsters(mid)){
            ok = mid;
        }
        else{
            ng = mid;
        }
    }
    return ok;
}

int main(){
    cin >> n >> a >> b;
    h = vector<ll>(n);
    REP(i,n)cin >> h[i];
    cout << binarysearch(INF,0) << endl;
    return 0;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  
  vector<int> a(n), count(1e6 + 1, 0);
  vector<bool> used(1e6 + 1, false);
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
    count.at(a.at(i))++;
  }
  
  sort(a.begin(), a.end());
  
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (count.at(a.at(i)) > 1) {
      if (used.at(a.at(i))) continue;
      int now = a.at(i);
      while (true) {
        used.at(now) = true;
        now += a.at(i);
        if (now > 1e6) break;
      }
      continue;
    }
    if (used.at(a.at(i)) == false) {
      ans += count.at(a.at(i));
      int now = a.at(i);
      while (true) {
        used.at(now) = true;
        now += a.at(i);
        if (now > 1e6) break;
      }
    }
  }
  
  cout << ans << '\n';
}

Measured memory_bytes: 8248
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


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

  int x,y;
  cin >> x >> y;
  cout << x+y/2 << endl;
  
  return 0;
    

}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<vector>
using namespace std;
typedef pair<int, int> P;
int n, ans, n_left, dis[101];
vector< vector<P> > G(101);
priority_queue< P, vector<P>, greater<P> > heap;
bool visited[101];

int main(){
   

    int u, v, w;
    scanf("%d", &n);
    n_left = n;
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            scanf("%d", &w);
            if(w==-1) continue;
            G[i].push_back(P(w, j));
        }
    }
    ans = 0;
    memset(visited, 0, sizeof(visited));
    memset(dis, 127, sizeof(dis));
    heap.push(P(0, 0));
    dis[0] = 0;
    
    while(!heap.empty() && n_left>0){
        P top = heap.top();
        heap.pop();
        u = top.second;

        if(visited[u]) continue;
        visited[u] = true;
        --n_left;
        ans += top.first;
        for(int i=0; i<G[u].size(); i++){
            v = G[u][i].second;
            if(visited[v]) continue;
            w = G[u][i].first;
            if(w<dis[v]){
                dis[v] = w;
                heap.push(P(w, v));
            }
        }
    }

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


Measured memory_bytes: 2716
package main 

import (
        "fmt"
)

func main () {
        var n, p, w, g, y int
        var s string
        fmt.Scan(&n)
        for i := 0 ; i < n ; i ++ {
                fmt.Scan(&s)
                if s == "P"{
                        p = 1
                } else if s == "W"{
                        w = 1
                }  else if s == "G"{
                        g = 1
                }  else if s == "Y" {
                        y = 1
                }
        }
        an := p + w + g + y 
        if an ==  3{
                fmt.Println("Three")
        }  else if an == 4 {
                fmt.Println("Four")
        
}}


Measured memory_bytes: 512
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  int n; cin >> n;
  vector<ll> a(n); REP(i, n) cin >> a[i];
  if (count(ALL(a), 0) > 0) {
    cout << "0\n";
    return 0;
  }
  ll ans = 1;
  REP(i, n) {
    if (log10(ans) + log10(a[i]) > 18 + EPS) {
      cout << "-1\n";
      return 0;
    }
    ans *= a[i];
  }
  cout << (ans > 1000000000000000000 ? -1 : ans) << '\n';
  return 0;
}


Measured memory_bytes: 3996
#include <stdio.h>

int solve(int, int);
int n, A[20];

int main(){
  int i, q, m;

  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }

  scanf("%d",&q);

  for(i=0;i<q;i++){
    scanf("%d",&m);
    if(solve(0,m))printf("yes\n");
    else printf("no\n");
  }
  return 0;
}

int solve(int i,int m){
  int res;
  if(m==0) return 1;
  if(i>=n) return 0;
  res = solve(i+1, m)||solve(i+1, m-A[i]);
  return res;
}

Measured memory_bytes: 580
#include <iostream>
#include <cmath>
#include <utility>

using namespace std;
int main (){
    int n,m;
    cin >> n >> m;
    int s[m],c[m];
    for (int k = 0; k < m; k++){
        cin >> s[k] >> c[k];
    }
    int ulim=pow(10,n);
    int llim=pow(10,n-1);
//    cout << llim << " " << ulim << "\n";
    if(n==1) llim=0;
    int dig[n];
    int k=llim;
    int kc;
    bool jud;
    while(k<ulim){
//        cout << k << "\n";
        kc=k;
        for (int j = 0; j < n; j++){
            dig[j]=kc%10;
            kc/=10;
        }
        jud=true;
        for (int j = 0; j < m; j++){
            if(dig[n-s[j]]!=c[j]) jud=false;
        }
        if(jud) break;
        k++;
    }
    if(k==ulim) cout << "-1\n";
    else        cout << k << "\n";
}

Measured memory_bytes: 256
import sys


def input():
    return sys.stdin.readline().rstrip()


def main():
    S = input()
    T = input()
    dictS =dict()
    dictT =dict()

    for i in range(len(S)):
        if S[i] in dictS:
            if dictS[S[i]] !=T[i]:
                print("No")
                exit()
        else:
            dictS[S[i]] =T[i]

        if T[i] in dictT:
            if dictT[T[i]] !=S[i]:
                print("No")
                exit()
        else:
            dictT[T[i]] =S[i]

    print("Yes")



if __name__ == "__main__":
    main()


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

int main(){

    int N;
    cin >> N;

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

    sort(v, v+N);
    //for(int i = 0; i < N; i++){cout << v[i] << endl;}

    double ans = v[0];

    for(int i = 1; i < N; i++){
        ans = (ans + v[i])/2.0;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256