akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>

#define rep(i,n) for(int i=0;i<(n);i++)
#define EPS (1e-7)
#define INF (2e9)

using namespace std;
typedef long long int ll;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef priority_queue<int> PQI;
typedef priority_queue<int,vector<int>,greater<int> > PQSI;
typedef priority_queue<ll> PQL;
typedef priority_queue<ll,vector<ll>,greater<ll> > PQSL;

const int MOD = 1000000007;
struct mint { int n; mint(int n_ = 0) : n(n_) {} };
mint operator-(mint a) { return -a.n + MOD * (a.n != 0); }
mint operator+(mint a, mint b) { int x = a.n + b.n; return x - (x >= MOD) * MOD; }
mint operator-(mint a, mint b) { int x = a.n - b.n; return x + (x < 0) * MOD; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }
istream &operator>>(istream &i, mint &a) { return i >> a.n; }
ostream &operator<<(ostream &o, mint a) { return o << a.n; }

vector<mint> F_{1, 1}, R_{1, 1}, I_{0, 1};
void check_fact(int n) {
  for (int i = I_.size(); i <= n; i++) {
    I_.push_back(I_[MOD % i] * (MOD - MOD / i));
    F_.push_back(F_[i - 1] * i);
    R_.push_back(R_[i - 1] * I_[i]);
  }
}

mint I(int n) { check_fact(abs(n)); return n >= 0 ? I_[n] : -I_[n]; }
mint F(int n) { check_fact(n); return n < 0 ? 0 : F_[n]; }
mint R(int n) { check_fact(n); return n < 0 ? 0 : R_[n]; }
mint C(int n, int r) { return F(n) * R(n - r) * R(r); }
mint P(int n, int r) { return F(n) * R(n - r); }
mint H(int n, int r) { return n == 0 ? (r == 0) : C(n + r - 1, r); }

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T>
T gcd(T x, T y){
    if (y == 0) return x;
    else return gcd(y, x % y);
}

template<typename T>
T lcm(T x, T y){
    return (x / gcd(x, y)) * y;
}

int N;
int H1[100000];
int main(void){
    cin >> N;
    rep(i,N) cin >> H1[i];

    if(N==1) cout << "Yes" << endl;
    else if(N==2){
        if (H1[0]-H1[1] >= 2) cout << "No" << endl;
        else cout << "Yes" << endl;
    }else{
        int c = 0;
        for(int i=0;i<N-1;i++){
            c += H1[i+1] - H1[i];
            if (c < -1) {
                cout << "No" << endl;
                return 0;
            }
            c = min(0,c);
        }
        cout << "Yes" << endl;
    }
    return 0;
}



Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<endl;
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;
const ll inf=1e15;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  vector<int> a(n+1);
  vector<vector<int>> cnt(n+1,vector<int>(30,0));
  FOR(i,1,n+1){
    cin>>a[i];
    rep(j,30){
      if(a[i] & 1<<j) cnt[i][j]=1;
    }
  }
  /*
  FOR(i,1,n+1){
    rep(j,30) cout<<cnt[i][j]<<' ';
    cout<<endl;
  }
  */
  ll ans=0;
  int r=1;
  vector<int> used(30,0);
  FOR(l,1,n+1){
    if(r<l) r=l;
    bool flag=true;
    while(flag && r!=n+1){
      rep(j,30){
        if(a[r] & 1<<j){
          if(used[j]) flag=false;
        }
      }
      if(flag){
        rep(j,30)if(a[r] & 1<<j)used[j]=1;
        r++;
      }
    }
    ans+=r-l;
    rep(j,30) if(a[l] & 1<<j) used[j]=0;
    //cout<<l<<' '<<r<<endl;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 30720
#include <bits/stdc++.h>
#define forn(i, n) for (int i = 0; i<(int)n; ++i)
#define forr(i, t, n) for (int i = t; i<n; ++i)
#define rmod(x, y) (((x%y)+y)%y)
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
const int maxn = 1024;

int main() {
	ll n;
	cin >> n;
	ll d1, d2;
	ll ans = 1e16;
	for(ll i = 1; i*i<=n; i++){
		if (not (n%i)){
			d1 = i;
			d2 = n/i;
			ans = min(ans, d1+d2-2);
		}
	}
	cout << ans;
	
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)
#define bg begin()
#define ed end()
#define all(x) x.bg, x.ed
#define vi vector<int>
template <class t, class u>
bool chmax(t &a, u b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class t, class u>
bool chmin(t &a, u b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}

signed main()
{
    string a, b, c;
    cin >> a >> b >> c;
    int turn = 0;
    int aa = 0;
    int bb = 0;
    int cc = 0;
    while (true)
    {
        if (turn == 0)
        {
            if (aa == a.size())
            {
                cout << "A" << endl;
                return 0;
            }
            else
            {
                turn = a[aa] - 'a';
                aa++;
            }
        }
        else if (turn == 1)
        {
            if (bb == b.size())
            {
                cout << "B" << endl;
                return 0;
            }
            else
            {
                turn = b[bb] - 'a';
                bb++;
            }
        }
        else if (turn == 2)
        {
            if (cc == c.size())
            {
                cout << "C" << endl;
                return 0;
            }
            else
            {
                turn = c[cc] - 'a';
                cc++;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3624
# 2019/4/11 17:00 ~ 21:39 記念
import heapq
from itertools import accumulate
X, Y, Z, K =  map(int, (input().split(' ')))
A =  sorted(list(map(int, (input().split(' ')))))[::-1]
B =  sorted(list(map(int, (input().split(' ')))))[::-1]
C =  sorted(list(map(int, (input().split(' ')))))[::-1]

### default
default = A[0] + B[0] + C[0]
Ai = 0
Bi = 0
Ci = 0
# 最小値を取っていくリストには巨大な数を入れておけば安全(out of rangeを防げる)
hoge = [10**20] *100
#used = [[[[0] * 1000] for _ in range(1000)] for _ in range(1000)]
used = set()


# 隣の要素との差を取る
A = [0] + [i - j for i, j in zip(A[:-1], A[1:])] + hoge
B = [0] + [i - j for i, j in zip(B[:-1], B[1:])] + hoge
C = [0] + [i - j for i, j in zip(C[:-1], C[1:])] + hoge
# 累積和
A = list(accumulate(A))
B = list(accumulate(B))
C = list(accumulate(C))
heap = []
print(default)
for _ in range(K-1):
    # 常に最小値がpopされるheapを用いる(貪欲法+条件を満たす葉を展開する)
    # ここでは、最小値だった葉を展開している
    if (Ai+1, Bi, Ci) not in used:
        heapq.heappush(heap, (A[Ai+1] + B[Bi] + C[Ci], "A", (Ai+1, Bi, Ci)))
        used.add((Ai+1, Bi, Ci))

    if (Ai, Bi+1, Ci) not in used:
        heapq.heappush(heap, (A[Ai] + B[Bi+1] + C[Ci], "B", (Ai, Bi+1, Ci)))
        used.add((Ai, Bi+1, Ci))

    if (Ai, Bi, Ci+1) not in used:
        heapq.heappush(heap, (A[Ai] + B[Bi] + C[Ci+1], "C", (Ai, Bi, Ci+1)))
        used.add((Ai, Bi, Ci+1))

    mi = heapq.heappop(heap)
    # 最高に美味しいケーキからの差分
    print(default - mi[0])
    # 展開時に次の葉のアドレスを仕込んでおく(いつ展開されるか未定なので)
    Ai, Bi, Ci = mi[2]


Measured memory_bytes: 5544
import sys

input = sys.stdin.readline


def main():
    M, D = map(int, input().split())

    ans = 0
    for m in range(1, M + 1):
        for d in range(10, D + 1):
            d_10 = d // 10
            d_1 = d % 10
            if d_1 >= 2 and d_10 >= 2 and d_1 * d_10 == m:
                ans += 1

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ans=0

for i,bb in enumerate(b):
    ans+=min(a[i], bb)
    sub=max(bb-a[i], 0)
    ans+=min(a[i+1], sub)
    a[i+1] = max(a[i+1]-sub, 0)
print(ans)

Measured memory_bytes: 19116
#include<cstdio>
#include<algorithm>
#include<cmath>
#define fo(i,a,b) for(i=a;i<=b;i++)
#define fd(i,a,b) for(i=a;i>=b;i--)
using namespace std;
typedef long long ll;
typedef double db;
const int maxn=200000+10,maxlen=maxn*4,mo=924844033,GG=5;
int size[maxn],h[maxn],go[maxn*2],nxt[maxn*2];
int w[maxlen],a[maxlen],b[maxlen],tt[maxlen],c[maxlen],rev[maxlen],fac[maxn],inv[maxn];
int i,j,k,l,t,n,m,tot,len,ans,ni;
db ce;
void add(int x,int y){
	go[++tot]=y;
	nxt[tot]=h[x];
	h[x]=tot;
}
int qsm(int x,int y){
	if (!y) return 1;
	int t=qsm(x,y/2);
	t=(ll)t*t%mo;
	if (y%2) t=(ll)t*x%mo;
	return t;
}
void dfs(int x,int y){
	a[n]++;
	int t=h[x];
	size[x]=1;
	while (t){
		if (go[t]!=y){
			dfs(go[t],x);
			a[size[go[t]]]--;
			size[x]+=size[go[t]];
		}
		t=nxt[t];
	}
	a[n-size[x]]--;
}
void prepare(){
	w[0]=1;
	w[1]=qsm(GG,(mo-1)/len);
	fo(i,2,len) w[i]=(ll)w[i-1]*w[1]%mo;
	fo(i,0,len-1){
		int p=0;
		for(int j=0,tp=i;j<ce;j++,tp/=2) p=(p<<1)+(tp%2);
		rev[i]=p;
	}
	ni=qsm(len,mo-2);
}
void DFT(int *a,int sig){
	int i;
	fo(i,0,len-1) tt[rev[i]]=a[i];
	for(int m=2;m<=len;m*=2){
		int half=m/2,bei=len/m;
		fo(i,0,half-1){
			int wi=sig>0?w[i*bei]:w[len-i*bei];
			for(int j=i;j<len;j+=m){
				int u=tt[j],v=(ll)tt[j+half]*wi%mo;
				tt[j]=(u+v)%mo;
				tt[j+half]=(u-v)%mo;
			}
		}
	}
	if (sig==-1)
		fo(i,0,len-1) tt[i]=(ll)tt[i]*ni%mo;
	fo(i,0,len-1) a[i]=tt[i];
}
void NTT(){
	DFT(a,1);DFT(b,1);
	fo(i,0,len-1) a[i]=(ll)a[i]*b[i]%mo;
	DFT(a,-1);
	fo(i,0,len-1) c[i]=a[i];
}
int main(){
	scanf("%d",&n);
	fo(i,1,n-1){
		scanf("%d%d",&j,&k);
		add(j,k);add(k,j);
	}
	dfs(1,0);
	fac[0]=1;
	fo(i,1,n) fac[i]=(ll)fac[i-1]*i%mo;
	inv[n]=qsm(fac[n],mo-2);
	fd(i,n-1,0) inv[i]=(ll)inv[i+1]*(i+1)%mo;
	fo(i,0,n) a[i]=(ll)a[i]*fac[i]%mo;
	fo(i,0,n) b[i]=inv[i];
	reverse(b,b+n+1);
	len=1;
	while (len<=2*n) len*=2;
	ce=log(len)/log(2);
	prepare();
	NTT();
	fo(i,1,n){
		ans=(ll)inv[i]*c[n+i]%mo;
		(ans+=mo)%=mo;
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 35072
//============================================================================
// Name        : filename.cpp
// Author      : abb
// Version     :
// Copyright   : [My copyright notice]
// Description : test program
//============================================================================

/*
A - Airplane

実行時間制限: 2 sec / メモリ制限: 1024 MB

配点 : 100 点

問題文
空港 A, B, C があり、それぞれの空港の間では、双方向に飛行機が運航しています。
空港 A, B 間の飛行時間は片道 P 時間、空港 B, C 間の飛行時間は片道 Q 時間、空港 C, A 間の飛行時間は片道 R 時間です。
いずれかの空港からスタートして他の空港に飛行機で移動し、さらにそのどちらでもない空港に飛行機で移動するような経路を考えます。
飛行時間の和は最短で何時間になるでしょうか。

制約

・1 <= P, Q, R <= 100
・入力は全て整数である
 */

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

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

using ll = long long;
using ull = unsigned long long;

#define REP(i, m, n) for (ll i = (m); i < (ll)(n); ++(i))
#define REPM(i, m, n) for (ll i = (m); i <= (ll)(n); ++(i))
#define REPR(i, m, n) for (ll i = (m); i >= (ll)(n); --(i))
#define REPD(i, m, n, d) for (ll i = (m); i < (ll)(n); i += (d))
#define REPMD(i, m, n, d) for (ll i = (m); i <= (ll)(n); i += (d))
#define ALL(x) begin(x), end(x)

/**
 * エントリポイント．
 * @return 0.
 */
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    ll p, q, r;
    cin >> p >> q >> r;
    cout << (p + q + r - max({p, q, r})) << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
		static void Main(){
		Sc sc=new Sc();
		var n=sc.L;
		long q=(long)Sqrt(n);
		if(q*q==n){ 
			Console.WriteLine("0 0 {0} 0 0 {0}",q);
		}
		else{
			long x1=1,y1=0,x2=q,y2=n-q*(q-1),x3=0,y3=q;
			while(y2>1000000000){
				if(x2<1000000000){x2++;}
				else{y3++;}
				y2-=Abs((x2-x1)*(y3-y1)-(y2-y1)*(x3-x1))-n;
			}
			Console.WriteLine("{0} {1} {2} {3} {4} {5}",x1,y1,x2,y2,x3,y3);
		}
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}


Measured memory_bytes: 13268
n, a, b = input().split()

n = int(n)
a = int(a)
b = int(b)

sum = 0

for i in range(1,n+1):
	dat = str(i)
	w_sum = 0
	for d in dat:
		w_sum = w_sum + int(d)
	if (w_sum>=a and w_sum<=b):
		sum = sum + i
	
print(sum)

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int K;
int gcd(int a,int b,int c){
    int m=0;
    for(int i=1;i<=K;i++){
        if(i>a||i>b||i>c){
            break;
        }else{
            if(a%i==0&&b%i==0&&c%i==0){
                m=i;
            }
        }
    }
return m;
}

int main(){
    cin >> K;
    long long int sum = 0;
    for(int i=1;i<=K;i++){
        for(int j=1;j<=K;j++){
            for(int k=1;k<=K;k++){
                sum += gcd(i,j,k);
            }
        }
    }
    cout << sum;
    return 0;
}

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

int main(){
    long long int a,b,c;
    cin >> a;
    b =1;
    vector<string> shou(a);
    for(int i=0;i < a;i++){
        cin >> shou.at(i);
    }
    sort(shou.begin(),shou.end());
    for(int i=0;i <a-1;i++){
        int ii= i+1;
        if(shou.at(i) != shou.at(ii)){
            b++;
        }
    }
    cout << b <<endl;

}



Measured memory_bytes: 9600
import sys

k,n=map(int,sys.stdin.readline().split())
a=list(map(int,sys.stdin.readline().split()))

max=0
for i in range(n):
    if i==0:
        pre=a[i]
    else:
        now=a[i]
        if now-pre>max:
            max=now-pre
        pre=now
if k-pre+a[0]>max:
    max=k-pre+a[0]
print(k-max)


Measured memory_bytes: 25880
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String pre = "", str = "", ans = "Yes";

		for (int i = 0; i < n; i++) {
			str = sc.next();
			if (i > 0 && (!pre.substring(pre.length()-2, pre.length()-1).equals(str.substring(0, 1)) || pre.contains("*"+str+"*"))) {
				ans = "No";
			} else {
				pre += "*"+str+"*";
			}
		}
		
		

		System.out.println(ans);
		sc.close();
	}

}


Measured memory_bytes: 22612
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        double[] v = new double[N];
        for (int i = 0; i < N; i++) {
            v[i] = Double.parseDouble(sc.next());
        }

        Arrays.sort(v);
        double res = (v[0] + v[1]) / 2;

        for (int i = 2; i < N; i++) {
            res = (res + v[i]) / 2;
        }
        System.out.println(res);
    }
}


Measured memory_bytes: 23892
#include <bits/stdc++.h>
#define rep(i, n) for(int i= 0; i < (n); i++)
using ll= long long int;
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; }
ll mod= 1e9 + 7;


int main(){
  int n,m,x;
  cin >> n >>m >>x;
  int a[m];
  rep(i,m)cin >> a[i];
  int g=lower_bound(a,a+m,x)-a;
  cout << min(g,m-g) << endl;
}

Measured memory_bytes: 3592
n,m=map(int,input().split())
li = [list(map(int,input().split())) for i in range(n)]
li.sort()
money = 0
num=0
while num < m:
  if num + li[0][1] < m:
    num += li[0][1]
    money += li[0][0] * li[0][1]
  else:
    money += li[0][0] * (m - num)
    num = m
  del li[0]
print(money)

Measured memory_bytes: 27756
N,K = map(int, input().split())

H = list(map(int, input().split()))
INF = float("inf")
dp = [INF] * N
dp[0] = 0
dp[1] = abs(H[0] - H[1])

for i in range(2, N):
    # １マス～Kマス先まで飛ぶ。ｊを１～Kまで動かす
    for j in range(1, K+1):
        if i-j < 0:
            break # スタートより後ろに戻る場合は飛ばす
        dp[i] = min(dp[i], dp[i-j] + abs(H[i] - H[i-j])) 

print(dp[-1])

Measured memory_bytes: 54880
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
long long mod = 1000000007;
const int INF = 1001001001;

int main(){
  ll n; cin >> n;
  ll ans = 1;
  vector<ll> count(100001,0);
  for(ll i=0;i<n;i++){
    ll scope; cin >> scope;
    if(scope == 0){
      ans = ans * (3-(count.at(scope))) % mod; 
    }else{
      ans = ans*( count.at(scope-1) - count.at(scope))%mod;
    }
    count.at(scope)++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1152
import collections
cc = collections.Counter()
for _ in range(int(raw_input())):
	v = int(raw_input())
	cc[v] += 1
	if cc[v] == 2:
		cc[v] = 0
s = 0
for k in cc:
	if cc[k] == 1:
		s +=1
print s

Measured memory_bytes: 98988
import java.awt.*;
import java.awt.geom.*;
import java.io.*;
 
import java.util.*;
class Main {
 
    static char[] xx = new char[] {'S','H','C','D'};
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(true) {
            int m = sc.nextInt();
            int f = sc.nextInt();
            int r = sc.nextInt();
            if(m == -1 && f == -1 && r == -1) break;
             
            if(m == -1 || f == -1) {
                System.out.println("F");
                continue;
            }
            if(m + f >= 80) {
                System.out.println("A");
                continue;
            }
            else if(m + f >= 65) {
                System.out.println("B");
            }
            else if(m + f >= 50) {
                System.out.println("C");
            }
            else if(m +f < 30) {
                System.out.println("F");
            }
            else {
                System.out.println((r >= 50)?"C":"D");
            }
             
        }
 
    }
}


Measured memory_bytes: 26376
n=int(input())
l=list(map(int,input().split()))
d={}
for a in l:
    if a in d:
        d[a]+=1
    else:
        d[a]=1
ks=sorted(d,reverse=True)
f=0
for i,k in enumerate(ks):
    if d[k]>=4:
        print(k*k)
        exit()
    if d[k]>=2:
        f=k
        break
s=0
for k in ks[i+1:]:
    if d[k]>=2:
        s=k
        break
print(f*s)


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

#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const ll MOD = 1e9+7;
ll N;

bool prime[1005];
ull c[1005];

void eratoutenes(int n) {
  for (int i = 2; i * i <= n; ++i) {
    if (prime[i]) {
      for (int k = 2*i; k <= n; k += i) {
        prime[k] = false;
      }
    }
  }
}

int main() {
  cin >> N;
  fill(prime, prime+1005, true);
  eratoutenes(N);

  for (int i = 2; i <= N; ++i) {
    for (int k = 2; k <= i; ++k) {
      if (prime[k] && i%k == 0) {
        int t = i;
        while (t >= k && t%k == 0) {
          ++c[k]; t /= k;
        }
        c[k] %= MOD;
      }
    }
  }

  ull ans = 1;
  for (int i = 2; i <= N; ++i) {
    if (prime[i]) {
      ans *= c[i]+1;
      ans %= MOD;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int main(){
   int  N ;
   scanf("%d", &N) ;
   int arr[3] , i , rest = N ;

   for(i = 0 ; i <3 ; i++) {
        arr[i] = rest %10 ;
        rest = rest / 10 ;
   }

   if(arr[0] == arr[2]){
    printf("Yes");
   }else{
    printf("No");
   }
}


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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}
int main() {
	std::string s, t;
	std::cin >> s >> t;
	int n = s.size(), m = t.size();
	int dp[n + 1][m + 1];
	std::pair<int, int> from[n + 1][m + 1];
	memset(dp, 0, sizeof(dp));
	for (int i = 0; i <= n; i++) for (int j = 0; j <= m; j++) {
		if (i < n && dp[i + 1][j] < dp[i][j]) dp[i + 1][j] = dp[i][j], from[i + 1][j] = {i, j};
		if (j < m && dp[i][j + 1] < dp[i][j]) dp[i][j + 1] = dp[i][j], from[i][j + 1] = {i, j};
		if (i < n && j < m) {
			int score = dp[i][j] + (s[i] == t[j]);
			if (dp[i + 1][j + 1] < score) dp[i + 1][j + 1] = score, from[i + 1][j + 1] = {i, j};
		}
	}
	std::string res;
	int x = n, y = m;
	while (x && y) {
		int new_x = from[x][y].first;
		int new_y = from[x][y].second;
		if (x == new_x + 1 && y == new_y + 1 && s[new_x] == t[new_y]) res.push_back(s[new_x]);
		x = new_x, y = new_y;
	}
	std::reverse(res.begin(), res.end());
	std::cout << res << std::endl;
	return 0;
}


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

int main(void){
    int d;
    cin >> d;
    vector<int> c(26);
    for (int i = 0; i < 26; i++) cin >> c.at(i);
    
    vector<vector<int>> s (d, vector<int> (26));
    for(int j = 0; j < d; j++) for(int i = 0; i < 26; i++) cin >> s.at(j).at(i);
    
    int score = 0;
    vector<int> last(26,-1);
    
    for(int i = 0; i < d; i++) {
        int mx = 0;
        for(int j = 0; j < 26; j++) {
         mx = max(mx,s.at(i).at(j));
        }
        score += mx;
        
        int select = 0;
        for(int j = 0; j < 26; j++) {
         if (mx == s.at(i).at(j)) select = j;
        }  
        last.at(select) = i;
        
        for(int j = 0; j < 26; j++) {
         score -= c.at(j) * (i - last.at(j));
        }
        //cout << select+1 << endl;
        }
        for(int i = 0; i < 365; i++) cout << 1 << endl;
}



Measured memory_bytes: 3676
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int k;
    cin >> k;
    string s;
    cin >> s;
    int n = sz(s);
    if (n <= k) {
        cout << s << endl;
    } else {
        cout << s.substr(0, k) + "..." << endl;
    }
}

Measured memory_bytes: 3668
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define EACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
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; }
template<class Value>using vec = vector< Value >;
using ll = long long;
using P = pair< long long, long long >;
#define fi first
#define se second
#define el endl
#pragma endregion

void Main();

int main(){
    std::cin.tie(nullptr);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}

void Main(){
    ll A, B, M;
    cin >> A >> B >> M;
    vec<ll> a(A), b(B);
    ll a_min = LONG_LONG_MAX, b_min = LONG_LONG_MAX;
    REP(i, A){
        cin >> a[i];
        chmin(a_min, a[i]);
    }
    REP(i, B){
        cin >> b[i];
        chmin(b_min, b[i]);
    }
    ll mn = a_min + b_min;
    REP(i, M){
        ll x, y, c;
        cin >> x >> y >> c;
        x--;y--;
        chmin(mn, a[x]+b[y]-c);
    }
    cout << mn << el;
}



Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <math.h>
#include <ctype.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;

int main() {
	string S, T;
	cin >> S >> T;

	int N = S.size();
	int M = 0;

	for (int i = 0; i < N; i++) {
		if (S == T) {
			M = 1;
			break;
		}
		S = S.back() + S.substr(0, S.size() - 1);
	}
	if (M == 0) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <random>
#include <cassert>
#include <cstring>
#include <chrono>
#include <set>
#include <map>

using namespace std;

typedef long long ll;

const ll mod = 998244353;

ll dp[3001][3001][3];

ll Solve(int at, int have, int state, const vector<int>& a, int s) {
  if (at == a.size()) {
    if (have == s && state == 2) return 1;
    return 0;
  }

  if (have > s) return 0;

  ll& result = dp[at][have][state];
  if (result != -1) return result;

  result = 0;

  if (state == 0) {
    result = Solve(at + 1, have, state, a, s) + Solve(at, have, state + 1, a, s);
    result %= mod;
  }

  if (state == 1) {
    result = Solve(at + 1, have, state, a, s) + Solve(at + 1, have + a[at], state, a, s) + Solve(at, have + a[at], state + 1, a, s) + Solve(at, have, state + 1, a, s);
    result %= mod;
  }

  if (state == 2) {
    result = Solve(at + 1, have, state, a, s);
  }

  return result;
}

int main()
{
  int n, s;
  cin >> n >> s;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];

  memset(dp, -1, sizeof(dp));
  cout << Solve(0, 0, 0, a, s) << endl;

  return 0;
}


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

int main() {
    vector<vector<vector<int>>> N(4, vector<vector<int>> (3, vector<int> (10, 0)));
    int n;
    cin >>n;
    for (int i=0; i<n; i++) {
        int b, f, r, v;
        cin >>b >>f >>r >>v;
        b--;
        f--;
        r--;
        N.at(b).at(f).at(r) +=v;
    }
    for (int b=0; b<4; b++) {
        if (b!=0)
            cout <<"####################" <<endl;
        for (int f=0; f<3; f++) {
            for (int r=0; r<10; r++)
                cout <<' ' <<N.at(b).at(f).at(r);
            cout <<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3164
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>

using namespace std;

int main() {
    int r, D, x_2000;
    cin >> r >> D >> x_2000;
    
    auto cur = x_2000;
    for(int i = 0; i < 10 ; ++i) {
        auto next = r * cur - D;
        cout << next << endl;
        cur = next;
    }
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
const int N=1000010,P=998244353;
inline int read(){
	int x=0,f=0,c=getchar();
	for(;c>'9'||c<'0';f=c=='-',c=getchar());
	for(;c>='0'&&c<='9';c=getchar())
	x=(x<<1)+(x<<3)+c-'0';return f?-x:x;
}
inline void write(ll x){
	if(x<0)putchar('-'),x=-x;
	if(x>9)write(x/10);putchar(x%10+'0');
}
char s[N],t[N];
int n,ans;
void solve(char c){
	int m=n,ct=0,i,re;
	for(i=1;i<=m;i++)t[i]=s[i],ct+=(t[i]==c);
	if(!ct){return;}if(ct==m){ans=0;return;}
	for(re=0;ct<m;re++){
		ct=0;m--;
		for(i=1;i<=m;i++)
			t[i]=(t[i+1]==c)?t[i+1]:t[i],ct+=(t[i]==c);
	}ans=min(ans,re);
}
int main(){
	//freopen("1.out","w",stdout);
	int i;scanf("%s",s+1);
	n=strlen(s+1);ans=n;
	solve('v');
	for(i=0;i<26;i++)solve('a'+i);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include<cstdio>
using namespace std;
int main(void)
{
	int nedan[5]={0,6000,4000,3000,2000};
	int t,n;
	int kin,i;

	for(i=0;i<4;i++)	{
		scanf("%d %d",&t,&n);
		kin=nedan[t]*n;
		printf("%d\n",kin);
	}
	return 0;
}


Measured memory_bytes: 1028
using System;

class Program
{
    static void Main()
    {
        String[] arr = Console.ReadLine().Split();
        int A = int.Parse(arr[0]), B = int.Parse(arr[1]), C = int.Parse(arr[2]);
        bool flg = false;
        if (A == B && B != C)
            flg = true;
        else if (B == C && C != A)
            flg = true;
        else if (C == A && A != B)
            flg = true;
        Console.WriteLine(flg ? "Yes" : "No");
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>  // sort, 二分探索, etc
#include <iomanip>  // setprecision (浮動小数点の出力の誤差)
#include <map>
#include <queue>
#include <set>
#include <stack>

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=a,i##_len=(b);i<i##_len;++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define cauto const auto&
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define SIZE(x) ((ll)(x).size()) // sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define MOD 1000000007
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

using namespace std;
using ll = long long;
using ull = unsigned long long;

template<class T>bool chmax(T &a, const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b;return true;}return false;}

const char newl = '\n';

ll qp(ll a,ull b){ll ans=1;do{if(b&1u)ans*=a;a*=a;}while(b>>=1u);return ans;}
ll qp(ll a,ull b,ll mod){ll ans=1;do{if(b&1u)ans=ans*a%mod;a=a*a%mod;}while(b>>=1u);return ans;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll comb(int n, int r) {
    vector<vector<ll> > v(n+1, vector<ll>(r+1, 0));
    for(int i=0;i<n+1;i++) {v[i][0]=1; if(i < r+1)v[i][i]=1; }
    for(int i=1;i<n+1;i++) {for(int j=1;j<min(i,r+1);j++) {v[i][j]=v[i-1][j-1]+v[i-1][j];}}
    return v[n][r];
}

// INT_MAX   = 2.1e+09 (2147483647)
// LONG_MAX  = 9.2e+18 (9223372036854775807)
// LLONG_MAX = 9.2e+18 (9223372036854775807)


int main() {
    ll a, b, c, k;
    cin >> a >> b >> c >> k;

    if (k <= a) {
        cout << k << newl;
        return 0;
    } else if (k - a <= b) {
        cout << a << newl;
        return 0;
    } else {
        cout << a - (k - (a + b)) << newl;
        return 0;
    }
}


Measured memory_bytes: 3196
s = input()
str_list = []
sec_list = []
flag = 0
for i in s:
    if (i in str_list) and (i not in sec_list):
        flag += 1
        sec_list.append(i)
    else:
        str_list.append(i)
        
if flag == 2:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
//#pragma GCC optimize(2)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define rep(i,a,b) for(int i = (a);i <= (b);i++)
#define per(i,a,b) for(int i = (a);i >= (b);i--)
#define pii pair<int,int>
#define pll pair<long long, long long>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 2e5 + 5;
const double eps = 1e-8;
const double pi = acos(-1.0);	
ll gcd(ll a,ll b){return !b?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a * b / gcd(a,b);}
ll qw(ll x,ll y){ll res = 1;while(y){if(y & 1) res *= x;x = x * x;y >>= 1;}return res;}
ll poww(ll x,ll y,ll p){ll ans = 1;while(y){if(y & 1) ans = ans * x % p;x = x * x % p;y >>= 1;}return ans % p;}
bool isp(ll x){if(x < 2) return 0; for(ll i = 2;i * i <= x;i++){if(x % i == 0) return 0;}return 1;}
ll n;
void solve(){
	string ans = "";
	while(n){
		int cur = n % 26;
		if(!cur) ans += 'z';
		else ans += (cur - 1 +  'a');
		n -= 1;
		n /= 26;
	}
	reverse(all(ans));
	cout << ans << endl;
}
int main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n;
	solve();	
	return 0;
}
//do smt instead of nothing! never give up!


Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
typedef long long ll;
using namespace std;
typedef struct {
	ll sum[4][4][4];
	int len;
} DP;

ll Nsum(DP A)
{
	ll ans = 0;
	int i, j, k;
	DP A_next;
	if (A.len == 3)
	{
		for (i = 0; i < 4; i++)
		{
			for (j = 0; j < 4; j++)
			{
				for (k = 0; k < 4; k++)
				{
					ans += A.sum[i][j][k];
					ans = ans % 1000000007;
				}
			}
		}
		return ans;
	}
	else
	{
		A_next.len = A.len - 1;
		for (i = 0; i < 4; i++)
		{
			for (j = 0; j < 4; j++)
			{
				for (k = 0; k < 4; k++)
				{
					A_next.sum[i][j][k] = 0;
					if ((i != 1 || j != 2 || k != 3) && (i != 2 || j != 1 || k != 3) && (i != 1 || j != 3 || k != 2))
					{
						A_next.sum[i][j][k] += A.sum[0][i][j];
						if ((j != 2 || k != 3) && (i != 2 || k != 3))
							A_next.sum[i][j][k] += A.sum[1][i][j];
						A_next.sum[i][j][k] += A.sum[2][i][j];
						A_next.sum[i][j][k] += A.sum[3][i][j];
						A_next.sum[i][j][k] = A_next.sum[i][j][k] % 1000000007;
					}
				}
			}
		}
		ans = Nsum(A_next);
	}
	
}

int main() 
{
	ll ans_sum = 0;
	DP T;
	int i, j, k, len;
	cin >> len;
	T.len = len;
	for (i = 0; i < 4; i++)
	{
		for (j = 0; j < 4; j++)
		{
			for (k = 0; k < 4; k++)
			{
				if ((i != 1 || j != 2 || k != 3) && (i != 2 || j != 1 || k != 3) && (i != 1 || j != 3 || k != 2))
				T.sum[i][j][k] = 1;
				else T.sum[i][j][k] = 0;
			}
		}
	}
	ans_sum = Nsum(T);
	cout << ans_sum << endl;
}

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


int main(void){
	int a,b,c,k;
	cin >> a >> b >> c >> k;
	cout << max(max(a,b),c)*pow(2,k)+a+b+c-max(max(a,b),c) << endl;

	return 0
	;
}

Measured memory_bytes: 256
# frozen_string_literal: true

_ = gets
h = Hash.new(0)
gets.split.map(&:to_i).each do |i|
  rate = case i
         when 1...400     then :grey
         when 400...800   then :brown
         when 800...1200  then :green
         when 1200...1600 then :light_blue
         when 1600...2000 then :blue
         when 2000...2400 then :yellow
         when 2400...2800 then :orange
         when 2800...3200 then :red
         else                  :wild
         end
  h[rate] += 1
end

s = h.size

if h[:wild] == 0
  min = max = s
else
  min = s == 1 ? 1 : s - 1
  max = s - 1 + h[:wild]
end

puts "#{min} #{max}"

Measured memory_bytes: 1788
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
using namespace std;
int main() {
	int t;
	vector<double> list;
	cin >> t;
	for (int i = 0; i < t; i++) {
		int n, m;
		double ra = 0,sum=0;
		cin >> n >> m;
		for (int j = 0; j < m; j++) {
			double v, r;
			cin >> v >> r;
			ra += v*r;
			sum += r;
		}
		ra /= sum;
		list.push_back(ra);
	}
	int n, m;
	double ra = 0,sum=0;
	cin >> n >> m;
	for (int j = 0; j < m; j++) {
		double v, r;
		cin >> v >> r;
		ra += v*r;
		sum += r;
	}
	ra /= sum;
	for (auto a : list) {
		if (a > ra + 0.0000001) {
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 3288
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main() {
	int n;
	cin >> n;
	vector<ll> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a.at(i);
	}
	ll t = 0;
	for (int i = 0; i < a.size(); i++) {
		if (i % 2 == 1) t -= a.at(i);
		else t += a.at(i);
	}
	//cout << t;
	vector<ll> ans(n);
	ans.at(0) = t;
	for (int i = 1; i < n; i++) {
		ans.at(i) = a.at(i - 1) - ans.at(i - 1) / 2;
		ans.at(i) = ans.at(i) * 2;
	}
	for (int i = 0; i < n; i++) {
		cout << ans.at(i);
		if (i != n - 1) cout << ' ';
	}
	cout << endl;
}

Measured memory_bytes: 2944
#include <iostream>
#include <vector>
#include <algorithm>
#include <complex>
#include <cmath>
#include <cstdio>

using namespace std;

#define EPS (1e-10)
#define EQ(a,b) (abs((a)-(b))<EPS)

const double PI=4*atan(1.0);
typedef complex<double> P;

// àÏ
double dot(P a, P b) {
  return (a.real() * b.real() + a.imag() * b.imag());
}
// OÏ
double cross(P a, P b) {
  return (a.real() * b.imag() - a.imag() * b.real());
}
// a©çbÖ¶üèÅ½x©
double diffAngle(P a,P b){
  // cos>0&&sin>0 -> 0 -> 90
  // cos<0&&sin>0 -> 90->180
  // cos<0&&sin<0 -> 180->270
  // cos>0&&sin<0 -> 270 -> 359
    //double cosn=dot(a,b)/(abs(a)*abs(b));
    //double sinn=cross(a,b);
    //double angle=acos(cosn);
    //if(sinn>0||EQ(sinn,0))
    //    return angle;
    //return 2*PI-angle;
    double angle=atan2(cross(a,b),dot(a,b));
    if(angle<0)
        return 2*PI+angle;
//    return 0;
    return angle;
}

int main(){
    int n;
    while(cin>>n&&n!=0){
        vector<P> points;
        for(int i = 0; i < n; i++){
            int x,y;
            cin>>x>>y;
            points.push_back(P(x,y));
        }
        vector<bool> isUsed(points.size(),false);
        double sum=0;
        P cp=P(0,1);
        P pp=P(0,0);
        int cnt=n;
        while(cnt--){
            int idx=-1;
            double minAngle=100000000;
            for(int i = 0; i < points.size(); i++){
                if(isUsed[i]) continue;
                double ca=diffAngle(points[i]-pp,cp);
                //cout<<ca<<endl;
                if(EQ(minAngle,ca)){
                    if(abs(points[idx]-pp)>abs(points[i]-pp))
                        idx=i;
                }
                else if(minAngle>ca){
                    idx=i;
                    minAngle=ca;
                }
            }
            isUsed[idx]=true;
            double inc=abs(points[idx]-pp);
            sum+=inc;
            P p=(points[idx]-pp);
            cp=p/abs(p);
            pp=points[idx];
        }
        printf("%.1f\n",sum);
    }
    return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int N = sc.nextInt();
	int M = sc.nextInt();
	int X = sc.nextInt();
	int Y = sc.nextInt();
	int maxX = -100;
	int minY = 100;
	int x=0;
	int y=0;
	for(int i=0;i<N;i++){
	    x = sc.nextInt();
	    if(x>maxX) maxX=x;
	}
	for(int i=0;i<M;i++){
	    y = sc.nextInt();
	    if(y<minY) minY=y;
	}
	boolean result = false;
	for(int z=X+1;z<=Y;z++){
	    if(maxX<z && minY>=z) result=true;
	}
	if(result) System.out.print("No War");
	else System.out.print("War");
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int main(){
    ll n; cin>>n;
    vector<ll> d(n);
    rep(i,n) cin>>d[i];
    sort(d.begin(), d.end());
    cout<<d[n/2]-d[n/2-1]<<endl;
    return 0;
}

Measured memory_bytes: 1024
from sys import stdin

a=int(stdin.readline())
A=stdin.readline().split()
sum=0
for k in range(0,a+1):
    sum+=int(A[k])

sum-=int(A[a])
ver=1
lay=1
K=0
T=0

if a==0:
    if A[0]!='1':
        print(-1)
        K=1
    else:
        print(1)
        K=1

for l in range(0,a):
    if lay-int(A[l])<=0:
        print(-1)
        K=1
        break
    if (lay-int(A[l]))*2<int(A[a]) and l==(a-1):
        print(-1)
        K=1
        break
    if (lay-int(A[l]))*2-sum+int(A[l])<=int(A[a]):
        lay=(lay-int(A[l]))*2
        ver+=lay
        sum-=int(A[l])
        T=l
    else:
        lay-=int(A[l])
        sum-=int(A[l])
        x=lay-sum-int(A[a])
        if x==0:
           ver+=lay
        elif x>0:
            print(-1)
            K=1
        else:
           lay=sum+int(A[a])
           ver+=lay
        T=l
        break

if K==0:
    for u in range(T+1,a):
        lay -= int(A[u])
        sum -= int(A[u])
        ver+=lay

if K==0:
    print(ver)

Measured memory_bytes: 16840
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long 
#define REP(i, a, b) for (ll i = a; i < b; i++)
#define REPI(i, a, b) for (ll i = b - 1; i >= a; i--)
#define i_os ios::sync_with_stdio(0);  cin.tie(0);  cout.tie(0);
#define INF (ll)1e18 + 100
#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl
/*SOME BITMASK KNOWLEDGE
1)x & (x - 1):sets the last one bit of x to zero
power of two exactly when x & (x − 1) = 0.
2)x & -x:sets all the one bits to zero, except last one bit
3)x | (x - 1):inverts all the bits after the last one bit*/
#define o_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define o_setll tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
typedef tree<pair<ll, ll>,null_type,less<pair<ll, ll>>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set1;
typedef tree<string,null_type,less<string>,rb_tree_tag,tree_order_statistics_node_update> indexed_set2;
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set

int main() 
{
    ll h,w,k;
    cin>>h>>w>>k;
    ll arr[w][h];
    REP(i,0,h){
        string s;
        cin>>s;
        REP(j,0,w){
            arr[j][i] = s[j] - '0';
        }
    }
    ll ans = w*h;

    REP(p,1,(1 << h))
    {
        vector<ll> v;
        REP(j,0,h){
            if((p >> j) & 1) v.push_back(j);
        }
        sort(v.begin(),v.end());
        
        if(v.back() == h-1)
        {
            bool flag = 0;
            ll sum = v.size() - 1;
            ll dp[v.size()] = {0};
            ll prev = -1;
            ll row = 0;

            while(row < w)
            {
                bool f = 0;
                ll ind = 0;
                REP(i,0,h){
                    if(v[ind] < i){
                        ind++;
                    }
                    dp[ind] += arr[row][i];
                    if(dp[ind] > k){
                        f = 1;
                    } 
                }
                if(f == 1)
                {
                    REP(i,0,v.size()){
                        dp[i] = 0;
                    }
                    if(prev == row){
                        flag = 1;
                        break;
                    }
                    prev = row;
                    sum++;
                }
                else {
                    row++;
                }
            }
            if(flag == 0){
                ans = min(ans,sum);    
            } 
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3620
using System;
using System.Linq;

namespace ABC128
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int A = int.Parse(s[0]);
            int P = int.Parse(s[1]);

            int pieP = P / 2;
            int pieP2 = P % 2;

            int pieA = (A * 3 + pieP2) / 2;

            int result = pieA + pieP;
            Console.WriteLine(result);
        }
    }
}

Measured memory_bytes: 13140
/**
 *   author: sahushivam
 *   created: 18 August 2019 (Sunday)  17:20:00
**/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;

int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    int n;
    string s;
    cin>>n>>s;
    if(n>=3200)
        cout<<s;
    else
        cout<<"red";
return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
int a, b;
int t[45];
int cnt[45];
signed main() {
	cin >> a >> b;
	t[0] = 1;
	for (int i = 1; i < 45; i++)t[i] = t[i - 1] * 2;
	rep(i, 44) {
		cnt[i] += ((b / t[i + 1])*t[i]) + max(0ll,( b%t[i + 1]) - t[i] + 1);
	}
	a--;
	rep(i, 44) {
		cnt[i] -= ((a / t[i + 1])*t[i]) + max(0ll, (a%t[i + 1]) - t[i] + 1);
    }
	int ans = 0;
	rep(i, 44)if (cnt[i] % 2)ans += t[i];
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
n = int(input())
c = list(input())

ans = 0
left = 0
right = n - 1

while left < right:
  while left < n and c[left] != 'W':
    left += 1
  while right >= 0 and c[right] != 'R':
    right -= 1
  if left < right:
    c[left], c[right] = c[right], c[left]
    ans += 1

print(ans)

Measured memory_bytes: 10644
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace A
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var N = Console.ReadLine();
            var answer = (N[0] == N[1] && N[1] == N[2]) || (N[1] == N[2] && N[2] == N[3]);
            Console.WriteLine(answer ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 25828
#include <iostream>
#include <iomanip>
#include <sstream>
#include <stdio.h>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <string>
#include <ctype.h>
#include <cstring>
#include <cstdio>
#include <sstream>
#include <functional>

using namespace std;

#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 114514810
#define ll long long
//#define scanf scanf_s

int main()
{
	int n;
	while (cin >> n,n)
	{
		int max = 0; int min = INF;
		int sum = 0;
		REP(i, n)
		{
			int a;
			cin >> a;
			sum += a;
			if (a > max) max = a;
			if (a < min) min = a;
		}
		sum = sum - max - min;
		cout << sum / (n - 2) << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

n = int(input())
prime = factorization(n)
prime_array = []
for i in range(len(prime)):
    prime_array.append(prime[i][1])

ans = 0
for j in range(len(prime_array)):
    check = True
    num = 1
    test = 1
    while check == True:
        if prime_array[j] == num:
            check = False
            ans += test
        elif prime_array[j] < num:
            check = False
            ans += test - 1
        test += 1
        num += test
if n == 1:
    ans = 0
print(ans)


Measured memory_bytes: 9516
#include <iostream>

using namespace std;

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

    int count = 0;
    int i;
    for (i = 0; i < M; i++) {
        int tmp;
        cin >> tmp;
        count += tmp;
    }

    if (count <= N) {
        cout << N - count;
    } else {
        cout << -1;
    }



    return 0;
}

Measured memory_bytes: 3592