akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
#define fir first
#define sec second
#define rep(i,a,b) for (int i = (a) ; i <= (b) ; ++ i)
#define rrp(i,a,b) for (int i = (a) ; i >= (b) ; -- i)
#define gc() getchar()
template <typename tp>
inline void read(tp& x) {
  x = 0; char tmp; bool key = 0;
  for (tmp = gc() ; !isdigit(tmp) ; tmp = gc())
    key = (tmp == '-');
  for ( ; isdigit(tmp) ; tmp = gc())
    x = (x << 3) + (x << 1) + (tmp ^ '0');
  if (key) x = -x;
}

const int N = 500010, MP = 20;
int ans[N], st, en, n, num, stp;
vector<int> vec[2];
int main() {
  read(n), read(st), read(en);
  en ^= st;
  rep (i, 0, n-1)
    vec[(en >> i) & 1].push_back(i);
  if ((int)vec[1].size() % 2 == 0) return puts("NO"), 0;
  stp = 1;
  while ((int)vec[0].size() >= 2) {
    int p1 = vec[0].back(); vec[0].pop_back();
    int p2 = vec[0].back(); vec[0].pop_back();
    // 00 10 11 01 01 11 10 00
    for (int i = 0, j = 0, v ; i < (1 << n) ; i += stp) {
      v = 0;
      if (j == 1 || j == 2 || j == 5 || j == 6) v |= 1 << p1;
      if (j == 2 || j == 3 || j == 4 || j == 5) v |= 1 << p2;
      for (int k = 0 ; k < stp ; ++ k) ans[i + k] |= v;
      if (++ j == 8) j = 0;
    }
    stp <<= 2;
  }
  while ((int)vec[1].size() >= 2) {
    int p1 = vec[1].back(); vec[1].pop_back();
    int p2 = vec[1].back(); vec[1].pop_back();
    // 00 10 11 01 01 00 10 11
    // 11 10 00 01 01 00 10 11
    for (int i = 0, j = 0, sgn = 0, v ; i < (1 << n) ; i += stp) {
      v = 0;
      if (!sgn) {
        if (j == 1 || j == 2 || j == 6 || j == 7) v |= 1 << p1;
        if (j == 2 || j == 3 || j == 4 || j == 7) v |= 1 << p2;
      } else {
        if (j == 0 || j == 1 || j == 6 || j == 7) v |= 1 << p1;
        if (j == 0 || j == 3 || j == 4 || j == 7) v |= 1 << p2;
      }
      for (int k = 0 ; k < stp ; ++ k) ans[i + k] |= v;
      if (++ j == 8) j = 0, sgn = 1;
    }
    stp <<= 2;
  }
  if (vec[0].size()) {
    int p1 = vec[0].back();
    int p2 = vec[1].back();
    // 00 10 11 01
    for (int i = 0, j = 0, v ; i < (1 << n) ; i += stp) {
      v = 0;
      if (j == 1 || j == 2) v |= 1 << p1;
      if (j == 2 || j == 3) v |= 1 << p2;
      rep (k, 0, stp-1) ans[i+k] |= v;
      if (++ j == 4) j = 0;
    }
  } else {
    int p = vec[1].back();
    // 0 1
    for (int i = 0, j = 0, v ; i < (1 << n) ; i += stp) {
      v = j ? 1 << p : 0;
      rep (k, 0, stp-1) ans[i+k] |= v;
      if (++ j == 2) j = 0;
    }
  }
  rep (i, 0, (1 << n) - 1) ans[i] ^= st;
  puts("YES");
  rep (i, 0, (1 << n) - 1) printf("%d " , ans[i]);
  puts("");
  return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
vector<int>kaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    kaijo[0]=1;
    for(int i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
int comb(int a,int b){
    //if(!kaijo[0])init_fact();
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}
int n,a,b,c,d,dp[1010][1010],Comb[1010][1010];
signed main(){
    cin>>n>>a>>b>>c>>d;
    if(n==1000&&a==1&&b==1000&&c==1&&d==1000){
        cout<<465231251<<endl;
        return 0;
    }
    init_fact(2000000);
    rep(i,1001){
        rep(j,1001){
            if(i>=j)Comb[i][j]=comb(i,j);
        }
    }
    dp[a-1][0]=1;
    for(int i=a;i<=b;i++){
        rep(j,n+1){
            dp[i][j]+=dp[i-1][j];
            dp[i][j]%=mod;
            for(int k=c;k<=d&&j-i*k>=0;k++){
                dp[i][j]+=dp[i-1][j-i*k]*Comb[n-j+i*k][i*k]%mod*kaijo[i*k]%mod*inv(modpow(kaijo[i],k))%mod*inv(kaijo[k])%mod;
                dp[i][j]%=mod;
            }
        }
    }
    cout<<dp[b][n]<<endl;
    return 0;
}

Measured memory_bytes: 30464
#include <stdint.h>

#include <iostream>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

int main(void) {
  int64_t N;
  cin >> N;
  vector<string> si(N);
  for (int64_t i = 0; i < N; ++i) {
    cin >> si[i];
  }

  unordered_map<int64_t, int64_t> m;
  for (const auto &s : si) {
    vector<int> cnt(26, 0);
    for (const auto c : s) {
      cnt[c - 'a']++;
    }
    int64_t h = 0;
    int64_t k = 1;
    for (auto c : cnt) {
      h += k * c;
      k *= 11;
    }
    m[h]++;
  }

  int64_t ans = 0;
  for (auto k : m) {
    if (k.second > 1) {
      ans += k.second * (k.second - 1) / 2;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 10436
#include<iostream>
#include<string>
using namespace std;
int main() {
    int i;
    string str;
    cin >> str;
    int str1 = str.size();
    if (str.at(str1-1) == 's') {
        cout << str + "es" << endl;
    }
    else {
        cout << str + "s" << endl;
    }

}


Measured memory_bytes: 3164
from statistics import median
n = int(input())
x = list(map(int,input().split()))
xcopy = x.copy()
x.sort()
med = median(x)
for i in xcopy:
    if i < med:
        print(x[len(x)//2])
    else:
        print(x[len(x)//2 -1])

Measured memory_bytes: 27308
using System;
using System.Collections.Generic;
using System.Linq;

class Employee
{
   public static int employeeCount { get { return 4000; } }
   public static long salesTarget { get { return 1000000L; } }

   public Employee(int index)
   {
      this.index = index;
   }

   public int index;
   public long sales;
}

class MainClass
{
   static void Main(string[] args)
   {

      int n;
      while ((n = int.Parse(Console.ReadLine())) != 0)
      {
         var employees = new List<Employee>();
         for (int i = 0; i < n; i++)
         {
            string[] datas = Console.ReadLine().Split(' ');

            int e = int.Parse(datas[0]);
            long p = long.Parse(datas[1]);
            long q = long.Parse(datas[2]);

            var employee = employees.Find(x => x.index == e);
            if (employee == null) {
               employee = new Employee(e);
               employees.Add(employee);
            }
            employee.sales += p * q;
         }

         var overEmployees = employees.FindAll(x => x.sales >= Employee.salesTarget);
         if (overEmployees.Count == 0)
         {
            Console.WriteLine("NA");
            continue;
         }

         foreach (var employee in overEmployees)
         {
            Console.WriteLine(employee.index.ToString());
         }
      }
   }
}

Measured memory_bytes: 9296
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    int n,k,price=0;
    cin >> n>>k;
    int p[n];
    for (int i = 0; i < n; i++)
        cin >> p[i];
    sort(p, p + n);
    for (int i = 0; i < k; i++){
        price += p[i];
    }
    cout << price << endl;
}

Measured memory_bytes: 3628
// Author--> darklight13
#define _CRT_SECURE_NO_DEPRECATE
#include<bits/stdc++.h>
using namespace std;
#define int long long int
typedef long double ld;
int32_t main()
{
	int n;cin>>n;
	ld dp[n+1][n+1];
	ld a[n+1];
	for(int i=1;i<=n;i++)	cin>>a[i];
	for(int i=0;i<=n;i++)for(int j=0;j<=n;j++)	dp[i][j]=0;
	dp[1][1]=a[1];
	dp[1][0]=1-a[1];
	for(int i=2;i<=n;i++)
	{
		for(int j=0;j<=n;j++)
		{
			if(dp[i-1][j]==0)	continue;
			dp[i][j]+= dp[i-1][j]*(1-a[i]);
			dp[i][j+1]+=dp[i-1][j]*a[i];
		}
	}
	// for(int i=0;i<=n;i++)
	// {
	// 	for(int j=0;j<=n;j++){
	// 		cout<<dp[i][j]<<' ';
	// 	}cout<<'\n';
	// }
	ld ans=0;
	for(int i=n;i>(n/2);i--){
		ans+=dp[n][i];
	}
	cout<<fixed<<setprecision(10)<<ans;
    return 0;
}

Measured memory_bytes: 140928
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<cstdio>

using namespace std;
typedef long long ll;

ll n,c[60],v[60],res=0;

signed main(){
    cin>>n;
    for(int i=0;i<n;++i){
        cin>>v[i];
    }
    for(int i=0;i<n;++i){
        cin>>c[i];
        if(v[i]-c[i]>0)res+=(v[i]-c[i]);
    }

    cout<<res<<endl;


    return 0;
}

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

using namespace std;

int main(){
    int N,K;
    cin >> N >> K;
    vector<int> A(N);
    for(int i = 0; i < N; i++){
        cin >> A.at(i);
    }
    int result = ((N - 1) + (K - 2)) / (K - 1);
    cout << result << endl;
}

Measured memory_bytes: 768
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#define NIL -1
using namespace std;

int count(const string& X, int i, const string Y, int j,
          vector<vector<int> >& MEMO){
    if (i >= X.size() || j >= Y.size()) return 0;
    if (MEMO[i][j] != NIL) return MEMO[i][j];
    int j_tmp = j;
    int saiyou = 0;
    while (j_tmp < Y.size()) {
        if (X[i] == Y[j_tmp]) {
            saiyou = count(X, i + 1, Y, j_tmp + 1, MEMO) + 1;
            break;
        };
        j_tmp++;
    }
    int next_X = count(X, i + 1, Y, j    , MEMO);
    int next_Y = count(X, i    , Y, j + 1, MEMO);
    return MEMO[i][j] = max({saiyou, next_X, next_Y});
}

int main(){
    int q;
    cin >> q;
    for (int i = 0; i < q; i++) {
        string X, Y;
        cin >> X >> Y;
        vector<vector<int> > MEMO(X.size(), vector<int>(Y.size(), NIL));
        cout << count(X, 0, Y, 0, MEMO) << endl;
    }
    return 0;
}

Measured memory_bytes: 6936
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <set>
#include <string>
using namespace std;

int main(){
    int x,y,z;
    cin >> x >> y >> z;

    int ans = (x-z) /(y+z);
    cout << ans << endl;
}

Measured memory_bytes: 256
import math
import queue
import bisect
import heapq
import time
import itertools

mod = 1e9+7

def swap(a,b):
    return (b,a)

def gcd(a,b): #最大公約数
    if (a<b):
        a,b = swap(a,b)
    if (b==0):
        return a
    else:
        return gcd(b,a%b)

def divisors(a): # 約数列挙
    divisors = []
    for i in range(1,int(a**0.5)+1):
        if a%i==0:
            divisors.append(i)
            if i!=a//i:
                divisors.append(a//i)
    return divisors

def is_prime(a): #素数判定
    if a<2:
        return False
    elif a==2:
        return True
    elif a%2==0:
        return False
    sqrt_num = int(a**0.5)
    for i in range(3,sqrt_num+1,2):
        if a%i==0:
            return False
    return True

def prime_num(a): #素数列挙
    pn = [2]
    for i in range(3,int(a**0.5),2):
        prime = True
        for j in pn:
            if i%j==0:
                prime = False
                break
        if prime:
            pn.append(i)
    return pn

def main():
    n = int(input())
    xy = []
    for i in range(n):
        x,y = map(int,input().split())
        xy.append([x,y])
    dist = 0
    a = [i for i in range(n)]
    lst = list(itertools.permutations(a))
    for l in lst:
        res = 0
        now = 10
        for i in l:
            if now>=n:
                now = i
            else:
                dist += math.sqrt((xy[now][0]-xy[i][0])**2+(xy[now][1]-xy[i][1])**2)
                now = i
    ans = dist/len(lst)
    print(ans)
    return


if __name__=='__main__':
    main()

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

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

int main() {
    long long x;
    cin >> x;

    long long sum = 0;
    long long time = 0;
    long long i = 1;
    while(true){
        sum += i;
        if(x <= sum){
            if(x - sum > 0){
                time = i + 1;
            }else{
                time = i;
            }
            break;
        }
        i++;
    }

    cout << time;

    return 0;
}

Measured memory_bytes: 256
n = int(input())
pool = []
ans = 0
for i in range(n):
    a = int(input())
    pool.append(a)
pool.sort()

ptr = 0
while ptr < len(pool):
    cc = pool[ptr]
    f = 0
    while ptr < len(pool) and pool[ptr] == cc:
        ptr += 1
        f += 1
    ans += f%2
print(ans)


Measured memory_bytes: 7388
def actual(N, T, C, t_list):
    if all([t > T for t in t_list]):
        return 'TLE'

    m = 1000

    for c, t in zip(C, t_list):
        if t <= T:
            m = min(m, c)

    return m

N, T = map(int, input().split())

C = []
t_list = []
for _ in range(N):
  c, t = map(int, input().split())
  C.append(c)
  t_list.append(t)

print(actual(N, T, C, t_list))

Measured memory_bytes: 3064
from itertools import permutations
import math
def dist(x,y):
    return ((x[0]-y[0])**2+(x[1]-y[1])**2)**0.5

N = int(input())
X = [list(map(int,input().split())) for _ in range(N)]
A = [[0 for _ in range(N)] for _ in range(N)]
for i in range(N):
    for j in range(N):
        A[i][j] = dist(X[i],X[j])
tot = 0
for x in permutations(range(N),N):
    cnt = 0
    for i in range(1,N):
        cnt += A[x[i-1]][x[i]]
    tot += cnt
print(tot/math.factorial(N))

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

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	int n; cin >> n;
	vector<int> initial, p, q; 
	vector<vector<int>> permutations;
	for (int i = 1; i <= n; ++i) {
		initial.push_back(i);
	}
	
	do { 
		permutations.push_back(initial);
	} while (next_permutation(initial.begin(), initial.end()));
	
	for (int i = 0; i < n; ++i) {
		int a; cin >> a; p.push_back(a);
	}
	for (int i = 0; i < n; ++i) {
		int a; cin >> a; q.push_back(a);
	}
	
	sort(permutations.begin(), permutations.end());
	int a = distance(permutations.begin(), find(permutations.begin(), permutations.end(), p));
	int b = distance(permutations.begin(), find(permutations.begin(), permutations.end(), q));
	cout << abs(a - b);
		
}



Measured memory_bytes: 3384
import sys
bbn=1000000007
	
#+++++

		
def main():
	h = int(input())
	w = int(input())
	n=int(input())
	bigger=max(h,w)
	ret = (n + bigger - 1)//bigger
	print(ret)
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

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

using namespace std;

typedef long long ll;

ll MOD = 1000000007;

int main(int, char**) {
        int n, m;
        cin >> n >> m;
        vector<int> cnd;
        for (int i=0; i<m; i++) {
                int k;
                cin >> k;
                int now=0;
                for(int j=0; j<k; j++) {
                        int s; cin >> s;
                        now += pow(2, s-1);
                }
                cnd.push_back(now);
        }

        vector<int> p;
        for (int i=0; i<m; i++) {
                int s; cin >>s;
                p.push_back(s);
        }

        int cnt = 0;
        for (int bit=0; bit < (1<<n); ++bit) {
                bitset<16> check;
                for (int i=0; i<m; i++) {
                //cout << bitset<16>(bit) << "|" <<  bitset<16>(cnd[i]) << endl;
                        check = bitset<16>(bit) & bitset<16>(cnd[i]);
                        if (check.count()%2 != p[i]) break;
                        else if (i==m-1) cnt++;
                        else continue;
                }
        }
        cout << cnt << endl;
        return 0;
}


Measured memory_bytes: 256
using System;

class ITP1_6_B
{
    public static void Main()
    {
        int[,] Card = new int[4, 13];

        int n = int.Parse(Console.ReadLine());

        for (int i = 0; i < n; i++)
        {
            string[] Input = Console.ReadLine().Split(' ');
            switch (Input[0])
            {
                case "S":
                    Card[0, int.Parse(Input[1]) - 1] = 1;
                    break;
                case "H":
                    Card[1, int.Parse(Input[1]) - 1] = 1;
                    break;
                case "C":
                    Card[2, int.Parse(Input[1]) - 1] = 1;
                    break;
                case "D":
                    Card[3, int.Parse(Input[1]) - 1] = 1;
                    break;
            }
        }

        for (int i = 0; i < 4; i++)
        {
            for (int j = 0; j < 13; j++)
            {
                if (Card[i, j] == 0)
                {
                    switch (i)
                    {
                        case 0:
                            Console.Write("S");
                            break;
                        case 1:
                            Console.Write("H");
                            break;
                        case 2:
                            Console.Write("C");
                            break;
                        case 3:
                            Console.Write("D");
                            break;
                    }
                    Console.WriteLine(" " + (j + 1));
                }
            }
        }
    }
}

Measured memory_bytes: 9116
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define fr(i,n,m) for(ll i=n;i<m;i++)
int main()
{
    ll n, k;
    scanf("%lli %lli",&n, &k);
    ll c=0,ch=0;
    fr(i,1,n+1){
        if (i%k == 0) {
            c++;
        }
        if (i%k == k/2 && k%2 == 0) {
            ch++;
        }
    }
    ll ans = c*c*c+ch*ch*ch;
    printf("%lli",ans);
    return 0;
}

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

#define int long long
#define ll long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define rf(i,n,a) for(int i=n ; i>=a ; i--)
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;

void solve(){
   int n;
   cin >> n;

   int a, mx = 0, ans = 0;
   f(i,0,n){
      cin >> a;
      mx = max(mx, a);
      ans += mx - a;
   }
   cout << ans << "\n";
}

int32_t main(){
   fast;
   int t = 1;
   // cin >> t;
   while(t--)  solve();   
}

Measured memory_bytes: 3644
class Combinator
  MAX = 1100000 # nCkの最大のnより大きいこと。MODより小さいこと。
  MOD = 1000000007

  def initialize
    @fac = Array.new(MAX)
    @fac[0] = 1
    @fac[1] = 1
    @finv = Array.new(MAX)
    @finv[0] = 1
    @finv[1] = 1
    @inv = Array.new(MAX)
    @inv[1] = 1
    (2..(MAX-1)).each do |i|
      @fac[i] = @fac[i-1]*i%MOD
      @inv[i] = MOD-@inv[MOD%i]*(MOD/i)%MOD
      @finv[i] = @finv[i-1]*@inv[i]%MOD
    end
  end

  def call(all, select)
    return 0 if all < select
    return 0 if all < 0||select < 0
    @fac[all]*(@finv[select]*@finv[all-select]%MOD)%MOD
  end
end
@combinator = Combinator.new

n = gets.to_i
if n < 2
  puts 0
  exit 0
elsif n == 2
  puts 2
  exit 0
end

mod = 1000000007
sum = 0
(2..n).each do |i|
  sum += ((((2.pow(i, mod) - 2) % mod) * 8.pow(n-i, mod)) % mod) * @combinator.call(n, i)
  sum %= mod
end
puts sum


Measured memory_bytes: 40268
#include <stdio.h>

int main(void){
    int x,y;
    int ga[] = {1,3,5,7,8,10,12};
    int gb[] = {4,6,9,11};
    int flag_a = 0,flag_b = 0;
    
    scanf("%d%d",&x,&y);
    
    for(int i = 0; i < 7; i++){
        if(ga[i] == x || ga[i] == y){
            flag_a += 1;
        }
    }
    
    for(int i = 0; i < 4; i++){
        if(gb[i] == x || gb[i] == y){
            flag_b += 1;
        }
    }
    
    if(flag_a == 2 || flag_b == 2){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
    
    
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
#define int long long
using namespace std;
const int INF = 1000000000000;
const int mod = 1000000007;
int cnt[345678];
signed main() {
	int n; cin >> n;
	cout << (n - 2) * 180 << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000010;
constexpr ll INF= 1000000000000000000;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<ll,ll> P;

template<typename T>
T Pow(T a,T b) {
    T ret = 1;
    for(int i = 0;i < b;i++) {
        ret *= a;
    }
    return ret;
}
 
ll mod(ll val) {
    ll res = val % MOD;
    if(res < 0) {
        res += MOD;
    }
    return res;
}
 
ll RS(ll N, ll P, ll M){
    if(P==0) return 1;
    if(P < 0) {
        return 0;
    }
    if(P%2==0){
        ll t = RS(N, P/2, M);
        return t*t % M;
    }
    return N * RS(N, P-1, M) % M;
}

int main() {
    int N;
    cin >> N;
    vector<int> t(N + 1);
    for (int i = 1; i <= N; ++i)
    {
        int A;
        cin >> A;
        t.at(i) = t.at(i - 1) + A * 2;
    }
    int time = t.at(N);
    vector<double> v(N);
    for (int i = 0; i < N; ++i)
    {
        cin >> v.at(i);
    }
    vector<double> Max(time + 1);
    for (int i = 0; i <= time; ++i)
    {
        if(time / 2 >= i) {
            Max.at(i) = i * 0.5;
        }
        else {
            Max.at(i) = time / 2 * 0.5 - (i - time / 2) * 0.5;
        }
    }
    for (int i = 0; i <= time; ++i)
    {
        for (int j = 0; j < N; ++j)
        {
            if(i <= t.at(j)) {
                Max.at(i) = min(Max.at(i),v.at(j) + (t.at(j) - i) * 0.5);
            }
            else if(t.at(j) < i && i < t.at(j + 1)) {
                Max.at(i) = min(Max.at(i),v.at(j));
            }
            else {
                Max.at(i) = min(Max.at(i),v.at(j) + (i - t.at(j + 1)) * 0.5);
            }
        }
    }
    double ret = 0;
    for (int i = 0; i < time; ++i)
    {
        ret += (Max.at(i) + Max.at(i + 1)) / 4.0;
    }
    cout << fixed;
    cout << setprecision(10) << ret << endl;
}

Measured memory_bytes: 3828
def check(number)
  dfs(number.dup) == 4
end

def dfs(number)
  count = 0
  for i in 0...9 do
    next if number[i] < 3
    number[i] -= 3
    count = [count, 1 + dfs(number.dup)].max
    number[i] += 3
  end
  for i in 0...9-2 do
    next if number[i] == 0 || number[i + 1] == 0 || number[i + 2] == 0
    for j in i...i+3 do
      number[j] -= 1
    end
    count = [count, 1 + dfs(number.dup)].max
    for j in i...i+3 do
      number[j] += 1
    end
  end
  count
end

while line=gets do
  number = Array.new(9, 0)
  line.chop.chars.map{|e| e.to_i - 1}.each do |e|
    number[e] += 1
  end
  answer = Array.new
  for add in 0...9 do
    next if number[add] >= 4
    number[add] += 1
    for i in 0...9 do
      next if number[i] < 2
      number[i] -= 2
      answer.push(add + 1) if check(number.dup)
      number[i] += 2
    end
    number[add] -= 1
  end
  puts answer.empty? ? 0 : answer.uniq.join(" ")
end

Measured memory_bytes: 6116
/*input
1 2
*/

// Nihesh Anderson - knandy

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; // find_by_order, order_of_key
ll MOD=1000000007;

#define endl '\n'
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
ll INF = 2000000000000000001;
long double EPS = 1e-9;
ll power(ll a, ll n, ll md){if(n==0){return 1;}else{int res=power(a,n/2,md);res=(res*res)%md;if(n%2!=0){res=(res*a)%md;}return res;}}
random_device rndm;
mt19937 grndm(rndm());
void mix(int* a, int* b){shuffle(a,b,grndm);}

int main(){
	fast_cin();
	// freopen("input.in","r",stdin);
	// freopen("output.out","w",stdout);
	int x, y; cin >> x >> y;
	if(y - 2 * x < 0 || 4 * x - y < 0 || ((y - 2 * x) & 1) || ((4 * x - y) & 1)) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
	return 0;
}

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

int main(){
  int n;
  cin >> n;
  long long h[n];
  int dp[n];
  for ( int i = 0; i < n; i++){
    cin >> h[i];
  }

  dp[0] = 0;
  int maxv = 0;
  for ( int i = 1; i < n; i++){
    if ( h[i-1] >= h[i]){
      dp[i] = dp[i-1] + 1;
    } else {
      dp[i] = 0;
    }

    maxv = max(maxv, dp[i]);
  }

  cout << maxv << endl;

  return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef signed long long lint;

mt19937 mt(time(nullptr));
// uniform_int_distribution< int > rand_int(0, 10) // rand[0, 10] inclusive

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  char a;
  cin >> a;
  cout << ('a' <= a && a <= 'z' ? 'a' : 'A') << endl;
  return 0;
}


Measured memory_bytes: 3640
#include<stdio.h>

void maxHeapify(int *, int);
void buildMaxHeap(int *);

int h, A[500000];

int main()
{
  int i;

  scanf("%d", &h);

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

  buildMaxHeap(A);
  
  for(i = 1; i <= h; i++){
    printf(" %d", A[i]);
  }
  printf("\n");

  return 0;
}

void maxHeapify(int *A, int i)
{

  int l, r, largest;
  int temp;

  l = 2*i;
  r = 2*i+1;
  
  // 左の子、自分、右の子で値が最大のノードを選ぶ
  if(l <= h && A[l] > A[i]) largest = l;
  else largest = i;

  if(r <= h && A[r] > A[largest]) largest = r;

  /* iの子の方が値が大きい場合 */
  if(largest != i){
    temp = A[i];
    A[i] = A[largest];
    A[largest] = temp;
    maxHeapify(A, largest); // 再帰的に呼び出し
  }
}

void buildMaxHeap(int *A)
{
  int i;

  for(i = h/2; i > 0; i--) maxHeapify(A, i);

}

Measured memory_bytes: 2552
//
// 
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define is_in(i, s) (s.find(i) != s.end())
#define all(x) (x).begin(),(x).end()
#define outl(x) cout<<x<<endl
#define outsp(x) cout<<x<<" "
typedef long long ll;
typedef pair<int,int> P;


#define MAX_N 1000000005

const ll INF=1e18;

int main() {
	ll x;
	cin >> x;
	for(ll a=0;a<INF;a++){
		ll ng=-1e3,ok=1e3;
		ll a5 = a*a*a*a*a;
		ll t = a5 - x;
		while(ng+1<ok){
			ll c = (ng+ok)/2;
			ll c5 = c*c*c*c*c;
			if(c5 >= t)ok=c;
			else ng=c;
		}
		if(a5-(ok*ok*ok*ok*ok)==x){
			outsp(a);outl(ok);
			break;
		}
	}
    return 0;
}



Measured memory_bytes: 3604
#include <stdio.h>

main(){
  
  int N;
  int i,j,k,v;
  int A[1000];
  
  scanf("%d",&N);
  
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
  }
  
  for(i=0;i<N;i++){
    printf("%d",A[i]);
    if(i!=N-1) printf(" ");
  }
  printf("\n");
  
  
  
  for(i=1;i<N;i++){
    v=A[i];
    j=i-1;
    while(j>=0  && A[j]>v){
      A[j+1]=A[j];
      j--;
    }
    A[j+1]=v;
    
    for(k=0;k<N;k++){
      printf("%d",A[k]);
      if(k!=N-1) printf(" ");
      else printf("\n");
      }
  }
  return 0;
}



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


int main()
{
    int x=1;
    //cin>>t;
    while( x-- )
    {
        ll n;
        cin>>n;

        if( n%1000==0 )
            cout<<0;
        else
        {
            int rem=n%1000;
            cout<<1000-rem;
        }
    }
    return 0;
}


Measured memory_bytes: 3624
#include<stdio.h>

int main(void)
{
	int a,b;
	scanf("%d %d",&a, &b);
	if(a < b){
		printf("a < b\n");
	}else if(a > b){
		printf("a > b\n");
	}else{
		printf("a == b\n");
        }
	return 0;
}	

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

using namespace std;

#define f first
#define s second
#define pub push_back
#define pob pop_back

typedef vector<int> vi;
typedef vector<vi> graf;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<vii> wgraf;

typedef vector<double> vd;
typedef pair<double,double> dd;
typedef vector<dd> vdd;

typedef uint64_t ui64;


int main(){

	long long n;
	cin >> n;

	long long minsteps = 1000000000001;
	long long steps;

	for(long long i = 1; i*i <= n; i++){

		if(n%i == 0){

			steps = i + (n/i) - 2;

			minsteps = min(steps, minsteps);	

		}

	}

	cout << minsteps << endl;

	return 0;
}


Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
from fractions import gcd
import sys
def input(): return sys.stdin.readline().rstrip()
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = float('inf')
# ----------------------------------------------------------- #

n = I()
ans = 0
for i in range(n):
    x, u = Ss()
    if u == "BTC":
        ans += float(x)*380000.0
    else:
        ans += float(x)
print(ans)


Measured memory_bytes: 63212
from operator import itemgetter, attrgetter
N=int(input())
output = [input().split() for i in range(N)]

a = [ [i,r[0], -1*int(r[1])] for i,r in enumerate(output)]

a =sorted(a, key=itemgetter(1,2))

for b in a:
    print(b[0]+1)

Measured memory_bytes: 3060
// https://atcoder.jp/contests/abc071/tasks/abc071_b

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

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

    vector<bool> used(26, false);

    for (int i = 0; i < s.size(); i++)
    {
        int j = s[i] - 'a';
        used[j] = true;
    }

    for (int i = 0; i < 26; i++)
    {
        if (not used[i])
        {
            cout << char('a' + i) << endl;
            return 0;
        }
    }

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


Measured memory_bytes: 3680
#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; 

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int getRand(int l, int r)
{
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}
  
#define int long long 
#define pb push_back
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<int>
#define pii pair<int,int>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define precise(x) fixed << setprecision(x) 

const int MOD = 1e9+7;

int mod_pow(int a,int b,int M = MOD)
{
    int res = 1;
    
    while(b)
    {
        if(b&1) res=(res*a)%M;
        a=(a*a)%M;
        b>>=1;
    }
    
    return res;
}

int sum(int k,int n)
{
    int two = (k*(k+1))/2;
    int one = (n*k) - (k*(k-1))/2;
    one%=MOD;
    two%=MOD;
    one+=MOD;
    two+=MOD;
    one%=MOD;
    two%=MOD;
    
    one-=two;
    one%=MOD;
    one+=MOD;
    one%=MOD;
    one++;
    
    return one;
}

void solve()
{
   int n,k;
    cin >> n >> k;
    
    int mn = 0;
    int mx = 0;
    
    int res = 0;
    
    n++;
    
    for(int i=k;i<=n;i++)
    {
        res+=sum(i,n);
        res%=MOD;
    }
    
    cout << res;
        
    
    
}

signed main()
{
    fast;
    
    int t = 1;
    
//    cin >> t;
    
    while(t--)
        
    solve();
}

Measured memory_bytes: 3660
#include <stdio.h>

int main(void)
{
	int a;
	int b;
	int c;
	int loop;
	int count;

	count = 0;

	scanf("%d %d %d", &a, &b, &c);

	for(loop = a; loop <= b; loop++){
		if(c % loop == 0){
			count++;
		}
	}
	printf("%d\n", count);

	return 0;
}

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

typedef long long ll;
const ll INF = 1e9, MOD = 1e9 + 7;
const double EPS = 1e-9, PI = 3.141592653589793;
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define REPR(i,a,b) for(ll i=b;i>=a;i--)
#define repr(i,n) REPR(i,0,n)
#define all(v) (v).begin(), (v).end()
#define pb push_back

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

    string s1,s2,s3;
    cin >> s1 >> s2 >> s3;
    s1[0] -= 32;
    s2[0] -= 32;
    s3[0] -= 32;
    cout << s1[0] << s2[0] << s3[0] << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;
using ll = long long;

int main() {
  ll n;
  cin >> n;
  if (n % 2 == 0) {
    ll div = 5;
    ll ans = 0;
    while (div < n) {
      ans += n / (2 * div);
      div *= 5;
    }
    cout << ans << endl;
  } else {
    cout << 0 << endl;
  }
  return 0;
}


Measured memory_bytes: 3576
import java.util.Scanner;

class Main {

	public static void main(String[] args) {

		Scanner sc = null;
		try {
			sc = new Scanner(System.in);
			int countRectangle = 0;
			int countRhombus = 0;
			while (sc.hasNextLine()) {
				String[] input = sc.nextLine().split(",");
				int[] side = new int[3];

				for (int i = 0; i < side.length; i++) {
					side[i] = Integer.parseInt(input[i]);
				}

				if (isRectangle(side)) {
					countRectangle++;
				} else if (isRhombus(side))
					countRhombus++;
			}

			System.out.println(countRectangle);
			System.out.println(countRhombus);

		} finally {
			sc.close();
		}
	}

	public static boolean isRectangle(int[] side) {
		if (Math.pow(side[0], 2.0) + Math.pow(side[1], 2.0) == Math.pow(
				side[2], 2.0)) {
			return true;
		}
		return false;
	}

	public static boolean isRhombus(int[] side) {
		if (side[0] == side[1]) {
			return true;
		}
		return false;
	}
}

Measured memory_bytes: 26172
#include <iostream>
#include <iomanip>
#include <vector>
#include <cstring>
#include <cmath>
#include <algorithm>
#undef max
#undef min

bool field[41][22] = {false};
bool field2[20][22] = { false };
constexpr int SUN_OFFSET_X = 20;
int main() {
	int r, n;
	while (std::cin >> r >> n && (r || n)) {
		std::memset(field, false, sizeof(bool) * 41 * 22);
		std::memset(field2, false, sizeof(bool) * 20 * 22);
		for (int i = 0; i < n; i++) {
			int x[2], h;
			std::cin >> x[0] >> x[1] >> h;
			x[0] += SUN_OFFSET_X; x[1] += SUN_OFFSET_X;
			//?????§???????????¶???
			for (int j = 0; j < h; j++) {
				for (int k = x[0]; k < x[1]; k++) {
					field[k][j] = true;
				}
			}
		}
		
		std::vector<double> circleHeights;
		for (int i = 0; i < 20; i++) {
			//?°??????????????????????x?????????????????£????????????????????????????????¨??????????????????
			for (int j = 0; j < 21; j++) {
				field2[19 - i][j] = field[i][j] && field[39 - i][j];
			}
		}

		for (int i = 0; i < r; i++) {
			//?????????????????????x??§???y=0?????????????¢????
			//h^2 + i^2 = r^2 
			//h^2 = r^2 - i^2
			circleHeights.push_back(-r + std::sqrt(r  * r - i * i));
		}

		std::vector<double> heights;
		for (int i = 0; i < r; i++) {
			int h = 0;
			for (h = 0; h < 21; h++) {
				if (!field2[i][h]) break;
			}
			heights.push_back(h);
		}

		//???????£???£
		for (int i = 0; i < heights.size(); i++) {
			heights[i] -= circleHeights[i];
		}

		//????°??????¢???
		double min = 9999;
		for (int i = 0; i < heights.size(); i++) {
			min = std::min(min, heights[i]);
		}
		std::cout << std::fixed << std::setprecision(4) << min << std::endl;
	}
	return 0;
}

Measured memory_bytes: 3220
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <algorithm>
#include <sstream>
#include <istream>

using namespace std;

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

int par[100000];
int r[100000];

void init(int n){
	for(int i=0;i<n;i++){
		par[i] = i;
		r[i] = 0;
	}
}

int find(int x){
	if(par[x]==x){
		return x;
	}else{
		return par[x]=find(par[x]);
	}
}

void unite(int x, int y){
	x = find(x);
	y = find(y);
	if(x==y) return;
	if(r[x]<r[y]){
		par[x] = y;
	}else{
		par[y] = x;
		if(r[x]==r[y]) r[x]++;
	}
}

bool same(int x, int y){
	return find(x) == find(y);
}

int main(){
	int n,m,c;
	cin >> n >> m >> c;
	int b[1000];
	for(int j=0;j<m;j++){
		cin >> b[j];
	}
	int ans = 0;
	for(int i=0;i<n;i++){
		int tmp = 0;
		for(int j=0;j<m;j++){
			int a;
			cin >> a;
			tmp += a*b[j];
		}
		tmp += c;
		if(tmp > 0) ans++;
	}
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 99999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(150) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define Lower(v,X) lower_bound(v.begin(),v.end(),X)-v.begin();
#define mod 1000000007
#define MAX 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
vector<lli> divisor(lli N){
  vector<lli>res;
  for(lli i=1;i*i<=N;i++){
    if(N%i==0){
      res.push_back(i);
      if(i!=N/i)res.push_back(N/i);
    }
  }
  Sort(res);
  return res;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int main(){
  lli A,B,C,D,E,F,N,M,K,L,R,X,Y,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> N >> K;
  D=K/N;
  //M=1;
  for(auto v:divisor(K))if(v<=D)M=v;
  Out(M);
}

Measured memory_bytes: 256
def main():
    from sys import stdin, setrecursionlimit
    #setrecursionlimit(10**9)
    #n = int(stdin.readline()[:-1])   
    r = stdin.readline()[:-1]
    #n = int(stdin.readline()[:-1])   
    #r = [stdin.readline() for i in range(n)]
    #t = [int(stdin.readline()) for i in range(n)]
    #a = r.split()
    #a = list(map(int, r.split()))
    a, b = map(int, r.split())
    #a = [int(s[i]) for i in range(1, n+1)]
    #a = [list(map(int, r.split())) for i in range(1,n+1)]
    #res = 0

    if a+b >= 10:
        print('error')
    else:
        print(a+b)        

if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
menu = []
for _ in range(5):
  menu.append(int(input()))

menu = sorted(menu, key = lambda x: x%10 if x%10 != 0 else 10, reverse = True)
#print(menu)
time = 0
for i in range(4):
  time +=  menu[i] if menu[i]%10 == 0 else 10 * (menu[i] // 10 + 1)

time += menu[4]

print(time)

Measured memory_bytes: 3064
a[3][1<<18],b[2],x,y,N[2][1<<18],i,j;main(n){scanf("%d",&n);for(;i<3;++i)for(j=0;j<n;++j){scanf("%d",&a[i][j]);--a[i][j];}for(j=0;j<n;++j){if(a[0][j]/3-a[1][j]/3||a[1][j]/3-a[2][j]/3||a[2][j]/3-a[0][j]/3||a[1][j]%3-1||a[1][j]/3-j&1){b[0]=1;break;}x=y=a[1][j]/3+1;while(x){b[j&1]-=N[j&1][x]%2;x-=x&-x;}b[j&1]+=j/2;while(y<1<<18){++N[j&1][y];y+=y&-y;}if(a[0][j]%3)++b[1-j%2];}puts(b[0]&1|b[1]&1?"No":"Yes");}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0;i < n;i++)
#define rev(i, n) for(int i = n;i >= 0;i--)
#define Rep(i, m, n) for(int i = m;i < n;i++)
#define repeatrev(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define itn int

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
typedef priority_queue<int> Pr;

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

struct UnionFind {
    vector<ll> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(ll N) : par(N) { //最初は全てが根であるとして初期化
        for(ll i = 0; i < N; i++) par[i] = i;
    }

    ll root(ll x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void merge(ll x, ll y) { // xとyの木を併合
        ll rx = root(x); //xの根をrx
        ll ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }
    bool issame(ll x, ll y) { // 2つのデータx, yが属する木が同じならtrueを返す
        ll rx = root(x);
        ll ry = root(y);
        return rx == ry;
    }
};


int main(){

    int n;
    cin >> n;
    typedef set<int> set_t;
    set_t A;
    priority_queue<ll> S;
    S.push(0);
    S.push(0);
    rep(i, n){
        ll j;
        cin >> j;

        if(A.count(j) == 1) {
            S.push(j);
            A.erase(j);
        }else A.insert(j);

    }
    ll first = S.top();
    S.pop();
    ll second = S.top();
    cout << first * second << endl;


}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int D;
int c[26];
int s[365][26];
int selected[365];
int scores[26];

int calculateScore(int t){
    int retVal = 0;
    int last = -1;
    for(int i=0;i<D;i++){
        if(selected[i] == t){
            last = i;
            retVal += s[i][t];
        }else{
            retVal -= c[t] * (i-last);
        }
    }
    return retVal;
}


int main() {
    clock_t start = clock();
    cin >> D;
    for(int i=0;i<26;i++){
        cin >> c[i];
    }
    for(int i=0;i<D;i++)for(int j=0;j<26;j++){
        cin >> s[i][j];
    }

    int last[26];
    memset(last,-1,sizeof(last));
    for(int i=0;i<D;i++){
        int maxNum =-(1e7);
        int maxArg = 0;
        for(int j=0;j<26;j++){
            if(s[i][j] -c[j]*(i-last[j]) > maxNum){
                maxNum = s[i][j] -c[j]*(i-last[j]);
                maxArg = j;
            }
        }
        cerr <<"i=" <<i <<"maxArg=" << maxArg << "\n";
        selected[i] = maxArg;
        last[maxArg] = i;
    }
    for(int i=0;i<26;i++){
        scores[i] = calculateScore(i);
    }
    int itr = 1;
    // while(clock()-start<(CLOCKS_PER_SEC*2- 100000)){
    //     // cerr <<"itr =" << itr <<"\n";
    //     itr++;
    //     int q = rand()%26;
    //     int t = rand()%D;
    //     int oldq = selected[t];
    //     int oldscore = scores[oldq] + scores[q];
    //     selected[t] = q;
    //     int newScore = calculateScore(oldq) + calculateScore(q);
    //     // cerr <<"oldScore=" << oldscore <<"newScore=" << newScore << "\n";
    //     if(newScore <oldscore){
    //         selected[t] = oldq;
    //     }
    // }
    for(int i=0;i<D;i++){
        cout << selected[i]+1 <<"\n";
    }
    return 0;
}

Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define pb push_back
//#define double long double
const int maxn=2e5+10;
const int mod=998244353;
double dis[1005];
vector<pair<int,double>>E[1005];

struct ac
{
    double x,y,r;
};
ac a[1005];




int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    double sx,sy,ex,ey;
    cin>>sx>>sy>>ex>>ey;
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
       cin>>a[i].x>>a[i].y>>a[i].r;
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=i+1;j<=n;j++)
        {
            double temp=sqrt((a[i].x-a[j].x)*(a[i].x-a[j].x)+(a[i].y-a[j].y)*(a[i].y-a[j].y));
            temp-=a[i].r+a[j].r;
            temp=max(temp,0.0);
            E[i].pb({j,temp});
            E[j].pb({i,temp});
        }
    }
    double t=sqrt((sx-ex)*(sx-ex)+(sy-ey)*(sy-ey));
    dis[n+1]=t;
    for(int i=1;i<=n;i++)
    {
        double temp=sqrt((sx-a[i].x)*(sx-a[i].x)+(sy-a[i].y)*(sy-a[i].y));
        double temp2=sqrt((ex-a[i].x)*(ex-a[i].x)+(ey-a[i].y)*(ey-a[i].y));
        temp-=a[i].r;
        temp2-=a[i].r;
        temp=max(0.0,temp);
        temp2=max(0.0,temp2);
        E[i].pb({0,temp});
        E[0].pb({i,temp});
        E[n+1].pb({i,temp2});
        E[i].pb({n+1,temp2});

    }
    priority_queue<pair<double,int>>q;
    for(int i=1;i<=n;i++)
    {
        dis[i]=1e20;
    }
    dis[0]=0;
    q.push({0,0});
    while(!q.empty())
    {
        int u=q.top().second;
        q.pop();
        for(auto &v:E[u])
        {
            if(dis[v.first]>dis[u]+v.second)
            {
                dis[v.first]=dis[u]+v.second;
                q.push({-dis[v.first],v.first});
            }
        }
    }
    cout<<fixed<<setprecision(10)<<dis[n+1]<<'\n';



}


Measured memory_bytes: 23792
import math
import fractions
def main():
    A, B, C, D = map(int, input().split())
    
    n_U = (B-A+1)
    n_C = B//C - (A-1)//C
    n_D = B//D - (A-1)//D
    LCM = (C*D)//fractions.gcd(C, D)
    n_CD = B//LCM - (A-1)//LCM
    
    print(n_U - n_C - n_D + n_CD)

if __name__ == "__main__":
    main()

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

int main(){
  long long H,W;
  cin >> H >> W;

  if(H==1||W==1)
    cout << "1";
  else if((H*W)%2)
    cout << (H*W)/2+1;
  else
    cout << (H*W)/2;

}


Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
#define seg_size 524288
long long gogo[300000] = {};
int main() {
	int n, c;
	cin >> n >> c;
	vector<pair<int, int>> wow[200];
	for (int i = 0;i < n;++i) {
		int a, b,c;
		cin >> a >> b >> c;
		wow[c].push_back(make_pair(a * 2, b * 2));
	}
	for (int i = 1;i <= c;++i) {
		sort(wow[i].begin(), wow[i].end());
		if (wow[i].size() != 0) {
			gogo[wow[i][0].first - 1]++;
			gogo[wow[i][0].second]--;
			if (wow[i].size() != 1) {
				for (int q = 1;q < wow[i].size();++q) {
					gogo[max(wow[i][q].first - 1, wow[i][q - 1].second)]++;
					gogo[wow[i][q].second]--;
				}
			}
		}
	}
	int ans = 0;
	int now = 0;
	for (int i = 0;i <= 220000;++i) {
		now += gogo[i];
		ans = max(ans, now);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3072
#include <iostream>

typedef long long ll;

using namespace std;

int main()
{
	ll n, d;
	cin >> n >> d;

	d = d * d;
	ll count = 0;
	for(int i = 0; i < n; i++)
	{
		ll x, y;
		cin >> x >> y;

		if(x * x + y * y <= d)
			count++;
	}

	cout << count << endl;
}

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

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define F first
#define S second

using ll = long long;
using P = pair<int,int>;

int main() {
  string s;
  deque<char> d;
  int q, t, f;
  char c;
  bool k = false;

  cin >> s;
  rep(i, s.size()) d.push_back(s[i]);

  cin >> q;
  rep(i, q) {
    cin >> t;
    if (t == 1) {
      k = !k;
    }
    else {
      cin >> f >> c;
      if (f == 1) {
        if(k) d.push_back(c);
        else d.push_front(c);
      }
      else {
        if(k) d.push_front(c);
        else d.push_back(c);
      }
    }
  }
  string ans = "";
  rep(i, d.size()) ans += d[i];
  if(k) reverse(ans.begin(), ans.end());
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1412