akhauriyash/Code-Regression huggingface dataset:
import sys

H,W = map(int,input().split())
s = []
for i in range(H):
        s.append(input())
for i in range(H):
        for j in range(W):
                if s[i][j]=="#":
                        if i==0:
                                if j==0:
                                        if s[i+1][j]=="." and s[i][j+1]==".":
                                                print("No")
                                                sys.exit(0)
                                elif j==W-1:
                                        if s[i+1][j]=="." and s[i][j-1]==".":
                                                print("No")
                                                sys.exit(0)
                                else:
                                        if s[i+1][j]=="." and s[i][j-1]=="." and s[i][j+1]==".":
                                                print("No")
                                                sys.exit(0)
                        elif i==H-1:
                                if j==0:
                                        if s[i-1][j]=="." and s[i][j+1]==".":
                                                print("No")
                                                sys.exit(0)
                                elif j==W-1:
                                        if s[i-1][j]=="." and s[i][j-1]==".":
                                                print("No")
                                                sys.exit(0)
                                else:
                                        if s[i-1][j]=="." and s[i][j-1]=="." and s[i][j+1]==".":
                                                print("No")
                                                sys.exit(0)
                        else:
                                if j==0:
                                        if s[i+1][j]=="." and s[i-1][j]=="." and s[i][j+1]==".":
                                                print("No")
                                                sys.exit(0)
                                elif j==W-1:
                                        if s[i+1][j]=="." and s[i-1][j]=="." and s[i][j-1]==".":
                                                print("No")
                                                sys.exit(0)
                                else:
                                        if s[i+1][j]=="." and s[i-1][j]=="." and s[i][j-1]=="." and s[i][j+1]==".":
                                                print("No")
                                                sys.exit(0)
print("Yes")


Measured memory_bytes: 3192
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
const ll mod = 998244353;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n,m;
  cin >> n >> m;
  vector<ll> a(n),b(m);
  for(int i = 0; i < n; ++i) cin >> a[i];
  for(int i = 0; i < m; ++i) cin >> b[i];
  vector<ll> c = convolution<mod>(a,b);
  for(ll i : c) cout << i << ' ';
  return 0;
}

Measured memory_bytes: 27304
#include<iostream>
#include<cstdlib>
using namespace std;
 
int main(){
	long long x,n,ans,r,sub = 1000;
	//敗因：答えに0があり得ることは思いついたが、101があり得ることは思いつかなかったこと
	//「pに含まれない整数」を考えた時に（正とは限らない）に頭が引っ張られすぎたやつ
	long long p[101];

	cin >> x >> n;
	ans = x;

	for(int i = 0; i < 101; i++){
		p[i] = i+1;
	}
	for(int j = 0; j < n; j++){
		cin >> r;
		p[r-1] = -999999;
	}
	for(int k= 0; k < 101; k++){
		if((llabs(x - p[k])) < sub){
			sub = llabs(x - p[k]);
			ans = k+1;
		}
	}
	if(sub >= x){
		ans = 0;
	}
	
	cout << ans << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define M 100005
using namespace std;
int f[M][3], n;
int main(){
    cin >> n;
    for(int i = 0; i < n; ++i){
        cin >> f[i][0] >> f[i][1] >> f[i][2];
    }
    for(int i = 1; i < n; ++i){
        f[i][0] += max(f[i - 1][1], f[i - 1][2]);
        f[i][1] += max(f[i - 1][0], f[i - 1][2]);
        f[i][2] += max(f[i - 1][0], f[i - 1][1]);
    }
    cout << max(f[n - 1][0], max(f[n - 1][1], f[n - 1][2]));
    return 0;
}


Measured memory_bytes: 1408
N, H, W = map(int, input().split())
ab = []
A = []
B = []
for i in range(N):
    ab.append(list(map(int, input().split())))
    A.append(ab[i][0])
    B.append(ab[i][1])

count = 0
for i in range(N):
    if H <= A[i] and W <= B[i]:
        count += 1
print(count)


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

int N;
map<ll,int> flags;

int main() {
    cin >> N;
    for (int i = 0; i < N; i++){
        ll temp; scanf("%Ld", &temp);
        flags[temp] = !flags[temp];
    }
    int count = 0;
    for (auto flag : flags) if (flag.second) count++;
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 6528
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <string>
#include <map>
#include <math.h>
#include <cmath>
#include <climits>

typedef long long ll;
using namespace std;

ll MOD = 1e9+7;

int main() {
    int a;
    cin >> a;
    cout << a + pow(a, 2) + pow(a, 3) << endl;
    return 0;
}

Measured memory_bytes: 4200
import bisect
S=input()
T=input()
N=len(S)
M=len(T)
chardict=dict()
for i in range(26):
    chardict[chr(i+97)]=[]
for i in range(2*N):
    chardict[S[i%N]].append(i)
dp=[0 for i in range(M+1)]
dp[0]=-1
for i in range(M):
    nowpoint=dp[i]%N
    cycle=dp[i]//N
    #cycle 周していて　nowpoint番目にいる
    if len(chardict[T[i]])==0:
        print(-1)
        exit()
    tmp=bisect.bisect_right(chardict[T[i]],nowpoint)
    dp[i+1]=cycle*N+chardict[T[i]][tmp]
    #print(T[i],chardict[T[i]],nowpoint,tmp,chardict[T[i]][tmp],cycle,dp[i+1])
print(dp[M]+1)
#print(dp)


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

using namespace std;

int main() {
	int n;
	string s, t;
	cin >> n >> s >> t;

	string u = s + t;
	for (int i = 0; i < n; i++) {
	// printf("%d: %s %s\n", i, s.substr(i).c_str(), t.substr(0, n - i).c_str());
		if (s.substr(i) == t.substr(0, n - i)) {
			u = s.substr(0, i) + t;
			break;
		}
	}

	// cout << u << endl;
	cout << u.size() << endl;
	return 0;
}


Measured memory_bytes: 256
h,w = map(int,input().split())

s = []
for i in range(h):
    s.append(list(input()))

dp = [[1000000]*w for i in range(h)]

for i in range(h):
    for j in range(w):
        if i == 0 and j == 0:
            if s[0][0] == "#":
                dp[0][0] = 1
            else:
                dp[0][0] = 0
        else:
            if i > 0:
                if s[i-1][j] == "#" or s[i][j] == ".":
                    dp[i][j] = min(dp[i][j],dp[i-1][j])
                else:
                    dp[i][j] = min(dp[i][j],dp[i-1][j]+1)
            if j > 0:
                if s[i][j-1] == "#" or s[i][j] == ".":
                    dp[i][j] = min(dp[i][j],dp[i][j-1])
                else:
                    dp[i][j] = min(dp[i][j],dp[i][j-1]+1)
                    
print(dp[-1][-1])


Measured memory_bytes: 44144
def main():
    n = int(input())
    p = tuple(int(i) for i in input().split())
    q = tuple(int(i) for i in input().split())
    from itertools import permutations 
    a = [i for i in range(1, n+1)]
    o1 = -1
    o2 = -1
    cnt = 0
    for i in permutations(a):
      cnt += 1
      if i == p:
          o1 = cnt
      if i == q:
          o2 = cnt
      ans = abs(o1-o2)
    print(ans)
main()

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int q = sc.nextInt();
		StringBuilder sb = new StringBuilder();
		while (q-- > 0) {
			long a = sc.nextLong();
			long b = sc.nextLong();
			sb.append(solve(a, b));
			sb.append("\n");
		}
		System.out.print(sb.toString());
	}

	private static long solve(long a, long b) {
		if (a == b) return 2 * (a - 1);
		if (a > b) {
			long t = a;
			a = b;
			b = t;
		}
		long l = 0;
		long r = b;

		while (r - l > 1) {
			long m = (l + r) / 2;

			long l2 = 0;
			long r2 = m;
			while (r2 - l2 > 1) {
				long m2 = (l2 + r2) / 2;
				if ((m - (m2 - 1)) * (a + m2) <= (m - (m2)) * (a + 1 + m2)) {
					l2 = m2;
				} else {
					r2 = m2;
				}
			}

			if ((m - l2) * (a + 1 + l2) < a * b) {
				l = m;
			} else {
				r = m;
			}
		}

		return (a - 1) + l;
	}
}


Measured memory_bytes: 21716
MOD = 1000000007
n = int(input())
s = [input() for _ in range(2)]

if s[0][0] == s[1][0]:
    ans = 3
    col = 1
else:
    ans = 6
    col = 2

while col < n:
    if s[0][col] == s[1][col]:
        if s[0][col - 1] == s[1][col - 1]:
            ans *= 2
        col += 1
    else:
        if s[0][col - 1] == s[1][col - 1]:
            ans *= 2
        else:
            ans *= 3
        col += 2

    ans %= MOD

print(ans)


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

int main(){
  long long n,p,a[50],ans=0,dp[20000]={};
  cin>>n>>p;
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  dp[0]=1;
  for(int i=0;i<n;i++)
    for(int j=10000;j>=0;j--)
      dp[j+a[i]]+=dp[j];

  for(int i=0;i<10000;i++)
    if(i%2==p)ans+=dp[i];

  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

ll dp[1 << 22];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<vector<int>> a(n, vector<int>(n));
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            cin >> a[i][j];
        }
    }
    dp[0] = 1;
    for (int S = 0; S < (1 << n); S++)
    {
        int i = __builtin_popcount(S);
        for (int j = 0; j < n; j++)
        {
            if (S & (1 << j))
            {
                continue;
            }
            if (a[i][j])
            {
                (dp[S + (1 << j)] += dp[S]) %= MOD;
            }
        }
    }
    cout << dp[(1 << n) - 1] << endl;
}

Measured memory_bytes: 18688
#include<stdio.h>

int p[1000000];

int main()
{
    int pi,katakati, inspect, counter;
    p[0] = p[1] = 1;

    for(pi=2; pi*pi<1000000; pi++)
    {
        if (p[pi] == 0)
        {
            for(katakati = pi*2; katakati<1000000; katakati+=pi)
            {
                p[katakati] = 1;
            }
        }
    }

    while(scanf("%d",&inspect)==1)
    {
        for(pi=1, counter=0; pi<=inspect; pi++)
        {
            if(p[pi]==0)
            {
                counter++;
            }
        }
        printf("%d\n",counter);
    }
    return 0;
}

Measured memory_bytes: 4500
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int H = sc.nextInt();
        int W = sc.nextInt();
        int h = sc.nextInt();
        int w = sc.nextInt();

        int ans = Math.max(H * W - h * W - w * H + w * h, 0);

        System.out.println(ans);

    }
}


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

int main() {
  char C;
  cin >> C;
  if (C=='a') cout << 'b' << endl;
  if (C=='b') cout << 'c' << endl;
  if (C=='c') cout << 'd' << endl;
  if (C=='d') cout << 'e' << endl;
  if (C=='e') cout << 'f' << endl;
  if (C=='f') cout << 'g' << endl;
  if (C=='g') cout << 'h' << endl;
  if (C=='h') cout << 'i' << endl;
  if (C=='i') cout << 'j' << endl;
  if (C=='j') cout << 'k' << endl;
  if (C=='k') cout << 'l' << endl;
  if (C=='l') cout << 'm' << endl;
  if (C=='m') cout << 'n' << endl;
  if (C=='n') cout << 'o' << endl;
  if (C=='o') cout << 'p' << endl;
  if (C=='p') cout << 'q' << endl;
  if (C=='q') cout << 'r' << endl;
  if (C=='r') cout << 's' << endl;
  if (C=='s') cout << 't' << endl;
  if (C=='t') cout << 'u' << endl;
  if (C=='u') cout << 'v' << endl;
  if (C=='v') cout << 'w' << endl;
  if (C=='w') cout << 'x' << endl;
  if (C=='x') cout << 'y' << endl;
  if (C=='y') cout << 'z' << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl

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

    int ans1 = 0;
    int ans2 = 0;
    for(int i = 0; i < s.size(); i++){
        if(i%2==0 && s[i]=='0'){ans1++;}
        else if(i%2==1 && s[i]=='1'){ans1++;}
    }
    for(int i = 0; i < s.size(); i++){
        if(i%2==1 && s[i]=='0'){ans2++;}
        else if(i%2==0 && s[i]=='1'){ans2++;}
    }
    cout << min(ans1, ans2) << endl;
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define int long long
#define rep1(i,a,b) for(int i=a;i<b;i++)
#define rep2(i,a,b) for(int i=a;i>=b;i--)
#define mod 1000000009
#define garou99 ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
signed main() {
   double d,t,s;
   cin>>d>>t>>s;
   if((d/(double)t)<=s)
cout<<"Yes";
else
{
	cout<<"No";
}

	}

Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+7; bool fl[N];
int n,ans,len[N],val[N]; vector<int>v[N];
inline int read(){
	int num=0; char g=getchar(); while(g<48||57<g) g=getchar();
	while(47<g&&g<58) num=(num<<1)+(num<<3)+g-48,g=getchar(); return num;
}
inline void find(int u){
	fl[u]=1;
	for(int i=0;i<len[u];i++){
		int x=v[u][i]; if(fl[x]) continue; find(x),val[u]^=(val[x]+1);
	}
}
int main(){
	n=read(); int u,t;
	for(int i=1;i<n;i++) u=read(),t=read(),v[u].push_back(t),v[t].push_back(u),len[u]++,len[t]++; find(1);
	if(val[1]) puts("Alice"); else puts("Bob");
	return 0;
}

Measured memory_bytes: 9728
using System;
using System.Collections.Generic;
using System.Linq;
using static Constans;

public static class Constans
{
    public const long Mod = (long)1e9 + 7;
}

public class Combination
{
    private readonly long[] Fact;
    private readonly long[] InvFact;  // モジュラ逆数

    public Combination(long n)
    {
        Fact = new long[n + 1];
        InvFact = new long[n + 1];

        long f = 1;
        Fact[0] = f;
        for (long i = 1; i <= n; i++)
        {
            f *= i;
            f %= Mod;
            Fact[i] = f;
        }

        long inv = ModInt.GetInv(f).Num;

        InvFact[n] = inv;
        for (long i = n - 1; i >= 0; i--)
        {
            InvFact[i] = (InvFact[i + 1] * (i + 1)) % Mod;
        }
    }

    // nCr
    public ModInt GetCombination(long n, long r)
    {
        var comb = Fact[n] * InvFact[r] % Mod;
        comb = comb * InvFact[n - r] % Mod;
        return new ModInt(comb);
    }
}

public struct ModInt
{
    public long Num;

    public ModInt(long num)
    {
        Num = num;
    }

    // x^n
    public static long Power(long x, long n)
    {
        long pow = 1;
        while (n > 0)
        {
            if (n % 2 == 0)
            {
                x *= x;
                x %= Mod;
                n /= 2;
            }
            else
            {
                pow *= x;
                pow %= Mod;
                n--;
            }
        }

        return pow;
    }

    public static ModInt GetInv(long f)
    {
        // フェルマーの小定理 a^(-1) = a^(mod-2)
        return new ModInt(Power(f, Mod - 2));
    }

    public ModInt GetInv()
    {
        return GetInv(Num);
    }

    public override string ToString()
    {
        return Num.ToString();
    }

    public static ModInt operator +(ModInt l, ModInt r)
    {
        l.Num += r.Num;
        if (l.Num >= Mod)
        {
            l.Num -= Mod;
        }
        return l;
    }

    public static ModInt operator -(ModInt l, ModInt r)
    {
        l.Num -= r.Num;
        if (l.Num < 0)
        {
            l.Num += Mod;
        }
        return l;
    }

    public static ModInt operator *(ModInt l, ModInt r)
    {
        return new ModInt(l.Num * r.Num % Mod);
    }

    public static implicit operator ModInt(long n)
    {
        n %= Mod;
        if (n < 0)
        {
            n += Mod;
        }
        return new ModInt(n);
    }
}


public class Solution
{
    public static void Main()
    {
        var K = int.Parse(Console.ReadLine());
        var S = Console.ReadLine();
        var n = K + S.Length;

        var comb = new Combination(n);
        var pattern = new ModInt();
        for (int i = S.Length; i <= n; i++)
        {
            pattern += comb.GetCombination(i - 1, S.Length - 1) * ModInt.Power(25, i - S.Length) * ModInt.Power(26, n - i);
        }

        Console.WriteLine(pattern);
    }
}

Measured memory_bytes: 63048
import math

a,b,h,m=map(int,input().split())

lx=b*math.cos(math.radians(6*m))
ly=b*math.sin(math.radians(6*m))
sx=a*math.cos(math.radians((60*h+m)*0.5))
sy=a*math.sin(math.radians((60*h+m)*0.5))

length=((lx-sx)**2+(ly-sy)**2)**(1/2)
print(length)


Measured memory_bytes: 9576
def solve():
    a=str(input())
    b=str(input())
    for i in range(len(b)):
        print(a[i]+b[i],end='')
    if(len(a)>len(b)):
        print(a[len(a)-1],end='')
    print()

if __name__ == "__main__":
    solve()

Measured memory_bytes: 3060
#include <vector>
#include <map>
#include <string>
#include <iostream>
#include <cmath>
#include <random>
#include <cctype>
#include <cstdlib>
#include <algorithm>
using namespace std;
#define MK make_pair
#define PB push_back
#define VI vector<int>
#define VII vector<int,int>
#define MSI map<string,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define W1 while(1);
const int MOD = 1000000007;
int main()
{
	string S;
	string ans;
	cin >> S;
	REP(i,S.size())
	{
		if (S.at(i) == '0')ans += '0';
		else if (S.at(i) == '1')ans += '1';
		else if(ans.size()!=0)ans.erase(--ans.end());
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
from math import factorial
from math import sqrt
from math import ceil
from itertools import permutations
from heapq import *
from collections import defaultdict
from copy import deepcopy
from math import log

N,M=map(int,input().split())
def nCr(n,r):
    a=factorial(n)
    b=factorial(n-r)
    c=factorial(r)
    return int(a//(b*c))
A=[int(i)%M for i in input().split()]
L=[0]
dic=defaultdict(int)
dic[0]+=1
for i in range(N):
    a=(L[-1]+A[i])%M
    L.append(a)
    dic[a]+=1
sum=0
for i in dic.keys():
    if dic[i]>=2:
        sum+=nCr(dic[i],2)
print(sum)


Measured memory_bytes: 68332
n, m, k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

from itertools import accumulate
CA = [0]+A
CB = [0]+B
CA = list(accumulate(CA))
CB = list(accumulate(CB))
#print(CA)
#print(CB)
import bisect
ans = 0
for i in range(n+1):
    t = k-CA[i]
    if t < 0:
        continue
    j = bisect.bisect_right(CB, t)
    #print(i, t, j)
    ans = max(i+j-1, ans)
print(ans)


Measured memory_bytes: 129868
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
typedef unsigned int ui;
bool tasai(string t) {
	int le = t.length();
	bool f = true;
	for (int i = 0; i < le; i++) {
		for (int j = i + 1; j < le; j++) {
			if (t[i] == t[j])f = false;
		}
	}
	return f;
}
int main() {
	string s;
	cin >> s;
	string ss = s;
	int l = s.length();
	if (l < 26) {
		for (int i = 0; i < 26; i++) {
			ss = s;
			char p = 'a' + i;
			string u = "a"; u[0] = p;
			ss += u;
			if (tasai(ss))break;
		}
		cout << ss << endl;
	}
	else {
		int check = 0;
		for (int i = 25; i > 0; i--) {
			if (0 + s[i - 1] < 0 + s[i]) {
				check = i; break;
			}
		}
		if (check == 0)cout << -1 << endl;
		else {
			char p = s[check - 1];
			s = s.substr(0, check);
			for (int i = 0; i < 26 && p<'z'; i++) {
				ss = s;
				p ++;
				string u = "a"; u[0] = p;
				ss += u;
				if (tasai(ss))break;
			}
			string s1 = ss.substr(0, check - 1);
			string s2 = ss.substr(check, 1);
			cout << s1 + s2 << endl;
		}
	}
	char nyaa;
	cin >> nyaa;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<cstdio>
#include<cstdlib>
#include<string>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define p(s) cout << (s) << endl
#define p2(s,t) cout << (s) << " " << (t) << endl 
#define ALL(v) (v).begin(), (v).end()
typedef long long ll;
using namespace std;

static const ll mod  = 1e9 + 7;
static const ll inf  = 1e18;

static const int White = 0;
static const int Gray = 1;
static const int Black = 2;

void pvector(vector<int> A){
    cout << "[vector]";
    for(int i = 0; i < A.size(); i++){
        cout << A[i] << " ";
    }
    cout << endl;
}

int main(){
    int n, m;
    cin >> n >> m;
    int a,b;
    vector<int> l, r;
    REP(i, m){
        cin >> a >> b;
        l.push_back(a);
        r.push_back(b);
    }
    sort(ALL(l));
    sort(ALL(r));
    if(r[0]- l[m-1] + 1 >= 0) p(r[0]- l[m-1] + 1);
    else p(0);
}

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

using namespace std;

int main(){
  int N;  cin>>N;
  vector<int> h(N,0); 
  for(int i=0;i<N;i++) cin>>h[i];

  bool check=true;

  int l=0,r=N-1,ans=0;

  while(check){
    check=false;
    for(int i=0;i<N;i++){
      if(h[i]!=0){
        l=i; check=true; break;
      }
    }
    r=N-1;
    for(int i=l;i<N;i++){
      if(h[i]==0){
        r=i-1;break;
      }
    }
    if(!check) break;
    for(int i=l;i<=r;i++){
      h[i]--; //cout<<h[i]<<" ";
    }
    ans++; //cout<<endl;
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 384
H, W = gets.split.map(&:to_i)

field = []

H.times do
  field << gets.split.map(&:to_i)
end

odds = []
ans = []
move_coin = false
from = []

H.times do |y|
  W.times do |x|
    if y.odd?
      x = W - x - 1
    end

    if move_coin
      ans << [from, [y, x]]
      from = [y, x]
    end

    if field[y][x].odd?
      if move_coin
        move_coin = false
      else
        from = [y, x]
        move_coin = true
      end
    end
  end
end

puts ans.size
ans.each do |l|
  puts l.flatten.map { |i| i + 1 }.join(' ')
end


Measured memory_bytes: 38524
#include <bits/stdc++.h>
using namespace std;
#define int long long int
int32_t main() {
    int n , l;
    cin >> n >> l ;
    int v[n] , w[n] ;
    for(int i = 0 ; i <n ; i++){
        cin >> w[i] >> v[i] ;
    }
    int dp[n+1][l+1] ;
    for(int i = 0 ; i <=n ; i++){
        for(int j = 0 ; j <=l ; j++){
            if(i == 0 || j == 0)dp[i][j] = 0;
            else if(w[i-1] <= j)dp[i][j] = max(v[i-1]+dp[i-1][j-w[i-1]],dp[i-1][j]);
            else dp[i][j] = dp[i-1][j];
        }
    }
    cout << dp[n][l] << endl ;
}


Measured memory_bytes: 79104
#include<iostream>
using namespace std;
int main(void){
  string s; cin>>s;
  bool seven=false;
  for(int i=0;i<3;++i){
    if(s[i]=='7') seven = true;
  }
  if(seven) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

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

a,b,c,k = inpl()
if k%2:
    print(b-a)
else:
    print(a-b)


Measured memory_bytes: 64180
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const double PI = acos(-1);
const ll MOD = 1000000007;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

int main() {
  int N; cin >> N;
  vector<ll> r(N),c(N);
  rep(i,N) cin >> r[i] >> c[i];

  vector<vector<ll>> dp(N, vector<ll>(N,1e18));
  rep(i,N) dp[i][i] = 0;
  
  for (int j = 1; j < N; j++) {
    for (int i = 0; i < N-j; i++) {
      for (int k = i; k < i + j; k++) {
        chmin(dp[i][i+j],dp[i][k] + dp[k+1][i+j] + r[i] * c[k] * c[i+j]); 
      }
    }
  }

  cout << dp[0][N-1] << endl;
}


Measured memory_bytes: 3240
n = int(input())
p = list(map(int,input().split()))
i=1
count=0
while i < n-1:
    if i != n-1:
        pa=[p[i],p[i-1],p[i+1]]
        pa=sorted(pa)
        if pa[1]==p[i]:
            count+=1
            i+=1
        else:
            i+=1
print(count)

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

struct R {
    string s ;
    int p ;
    int id ;
    bool operator< (const R &o) const {
    return s == o.s ? p > o.p : s < o.s;
  }
};

struct R rs[110] ;

int main() {
	
    int n ;    
    cin >> n ;
    string name ;
    int p;

    for(int i=0;i<n;i++){
       cin >> name >> p ;
       rs[i].s = name ;
       rs[i].p = p ;
       rs[i].id = i+1 ;
    } 

    sort(rs,rs+n) ;

    for(int i=0;i<n;i++){
      cout << rs[i].id << endl;
    } 

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, T, ans = 10000;
  cin >> N >> T;
  vector<int>c(N);
  vector<int>t(N);
  for (int i = 0; i < N; i++) {
    cin >> c.at(i) >> t.at(i);
  }
  for (int i = 0; i < N; i++) {
    if (t.at(i) <= T) {
      if (c.at(i) < ans) {
        ans = c.at(i);
      }
    }
  }
  if (ans == 10000) {
    cout << "TLE";
  }
  else {
    cout << ans;
  }
}

Measured memory_bytes: 256
def main():
    n, m = map(int, input().split())
    ab_lst = []
    for i in range(m):
        ab_lst.append(list(map(int, input().split())))

    flag = False
    lst = []
    for i in range(m):
        a = ab_lst[i][0]
        b = ab_lst[i][1]

        if a == 1:
            lst.append(b)
    st = set(lst)

    for i in range(m):
        a = ab_lst[i][0]
        b = ab_lst[i][1]

        if b == n:
            if a in st:
                flag = True
                break

    if flag:
        print('POSSIBLE')
    else:
        print('IMPOSSIBLE')


if __name__ == '__main__':
    main()

Measured memory_bytes: 49248
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define f(i,x,n) for(int i=x;i<n;i++) 
#define all(c) c.begin(),c.end()
const int MOD = 1e9 + 7, N = 5e5 + 10;
const int LINF = LLONG_MAX;

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int x,y;
    cin >> x >> y;
    f(i,0,101){
        f(j,0,101){
            if(i + j == x){
                if(i*2 + j*4 ==y){
                    cout << "Yes\n";
                    return 0;
                }
            }
        }
    }
    cout << "No\n";
    return 0;
}
 

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  string s;
  cin >> n >> s;
  int r = 0, w = 0, ans = 0;
  for(char& ch : s) {
    if(ch == 'W') w++;
    else r++;
  }
  for(int i = 0; i < r; i++) {
    if(s[i] == 'W') ans++;
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3736
n = int(input())
v = list(map(int,input().split()))
c = list(map(int,input().split()))
def dfs(cnt,a):
    if cnt==n:
        return a
    ret1 = dfs(cnt+1,a+v[cnt]-c[cnt])
    ret2 = dfs(cnt+1,a)
    return max(ret1,ret2)
print(dfs(0,0))

Measured memory_bytes: 3060
#include<cstdio>
#include<cstdlib>
#include<cassert>
typedef long long LL;
const int md=1e9+7,N=1e5+5;
int tot[N],n,a[N],deg[N],cnt,bel[N],L[N],ans=1,top[N];
bool vis[N],inc[N];
inline void fail(){puts("0");exit(0);}
inline void upd(int&a){a+=a>>31&md;}
int solve(int L){
	static int f[N];
	*f=1;
	for(int i=1;i<=tot[L];++i){
		if((L&1)&&(L>1))upd(f[i]=f[i-1]*2-md);else f[i]=f[i-1];
		if(i>1)f[i]=(f[i]+(i-1LL)*f[i-2]%md*L)%md;
	}
	return f[tot[L]];
}
int solve_tree(int id){
	int len=0,now=top[id],r=1;
	do{
		++len;
		now=a[now];
		if(L[now]){
			if(L[now]>len)return 0;
			if(L[now]<len)upd(r=r*2-md);
			len=0;
		}
	}while(now!=top[id]);
	return r;
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i)scanf("%d",a+i),++deg[a[i]];
	for(int i=1;i<=n;++i)
	if(deg[i]==2&&!vis[i]){
		int j;
		top[bel[i]=++cnt]=i;
		vis[i]=inc[i]=1;
		for(j=a[i];!vis[j];j=a[j])vis[j]=1,bel[j]=cnt,inc[j]=1;
		if(j!=i)fail();
	}else if(deg[i]>2)fail();
	for(int i=1;i<=n;++i)
	if(!vis[i]&&deg[i]==0){
		int x=i;
		while(!vis[x])x=a[x];
		if(!inc[x]||L[x])fail();
		int len=0;
		for(x=i;!inc[x];x=a[x])vis[x]=1,++len;
		L[x]=len;
	}
	for(int i=1;i<=n;++i)if(!vis[i]){
		assert(deg[i]==1),vis[i]=1;
		int x,len=1;
		for(x=a[i];!vis[x];x=a[x])vis[x]=1,++len;
		assert(x==i);
		++tot[len];
	}
	for(int i=1;i<=n;++i)if(tot[i])ans=(LL)ans*solve(i)%md;
	for(int i=1;i<=cnt;++i)
	ans=(LL)ans*solve_tree(i)%md;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1920
import numpy as np

N,K = map(int, input().split())
A = []
for i in range(N):
  a = int(input())
  A.append(a)

S = [(0, 0)]
ss = 0
for i in range(N):
  ss += (A[i] - K)
  S.append((ss, i+1))

S = sorted(S)

#BIT
class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
 
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
 
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i


bit = Bit(N+1)

ans = 0
for s,i in S:
  ans += bit.sum(i+1)
  bit.add(i+1, 1)
  
print(ans)


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

// {to, cost, rev}
using vi3 = std::vector<std::array<int, 3>>;
using vvi3 = std::vector<vi3>;

int N, T, S, E;
vvi3 edges;
std::vector<bool> visited;

bool solve();
std::pair<bool, bool> dfs(int);

int main()
{
	if (solve()) puts("Yes");
	else puts("No");

	return 0;
}

bool solve()
{
	scanf("%d%d%d%d", &N, &T, &S, &E);
	S--; E--;

	edges.resize(N);
	for (int i{}; i < N - 1; i++)
	{
		int a, b, w;
		scanf("%d%d%d", &a, &b, &w);
		a--; b--;
		int tmp{1 << 30};
		if (T > 0) tmp = (w + T - 1) / T;
		edges[a].push_back({b, tmp, (int)edges[b].size()});
		edges[b].push_back({a, tmp, (int)edges[a].size() - 1});
	}
	for (auto& e: edges[S])
	{
		e[1] += 1;
		edges[e[0]][e[2]][1] += 1;
	}
	visited.resize(N);
	return dfs(S).first;
}

// {ok, E_found}
std::pair<bool, bool> dfs(int index)
{
	visited[index] = true;
	bool e_found{index == E};
	for (auto& e: edges[index])
	{
		e[1] -= 1;
		edges[e[0]][e[2]][1] -= 1;
	}
	for (auto& e: edges[index])
	{
		if (visited[e[0]]) continue;
		if (e[1] <= 0) return {false, false};
		auto tmp{dfs(e[0])};
		if (!tmp.first) return {false, false};
		if (!tmp.second)
		{
			if (e[1] <= 0) return {false, false};
			for (auto& e: edges[index])
			e[1] -= 1;
			edges[e[0]][e[2]][1] -= 1;
		}
		e_found = (e_found || tmp.second);
	}
	return {true, e_found};
}


Measured memory_bytes: 9472
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

const ll mod=1e9+7;
const ll inf=1e16;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define all(x) x.begin(),x.end()
#define gll greater<ll>()

void solve(){
 ll n;
  cin >> n;
  vll a(n);
  map<ll,ll> mp;
  ll ans=0;
  rep(i,0,n) {
    cin >> a[i];
    mp[a[i]]++;
    ans+=a[i];
  }
  ll q;
  cin >> q;
  while(q--){
   ll b,c;
    cin >> b >> c;
    ans-=mp[b]*b;
    ans+=mp[b]*c;
    mp[c]+=mp[b];
    mp[b]=0;
    cout << ans << endl;
  }
  
 
}
int main(){
   cin.tie(nullptr);
  ios::sync_with_stdio(false);
  solve();
}

Measured memory_bytes: 10068
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string>
#include <list>
#include <bitset>
#include <vector>
using namespace std;

#define I64d_OJ

//#ifdef I64d_OJ
//#define LL __int64
//#endif // I64d_OJ
#ifdef I64d_OJ
#define LL long long
#endif // I64d_OJ

typedef unsigned LL ULL;
typedef unsigned uint;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<LL,LL> pLL;
typedef vector<int> vi;

inline int read(){
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-f; ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}

#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define ls rt<<1
#define rs rt<<1|1
#define MID(a,b) (((LL)(a)+(LL)(b))>>1)
#define absx(a) ((a)<0?-(a):(a))
#define MK(a,b) make_pair(a,b)
#define PB(a) push_back(a)
#define lowbit(x) ((x)&-(x))

#define lc c[x][0]
#define rc c[x][1]

template< typename T >
inline void Max(T &a,T &b){if(a<b) a=b;}
template< typename T>
inline void Min(T &a,T &b){if(a>b) a=b;}

const double pi=(double)acos(-1.0);
const double eps=(double)1e-8;
const int INF = (int) 0x3f3f3f3f;
const int MOD = (int) 1e9+7;
const int MAXN =(int) 5e5+10;
const int MAXM = (int) 3e6+10;

///--------------------START-------------------------
map<string,int> mp;
void work(){
    int N;
    string x;
    cin>>N;
    int ans=0;
    while(N--){
        cin>>x;
        if(!mp[x]){
            mp[x]=1;
            ans++;
        }
    }
    printf("%d\n",ans);
}

///--------------------END-------------------------
int main(){
#ifdef NNever
//freopen("data.in","r",stdin);
///freopen("out.txt","w",stdout);
#endif // NNever
    work();
    return 0;
}









Measured memory_bytes: 19352
check[30], c, n, a, xor_sum, A, B, i;
main() {
  while (1) {
    c = getchar_unlocked();
    if (48 <= c && c <= 57)
      n = n * 10 + c - 48;
    else
      break;
  }

  for (i = 0; i < n; i++) {
    a = 0;
    while (1) {
      c = getchar_unlocked();
      if (48 <= c && c <= 57)
        a = a * 10 + c - 48;
      else
        break;
    }
    xor_sum ^= a;
    check[__builtin_popcount(a ^ (a - 1)) - 1] = 1;
  }

  for (B = 29; B >= 0; B--)
    if (check[B] && ((1 << B) & xor_sum))
      xor_sum ^= (1 << (B + 1)) - 1, A++;

  printf("%d\n", xor_sum ? -1 : A);
}

Measured memory_bytes: 128
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;

class Main {

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    String s = scanner.next();
    int K = scanner.nextInt();
    scanner.close();
    List<String> list1 = new ArrayList<String>();
    for (int i = 0; i < s.length(); i++) {
      for (int j = i + 1; j <= Math.min(i + K, s.length()); j++) {
        list1.add(s.substring(i, j));
      }
    }
    List<String> list2 = new ArrayList<String>(new HashSet<>(list1));
    Collections.sort(list2);
    System.out.println(list2.get(K - 1));
  }

}


Measured memory_bytes: 24784
#include<math.h>
#include<map>
#include<iostream>
#include <algorithm>
#include <string>
#include<vector>
#include<array>
#include<tuple>
#include<queue>
#include<stack>
#include<iomanip>
#include<bitset>
#include <list>
#include<numeric>
//AtCoderC++.cpp

using namespace std;


inline int ceileing(int a, int b) {return a % b == 0 ? a / b : a / b + 1;}
int main() {
	string s; cin >> s;
	s[5] = s[13] = ' ';
	cout << s << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
using namespace std;
typedef long long ll;

int main() {
    cin.tie(0);
    cin.sync_with_stdio(0);
    
    int n;
    cin >> n;
    ll a, b = 0, c = 0;
    map<ll, int> mp;
    for (int i = 0; i < n; i++) {
        cin >> a;
        mp[a]++;
    }

    for (auto u:mp) {
        if (u.second >= 4) {
            b = u.first;
            c = u.first;
        } else if (u.second >= 2) {
            c = b;
            b = u.first;
        }
    }

    cout << b * c << endl;
}

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


int main() {
	int N, x,count=0,sum=0;
	cin >> N >> x;
	vector<int> a(N);
	rep(i, N) { 
		cin >> a[i];
		
	}
	
	sort(a.begin(), a.end());

	for (int i = 0; i<N; i++)
	{
		x -= a[i];
		if (x < 0)break;
		count++;
	}
	if (x > 0)--count;
	
	cout << count << endl;
}

Measured memory_bytes: 3612
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, l;
  cin >> n >> l;
  vector<string> vec(n);
  REP(i,n) cin >> vec[i];
  sort(vec.begin(), vec.end());
  string s = "";
  REP(i,n) s += vec[i];
  cout << s << endl;
  return 0;
}
//templete by private_yusuke

Measured memory_bytes: 256
S = list(input())

_condi_flag = False


if S[0] == 'A':
    for i in range(2, len(S)-1):
        if S[i] == 'C':
            _condi_flag = True
            index = i
            break


if _condi_flag == True:
    S.pop(index)
    S.pop(0)
    S = str(S)
    if S.islower() == True:
        print('AC')
    else:
        print('WA')
else:
    print('WA')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define pb push_back
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ggdem=b;i<ggdem;++i)
#define SZ(x) ((int)x.size())
#define ALL(x) x.begin(),x.end()
#define mset(a,v) memset((a),(v),sizeof(a))
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;

const ll MOD=1000000007;

typedef vector<vector<ll> > Matrix;
Matrix ones(int n) {
	Matrix r(n,vector<ll>(n));
	fore(i,0,n)r[i][i]=1;
	return r;
}
Matrix operator*(Matrix &a, Matrix &b) {
	int n=SZ(a),m=SZ(b[0]),z=SZ(a[0]);
	Matrix r(n,vector<ll>(m));
	fore(i,0,n)fore(j,0,m)fore(k,0,z)
		r[i][j]+=a[i][k]*b[k][j],r[i][j]%=MOD;
	return r;
}
Matrix be(Matrix b, ll e) {
	Matrix r=ones(SZ(b));
	while(e){if(e&1LL)r=r*b;b=b*b;e/=2;}
	return r;
}

int main(){FIN;
	ll n,k; cin>>n>>k;
	Matrix m=ones(n);
	fore(i,0,n){
		fore(j,0,n){
			cin>>m[i][j];
		}
	}
	m=be(m,k);
	ll res=0;
	fore(i,0,n){
		fore(j,0,n){
			res+=m[i][j];
			if(res>MOD)res-=MOD;
		}
	}
	cout<<res;
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#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 all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<"\n"
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define mp make_pair
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using vc = vector<char>;
using vvc = vector<vc>;
template<class T> inline bool chmax(T& a, T b) { 
 if (a < b) { a = b; return true; } return false; 
}
template<class T> inline bool chmin(T& a, T b) {
 if (a > b) { a = b; return true; } return false; 
}
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll n,x,t;
  cin>>n>>x>>t;
  COUT((n+x-1)/x*t);
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<ll(n);i++)
const int MOD  = 2019;
int main() {
    ll l, r, ans;
    cin >> l >> r;
    ans = 3000;
    if ((r - l)>=2019) {
        ans = 0;
    }else{
        for (ll i = l; i < r; i++) {
            for (ll j = i + 1; j <= r; j++) {
                ans = min(ans, (i*j)%MOD);
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

typedef long long ll;
// can't

int main() {
    cin.tie(0);
    cin.sync_with_stdio(0);
    
    ll x;
    scanf("%lld", &x);

    ll a, b;
    bool found = false;
    for (a = -118; a <= 119; a++) {
        for (b = -118; b <= 119; b++) {
            if (pow(a, 5) - pow(b, 5) == x) found = true;
            if (found) break;
        }
        if (found) break;
    }

    printf("%lld %lld\n", a, b);
}

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

int main(){
  vec t;
  for(int i=0;i<3;i++){
    int a;
    cin>>a;
    t.push_back(a);
  }
  queue<vec > Q;
  map < vec , int > d;

  d[t]=0;
  Q.push(t);
  
  while(!Q.empty()){
    vec p=Q.front();
    Q.pop();
    if(p[0]==p[1]&&p[1]==p[2]){
      cout<<d[p]<<endl;
      break;
    }
    
    for(int i=0;i<3;i++){
      vec np=p;
      np[i]+=2;
      if(d.count(np)==0){
        d[np]=d[p]+1;
        Q.push(np);
      }
    }
    
    vec tmp=p;
    tmp[0]++;
    tmp[1]++;
    tmp[2]++;
    
    for(int i=0;i<3;i++){
      vec np=tmp;
      np[i]--;
      if(d.count(np)==0){
        d[np]=d[p]+1;
        Q.push(np);
      }
    }
  }
  return 0;
}


Measured memory_bytes: 10496
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'

int main()
{
    string s,t,tmp="";
    cin>>s>>t;
    for(ll i=0;i<t.length()-1;i++)
    {
        tmp += t[i];
    }
    if(tmp!=s) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
}

Measured memory_bytes: 3628
import java.util.*;

class Main {
    public static void main(String args[]) {
        Scanner inp = new Scanner(System.in);
        String s[] = inp.nextLine().split(" ");
        char x[] = map(s);
        // 32
        int d = 0;
        for (int i = 0; i < 3; i++) {
            d = ((int)x[i]) - 32;
            System.out.print((char)d);
        }
        System.out.println();
    }
    public static char[] map(String s[]) {
        char res[] = new char[s.length];
        for (int i = 0; i < s.length; i++) {
            res[i] = s[i].toCharArray()[0];
        }
        return res;
    }
}

Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,x,ind,mn,cnt;
    vector<int>v;
    cin>>n;
    while(n--)
    {
        cin>>x;
        v.push_back(x);
    }
    cnt=0;
    mn=v[0];
    for(auto y: v)
    {
        mn=min(mn,y);
        if(mn>=y)
            cnt++;
    }
    cout<<cnt<<endl;

}



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


int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n;
    cin >> n;
    int v[n];
    for( int &i: v ) {
        cin >> i;
    }
    sort(v, v+n);
    long double ans = v[0];
    for( int i = 1; i < n; i++ ) {
        ans += v[i];
        ans /= 2;
    }
    cout << fixed << setprecision(10) << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define de_x(x) cout<<"debug_val: "<<x<<endl;
#define de_ve(x) for(auto it: x) cout<<it<<" ";
#define rep(i,a,n) for (int i=a;i<n;i++)
#define _rep(i,a,n) for (int i=a;i<=n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef vector<int> VI;
typedef pair<int,int> PII;
typedef double db;
std::mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x ; }
const ll mod=1e7;
ll ksm(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
int _,n,m;;
/***********************/
void run(){
}

int main(){
//    for(scanf("%d",&_);_;_--) run();
    cin>>n;
    cout<< ceil(n*1.0/2)<<endl;
    return 0;
}

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

int main() {
    string s;
    cin>>s;
    set<char> st;
    for(auto c : s){
        st.insert(c);
    }
    cout<<(sz(st)==1?"No":"Yes")<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
    ios_base :: sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin >> s;
    int len = s.length();
    if(s[len-1]=='s'){
        cout << s;
        cout << "es\n";
    }
    else{
        cout << s;
        cout <<"s\n";
    }
    return 0;
}

Measured memory_bytes: 3620