akhauriyash/Code-Regression huggingface dataset:
import random

def down_score(d, c, last_d, score):
    sum = 0
    for i in range(26):
        sum += c[i]*(d-last_d[i])
        
    return int(score - sum)

def main():
    D = int(input())

    c = list(map(int, input().split()))

    s = [list(map(int, input().split())) for i in range(D)]

    #print(c)

    #print(s)

    last_d = [0 for i in range(26)]
    
    ans = []
    
    score = 0
    
    for i in range(D):
        max = 0
        idx = 0
        for j in range(26):
            if max < (s[i][j] + c[j] * (i-last_d[j])*(i-last_d[j]+1)/2) and c[j] != 0:
                max = s[i][j] + c[j] * (i-last_d[j])*(i-last_d[j]+1)/2
                idx = j
            elif max == (s[i][j] + c[j] * (i-last_d[j])*(i-last_d[j]+1)/2) and c[j] * (i-last_d[j])*(i-last_d[j]+1)/2 > c[idx]* (i-last_d[idx])*(i-last_d[idx]+1)/2:
                idx = j
        last_d[idx] = i+1
        
        ans.append(idx)

    for i in range(D):
        print(ans[i]+1)

if __name__ == "__main__":
    main()

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


int main() {

    ll n  ,i ;
    cin >> n ;
    vector<ll>v(n) , a(n) , b(n) ;
    for (i = 0 ; i< n ;i++) cin >> v[i] ;
    for ( i = 1 ; i<= n ;i++) {
        a[i-1] = 25000 * (i) ;
        b[n-i] = a[i-1] ;
    }

    for ( i = 0 ; i < n ;i++) {
        b[v[i]-1]+=i ;
    }
    for ( i = 0 ; i< n ;i++) cout << a[i] << " " ;
    cout << endl ;
    for (i  = 0 ; i< n; i++) cout << b[i] << ' ' ;


    return 0 ;
}


Measured memory_bytes: 1152
# ABC044C - 高橋君とカード / Tak and Cards (ARC060C)
def main():
    N, A = tuple(map(int, input().split()))
    X = tuple(map(int, input().split()))
    # dp[i][j][k] := patterns to make k with j cards from X1, X2, ..., Xi
    dp = [[[0] * (N * 50 + 1) for _ in range(N + 1)] for _ in range(N + 1)]
    dp[0][0][0] = 1
    for i in range(N):
        for j in range(N):
            for k in range(N * 50 + 1):
                if dp[i][j][k]:
                    dp[i + 1][j][k] += dp[i][j][k]
                    dp[i + 1][j + 1][k + X[i]] += dp[i][j][k]
    ans = sum(dp[N][i][i * A] for i in range(1, N + 1))
    print(ans)


if __name__ == "__main__":
    main()


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

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

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

    int n = a.back();

    vector<pair<int, int>> b(N - 1);
    for (int i = 0; i < N - 1; i++) {
        b[i] = { min(a[i], n - a[i]), a[i] };
    }
    sort(b.begin(), b.end());

    int r = b.back().second;

    cout << n << " " << r << endl;

    return 0;
}

Measured memory_bytes: 1408
import sys
input = sys.stdin.readline
#A1~Aiまでの和 O(logN)　iが与えられたとき a1~aiまでの和を計算する(O(log n))
def BIT_query(BIT,idx):
  res_sum=0
  if idx==0:
    return 0
  while idx>0:
    res_sum+=BIT[idx]
    idx-=idx&(-idx)
  return res_sum

#Ai+=x O(logN)　iとxが与えられたとき ai+=x とする (O(log n))
def BIT_update(BIT,idx,x,n):
  while idx<=n:
    BIT[idx]+=x
    idx+=idx&(-idx)
  return

N,Q=map(int, input().split())
C=list(map(int, input().split()))
LRI=[]
for i in range(Q):
  l,r=map(int,input().split())
  LRI.append((r,l,i))

LRI.sort(key=lambda x:x[0])
lastAppend =[-1]*(N+1)
#A1 ... AnのBIT(1-indexed)
BIT=[0]*(N+1)
ANS=[0]*Q
now=1
for r,l,i in LRI:
  while now<=r:
    c=C[now-1]
    #初めてその種類が登場
    if lastAppend[c]==-1:
      BIT_update(BIT,now,1,N)
    #その種類の登場が2回目　
    else:
      BIT_update(BIT,now,1,N)
      BIT_update(BIT,lastAppend[c],-1,N)
    lastAppend[c]=now                
    now+=1
  ANS[i]=BIT_query(BIT,r)-BIT_query(BIT,l-1)

for ans in ANS:
  print(ans)


Measured memory_bytes: 226272
#include<iostream>
#include<vector>
using namespace std;
int main(){
    int n,m,ans=0,l,r;
    cin>>n>>m;
    vector<int>ID(100001,0);
    for(int i=0;i<m;i++){
        cin>>l>>r;
        ID[l]++;
        ID[r+1]--;
    }
    for(int i=1;i<100001;i++)ID[i]+=ID[i-1];
    for(int i=0;i<100001;i++)if(ID[i]==m)ans++;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 640
# 区間和の計算と要素の更新が高速で必要
# l,rごとにやっていると日が暮れる→要素ごとに何回カウントされるかを考える
# 自分より左に大なもの1つ　かつ　右は0個
# 自分より右に大なもの1つ　かつ　左は0個
n = int(input())
P = list(map(int, input().split()))

# segment tree
# 1-index
# A[0]はSEG[num]に。A[n]はSEG[num+n]に
# SEG[i]の下はSEG[2i], SEG[2i+1]
# SEG[i]の上はSEG[i//2]
num = 2 ** (n.bit_length())
ele = 0
SEG = [ele] * (2 * num)


def func(a, b):
    return a + b


def update(idx, x):
    idx += num
    SEG[idx] += x
    idx //= 2
    while idx > 0:
        SEG[idx] = func(SEG[2 * idx], SEG[2 * idx + 1])
        idx //= 2


# [a,b)で定義
def query(a, b):
    a += num
    b += num - 1
    res = ele
    while b - a > 0:
        if a & 1 == 1:
            res = func(res, SEG[a])
            a += 1
        if b & 1 == 0:
            res = func(res, SEG[b])
            b -= 1
        a //= 2
        b //= 2
    if b == a:
        res = func(res, SEG[b])
    return res


def nibutan1(a):
    ok1 = a
    ng = n
    while ng - ok1 > 1:
        mid = (ng + ok1) // 2
        if query(a, mid + 1) == 0:
            ok1 = mid
        else:
            ng = mid
    if ok1 == n - 1:
        return n - 1, n - 1
    ok2 = 0
    ok2 += ok1
    ng = n
    while ng - ok2 > 1:
        mid = (ng + ok2) // 2
        if query(a, mid + 1) == 1:
            ok2 = mid
        else:
            ng = mid
    return ok1, ok2


def nibutan2(a):
    ok1 = a
    ng = -1
    while ok1 - ng > 1:
        mid = (ng + ok1) // 2
        if query(mid, a + 1) == 0:
            ok1 = mid
        else:
            ng = mid
    if ok1 == 0:
        return 0, 0
    ok2 = 0
    ok2 += ok1
    ng = -1
    while ok2 - ng > 1:
        mid = (ng + ok2) // 2
        if query(mid, a + 1) == 1:
            ok2 = mid
        else:
            ng = mid

    return ok1, ok2


A = [None] * n
for idx, v in enumerate(P):
    A[idx] = (v, idx)
A.sort(reverse=True)
ans = 0
for v, idx in A:
    migi1, migi2 = nibutan1(idx)
    hidari1, hidari2 = nibutan2(idx)
    # print("num", v, "idx", idx)
    # print(hidari1, hidari2, migi1, migi2)
    if migi1 == n - 1 and hidari1 == 0:
        pass
    elif migi1 == n - 1:
        ans += v * (migi1 - idx + 1) * (hidari1 - hidari2)
    elif hidari1 == 0:
        ans += v * (idx - hidari1 + 1) * (migi2 - migi1)
    else:
        ans += v * (migi1 - idx + 1) * (hidari1 - hidari2)
        ans += v * (idx - hidari1 + 1) * (migi2 - migi1)
    # print("ans", ans)
    update(idx, 1)
print(ans)


Measured memory_bytes: 90012
"""
import decimal
import math
decimal.getcontext().prec = 100
a, b = map(str, input().split())
c = decimal.Decimal(str(int((int(a) * float(b).as_integer_ratio()[1] * float(b).as_integer_ratio()[0]))))
d = decimal.Decimal(str(float(b).as_integer_ratio()[1] ** 2))
print(math.floor(c/d))
"""
import decimal
import math
decimal.getcontext().prec = 100
a, b = map(str, input().split())
a = decimal.Decimal(a)
b = decimal.Decimal(b)
print(math.floor(a*b))
# 遊びで、浮動小数点でなんとかならないかなと思ったけど無理だった なんで？？？？？

Measured memory_bytes: 10072
package main

import (
	"fmt"
	"strings"
)

func main() {
	var s, t string
	fmt.Scanf("%s", &s)
	fmt.Scanf("%s", &t)
	if strings.HasPrefix(t, s) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


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

int main(){
    int n;
    cin >> n;
    vector<vector<pair<int,int>>> data(n);
    for(int i=0;i<n;i++){
        int a;
        cin >> a;
        for(int j=0;j<a;j++){
            int b,c;
            cin >> b >> c;
            data[i].push_back({b,c});
        }
    }
    int ans=0;
    for(int i=0;i<(1<<n);i++){
        //cout << "  i " << i << endl;
        bool flag=true;
        for(int j=0;j<n;j++){
            if((i>>j)&1){
                //cout << "j " << j << endl;
                for(auto x:data[j]){
                    //cout << "x.first " << x.first << " x.second " << x.second << endl;
                    if(((i>>(x.first-1))&1)!=x.second){
                        //cout << "kani" <<endl;
                        //cout << (i>>(x.first-1)) << " " << x.second << endl;
                        flag=false;
                        break;
                    }
                }
            }
            if(!flag) break;
        }
        if(flag){
            int count=0;
            for(int j=0;j<n;j++) if((i>>j)&1) count++;
            ans=max(ans,count);
            //cout << " ans " << ans << endl;
        }
    }
    cout << ans << endl;
}

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

// using ll = long long;
#define int long long

#define LOG(variable) cout << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cout << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, r, n) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
/***** MAIN *****/
signed main() {
  int n;
  cin >> n;
  int nums[n];
  map<int, int> mp;
  REP(i,n) {
    cin >> nums[i];
    ++mp[nums[i]];
  }
  int ans = 0;
  REPOBJ(itr, mp) {
    if(itr->second >= 2) {
      ans += itr->second * (itr->second-1) / 2;
    }
  }
  REP(i,n) {
    int current = nums[i];
    if(mp[current] >= 2) {
      cout << ans - (mp[current]-1);
    } else {
      cout << ans;
    }
    cout << "\n";
  }
  return 0;
}
/***** MAIN *****/


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

int main() {
  int a, b, c, d, e, f, x, y;
  cin >> a >> b >> c >> d >> e >> f;
  
  if (a > b) {
    x = a;
    a = b;
    b = x;
  }
  if (b > c) {
    x = b;
    b = c;
    c = x;
  }
  if (c > d) {
    x = c;
    c = d;
    d = x;
  }
  if (b > c) {
    x = b;
    b = c;
    c = x;
  }
  if (a > b) {
    x = a;
    a = b;
    b = x;
  }
  if (e > f) {
    y = e;
    e = f;
    f = y;
  }
  cout << b + c + d + f << endl;
  
  return 0;
  
}



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

int main(){
  string str;
  stringstream ss;
  int sum, i;
  for(;;){
    cin >> str;
    if (str == "0"){ break; }
    sum = 0;
    for(char c : str){
      ss.clear();
      ss << c;
      ss >> i;
      sum += i;
    }
    cout << sum << endl;
  }
  return 0;
}

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

public class Hello
{
    public static void Main()
    {
        var a = new bool[110000];
        GeneratePrime(a);
        while (true)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var n = int.Parse(line[0]);
            var p = int.Parse(line[1]);
            if (n == -1 && p == -1) break;
            var t = n + 1;
            var ba = new int[25];
            var count = 0;
            while (count < 25)
            {
                if (a[t]) ba[count++] = t;
                t++;
            }
            Console.WriteLine(getAns(ba,p));
        }
    }
    public static int getAns (int[] a ,int p)
    {
        var aL = a.Length;
        var ret = new List<int>();
        for (int i = 0; i < aL; i++)
            for (int j = i; j < aL; j++) ret.Add(a[i] + a[j]);
        ret.Sort();
        return ret[p - 1];
    }
    public static void GeneratePrime(bool[] p)
    {
        int prime;
        var m = p.Length;
        var sqrtMax = Math.Sqrt(m);
        var searchList = Enumerable.Range(2, m - 1).ToList();
        do
        {
            prime = searchList.First();
            p[prime] = true;
            searchList.RemoveAll(n => n % prime == 0);
        }
        while (prime < sqrtMax);
        foreach (var x in searchList)
            p[x] = true;
    }
}



Measured memory_bytes: 10672
/**Bismillahir Rahmanir Rahim.**/
/*
         Md.Fagun Molla
         18ICTCSE006
         BSMRSTU(SHIICT)
*/
#include <bits/stdc++.h>
using namespace std;
#define  gcd(a,b)         __gcd(a,b)
#define  lcm(a,b)         (a*b)/gcd(a,b)
#define  ll               long long
#define  vi               std::vector<int>
#define  pb               push_back
#define  MAX              100007
#define  End              return 0;
#define  pi               acos(-1)


int main () {
    ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
    ll k,n;
    cin>>k>>n;
    ll aa[n];
    for(int i=0; i<n; i++)
        cin>>aa[i];
    ll mn=aa[n-1]-aa[0];
    ll s;
    for(int i=1; i<n; i++){
        s=k-aa[i]+aa[i-1];
        mn=min(s,mn);
    }
    cout<<mn<<endl;
    End
}
/* pray for me
Do before die
*/






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

int main() {
    int N, n, sum = 0;
    cin >> N;
    n = N;
    while (n > 0){
        sum += n % 10;
        n /= 10;
    }
    if (N % sum == 0) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const long long INF = 1LL << 60;

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

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


int main(){
    int n;
    cin >> n;
    int a[n],b[n],c[n];
    for (int i = 0; i < n; i++){
        cin >> a[i] >> b[i] >> c[i];
    }

    long long dp[n][3];
    for (int i = 0; i < n; i++){
        dp[i][0] = INF*(-1);
        dp[i][1] = INF*(-1);
        dp[i][2] = INF*(-1);
    }
    dp [0][0] = a[0];
    dp [0][1] = b[0];
    dp [0][2] = c[0];
    for (int i = 0; i < n-1; i++){
        chmax(dp[i+1][0],dp[i][1]+a[i+1]);
        chmax(dp[i+1][0],dp[i][2]+a[i+1]);
        chmax(dp[i+1][1],dp[i][0]+b[i+1]);
        chmax(dp[i+1][1],dp[i][2]+b[i+1]);
        chmax(dp[i+1][2],dp[i][0]+c[i+1]);
        chmax(dp[i+1][2],dp[i][1]+c[i+1]);
    }
    long long res = 0;
    if (res < dp[n-1][0]) res = dp[n-1][0];
    if (res < dp[n-1][1]) res = dp[n-1][1];
    if (res < dp[n-1][2]) res = dp[n-1][2];
    cout << res;
 
    return 0;
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
#define ll long long int
const ll MOD = 1e9 + 7;
using namespace std;
ll powmod(ll a, ll b, ll MOD = MOD){
    if(!a and !b)	return 1ll;
    if(!a)	return a;
    ll res = 1ll;
    b %= (MOD - 1ll), a %= MOD;
    while(b){
        if(b%2 == 1)	res = (res * a) % MOD;
        a = (a * a) % MOD;
        b /= 2;
    }
    return res;
}
void panda() {
   ll n;
   cin>>n;
   ll arr[n];
   //map <ll,ll> mp;
   //mp[1]=
   ll pp[n]={0};

   for(int i=1;i<n;++i)
   {
       cin>>arr[i];
       pp[arr[i]-1]++;


   }
   for(int i=0;i<n;++i)
   {
       cout<<pp[i]<<"\n";
   }

}
int main() {
    panda();
    return  0;
}


Measured memory_bytes: 6764
#include <stdio.h>
#include <iostream>
using namespace std;

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

    int nextSUN = 0;

    if (S == "SUN") nextSUN = 7;
    if (S == "MON") nextSUN = 6;
    if (S == "TUE") nextSUN = 5;
    if (S == "WED") nextSUN = 4;
    if (S == "THU") nextSUN = 3;
    if (S == "FRI") nextSUN = 2;
    if (S == "SAT") nextSUN = 1;

    cout << nextSUN << endl;
    return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val mod = 1000000007L
    
    val N = readInputLine().toInt()
    
    val AList = readInputLine().split(" ").map { it.toInt() }
    
    val hatNum = IntArray(3)
    
    var ans = 1L
    
    for (A in AList) {
        var cnt = 0L
        for (h in hatNum) {
            if (A == h) {
                cnt++
            }
        }
        
        ans *= cnt
        ans %= mod
        
        for (i in 0..2) {
            if (A == hatNum[i]) {
                hatNum[i]++
                break
            }
        }
    }
    
    println(ans)
}

fun readInputLine(): String {
    return readLine()!!
}


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

int main() {
    int H, W;
    std::cin >> H >> W;
    std::vector<std::vector<bool>> is_obstacle(H + 2, std::vector<bool>(W + 2, true));
    for (int i = 1; i <= H; ++i) {
        std::string S;
        std::cin >> S;
        for (int j = 1; j <= W; ++j) {
            if (S[j - 1] == '.') {
                is_obstacle[i][j] = false;
            }
        }
    }

    std::vector<std::vector<int>> L(H + 2, std::vector<int>(W + 2, 0));
    std::vector<std::vector<int>> U(H + 2, std::vector<int>(W + 2, 0));
    std::vector<std::vector<int>> R(H + 2, std::vector<int>(W + 2, 0));
    std::vector<std::vector<int>> D(H + 2, std::vector<int>(W + 2, 0));
    for (int i = 1; i <= H; ++i) {
        for (int j = 1; j <= W; ++j) {
            if (is_obstacle[i][j]) {
                L[i][j] = 0;
                U[i][j] = 0;
            } else {
                L[i][j] = L[i][j - 1] + 1;
                U[i][j] = U[i - 1][j] + 1;
            }
        }
    }
    for (int i = H; i >= 1; --i) {
        for (int j = W; j >= 1; --j) {
            if (is_obstacle[i][j]) {
                R[i][j] = 0;
                D[i][j] = 0;
            } else {
                R[i][j] = R[i][j + 1] + 1;
                D[i][j] = D[i + 1][j] + 1;
            }
        }
    }

    int ans = 0;
    for (int i = 1; i <= H; ++i) {
        for (int j = 1; j <= W; ++j) {
            int sum_light = L[i][j] + U[i][j] + R[i][j] + D[i][j] - 3;
            ans = std::max(ans, sum_light);
        }
    }

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


Measured memory_bytes: 63744
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int n, x, y;
    cin >> n >> x >> y;
    x--; y--;

    mat g(n);
    rep(i, n-1) {
        g[i].push_back(i+1);
        g[i+1].push_back(i);
    }
    g[x].push_back(y);
    g[y].push_back(x);

    // dist[start][v]
    mat dist(n, vec(n, INF));

    rep(st, n) {
        dist[st][st] = 0;

        queue<int> que;
        que.push(st);

        while (!que.empty()) {
            int v = que.front();
            que.pop();

            for (auto&& c : g[v]) {
                if (dist[st][c] == INF) {
                    dist[st][c] = dist[st][v] + 1;
                    que.push(c);
                }
            }
        }
    }

    rep(i, n) sort(all(dist[i]));

    for (int k = 1; k <= n-1; k++) {
        lint res = 0;

        rep(i, n) {
            auto t1 = upper_bound(all(dist[i]), k);
            auto t2 = lower_bound(all(dist[i]), k);
            res += t1 - t2;
        }

        cout << res / 2 << endl;
    }
    return 0;
}

Measured memory_bytes: 16128
#include <bits/stdc++.h>
#define ll unsigned long long 
#define pb push_back
using namespace std;

int main(){
	ll n, a, b;
	cin >> n >> a >> b;
	ll c =  b - a;
	if(c % 2 == 0) cout << c / 2 << endl;
	else{
		cout << min(a-1, n-b) + 1 + (b - a - 1) / 2;
	}
}

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

int main()
{
     int n , a[1000][2] , cnt = 1 ;
     cin >> n ;
     for(int i = 0 ; i < n ; i++)
     {
          cin >> a[i][0] >> a[i][1] ;
     }
     int f = 0 ;
     for(int i = 0 ; i < n-2 ; i++)
     {
          cnt = 0 ;
          if(a[i][0] == a[i][1])
          {
               cnt++ ;
               if(a[i+1][0] == a[i+1][1])
               {
                    cnt++ ;
                    if(a[i+2][0] == a[i+2][1])
                    {
                         cnt++ ;
                    }
               }
          }
          if(cnt == 3)
          {
               f = 1 ;
               break ;
          }
     }
     if(f == 1)
     {
          cout << "Yes\n" ;
     }
     else
     {
          cout << "No\n" ;
     }
}


Measured memory_bytes: 3624
import collections
H, W = map(int, input().split())
A = [input() for _ in range(H)]
A = [a+'.' for a in A]
A.append('.'*(W+1))

cnt = -1
for a in A:
    cnt += a.count('#')

i=j=0
flg=False
while True:
    if (A[i][j+1]=='#' and A[i+1][j]=='.'):
        j += 1
        cnt -= 1
    elif (A[i][j+1]=='.' and A[i+1][j]=='#'):
        i += 1
        cnt -= 1
    else:
        break
    
    if i==H-1 and j==W-1 and cnt==0:
        flg=True
        break

ans = 'Possible' if flg else 'Impossible'
print(ans)
        

Measured memory_bytes: 3316
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    if(s.length()<=3)System.out.println("No");
    else{
      if(s.substring(0,4).equals("YAKI"))System.out.println("Yes");
      else System.out.println("No");
    }
  }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (int)(n); i++)
#define int long long
#define ll long long
using namespace std;
int dp[1000010];
int n,h[100010];
signed main(){
    cin>>n;
    rep(i,n){
        cin>>h[i];
    }
    rep(i,n){
        if(i==0)dp[0]=0;
        else if(i==1)dp[1]=abs(h[1]-h[0]);
        else{
            dp[i]=min(dp[i-2]+abs(h[i]-h[i-2]),dp[i-1]+abs(h[i]-h[i-1]));
        }
    }
    cout<<dp[n-1]<<endl;
    return 0;
}

Measured memory_bytes: 1792
from sys import stdin


def main():
    lines = stdin.readlines()
    A = tuple([int(i) for i in lines[1].split()])
    B = tuple([int(i) for i in lines[2].split()])
    pre = A[0]
    ans = 0
    for a, b in zip(A[1:], B):
        tmp1 = pre if pre < b else b
        b -= tmp1
        tmp2 = a if a < b else b
        ans += tmp1 + tmp2
        pre = a - tmp2
    print(ans)
    return


main()


Measured memory_bytes: 20176
#include <bits/stdc++.h>
#define ALL(v) std::begin(v), std::end(v)
#define ALLR(v) std::rbegin(v), std::rend(v)
using ll = std::int64_t;
using ull = std::uint64_t;
using pii = std::pair<int, int>;
using tii = std::tuple<int, int, int>;
using pll = std::pair<ll, ll>;
using tll = std::tuple<ll, ll, ll>;
template <typename T> using vec = std::vector<T>;
template <typename T> using vvec = vec<vec<T>>;
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return std::min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return std::max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return std::max(low, std::min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { return t = clamp(t, low, high); }
template <typename T> T make_v(T init) { return init; }
template <typename T, typename... Tail> auto make_v(T init, std::size_t s, Tail... tail) { auto v = std::move(make_v(init, tail...)); return vec<decltype(v)>(s, v); }
template <typename T, std::size_t Head, std::size_t ...Tail> struct multi_dem_array { using type = std::array<typename multi_dem_array<T, Tail...>::type, Head>; };
template <typename T, std::size_t Head> struct multi_dem_array<T, Head> { using type = std::array<T, Head>; };
template <typename T, std::size_t ...Args> using mdarray = typename multi_dem_array<T, Args...>::type;
namespace init__ { struct InitIO { InitIO() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(30); } } init_io; }

int main() {
    int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, };
    int k;
    std::cin >> k;
    std::cout << a[k - 1] << '\n';
    return 0;
}


Measured memory_bytes: 256
#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>
using namespace std;

int a[123456];

int main(void)
{
	int n;
	cin >> n;
	int onum = 0;
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
		if (a[i] % 2)onum++;
	}
	if (onum % 2 == 0)cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}


Measured memory_bytes: 640
A = str(input())
AC = list(A)
AB = int(A[0] + A[1])
AC = int(A[2] + A[3])

if 1 <= AB <= 12 and 1 <= AC <= 12:
    print("AMBIGUOUS")
elif 1 <= AB <= 12:
    print("MMYY")
elif 1 <= AC <= 12:
    print("YYMM")
else:
    print("NA")

Measured memory_bytes: 3064
import sys
import copy
from collections import deque
import collections
import itertools
stdin = sys.stdin
import math

mod = 10**9+7

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n = ni()

a = na()

prev = 0
cnt = 0
for ai in a:
    if ai >= prev:
        prev = ai
    else:
        cnt += (prev-ai)

print(cnt)


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

using ll = long long int;
using ull = unsigned long long int;
using P = pair<ll, ll>;
using P3 = pair<ll, P>;
using PP = pair<P ,P>;
constexpr ll MOD = ll(1e9+7);
constexpr int IINF = INT_MAX;
constexpr ll LLINF = LLONG_MAX;
constexpr int MAX_N = int(2e5) + 5;
constexpr double EPS = 1e-8;
constexpr int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()

ll d[305][305], ans[305][305];

int main(){
    ll n, m, l;
    cin >> n >> m >> l;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            d[i][j] = LLINF/3;
        }
    }
    for(int i=0;i<m;i++){
        ll a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        d[a][b] = c;
        d[b][a] = c;
    }
    for(int k=0;k<n;k++){
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
    for(int i=0;i<n;i++){
        fill(ans[i], ans[i]+n, LLINF/3);
        ans[i][i] = -1;
        queue<int> que;
        que.push(i);
        while(!que.empty()){
            int now = que.front();
            que.pop();
            for(int nxt=0;nxt<n;nxt++){
                if(d[now][nxt] <= l && ans[i][nxt] > ans[i][now] + 1){
                    ans[i][nxt] = ans[i][now] + 1;
                    que.push(nxt);
                }
            }
        }
        ans[i][i] = 0;
    }
    int q;
    cin >> q;
    for(int i=0;i<q;i++){
        int s, t;
        cin >> s >> t;
        s--; t--;
        cout << (ans[s][t] < LLINF/3 ? ans[s][t] : -1) << endl;
    }
    return 0;
}

Measured memory_bytes: 1920
#include <iostream>
using namespace std;
int main(void){
    int n, a[100] = {0}; //100個
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    cout << a[n-1];
    for(int i = 1; i < n; i++){
        int j = (n-1) - i;
          
        cout << " " << a[j];
    }
    cout << endl;
}


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

using namespace std;

typedef long long ll;

int snuke(ll N) {
	int res = 0;
	if (N > 0) {
		res = N % 10 + snuke(N / 10);
	}
	return res;
}

int main() {
	int K;
	cin >> K;
	ll res = 1;
	for (int i = 0; i < K; i++) {
		if (res < 10) {
			cout << res++ << endl;
		}
		else {
			vector<ll> koho;
			ll temp = res;
			ll x = 10;
			for (int j = 0; j < 17; j++) {
				ll t = (temp / x) * x + x - 1;
				if (t > 1e+18) break;
				koho.push_back(t);
				x *= 10;
			}
			ll min = 1e+18;
			for (ll x : koho) {
				if (x / (double)snuke(x) < min / (double)snuke(min)) {
					min = x;
				}
			}
			res = min;
			cout << res << endl;
			res++;
		}
	}
}

Measured memory_bytes: 256
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)
#pragma GCC optimize("unroll-loops")
// -------------------</optimizations>--------------------

#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define f first
#define s second
#define sz(x) int(x.size())
#define endl '\n'
#define forn(i,n) for(int i=0;i<n;++i)
#define fore(i,l,r) for(int i=int(l);i<=int(r);++i)
#define rep(i,begin,end) for(__typeof(end) i=(begin);i!=(end);i++)
#define fill(a,value) memset(a,value,sizeof(a));
#define SIZE 26     
#define watch(x) cout << (#x) << " is " << (x) << endl
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
 
typedef long long ll;
typedef long double ld; 
typedef pair<ll,ll> pii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
 
const ll mod = 1e9 + 7;
const int inf = 1e9 + 5;
const int N = 1e5 + 5;

vector<int> g[N],vis(N),dp(N);

void dfs(int v){
    vis[v]=1;
    for(auto u:g[v]){
        if(!vis[u]){
            dfs(u);
        }
        dp[v]=max(dp[v],1+dp[u]);
    }
}

signed main(){
    fastio;
    int n,m,x,y,ans=-1;
    cin>>n>>m;
    for(int i=0;i<m;++i){
        cin>>x>>y;
        g[x].push_back(y);
    }
    for(int i=1;i<=n;++i){
        if(!vis[i]){
            dfs(i);
        }
    }
    for(int i=1;i<=n;++i){
        ans=max(ans,dp[i]);
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 7808
import java.util.*;
import java.io.*;

/**
 * @author kawakami
 *
 */
class Main {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		Scanner as = new Scanner(System.in);
		
		String dam;
		String str = "";
		
		int alf[];
		char line;
		char hika;
		alf = new int[26];
		
				
		while(as.hasNext()){
			
			str = str + as.nextLine();
			
		}
		
		dam = str;
		dam = dam.toUpperCase();
		
		for(int i=0;i<str.length();i++){      //
            
            line = str.charAt(i);
            hika = dam.charAt(i);
            if(line - 'A' >= 0){
            	if(line == hika ){
            		
            		alf[line-'A'] += 1;
            		
            	}
            	else{
            	
            		alf[line-'a'] += 1;
            		
            	}
            	
            }
             
        }
		
		line = 'a';
		
		for(int i=0;i<26;i++){
		
			str = (line++) + " : " + alf[i];
			System.out.println(str);
			
		}
		
		
		

	}

}

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

int main(void){
    int n;
    cin >> n;
    int a[2*n];
    for(int i = 0;i < 2*n;i++)cin >> a[i];
    sort(a,a+2*n);
    int sum = 0;
    for(int i = 0;i < 2*n;i+=2)sum += a[i];
    cout << sum;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast") 
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define owo ios_base::sync_with_stdio(0);cin.tie(0);
#define MOD (ll)(1e9+7)
#define INF (ll)(1e18)
#define debug(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false);\
debug("%s time : %.4fs\n", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> PII;
typedef pair<int,int> pii;
typedef vector<vector<int>> vii;
typedef vector<vector<ll>> VII;
ll gcd(ll A,ll B) {if(!B)return A;return gcd(B,A%B);}
ll dp[2][105][10005];
//0 -> prefix same
//1 -> any 
int main()
{
	owo
	string s;
	int d;
	cin>>s>>d;
	int n = s.length();
    dp[0][0][0] = 1;
    for(int i=0;i<n;i++){
		for(int j=0;j<d;j++){
			for(int k=0;k<10;k++){
				dp[1][(j+k)%d][i+1]+=dp[1][j][i];
				dp[1][(j+k)%d][i+1]%=MOD;
			} //any
			for(int k=0;k<s[i]-'0';k++){
				dp[1][(j+k)%d][i+1]+=dp[0][j][i];
				dp[1][(j+k)%d][i+1]%=MOD;
			}
			dp[0][(j+s[i]-'0')%d][i+1]+=dp[0][j][i];
			dp[0][(j+s[i]-'0')%d][i+1]%=MOD;
		}
	}
	ll ans = dp[1][0][n]+dp[0][0][n]-1+MOD;
	ans%=MOD;
	cout<<ans;
}


Measured memory_bytes: 19132
#include <iostream>
using namespace std;
int main(){
	int n;
	cin>>n;

	for(int i=0;i<n;i++){
		int a,b,c;
		cin>>a>>b>>c;

		if( a*a + b*b == c*c || b*b + c*c == a*a || c*c + a*a ==b*b){
			cout<<"YES"<<endl;
		}else{
			cout<<"NO"<<endl;
		}
	}

	return 0;
}

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

#define pb push_back
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#define ms memset
//#define MAXN 10005
//#define MAXM 100005
#define pi 3.14159265359

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int>> vpii;
typedef long long ll;
typedef priority_queue<int> pqi;
typedef priority_queue<pii, vpii, greater<pii> > dij;

int N, M, mi, sum;

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

	cin >> N >> M;

	for(int i = 0; i < M; i++){
		cin >> mi;
		sum += mi;
	}

	cout << (N - sum >= 0 ? N-sum : -1) << "\n";

	return 0;	
}

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

using namespace std;

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

    int n;
    cin >> n;
    int nOdd = (n + 1) / 2;
    cout << (double) nOdd / n << setprecision(20) << '\n';

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>

using namespace std;

#define REP(i,n) for(int i=0;i<int(n);i++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
typedef pair<ll,ll> P;

int main(void){
	          int i;

	          ll N,C,K;
	          cin >> N >> C >> K;
	          vector<ll> v(N);
	          for(i=0;i<N;i++) cin >> v[i];

	          sort(v.begin(),v.end());

	          ll ans=1,e=v[0]+K,cnt=1;
	          for(i=1;i<N;i++){
	        	  if(cnt==C || v[i]>e){
	        		  ans++;
	        		  cnt=1;
	        		  e=v[i]+K;
	        	  }else{
	        		  cnt++;
	        	  }

	          }

	          cout << ans << endl;

	          return 0;
}


Measured memory_bytes: 1024
#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 ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size() 

ll power(ll x,ll y,ll p) 
{ 
    ll res = 1;      
    x = x % p;  
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1; 
        x = (x*x) % p;   
    } 
    return res; 
} 

ll F(ll n) 
{ 
    // Initialize result 
    ll count = 0; 
  
    // Keep dividing n by powers of  
    // 5 and update count 
    for (ll i = 5; n / i >= 1; i *= 5) 
        count += n / i; 
  
    return count; 
} 

int main()
{
    ios_base::sync_with_stdio(false);
	ll n,i,j,k,x,y,t,m;


	cin >> n;
	if(n%2==1)
		cout<<0<<endl;
	else
	{
		cout<<F(n/2)<<endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>
using namespace __gnu_pbds;  
using namespace std;

typedef tree<long long, null_type, less<long long>, rb_tree_tag, 
             tree_order_statistics_node_update> 
    new_data_set; 
    
//defines
typedef long long ll;
typedef long double ld;
const long long MOD = (long long)(1e9 + 7); //(int)(1e9 + 7); //998244353;

ll a,b,c,n,m,k;

ll t=1;


void solve()
{
    cin>>n;
    vector<ll>v(n);
    ll sum=0LL;
    for(ll i=0;i<n;i++)cin>>v[i],sum+=v[i];
    ll ans=0LL;
    for(ll i=0;i<n-1;i++)
    {
        sum-=v[i];
        ans+=((v[i]*(sum%MOD))%MOD);
        ans%=MOD;
    }
    cout<<ans;
 if(t>0)cout<<"\n";
}

int32_t main()
{
#ifdef ONPC
    freopen("input.txt", "r", stdin);
#endif
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

  //cin>>t;
    while(t--)
    {
        solve();
    }
  //cout<<sum;
        
    return 0;
}

Measured memory_bytes: 4740
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll INF = ll(1e18)+5;

int main() {
    ll N,K;
    cin >> N >>K;
    vector<ll> A(N);
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    ll l =0;
    ll r = INF;
    while(l+1<r){
        ll mid = (l+r)/2;
       
        ll temp =0;
        for(int i=0;i<N;i++){
            temp += (A[i]-1)/mid;
        }
        //  cerr <<"mid=" << mid << "temp=" <<temp <<  ", l=" <<l << "r=" <<r<< endl;
        if(temp<=K){
            r = mid;
        }else{
            l = mid;
        }
    }
    cout << r << endl;

    return 0;
}

Measured memory_bytes: 4772
object Main extends App{
  import scala.io.StdIn._
  def gcd(a: Long, b: Long): Long = {
    if(b == 0L) a
    else gcd(b, a%b)
  }
  val n=readLong()
  var ans:Long=0L
  (1L to n).foreach(i=>{
    (1L to n).foreach(j=>{
      (1L to n).foreach(k=>{
        ans+=gcd(k,gcd(i,j))
      })
    })
  })
  println(ans)
}

Measured memory_bytes: 57036
#include <iostream>

using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;
    string ans;

    if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) ans = "Possible";
    else ans = "Impossible";

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
/*#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <array>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <unordered_map>
#include <unordered_set>
*/

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

#define int long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())

typedef long long ll;
const ll INF = 1LL<<60;
const ll mod = 1e9 + 7;
const int MAX_N = 5e5 + 5;
int dx[] = { -1,0,1,0 }, dy[] = { 0,1,0,-1 };
vector<ll> prime;

ll inv[MAX_N], fac[MAX_N];

template <class T = ll> T in() { T x; cin >> x; return (x); }
inline ll GCD(ll a, ll b) { ll c; while (b != 0) { c = a % b; a = b; b = c; }return a; }
inline ll LCM(ll a, ll b) { return a * b / GCD(a, b); }
inline ll POW(ll a, ll b) { ll c = 1; while (b > 0) { if (b & 1) { c = a * c%mod; }a = a * a%mod; b >>= 1LL; }return c; }
inline void _nCr() { fac[0] = 1; for (int i = 1LL; i < MAX_N; i++) { fac[i] = fac[i - 1] * i%mod; }for (int i = 0; i < MAX_N; i++) { inv[i] = POW(fac[i], mod - 2); } }
inline ll nCr(ll n, ll r) { return (fac[n] * inv[r] % mod)*inv[n - r] % mod; }
inline void PRI(ll n) { bool a[n + 1]; for (int i = 0; i < n + 1; i++) { a[i] = 1; }for (int i = 2; i < n + 1; i++) { if (a[i]) { prime.pb(i); ll b = i; while (b <= n) { a[b] = 0; b += i; } } } }

typedef pair<int, pair<int, int>> edge;

class UnionFind {
private:
	vector<int> par;
public:
	UnionFind(int N) { par = vector<int>(N, -1LL); }
	int find(int x);
	ll size(int x);
	void unite(int x, int y);
	bool same(int x, int y);
};



class Kruskal {
private:
	UnionFind *uf;
	vector<edge> e;
public:
	vector<edge> mst;
	Kruskal(int N) { uf = new UnionFind(N); }
	void add(int x, int y, ll z);
	void run();
};



//----UnionFind-------------------------------
int UnionFind::find(int x) {
	if (par[x] < 0) return x;
	else return par[x] = find(par[x]);
}

ll UnionFind::size(int x) {
	return -par[find(x)];
}

void UnionFind::unite(int x, int y) {
	x = find(x);
	y = find(y);

	//大きい方に小さい方をくっ付ける
	if (size(x) < size(y)) swap(x, y);
	par[x] += par[y];
	par[y] = x;
}

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



//----Kruskal-------------------------------
void Kruskal::add(int x, int y, ll z) {
	//x < y
	if (x > y) swap(x, y);
	e.push_back({ z,{x,y} });
}

void Kruskal::run() {
	sort(e.begin(), e.end());
	e.erase(unique(e.begin(), e.end()), e.end());
	for (auto x : e) {
		if (uf->same(x.second.first, x.second.second)) {
			continue;
		}
		else {
			mst.push_back(x);
			uf->unite(x.second.first, x.second.second);
		}
	}
}

signed main() {
	char b;
	cin >> b;
	if (b == 'A') cout << 'T' << endl;
	if (b == 'T') cout << 'A' << endl;
	if (b == 'G') cout << 'C' << endl;
	if (b == 'C') cout << 'G' << endl;
}

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

int main(){
    int a,b,c,d;
    scanf("%d %d %d %d",&a,&b,&c,&d);
    int turnKillA = ceil((double)a/d);
    int turnKillB = ceil((double)c/b);
    if(turnKillA >= turnKillB) printf("Yes\n");
    else printf("No\n");
}


Measured memory_bytes: 3768
/// Code By t_bone_289 (Tushar Singh)
/// An Immature Programmer.... I'm still developing !!
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define pll pair<ll,ll>
#define fi first
#define se second
#define mp make_pair
#define pb emplace_back
#define endl '\n'
#define M 1000000007
#define error(x) cout << #x << " = " << x << endl;
#define pi 3.14159265358979323846
typedef long long ll;
typedef long double ld;
template <typename T>
void ContainerError(T &v){cout<<"{";for(auto &x:v){cout<<x<<',';}cout<<"}"<<endl;return;}
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
ll powmod(ll base,ll exp,ll MOD){ll res=1;while(exp>0){if(exp%2==1) res=(res*base)%MOD;base=(base*base)%MOD;exp/=2;}return (res%MOD);}
ll mpow(ll base,ll exp){ll res=1;while(exp>0){if(exp%2==1) res=(res*base);base=(base*base);exp/=2;}return (res);}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s; cin>>s;
    if(s[2]==s[3] && s[4]==s[5]) {
    	cout<<"Yes";
    }
    else {
    	cout<<"No";
    }
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

  if (a == 1)
    a = 14;
  if (b == 1)
    b = 14;

  cout << (a == b ? "Draw" : a > b ? "Alice" : "Bob") << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.*; 
class Main {
   public static void main(String[] args) {
      
        Scanner sc = new Scanner(System.in);
       int N = sc.nextInt();
       int h[] = new int [N]; 
       int con = 1;
       int a = 0;
     
     for(int i =0;i<N;i++){
      h[i] = sc.nextInt();
     }
     
      for(int i = 1;i<N;i++){
        a = Math.max(h[i-1],a);
        if(a<=h[i]){con++;}
      }
       
     
     
     System.out.print(con);


   }
}


Measured memory_bytes: 23252
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
#define pb push_back

const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;
const double PI = acos(-1.0);


long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a * b / g;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
map<ll, ll> prime_factor(ll n) {
	map<ll, ll> ret;
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ret[i]++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}



const int MAX_N = 100010;


signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int h; cin >> h;
	int ans = 1;
	int now = 1;
	while (h > 1) {
		now *= 2; ans += now;  h /= 2;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std;
    int N;
    long long A[25252];
    const int ITER = 8e6;
    bool cnt[20][10];
    long long key = 0;
    long long key2 = 0;
    inline bool cmp(long long x, long long y)
    {
        return x%key < y%key;
    }
    int main()
    {
        scanf("%d", &N);
        for(int i=0; i<N; ++i)
            scanf("%lld", A+i);
        for(int i=0; i<13; ++i)
        {
            key = 1;
            for(int j=0;j<i; ++j) key *= 10;
            sort(A, A+N, cmp);
            long long sum = 0;
            for(int i=0; i<N; ++i)
            {
                sum += A[i];
                long long s = sum;
                int tp = 0;
                while(s)
                {
                    cnt[tp++][s%10] = true;
                    s /= 10;
                }
            }
            reverse(A, A+N);
            sum = 0;
            for(int i=0; i<N; ++i)
            {
                sum += A[i];
                long long s = sum;
                int tp = 0;
                while(s)
                {
                    cnt[tp++][s%10] = true;
                    s /= 10;
                }
            }
        }
        for(int iter=0; iter<ITER/N; ++iter)
        {
            std::random_shuffle(A, A+N);
            long long sum = 0;
            for(int i=0; i<N; ++i)
            {
                sum += A[i];
                long long s = sum;
                int tp = 0;
                while(s)
                {
                    cnt[tp++][s%10] = true;
                    s /= 10;
                }
            }
        }
        int ans = 0;
        for(int i=0; i<20; ++i)
        {
            int maxv = 0;
            for(int j=0; j<10; ++j)
                if(cnt[i][j])
                    maxv = j;
            ans += maxv;
        }
        printf("%d\n", ans);
        return 0;
    }

Measured memory_bytes: 512