akhauriyash/Code-Regression huggingface dataset:
//#include <bits/stdc++.h>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include <bitset>
#include <array>
#include <set>
#include <string>

#include <iterator>
#include <algorithm>
#include <numeric>

#include <ios>
#include <sstream>
#include <iostream>
#include <fstream>


#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define range(i,m,n) for(int i=m, i<n;i++)
#define each(i,n) for(auto i:n)
#define all(i) i.begin(),i.end()

#define makevv(i,j,k,l,m) vector<vector<i>> j(k,vector<i>(l,m))

using vi=std::vector<int>;
using vvi=std::vector<vi>;


template <typename T>
std::string printItr(T b, T e, std::string delim=" ")
{
    std::stringstream ss;
    std::ostream_iterator<decltype(*b)> out_it(ss, delim.c_str());
    std::copy(b,e - 1, out_it);
    ss<<*(e-1);
    return ss.str();
}
using namespace std;

int main(void){/*
    makevv(int,v,4,4,0);
    rep(i,4){
        iota(all(v[i]),i*4);
    }
    each(p,v){
        cout<<printItr(all(p),"+")<<"="<<accumulate(all(p),0)<<endl;
    }
    vi nv(3,0);
    each(&n,nv){
        n++;
    }
    cout<<printItr(all(nv))<<endl;
    each(n,nv){
        n++;
    }
    cout<<printItr(all(nv),",")<<endl;*/
    int n,m;
    cin>>n;
    multiset<int> a;
    rep(i,n){int p;cin>>p;a.insert(p);}
    cin>>m;
    multiset<int> b;
    rep(i,m){int p;cin>>p;b.insert(p);}
    multiset<int> r;
    set_difference(b.begin(), b.end(),
                      a.begin(), a.end(),
                      std::inserter(r, r.end()));
    if(r.empty()){
        cout<<"YES";
    }else cout<<"NO";
    
}

Measured memory_bytes: 19072
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define endl "\n"
#define speed(); ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define sz(x) (int)(x).size()
#define _USE_MATH_DEFINES
using namespace std;
typedef long long int lli;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
    speed();
    ll h, w;
    cin >> h >> w;
    if (h == 1 || w == 1)
        cout << "1" << endl;
    else
        cout << (h*w + 1) / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pr = pair<ll, ll>;
 
ll KnapsackDPW(vector<pr>&sack, int w) {
	ll sum = 0;
	for (auto &x : sack)
		sum += x.second;
	vector<ll>dp(sum + 1, (~(1 << 31)));
	dp[0] = 0;
	for (int i = 0; i < sack.size(); ++i)
		for (int j = sum - sack[i].second; j >= 0; --j)
			dp[j + sack[i].second] = min(dp[j + sack[i].second], dp[j] + sack[i].first);
 
	ll mn = 0;
	for (ll i = 0; i <= sum; ++i) {
		if(dp[i] <= w)
			mn = max(mn, i);
	}
	return mn;
}
int main() {
	/*fio;
	int n = 10;
	vector<vector<short>>board(n, vector<short>(n, 0));
 
	MoveOfAKnight(board, 0, 0);
 
	for (auto &x : board) {
		for (auto y : x)
			cout << ((y < 10) ? "0" : "") << y << " ";
		cout << endl;
	}*/
	int N, W, w, c;
	cin >> N >> W;
	vector<pr>sack;
	for (int i = 0; i < N; ++i) {
		cin >> w >> c;
		sack.push_back({ w, c });
	}
	cout << KnapsackDPW(sack, W) << endl;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
#include <list>
#include <ctime>
#include <numeric>
#include <fstream>
#include <valarray>
using namespace std;
static const double EPS = 1e-6;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PI;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SZ(a) (int(a.size()))
#define F first
#define S second
const long double pi=acos(-1.0);
int dx[]={0,1,0,-1,1,1,-1,-1,0},dy[]={1,0,-1,0,1,-1,1,-1,0};

int n;
pair<ll,ll> in[100];
ll dp[100][101];
bool vis[100][101];

ll rec(int a,int b){
  if(a+2>b)return 0;
  if(a+2==b)
    return in[a].F*in[a].S*in[b-1].F*in[b-1].S;
  if(vis[a][b])return dp[a][b];
  vis[a][b]=true;
  ll& ret=dp[a][b]=1LL<<50LL;
  
  for(int s=a+1;s<b;++s)
    ret=min(ret,
            rec(a,s)+rec(s,b)+
            in[a].F*in[s-1].S*in[s].F*in[b-1].S);
  return ret;
}

main(){
  cin>>n;
  rep(i,n)cin>>in[i].F>>in[i].S;

  cout<<rec(0,n)<<endl;
}

Measured memory_bytes: 0
import sys
import math
import itertools

n=int(input())
l=list(map(int,input().split()))

l.sort(reverse=True)
max=l.pop(0)
for i in range(len(l)-1):
	l[i+1]=l[i]+l[i+1]

if max<l[-1]:
	print("Yes")
else :
	print("No")

Measured memory_bytes: 3060
N, Y = map(int,input().split())

if 10000*N < Y:
    print(-1,-1,-1)

else:
    A = Y//10000

    end = 0

    for i in range(A+1):
        a = Y-10000*(A-i)
        B = a//5000
        for j in range(B+1):
            b = a - 5000*(B-j)
            n = N - (A-i) - (B-j)
            if b == 1000*n:
                print(A-i,B-j,n)
                end += 1
                break
        if end == 1:
            break
        if i == A:
            print(-1,-1,-1)


Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#pragma GCC optimize("Ofast")
using namespace std;
const long long INF=20000000000;
//setprecision(2) <<

const int MOD = 1000000007;

long long max(long long a,long long b){
	if(a<b)return b;
	else return a;	
}
long long min(long long a,long long b){
	if(a>b)return b;
	else return a;	
}
long long gcd(long long a,long long b){
	if(a<b)swap(a,b);
	if(a%b==0)return b;
	else return gcd(a%b,b);
}

long long lcm(long long a,long long b){
	return a*b/gcd(a,b);
}


int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	string s;
	cin>>s;
	s[3]='8';
	cout<<s;
}

	


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

int main() {
  int n,k,ck=0;
  while(cin >> n >> k && (n!=0 || k!=0)) {
    vector<int> a(n+1);
    for(int i=0; i<n+1; i++) a[i]=0;
    while(k--) {
      int x;
      cin >> x;
      if(x!=0) a[x]=1;
      if(x==0) ck=1;
    }
    int max=0,cnt=0;
    if(ck==0) {
      for(int i=1; i<=n; i++) {
	if(a[i]) {
	  cnt++;
	  if(cnt>max) max=cnt;
	} else {
	  cnt=0;
	}
      }
    } else {
      queue<int>que;
      for(int i=1; i<=n; i++) {
	if(a[i-1]==0) que.push(i);
      }
      while(!que.empty()) {
	int z=que.front(), k=1;
	que.pop();
	cnt=0;
	int i;
	for(i=z; i<=n; i++) {
	  if(a[i]==0) k--;
	  if(k<0) break;
	  cnt++;
	  if(cnt>max) max=cnt;
	}
      }
    }  
    
    cout << max << endl;
  }
  return 0;
}


Measured memory_bytes: 1532
#include<stdio.h>
int main(){
  int n,a,sum=0;
  int c[20],v[20];
  scanf("%d",&n);
  for(int i=0;i<n;i++) scanf("%d",&v[i]);
  for(int i=0;i<n;i++) scanf("%d",&c[i]);
  for(int i=0;i<n;i++){
    a=v[i]-c[i];
    if(a>0) sum+=a;
  }
  printf("%d",sum);
  return 0;
}

Measured memory_bytes: 128
#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;
#define int long long int
#define mod 1000000007
#define string_mod 2549536629329_base_255
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define all(v) v.begin(), v.end()
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int power(int x, unsigned int y, int p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res % p;
}
void solve()
{
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n;i++){
        cin >> a[i];
    }
   
    sort(a, a + n);
    if (n == 2)
    {
        cout << a[1] << endl;
        return;
    }
    int ans = a[n-1];
    int f = n - 2;
    for (int i = n - 3; i >= 0;){
        ans += a[f];
        i--;
        if(i>=0){
            i--;
            ans += a[f];
            f--;
        }
    }
    cout << ans << endl;
}
int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int tc;
    tc = 1;
    //cin >> tc;
    while (tc--)
    {
        solve();
    }

    return 0;
}


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

namespace atCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var count = int.Parse(Console.ReadLine());
            var nums = Console.ReadLine().Split().Select(_ => int.Parse(_)).ToArray();

            int hit = 0;
            for(int n=2; n<nums.Length;n++)
            {
                int[] nums2 = new int[3] {
                   nums[n],nums[n-1],nums[n-2]
               };
                Array.Sort(nums2);
                if (nums2[1] == nums[n - 1])
                    hit++;
            }

            Console.WriteLine(hit);
        }

    }
}

Measured memory_bytes: 13396
#include <iostream>
#include <vector>

using namespace std;

const int MOD = 1000000007;

int main(){
    int N; cin >> N;
    vector<int> last(200001, -1);
    vector<int> next(N, -1);
    for(int i=0;i<N;i++){
        int c; cin >> c;
        if(last[c] != -1) next[last[c]] = i;
        last[c] = i;
    }
    vector<long long> dp(N, 0);
    dp[0] = 1;
    for(int i=0;i<N;i++){
        dp[i+1] = (dp[i+1] + dp[i]) % MOD;
        if(next[i] != -1 && next[i] != i+1){
            dp[next[i]] = (dp[next[i]] + dp[i]) % MOD;
        }
    }
    cout << dp.back() << endl;
}

Measured memory_bytes: 3328
n = int(input())
a = list(map(int, input().split()))
for i in range(n):
    if a[i] % 4 == 0:
        a[i] = 2
    elif a[i] % 2 == 0:
        a[i] = 1
    else:
        a[i] = 0

two = a.count(2)
one = a.count(1)
zero = a.count(0)
if two >= n // 2:
    print("Yes")
else:
    if n - two * 2 == one:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
ll inf = LLONG_MAX;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
  ll n, m;
  cin >> n >> m;
  ll ms = 1900 * m + 100 * (n - m);
  cout << ms * pow(2, m) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define c(n) cin>>n
#define c2(n,m) cin>>n>>m
#define c3(n,m,k) cin>>n>>m>>k
#define c4(n,m,k,l) cin>>n>>m>>k>>l
#define co(n) cout<<n<<endl
using namespace std;

int main(){
  long a,b=2,c=0,d=0,e,n,m=0,x;
  c(n);
  a=n;
  rep(i,0,9){
    e=pow(10,9-i);
    c+=a/e;
    a=a%e;
  }
  c+=n%10;
  if(n%c==0) co("Yes");
  else co("No");
  
  return 0;
}

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

int main(){
    int x,n,a,b,judge1=1,judge2=1;
    cin>>x>>n;
    if(n==0){
        cout<<x<<endl;
        return 0;
    }
    vector<int> p(n);
    for(int i=0;i<n;i++){
      cin>>p[i];
    }
    for(int i=0;i<101;i++){
        a=x-i;
        b=x+i;
        judge1=1;
        judge2=1;
        for(int j=0;j<n;j++){
            if(a==p[j]){
                judge1=0;
            }
            if(b==p[j]){
                judge2=0;
            }
        }
        if(judge1==1){
            cout<<a<<endl;
            return 0;
        }
        if(judge2==1){
            cout<<b<<endl;
            return 0;
        }
    }
}

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

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

Measured memory_bytes: 256
D = int(input())
C = list(map(int, input().split()))
S = [list(map(int, input().split())) for _ in range(D)]

import copy
MAX_SCORE = -float('inf')
MAX_ANS = -1
for K in range(26):
    v = 0
    ans = [0]*D
    L = [0]*26
    for i in range(1, D+1):
        max_score = -float('inf')
        max_idx = 0
        for j in range(26):
            temp = v
            temp += S[i-1][j]
            L_ = copy.copy(L)
            L_[j] = i
            for k in range(26):
                for l in range(i, min(i+K+1, D+1)):
                    temp -= C[k]*(l-L_[k])
            if temp >= max_score:
                max_score = temp
                max_idx = j
        v += S[i-1][max_idx]
        L[max_idx] = i
        ans[i-1] = max_idx+1
    if v >= MAX_SCORE:
        MAX_SCORE = v
        MAX_ANS = ans
print(*MAX_ANS, sep='\n')


Measured memory_bytes: 76924
import random

N = int(input())
A = list(map(int, input().split()))

ch = A[0]
cnt = 1
R = 0
for i in range(1, N):
    
    if ch != A[i]:
        R += cnt // 2
        cnt = 1
        ch = A[i]
    else:
        cnt += 1

R += cnt // 2

print(R)



Measured memory_bytes: 3696
H, W, K = map(int,input().split())
S = [list(map(int,input())) for _ in range(H)]
ans = float("inf")
for i in range(1<<(H - 1)):
    data = [S[0][0:]]
    for j in range(H - 1):
        if (i >> j) & 1:
            data.append([0] * W)
        for k in range(W):
            data[-1][k] += S[j + 1][k]
    if any([any([x > K for x in y]) for y in data]):
        continue
    cnt = len(data) - 1
    judge = [0] * len(data)
    for j in range(W):
        if any([judge[x] + data[x][j] > K for x in range(len(data))]):
            judge = [0] * len(data)
            cnt += 1
        judge = [judge[x] + data[x][j] for x in range(len(data))]
    ans = min(ans, cnt)
print(ans)

Measured memory_bytes: 52060
#include <iostream>
#include <cstdio>
#include <cstring>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)

const int INF = 1001001001;

int N;
int map[12][12];
bool used[12][12];

int reverse(int x, int y){
    map[y][x] = !map[y][x];
    map[y][x-1] = !map[y][x-1];
    map[y-1][x] = !map[y-1][x];
    map[y][x+1] = !map[y][x+1];
    map[y+1][x] = !map[y+1][x];
}

int main(){
    scanf("%d", &N);

    REP(_, N){
        FOR(i, 1, 11){
            FOR(j, 1, 11){
                scanf("%d", &map[i][j]);
            }
        }

        REP(state, 1<<10){
            memset(used, 0, sizeof(used));

            FOR(i, 1, 11){
                if(state >> (i-1) & 1){
                    used[1][i] = true;
                    reverse(i, 1);
                }
            }

            FOR(i, 2, 11){
                FOR(j, 1, 11){
                    if(map[i-1][j] == 1){
                        used[i][j] = true;
                        reverse(j, i);
                    }
                }
            }

            bool f = false;
            FOR(i, 1, 11){
                f |= map[10][i];
            }

            if(f){
                FOR(i, 1, 11){
                    FOR(j, 1, 11){
                        if(used[i][j]){reverse(j, i);}
                    }
                }
                continue;
            }

            FOR(i, 1, 11){
                FOR(j, 1, 11){
                    printf("%d", used[i][j]);
                    if(j < 10){putchar(' ');}
                    else{puts("");}
                }
            } 
        }
    }
}

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

int n, m, a[4];
int ans[4] = {1, 4, 7, 9};
int main()
{
	for (int i = 0; i < 4; i++)
		cin >> a[i];
	sort(a, a + 4);
	for (int i = 0; i < 4; i++)
	{
		if (a[i] != ans[i])
		{
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
}


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

 
const int INF = (int) 1e9;

struct point {
	int x;
    int y;
	point() : x(0), y(0) {}
};
 
struct fenwick_tree {
	int n;
	unordered_map<int, int> F;
 
    fenwick_tree() : n(INF) {
        F.rehash((int) 2.5e5);
    }
	void upd(int i, int x) {
		for (; i < n; i |= i + 1)
			F[i] = max(F[i], x);
	} 
	int get(int i) {
		int res = 0;
		for (; i >= 0; i &= i + 1, --i)
			res = max(res, F[i]);
		return res;
	}
};
 
 
bool cmp(point a, point b) {
    return make_pair(a.x, a.y) < make_pair(b.x, b.y); 
}
 
 
int main() {
#ifdef NICK
	freopen("input.txt", "r", stdin);
#else

#endif
    point start, finish;
    int n;
    cin >> start.x >> start.y;
    cin >> finish.x >> finish.y;
    cin >> n;
    point p[n];
    for (int i = 0; i < n; i++) {
        cin >> p[i].x >> p[i].y;
    }
    if (start.x > finish.x)
        swap(start, finish);
    if (start.y > finish.y) {
        finish.y = 2 * start.y - finish.y;
        for (int i = 0; i < n; i++) {
            p[i].y = 2 * start.y - p[i].y;
        }
    }
    vector<point> a;
    for (int i = 0; i < n; i++) {
        if (start.x <= p[i].x && p[i].x <= finish.x && start.y <= p[i].y && p[i].y <= finish.y)
            a.emplace_back(p[i]);
    }
    fenwick_tree dp;
    sort(a.begin(), a.end(), cmp);
    for (int i = 0; i < (int)a.size(); ++i)
        dp.upd(a[i].y, dp.get(a[i].y) + 1);
    int cur = dp.get(INF);
    long double ans = 0;
    if (cur != min(finish.y - start.y, finish.x - start.x) + 1)
        ans = 100.0 * (finish.y + finish.x - start.y - start.x) - 20.0 * cur + 5 * M_PI * cur;
    else
        ans = 100.0 * (finish.y + finish.x - start.x - start.y) - 20.0 * cur + 5 * M_PI * (cur - 1) + 10 * M_PI;
    cout << fixed << setprecision(13) << ans << "\n";
	return 0;
}


Measured memory_bytes: 70776
from collections import defaultdict
dpa = defaultdict(lambda: 0)
n = int(input())
a = list(map(int, input().split()))
q = int(input())

sum = 0
for i in range(n):
	dpa[a[i]]+=1
	sum+=a[i]

for j in range(q):
	bc = list(map(int, input().split()))
	b = bc[0]
	c = bc[1]
	if(dpa[b] != 0):
		sum = sum+(c-b)*dpa[b]
		print(sum)
		dpa[c] += dpa[b]
		dpa[b] = 0
		#print(dpa)
	else:
		print(sum)

Measured memory_bytes: 88500
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;  
#define pb push_back
#define F first
#define S second
#define ppp pair<ll,pair<ll,ll>>
#define pp pair<ll,ll>
#define all(x) (x).begin(),(x).end()
#define pi 3.14159265358
#define MOD 998244353

unordered_map<ll,ll> mp;
vector<ll> v;

void fn(ll num,ll sz)
{
	if(sz==11)
		return;

	if(mp[num]==1)
		return;
	v.pb(num);
	mp[num]=1;

	ll last=num%(10LL);

	if(last!=9)
	fn(num*10LL+last+1,sz+1);
	fn(num*10LL+last,sz+1);
	if(last!=0)
		fn(num*10LL+last-1,sz+1);
}



int main()
{

  //  #ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
  
    
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);

    

     ll k;
     cin>>k;


     for(ll i=1;i<=9;i++)
     	fn(i,1);

     sort(v.begin(),v.end());
     cout<<v[k-1]<<endl;

     // for(ll i=0;i<200;i++)
     // 	cout<<v[i]<<" ";
}



Measured memory_bytes: 10044
import math
while True:
    n = int(input())
    d = 0
    if n == 0:
        break
    else:
        li = list(map(int,input().split()))
        ave = sum(li)/len(li)
        for i in range(len(li)):
            a = li[i] - ave
            d += a**2
        stv = math.sqrt((d)/len(li))
        print(stv)


Measured memory_bytes: 5700
#include <utility>
#include <vector>
#include <iostream>
#include <algorithm>
#include <set>
#define REP(i,n) for(int i=0;i<n;i++)
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
using namespace std;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

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

    cout << N*N*N <<endl;
    return 0;
}

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

int main() {
  int N,P,time_sum;
  cin>>N;
  vector<int> time(N);
  for(int i=0;i<N;i++){
    cin>>time.at(i);
  }
  cin>>P;
  vector<vector<int>> drink(P,vector<int>(2));
  for(int i=0;i<P;i++){
    cin>>drink.at(i).at(0)>>drink.at(i).at(1);
  }
  time_sum=0;
  for(int i=0;i<P;i++){
    int a;
    a=time.at(drink.at(i).at(0)-1);
    time.at(drink.at(i).at(0)-1)=drink.at(i).at(1);
    for(int j=0;j<N;j++){
      time_sum+=time.at(j);
    }
    cout<<time_sum<<endl;
    time.at(drink.at(i).at(0)-1)=a;
    time_sum=0;
  }
}

Measured memory_bytes: 256
from itertools import combinations as combo

def check_tri(c):
    c = list(c)
    if len(set(c)) != 3:
        return False
    else:
        c.sort()
        if c[0] + c[1] > c[2]:  return True
        else:   return False



n = int(input())
ls = list(map(int, input().split()))
tri = list(combo(ls, 3))

ans = 0

for i in tri:
    a = check_tri(i)
    if a:
        ans += 1

print(ans)




Measured memory_bytes: 20452
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<cctype>
using namespace std;

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int s = a * b;
	s = max(s, c * d);
	cout << s << endl;
}

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

void trace(int A[], int N) {
    for (int i = 0; i < N; i++){
        if (i > 0){
            cout << " ";
        }
        cout << A[i];
    }
    cout << endl;
}

void insertionSort(int A[], int N) {
    trace(A, N);
    for (int i=1; i < N; i++) {
        int v = A[i];
        int j = i - 1;
        while( j >= 0 && A[j] > v){
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = v;
        trace(A, N);
    }
}

int main(){
    int N;
    cin >> N;
    int A[N];
    for (int i=0; i < N; i++) {
        cin >> A[i]; 
    }
    insertionSort(A, N);
    return 0;
}



Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] arr = new int[n];
        int minPoint = 0;
        for(int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
            if(arr[i] == 1) {
                minPoint = i;
            }
        }
//        int left = minPoint;
//        int right = n - left - 1;
//        int ans = 0;
//        ans += (left / (k-1));
//        ans += right / (k-1);
//        ans += (left%(k-1)==0 ? 0 : 1);
//        ans += (right%(k-1) == 0 ? 0 : 1);
        int a = n-1;
        int b = k-1;
        System.out.println(a/b+(a%b==0?0:1));
    }
}

Measured memory_bytes: 48196
using System;

public class hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        var on = n;
        Console.Write("{0}:", n);
        var te = 1;
        while (true)
        {
            if (n % 2 == 0) { Console.Write(" 2"); n /= 2; te *= 2; }
            else break;
        }
        if (n == 1) goto end;
        var sq = Math.Max((int)Math.Sqrt(n), 3);
        for (int i = 3; i <= sq+1; i += 2)
            while (true)
            {
                if (n % i == 0)
                {
                    Console.Write(" {0}", i);
                    n /= i; te *= i;
                    if (te == on) goto end;
                }
                else break;
            }
        Console.Write(" {0}", n);
        end:;
        Console.WriteLine();
    }
}

Measured memory_bytes: 9220
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;


int main() {
    int64_t N, ans = 1;
    cin >> N;
    vector<int64_t> A(3);
    for (int i = 0; i < N; i++) {
        int64_t a;
        cin >> a;
        int64_t count = 0;
        bool T = true;
        for (int j = 0; j < 3; j++) {
            if (A.at(j) == a) {
                count++;
                if (T) {
                    A.at(j)++;
                    T = false;
                }
            }
        }
        ans = ans * count % 1000000007;
    }
    cout << ans << endl;
}


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

typedef long long LL;
typedef pair<int, int> II;

const int MAXN = (int) 2e5 + 10;
int n, nxt[MAXN][26], d[MAXN];
char S[MAXN];

int main() {
	scanf("%s", S + 1);
	n = strlen(S + 1);

	for (int i = 0; i < 26; ++i) nxt[n + 1][i] = n + 1;
	for (int i = n; i >= 1; --i) {
		for (int j = 0; j < 26; ++j) nxt[i][j] = nxt[i + 1][j];
		nxt[i][S[i] - 'a'] = i;
	}
	for (int i = n; i >= 1; --i) {
		int flag = 0;
		for (int j = 0; j < 26; ++j)
			if (nxt[i + 1][j] == n + 1) flag = 1;
		if (flag == 1) d[i] = 1; else {
			d[i] = n + 1;
			for (int j = 0; j < 26; ++j) {
				int p = nxt[i + 1][j]; if (p == n + 1) continue;
				d[i] = min(d[i], d[p] + 1);
			}
		}
	}

	int len = n + 1;
	for (int i = 0; i < 26; ++i) len = min(len, d[nxt[1][i]]);

	int p = 0;
	for (int i = 1; i <= len; ++i) {
		for (int j = 0; j < 26; ++j)
			if (d[nxt[p + 1][j]] == len - i + 1) {
				p = nxt[p + 1][j];
				putchar(j + 'a');
				break;
			}
	}
	for (int i = 0; i < 26; ++i)
		if (nxt[p + 1][i] == n + 1) {
			putchar(i + 'a');
			break;
		}
	puts("");
	return 0;
}

Measured memory_bytes: 21504
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
int main() {
    /*
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif  */
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);  
    int n,m;
    cin>>n>>m;
    vector<vector<int>> v(n);
    int indeg[n]={0};
    vector<vector<int>> v1(n);
    for(int i=0;i<n-1+m;i++){
        int a,b; cin>>a>>b; a--; b--;
        v[a].push_back(b);
        v1[b].push_back(a);
        indeg[b]++;
    }  
    queue<int> q;
    for(int i=0;i<n;i++){
       // cout<<indeg[i]<<" ";
        if(indeg[i]==0) q.push(i);
    }
    /*
    for(int i=0;i<n;i++){
        cout<<i+1<<"-> ";
        for(auto x : v[i]) cout<<x+1<<" ";
            cout<<"\n";
    }*/
    int p[n]={0};
    while(q.size()>0){
        int ci=q.front();
        q.pop();
        for(auto x: v[ci]){
            indeg[x]--;
            if(indeg[x]==0) q.push(x);
            p[x]=ci+1;
        }
    }
    /*
    for(auto x : top) cout<<x+1<<" ";
        cout<<"\n";*/
    /*int l[n];
    for(int i=0;i<n;i++){
        l[top[i]]=i;
    }
    int p[n];
    p[top[0]]=-1;
    for(int i=1;i<n;i++){
        int z=-1; int k=-1;
        for(auto x : v1[i]){
            if(l[x] > z){
                z=l[x];
                k=x;
            }
        }
        p[i]=k;
    }*/
    for(int i=0;i<n;i++){
        cout<<p[i]<<"\n";
    }  
}

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

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

    char grid[50][50];
    int count = 0;
    for (int i = 0; i < h; i++)
        for (int j = 0; j < w; j++) {
            cin >> grid[i][j];
            if (grid[i][j] == '.') count++;
        }

    int visit[50][50];
    int counter = 0;
    for (int i = 0; i < h; i++)
        for (int j = 0; j < w; j++)
            visit[i][j] = -1;

    int dx[4] = {1, -1, 0, 0};
    int dy[4] = {0, 0, -1, 1};
    
    queue<pair<int, int> > q;
    q.push(make_pair(0,0));
    visit[0][0] = 1;
    while (!q.empty()) {
        pair<int,int> p = q.front();
        q.pop();
        int x = p.first;
        int y = p.second;
        for (int i = 0; i < 4; i++) {
            int xx = x + dx[i];
            int yy = y + dy[i];
            if (xx < 0 || yy < 0 || xx >= h || yy >= w) continue;
            if (visit[xx][yy] == -1 && grid[xx][yy] == '.') {
                visit[xx][yy] = visit[x][y] + 1;
                q.push(make_pair(xx,yy));
            }
        }
    }
    if (visit[h - 1][w - 1] == -1) {
        cout << -1 << endl;
    } else {
        cout << count - visit[h - 1][w - 1] << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include <vector>
#include <set>
using namespace std;
int main(){
	string a,b,c;
	cin>>a>>b>>c;
	a[0]-=32;
	b[0]-=32;
	c[0]-=32;
	cout<< a[0]
	<<b[0]<<c[0];
}


Measured memory_bytes: 256
k, s = gets.strip.split.map(&:to_i)
cnt = 0

(0..k).each do |x|
  (0..k).each do |y|
    # 3重ループはTLE
    # zはs-x-yで求められる
    z = s - x - y
    cnt +=1 if (0..k).include?(z)
  end
end
puts cnt

Measured memory_bytes: 1788
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
#define ld long double

#define all(X) (X).begin(), (X).end()
#define reset(X) memset(X, 0, sizeof(X))
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define endl '\n'
#define ff first
#define ss second


using namespace __gnu_pbds;
using namespace std;
const int mod=1e9+7;
 // const int mod=998244353;
 // const int mod=1e9+9;
const int INF=4e18+10;
// const int INF=4e18+10;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define read(n) int n; cin>>n;
#define readv(x, n) vector<int> x(n); for(auto &i:x) cin>>i;


typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

template<typename T1,typename T2>
void set_min(T1& a, T2 b)
{
    a=min(a, (T1)b);
}


int multiply(int a, int b, int in_mod){return (a*b)%in_mod;}
int mult_identity(int a){return 1;}


auto power(auto a, int b, int in_mod)
{
    auto prod=mult_identity(a);
    auto mult=a%in_mod;
    while(b!=0)
    {
        if(b%2)
        {
            prod=multiply(prod,mult, in_mod);

        }
        mult=multiply(mult, mult,in_mod);
        b/=2;
    }
    return prod;
}
int mod_inv(int q, int in_mod)
{

    return power(q, in_mod-2,in_mod);
}

int gcd(int a,int b){
    if(b==0) return a;
    return gcd(b,a%b);
}

int fact(int n,int in_mod){
    int f=1;
    for(int i=1;i<=n;i++) f=(f*i)%in_mod;
    return f;
}
int ncr(int n,int r,int in_mod){
    return (((fact(n,in_mod)*mod_inv(fact(r,in_mod),in_mod))%in_mod)*mod_inv(fact(n-r,in_mod),in_mod))%in_mod;
}

void solve()
{

int x,y;
cin>>x>>y;
int b=(y-2*x)/2;
int a=x-b;
if(a>=0&&b>=0&&a+b==x&&2*a+4*b==y){
    cout<<"Yes"<<endl;
}
else{
    cout<<"No"<<endl;
}
}

signed main()

{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cout<<fixed<<setprecision(10);
    #ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
        freopen ("INPUT.txt" , "r" , stdin);
        freopen ("OUTPUT.txt" , "w" , stdout);
    }
    #endif
    auto clk=clock();
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    // -------------------------------------Code starts here---------------------------------------------------------------------

    int t=1;
    //cin>>t;
    for(int test=1;test<=t;test++)
    {
        // cout<<"Case #"<<test<<": ";
        // cout<<endl;
        solve();
        // cout<<endl;

    }

    // -------------------------------------Code ends here------------------------------------------------------------------


    clk = clock() - clk;
    cerr << fixed << setprecision(6) << "Time: " << ((long double)clk)/CLOCKS_PER_SEC << "\n";
    return 0;
}

Measured memory_bytes: 3820
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

static int check_int(double x);

int main(){
  int i, j, k;
  int N, D;
  int count = 0;

  scanf("%d%d",&N, &D);

  int X[N][D];

  for(i=0;i<N;i++) {
    for(j=0;j<D;j++) {
      scanf("%d",&X[i][j]);
    }
  }

  double z;

  for(i=0;i<N;i++) {
    for(j=i+1;j<N;j++){
      z = 0;
      for(k=0;k<D;k++) {
        z += pow(X[i][k]-X[j][k] ,2);
      }
      if(check_int(sqrt(z)) == 1) {count ++;}
    }
  }

  printf("%d", count);

  return 0;
}


static int check_int(double x) {
  if (ceil(x) != floor(x)) {
    return 0;
  } else {
    return 1;
  }
}


Measured memory_bytes: 128
class Integer
    def div_cnt
        (1..self).each_with_object([]) {|i, a| a << i if self % i == 0}.size
    end
    
    def div_8_cnt
        (1..self).inject(0) {|sum, i|
            sum = i.div_cnt == 8 && i.odd? ? sum + 1 : sum
        }
    end
end

N = gets.to_i
puts N.div_8_cnt

Measured memory_bytes: 1788
def main():
    n = int(input())
    t, a = map(int, input().split())
    h = list(map(int, input().split()))
    # s = input()

    mini = 10**10
    ans = 0
    for i, x in enumerate(h):
        c = t - x * 0.006
        if abs(a - c) < mini:
            mini = abs(a - c)
            ans = i+1

    print(ans)


if __name__ == '__main__':
    main()


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

//#define Fast ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
typedef vector<int>Vl;
typedef pair<int,int>PII;
typedef vector<PII>Vll;
typedef vector<pair<int,pair<int,int> > >Vlll;
typedef priority_queue<int>PQL;
typedef map<int,int>M;
#define S second
#define F first
#define mp make_pair
#define ms(x,y) memset(x,y,sizeof(x))
#define pb push_back
#define sl(n) cin>>n
#define pl(n) cout<<n
const int mod=1e9+7;
const int sze=1e5+2;
//const int inf=1e19;
void solve(){
  int h,a;
  sl(h);sl(a);
   int total=ceil((1.0*h)/a);
   cout<<total<<endl;
}

signed main(){
   int test=1;
   //sl(test);
   while(test--){
      solve();

   }
  return 0;
}


Measured memory_bytes: 256
N=int(input())
lst=[]
for i in range(N):
  text=input()
  lst.append([sorted(text)])
lst=sorted(lst)      
count=0
i=0
while(i<N-1):
  j=1
  while(lst[i]==lst[i+j]):
    count=count+j
    j=j+1
    if (i+j >= N):
      break
  i=i+j
print(count)

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

const int NOTV = 0;
const int VIST = 1;
const int NMAX = 100;
const int VMAX = 2000;
const int NILL = -1;
const int INF = 1 << 21;
int a[NMAX][NMAX];  //??£??\??????
int n;
//priority_queue <greater<int>> pq;

void dijkstra(){

	int p[NMAX];
	int d[NMAX];
	int vst[NMAX];
	int minc;
	for (int i = 0; i < n; i++) {
		vst[i] = NOTV;
		d[i] = INF;
	}
	d[0] = 0;
	p[0] = -1;
	while (1) {
		minc = INF;
		int u;
		for (int i = 0; i < n; i++) {
			if (minc > d[i] && vst[i]==NOTV) {
				u = i;
				minc = d[i];
			}
		}
		if (minc == INF) break;
		vst[u] = VIST;
		for (int v = 0; v < n; v++) {
			if (vst[v] == NOTV && a[u][v] != INF) {
				if (d[u] + a[u][v] < d[v]) {
					d[v] = d[u] + a[u][v];
					vst[v] = NOTV;
				}
			}

		}
	}
	for (int i = 0; i < n; i++) {
		cout << i << ' ' << ((d[i] == INF) ? -1 : d[i]) << endl;
	}
}

int main() {
	cin >> n;
	int um;
	int uo;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			a[i][j] = INF;
		}
	}
	for (int i = 0; i < n; i++) {
		cin >> um;
		int k;
		cin >> k;
		for (int j = 0; j < k; j++) {
			cin >> uo;
			cin >> a[um][uo];
		}
		
	}
	
	dijkstra();
	return 0;
}

Measured memory_bytes: 3136
#include<stdio.h>

int main(void){
	int a, b, c, d;
	scanf("%d", &a);
	scanf("%d", &b);
	scanf("%d", &c);
	scanf("%d", &d);
	
	while(1){
	
		c -= b;
		
		if(c <= 0){
			puts("Yes");
			break;
		}
		
		a -= d;
		
		if(a <= 0){
			puts("No");
			break;
		}
	}
	
	return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <queue>
#define INF 200000
using namespace std;
typedef pair<int,int> P;
P a;
priority_queue< P,vector<P> ,greater<P> > pq;
int map[101][101];
bool decided[101];
int sum,n;
int node,count;
void check(){
	node=1;
	decided[node]=true;
	count=n-1;
	while(1){
		for(int i=1;i<=n;i++){
			if(map[node][i]!=-1&&!decided[i]){
				a=make_pair(map[node][i],i);
				pq.push(a);
			}
		}
		while(decided[pq.top().second])pq.pop();
		sum+=pq.top().first;
		node=pq.top().second;
		decided[node]=true;
		count--;
		if(count==0)break;
		pq.pop();
	}
}

int main(){
	cin >>n;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			cin >> map[i][j];
		}
	}
	sum=0;
	check();
	cout << sum<<endl;
}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double

int main(){
    string S;
    cin >> S;
    ll sum = 0;
    for (int i = 0; i < (int)S.size(); i++) {
        sum += (int)(S[i]-'0');
    }
    if (sum%9 == 0) cout << "Yes\n";
    else cout << "No\n";
	return 0;
}

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

int main() {
  string S, T;
  int ans =0;
  cin >> S >> T;
  
  for(int i = 0; i<S.size(); i++){
    if(S.at(i)!=T.at(i)){
      ans ++;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3912
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <vector>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;

int main() {
    int n, x, c = 0;

    while(1) {
        cin >> n >> x;
        if(n == 0 && x == 0)
            break;
        c = 0;
        rep(i, 1, n + 1) rep(j, i + 1, n + 1)
            rep(k, j + 1, n + 1) if(i + j + k == x) c++;
        cout << c << endl;
    }

    return 0;
}


Measured memory_bytes: 3092
#include<iostream>
#include<iomanip>
#include<stdio.h>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<string>
#include<algorithm>
#include<functional>
#include<math.h>
#include<unordered_set>
using namespace std;

const int MAX = 100;
int main() {
	int N;
	int D, X;
	int ans = 0;

	cin >> N >> D >> X;
	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;
		ans += D / a;
		ans += D % a ? 1 : 0;
	}

	cout << ans + X << endl;

	return 0;
}

Measured memory_bytes: 256
l, r = gets.chomp.split(" ").map(&:to_i)

if r - l >= 2019
    puts 0
elsif r%2019 <= l%2019
    puts 0
else
    min = 2019
    (l..r-1).each do |i|
        (i+1..r).each do |j|
            md = ((i%2019) * (j%2019)) % 2019
            min = min <= md ? min : md
        end
    end
    puts min
end

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

char a, b;
int x, y;

int main() {
  cin >> a >> b;
  x = a - 'A';
  y = b - 'A';
  if(x > y)
    cout << ">" << endl;
  else if(x < y)
    cout << "<" << endl;
  else
    cout << "=" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
    int i,o,t,j,l,s,z,q;
    cin>>i>>o>>t>>j>>l>>s>>z;
    if (i>0&&j>0&&l>0)q=2*((i-1)/2+(j-1)/2+(l-1)/2)+o+3;
    else q=0;
	cout<<max(2*(i/2+j/2+l/2)+o,q);
}

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

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

from collections import defaultdict
d = defaultdict(int)
for i in range(1,n):
    num=i+1
    for div in fact(num):
        d[div[0]]+=div[1]

ans=1
for a in d.values():
    ans*=(a+1)
    ans%=(10**9+7)
ans%=(10**9+7)
print(ans)

Measured memory_bytes: 43756
//
//  main.cpp
//  beginner3
//
//  Created by zer0 on 2020/03/22.
//  Copyright © 2020 zer0. All rights reserved.
//

#include <iostream>

int main(int argc, const char * argv[]) {
    int L;
    std::cin >> L;
    
    double l = (double)L / 3.0;
    
    double a = l * l * l;
    
    // insert code here...
    std::cout << std::to_string(a);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
using Double = long double;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define ALL(v) (v).begin(), (v).end()
#define PUTS(x) cout << (x) << endl;
#define PB push_back
int main() {
    int n;
    cin >> n;
    auto v = vector<Double>(0);
    v.PB(0);
    Double sum = 0;
    rep(i, n) {
        Double a;
        cin >> a;
        sum += a;
        v.PB(sum);
    }
    auto half = sum / 2;
    auto itr = lower_bound(ALL(v), half);
    auto b = *itr;
    itr--;
    auto a = *itr;
    auto x = (Int)((b - half > half - a) ? a : sum - b);
    auto y = (Int)(sum - x);
    PUTS(abs(x - y));
}

Measured memory_bytes: 6512
/*input
9
*/
#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long
#define mod 1000000007
#define inf 1000000000000000001
#define all(c) c.begin(),c.end()
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define sz(a) int((a).size())
#define pb push_back
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())     
#define rep(i,j,n) for(ll i=j;i<n;i++)
#define mp make_pair
#define N 998244353
#define PI acos(-1.0)
//if (s.find('R') != std::string::npos)
//s.replace(s.find("10"), sizeof("10") - 1, "");
using namespace std;
bool comp(pair<string,ll>a,pair<string,ll>b){
  if(a.first==b.first) return a.second>b.second;
  return a.first<b.first;
}
int main()
{
  // added the two lines below 
  ios_base::sync_with_stdio (false); 
  cin.tie(NULL);
  cout.tie(0);

  char a;
  cin>>a;
  map<char,char>m;
  m['A']='T';
  m['T']='A';
  m['C']='G';
  m['G']='C';
  cout<<m[a];
}

Measured memory_bytes: 256
#include<cstdio>

int main(){
	unsigned N;
	scanf("%u\n", &N);
	unsigned long long a=0, b=0, c=0, d=0, e=0;
	for (unsigned i = 0; i < N; ++i)	{
		char tmp[15];
		scanf("%s", tmp);
		if(tmp[0] == 'M') a++;
		if(tmp[0] == 'A') b++;
		if(tmp[0] == 'R') c++;
		if(tmp[0] == 'C') d++;
		if(tmp[0] == 'H') e++;
	}
	printf("%llu\n", a*(b*(c+d+e)+c*(d+e)+d*e)+b*(c*(d+e)+d*e)+c*d*e);
	return 0;
}

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

public class Main{

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Integer[] a = new Integer[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);
        Integer[] c = new Integer[n];
        for (int i = 0; i < n; i++) {
            c[i] = a[n - 1 - i];
        }

        long ans = 0;
        int l = a[0];
        int r = a[n - 1];
        ans += r - l;
        int aa = 1;
        int cc = 1;
        for (int i = 1; i < n - 1; i++) {
            int anum = a[aa];
            int cnum = c[cc];
            int aMax = Math.max(Math.abs(anum - l), Math.abs(anum - r));
            int cMax = Math.max(Math.abs(cnum - l), Math.abs(cnum - r));
            if (aMax > cMax) {
              int b = a[aa];
              if (Math.abs(l - b) > Math.abs(r - b)) {
                  ans += Math.abs(l - b);
                  l = b;
              } else {
                  ans += Math.abs(r - b);
                  r = b;
              }
              aa++;
            } else {
              int b = c[cc];
              if (Math.abs(l - b) > Math.abs(r - b)) {
                  ans += Math.abs(l - b);
                  l = b;
              } else {
                  ans += Math.abs(r - b);
                  r = b;
              }
              cc++;
            }

//            if (i % 2 == 1) {
//                int b = a[aa];
//                if (Math.abs(l - b) > Math.abs(r - b)) {
//                    ans += Math.abs(l - b);
//                    l = b;
//                } else {
//                    ans += Math.abs(r - b);
//                    r = b;
//                }
//                aa++;
//            } else {
//                int b = c[cc];
//                if (Math.abs(l - b) > Math.abs(r - b)) {
//                    ans += Math.abs(l - b);
//                    l = b;
//                } else {
//                    ans += Math.abs(r - b);
//                    r = b;
//                }
//                cc++;
//            }
        }
        System.out.println(ans);

    }

}


Measured memory_bytes: 64160
import Control.Monad

data DayOfWeek = SUN | MON | TUE | WED | THU | FRI | SAT
  deriving (Read, Show)

main :: IO ()
main = do
  s <- readLn
  print $ solve s

solve :: DayOfWeek -> Int
solve SUN = 7
solve MON = 6
solve TUE = 5
solve WED = 4
solve THU = 3
solve FRI = 2
solve SAT = 1


Measured memory_bytes: 508
//Radhe Radhe
#include<bits/stdc++.h>
#define ll long long
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
using namespace std;

int main()
{
    fast_io
    ll i,j,n;
    cin>>n;
   ll x,ans=0,maxi=-1;
    while(n--)
        {
            cin>>x;
            maxi=max(maxi,x);
            ans+=x;
        }
    cout<<ans-(maxi/2)<<endl;

    return 0;
}





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

int main() {
  int L, R, d;
  cin >> L >> R >> d;

  int res = 0;

  for (int i = d; i <= R; i += d) {
    if (i >= L) res++;
  }

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 3632
#include<stdio.h>
int main()
{
  int a,b[10000],c,d,s,i;
  scanf("%d",&a);
  for(i=0;i<a;i++){
    scanf("%d",&b[i]);
  }
  d=a-1;
  for(i=d;i>=0;i--){
    if (i>0)printf("%d ",b[i]);
    else printf("%d",b[i]);
  }
  printf("\n");
  return 0;
}



Measured memory_bytes: 2044
#include<bits/stdc++.h>
using namespace std;
main(){
	int x1,x2,x3,x4,x5;
	cin>>x1>>x2>>x3>>x4>>x5;
	if(x1==0){
		cout<<1<<endl;
	}
	else if(x2==0){
		cout<<2<<endl;
	}
	else if(x3==0){
		cout<<3<<endl;
	}
	else if(x4==0){
		cout<<4<<endl;
	}
	else if(x5==0){
		cout<<5<<endl;
	}
}

Measured memory_bytes: 3532
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
		int hito,nissu,nokori,choko=0;
	cin>>hito>>nissu>>nokori;
	int kankaku[100];
	for(int i=0;i<hito;i++)
	{
		cin>>kankaku[i];
	}
	for(int i=0;i<hito;i++){
		if(nissu%kankaku[i]==0){
			choko=nissu/kankaku[i]+choko;
		}
		else{
			choko=nissu/kankaku[i]+1+choko;
		}
	}
	choko=choko+nokori;
	cout<<choko<<endl;
return 0;
}

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

namespace AtCoderMake.ABC173
{
    class ABC173A
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            if (n % 1000 == 0)
            {
                Console.WriteLine(0);
            }
            else
            {

                Console.WriteLine(1000 - (n % 1000));
            }
        }
    }
}


Measured memory_bytes: 27468
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    ll n;
    cin>>n;
    vector<int> v;      //factor
    int count=0;
    int ans=0;
    while((n&1)==0){
        n>>=1;
        count++;
    }
    if(count>=1){
        v.pb(count);
    }
    for(int i=3;i<=sqrt(n);i+=2){
        count=0;
        while((n%i)==0){
            n/=i;
            count++;
        }
        if(count>=1){
            v.pb(count);
        }
    }
    if(n>1){
        v.pb(1);
    }
    sort(v.begin(),v.end());
    int s=v.size();
    for(int j=0;j<s;j++){
        for(int i=1;i<=70;i++){
            v[j]-=i;
            if(v[j]>=0){
                ans+=1;
            }
            else{
                break;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3676
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)


gcdL = []
gcdR = []

N = int(input())
A = [int(x) for x in input().split()]
gcdL.append(0)
length_A = len(A)
for i in range(1,length_A):
    gcdL.append(gcd(A[i-1],gcdL[i-1]))


gcdR.append(0)
for i in range(1,length_A):
    gcdR.append(gcd(A[length_A-i],gcdR[i-1]))



list_gcd = []
for i in range(length_A):
        list_gcd.append(gcd(gcdL[i],gcdR[length_A-i-1]))

print(max(list_gcd))

Measured memory_bytes: 14056