akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <cassert>
#include <fstream>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

const ll mod = 1e9 + 7;

vector<ll> dx = {1, -1, 0, 0};
vector<ll> dy = {0, 0, 1, -1};

vector<string> g;

vector<long long> sieve(const long long& n)
{
    vector<long long> v(n + 1);
    vector<bool> c(n + 1, 1);
    vector<long long> ret;
    for (long long i = 2; i <= n; ++i)
    {
        if (c[i])
        {
            for (long long j = 2 * i; j <= n; j += i)
            {
                c[j] = 0;
            }
            ret.push_back(i);
        }
    }
    return ret;
}

int main() {
    
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    
    ll n;
    cin >> n;
    
    vector<vector<ll>> div(1e3 + 1, vector<ll>());
    vector<ll> p = sieve(1e3);
    for (int i = 2; i <= 1e3; ++i)
    {
        for (int j = 0; j < p.size(); ++j)
        {
            ll tmp = i;
            while (tmp > 1 && tmp % p[j] == 0)
            {
                tmp /= p[j];
                div[i].push_back(p[j]);
            }
        }
    }
    map<ll, ll> m;
    for (int i = 1; i <= n; ++i)
    {
        for (int j = 0; j < div[i].size(); ++j)
        {
            m[div[i][j]]++;
        }
    }
    ll ret = 1;
    for (auto itr = m.begin(); itr != m.end(); ++itr)
    {
        ret *= itr->second + 1ll;
        ret %= mod;
    }
    
    cout << ret << endl;
    
    
    return 0;
}

Measured memory_bytes: 384
class Dijkstra():
  class Edge():
    # weighted directed edge
    def __init__(self,_to,_cost):
      self.to=_to
      self.cost=_cost
  def __init__(self,V):
    # 0-indexed
    self.G=[[] for i in range(V)]
    self._E=0
    self._V=V
  def E(self):
    # number of edge
    return self._E
  def V(self):
    # number of vertex
    return self._V
  def add(self, _from, _to, _cost):
    # add vertex and edge cost
    self.G[_from].append(self.Edge(_to, _cost))
    self._E+=1
  def shortest_path(self,s):
    # return the list of shortest pathes from s to each vertex
    import heapq
    que=[]
    d=[float('inf')]*self._V
    d[s]=0
    heapq.heappush(que,(0,s))
    while que:
      cost,v=heapq.heappop(que)
      if d[v]<cost:continue
      for i in range(len(self.G[v])):
        e=self.G[v][i]
        if d[e.to]>d[v]+e.cost:
          d[e.to]=d[v]+e.cost
          heapq.heappush(que,(d[e.to],e.to))
    return d

n,m=map(int,input().split())
g=Dijkstra(n)
for i in range(1,n):
  g.add(i,i-1,0)
for i in range(m):
  u,v,c=map(int,input().split())
  if u>v:
    u,v=v,u
  g.add(u-1,v-1,c)
tmp=g.shortest_path(0)[-1]
if tmp==float('inf'):
  print(-1)
else:
  print(tmp)

Measured memory_bytes: 96688
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <climits>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <functional>
#include <set>
#include <numeric>
#include <stack>
#include <utility>
#include <time.h>
#include <iterator>
//#include "util.h"

using namespace std;
typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pii;

//呪文
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const pair<_KTy, _Ty>& m) { cout << "{" << m.first << ", " << m.second << "}"; return ostr; }
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const map<_KTy, _Ty>& m) { if (m.empty()) { cout << "{ }"; return ostr; } cout << "{" << *m.begin(); for (auto itr = ++m.begin(); itr != m.end(); itr++) { cout << ", " << *itr; } cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const vector<_Ty>& v) { if (v.empty()) { cout << "{ }"; return ostr; }	cout << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const set<_Ty>& s) { if (s.empty()) { cout << "{ }"; return ostr; } cout << "{" << *(s.begin()); for (auto itr = ++s.begin(); itr != s.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _KTy, typename _Ty> istream& operator >> (istream& istr, pair<_KTy, _Ty>& m) { cin >> m.first >> m.second; return istr; }
template <typename _Ty> istream& operator >> (istream& istr, vector<_Ty>& v) { for (size_t i = 0; i < v.size(); i++) cin >> v[i]; return istr; }
ll modpow(ll n, ll p, ll m) { ll result = 1; while (p > 0) { if (p & 1) result = (result * n) % m; p >>= 1; n = (n * n) % m; } return result; }
#define PI 3.14159265358979323846
#define EPS 1e-8
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define all(x) (x).begin(), (x).end()
#define fake false



int main() {
	int N, K;
	cin >> N >> K;
	int ans = 0;
	REP(i, N) {
		int x;
		cin >> x;
		ans += 2 * min(x, K - x);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
n = gets.chomp.to_i
a = gets.split.map(&:to_i)
b = []
c = []
if n % 2 == 0
  lower_b = 1
  lower_c = 0
else
  lower_b = 0
  lower_c = 1
end
(lower_b..(n-1)).step(2).to_a.reverse_each do |i|
  b.push a[i]
end
(lower_c..(n-2)).step(2) do |j|
  c.push a[j]
end
puts b.join(' ') + ' ' + c.join(' ')


Measured memory_bytes: 28276
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(),x.end()
//#define maxi 1e18
#define pll pair<ll,ll>
#define inf 1000000007
#define mod 998244353
map<ll,ll> m;
int main(){
    ll n,k,i,sum=0;
    cin>>n>>k;
    ll a[n];
    for(i=0;i<n;i++){
            cin>>a[i];
        if(a[i]>=k)sum+=1;
    }
    cout<<sum;
    /*for(i=0;i<n+3;i++){
        cout<<v[i]<<endl;
    }
    ll n,i;
    cin>>n;
    ll a[n];
    vector<vector<ll> > v(2);
    for(i=0;i<n;i++){
        cin>>a[i];
        ll r=sqrt(a[i]);
        if(a[i]!=r*r){
            if(a[i]-r*r<(r+1)*(r+1)-a[i]){
                v[0].pb(a[i]-r*r);
            }
            else v[0].pb((r+1)*(r+1)-a[i]);
        }
        else if(a[i]==0){
            v[2].pb(0);
        }
        else {
            v[1].pb(0);
        }
    }
    ll sum=0,cnt=0;
    sort(all(v[0]));
    sort(all(v[1]));
    for(i=0;i<v[0].size();i++){
        sum+=v[0][i];
    }
   // cout<<v[0].size()<<endl;
    for(i=1ll*v[0].size()-1;i>=0;i--){
           // cout<<"HI"<<endl;
        if(cnt<n/2){sum-=v[0][i];cnt++;}
        else break;
    }
    ll diff=(n/2)-cnt;
    while(diff>0){
        for(i=v[1].size()-1;i>=0;i--){
            if(diff>0){
                diff--;
                sum++;
            }
            else break;
        }
    }
    cout<<sum<<endl;
   /*
    ll n,don=0;
    cin>>n;
    ll i,z=0;
    ll a[n];
    ll sum=0;
    vector<ll> ans;
    for(i=0;i<n;i++){
        cin>>a[i];
        sum+=a[i];
        if(a[i]==0){
            z=1;
        }
    }
    sort(a,a+n);
    if(!z){
        cout<<-1;
        return 0;
    }
   ll  nz=0;
    if(sum%3==0){
        for(i=0;i<n;i++){
            ans.pb(a[i]);
            if(a[i]!=0)nz=1;
        }
        if(!nz){
            ans.clear();ans.pb(0);
        }
    }
    else if(sum%3==1){
        for(i=0;i<n;i++){
            if(!don&&a[i]%3==1){
                don=1;
            }
            else ans.pb(a[i]);
        }
         if(!don){
                ans.clear();
                don=-1;
            for(i=0;i<n;i++){
                if(don<1&&a[i]%3==2){
                    don++;
                }
                else ans.pb(a[i]);
            }
        }
        if(don<1){
            cout<<-1;
            return 0;
        }
    }
    else{
        for(i=0;i<n;i++){
            if(a[i]%3==2)don=1;
            else ans.pb(a[i]);
        }
        if(!don){
                ans.clear();
                don=-1;
            for(i=0;i<n;i++){
                if(don<1&&a[i]%3==1){
                    don++;
                }
                else ans.pb(a[i]);
            }
        }
        if(don<1){
            cout<<-1;
            return 0;
        }
    }
    reverse(all(ans));
    for(i=0;i<ans.size();i++){
        cout<<ans[i];
    }*/
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;
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(){
	ll n,k;cin>>n>>k;
	vector<ll> po;
	vector<ll> ne;
	ll cnt_zero = 0;
	for(ll i = 0; i < n; i++) {
		ll x;cin>>x;
		if (x >= 0){
			po.pb(x);
		}
		else if(x != 0){
			ne.pb(x);
		}
		if(x == 0){
			cnt_zero++;
		}
	}
	ll po_len = po.size();
	ll ne_len = ne.size();

	

	

	// for(int i = 0; i < po_len; i++) {
	// 	cout << ne[i] << endl;
	// }
	


	if (k == po_len + ne_len){

		sort(ALL(po),greater<ll>());
		sort(ALL(ne));
		vector<ll> sum_po(po_len+1,1LL);
		vector<ll> sum_ne(ne_len+1,1LL);

		for(ll i = 0; i < po_len; i++) {
			sum_po[i+1] = sum_po[i] * po[i];
			sum_po[i+1] %= mod;
		}
		for(ll i = 0; i < ne_len; i++) {
			sum_ne[i+1] = sum_ne[i] * ne[i];
			sum_ne[i+1] %= mod;
			if(sum_ne[i+1] < 0LL){
				sum_ne[i+1] += mod;
			}
		}

		if (cnt_zero != 0LL){
			cout << 0 << endl;
		}
		else{
			if (po_len == 0){
				cout << sum_ne[ne_len] << endl;
			}
			else if (ne_len == 0){
				cout << sum_po[po_len] << endl;
			}
			else{
				cout << (sum_po[po_len] * sum_ne[ne_len]) % mod << endl;
			}
		}
		return 0;
	}
	
	else if (k % 2 == 1 && po_len == 0){
		ll res;
		sort(ALL(ne),greater<ll>());
		vector<ll> sum_ne(ne_len+1,1LL);
		for(ll i = 0; i < ne_len; i++) {
			sum_ne[i+1] = sum_ne[i] * ne[i];
			sum_ne[i+1] %= mod;
		// 	if(sum_ne[i+1] < 0LL){
		// 	sum_ne[i+1] += mod;
		// }
		}
		if (cnt_zero != 0){
			res = max(0LL,sum_ne[k]);
		}
		else{
			res = sum_ne[k];
		}
		if(res < 0LL){
			res += mod;
		}
		cout << res << endl;
		return 0;
	}
	else{
		sort(ALL(po),greater<ll>());
		sort(ALL(ne));
		ll ans = 1LL;
		ll id_p = 0;
		ll id_n = 0;
		ll element = 0;
		// if (k % 2 == 1){
		// 	ans *= po[0];
		// 	id_p++;
		// 	element++;
		// }
		while(element < k){
			if(element < k -1 && id_n + 1< ne_len && ((id_p + 1>= po_len)||(id_p + 1 < po_len && po[id_p] * po[id_p +1] <= ne[id_n] * ne[id_n+1]))){
				ans = ans *ne[id_n] %mod;
				ans = ans*ne[id_n + 1]%mod;
				id_n += 2;
				element+=2;
			}
			else{
				ans = ans*po[id_p]%mod;
				id_p += 1;
				element+= 1;
			}
		}
		cout << ans << endl;
	}
	return 0;	
	}


Measured memory_bytes: 6276
#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 mod 1000000007
#define INF 1000000000000000000
/****************************/
int main()
{
  	ll n,k;
  	cin>>n>>k;
  	cout<<min(n%k,k-n%k);
    return 0;
}

Measured memory_bytes: 256
count=0
def mg(S,left,right,mid):
    global count
    L=[]
    L=S[left:mid]
    L.append(9999999999)
    R=[]
    R=S[mid:right]
    R.append(9999999999)
    r=0
    l=0
    for i in range(left,right):
        count=count+1
        if L[l]<=R[r]:
            S[i]=L[l]
            l=l+1
        else:
            S[i]=R[r]
            r=r+1
def ms(S,left,right):
    if right>left+1:
        mid=(right+left)//2
        ms(S,left,mid)
        ms(S,mid,right)
        mg(S,left,right,mid)
n=int(input())
S=[]
S=input().split()
S=[int(u) for u in S]
ms(S,0,n)
for i in range(0,n-1):
    print(S[i],end=" ")
print(S[n-1])
print(count)


Measured memory_bytes: 61656
import java.io.*;
import java.util.regex.Pattern;

public class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        Pattern p=Pattern.compile("the|this|that");
        String str;
        
            while((str=br.readLine())!=null){
                char[] ch=str.toCharArray();
                for(int j=0;!p.matcher(str).find()&&j<26;j++){
                    for(int i=0;i<ch.length;i++){
                        if('a'<=ch[i]&&ch[i]<'z'){
                            ch[i]++;
                        }else if(ch[i]=='z'){
                            ch[i]='a';
                        }
                    }
                    if(p.matcher(String.valueOf(ch)).find()){
                        break;
                    }
                }
                System.out.println(ch);
            }
        
    }
}

Measured memory_bytes: 17900
//#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define endl '\n'
#define elif else if
#define lli long long int
#define ld long double
#define vec vector
#define forn(a) for(lli a=0; a<n; a++)
#define all(x) x.begin(), x.end()
#define deb(x) cerr<<#x<<" = "<<x<<endl

using namespace std;

int main(){
  IOS;

  int n; cin>>n;
  string s; cin>>s;
  int k; cin>>k; k--;

  forn(i){
    if(s[i]!=s[k]) cout<<'*';
    else cout<<s[i];
  }cout<<endl;

  return 0;
}

Measured memory_bytes: 256
import sys
from collections import defaultdict
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10**8)


def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split())


def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip())


def main():
    mod = 10**9 + 7
    H, W = geta(int)
    g = []
    for _ in range(H):
        g.append(gete())

    dp = [[0] * W for _ in range(H)]

    for i in range(W):
        if g[0][i] == "#": break
        dp[0][i] = 1

    for i in range(H):
        if g[i][0] == "#": break
        dp[i][0] = 1

    for i, gi in enumerate(g[1:], 1):
        for j, gij in enumerate(gi[1:], 1):
            if gij == "#":
                dp[i][j] = 0
            else:
                dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % mod

    print(dp[H - 1][W - 1])


if __name__ == "__main__":
    main()

Measured memory_bytes: 52716
//programking2_a.cpp
//Sun Dec  1 10:34:25 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	int ans = 0;
	for (int i=1;i<n;i++){
		if (n-i <= i){
			break;
		}
		ans++;
	}


	cout << ans << endl;
//	printf("%.4f\n",ans);
}

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

int main(){
  string  divide[4]={"dream","dreamer","erase","eraser"};

  string S;
  cin >> S;
   //後ろから解く代わりに全ての文字列を左右反転
   reverse(S.begin(),S.end());
   for(int i=0; i<4; i++) reverse(divide[i].begin(),divide[i].end());

   //橋から切って行く
   bool can=true;
   for(int i=0; i<S.size();){
     bool can2 = false ; //４個の文字列たちのどれでdevideできるのか
     for(int j=0; j<4; j++){
       string d=divide[j];
       if(S.substr(i,d.size())==d){ //dでdivideできるか
         can2=true;
         i += d.size(); //divideできたらiをすすめる
       }
   }
   if(!can2){ //divide できなかったら
     can= false;
     break;
   }
 }

 if(can) cout <<"YES" <<endl;
 else cout<<"NO"<<endl;

}


Measured memory_bytes: 512
import sys

def main():
  input = sys.stdin.readline
  S = str(input().strip())
  T = str(input().strip())
  ans = 'No'
  for _ in range(len(S)):
    if S == T:
      ans = 'Yes'
      break
    else:
      S = S[1:] + S[0]
  print(ans)


if __name__ == '__main__':
  main()

Measured memory_bytes: 3060
A, B, C, X, Y = map(int, input().split())
result = 0
m = min(X, Y)
if A + B < 2 * C:
    result += m * (A + B)
    if m == X:
        result += (Y - m) * B
    else:
        result += (X - m) * A
else:

    if m == X:
        if B > 2 * C:
            result += 2 * max(X, Y) * C
        else:
            result += 2 * m * C + (Y - m) * B
    else:
        if A > 2 * C:
            result += 2 * max(X, Y) * C
        else:
            result += 2 * m * C + (X - m) * A

print(result)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

ll gcd(ll a, ll b) {return (!b ? a : gcd(b, a % b));}
bool cmp(int a,int b){return a>b;}

const ll mod = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;
const ld pi = 3.141592653589793;
const int N = 1e6 + 10;

long long modpow(long long n, long long k, long long mod)
{
if (k == 0) return 1;
long long r = modpow(n * n % mod, k >> 1, mod);
if (k & 1) r = r * n % mod;
return r;
}

void solve(){
   int a,b,c,d;cin >> a >> b >> c >> d;
   cout <<(a-c)*(b-d);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    solve();
    return 0;
}

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

int main(void) {
  int a, b,c;
  cin >> a >> b >> c;
  bool x = false;
  if(a == 5 && b == 5 && c == 7) x = true;
  else if(a == 5 && b == 7 && c == 5) x = true;
  else if(a == 7 && b == 5 && c == 5) x = true;

  if(x) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int n=0;
    int h=0;
    cin>>n>>h;
    int arr[n];
    int x=0;
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    for(int i2=0;i2<n;i2++)
    {
        if(arr[i2]>=h)
        {
            x++;
        }
    }
    cout<<x;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <unordered_map>
#include <cmath>
#include <utility> // pair make_pair
#include <algorithm>
#include <functional>
#include <iomanip>
#include <climits> // LLONG_MAX, LLONG_MIN, INT_MIN, INT_MAX
#include <assert.h>

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define ll long long
//#define int ll
#define INF INT_MAX/10
#define MOD 1000000007

using namespace std;
using Pi = pair<int, int>;
using Graph = vector<vector<int> >;
using WeightGraph = vector<vector<Pi> >;

int Input[100100];

int main() {
  int N; cin >> N;
  if (N % 2 == 0) {
    cout << 0.5 << endl;
  } else {
    double odd = N / 2 + 1;
    double t = N;
    double x = odd / t;
    cout << x << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define REPS(i,n) for(int i=1;i<=(int)(n);i++)
using namespace std;
using ll = long long;
using ld = long double;

int main(void) {
    ld a, b, x;
    cin >> a >> b >> x;
    // 2次元に次元を落とす
    x /= a;

    ld tan_theta;
    if (x <= a*b/2) {
        tan_theta = b*b / (2*x);
    } else {
        tan_theta = 2*(a*b-x) / (a*a);
    }

    ld l = 0, r = 90, pi = 3.14159265;
    while (r-l > 0.00000000001) {
        ld m = l + (r-l)/2;
        if (tan((m/180)*pi) <= tan_theta) {
            l = m;
        } else {
            r = m;
        }
    }

    cout << fixed << setprecision(10) << l << endl;
}

Measured memory_bytes: 384
A, B = list(map(int, input().split()))
C = 16-(A+B)

arr = ['a']
A = A - 1
for i in range(1,16):
  if arr[-1] == 'a':
    if B >= 1:
      B = B-1
      arr.append('b')
    elif C >= 1:
      C = C-1
      arr.append('c')
  elif arr[-1] == 'b':
    if A >= 1:
      A = A-1
      arr.append('a')
    elif C >= 1:
      C = C-1
      arr.append('c')
  elif arr[-1] == 'c':
    if A >= 1:
      A = A-1
      arr.append('a')
    elif B >= 1:
      B = B-1
      arr.append('b')
    elif C >= 1:
      C = C-1
      arr.append('c')
if len(arr) == 16:
  print("Yay!")
else:
  print(":(")


Measured memory_bytes: 9240
#include<bits/stdc++.h>
#define PI 3.141592653589793238
using namespace std;

int main(){
    int a,b;cin>>a>>b;
    int h,m;cin>>h>>m;
    long double angle_minute_hand=6*m;
    long double angle_hour_hand=30*h + 0.5*m;
    long double angle=max(angle_minute_hand,angle_hour_hand)-min(angle_minute_hand,angle_hour_hand);
    if(angle>180){
        angle=360-angle;
    }
    if(angle==180){
        printf("%.10f", (double)a+b);
        return 0;
    }
    if(angle==0){
        printf("%.10f", (double)abs(a-b));
        return 0;
    }
    long double dist=sqrt((a*a)+(b*b)-2*a*b*cos(angle*PI/180));
    printf("%.10Lf",dist);
}


Measured memory_bytes: 4044
n,l = map(int,input().split())
num = set(map(int,input().split()))
ans=0
for i in range(n,10*n):
  for j in range(len(str(i))):
    if int(str(i)[j]) in num:
      if j==0:
        i = (int(str(i)[0])+1)*(10**(len(str(i))-1))   
      break
    if j ==len(str(i))-1:
      ans=i
  if ans!=0:
    break
print(ans)

Measured memory_bytes: 3064
#include <cstdio>
struct Edge{
	int a,b;
}a[5];
bool vis[5];
bool dfs(int x){
	int num=0;
	vis[x]=1;
	for(int i=1;i<=3;i++){
		if(a[i].a==x&&!vis[a[i].b]){
			if(!dfs(a[i].b)){
				return 0;
			}
			num++;
		}
		if(a[i].b==x&&!vis[a[i].a]){
			if(!dfs(a[i].a)){
				return 0;
			}
			num++;
		}
	}
	if(num>1){
		return 0;
	}
	return 1;
}
int main(){
	for(int i=1;i<=3;i++){
		scanf("%d%d",&a[i].a,&a[i].b);
	}
	bool ans=0;
	for(int i=1;i<=4&&!ans;i++){
		for(int j=1;j<=4;j++){
			vis[j]=0;
		}
		if(dfs(i)){
			ans=1;
			for(int j=1;j<=4;j++){
				ans=(ans&&vis[j]);
			}
		}
	}
	if(ans){
		puts("YES");
	}
	else{
		puts("NO");
	}
	return 0;
}


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

int main(void){
    int n;
    cin >> n;
    
    int sum = 0;
    vector<int> vec(n);
    rep(i, n) {
        cin >> vec.at(i);
        sum += vec.at(i);
    }
    
    int mean = sum / n;
    int mean1 = mean + 1;
    
    
    int sq_m = 0, sq_m1 = 0;
    rep(i, n) {
        sq_m += pow((vec.at(i) - mean), 2);
        sq_m1 += pow((vec.at(i) - mean1), 2);
    }
    
    if (sq_m <= sq_m1) cout << sq_m << endl;
    else cout << sq_m1 << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b)-1);i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int, int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))

int main(void){
	int n, m; cin >> n >> m;
	int c[n][n], d[n][n];
	vector<int> v[n];
	bool u[n][n];
	
	rep(i, n) rep(j, n) c[i][j] = d[i][j] = (i==j?0:1001);
	rep(i, m){
		int ta, tb, tc; cin >> ta >> tb >> tc;
		ta--; tb--;
		c[ta][tb] = c[tb][ta] = d[ta][tb] = d[tb][ta] = tc;
		v[ta].push_back(tb);
		v[tb].push_back(ta);
	}
	rep(i, n) rep(j, n) u[i][j] = false;
	
	rep(k, n) rep(i, n) rep(j, n) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
		
	rep(i, n) rep(j, n){
		if(i >= j) continue;
		rep(k, v[j].size()) if(d[i][j] == d[i][v[j][k]] + c[v[j][k]][j]) u[v[j][k]][j] = u[j][v[j][k]] = true;
	}
		
	int ans = 0;
	rep(i, n) rep(j, n) if(i<j && u[i][j] == true) ans++;
	cout << m - ans << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <queue>

const int INF = 100000000;

int main(){
   int N, M;
   int L, R, D;
   std::cin >> N >> M;
   std::vector<std::vector<std::pair<int, int> > > v(N);
   for(int i=0; i<M; ++i){
      std::cin >> L >> R >> D;
      v[L-1].emplace_back(R-1,D);
      v[R-1].emplace_back(L-1,-D);
   }

   std::vector<int> d(N, INF);
   for(int i=0; i<N; ++i){
      if(d[i]!=INF) continue;
      std::queue<int> q;
      q.push(i);
      d[i] = 0;
      while(!q.empty()){
	 int cur = q.front();
	 q.pop();
	 for(auto pair: v[cur]){
	    if(d[pair.first]==INF){
	       q.push(pair.first);
	       d[pair.first] = d[cur] + pair.second;
	    }else if(d[pair.first] != d[cur] + pair.second){
	       std::cout << "No" << std::endl;
	       return 0;
	    }
	 }
      }
   }

   std::cout << "Yes" << std::endl;

   return 0;
}


Measured memory_bytes: 9344
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i <= n; i++)
#define FORR(i, m, n) for(ll i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n)
#define MAX 100000
#define inf 1000000007
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
using graph = vector<vector<int>>;

int main() {
    //cin高速化
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a;
    cin >> a ;

    cout << a + a*a + a*a*a <<"\n";
	return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
using namespace std;
using ll = long long;

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

    if ((b - a) % 2 == 0) {
        cout << (b - a) / 2 << endl;
        exit(0);
    }

    a--; b--;

    auto f = [](ll n, ll a, ll b) {
        ll r = a + 1;
        b -= r;
        return r + b / 2;
    };

    cout << min(f(n, a, b), f(n, n - 1 - b, n - 1 - a)) << endl;

    return 0;
}

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

int main() {
  int n; cin >> n;
  long long answer;
  
  long long a = 2;
  long long b = 1;
  
  for (int i = 0; i < n - 1; i++) {
    long long c = a + b;
    a = b;
    b = c;
  }
  
  cout << b << endl;
}

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

int main(){
  int a,b;
  cin >>a>>b;
  
  int ans=0;
  if(a>=13) ans=b;
  if(6<=a&&a<=12) ans = b/2;
  if(a<=5) ans = 0;;
  
  cout <<ans<<endl;
}
    

Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,m = inpl()
g = [[] for _ in range(n)]
for i in range(m):
    l,r,d = inpl()
    g[l-1].append((r-1,d))
    g[r-1].append((l-1,-d))
seen = [False] * n
dist = [0] * n
for i in range(n):
    if seen[i]:
        continue
    q = deque([i])
    while q:
        now = q.popleft()
        seen[i] = True
        for v,d in g[now]:
            if seen[v]:
                if dist[v] != d + dist[now] :
                    print('No')
                    quit()
            else:
                dist[v] = dist[now] + d
                seen[v] = True
                q.append(v)
print('Yes')


Measured memory_bytes: 101532
#include<bits/stdc++.h>
using namespace std;
const int MAXN=1e5+5;
#define pii pair<int,int>
#define mp(x,y) make_pair(x,y)
int n;
deque< pair<int,int> >q;
bool vis[MAXN];
int main()
{
    cin>>n;
    q.push_front(mp(1,1));
    while(!q.empty())
	{
        pii tp=q.front();
        q.pop_front();
        int x=tp.first,step=tp.second;
        if(vis[x])
			continue;
        vis[x]=1;
        if(x==0)
		{
			cout<<step;
			break;
		}
        q.push_front(mp(x*10%n,step));
        q.push_back(mp((x+1)%n,step+1));
    }
    return 0;
}

Measured memory_bytes: 1152
import sys

readline = sys.stdin.buffer.readline


def main():
    N, A, B = map(int, readline().split())
    X = list(map(int, readline().split()))

    c = 0
    for i in range(N - 1):
        c += min(A * (X[i + 1] - X[i]), B)

    print(c)


main()


Measured memory_bytes: 12496
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()

from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
from fractions import gcd
import copy
from itertools import permutations
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

from itertools import permutations
from math import factorial, hypot

N = getN()
A = getList()

course = []
x1 = A[0]
for i in A:
    x2 = i
    opt = gcd(x1, x2)
    course.append(opt)
    x1 = opt

reverse = []
y1 = A[-1]
for i in A[::-1]:
    y2 = i
    opt = gcd(y1, y2)
    reverse.append(opt)
    y1 = opt
reverse.sort()

ans = 0
for i in range(N):
    res = 0
    if i == 0:
        res = reverse[1]
    elif i == N - 1:
        res = course[-2]
    else:
        res = gcd(course[i - 1], reverse[i + 1])
    ans = max(ans, res)
print(ans)

Measured memory_bytes: 89580
import heapq
T = int(input())

for loop in range(T):

    N,A,B,C,D = map(int,input().split())

    q = [(0,N)]
    end = {}
    ans = D * N
    dl = {}

    while len(q) > 0:

        tmp = heapq.heappop(q)
        dis,num = tmp

        if num in end:
            continue
        end[num] = 1


        if dis > ans:
            print (ans)
            break
        if num == 0:
            print (dis)
            break
        ans = min( ans , dis + num * D )
        

        nc = A
        xx = 2
        nd = num % xx
        if (num-nd)//xx not in end:
            if nd != 0 and (num-nd) == 0:
                dl[num-nd] = dis + num * D
                heapq.heappush(q , (dis + num * D,0))
            if (num-nd)//xx not in dl or dl[(num-nd)//xx] > dis+nc+nd*D:
                dl[(num-nd) // xx] = dis+nc+nd*D
                heapq.heappush(q , (dis+nc+nd*D , (num-nd) // xx))
        nd = xx - num % xx
        if (num+nd)//xx not in end:
            if (num+nd)//xx not in dl or dl[(num+nd)//xx] > dis+nc+nd*D:
                dl[(num+nd) // xx] = dis+nc+nd*D
                heapq.heappush(q , (dis+nc+nd*D , (num+nd) // xx))
        
        nc = B
        xx = 3
        nd = num % xx
        if (num-nd)//xx not in end:
            if nd != 0 and (num-nd) == 0:
                dl[num-nd] = dis + num * D
                heapq.heappush(q , (dis + num * D,0))
            if (num-nd)//xx not in dl or dl[(num-nd)//xx] > dis+nc+nd*D:
                dl[(num-nd) // xx] = dis+nc+nd*D
                heapq.heappush(q , (dis+nc+nd*D , (num-nd) // xx))
        nd = xx - num % xx
        if (num+nd)//xx not in end:
            if (num+nd)//xx not in dl or dl[(num+nd)//xx] > dis+nc+nd*D:
                dl[(num+nd) // xx] = dis+nc+nd*D
                heapq.heappush(q , (dis+nc+nd*D , (num+nd) // xx))
        
        nc = C
        xx = 5
        nd = num % xx
        if (num-nd)//xx not in end:
            if nd != 0 and (num-nd) == 0:
                dl[num-nd] = dis + num * D
                heapq.heappush(q , (dis + num * D,0))
            if (num-nd)//xx not in dl or dl[(num-nd)//xx] > dis+nc+nd*D:
                dl[(num-nd) // xx] = dis+nc+nd*D
                heapq.heappush(q , (dis+nc+nd*D , (num-nd) // xx))
        nd = xx - num % xx
        if (num+nd)//xx not in end:
            if (num+nd)//xx not in dl or dl[(num+nd)//xx] > dis+nc+nd*D:
                dl[(num+nd) // xx] = dis+nc+nd*D
                heapq.heappush(q , (dis+nc+nd*D , (num+nd) // xx))
        


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


using namespace std ; 

int n ; 

int main(){
        ios_base::sync_with_stdio(0) ; 
        cin.tie(0) ;
        //freopen("in.in" , "r" , stdin) ; 
        long double a , b ; 
        cin>>a>>b ; 
        cout<<fixed<<setprecision(0) << trunc(a * b) ; 
        return 0 ; 
}

Measured memory_bytes: 3828
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<tuple>
#include<iomanip>
#include<stack>
#include<map>
#include<queue>
#include<set>
#define int long long
using namespace std;
const int INF = 1e10;
const int ZERO = 0;

signed main() {
    string S;
    cin >> S;
    int ret = 700;
    for(int i = 0;i < 3;i++) {
        if(S.at(i) == 'o') {
            ret+= 100;
        }
    }
    cout << ret << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int A,B,C,D;

  scanf("%d%d%d%d",&A,&B,&C,&D);

  if(A+B > C+D){
    printf("Left\n");
  }else if(A+B == C+D){
    printf("Balanced\n");
  }else{
    printf("Right\n");
  }

  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<cmath>
#include<cstdlib>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<queue>

using namespace std;

int main(){
  int n,h;
  cin>>n>>h;
  pair<int,int> pi[200005];
  for(int i=0;i<n;i++){
    int a,b;cin>>a>>b;
    pi[i*2] = make_pair(b,1);
    pi[i*2+1] = make_pair(a,0);
  }
  sort(pi,pi+2*n);
  int ans = 0;
  for(int i=0;i<2*n;i++){
    if(h<=0) break;
    if(pi[n*2-1-i].second == 0){
      ans += h/pi[n*2-1-i].first;
      if(h%pi[n*2-1-i].first > 0) ans ++;
      break;
    }
    h -= pi[n*2-1-i].first;
    ans++;
  }
  cout<<ans<<endl;
}


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

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

	int ans=0;

	int now=0, count=0, tmp;
	for(int i=0;i<n;i++){
		if(now!=a[i]){
			if(now>count) ans+=count;
			else if(now<count) ans+=(count-now);
			now=a[i];
			count=1;
			continue;
		}else{
			count++;
		}
	}
			if(now>count) ans+=count;
			else if(now<count) ans+=(count-now);

	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
string s;
cin>>s;
if(s=="SUN"){
cout<<7<<endl;}
else if(s=="MON"){
cout<<6<<endl;}
else if(s=="TUE"){
cout<<5<<endl;}
else if(s=="WED"){
cout<<4<<endl;}
else if(s=="THU"){
cout<<3<<endl;}
else if(s=="FRI"){
cout<<2<<endl;}
else{
cout<<1<<endl;}
}

Measured memory_bytes: 256
using System;
class Program
{
	static void Main()
	{
	string[] input = Console.ReadLine().Split(' ');//Splitで空白で区切って２つ受け取る。
	int a = int.Parse(input[0]);
	int b = int.Parse(input[1]);

	Console.WriteLine((int)((a+b+1)/2));//WriteLineをWriteとすると、改行なしで出力。
	}
}


Measured memory_bytes: 11092
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
//by NeighThorn
using namespace std;
inline int ex_gcd(int a,int b,int &x,int &y){
	if(b==0)
		return x=1,y=0,a;
	int lala=ex_gcd(b,a%b,x,y),tmp=x;
	x=y;y=tmp-a/b*y;
	return lala;
}
signed main(void){
	int a,b,x,y;scanf("%d%d",&a,&b);
	ex_gcd(a,b,x,y);cout<<x<<" "<<y<<endl;
	return 0;
}

Measured memory_bytes: 3236
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from itertools import permutations
inf = 10**17
mod = 10**9+7

n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))

cnt = 1
a = 0
b = 0
a = [i for i in range(1, n + 1)]
for v in permutations(a):
    v = list(v)
    if p == v: a = cnt
    if q == v: b = cnt
    cnt += 1

print(abs(a - b))


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

using namespace std;

int main() {
    int a, b, h, m;

    cin >> a >> b >> h >> m;

    double d, angle_h, angle_m;

    angle_m = m / 60.0 * 2 * M_PI;
    angle_h = (60.0 * h + m) / (12 * 60.0) * 2 * M_PI;
    d = sqrt(a * a + b * b - 2 * a * b * cos(angle_h - angle_m));

    printf("%.11lf\n", d);

    return 0;
}

Measured memory_bytes: 4188
from itertools import product

A, B, C, D = list(map(int, input()))

for pattern in product('+-', repeat=3):
    f = '{}{}{}{}{}{}{}'.format(A, pattern[0], B, pattern[1], C, pattern[2], D)
    if eval(f) == 7:
        print(f+'=7')
        break

Measured memory_bytes: 3060
h, w = list(map(int, input().split()))
a = [list(map(int, input().split())) for i in range(h)]

ansl = []
n = 0
for i in range(h):
    for j in range(w-1):
        if a[i][j] % 2 == 0:
            pass
        else:
            n += 1
            ansl.append([i+1, j+1, i+1, j+2])
            a[i][j] -= 1
            a[i][j+1] += 1

for i in range(h-1):
    if a[i][w-1] % 2 == 0:
        pass
    else:
        n += 1
        ansl.append([i+1, w, i+2, w])
        a[i][w-1] -= 1
        a[i+1][w-1] += 1

print(n)
[print(*x) for x in ansl]


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

int main() {
  int n;
  cin >> n;
  
  int a, count, min = 10000000;
  
  for (int i = 0; i < n; i++){
    cin >> a;
    count = 0;
    while (a % 2 == 0){
      a /= 2;
      count++;
    }
    if (count < min){
      min = count;
    }
  }
  
  cout << min << endl;
        
}


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

using namespace std;

typedef long long ll;

int main(){
    string x, y;
    int z[256] = {};
    int zz[256] = {};
    cin >> x >> y;
    for(int a = 0; a < (int)x.size(); a++){
        if(z[(int)x[a]] == 0) z[(int)x[a]] = (int)y[a];
        else if(z[(int)x[a]] != (int)y[a]){
            cout << "No" << endl;
            return 0;
        }
        if(zz[(int)y[a]] == 0) zz[(int)y[a]] = (int)x[a];
        else if(zz[(int)y[a]] != (int)x[a]){
            cout << "No" << endl;
            return 0;
        }
    }

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

Measured memory_bytes: 776
from itertools import groupby

n = int(input())
a = list(map(int,input().split()))
a = sorted(a)
g = groupby(a)
s = [0,0]

for k,v in g:
    l = len(list(v))
    while l>1:
        s.append(k)
        l -= 2

s = sorted(s)
print(s[-1] * s[-2])


Measured memory_bytes: 14460
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
typedef pair<ll,ll> pll;
void read(int& x){ scanf("%d",&x); }
void read(double& x){ scanf("%lf",&x); }
template<typename T,typename... Args>
void read(T& a,Args&... b){ read(a); read(b...); }
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
#define x first
#define y second

double vol[500010];
double tmp[500010];

int n; double l;

double h;

int main()
{
	int head=0, tail=0;
	read(n, l);
	for(;n--;){
		double t, v;
		read(t, v);
		double left_v = v;
		while(head<tail && left_v > 0){
			double toru = min(vol[head], left_v);
			h -= toru * tmp[head];
			vol[head] -= toru;
			left_v -= toru;
			if(vol[head] == 0){
				++head;
			} else {
				break;
			}
		}
		printf("%.10f\n", (h + t*v) / l);
		vol[tail] = v;
		tmp[tail] = t;
		h += v*t;
		++tail;
		while(tail-head >= 2){
			if(tmp[tail-2] < tmp[tail-1]) break;
			double new_temp = tmp[tail-1]*vol[tail-1] + tmp[tail-2]*vol[tail-2];
			vol[tail-2] += vol[tail-1];
			tmp[tail-2] = new_temp/vol[tail-2];
			--tail;
		}
	}
	return 0;
}


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

using namespace std;

char s[110];
int n[26];

int main()
{

	cin>>s;
	for(int i=0; i<strlen(s); i++)
	{
		if(n[s[i]-'a']==0)n[s[i]-'a']++;
		else n[s[i]-'a']--;
	}
	for(int i=0; i<26; i++)if(n[i])
		{
			printf("No");
			return 0;
		}
	printf("Yes");
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

#define PAD(n) (n+2-1)/2

int main(int argc, char* argv[])
{
    int N; cin >> N;

    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }

    sort(A.begin(), A.end(), greater<int>());
    
    int player[2] = {0};
    for (int i = 0; i < N; i++) {
      player[i%2] += A[i];
    }

    cout << player[0]-player[1] << endl;
    return 0;
}


Measured memory_bytes: 256
using System;

namespace abc60
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            string A = str[0];
            string B = str[1];
            string C = str[2];
            if (A[A.Length - 1] == B[0] && B[B.Length - 1] == C[0])
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

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; }
const long long INF = 1LL << 60;
typedef pair<int, int> PR;

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define fr(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijo(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i <=n;i++){
    num*=yakusu[i];
  }
  return num;
}
 

//cout<<""<<endl;
int main(){
  ll N;cin>>N;
  ll K;cin>>K;
  vl A(N);
  ll ma=0;
  rep(i,N){
    cin>>A[i];
    ma=max(ma,A[i]);
  }
  ll lf=0,rg=ma+1;
  while(true){
    if(rg-lf<=1)break;
    ll mid = (lf + rg) / 2;
    ll cnt=0;
    rep(i,N){
      cnt+=(((A[i]+mid-1)/mid)-1);
    }
    if(cnt>K)lf=mid;
    else rg=mid;
  }
  cout<<rg<<endl;
    
  
 
}






Measured memory_bytes: 4892
#include <iostream>

using namespace std;

struct Task{
	int load;
	int ts;
	Task * next;
	char name[12];
};

Task done;
Task * donelast = &done;
Task * queue;
Task * store;
Task * last;
int n = 0;
int nd = 0;
int q = 0;
int ts = 0;
int main()
{
 	cin >> n;
 	cin >> q;
 	store = new Task[n+1];
 	last = store;
 	for (int i=1;i<=n;i++)
 	{
 		auto & t = store[i];
 		cin >> t.name;
 		cin >> t.load;
 		t.ts = 0;
 		t.next = 0;
 		last->next = &t;
 		last = &t;
 	}
 	last->next =0;
 	
 	while (n!=nd)
 	{
 		auto * t = store;
	 	while(1)
 		{
 			last = t;
 			t = t->next;
 			if(!t) break;
 			ts += q;
 			auto & l =t->load;
 			l -= q;
 			if (l > 0) continue;
 			ts += l;
 			t->ts = ts;
 			donelast->next = t;
 			donelast = t;
 			nd++;
 			last->next = t->next;
 			t = last;
 		}
 	}
 	auto t = done.next;
	for (int i=0; i<n;i++)
	{
		cout << t->name << ' ' << t->ts << endl;
		t = t->next;
	}
	return 0;
}

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

using namespace std;

int main (){

  long long int N,A,B;
  cin >>N>>A>>B;
  long long int C,D,E;
  C=N/(A+B);
  if(N%(A+B)<A)
    cout <<C*A+N%(A+B);
  else
    cout<<C*A+A;
  









  return 0;
}


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


int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  int a;
  cin >> a;
  n %= 500;
  if(n <= a)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

}


Measured memory_bytes: 896
n= int(input())
s = input()
num = [int(s) for s in s.split(" ")]
ans=[]

while(True):
  ch = False
  for i in reversed(range(len(num))):
    if num[i] == i+1:
      ch = True
      del num[i]
      ans.append(i+1)
      break
  if not ch:
    break
if len(num)==0:
  for i in reversed(ans):
    print(i)
else:
  print("-1")

Measured memory_bytes: 3064
#include<stdio.h>
#define INFTY 1000000001
int t=0;
void merge(int s[],int left,int mid,int right){
	int n1=mid-left;
	int n2=right-mid;
	int l[n1+1],r[n2+1];
	int i,j,k;
	for(i=0;i<n1;i++)
	l[i]=s[left+i];
	for(i=0;i<n2;i++)
	r[i]=s[mid+i];
	l[n1]=INFTY;
	r[n2]=INFTY;
	i=0;
	j=0;
	for(k=left;k<right;k++){
		if(l[i]<=r[j]){
			s[k]=l[i];
			i++;
		}
		else{
			s[k]=r[j];
			j++;
		}
		t++;
	}
}
void mergeSort(int s[],int left,int right){
	if(left+1<right){
		int mid=(left+right)/2;
		mergeSort(s,left,mid);
		mergeSort(s,mid,right);
		merge(s,left,mid,right);
	}
}
int main(){
	int n,i;
	scanf("%d",&n);
	int s[n];
	for(i=0;i<n;i++)
	scanf("%d",&s[i]);
	int left=0;
	int right=n;
	mergeSort(s,left,right);
	for(i=0;i<n;i++){
		if(i>0)
		printf(" ");
		printf("%d",s[i]);
	}	 
	printf("\n");
	printf("%d\n",t);
	return 0;
} 


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

int main() {
 int N;

 cin >> N;
 for (int i = 1; i < 10; ++i){
   for (int j = 1; j < 10; ++j){
   
     if(i*j==N){
       	cout << "Yes" << endl; 
       	return 0;}
 }
 }
 	cout << "No" << endl; 
 }
  

Measured memory_bytes: 256
N, M = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(M)]

ans = 0

for i in ab:
    vertex = list(range(N))
    for j in ab:
        if i != j:
            vertex = [vertex[j[0] - 1] if vertex[k] == vertex[j[1] - 1] else vertex[k] for k in range(N)]
    if len(set(vertex)) != 1:
        ans += 1

print(ans)

Measured memory_bytes: 3064
n,k = map(int,input().split())
a = [ int(i) for i in input().split() ]
ans = 0
dp = dict()
dp[0] = 1
pref = [ 0 for i in range(n+1) ]
pre = 0
for i in range(n):
    pre += a[i] - 1
    pre %= k
    pref[i+1] = pre
    if i >= k-1:
        dp[pref[i-k+1]] -= 1

    try:
        ans += dp[pre]
        dp[pre] += 1
    except:
        dp[pre] = 1

print(ans)


Measured memory_bytes: 39844