akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<iostream>
#include<algorithm> // sort(ALL())
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue> // push(), front(), pop() 先入れ先出し
#include<map> // 連想配列 map<string, int>
#include<iomanip>
#include<set>
#include<utility>
using namespace std;
#define FOR(i, a, b) for(int i=(a); i<(b);  i++)
#define REP(i, n)    for(int i=0;   i<(n);  i++)
#define REP1(i, n)   for(int i=1;   i<=(n); i++)
#define pb push_back
#define mp make_pair
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define EPS 1e-7
#define ALL(obj) (obj).begin(), (obj).end()
using ul    = unsigned long;
using ll = long long;
using ull    = unsigned long long;
using ld    = long double;
using vint  = vector<int>;
using vll   = vector<ll>;
using pint  = pair<int, int>;
using pll   = pair<ll, ll>;
using vpint = vector<pint>;
using vpll  = vector<pll>;
const int INF = (int)1e9 + 1;
const int MOD = (int)1e9 + 7;
#define INT(argu) (int)(argu+EPS)

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

	ull a;
	double b;

	cin >> a >> b;

 	ull c = INT(b*100);
	a = a*c;

  cout << a/100LL << endl;

  return 0;
}


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

#ifdef DEBUG
    #define IFD if(true)
#else
    #define IFD if(false)
#endif

int main()
{
    int N, Q;
    string S;
    int cnt[100000];

    cin >> N >> Q;
    cin >> S;

    cnt[0] = 0;
    for(int i = 0; i < N - 1; i++) {
        cnt[i + 1] = cnt[i];
        if(S[i] == 'A' && S[i + 1] == 'C') {
            cnt[i + 1]++;
        }
    }

    for(int i = 0; i < Q; i++) {
        int l, r;
        cin >> l >> r;
        cout << cnt[r - 1] - cnt[l - 1] << endl;
    }

    return 0;
}


Measured memory_bytes: 1408
#include <stdio.h>


int main(void){
	int n,m;
	scanf("%d %d",&n,&m);
	int a[m],b[m];
	for(int i=0;i<m;i++) scanf("%d %d",&a[i],&b[i]);
	int check[n];
	for(int i=0;i<n;i++) check[i]=0;

	for(int i=0;i<m;i++){
		if(a[i]==1){check[b[i]-1]++;}
		if(b[i]==n){check[a[i]-1]++;}
	}

	int answer=0;
	for(int i=0;i<n;i++){
		if(check[i]==2) answer=1;
	}


	if(answer==1){
		printf("POSSIBLE");
	}else{printf("IMPOSSIBLE");}
	return 0;
} 

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

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

	int ans;
	int longer;
	if (h > w) {
		longer = h;
	}
	else {
		longer = w;
	}

	if (n % longer == 0) {
		ans = n / longer;
	}
	else {
		ans = n / longer + 1;
	}
	

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 0x3f3f3f3f
inline int read(){
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return x*f;
}
ll ans=0,a,b,c;
int main(){
//	freopen("a.in","r",stdin);
	a=read();ans=read();read();b=read();c=read();read();read();
	if(!a||!b||!c){printf("%lld\n",ans+a/2*a+b/2*2+c/2*2);return 0;}
	if(a%2==b%2&&b%2==c%2){printf("%lld\n",ans+a+b+c);return 0;}
	printf("%lld\n",ans+a+b+c-1);
	return 0;
}

Measured memory_bytes: 256
import sys

def gcd(a, b): return gcd(b, a % b) if b else abs(a)
def lcm(a, b): return abs(a // gcd(a, b) * b)

n, *a = map(int, sys.stdin.read().split())

def main():
    lg = [0] * n
    rg = [0] * n
    for i in range(1, n):
        lg[i] = gcd(lg[i-1], a[i-1])
    for i in range(n-2, -1, -1):
        rg[i] = gcd(rg[i+1], a[i+1])
    res = max([gcd(lg[i], rg[i]) for i in range(n)])
    print(res)

if __name__ ==  '__main__':
    main()

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

#define INF 10000000000000

int main(){
  long long int N, M;
  long long int a[2][100] = {}, c[2][100] = {};

  cin>>N>>M;
  
  for(int i = 1; i <= N; i++){
    cin>>a[0][i]>>a[1][i];
  }

  for(int i = 1; i <= M; i++){
    cin>>c[0][i]>>c[1][i];
  }

  for(int i = 1; i <= N; i++){//cout<<i<<endl;
    long long int mi = INF ,ans = 1;
    for(int j = 1; j <= M; j++){//cout<<j<<endl;
      if(fabs(a[0][i]-c[0][j]) + fabs(a[1][i]-c[1][j]) < mi){
	ans = j;
	mi = fabs(a[0][i]-c[0][j]) + fabs(a[1][i]-c[1][j]);
      }
    }  cout<<ans<<endl;
   }

  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int A,B;
  cin>>A>>B;
  if(A!=1&&B!=1){
    if(A>B)cout<<"Alice"<<endl;
    else if(A<B)cout<<"Bob"<<endl;
    else cout<<"Draw"<<endl;
  }
  else if(A==1&&B!=1)cout<<"Alice"<<endl;
  else if(A!=1&&B==1)cout<<"Bob"<<endl;
  else cout<<"Draw"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define F first
#define S second

using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef pair<int, int> pint;
const int Inf = 1e9;
const double EPS = 1e-9;



int main()
{
  int x ;
  cin >> x ;
  
  if(x>=64){
    cout << 64 <<endl ;
  }
  else if(x>=32){
    cout << 32 <<endl ;
  }
  else if(x>=16){
    cout << 16 <<endl ;
  }
  else if(x>=8){
    cout << 8 <<endl ;
  }
  else if(x>=4){
    cout << 4 <<endl ;
  }
  else if(x>=2){
    cout << 2 <<endl ;
  }
  else{
    cout << 1 <<endl ;
  }

  return 0 ;
}


Measured memory_bytes: 256
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")
al = "abcdefghijklmnopqrstuvwxyz"
AL = al.upper()

h,w = I()
A = []
for i in range(h):
    A.append([int(i) for i in input().split()])
Ans = []
for i in range(h):
    for j in range(w-1):
        if A[i][j] % 2==1:
            Ans.append([i+1,j+1,i+1,j+2])
            A[i][j+1] += 1

for i in range(h-1):
    if A[i][w-1] % 2 == 1:
        Ans.append([i+1,w,i+2,w])
        A[i+1][w-1] += 1

print(len(Ans))
for ans in Ans:
    print(*ans)

Measured memory_bytes: 33716
#include <iostream>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <algorithm>
#include <cassert>
#include <string>
#include <climits>
#include <numeric>

#define all(x) begin(x),end(x)

using namespace std;
using ll = long long;

int main()
{
	int n, k;
	cin >> n >> k;
	if (n % k)
		cout << 1 << endl;
	else
		cout << 0 << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    string s;  cin>>s;
    string ans;
  
   for(int i=0;i<s.size();i++)
   {
       ans +='x';
   }

    cout<<ans<<endl;
  
    return 0;

}


Measured memory_bytes: 256
H,W = map(int,input().split())
C = [list(map(int,input().split())) for i in range(10)]
A = [list(map(int,input().split())) for i in range(H)]

for k in range(10):
    for i in range(10):
        for j in range(10):
            C[i][j] = min(C[i][j], C[i][k] + C[k][j])
ans = 0
for row in A:
    for a in row:
        if a==-1: continue
        ans += C[a][1]
print(ans)

Measured memory_bytes: 3316
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.lang.Math.*;

// 2012/12/25
// Up Above the World So High
public class Main{
	Scanner sc=new Scanner(System.in);

	double EPS=1e-6;

	int n;
	P[] ps;
	double rad;

	void run(){
		n=sc.nextInt();
		ps=new P[n];
		for(int i=0; i<n; i++){
			int x=sc.nextInt();
			int y=sc.nextInt();
			int z=sc.nextInt();
			ps[i]=new P(x, y, z);
		}
		rad=sc.nextInt();
		solve();
	}

	void solve(){
		rad=toRadians(rad);
		int max=1;
		Random rand=new Random(0);
		for(int trial=0; trial<10; trial++){
			double d1=rand.nextDouble()*PI, d2=rand.nextDouble()*PI, d3=rand
					.nextDouble()*PI;
			for(int i=0; i<n; i++){
				ps[i]=ps[i].div(ps[i].norm()).rotX(d1).rotY(d2).rotZ(d3);
			}
			double cos2=cos(rad)*cos(rad);
			for(int i=0; i<n; i++){
				for(int j=i+1; j<n; j++){
					P P=ps[i], Q=ps[j];
					double A, B, C, D;
					{
						double a=-(P.x*Q.z-Q.x*P.z), b=(Q.z-P.z)*cos2, c=(P.y
								*Q.z-Q.y*P.z);
						A=a/c;
						B=b/c;
					}
					{
						double a=-(P.x*Q.y-Q.x*P.y), b=(Q.y-P.y)*cos2, c=(P.z
								*Q.y-Q.z*P.y);
						C=a/c;
						D=b/c;
					}
					for(double vx : quad(1+A*A+C*C, 2*(A*B+C*D), B*B+D*D-cos2)){
						P v=new P(vx, A*vx+B, C*vx+D);
						int count=0;
						for(int k=0; k<n; k++){
							if(acos(v.dot(ps[k])/v.norm())<rad+EPS){
								count++;
							}
						}
						max=max(max, count);
					}
				}
			}
		}
		println(max+"");
	}

	double[] quad(double a, double b, double c){
		double D=b*b-4*a*c;
		if(D+EPS<0){
			return new double[0];
		}
		D=max(D, 0);
		return new double[]{(-b-sqrt(D))/(2*a), 2*c/(-b-sqrt(D))};
	}

	class P{
		double x, y, z;

		P(double x, double y, double z){
			this.x=x;
			this.y=y;
			this.z=z;

		}

		double dot(P p){
			return x*p.x+y*p.y+z*p.z;
		}

		P div(double d){
			return new P(x/d, y/d, z/d);
		}

		double norm(){
			return sqrt(x*x+y*y+z*z);
		}

		P rotX(double d){
			return new P(x, y*cos(d)-z*sin(d), y*sin(d)+z*cos(d));
		}

		P rotY(double d){
			return new P(z*sin(d)+x*cos(d), y, z*cos(d)-x*sin(d));
		}

		P rotZ(double d){
			return new P(x*cos(d)-y*sin(d), x*sin(d)+y*cos(d), z);
		}
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		new Main().run();
	}
}

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

//出力
void Yes(){ cout << "Yes" << endl; }
void yes(){ cout << "yes" << endl; }
void No(){ cout << "No" << endl; }
void no(){ cout << "no" << endl; }
void Possible(){ cout << "Possible" << endl; }
void possible(){ cout << "possible" << endl; }
void Imossible(){ cout << "Impossible" << endl; }
void imossible(){ cout << "impossible" << endl; }

//マクロ
#define INF 10010010010010010
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a = max(a, b)
#define sort(a) sort(a.begin(), a.end())
#define reverse(a) reverse(a.begin(), a.end())

vector<long long> dijk(long long s, long long v, vector<vector<pair<long long, long long> > > adjlist){
    
    
    priority_queue<pair<long long, long long> > wait;
    vector<long long> result(v, INF);

    //スタート地点を追加
    result[s] = 0;
    wait.push(make_pair(0, s));

    //ダイクストラ本体
    while(!wait.empty()){    //waitが空になるまで

        long long nowpoint = wait.top().second;
        long long nowcost = -wait.top().first;
        wait.pop();

        if(result[nowpoint] < nowcost) continue;


        //今いる頂点と隣接しているすべての頂点をなめる
        for(int i = 0; i < adjlist[nowpoint].size(); i++){

            long long nextpoint = adjlist[nowpoint][i].second;
            long long nextcost = nowcost + adjlist[nowpoint][i].first;
            //現時点より安く到達できそうであれば、結果を更新して優先度付きキューに格納
            if(result[nextpoint] > nextcost){
                result[nextpoint] = nextcost;
                wait.push(make_pair(-nextcost, nextpoint));
            }
        }
    }
    
    return result;         //結果列を返す
}

int main(){
    
    int n; cin >> n;
    vector<vector<pair<long long, long long> > > adjlist(n);      //first := 行先　second := コスト
    for(int i = 0; i < n - 1; i++){
        long long a, b, c; cin >> a >> b >> c;
        a--;
        b--;
        adjlist[a].push_back(make_pair(c, b));     //もし無向グラフならもう一つやる
        adjlist[b].push_back(make_pair(c, a));     //もし無向グラフならもう一つやる
    }

    long long q, k; cin >> q >> k;
    k--;
    vector<long long> result(n);
    result = dijk(k, n, adjlist);

    for(int i = 0; i < q; i++){
        long long x, y; cin >> x >> y;
        x--; y--;
        cout << result[x] + result[y] << endl;
    }
    return 0;
}

Measured memory_bytes: 18928
#include <bits/stdc++.h>
#define ll long long
#define fori(n) for(long long i=0;i<n;i++)
#define forj(n) for(long long j=0;j<n;j++)
#define sp(n) setprecision(n)
#define mp make_pair
#define mt make_tuple
#define pi 3.14159265358979323846264
#define MOD 1000000007

using namespace std;
int primeFactors(ll n)  
{  ll f=0;
    // Print the number of 2s that divide n  
    while (n % 2 == 0)  
    {  
        f++;
        n = n/2;  
    }  
  
    // n must be odd at this point. So we can skip  
    // one element (Note i = i +2)  
    for (int i = 3; i <= sqrt(n); i = i + 2)  
    {  
        // While i divides n, print i and divide n  
        while (n % i == 0)  
        {  
            f++; 
            n = n/i;  
        }  
    }  
  
    // This condition is to handle the case when n  
    // is a prime number greater than 2  
    if (n > 2)  
        f++;
        
 return f;        
}  
  
bool isPrime(long long k){
    if(k<=1){return false;}
    if(k==2){return true;}
    if(k%2==0){return false;}
    long long i = 3;
   while (i*i <= k) {if (k % i == 0) {return false;}i += 2;}
return true;
}
 
ll binomialCoeff(ll n, ll k){
    ll C[n + 1][k + 1];ll i, j;
    for (i = 0; i <= n; i++){
        for (j = 0; j <= min(i, k); j++){
            if (j == 0 || j == i){C[i][j] = 1;}
            else{C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]);}}}
    return C[n][k];
 }
 
ll gcd(ll a, ll b){if (b == 0)
        return a;return gcd(b, a % b);}
 
ll expmod(ll n,ll k,ll m){
    ll ans;
    ans=1;
    fori(k){
        ans=(ans*n)%m;
    }
    return ans;
}
//define temp-functions below
 
 
//some definitions and global variables
vector<ll> primes;
void storePrime(ll n){
    fori(n){
        if(isPrime(i+1)&&(n%(i+1)==0)){primes.push_back(i+1);}
    }
}
 
int main(){ //make cin/cout faster
 ios_base::sync_with_stdio(false);
 cin.tie(NULL);cout.tie(NULL);

 
      ll n;cin>>n;
    long double x=0;
    ll a[n];for(int i=0;i<n;i++) {cin>>a[i];x=x+a[i];}
    ll k;k=x/n;x=x/n;
    if((x-k)>(k+1-x)){
        k=k+1;
        
    }
    ll p=0;
    for(int i=0;i<n;i++){p=p+(a[i]-k)*(a[i]-k);}
    
      cout<<p;
      
      
      
      
      
      
      
      
      
    

return 0;}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define STATIC_ASSERT(expr) static_assert(expr, #expr)
using namespace std;
using ll = long long;
// clang-format off
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
// clang-format on
const string YES = "Yes";
const string NO = "No";

void solve(long long N) {
  int m9[81] = {};
  REP(i, 9) {
    REP(j, 9) { m9[i * 9 + j] = (i + 1) * (j + 1); }
  }
  if (find(begin(m9), end(m9), N) != end(m9)) {
    cout << YES << endl;
  } else {
    cout << NO << endl;
  }
}

int main() {
  long long N;
  scanf("%lld", &N);
  solve(N);
  return 0;
}


Measured memory_bytes: 256
from scipy.special import comb
import numpy as np
def get_keta_plusnum(n,m):
    if n<=m:
        print("error")
    else:
        hit_num=[0 for i in range(n)]
        for keta in range(1,n-m+1):
            for j in range(n+1-keta):
                if j!=n-keta:
                    hit_num[j]+=10**(keta-1)*comb(n-1-keta,m-1)
                else:
                    hit_num[j]+=10**(keta-1)*comb(n-keta,m)
    return np.array(hit_num,dtype="int64")

s=input()
n=len(s)

hit_num=np.array([0 for i in range(n)])

for m in range(n):
    hit_num+=get_keta_plusnum(n,m)
s=np.array([int(i) for i in s])
print(np.dot(hit_num,s))



Measured memory_bytes: 42524
#include<bits/stdc++.h>
using namespace std;
int a[10];
int main()
{

  for(int i=1;i<=5;i++)
  {
  	cin>>a[i];
  	if(a[i]==0)
  	{
  	cout<<i;
  	return 0;
	  }
  }
   return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

int main(){
  int N;
  cin>>N;
  vector<ll> A(N);
  rep(i,N) cin>>A[i];

  ll sum=0;
  rep(i,N) sum+=A[i];

  ll mid1=sum/2;
  ll mid2=(sum+1)/2;
  ll ans=sum%2;

  ll res=sum+10;
  ll now=0;
  for(int i=0;i<N;i++){
    now+=A[i];
    res=min(res,abs(now-mid1)*2);
    res=min(res,abs(now-mid2)*2);
  }

  cout<<ans+res<<endl;

  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

bool find(set<int> S, int a) {
    if (S.find(a) != S.end()) return true;
    return false;
}

int main() {
    vector<vector<int>> A(3, vector<int>(3));
    REP(i, 0, 3) cin >> A[i][0] >> A[i][1] >> A[i][2];

    int N; cin >> N;
    set<int> S;
    REP(i, 0, N) {
        int b; cin >> b;
        S.insert(b);
    }

    REP(i, 0, 3) {
        if (find(S, A[i][0]) && find(S, A[i][1]) && find(S, A[i][2])) {
            cout << "Yes" << endl;
            return 0;
        }
        if (find(S, A[0][i]) && find(S, A[1][i]) && find(S, A[2][i])) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    if (find(S, A[0][0]) && find(S, A[1][1]) && find(S, A[2][2])) {
        cout << "Yes" << endl;
        return 0;
    }
    if (find(S, A[0][2]) && find(S, A[1][1]) && find(S, A[2][0])) {
        cout << "Yes" << endl;
        return 0;
    }

    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
//AUTHOR: RAVAN_2070
//PUNE INSTITUTE OF COMPUTER TECHNOLOGY
/*
        PEOPLE'S LIVES DON'T END WHEN THEY DIE.
        IT ENDS WHEN THEY LOSE FAITH
                                     -ITACHI UCHIHA
        EXPLAINATION BELOW->
*/
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<pair<ll,ll>> vii;
typedef pair<ll,ll> pii;
typedef map<ll,ll> mii;
#define MOD7 1000000007
#define MOD9 1000000009
#define pi 3.1415926535
#define Test_cases ll TC;cin>>TC;while(TC--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define sp(x) fixed<<setprecision(x)
#define sz(x) (ll)(x.size())
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
void solve()
{
  ll A[3][3];
  map<ll,ll>M;
  ll i,j;
  fo(i,0,3)
  fo(j,0,3)
  {
      cin>>A[i][j];
      M[A[i][j]]++;
  }
  
  ll q,t;cin>>q;
  while(q--)
  {
      cin>>t;
      if(M[t])
      {
          ll flag=0;
          fo(i,0,3)
          {
              fo(j,0,3)
              {
                if(t==A[i][j]){A[i][j]=-1;flag=1;break;}
              }
              if(flag)break;
          }
          M[t]--;
      }
  }
   
  fo(i,0,3)
  {
      ll flag=1;
      fo(j,0,3)
      {
          if(A[i][j]!=-1){flag=0;break;}
      }
      if(flag==1){cout<<"Yes\n";return;}
  }
  
  
  fo(i,0,3)
  {
      ll flag=1;
      fo(j,0,3)
      {
          if(A[j][i]!=-1){flag=0;break;}
      }
      if(flag==1){cout<<"Yes\n";return;}
  }
  
  if(A[0][0]+A[1][1]+A[2][2]==-3||A[0][2]+A[1][1]+A[2][0]==-3){cout<<"Yes\n";return;}
  
  cout<<"No\n";
}
int main()
{
   fastio
   solve();
  return 0;
}


Measured memory_bytes: 256
# coding-utf8 #

n, y = map(int, input().split())

ans1 = -1
ans2 = -1
ans3 = -1


for i in range(n + 1):
  for j in range(n + 1):
    sum = 10000 * i + 5000 * j + 1000 * (n - i -j)

    if sum == y and n - i -j >= 0:
      ans1 = i
      ans2 = j
      ans3 = n - i - j

print("{} {} {}".format(ans1, ans2, ans3))

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

int main() {
	const ll INF = 1e18;
	int N, K;
	cin >> N >> K;
	vector<ll> h(N + 1, 0);
	for (int i = 1; i <= N; ++i) { cin >> h[i]; }

	vector<ll> dp(N + 1, INF);
	dp[1] = 0;
	for (int i = 1; i < N; ++i) {
		for (int j = i; j <= min(i + K, N); ++j) {
			ll cost = abs(h[i] - h[j]);
			dp[j] = min(dp[j], dp[i] + cost);
		}
	}

	cout << dp[N] << endl;

	return 0;
}


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

using namespace std;

int main(){
  int n, m, x, y;
  cin >> n >> m;

  cin >> x >> y;

  for ( int i = 0; i < n; i++ ){
    int tmp;
    cin >> tmp;
    if ( tmp > x ){
      x = tmp;
    }
  }
  for ( int i = 0; i < m; i++ ){
    int tmp;
    cin >> tmp;
    if ( tmp < y ){
      y = tmp;
    }
  }
  if ( x < y )
    cout << "No War" << endl;
  else 
    cout << "War" << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
const int mod = 1000000007;
#define ll long long

int main()
{
	int N, A, B;
	string S;
	cin >> N >> A >> B >> S;
	int count = 0, o = 0;
	for (int i = 0; i < N; i++) {
		if (S[i] == 'a') {
			if (count < A + B) {
				cout << "Yes" << endl;
				count++;
			}
			else cout << "No" << endl;
		}
		else if (S[i] == 'b') {
			o++;
			if (count < A + B && o <= B) {
				cout << "Yes" << endl;
				count++;
			}
			else cout << "No" << endl;
		}
		else cout << "No" << endl;
	}
}

Measured memory_bytes: 896
#include<iostream>

using namespace std;
int main()
{
    string s;
    int n;
    cin>>n>>s;int sum=0,i=0;
    while(s[i]!='\0'){
          if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C'){
             sum++;
          }
       i++;
    }
    cout<<sum<<endl;


    return 0;
}


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

int main(){
  int n;
  cin>>n;
  bool num[30]={false};
  int a[30];
  for(int i=0;i<n;i++) {
    cin>>a[i];
  }
  for(int i=0;i<(n-1);++i){
    if(i==0) {
      if(a[0]+1==a[1]) num[0]=true;
    }
    if(a[i]+1==a[i+1]) num[i]=true;
  }
  int sum=0;
  int c[30];
  for(int i=0;i<n;++i) {
    cin>>c[i];
    sum+=c[i];
  }
  for(int i=0;i<(n-1);i++){
    cin>>c[i];
  }
  for(int i=0;i<n;++i){
    if(num[i]==true){
       sum+=c[a[i]-1];
    }
  }
  
  cout<<sum<<endl;
  
}
 
  

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

int main()  {
  string g;
  int y, m, d;

  while (cin >> g, g != "#") {
    cin >> y >> m >> d;
    if (y > 31 || (y == 31 && m > 4))
      cout << "? " << y-30 << ' ' << m << ' ' << d << endl;
    else
      cout << g << ' ' << y << ' ' << m << ' ' << d << endl;
  }
  return 0;
}


Measured memory_bytes: 3148
#include<bits/stdc++.h>
using namespace std;
#define loop(i,a,n) for(int i=a; i<n; i++)
#define rloop(i,a,n) for(int i=a; i>=n; i--)
#define lli long long int
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ff first
#define ss second
#define pb push_back

int main(){

	fastIO

	int n,m;
	cin>>n>>m;

	int grid[n][m];
	char ch;

	loop(i,0,n){
		loop(j,0,m){
			cin>>ch;
			if(ch=='.')
				grid[i][j]=0;
			else
				grid[i][j]=1;
		}
	}

	int dp[n][m];
	dp[0][0]=1;
	loop(i,1,m){
		if(grid[0][i]==0)
			dp[0][i]=dp[0][i-1];
		else
			dp[0][i]=0;
	}
	loop(i,1,n){
		if(grid[i][0]==0)
			dp[i][0]=dp[i-1][0];
		else
			dp[i][0]=0;
	}

	loop(i,1,n){
		loop(j,1,m){
			if(grid[i][j]==1)
				dp[i][j]=0;
			else
				dp[i][j]=(dp[i-1][j]+dp[i][j-1])%1000000007;
			//cout<<dp[i][j]<<" ";
		}
		//cout<<"\n";	
	}
	cout<<dp[n-1][m-1];
}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define FORR(I,A,B) for(ll I = ((B)-1); I >= (A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;
#define pri(a) cout << (a) << endl


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s,k;
	cin >> s;
	k += s[0];
	FOR(i,1,s.size()){
		if(s[i]!=k[k.size()-1]){
			k += s[i];
		}
	}
	cout << k.size()-1 << endl;
}


Measured memory_bytes: 592
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int n,a[120000];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	sort(a+1,a+1+n);
	int ans=0;
	for(int i=1;i<=n;i++){
		if((a[i]-a[i-1])&1)ans^=(n-i+1);
	}
	if(ans==0)printf("second\n");
	else printf("first\n");
}

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

int main() {
	int A, B, C, D, E, F;
	cin >> A >> B >> C >> D >> E >> F;
	cout << A + B + C + D + E + F - min(A, min(B, min(C, D))) - min(E, F) << endl;
}


Measured memory_bytes: 3084
#if defined(LOCAL)
// #define RANDOM_TEST
#define PROBLEM_NAME "D"
const double _max_double_error = 1e-9;
#include "testutils.h"
#endif
#include <bits/stdc++.h>

using namespace std;

using vi = vector<int>; using vvi = vector<vi>;
using ii = pair<int,int>; using vii = vector<ii>;
using l = long long; using vl = vector<l>; using vvl = vector<vl>;
using ll = pair<l,l>; using vll = vector<ll>; using vvll = vector<vll>;
using lu = unsigned long long;
using vb = vector<bool>; using vvb = vector<vb>;
using vd = vector<double>; using vvd = vector<vd>;
using mll = unordered_map<l, l>;
const l INF = numeric_limits<int>::max();
const double EPS = 1e-10; static constexpr auto PI = acos(-1);
const l e0=1, e3=1000, e5=100000, e6=10*e5, e7=10*e6, e8=10*e7, e9=10*e8;
const char lf = '\n';
#define all(x) begin(x), end(x)
#define F(a,b,c) for (l a = l(b); a < l(c); a++)
#define B(a,b,c) for (l a = l(b); a > l(c); a--)

#if defined(LOCAL)
bool local = true;
#define L(x...) debug(x)
#else
bool local = false;
#define L(x, ...) (x)
#endif
struct VoidStream { void operator&(std::ostream&) { } };
#define LOG !(local) ? (void) 0 : VoidStream() & cerr

struct disjoint_set { // set of [0..n-1]
  vl parent;
  l components_count_;

  disjoint_set(size_t n) {
    components_count_ = n;
    parent.resize(n);
    for (size_t i = 0; i < n; i++) parent[i] = i;
  }
  l get_parent(l i) {
    if (parent[i] != i) parent[i] = get_parent(parent[i]);
    return parent[i];
  }
  bool connected(l i, l j) { return get_parent(i) == get_parent(j); }
  void connect(l i, l j) {
    i = get_parent(i);
    j = get_parent(j);
    if (i != j) {
      parent[i] = j;
      components_count_--;
    }
  }
  l components_count() { return components_count_; }
};


void solve(istream& cin, ostream& cout) {
  l n;
  while (cin >> n) {
    vll xx, yy;
    F(i, 0, n) {
      l x, y; cin >> x >> y;
      xx.emplace_back(x, i);
      yy.emplace_back(y, i);
    }
    sort(all(xx));
    sort(all(yy));
    vector<tuple<l, l, l>> dd;
    F(i, 1, n) {
      dd.emplace_back(xx[i].first - xx[i - 1].first, xx[i].second, xx[i - 1].second);
      dd.emplace_back(yy[i].first - yy[i - 1].first, yy[i].second, yy[i - 1].second);
    }
    sort(all(dd));
    disjoint_set s(n);
    l answer = 0;
    for (auto c : dd) {
      if (s.connected(get<1>(c), get<2>(c))) continue;
      s.connect(get<1>(c), get<2>(c));
      answer += get<0>(c);
    }
    cout << answer << lf;
  }
}

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  cout << fixed << setprecision(15);
#if defined(LOCAL)
  maybe_run_tests(cin, cout);
#else
  solve(cin, cout);
#endif
}


Measured memory_bytes: 12896
from fractions import gcd
n,k = map(int,input().split())
a = [int(i) for i in input().split()]
g = a[0]
for i in a:
  g = gcd(g,i)
  
if k%g != 0:
  print('IMPOSSIBLE')
elif k<=max(a):
  print('POSSIBLE')
else:
  print('IMPOSSIBLE')

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

int main() {
    int64_t h, w;
    cin >> h >> w;
    int64_t hw = h * w;
    int64_t ans;
    if (hw % 2 == 0) ans = hw / 2;
    else ans = (hw + 1) / 2;
    if (h == 1 || w == 1) ans = 1;
    cout << ans << endl;
}

Measured memory_bytes: 256
c=int(input())
l=[]
b=''
f=False
for i in range(c):
	a=input()
	if l.count(a)>0 or (b!='' and a[0]!=b[-1]):
		f=True
	b=a
	l.append(a)
if f:
	print('No')
else:
	print('Yes')

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

int main() {
  int n; cin >> n;
  vector<pair<int, int>> v(n);
  vector<int> city(n);
  for (int i = 0; i < n; i++) {
    int x, y;
    scanf("%d %d", &x, &y);
    v[i] = make_pair(x, y);
    city[i] = i;
  }
  double sumleng = 0.00000000;
  do {
    double leng = 0.00000000;
    for(int i = 1; i < n; i++) {
      int mae = city[i-1], ato = city[i];
      int dx = v[ato].first - v[mae].first, dy = v[ato].second - v[mae].second;
      leng += sqrt(dx*dx + dy*dy);
    }
    sumleng += leng;
  } while (next_permutation(city.begin(), city.end()));
  int route = 1;
  while(n > 1) {
    route *= n;
    n--;
  }
  cout << setprecision(14);
  cout << sumleng / (double)route;
}

Measured memory_bytes: 3836
// ConsoleApplication.cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//

#include "stdio.h"
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <numeric>
#include <string>
#include <vector>

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> S(n);
	for (int& i : S) cin >> i;
	sort(S.begin(), S.end());

	int q;
	cin >> q;
	vector<int> T(q);
	for (int& i : T) cin >> i;
	sort(T.begin(), T.end());
	
	vector<int> r;
	r.reserve(T.size());
	set_intersection(S.begin(), S.end(), T.begin(), T.end(), back_inserter(r));
	cout << to_string(r.size()) << endl;

	return 0;
}


Measured memory_bytes: 3280
#include <iostream> // cout, endl, cin
#include <iomanip>
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <numeric>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
const int INF = 1001001001;

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

    for(char c : N)
    {
        if(c == '9')
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;

}

Measured memory_bytes: 256
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int main() {
  long long l;
  int n;
  cin >> l >> n;
  vector<long long> x(n + 2), y(n + 2);
  x[n + 1] = l;
  y[0] = l;
  for (int i = 1; i <= n; i++)
    cin >> x[i];
  for (int i = 1; i <= n; i++)
    y[i] = l - x[i];
  if (n == 1) {
    cout << max(x[1], y[1]) << endl;
    return 0;
  }
  if (n == 2) {
    cout << max(max(x[2], y[1]), max(x[1] * 2 + y[2], x[1] + y[2] * 2)) << endl;
    return 0;
  }
  long long ans = max(x[n], y[1]);
  long long ls = x[1], rs = y[2] * 2;
  ans = max(ans, ls + rs);
  ans = max(ans, ls + rs + x[1] - (x[n + 1] - x[2]) + (x[n + 1] - x[3]) * 2);
  for (int i = 2; i <= n / 2; i++) {
    ls += x[i] - x[i - 1];
    ls += x[i - 1] * 2;
    rs -= (x[i + i - 1] - x[i]) * 2;
    rs += (x[n + 1] - x[i + i]) * 2;
    ans = max(ans, ls + rs);
    ans = max(ans, ls + rs + x[i] - (x[n + 1] - x[i + 1]) +
                       (x[n + 1] - x[i + i + 1]) * 2);
  }
  reverse(x.begin(), x.end());
  reverse(y.begin(), y.end());
  ls = y[1], rs = x[2] * 2;
  ans = max(ans, ls + rs);
  ans = max(ans, ls + rs + y[1] - (y[n + 1] - y[2]) + (y[n + 1] - y[3]) * 2);
  for (int i = 2; i <= n / 2; i++) {
    ls += y[i] - y[i - 1];
    ls += y[i - 1] * 2;
    rs -= (y[i + i - 1] - y[i]) * 2;
    rs += (y[n + 1] - y[i + i]) * 2;
    ans = max(ans, ls + rs);
    ans = max(ans, ls + rs + y[i] - (y[n + 1] - y[i + 1]) +
                       (y[n + 1] - y[i + i + 1]) * 2);
  }

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


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


#define	ll_int	long long int
#define	BUCKET_SIZE	100000


typedef struct data_t{
	char key[21];
	ll_int x;
	struct data_t *next;
} DATA_T;

DATA_T *S[BUCKET_SIZE];


// ハッシュテーブルの初期化
void Init()
{
	int i;

	for(i = 0; i < BUCKET_SIZE; i++)
		S[i] = NULL;
}


ll_int Hash(char *key)
{
	int i;
	int sum = 0;

	for(i = 0; i < strlen(key); i++)
		sum += key[i];

	return sum % BUCKET_SIZE;
}


DATA_T *Get(char *key)
{
	ll_int h;
	DATA_T *p;

	h = Hash(key);

	for(p = S[h]; p != NULL; p = p->next)
		if(!strcmp(key, p->key))
			return p;

	return NULL;
}


void Insert(char *key, ll_int x)
{
	ll_int h;
	DATA_T *p;

	if(( p = Get(key) )){
		p->x = x;
		return;
	}


	if( ( p = (DATA_T *)malloc(sizeof(DATA_T)) ) == NULL){
		printf("malloc error\n");
		exit(1);
	}

	h = Hash(key);
	strcpy(p->key, key);
	p->x = x;
	p->next = S[h];
	S[h] = p;
}


int main()
{
	int q;
	int query;
	char key[21];
	ll_int x;
	DATA_T *p;
	int i;

	scanf("%d", &q);

	for(i = 0; i < q; i++){
		scanf("%d", &query);

		if(query){
		// get
			scanf("%s", key);
			p = Get(key);
			printf("%lld\n", p->x);
		}else{
		// insert
			scanf("%s %lld", key, &x);
			Insert(key, x);
		}
	}

	return 0;
}


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  ll N,K;
  cin>>N>>K;
  vector<pii>a(N);
  for(int i=0;i<N;i++)cin>>a[i].first>>a[i].second;
  sort(rng(a));
  for(auto it:a){
    if(K<=it.second){
      cout<<it.first<<endl;
      return 0;
    }
    else{
      K-=it.second;
    }
  }
  return 0;
}


Measured memory_bytes: 1024
import sys
input = sys.stdin.readline


def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def main():
    N = input().strip()
    M = len(N)
    K = int(input())

    dp1 = [[0 for _ in range(K + 1)] for __ in range(M)]
    dp2 = [[0 for _ in range(K + 1)] for __ in range(M)]

    dp1[0][0] = 1
    dp1[0][1] = int(N[0]) - 1
    dp2[0][1] = 1

    for i in range(1, M):
        a = int(N[i])
        for k in range(K + 1):
            dp1[i][k] += dp1[i - 1][k]
            if a > 0:
                dp1[i][k] += dp2[i - 1][k]
            
            if a == 0:
                dp2[i][k] = dp2[i - 1][k]
            else:
                if k > 1:
                    dp2[i][k] = dp2[i - 1][k - 1]

        for k in range(1, K + 1):
            dp1[i][k] += 9 * dp1[i - 1][k - 1]
            if a > 0:
                dp1[i][k] += (a - 1) * dp2[i - 1][k - 1]

    print(dp1[M - 1][K] + dp2[M - 1][K])


if __name__ == "__main__":
    main()



Measured memory_bytes: 3064
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author bone
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = in.nextInt();
            }
            int[] b = Arrays.copyOf(a, n);
            Arrays.sort(b);

            for (int i = 0; i < n; i++) {
                int j = n - 1;
                while (a[i] == b[j]) {
                    j--;
                    break;
                }
                out.println(b[j]);
            }
        }

    }
}



Measured memory_bytes: 69408
#include<bits/stdc++.h>
#define int long long
#define endl "\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;


const int maxn = 16;
int a[maxn][maxn],dp[1LL<<maxn];
int n;
int32_t main()
{
	IOS
	memset(dp,0,sizeof(dp));
	cin>>n;
	for(int i=0;i<n;i++)
	for(int j=0;j<n;j++)
	cin>>a[i][j];
	
	
	for(int i=0;i<(1LL<<n);i++)
	{
		int msk = i;
		for(int j=0;j<n;j++)
		for(int k=0;k<n;k++)
		if( ((msk>>j)&1)   &&  ((msk>>k)&1) )
		{
			dp[msk]+=a[j][k];
		}
	}
	
	for(int i=0;i<(1LL<<n);i++)
	{
		
		for(int j=i;j;j=(j-1)&i)
		{
			int msk1 = j;
			int msk2 = i^j;
			
			dp[i]=max(dp[i],dp[msk1]+dp[msk2]);
		}
	}
	
	cout << (dp[(1LL<<n)-1]>>1) << endl;
	
	
}


Measured memory_bytes: 768
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	res := 0
	for i := 1; i < n+1; i++ {
		if i%2 == 0 {
			continue
		}
		div := 0
		for j := 1; j < i+1; j++ {
			if i%j == 0 {
				div++
			}
		}
		if div == 8 {
			res++
		}
	}
	fmt.Println(res)
}


Measured memory_bytes: 512
h, w = map(int, input().split())
a = [list(input()) for i in range(h)]
ta = [["."] * w for i in range(h)]
ao = [["."] * w for i in range(h)]
for i in range(h):
    if i % 2 == 0:
        for j in range(w - 1):
            ta[i][j] = "#"
        ao[i][-1] = "#"
    else:
        for j in range(1, w):
            ao[i][j] = "#"
        ta[i][0] = "#"
for i in range(h):
    for j in range(w):
        if a[i][j] == "#":
            ta[i][j] = "#"
            ao[i][j] = "#"
for i in range(h):
    print(*ta[i], sep="")
print()
for i in range(h):
    print(*ao[i], sep="")

Measured memory_bytes: 15124
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define res(i,n) for(int i=n;;i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define REV(i,n) for(int i=n-1;i>0;i--)
#define req(i,n,m) for(int i=n;i<m;i++)
#define REQ(i,n,m,l) for(int i=n;i<m;i+=l) 
#define _GLIBCXX_DEBUG
int INF = 1e9 + 7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
    unsigned day;
    if (dow < dow1) dow += 7;
    day = dow - dow1;
    day += 7 * n - 6;
    return day;
}
signed gcd(long long x, long long y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
signed lcm(long long x, long long y) {
    return x / gcd(x, y) * y;
}
unsigned DayToWeekNumber(unsigned day)
{
    return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
    return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
signed main() {
    long long Q, H, S, D, N; cin >> Q >> H >> S >> D >> N;
    N *= 4;
    cout << min(min(min(min(min(min(N * Q, N / 8 * D + N % 8 / 2 * H + N % 2 * Q), N / 8 * D + N % 8 * Q), N / 4 * S + N % 4 * Q), N / 2 * H + N % 2 * Q), N / 4 * S + N % 4 / 2 * H + N % 2 * Q), N / 8 * D + N % 8 / 4 * S + N % 4 / 2 * H + N % 2 * Q) << endl;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll A,P;
    cin >>A>>P;
    
    cout << (A*3+P)/2 << endl;


    return 0;
    

}

Measured memory_bytes: 3536
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
l = [b-a,c-a,d-a,e-a,c-b,d-b,e-b,d-c,e-c,e-d]
if max(l) <= k:
    print('Yay!')
else:
    print(':(')

Measured memory_bytes: 3064
n=int(input())
def prime_table(n):
  n+=1
  table=[i if i%2 else 2 for i in range(n)]
  for i in range(3,n,2):
    if table[i]==i:
      for j in range(i*i,n,2*i):
        if table[j]==j:
          table[j]=i
  return table


def prime_fact(n,table):
  p=[]
  while n!=1:
    pp=table[n]
    p.append(pp)
    n//=pp
  return p

t=prime_table(n)

d={}
for i in range(2,n+1):
  for j in prime_fact(i,t):
    if j in d:
      d[j]+=1
    else:
      d[j]=1
c=1
for i in d:
  c=(c*(d[i]+1))%(10**9+7)
print(c)

Measured memory_bytes: 68028
from functools import reduce
from fractions import gcd


def lcm_base(x, y):
    return (x * y) // gcd(x, y)


def lcm(numbers):
    return reduce(lcm_base, numbers, 1)


N = int(input())
Tn = [int(input()) for _ in range(N)]

print(lcm(Tn))


Measured memory_bytes: 5128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  int a, b;
  cin >> a >> b;
  vi ans = {a, b, a - 1, b - 1};
  sort(all(ans));
  cout << ans[2] + ans[3] << endl;
}

Measured memory_bytes: 256
s=list(input())
q=int(input())

for i in range(q):
    cmd=list(input().split())
    
    if cmd[0]=="replace":
        s[int(cmd[1]):int(cmd[2])+1]=cmd[3]
        
    if cmd[0]=="reverse":
        ts=s[int(cmd[1]):int(cmd[2])+1]
        ts.reverse()
        s[int(cmd[1]):int(cmd[2])+1]=ts
        
    if cmd[0]=="print":
        ts=s[int(cmd[1]):int(cmd[2])+1]
        print("".join(ts))

Measured memory_bytes: 7712
if __name__=="__main__":
    while True:
        try:
            ans=0.0
            term=float(raw_input())
            for i in range(1,11):
                ans+=term
                if i%2 :
                    term*=2
                else :
                    term/=3
            print ans
        except EOFError:break
        

Measured memory_bytes: 6300
#include <iostream>

int main() {
  int temp, ans = 1;
  while (std::cin >> temp) {
    if (temp >= 10) {
      std::cout << "-1" << std::endl;
      return 0;
    } else {
      ans *= temp;
    }
  }
  std::cout << ans << std::endl;
}

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

using namespace std;

typedef pair<int, int> pii;

int main() {
    int n, m; cin >> n >> m;
    vector<pii> edges;
    vector<int> in_cnt(n, 0);
    vector<vector<int>> adj(n);
    for (int i = 0; i < n - 1 + m; i++) {
        int a, b; cin >> a >> b;
        a--;
        b--;
        adj[a].push_back(b);
        in_cnt[b]++;
    }
    int root = -1;
    for (int i = 0; i < n; i++) {
        if (in_cnt[i] == 0) {
            root = i;
        }
    }

    queue<int> q;
    q.push(root);
    vector<int> parent(n, -1);
    parent[root] = 0;
    while(!q.empty()) {
        int cur = q.front();
        q.pop();
        for (int i = 0; i < adj[cur].size();i ++) {
            int dst = adj[cur][i];
            in_cnt[dst]--;
            if (in_cnt[dst] == 0) {
                q.push(dst);
                parent[dst] = cur + 1;
            }
        }
    }

    for (int i = 0; i < n; i++) {
        cout << parent[i] << endl;
    }

    return 0;
}


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

typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1e9+7;
#define rep(i,N) for(ll i=0; i<(N); i++)
#define rep1(i,N) for(ll i=1; i<(N); i++)
#define f first
#define s second

ll N,X;
ll x[100005];
ll gcd(ll a,ll b){
if(a<b) swap(a,b);
if(a%b==0) return b;
else return gcd(a%b,b);
}

int main(){

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

cin>>N>>X;

rep(i,N){
	cin>>x[i];
}

ll D=abs(X-x[0]);
rep(i,N){
	D=gcd(D,abs(X-x[i]));
}

cout<<D<<endl;

}
	


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

using namespace std;

const int md = (int) 1e9 + 7;

inline void add(int &x, int y) {
  x += y;
  if (x >= md) x -= md;
}

inline void sub(int &x, int y) {
  x -= y;
  if (x < 0) x += md;
}

inline int mul(int x, int y) {
  return 1ll * x * y % md;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<pair<int, int>> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i].second >> a[i].first;
  }
  sort(a.begin(), a.end());
  vector<int> bl(n + 2);
  vector<int> cur;
  for (int i = 0; i < n; i++) {
    int low = -1, high = cur.size();
    while (high - low > 1) {
      int mid = (low + high) / 2;
      (a[cur[mid]].second > a[i].second ? high : low) = mid;
    }
    if (high == (int) cur.size()) {
      cur.push_back(i);
    }
    bl[i] = cur[high];
  }
  cur.clear();
  vector<vector<int>> vec(n + 2);
  for (int i = n - 1; i >= 0; i--) {
    int low = -1, high = cur.size();
    while (high - low > 1) {
      int mid = (low + high) / 2;
      (a[cur[mid]].second < a[i].second ? high : low) = mid;
    }
    if (high == (int) cur.size()) {
      cur.push_back(i);
    }
    vec[cur[high] + 1].push_back(bl[i]);
  }
  vector<int> dp(n + 1);
  vector<int> pref(n + 1);
  dp[0] = 1;
  pref[0] = 1;
  for (int i = 1; i <= n; i++) {
    add(pref[i], pref[i - 1]);
    sort(vec[i].begin(), vec[i].end());
    for (int l : vec[i]) {
      add(dp[i], pref[i]);
      if (l > 0) sub(dp[i], pref[l - 1]);
      pref[i] = pref[i - 1];
      add(pref[i], dp[i]);
    }
  }
  cout << dp[n] << '\n';
  return 0;
}



Measured memory_bytes: 18744
#include <bits/stdc++.h> 
using namespace std;
//関数
const long INF=1000000000000000;
const long MOD=1000000007;
bool check=false;


int main(void){
    long N,K;
    cin>>N>>K;
    vector<long> P(N);
    for(int i=0;i<N;i++) cin>>P.at(i);
    set<long> s;
    for(int i=0;i<K;i++) s.insert(P.at(i));
    long count=1;
    for(int i=K-1;i>=1;--i){
        if(P.at(i)>P.at(i-1)) count++;
        else break;
    }
    
    bool nothing=(count>=K);
    long ans=(count<K);
    
    for(int i=K;i<N;i++){
        if(P.at(i)>P.at(i-1)) count++;
        else count=1;
        
        if(count>=K){
            nothing=true;
            s.erase(P.at(i-K));
            s.insert(P.at(i));
        }else{
            s.erase(P.at(i-K));
            auto iteb=s.begin();
            auto itee=s.end();
            --itee;
            ans+=(P.at(i)<(*itee) || P.at(i-K)>(*iteb));
            s.insert(P.at(i));
        }
    }
    //cout<<ans<<endl;
    cout<<ans+nothing<<endl;
}

Measured memory_bytes: 11136