akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
#define fr(i,a,n) for(ll i=a;i<n;i++)
#define ina for(ll i=0;i<n;i++)cin>>a[i];
#define YES printf("YES\n")
#define all(v) v.begin(),v.end()
#define NO printf("NO\n")
#define fastio std::ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;


int main()
{
    fastio;


          ll n,m;
          cin>>n>>m;

          ll s=0;
          ll a[n+5];
          fr(i,0,n)
          {
                cin>>a[i];
                s+=a[i];
          }

            //cout<<s<<endl;
          ll f=0;
      //cout<<floor(s/(4.0*m))<<endl;
          fr(i,0,n)
          {
                if(a[i]*4*m>=s)f++;
          }
          //cout<<f<<endl;
          if(f>=m)cout<<"Yes"<<endl;
          else cout<<"No"<<endl;





}



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

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

	vector<double>V;
	for (int i = 0; i < N; i++) {
		int H;
		cin >> H;

		double Temp = T - H * 0.006;

		V.push_back(Temp);
	}

	int ans = 0;

	for (int i = 0; i < V.size(); i++) {
		if (abs(V[i] - A) < abs(V[ans] - A)) {
			ans = i;
		}
	}

	cout << ans + 1 << endl;
}

Measured memory_bytes: 3616
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

enum Type{
	Sente,
	Gote,
};

int dp[51][51][51][51][2][3];
int num_sente,num_gote;
int sente_array[51],gote_array[51];

int calc(int sente_0,int sente_1,int gote_0,int gote_1,int pass_num,Type turn,int sente_value,int gote_value){

	//?¨???????????????????????????????
	if(abs(dp[sente_0][sente_1][gote_0][gote_1][turn][pass_num]) != BIG_NUM){
		return dp[sente_0][sente_1][gote_0][gote_1][turn][pass_num];
	}

	int ret;

	if(turn == Sente){

		ret = -BIG_NUM;

		if(sente_1+1 <= num_sente){
			if(sente_array[sente_1+1] == -1){
				ret = max(ret,calc(sente_0,sente_1+1,gote_0,gote_1,0,Gote,sente_value,0));
			}else{
				ret = max(ret,calc(sente_0,sente_1+1,gote_0,gote_1,0,Gote,sente_value+sente_array[sente_1+1],gote_value));
			}
		}

		if(sente_0 == sente_1 && gote_0 == gote_1){
			if(pass_num == 0){
				ret = max(ret,calc(sente_1,sente_1,gote_1,gote_1,1,Gote,0,0));
			}else{ //pass_num == 1
				ret = max(ret,0);
			}
		}else{
			ret = max(ret,sente_value-gote_value+calc(sente_1,sente_1,gote_1,gote_1,0,Gote,0,0));
		}

		return dp[sente_0][sente_1][gote_0][gote_1][turn][pass_num] = ret;

	}else{

		ret = BIG_NUM;

		if(gote_1+1 <= num_gote){
			if(gote_array[gote_1+1] == -1){
				ret = min(ret,calc(sente_0,sente_1,gote_0,gote_1+1,0,Sente,0,gote_value));
			}else{
				ret = min(ret,calc(sente_0,sente_1,gote_0,gote_1+1,0,Sente,sente_value,gote_value+gote_array[gote_1+1]));
			}
		}

		if(sente_0 == sente_1 && gote_0 == gote_1){
			if(pass_num == 0){
				ret = min(ret,calc(sente_1,sente_1,gote_1,gote_1,pass_num+1,Sente,0,0));
			}else{ //pass_num == 1
				ret = min(ret,0);
			}
		}else{
			ret = min(ret,sente_value-gote_value+calc(sente_1,sente_1,gote_1,gote_1,0,Sente,0,0));
		}

		return dp[sente_0][sente_1][gote_0][gote_1][turn][pass_num] = ret;

	}

}


int main(){

	for(int a = 0;a <= 50; a++){
		for(int b = 0; b <= 50;b++){
			for(int c = 0; c <= 50; c++){
				for(int d = 0; d <= 50; d++){
					for(int e = 0; e < 2; e++){
						for(int f = 0; f < 2; f++){
							if(e == 0){
								dp[a][b][c][d][e][f] = -BIG_NUM;
							}else{
								dp[a][b][c][d][e][f] = BIG_NUM;
							}
						}
					}
				}
			}
		}
	}

	scanf("%d %d",&num_sente,&num_gote);
	for(int i = 1; i <= num_sente; i++)scanf("%d",&sente_array[i]);
	for(int i = 1; i <= num_gote; i++)scanf("%d",&gote_array[i]);

	printf("%d\n",calc(0,0,0,0,0,Sente,0,0));

	return 0;
}

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

typedef long long int ll;
typedef long long unsigned int ull;
typedef long double ld;
typedef vector<int> vr;
typedef pair<int, int> pr;
#define pb push_back
#define ff first
#define ss second
#define INF 1999999999
#define MODA 1000000007
#define PI 3.1415926535897932384626433
#define endl "\n"
//cout << fixed << setprecision(2);

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int r1, r2;
    cin >> r1 >> r2;
    double sum = (double)(r1 + r2);
    double mul = (double)(r1 * r2);

    double r3 = (double)(mul / sum);
    cout << fixed << setprecision(10);
    cout << r3 << endl;
    return 0;
}



Measured memory_bytes: 3796
/*
Author: Srinjoy
Language: C++ 17
*/
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define de(a) cout << #a << " = " << a << endl
#define dd(a) cout << #a << " = " << a << " "
#define optimiza_io cin.tie(0); ios_base::sync_with_stdio(0);
#define ZERO(a) memset(a,0,sizeof(a))
#define fileinput(s) freopen(s,"r",stdin)
#define MINUS(a) memset(a,0xff,sizeof(a))
typedef long long ll;
const ll mod = 1000000007;

template<class T>
istream& operator >> (istream& in, vector<T>& v){ for (auto &x : v) { in >> x; } return in; }
 
template<class T>
istream& operator >> (istream& in, pair<T, T> & v){ in >> v.fi >> v.se;return in; }

void printArr(vector<int> arr){
	cout<<"\n------------------------------------\n";

	for(int i=0;i<arr.size();i++) cout<<arr[i]<<" ";
	
	cout<<"\n------------------------------------\n";
}

void printArr(vector<vector<int> > arr){
	cout<<"\n------------------------------------\n";

	for(vector<int> i:arr){
		for(int j:i){
			cout<<j<<" ";
		}
		cout<<endl;
	}
	
	cout<<"\n------------------------------------\n";

}


int main(){
	optimiza_io

	int h,a;
	cin>>h>>a;

	double ans = (double)(h)/(double)(a);

	cout<<ceil(ans)<<endl;
	
}

Measured memory_bytes: 256
n = int(input())
a = [int(x) for x in input().split()]
z = 0
ans = 0
for i in range(1,n):
  if a[i] > a[i-1]:
    if z > ans:
    	ans = z
    z = 0
  else:
    z += 1
print(max(z, ans))

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

int main(){
    char s[4];
    for(int i=0; i<4; i++){
        cin >> s[i];
    }

    if(s[0]==s[1]||s[1]==s[2]||s[2]==s[3]){
        cout << "Bad";
    }
    else{
        cout << "Good";
    }
    cout << endl;
    return 0;
}

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

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }

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

    //累積GCD(左右から)
    vector<int> gcd_left(N+1, 0), gcd_right(N+1, 0);
    for (int i = 0; i < N; i++){ gcd_left.at(i+1) = GCD(gcd_left.at(i), a.at(i)); }
    for (int i = N-1; i >= 0; i--){ gcd_right.at(i) = GCD(gcd_right.at(i+1), a.at(i)); }
    
    int res = 0;
    for (int i = 0; i < N; i++) {
        
        int l = gcd_left.at(i);
        int r = gcd_right.at(i+1);
        res = max( res, GCD(l, r) );
    }

    cout << res << endl;
}

Measured memory_bytes: 1408
#include<iostream>
#include<map>
#include<string.h>
#include<queue>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<cstdlib>
#include<math.h>
#include<set>
#include<array>
using namespace std;

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



#define rep(n) for(int i=0;i<n;i++)
typedef pair<int, int> pii;

typedef long long ll;
typedef pair<ll, ll>pll;
const int MOD = 1000000007;
const int INF = 1 << 29;



int main() {
	
	
	int n;
	cin >> n;
	
	priority_queue<pii,vector<pii>,greater<pii>> pq;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		pq.push(make_pair(a, i));

	}

	while (!pq.empty()) {

		pair<int, int> pp = pq.top();
		cout << pp.second+1 << endl;
		pq.pop();


	}
	return 0;
}


Measured memory_bytes: 1780
import sys
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7



def main():
    N, Y = map(int, readline().split())
    Y //= 1000
    for a in range(N+1):
        for b in range(N+1-a):
            if 10*a+5*b+(N-a-b)==Y:
                print(a, b, N-a-b)
                break
        else:
            continue
        break
    else:
        print('-1 -1 -1')

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
n, k = map(int, input().split())
prob = [0.0] * k
for i in reversed(range(k)):
    if i * 2 >= k:
        prob[i] = 0.5
    else:
        prob[i] = prob[i * 2] / 2
ans = 0
for i in range(1, n+1):
    if i >= k:
        ans += 1
    else:
        ans += prob[i]
print(ans / n)

Measured memory_bytes: 4980
n = int(input())
s = [input() for i in range(n)]

d = {}
for st in s:
    d[st] = d.get(st, 0) + 1
#print(d)

t = max(d.values())
ans = []
for p in d:
    if d[p] == t:
        ans.append(p)
#print(ans)

ans.sort()
print("\n".join(ans))


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

int N,K,a=1;
int main(){
	cin>>N>>K;
	for(int i=0; i<N; i++) {
		if(a*2<a+K) {
			a=a*2;
		} else {
			a=a+K;
		}
	}
	cout<<a<<endl;
}

Measured memory_bytes: 256
function gets(str){
  this._s = str.split("\n");
  this._y = 0;
};
gets.prototype = {
  a: function(f){
    var s = this._s, y = this._y, r;
    if(typeof s[y] === "string")s[y] = s[y].split(" ").reverse();
    r = s[y].pop();
    if(!s[y].length)this._y++;
    return f?r:+r;
  },
  l: function(f){
    var s = this._s[this._y++].split(" ");
    return f?s:s.map(a=>+a);
  },
  m: function(n,f){
    var s = this._s, y = this._y, r = [], i = 0;
    if(f)for(;i < n; i++)r[i] = s[y+i].split(" ");
    else for(;i < n; i++)r[i] = s[y+i].split(" ").map(a=>+a);
    this._y += n;
    return r;
  },
};
var o=new gets(require("fs").readFileSync("/dev/stdin","utf8"));

console.log(main());
function main(){
  var n = o.a();
  var x = o.m(n);
  var t = (x[0][0]+x[0][1]) & 1;
  for(var i = 1; i < n; i++){
    var u = (x[i][0]+x[i][1]) & 1;
    if(u !== t)return -1;
  }
  var m = 32 - t;
  var d = [1<<30];
  
  for(i = 1; i < 31; i++){
    d[i] = d[i-1] >> 1;
  }
  if(m % 2 === 0)d[31] = 1;
  var w = [];
  for(i = 0; i < n; i++){
    w[i] = "";
    for(var j = 0; j < m; j++){
      if(Math.abs(x[i][0]) > Math.abs(x[i][1])){
        if(x[i][0] > 0){x[i][0] -= d[j]; w[i] += "R";}
        else{x[i][0] += d[j]; w[i] += "L";}
      }else{
        if(x[i][1] > 0){x[i][1] -= d[j]; w[i] += "U";}
        else{x[i][1] += d[j]; w[i] += "D";}
      }
    }
  }
  return m + "\n" + d.join(" ") + "\n" + w.join("\n");
}

Measured memory_bytes: 10568
#include <stdio.h>

int main()
{
	int i, N, W, w[101], v[101], sum = 0;
	scanf("%d %d", &N, &W);
	for (i = 1; i <= N; i++) {
		scanf("%d %d", &(w[i]), &(v[i]));
		sum += v[i];
	}

	int j, dp[100001];
	for (i = 1, dp[0] = 0; i <= sum; i++) dp[i] = W + 1;
	for (i = 1; i <= N; i++) {
		for (j = sum; j >= v[i]; j--) if (dp[j-v[i]] + w[i] < dp[j]) dp[j] = dp[j-v[i]] + w[i];
	}
	for (j = sum; j >= 0; j--) if (dp[j] <= W) break;
	printf("%d\n", j);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 2096
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
    int N; cin >> N;
    vector<int> A(N, 0);
    vector<int> ans(N, 0);
    for (int i = 0; i < N; ++i) {
        int a = 0; cin >> a;
        ans[a - 1] = i + 1;
    }
    for (int i = 0; i < N; ++i) printf("%d ", ans[i]);
    printf("\n");
}


Measured memory_bytes: 1536
#include <stdio.h>
#define N 101
int main(){
  int n, m;
  int i, j, k, l;
  int G[N][N];
  scanf("%d", &n);
  for(i = 0; i <= n; i++){
    for(j = 0; j <= n; j++){
      G[i][j] = 0;
} }
  for(i = 0; i < n; i++){
    scanf("%d%d", &m, &k);
    for(j = 0; j < k; j++){
      scanf("%d", &l);
G[m][l] = 1; }
}
  for(i = 1; i <= n; i++){
    for(j = 1; j <= n; j++){
      if(j==n){
        if(G[i][j] != 0){
          printf("1");
        } else printf("0");
        break;
}
      if(G[i][j] != 0){
        printf("1 ");
      } else printf("0 ");
    }
    printf("\n");
  }
return 0; }


Measured memory_bytes: 2108
let split_string ?(pattern="") = Str.split @@ Str.regexp pattern
let n = Scanf.sscanf (read_line ()) "%d" @@ fun n -> n
let a = read_line () |> split_string ~pattern:" " |> List.map int_of_string |> List.sort compare
let b = read_line () |> split_string ~pattern:" " |> List.map int_of_string |> List.sort compare
let c = read_line () |> split_string ~pattern:" " |> List.map int_of_string |> List.sort compare

let rec drop_while f = function
  | (_, []) -> (0, [])
  | (i, x :: xs) as tpl -> if f x then drop_while f (i - 1, xs) else tpl

let rec loop ans a b c = match b with
  | [] -> ans
  | x :: xs ->
    let a = drop_while (fun i -> i < x) a in
    let c = drop_while (fun i -> i <= x) c in
    loop (ans + (n - fst a) * (fst c)) a xs c

let () = Printf.printf "%d\n" @@ loop 0 (n, a) b (n, c)

Measured memory_bytes: 30008
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int A = scanner.nextInt();
    int B = scanner.nextInt();

    int fare;
    if (A >= 13) {
      fare = B;
    } else if (A >= 6) {
      fare = B / 2;
    } else {
      fare = 0;
    }

    System.out.println(fare);
  }
}

Measured memory_bytes: 21844
import math
import time
from collections import defaultdict, deque
from sys import stdin, stdout
from bisect import bisect_left, bisect_right
n=int(input())
a=input()
ans=0
x=0
for i in a:
    if(i=='I'):
        x+=1
    else:
        x-=1
    ans=max(ans,x)
print(ans)

Measured memory_bytes: 38416
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
#include <tuple>

#include <set>
#include <unordered_map>
#include <stack>
#include <map>

using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
using ll = long long;
template<class T>bool chmaxj(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; }
void YesNo(bool y) { cout << (y ? "Yes" : "No") << endl; } //true==yes


#define INF 21474836

//////////////////////////////////////////////////////////////

int main() {

	int X;
	cin >> X;
	int Xi = X;

	vector<long long>AA(1000,0);
	AA[0] = 0;
	for (int i = 1; i < 1000; i++) {
		AA[i] = pow(i, 5);
	}
	 
	rep(i, 1000) {
		rep(j, 1000) {
			if (AA[i] - AA[j] == X) {
				cout << to_string(i) + " " + to_string(j) << endl;
				return 0;
			}
			if (AA[i] + AA[j] == X) {
				j = -1 * j;
				cout << to_string(i) + " " + to_string(j) << endl;
				return 0;
			}
		}
	}

}


Measured memory_bytes: 4172
/**
 *   author: malviyanshiv
 *   created: 09 January 2019  23:27:27
**/

#include <bits/stdc++.h>

using namespace std;

#define REP(i, a, b) for(int i = a; i < b; i++)
#define RREP(i, a, b) for(int i = a-1; i >= b; i--)
#define PB push_back
#define MP make_pair
#define MOD 1000000007
#define INF 0x7fffffff
#define MAX 100005

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

void fastscan(int &x){
    bool neg=false;
    register int c;
    x =0;
    c=getchar();
    if(c=='-'){
        neg = true;
        c=getchar();
    }
    for(;(c>47 && c<58);c=getchar())
        x = (x<<1) + (x<<3) +c -48;
    if(neg)
        x *=-1;
}

void optimizeIO(){
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
}

vector< vector<ll> > dp(101, vector<ll>(MAX, -1));
int wi[101];
int vi[101];

ll cal(int idx, int w){
    if( idx == 0 || w == 0 )
        return 0;
    if( dp[idx][w] != -1 )
        return dp[idx][w];
    if( wi[idx] > w )
        return dp[idx][w] = cal(idx-1, w);
    else
        return dp[idx][w] = max( vi[idx] + cal(idx-1, w-wi[idx]), cal(idx-1, w));
}

int main(){
	optimizeIO();
    int n, w;
    cin >> n >> w;
    REP(i, 1, n+1)
        cin >> wi[i] >> vi[i];

    cout << cal(n, w) << endl;

	return 0;
}


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

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

const ll INF = 1000000000000000000;


int main() {
	ll a;
	long double b;
	ll c;

	cin >> a >> b;

	c = a * b;
	cout << c;

	return 0;
}


Measured memory_bytes: 3664
#include<stdio.h>

int main(void){
    int a, b, c;
    scanf("%d""%d""%d", &a, &b, &c);
    if((a == b && b != c) || (a == c && a != b) || (b == c && b != a)){
        printf("Yes\n");
        return 0;
    }else{
        printf("No\n");
        return 0;
    }
}

Measured memory_bytes: 128
S = input()
targets = ["dream", "dreamer", "erase", "eraser"]
while True:
    isEndTarget = False
    for target in targets:
        if S.endswith(target):
            S = S[: -len(target)]
            isEndTarget = True
            break
    if not isEndTarget:
        print("NO")
        break
    elif S == "":
        print("YES")
        break

Measured memory_bytes: 3188
#include<bits/stdc++.h>
 
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define rep(i,a,b)    for(int i=a;i<b;i++)
#define repn(i,a,b)   for(int i=a;i>=b;i--)
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define mp  make_pair
#define all(v) (v).begin(), (v).end()
#define mod 1000000007
 
using namespace std;

int i,j,k;
 
int max(int a, int b)
{
    if(a>b) return a;
    else return b;
}
 
int min(int a,int b)
{
    if(a<b) return a;
    else return b;
}

int fast_power(int a,int b)
{
    int res=1;
    while(b>0)
    {
        if(b%2==0)
        {
            b/=2;
            a=(a*a)%mod;
        }
        else
        {
             b/=2;
             res=(res*a)%mod;
            a=(a*a)%mod;
        }
    }
    return res;
}

signed main()
{
    IOS;
    int a,b,c,temp;
    cin>>a>>b>>c;
    temp=a;
    a=b;
    b=temp;
    temp=a;
    a=c;
    c=temp;
    cout<<a<<" "<<b<<" "<<c;    
    
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main
{
	public static void main(String[] args) 
	{
		Scanner in=new Scanner(System.in);
		for(;;)
		{
			int N=in.nextInt();
			if(N==0)
				return;
			jump a[][]=new jump[N][N];
			ArrayList<jump>AL=new ArrayList<jump>();
			int field[][]=new int[N][N];
			boolean judge[][]=new boolean[N][N];
			int cnt=0;
			for(int i=0;i<N;i++)
				for(int j=0;j<N;j++)
				{
					jump b=new jump(in.nextInt(),in.nextInt());
					a[j][i]=b;
				}

			for(int i=0;i<N;i++)
				for(int j=0;j<N;j++)
				{
					int xx=j;
					int yy=i;
					if(field[j][i]==0)
						for(;;)					
						{
							if(field[xx][yy]==2)
							{
								if(judge[xx][yy]==false)
								{
									cnt++;
									judge[xx][yy]=true;
								}
								break;
							}
							field[xx][yy]=2;
							jump b=new jump(xx, yy);
							AL.add(b);
							int tx=a[xx][yy].x;
							int ty=a[xx][yy].y;
							xx=tx;
							yy=ty;
						}
					for(int k=0;k<AL.size();k++)
					{
						int rex=AL.get(k).x;
						int rey=AL.get(k).y;
						judge[rex][rey]=true;
					}
				}
			System.out.println(cnt);
		}
	}
}
class jump
{
	int x;
	int y;
	public jump(int a,int b) 
	{
		x=a;
		y=b;
	}
}

Measured memory_bytes: 61304
#include<iostream>
using namespace std;
int solver(int everymaketime,int makepeace,int alltime){
    int result;
    result = ( alltime / everymaketime ) * makepeace;
    return result;
}

int main(void){
    int A,B,T;
    int answer;
    cin >> A >> B >> T;
    answer = solver(A,B,T);
    cout << answer << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
using namespace std;
/****************************/
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define qi queue<int>
#define mii map<int,int>
#define msi map<string,int>
#define vs vector<string>
#define vc vector<char>
/****************************/
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define rep3(i,a,n) for(ll i=(a);i<(n);i++)
#define rep4(i,a,n) for(ll i=(n)-1;i>=a;i--)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define pi 3.1415926535897932384626433832795
#define zero(n) memset(n,0,sizeof(n));
#define SZ(n) n.size()
#define ss st.st
#define sn st.nd
#define mod 1000000007
/****************************/
int main()
{
	string s;
	cin>>s;
	if(s.size()%2!=0)
	{
		cout<<"No";
		return 0;
	}
	for(int i=0;i<s.size();i+=2)
	{
		if(s[i]=='h'&&s[i+1]=='i') continue;
		cout<<"No";
		return 0;
	}
	cout<<"Yes";
	return 0;
}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

const int N = 1e5 + 5;
int j, n, m, k, ans;

int main() {
    cin >> n >> k;
    for (int i = 0; i < n; ++i) {
        cin >> m;
        if (m == 1) {
            j = i;
        }
    }
    int l = j;
    int r = n - 1 - j;
    int rm = 0;
    rm += l % (k - 1);
    l = l / (k - 1);
    rm += r % (k - 1);
    r = r / (k - 1);
    int ans = l + r;
    if (rm > 0)
        ++ans;
    if (rm > k - 1)
        ++ans;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3544
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <functional>
#include <cstring>
#include <cmath>

using namespace std;
#define inputInt(a) int a;cin >> a; 
#define inputIntArray(a,N) int a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define output(answer) cout << answer << endl;
#define f(i,s,e) for(int i=s; i<=e; i++)

int main()
{
    //input
    inputInt(N);
    inputIntArray(d,N);
    
    //main
    int ans = 1e9;
    
    sort(d,d+N,greater<int>());
    ans = d[N/2-1] - d[N/2];
  
    // 出力
    output(ans);
    return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
	ll a, b, h;
  cin>>a>>b>>h;
  cout<<(a+b)*h/2<<endl;
	return 0;
}


Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    string a, b, c;
    cin >> a >> b >> c;
    cout << a.at(0) << b.at(0) << c.at(0) << endl;
}

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

int main(){
    int n;
    int a=0;
    int count =0;
    cin>> n;
    vector <int> A(n);
    for(int i=0;i<n;++i){
        cin >> A[i];
    }
  sort(A.begin(),A.end());
    for(int i=0;i<n;++i){
        if(a<A[i]){
            a=A[i];
            ++count; 
        }
    }
        cout << count <<endl;
}

Measured memory_bytes: 256
MOD = 10**9 + 7


m = 5000
fac = [0] * m
finv = [0] * m
inv = [0] * m


def COMBinitialize(m):
    fac[0] = 1
    finv[0] = 1
    if m > 1:
        fac[1] = 1
        finv[1] = 1
        inv[1] = 1
        for i in range(2, m):
            fac[i] = fac[i - 1] * i % MOD
            inv[i] = MOD - inv[MOD % i] * (MOD // i) % MOD
            finv[i] = finv[i - 1] * inv[i] % MOD


def COMB(n, k):
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD


COMBinitialize(m)


def main():
    S = int(input())
    if S < 3:
        print(0)
        return
    ans = 0
    for i in range(1, S // 3 + 1):
        r = S - i * 3
        ans += COMB(r + i - 1, i - 1)
        ans %= MOD
    print(ans)


if __name__ == '__main__':
    main()


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

#define ll long long
#define ull unsigned long long

using namespace std;

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

	int sum = 0;
	for (int ii = 0; ii < N; ++ii){
		sum += L + ii;
	}

	int min = 100100100;
	int ans = 0;
	for (int ii = 0; ii < N; ++ii){
		int tmp = sum - (L + ii);
		if (abs(sum - tmp) < min){
			min = abs(sum - tmp);
			ans = tmp;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

typedef long long ll;

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

// const int C ;
const int infty = 1000000007;

int P[110][110];
int Q[110][110];

int main () {
  int N, M;
  cin >> N >> M;
  for (auto i = 0; i < N; i++) {
    for (auto j = 0; j < N; j++) {
      P[i][j] = infty;
    }
  }
  for (auto i = 0; i < M; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--; b--;
    P[a][b] = P[b][a] = c;
  }
  for (auto i = 0; i < N; i++) {
    for (auto j = 0; j < N; j++) {
      Q[i][j] = P[i][j];
    }
  }
  for (auto k = 0; k < N; k++) {
    for (auto i = 0; i < N; i++) {
      for (auto j = 0; j < N; j++) {
        if (i == j) continue;
        Q[i][j] = min(Q[i][j], Q[i][k] + Q[k][j]);
      }
    }
  }
  int ans = 0;
  for (auto i = 0; i < N; i++) {
    for (auto j = 0; j < N; j++) {
      if (P[i][j] < infty && P[i][j] > Q[i][j]) {
        ans++;
      }
    }
  }
  cout << ans/2 << endl;
  /*
  for (auto i = 0; i < N; i++) {
    for (auto j = 0; j < N; j++) {
      cerr << i << ", " << j << " : " << P[i][j] << " " << Q[i][j] << endl;
    }
  }
  */
}


Measured memory_bytes: 384
#include<set>
#include<map>
#include<cmath>
#include<ctime>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<random>
#include<cstdlib>
#include<cstring>
#include<iomanip>
#include<iostream>
#include<algorithm>
#include<unordered_map>
#define endl "\n"
#define fi first
#define se second
#define db double
#define gcd __gcd
#define pb push_back
#define mp make_pair
#define lowbit(x) (x & (-x))
#define PII  pair<int, int> 
#define all(x) x.begin(), x.end()
#define debug(x) cout << #x << " = " << x << endl
#define rep(i, a, b) for(__typeof(b) i = a; i <= (b); i++)
#define Rep(i, a, b) for(__typeof(a) i = a; i >= (b); i--)
#define FAST ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
template<class T> inline T qmin(T a, T b) { return a < b ? a : b; }
template<class T> inline T qmax(T a, T b) { return a > b ? a : b; }
typedef long long ll;
typedef unsigned long long ull;
const db eps = 1e-9;
const db PI = acos(-1);
const int inf = 0x3f3f3f3f;
const int mod = (int)1e9 + 7;
const int maxn = (int)1e3 + 5;//remember to modify it, No RE or MLE
const ll INF = 0x3f3f3f3f3f3f3f3f;
using namespace std;
ll qpow(ll x, ll y) { ll ret = 1; for( ; y; y >>= 1, x = (x * x) % mod) if(y & 1) ret = (ret * x) % mod; return ret; }

inline int read(){
	char ch = getchar();
	int x = 0, f = 1;
	while(ch < '0' || ch > '9'){
		if(ch == '-') f = -1;
		ch = getchar();
	}
	while('0' <= ch && ch <= '9'){
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	return x * f;
}

int n, m;
char G[maxn][maxn];
int dp[maxn][maxn];

int main()
{
	n = read(), m = read();
	rep(i, 1, n){
		rep(j, 1, m){
			scanf("%c", &G[i][j]);
		}
		getchar();
	}
	dp[1][1] = 1;
	rep(i, 1, n) rep(j, 1, m){
		if(G[i-1][j] == '.') dp[i][j] = (dp[i][j] + dp[i-1][j]) % mod;
		if(G[i][j-1] == '.') dp[i][j] = (dp[i][j] + dp[i][j-1]) % mod;
	}
	printf("%d\n", dp[n][m]);
	return 0;
}

Measured memory_bytes: 5120
#define _USE_MAT_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <deque>
#include <numeric>
#include <functional>
using namespace std;

int main() {
    int N, cnt = 0;
    cin >> N;
    set<int>st;
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        if (st.find(a) != st.end()) {
            cnt++;
        }
        st.insert(a);
    }

    cout << ((cnt % 2 == 0) ? st.size() : st.size() - 1) << endl;
    
    return 0;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod =1e9+7;
vector<ll>fat,fat_inv,inv; 
//a^(phi(m)-1)=a^-1 mod m
//a^(m-2)=a^-1 mod m if m prime
void fill_fat(int n){
	fat=vector<ll>(n+1,1);
	fat_inv=vector<ll>(n+1,-1);
	for(ll i=2;i<=n;i++){
		fat[i]=fat[i-1]*i %mod;
	}
}

ll binExp(ll b, ll e){
	ll ret=1;
	while(e){
		if(e&1){
			ret=ret*b %mod;
		}
		b=b*b %mod;
		e/=2;
	}
	return ret;
}

ll comb(ll n, ll k){
	if(fat_inv[k]==-1)fat_inv[k]=binExp(fat[k],mod-2);
	if(fat_inv[n-k]==-1)fat_inv[n-k]=binExp(fat[n-k],mod-2);
 
	ll ret = fat[n]*fat_inv[k]%mod;
	return ret = ret*fat_inv[n-k]%mod;
}



int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	fill_fat((int)1e6);
	ll s=0,ans=0;
	cin>>s;

	ll n=0;
	while(s-3>=0){
		s-=3;
		n++;

		ans= (ans+comb(s+n-1,n-1))%mod;
	}
	cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 18716
#include<stdio.h>
#include<math.h>
int main()
{
    int n,m,i,j,k,sum,res;
    int a[100];
    while(scanf("%d%d",&n,&m)!=EOF){
            res=0;
        for(i=0;i<n;i++){
            scanf("%d",&a[i]);
        }
        for(i=0;i<n;i++){
            k=m-a[i];
            if(k>a[i]){
                res=res+a[i];
            }
            else{res=res+k;}
        }
        res=res*2;
        printf("%d\n",res);
    }
    return 0;
}


Measured memory_bytes: 128
N, K = map(int, input().split())
P    = list(map(int, input().split()))
p    = [(P[i]+1) / 2 for i in range(N)]
a    = 0
for i in range(K):
    a += p[i]
b = a
for i in range(N - K):
    c = a + p[i+K] - p[i]
    b = max(b, c)
    a = c
print(b)

Measured memory_bytes: 24804
#include <iostream>
#include <vector>
#include <cstdio>
#include <sstream>
#include <map>
#include <string>
#include <algorithm>
#include <queue>
#include <cmath>
#include <set>
using namespace std;

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

	vector<int> f(N),a(N),t(N),x(N),y(N);
	for(int i=0; i<N; i++){
		cin >> f[i] >> a[i] >> t[i] >> x[i] >> y[i];
	}

	int ans_d[2] = {-1,-1};
	int ans_t[2] = {-1,-1};
	for(int i=1; i<N; i++){
		if(t[i] != t[i-1]) continue;
		if(a[i] == a[i-1]) continue;
		int& ans_dist = ans_d[t[i]];
		int& ans_time = ans_t[t[i]];

		int dx = abs(x[i] - x[i-1]);
		int dy = abs(y[i] - y[i-1]);

		int dist = dx*dx + dy*dy;
		int time = f[i] - f[i-1];

		if( ans_dist > dist ) continue;
		if( ans_dist == dist && ans_time > time){
			ans_time = time;
		}else if(ans_dist < dist){
			ans_dist = dist;
			ans_time = time;
		}
	}

	for(int i=0; i<2; i++){
		if(ans_d[i] < 0){
			cout << -1 << " " << -1 << endl;
		}else{
			printf("%.12f %.12f\n", sqrt(ans_d[i]), ans_t[i]/60.0);
		}
	}
	return 0;
}

Measured memory_bytes: 1264
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
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;}


int main() {
    int n;
    string s,t;
    cin >> n >> s >> t;
    rep(i,n) {
        cout << s[i] << t[i];
    }
    cout << endl;
}

Measured memory_bytes: 3624
#include <set>
#include <map>
#include <list>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;

int main(){
    int N,D,mieru,ans;
    cin >> N >> D;
    mieru = (D * 2) + 1;
    if(N%mieru == 0)ans = (N/mieru);
    else ans = (N/mieru) + 1;
    cout << ans << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <cstdarg>
#include <sys/time.h>
#include <fstream>
//#include "cout.h"

using namespace std;

#define SZ(x) ((int)x.size())
#define MSET(x,a) memset(x, a, (int)sizeof(x))
#define PB push_back
#define VI vector < int >
#define PII pair < int, int >
#define LL long long
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define FIT(it,v) for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define OUT(A) cout << #A << " = "<< (A) << endl
#define OUT2(A, B) cout << "(" << #A << ", " << #B << ") = (" << (A) << ", "<< (B) << ")" << endl
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }

#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(ALL(c), (e)) != (c).end())



void init() {

}

void input() {

}

void solve() {
  int n;
  int x[110], y[110], h[110];
  cin >> n;
  REP(i, n) cin >> x[i] >> y[i] >> h[i];
  while(1) {
    REP(X, 101) REP(Y, 101) {
      bool ok = true;
      LL H = -1;
      REP(i, n) {
        int tmph = h[i] + abs(X-x[i]) + abs(Y-y[i]);
        if (H == -1 && h[i] > 0) {
          H = tmph;
        } else if (h[i] == 0) {
          if (H > tmph) ok = false;
        } else {
          if (H != tmph) ok = false;
        }
      }
      for(int i = n-1; i >= 0; i--) {
        int tmph = h[i] + abs(X-x[i]) + abs(Y-y[i]);
        if (H == -1 && h[i] > 0) {
          H = tmph;
        } else if (h[i] == 0) {
          if (H > tmph) ok = false;
        } else {
          if (H != tmph) ok = false;
        }
      }

      if (ok) {
        cout << X <<" " << Y <<" "<< H << endl;
        return;
      }
    }
  }
}

int main() {
	init();
	input();
	solve();
	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python

tmp_max = [0,0,0]

import sys
for line in iter(sys.stdin.readline, ""):
	if int(line) > tmp_max[2]:
		tmp_max[2] = int(line)
		if tmp_max[2] > tmp_max[1]:
			tmp_max[1],tmp_max[2] = tmp_max[2],tmp_max[1]
			if tmp_max[1] > tmp_max[0]:
				tmp_max[0],tmp_max[1] = tmp_max[1],tmp_max[0]

print tmp_max[0]
print tmp_max[1]
print tmp_max[2]

Measured memory_bytes: 4228
#include<stdio.h>
int main(){
  int i;
  int a,b,c,d;
  while(scanf("%d%d%d",&a,&b,&c)!=-1){
    d=0;
    for(i=1;i<11;i++){
      if(i!=a&&i!=b&&i!=c)
	if(a+b+i<=20)
	  d++;
    }
    if(d>3)
      puts("YES");
    else
      puts("NO");
  }
  return 0;
}

Measured memory_bytes: 0
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

x, k, d = rm()
t = abs(x) // d
if t > k:
    if x > 0:
        print(abs(x - k*d))
    else:
        print(abs(x + k*d))
    exit()
if x > 0:
    if (k - t) & 1:
        print(abs(x - t*d - d))
    else:
        print(abs(x - t*d))
else:
    if (k - t) & 1:
        print(abs(x + t*d + d))
    else:
        print(abs(x + t*d))












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

int main() {
	string a[3];
	for (int i = 0; i < 3; i++) {
		cin >> a[i];
	}
	string ans = "";
	for (int i = 0; i < 3; i++) {
		ans += a[i].at(0);
	}
	cout << ans << endl;
	return 0;
}

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

int main(void) {
	int ans = 0;
	string S;
	cin >> S;
	string temp = "CODEFESTIVAL2016";
	for (int i = 0; i < S.size(); i++) {
		if (S[i] != temp[i]) ans++;
	}
	printf("%d\n", ans);
	return 0;
}


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

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

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

    int count = 0;
    for(i = 0; i < n; ++i){
        if(i + 1 != p[i]){
            count++;
        }
    }

    if(count < 3){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n;
	cin>>n;
	ll cnt1=n/100;
 	ll cnt2=n%100;
 	if(cnt1*5>=cnt2){
 		cout << 1;
 	}
 	else{
 		cout << 0;
 	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int ans = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'A') {
      for (int j = s.size() - 1; j > 0; j--) {
        if (s[j] == 'Z') {
          if (ans < j - i + 1) {
            ans = j - i + 1;
            break;
          }
          break;
        }
      }
      break;
    }
  }
  cout << ans << endl;
}


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

using namespace std;

int32_t main(){
        ios::sync_with_stdio(0), cin.tie(0);
        string s ; cin >> s ;
        map<string,int>mp;
        mp["SUN"]=7;
        mp["MON"]=6;
        mp["TUE"]=5;
        mp["WED"]=4;
        mp["THU"]=3;
        mp["FRI"]=2;
        mp["SAT"]=1;
        cout << mp[s] << endl; 
        return 0;
}


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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(1e5 + 5);

int n;
ll a[MAX_N];

int main(void) {
  // Here your code !
  scanf("%d", &n);

  for (int i = 1; i <= n; ++i) {
    ll tmp;
    scanf("%lld", &(a[i]));
  }

  vector<int> idx;

  ll ans = 0LL;

  for (int i = 1; i <= n; ++i) {
    {  // about i;
      ll commit = a[i] / 2LL;
      ans += commit;
      a[i] -= 2LL * commit;
    }

    {  // about i and (i + 1)
      ll commit = min(a[i], a[i + 1]);

      ans += commit;

      a[i] -= commit;
      a[i + 1] -= commit;
    }
  }

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

  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll> 
#define P pair<ll,ll>
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll a,b;cin>>a>>b;
  if((a*b)%2==1) puts("Yes");else puts("No");
  return 0;
}

Measured memory_bytes: 384
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.StringTokenizer;
import java.io.Writer;
import java.io.BufferedReader;
import java.io.InputStream;

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

    static class A753 {
        public void solve(int testNumber, InputReader in, OutputWriter out) {
            int x = in.NextInt();
            if (x == 3 || x == 5 || x == 7) {
                out.println("YES");
            } else {
                out.println("NO");
            }
        }

    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine(), " \t\n\r\f,");
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int NextInt() {
            return Integer.parseInt(next());
        }

    }

    static class OutputWriter extends PrintWriter {
        public OutputWriter(Writer out) {
            super(out);
        }

        public OutputWriter(File file) throws FileNotFoundException {
            super(file);
        }

        public OutputWriter(OutputStream out) {
            super(out);
        }

    }
}



Measured memory_bytes: 20820
n,w=map(int,input().split())
wv=[list(map(int,input().split())) for i in range(n)]
wv.sort(key=lambda x:-x[1])
wv.sort(key=lambda x:x[0])
#print(wv)
w0=wv[0][0]
x=[[0],[0],[0],[0]]
for i in range(n):
    if wv[i][0]==w0:
        k=wv[i][1]+x[0][-1]
        l=len(x[0])
        if l*w0<=w:x[0].append(k)
    elif wv[i][0]==w0+1:
        k=wv[i][1]+x[1][-1]
        l=len(x[1])
        if l*(w0+1)<=w:x[1].append(k)
    elif wv[i][0]==w0+2:
        k=wv[i][1]+x[2][-1]
        l=len(x[2])
        if l*(w0+2)<=w:x[2].append(k)
    else:
        k=wv[i][1]+x[3][-1]
        l=len(x[3])
        if l*(w0+3)<=w:x[3].append(k)
#print(x)
ma=0
for i in range(len(x[0])):
    for j in range(len(x[1])):
        for k in range(len(x[2])):
            for l in range(len(x[3])):
                if i*w0+j*(w0+1)+k*(w0+2)+l*(w0+3)<=w:
                    ma_sub=0
                    ma_sub+=x[0][i]
                    ma_sub+=x[1][j]
                    ma_sub+=x[2][k]
                    ma_sub+=x[3][l]
                    ma=max(ma,ma_sub)
                else:
                    break
print(ma)


Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,x[2001],y[2001];
void proc(bool f)
{
	int k=38;
	vector<int> v;
	int sum=0;
	if(f)v.push_back(1),sum=1;
	for(int s=0;s<=k;s++)v.push_back(1ll<<s),sum+=1ll<<s;
	int N=(int)v.size();
	printf("%lld\n",N);
	for(int i:v)printf("%lld ",i);
	puts("");
	for(int i=0;i<n;i++)
	{
		bool p[51],sel[51];
		int s=sum,t=N-1;
		memset(p,-1,sizeof p);
		memset(sel,0,sizeof sel);
		while(s>x[i]+y[i])
		{
			while(s-2*v[t]<x[i]+y[i])t--;
			s-=2*v[t];
			p[t]=0;
		}
		int totx=0;
		for(int j=0;j<N;j++)
			if(p[j])sel[j]=1,totx+=v[j];
		t=N-1;
		while(totx>x[i])
		{
			if(p[t]&&totx-v[t]>=x[i])totx-=v[t],sel[t]=0;
			else if(!p[t]&&totx-v[t]>=x[i])totx-=v[t],sel[t]=1;
			t--;
		}
		for(int j=0;j<N;j++)putchar(p[j]?sel[j]?'R':'U':sel[j]?'L':'D');
		puts("");
	}
}
main()
{
	scanf("%lld",&n);
	int q[2]={0,0},lim=0;
	for(int i=0;i<n;i++)scanf("%lld%lld",x+i,y+i),q[(x[i]+y[i])&1]++,lim=max(lim,abs(x[i]+y[i]));
	if(q[0]&&q[1])return puts("-1"),0;
	if(lim&1)proc(0);
	else proc(1);
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))

int n, q;
string s;
string t;
string d;

bool ok(int x, int mode)
{
    rep (i, q)
    {
        if (d[i] == 'L')
        {
            if (s[x] == t[i]) --x;
            if (x < 0) return mode == 1;
        }
        else
        {
            if (s[x] == t[i]) ++x;
            if (x >= n) return mode == 0;
        }
    }

    return true;
}

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

    cin >> n >> q;

    cin >> s;

    t.resize(q);
    d.resize(q);
    rep (i, q)
    {
        cin >> t[i] >> d[i];
    }

    int ans = n;
    int l, r;
    l = -1; r = n;
    while (l + 1 < r)
    {
        int m = (l + r) / 2;
        if (ok(m, 0)) r = m;
        else l = m;
    }
    ans -= r;

    l = -1; r = n;
    while (l + 1 < r)
    {
        int m = (l + r) / 2;
        if (ok(m, 1)) l = m;
        else r = m;
    }
    ans -= n - l - 1;

    cout << ans << "\n";
    return 0;
}



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

int main(){
  int n,k;
  cin >> n >> k;
  int sum=0;
  vector<int> x(n);
  for(int i=0;i<n;i++){
    cin >> x[i];
  }
  for(int i=0;i<n;i++){
    if(x[i]>=k-x[i]){
      sum += 2*(k-x[i]);
    }else{
      sum += 2*x[i];
    }
  }
    cout << sum << endl;
}

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



int main(){
  int N;
  cin >> N;
  int tempmin;
  cin >> tempmin;
  int ans = 1;
  for (int i = 0; i<N-1; i++){
    int t;
    cin >> t ;
    if (tempmin >= t){tempmin = t; ans++;}
  }
  cout << ans << endl;


  return 0;
}

Measured memory_bytes: 256
N = gets.to_i
as = [0] + gets.split.map(&:to_i)

l = Array.new(N+2, 0)
r = Array.new(N+2, 0)
(1..N).each do |i|
    l[i] = l[i-1].gcd(as[i])
end
N.downto(1) do |i|
    r[i] = r[i+1].gcd(as[i])
end

ans = 0
(1..N).each do |i|
    res = l[i-1].gcd(r[i+1])
    ans = res if ans < res
end
puts ans

Measured memory_bytes: 10892