akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
using namespace std;
 
const long long MOD=1e9+7;
const double PI=3.14159265359;

int main() {
    
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    string s;
    cin>>s;
    int n=s.size();
    int ans=n;
    for(int i=0; i<n-1; i++){
        if(s[i]!=s[i+1]){
            ans=min(ans,max(i+1,n-i-1));
        }
    }
    cout<<ans;
   
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef long int li;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
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 pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1LL<<60;

int main(){

  ll n;cin>>n;
  ll a[n+1];rep(i,0,n+1)cin>>a[i];
  ll b[n];rep(i,0,n)cin>>b[i];

  ll ans=0;
  rep(i,0,n){
    if(b[i]<=a[i]+a[i+1]){
      ans+=b[i];
      if(b[i]>a[i])a[i+1]=a[i+1]+a[i]-b[i];
    }else{
      ans+=a[i]+a[i+1];
      a[i]=0;
      a[i+1]=0;
    }
  }

  out(ans);




  return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <math.h>


int main(){

    int W, H, x, y, r;
    scanf("%d%d%d%d%d",&W,&H,&x,&y,&r);

    if((r <= x) && (x <= W-r) && (r <= y) && (y <= H-r)){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}



Measured memory_bytes: 2684
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include <cmath>
#include <limits>
#include<set>
#include <queue>

using namespace std;
#define int long  long int
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

signed main()
{
	int N, M;
	cin >> N >> M;
	priority_queue<int>q;
	int num;
	for (int i = 0; i < N; i++)
	{
		cin >> num;
		q.push(num);
	}
	int max;
	for (int i = 0; i < M; i++)
	{
		max = q.top();
		q.pop();
		q.push(max / 2);
	}
	int sum = 0;
	for (int i = 0; i < N; i++)
	{
		max = q.top();
		sum += max;
		q.pop();
	}
	cout << sum;
}

Measured memory_bytes: 1400
#入力
H,W,D = list(map(int,input().split()))
A = [list(map(int,input().split())) for i in range(H)]

P = {}
for h in range(H):
    for w in range(W):
        P[A[h][w]] = (h,w)

C = [0] * (H*W+1)
for i in range(D+1,H*W+1):
    C[i] = C[i-D] + abs(P[i][0]-P[i-D][0]) + abs(P[i][1]-P[i-D][1])
Q = int(input())

for q in range(Q):
    L,R = list(map(int,input().split()))
    print(C[R]-C[L])

Measured memory_bytes: 25128
#include <stdio.h>
#include <string.h>

void reset(int dp[][1000]){
    int i,j;
    for(i=0;i<1000;i++){
        for(j=0;j<1000;j++){
            dp[i][j]=0;
        }
    }
}

int main(void){
    int n,i,j,k,alen,blen;
    int dp[1001][1001];
    char a[1024],b[1024];
    scanf("%d",&n);
    for(k=0;k<n;k++){
        reset(dp);
        scanf("%s",a);
        scanf("%s",b);
        alen =strlen(a);blen =strlen(b);
        for(i=1;i<=alen;i++){
            for(j=1;j<=blen;j++){
                if(a[i-1]==b[j-1]){
                    dp[i][j]=dp[i-1][j-1]+1;
                }else{
                    dp[i][j]=dp[i-1][j];
                    if(dp[i][j]<dp[i][j-1]){
                        dp[i][j]=dp[i][j-1];
                    }
                }
            }
        }
        printf("%d\n",dp[alen][blen]);
    }
}


Measured memory_bytes: 5648
n,x=map(int,input().split())
lists=list(map(int,input().split()))
count=0
for i  in range(n-1):
    if lists[i]+lists[i+1]<=x:
        continue
    elif lists[i]+lists[i+1]>x and lists[i]<=x:
        count+=lists[i]+lists[i+1]-x
        lists[i+1]=x-lists[i]

    elif lists[i]+lists[i+1]>x and lists[i]>x:
        count+=(lists[i]+lists[i+1]-x)
        lists[i+1]=0
print(count)

Measured memory_bytes: 14404
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
int main() {
	int n,k;
	scanf("%d%d",&n,&k);
	vector<ll>a(n);
	for(int i=0;i<n;i++) scanf("%lld",&a[i]);
	sort(a.begin(),a.end());
	ll ans=1,sign=1;
	int l=0,r=n-1;
	if(k%2){
        ans=a[r--];
        --k;
        if(ans<0) sign=-1;
	}
	while(k){
        ll x=a[l]*a[l+1],y=a[r]*a[r-1];
        if(x*sign>y*sign){
            ans=x%mod*ans%mod;
            l+=2;
        }else{
            ans=y%mod*ans%mod;
            r-=2;
        }
        k-=2;
	}
	printf("%lld",(ans+mod)%mod);
	return 0;
}


Measured memory_bytes: 4844
import math


def main():
    n = int(input())
    # a, b, t = map(int, input().split())
    # h = list(map(int, input().split()))
    # s = input()
    # h = [int(input()) for _ in rane(n)]

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

    sub = [v[i]-c[i] for i in range(n)]

    ans = 0
    for num in sub:
        if num >0:
            ans +=num

    print(ans)






if __name__ == '__main__':
    main()


Measured memory_bytes: 62072
/*
██████╗  ███████╗  
██╔══██╗ ██╔════╝ 
██████╔╝ ███████╗ 
██╔══██╗ ╚════██║  
██║  ██║ ███████║      
╚═╝  ╚═╝ ╚══════╝                                                                                                             
*/

#include<bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define haha(j,a,n) for(int j=a;j<n;j++)
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define endl "\n"
#define bc(v) v.begin(),v.end()
#define vl vector<ll>
#define vi vector<int>
#define why 1000000007
#define NUM 100005
#define F first
#define S second
#define bhar(a) rep(i,a.size()) cin>>a[i];
#define show(a) rep(i,a.size()) cout<<a[i]<<" ";
#define sott(a) sort(bc(a))
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define mapp map<ll,ll>
#define dkac cout<<fixed<<setprecision(15);
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define yeah(n) while(n--)
ll gcd(int a, int b){if(b==0) return a; else return gcd(b,a%b);}
ll bitfun(ll x){
  return (x&(-x));
}
 
using namespace std;
 
int main() {
    ll n; string s;
    cin>>n>>s;
 
    ll dp[4][n+5];
    memset(dp, 0, sizeof dp);
    rep(i,n) {
        if(i) {
            dp[0][i] += dp[0][i-1];
            dp[1][i] += dp[1][i-1];
            dp[2][i] += dp[2][i-1];
        }
        if(s[i] == 'R') {
            s[i] = 0;
            dp[0][i]++;
        }
        if(s[i] == 'G') {
           s[i] = 1;
           dp[1][i]++;
        }
        if(s[i] == 'B'){
         s[i] = 2;
         dp[2][i]++;
        }
    }
 
    ll sum = 0;
    rep(i,n)
        haha(j,i+1,n) {
            if(s[i] == s[j])
                continue;
            for(ll k = 0; k < 3; k++) {
 
                if(k == s[i] or k == s[j])
                    continue;
 
                sum += dp[k][n-1]-dp[k][j];
 
 
 
                if(j+(j-i) < n && s[j+(j-i)] == k) 
                    sum--;
 
            }
 
 
        }
    cout << sum << endl;
}

Measured memory_bytes: 3772
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
 
int main()
{
vector<string> v(8);
string s;
int n,i;
 
for(i=0;i<8;i++) v[i] = '0'+i+(i>=4)+(i>=5);
 
while(cin>>n,n){
 s = "";
 while(n>0){
  s += v[n%8];
  n /= 8;
 }
 reverse(s.begin(),s.end());
 cout<<s<<endl;
}
 
return 0;
}

Measured memory_bytes: 916
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [list(input()) for _ in range(n)]

a = input()
b = input()

al = len(a)
bl = len(b)

if (al > bl):
    print("GREATER")
elif (al < bl):
    print("LESS")
else:
    for i in range(al):
        if a[i] > b[i]:
            print("GREATER")
            exit()
        elif a[i] < b[i]:
            print("LESS")
            exit()
    print("EQUAL")


Measured memory_bytes: 9060
#include <bits/stdc++.h>
using namespace std;
void debug() {cout<<endl;}
template<typename T,typename... Args>
void debug(T x,Args... args) {cout<<x<<" ";debug(args...);}
#define forn(i,a,b) for(int i=a;i<b;++i)
#define SZ(x) int(x.size())
#define pb push_back
#define F first
#define S second
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    
    int n, m, k;
    cin >> n >> m >> k;
    
    map<pii, int> cnt;
    while (k--) {
        int y, x;
        cin >> y >> x;
        
        int a = max(1, y-2), b = min(n-2, y);
        int c = max(1, x-2), d = min(m-2, x);
        
        forn(i, a, b+1) {
            forn(j, c, d+1) {
                cnt[{i, j}]++;
            }
        }
    }
    
    ll ans[10] = {};
    ans[0] = 1ll*(n-2)*(m-2);
    for (auto &x : cnt) {
        ans[x.S]++;
        ans[0]--;
    }
    
    forn(i, 0, 10) {
        cout << ans[i] << endl;
    }
}


Measured memory_bytes: 59852
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define rrep(i, n) for (ll i = n - 1; i >= 0; i--)
#define Rep(i, r, n) for (ll i = r; i < n; i++)
#define RRep(i, r, n) for (ll i = n - 1; i <= r; i--)
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define int long long
#define pb push_back
#define mp make_pair
const int dx[] = {0, -1, 0, 1};
const int dy[] = {1, 0, -1, 0};
const int MOD = (1000000007);
//const int MOD = (998244353);
//const int INF = (1 << 30)-1;
const int INF = (1LL << 60)-1;
const double EPS = (1 >> 30);

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

using Graph = vector<vector<pair<int, int>>>;
using Ki = vector<vector<int>>;
using Vi = vector<int>;

vector<int> ans;
int dp[1000000];
bool used[1000000];

void dfs (int u,Ki &G){
    if(used[u]) return;
    used[u]=true;
    for(auto& i:G[u]){
        dfs(i,G);
        dp[u]=max(dp[u],dp[i]+1);
    }
    ans.pb(u);
}

void tsort(int v,Ki &G){
    rep(i,v) dfs(i,G);
    reverse(all(ans));
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    //---------------------------------------------
    
    int n,m;
    cin>>n>>m;
    Ki G(n);
    rep(i,m){
        int a,b;
        cin>>a>>b;
        a--;b--;
        G[a].pb(b);
    }
    tsort(n,G);
    ll ans=0;
    rep(i,n) ans=max(ans,dp[i]);
    cout<<ans<<endl;

    // for(int i:ans) cout<<i<<endl;

    
}

Measured memory_bytes: 43000
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
//ll dp[100001];

int main()
{
  int n;
  cin>>n;
  int a[n][3];
  for(int i=0;i<n;i++)
  {
    cin>>a[i][0]>>a[i][1]>>a[i][2];
  }
  ll dp[n][3];
  dp[0][0]=a[0][0];
  dp[0][1]=a[0][1];
  dp[0][2]=a[0][2];
  for(int i=1;i<n;i++)
  {
    dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i][0];
    dp[i][1]=max(dp[i-1][0],dp[i-1][2])+a[i][1];
    dp[i][2]=max(dp[i-1][1],dp[i-1][0])+a[i][2];
    //cout<<dp[i][0]<<dp[i][1]<<dp[i][2]<<endl;
  }
  int max=0;
  for(int i=0;i<3;i++)
  {
    if(dp[n-1][i]>max)
      max=dp[n-1][i];
  }
  cout<<max<<endl;
}


Measured memory_bytes: 3712
n, k, q = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(q)]
start = [k - q] * n

for i in range(q):
    start[a[i][0] - 1] += 1

for i in range(n):
    if start[i] > 0:
        print('Yes')
    else:
        print('No')

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

int main(){
    string s;
    cin >> s;
    int ans[100005] = {}, i = 0, n = s.size();

    while (i < n){
        int cr = 0, cl = 0;
        while (s[i] == 'R'){
            i++;
            cr++;
        }
        int p = i - 1;
        while (s[i] == 'L'){
            i++;
            cl ++;
        }
        ans[p] = (cr + 1) / 2 + cl / 2;
        ans[p + 1] = cr / 2 + (cl + 1) / 2;
    }

    rep(j, n) cout << ans[j] << ' ';
    cout << endl;
    return 0;
}

Measured memory_bytes: 1024
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	
	public static final int INF = Integer.MAX_VALUE / 2 - 1;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		while (true) {
			final int n = sc.nextInt();
			final int m = sc.nextInt();
			
			if(n == 0 && m == 0){
				break;
			}
			System.gc();
			
			int[][] land_adj = new int[n][n];
			int[][] sea_adj = new int[n][n];
			
			for(int i = 0; i < n; i++){
				for(int j = i + 1; j < n; j++){
					land_adj[i][j] = land_adj[j][i] = INF;
					sea_adj[i][j] = sea_adj[j][i] = INF;
				}
			}
			
			for(int i = 0; i < m; i++){
				final int x = sc.nextInt() - 1;
				final int y = sc.nextInt() - 1;
				final int cost = sc.nextInt();
				final String str = sc.next();
				
				if("L".equals(str)){
					land_adj[x][y] = land_adj[y][x] = Math.min(land_adj[x][y], cost);
				}else{
					sea_adj[x][y] = sea_adj[y][x] = Math.min(sea_adj[x][y], cost);
				}
			}
			
			for(int k = 0; k < n; k++){
				for(int i = 0; i < n; i++){
					for(int j = 0; j < n; j++){
						land_adj[i][j] = Math.min(land_adj[i][j], land_adj[i][k] + land_adj[k][j] >= INF ? INF : (land_adj[i][k] + land_adj[k][j]));
						sea_adj[i][j] = Math.min(sea_adj[i][j], sea_adj[i][k] + sea_adj[k][j] >= INF ? INF : (sea_adj[i][k] + sea_adj[k][j]));
					}
				}
			}
			
			final int r = sc.nextInt();
			
			int[] purpos_place = new int[r];
			for(int i = 0; i < r; i++){
				purpos_place[i] = sc.nextInt() - 1;
			}
			
			int[][] time_dp  = new int[r][n];
			for(int i = 0; i < r; i++){
				for(int j = 0; j < n; j++){
					time_dp[i][j] = Integer.MAX_VALUE;;
				}
			}
			
			time_dp[0][purpos_place[0]] = 0;
			
			for(int pur = 1; pur < r; pur++){
				for(int boat_place = 0; boat_place < n; boat_place++){
					if(time_dp[pur-1][boat_place] == Integer.MAX_VALUE){
						continue;
					}
					
					for(int next_boat = 0; next_boat < n; next_boat++){
						final int move_to_boat = land_adj[purpos_place[pur-1]][boat_place];
						final int ride_boat = sea_adj[boat_place][next_boat];
						final int move_to_next = land_adj[next_boat][purpos_place[pur]];
						
						if(ride_boat >= INF){
							continue;
						}else if(move_to_next >= INF){
							continue;
						}
						
						//System.out.println(pur + " " + boat_place + " " + next_boat + " " + (time_dp[pur-1][boat_place] + move_to_boat + ride_boat + move_to_next));
						
						time_dp[pur][next_boat] = Math.min(time_dp[pur][next_boat],
								time_dp[pur-1][boat_place] + move_to_boat + ride_boat + move_to_next);
					}
					
					if(land_adj[purpos_place[pur-1]][purpos_place[pur]] < INF){
						time_dp[pur][boat_place] = Math.min(time_dp[pur][boat_place],
								time_dp[pur-1][boat_place] + land_adj[purpos_place[pur-1]][purpos_place[pur]]);
					}
					
				}
			}
			
			//for(int i = 0; i < r; i++){
			//	System.out.println(Arrays.toString(time_dp[i]));
			//}
			
			int min = Integer.MAX_VALUE;
			for(int i = 0; i < n; i++){
				min = Math.min(min, time_dp[r-1][i]);
			}
			
			System.out.println(min);
		}

	}

}

Measured memory_bytes: 61396
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Library;
using static Library.Input;

namespace AtCoderTemplate
{
    class ProgramD
    {
        static void Main()
        {
            long a = NextLong, b = NextLong, n = NextLong;
            long x = Math.Min(b - 1, n);

            System.Console.WriteLine((a * x) / b - a * (x / b));
        }
    }
}

namespace Library
{
    class Input
    {
        static IEnumerator<string> enumerator = new string[] { }.AsEnumerable().GetEnumerator();

        public static string Line => Console.ReadLine();

        public static string[] StrArr => Line.Split(' ');

        public static int NextInt => int.Parse(NextWord());

        public static long NextLong => long.Parse(NextWord());

        public static List<int> IntList => StrArr.Select(int.Parse).ToList();

        public static List<long> LongList => StrArr.Select(long.Parse).ToList();

        public static IEnumerable<long[]> TakeLine(int N)
        {
            return Enumerable.Repeat(0, N).Select(_ => Console.ReadLine().Split(' ').Select(long.Parse).ToArray());
        }

        public static string NextWord()
        {
            while (!enumerator.MoveNext())
            {
                enumerator = StrArr.AsEnumerable().GetEnumerator();
            }
            return enumerator.Current;
        }
    }
}


Measured memory_bytes: 27900
inp = require('fs').readFileSync('/dev/stdin', 'utf8').split('\n')[0].split(' ')
a = inp.shift() * 1
b = inp.shift() * 1
c = inp.shift() * 1
m = Math.max(a,b,c)
console.log((a + b + c - m) == m  ? 'Yes' : 'No')

Measured memory_bytes: 8776
fun main(args: Array<String>) {
    val (n, k) = readLine()!!.split(' ').map { it.toInt() }
    val hs = readLine()!!.split(' ').map { it.toInt() }

    val dp = Array(n) { Int.MAX_VALUE }

    (0 until n).forEach { i ->
        if (i == 0) {
            dp[i] = 0
            return@forEach
        }

        (1..k).forEach { j ->
            if (i - j >= 0) {
                dp[i] = Math.min(dp[i], dp[i - j] + Math.abs(hs[i] - hs[i - j]))
            }
        }
    }

    println(dp.last())
}

Measured memory_bytes: 104932
import math
n, k = map(int, input().split())
s = input()

q = []
tmp = 0

if len(s) == 1:
    if k >= 1 or s[0] == '1':
        print(1)
    else:
        print(0)
else:
    if s[0] == '0':
        q.append(0)
    for i in range(len(s)):
        if i == 0:
            tmp += 1
        elif i != len(s)-1:
            if s[i] == s[i-1]:
                tmp += 1
            else:
                q.append(tmp)
                tmp = 1
        else:
            if s[i] == s[i-1]:
                tmp += 1
                q.append(tmp)
            else:
                q.append(tmp)
                q.append(1)
    if s[len(s)-1] == '0':
        q.append(0)

    tmp = 0
    max_k = min(math.ceil(len(q)/2), k)
    """
    if len(q) == 1:
        if s[0] == '0' and k == 0:
            ans.append(0)
        else:
            ans.append(q[0])

    #先頭、末尾が0の時
    elif s[0] == '0' and len(q) % 2 == 1:
        for i in range(1, len(q) - 2 * max_k, 2):
            ans.append(sum(q[i:i+2*max_k+1]))
        ans.append(sum(q[:+2*max_k]))
        ans.append(sum(q[-2*max_k+1:]))
    #先頭0末尾1
    elif s[0] == '0' :
        for i in range(1, len(q) - 2 * max_k, 2):
            ans.append(sum(q[i:i+2*max_k+1]))
        ans.append(sum(q[:2*max_k]))
    #先頭1末尾0
    elif len(q) % 2 == 0:
        for i in range(1, len(q) - 2 * max_k, 2):
            ans.append(sum(q[i:i+2*max_k+1]))
        ans.append(sum(q[-2*max_k+1:]))
    else:
        if max_k == math.ceil(len(q)/2):
            max_k -= 1
        for i in range(0, len(q) - 2 * max_k, 2):
            ans.append(sum(q[i:i+2*max_k+1]))

    """
    #先頭1末尾1
    left = 0
    right = 0
    tmp = 0
    ans = 0
    for i in range(0, len(q), 2):
        next_left = i
        next_right = min(i + 2 * k+1, len(q))

        while (next_left > left):
            tmp -= q[left]
            left += 1

        while (next_right > right):
            tmp += q[right]
            right += 1

        ans = max(ans, tmp)
    print(ans)


Measured memory_bytes: 4092
#include <map>
#include <list>
#include <queue>
#include <cstdio>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm>
#define LL long long
using namespace std;

LL prep[2005][2005] = {0};
LL prer[2005][2005] = {0};
LL prec[2005][2005] = {0};
char bl[2005][2005] = {0};
char sidr[2005][2005] = {0};
char sidc[2005][2005] = {0};

LL n,m,q,a1,b1,a2,b2;

int main(){
	cin >> n >> m >> q;
	for(int i = 1;i <= n;i ++){
		for(int j = 1;j <= m;j ++){
			cin >> bl[i][j]; bl[i][j] -= '0';
			prep[i][j] = prep[i - 1][j] + prep[i][j - 1] - prep[i - 1][j - 1] + bl[i][j];
			if(bl[i][j] && bl[i - 1][j]) sidr[i][j] = 1;
			if(bl[i][j] && bl[i][j - 1]) sidc[i][j] = 1;
			prer[i][j] = prer[i - 1][j] + prer[i][j - 1] - prer[i - 1][j - 1] + sidr[i][j];
			prec[i][j] = prec[i - 1][j] + prec[i][j - 1] - prec[i - 1][j - 1] + sidc[i][j];
		}
	}
	while(q --){
		scanf("%lld %lld %lld %lld",&a1,&b1,&a2,&b2);
		printf("%lld\n",(prep[a2][b2] - prep[a1 - 1][b2] - prep[a2][b1 - 1] + prep[a1 - 1][b1 - 1])  - (prec[a2][b2] - prec[a1 - 1][b2] - prec[a2][b1] + prec[a1 - 1][b1]) - (prer[a2][b2] - prer[a1][b2] - prer[a2][b1 - 1] + prer[a1][b1 - 1]) );
	}
	return 0;
}

Measured memory_bytes: 107648
N, Y = map(int, input().split(' '))
solved = False
Y /= 1000
for y in range(N+1):
    for z in range(N+1):
        remain_yen = Y - 5 * y - z
        remain_num = N - y - z
        if (remain_num >= 0 and remain_yen == 10 * remain_num):
            solved = True
            break
    if solved:
        break

if solved:
    print(remain_num, y, z)
else:
    print('-1 -1 -1')

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

int main() {
  int n, d = 100000;
  cin >> n;
  for (int i = 0; i < n; i++) {
    d = d * 105 / 100;
    if (d % 1000) {
      d = (d / 1000 + 1) * 1000;
    }
  }
  cout << d << endl;
  return 0;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	int inf = 1e9;
	int c = inf;
	int f = -inf;
	for(int i = 0; i < s.size(); ++i){
		if(s[i] == 'C'){
			c = min(c, i);
		}
		if(s[i] == 'F'){
			f = max(f, i);
		}
	}
	if(f > -inf && c < inf && c < f){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
	return 0;
}


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

using namespace std;

const int INF = 1e9;
int d[201][201];

void warshallFloyd(int n) {
  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]);
      }
    }
  }
}

int main(void) {
  int n, m, R;
  cin >> n >> m >> R;

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

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      d[i][j] = INF;
    }
    d[i][i] = 0;
  }

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

  warshallFloyd(n);

  int ans = INF;
  do {
    int dis = 0;
    for (int i = 0; i < R - 1; i++) {
      dis += d[r[i]][r[i + 1]];
    }
    ans = min(ans, dis);
  } while (next_permutation(r.begin(), r.end()));

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 384
#!/usr/bin/env python3
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


def main():
    A, B = map(int, readline().split())
    if (A <= 9) & (B <= 9):
        print(A * B)
    else:
        print(-1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
N = gets.to_i

play_lists = N.times.map { 
  title, time = gets.chomp.split
  [title, time.to_i]
}
X = gets.chomp

sleep = false
ans = 0

play_lists.each do |s, t|
  if s == X
    sleep = true
  elsif sleep
    ans += t
  end
end

puts ans


Measured memory_bytes: 1788
#include<stdio.h>
int main(){
  long long int a,b,tmp,x,y;
  while(scanf("%lld %lld",&a,&b)!=EOF){
    x=a,y=b;
    if(x<y){
      tmp = x;
      x=y;
      y = tmp;
    }
    while(y!=0){
      tmp = y;
      y = x%y;
      x = tmp;
    }
    printf("%lld %lld\n",x,a*b/x);
  }
  return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e9;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
typedef pair<double,double> point;
const ll MAX = 200005;
constexpr ll nx[8] = {1,0,-1,0,1,-1,1,-1};
constexpr ll ny[8] = {0,1,0,-1,1,1,-1,-1};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    ll w;
    cin >> s >> w;
    ll i = 0;
    string ans = "";
    while(i < s.length()){
        ans += s[i];
        i += w;
    }
    PRINT(ans);
}


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

int main(){
    int n;
    cin >> n;
    bool moti[110]={};
    for(int i=0; i<n; i++) {
        int d;
        cin >> d;
        moti[d] = true;
    }
    int cnt = 0;
    for(int i=0; i<105; i++){
        if(moti[i])cnt++;
    }
    cout << cnt << '\n';
    return 0;
}


Measured memory_bytes: 3552
a, b, c = map(int, input().split())
if a == b == c:
    if a % 2:
        print(0)
    else:
        print(-1)
else:
    ans = 0
    while a % 2 == 0 and b % 2 == 0 and c % 2 == 0:
        A = a // 2
        B = b // 2
        C = c // 2
        a = B + C
        b = A + C
        c = A + B
        ans += 1
    print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long x = sc.nextLong();
		
		long[] a = new long[N];
		a[0] = sc.nextLong();
		
		long count = 0;
		
		for(int i = 1; i < N; i++) {
			a[i] = sc.nextLong();
			if(x - a[i - 1] >= 0) {
				if(a[i - 1] + a[i] > x) {
					count += a[i] - (x - a[i - 1]);
					a[i] = x - a[i - 1];
				}
			} else {
				count += a[i];
				a[i] = 0;
				count += a[i - 1] - x;
				a[i - 1] = x;
			}
		}		
		System.out.println(count);
	}
}


Measured memory_bytes: 62336
#include <bits/stdc++.h>
using namespace std;
#define SELECTER(_1, _2, _3, SELECT, ...) SELECT
#define REP1(i, n) for(int (i)=0; (i)<(n); (i)++)
#define REP2(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define REP(...) SELECTER(__VA_ARGS__, REP2, REP1,) (__VA_ARGS__)
#define MOD 1'000'000'007

template <class T> ostream& operator<<(ostream& os, const vector<T>& v){ os << "{"; for(size_t i=0; i<v.size(); i++) os << v[i] << (i+1==v.size() ? "" : ", "); os << "}"; return os; }
template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ return os << "{" << p.first << ", " << p.second << "}"; }

int main(){
    int L;
    cin >> L;
    double a = L/3.0;
    double ans = a*a*a;
    cout << fixed << setprecision(32) << ans << endl;
    return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val a1 = readLine()!!.split(" ").map { it.toInt() }
    val a2 = readLine()!!.split(" ").map { it.toInt() }
    val a3 = readLine()!!.split(" ").map { it.toInt() }
    val n = readLine()!!.toInt()
    val card = Array(3) { Array(3){ 0 } }
    for (i in 0 until n) {
        val b = readLine()!!.toInt()
        for (j in 0 until 3) {
            when(b) {
                a1[j] -> card[0][j] = 1
                a2[j] -> card[1][j] = 1
                a3[j] -> card[2][j] = 1
            }
        }
    }

    if (card[0][0] + card[0][1] + card[0][2] == 3 || card[1][0] + card[1][1] + card[1][2] == 3 || card[2][0] + card[2][1] + card[2][2] == 3
            || card[0][0] + card[1][0] + card[2][0] == 3 || card[0][1] + card[1][1] + card[2][1] == 3 || card[0][2] + card[1][2] + card[2][2] == 3
            || card[0][0] + card[1][1] + card[2][2] == 3 || card[0][2] + card[1][1] + card[2][0] == 3) {
        println("Yes")
    } else {
        println("No")
    }
}

Measured memory_bytes: 38048
#include <iostream>
#include <string>
#include <climits>
#include <vector>
using namespace std;

string u, v;
vector<vector<int> > memoization;

int lenLCS(int i, int j) {
  int current_max = INT_MIN;
  int attempt;
  if (i == -1)
    return 0;
  if (j == -1)
    return 0;
  if (memoization[i][j] != -1)
    return memoization[i][j];
  if (u[i] == v[j]) {
    attempt = 1 + lenLCS(i-1,j-1);
    if (attempt > current_max)
      current_max = attempt;
  }
  attempt = lenLCS(i-1,j);
  if (attempt > current_max)
    current_max = attempt;
  attempt = lenLCS(i,j-1);
  if (attempt > current_max)
    current_max = attempt;
  memoization[i][j] = current_max;
  return memoization[i][j];
}

int main(int argc, char **argv) {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> u >> v;
    memoization = vector<vector<int> > (u.size(), vector<int> (v.size(), -1));
    cout << lenLCS(u.size()-1, v.size()-1) << endl;
  }
  return 0;
}



Measured memory_bytes: 11084
#include <iostream>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;

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

  bool flag = false;
  int a, b, c; cin >> a >> b >> c;
  for(int i = a; i < a*b; i += a) {
    if(i%b == c) flag = true;
  }
  cout << (flag ? "YES" : "NO") << '\n';
  return 0;
}


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

const int N = 100 + 10;

int n, a[N], b[N];

int main() {
    scanf("%d", &n);
    for(int i = 1; i <= n; i++)
        scanf("%d %d", &a[i], &b[i]);
    for(int i = 1; i <= n - 2; i++) {
        bool flag = true;
        for(int j = i; j <= i + 2; j++)
            if(a[j] != b[j]) flag = false;
        if(flag == true) puts("Yes"), exit(0);
    }
    puts("No");
    return 0;
}

Measured memory_bytes: 3756
#include <iostream>

using namespace std;

long long f(long long a) {
    if (a%2) {
        return ((a+1)/2)%2;
    } else {
        return a^((a/2)%2);
    }
}

int main() {
    long long N, M;
    cin >> N >> M;
    cout << (f(N-1)^f(M)) << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
a.sort()

l = -1
r = n
while r - l > 1:
    m = l + (r-l)//2
    b = a[:]
    b[m] += sum(b[:m])
    flag = 1
    for i in range(m, n-1):
        if b[i+1] <= 2*b[i]:
            b[i+1] += b[i]
        else:
            flag = 0
            break

    if flag == 1:
        r = m
    else:
        l = m


print(n-r)


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

int main(){
    string S;
  	cin >> S;
    bool C = false, F = false;
    for (int i = 0; i < S.length(); i++) {
        if (C && F) {
            break;
        } else {
            if (C) {
                if (S[i] == 'F') {
                    F = true;
                }
            } else {
                if (S[i] == 'C') {
                    C = true;
                }
            }
        }
    }
    
    if (C && F) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

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

int main() {
	char S[5];
	cin >> S;
	if (S[0] == S[1] && S[2] == S[3] && S[1]!=S[2]) cout << "Yes" << endl;
	else if (S[1] == S[2] && S[0] == S[3] && S[1]!=S[0]) cout << "Yes" << endl;
	else if (S[0] == S[2] && S[1] == S[3] && S[0]!=S[1]) cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
// clang-format on

int A, B;

int main(void)
{
  cin >> A >> B;
  int ans = max({A + B, A - B, A * B});
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 888
/*input
3 2
*/
#include<bits/stdc++.h>
using namespace std;

#define int long long 
#define double long double
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define RE(i,n) for (int i = 1; i <= n; i++)
#define RED(i,n) for (int i = n; i > 0; i--)
#define REPS(i,n) for(int i = 1; (i*i) <= n; i++)
#define REP(i,n) for (int i = 0; i < n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)
#define remax(a,b) a = max(a,b)
#define remin(a,b) a = min(a,b)
#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define mii map<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define WL(t) while(t --)
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define print(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout << *it << " "; cout << endl;
#define debug(x) cout << x << endl;
#define debug2(x,y) cout << x << " " << y << endl;
#define debug3(x,y,z) cout << x << " " << y << " " << z << endl;
const int INF = 1e18+1;
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338;

int fast_ex(int a,int n,int m){
  if(n == 0)return 1;
  if(n == 1)return a;
  int x = 1;
    x *= fast_ex(a,n/2,m);
    x %= m;
    x *= x;
    x %= m;
    if(n%2)x*= a;
    x %= m;
    return x;
}


void solve(){
	 int n,k;cin >> n >> k;
	 if( (n+1)/2 >= k)cout << "YES";
	 else cout << "NO";
}

signed main(){
  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  //freopen(".in","r",stdin);freopen(".out","w",stdout);
  int t = 1;//cin >> t;
  WL(t)solve();
  return 0;
}

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

#define lli long long int
#define pb push_back
#define pii pair <int, int>
#define pll pair <lli, lli>
#define _F first
#define _S second
#define mset(x) memset(x, 0, sizeof(x))
#define fastio() ios_base::sync_with_stdio(0)

using namespace std;

int main()
{
	lli n, m;
	cin >> n >> m;

	vector < pair <pll, lli> > E;

	while(m--)
	{
		lli x, y, w;
		cin >> x >> y >> w;

		E.pb({{x, y}, w});
	}

	lli inf = - (1e17);

	lli D[n+1];
	for(int i=0; i<=n; i++)
		D[i] = inf;

	D[1] = 0;

	for(int i=0; i<n-1; i++)
	{
		for(int j=0; j<E.size(); j++)
		{
			lli x, y, w;

			tie(x, y) = E[j].first;
			w = E[j].second;

			D[y] = max(D[y], D[x] + w);
 		}
	}

	lli ans = D[n];

	for(int i=0; i<n-1; i++)
	{
		for(int j=0; j<E.size(); j++)
		{
			lli x, y, w;

			tie(x, y) = E[j].first;
			w = E[j].second;

			D[y] = max(D[y], D[x] + w);
 		}
	}

	if(D[n] > ans)
		cout << "inf" << endl;
	else
		cout << ans << endl;


	return (0-0);	
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
//typedef tuple<ll, ll, ll> T;

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 dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int gcd(ll x, ll y){
  return y ? gcd(y, x%y) : x;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,K;
    cin>>N>>K;
    ll ma=0;
    ll GCD;
    REP(i,N){
        ll a;cin>>a;
        if(i==0) GCD=a;
        chmax(ma,a);
        GCD = gcd(GCD,a);
    }
    
    if(ma>=K&&K%GCD==0) cout<<"POSSIBLE";
    else cout<<"IMPOSSIBLE";
}

Measured memory_bytes: 256
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.lang.Exception
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val k = sc.nextInt()
    if (k % 2 == 0 || k % 5 == 0) {
        println(-1)
    } else if (k == 7) {
        println(1)
    } else {
        var min = Int.MAX_VALUE
        var num = 7L
        for (i in 1..k) {
            if (num % k == 0L) {
                min = i
                break
            }
            num = (10 * num + 7) % k
        }
        if (min == Int.MAX_VALUE) {
            println(-1)
        } else {
            println(min)
        }
    }
}

fun main() {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}


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

using namespace std;

int a[200005];

int main() {
	int n;
	scanf("%d", &n);
	
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	
	sort(a, a + n, greater<int>());
	
	long long res = 0;
	int ptr = 0;
	
	for (int i = 0; i < n - 1; i++) {
		res += a[ptr];
		if (i % 2 == 0) ptr++;
	}
	
	printf("%lld\n", res);
}


Measured memory_bytes: 4616
#include <cstdio>
using namespace std;

const int N = 1e5 + 10;
int n, a[N], vis[N], flag[2], val[N][3];

inline int abs(int x) {return x < 0 ? -x : x;}
template <class T> inline void in(T &x) {
	x = 0; int f = 1; char ch = getchar();
	for (; ch<'0' || ch>'9';) {if (ch=='-') f=-1; ch = getchar();}
	for (; ch>='0' && ch<='9';) x = x*10 + ch-'0', ch = getchar();
	x *= f;
}

int main() {
	int u, v, w; in(n);
	for (int i = 0; i <= 2; ++i)
		for (int j = 1; j <= n; ++j) in(val[j][i]);
	for (int i = 1; i <= n; ++i) {
		if (abs(val[i][0] - val[i][1]) != 1) {puts("No"); return 0;}
		if (abs(val[i][1] - val[i][2]) != 1) {puts("No"); return 0;}
		a[i] = (val[i][1] + 1) / 3;
		if ((a[i] & 1) != (i & 1)) {puts("No"); return 0;}
		if (val[i][0] > val[i][1]) flag[i&1] ^= 1;
	}
	for (int i = 1; i <= n; ++i)
		if (!vis[i]) {
			w = 0, vis[i] = 1;
			for (v = i; !vis[v = a[v]];) vis[v] = 1, w ^= 1;
			flag[i&1^1] ^= w;
		}
	if (flag[0] || flag[1]) {puts("No"); return 0;}
	puts("Yes"); return 0;
}

Measured memory_bytes: 2176
#include <stdio.h>

int main()
{
    char S[4],temp;
    scanf("%s",S);

    int i = 0,length;
    while (S[i])
    {
        length = i;
        i++;
    }
    if (length == 2)temp = S[0],S[0] = S[2],S[2] = temp; 
    printf("%s",S);
}


Measured memory_bytes: 128
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	int ans = 0;
	int tmp;
	int h, a;
	cin >> h >> a;
	
	cout << (h+ a- 1)/ a << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
 
#define rep(i,n) for (int i = 0; i < (n); ++i)
  
int n, a, b, friends[100005], fri, maxi;

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

  std::cin >> n;
  rep(i,n) {
    std::cin >> a >> b;
    a--; b--;
    for (int i = a; i <= b; ++i) friends[i]++;
  }
  rep(i,n+1) {
    if (friends[i] >= i) {
        maxi = i;
    }
  }

  std::cout << maxi << std::endl;

  return 0;
}

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

int main() {
  int N, A, B, X;
  cin >> N >> A >> B;
  
  X = N * A;
  if(X > B){
    cout << B << endl;
  }
  else{
    cout << X << endl;
  }
}
 
 


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<vector>
using namespace std;
 
template <class T> using V = vector<T>;
 
using ll = long long;
using bl = bool;
using vll = V<ll>;
using vbl = V<bl>;
 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  int q;
    cin>>q;
  vector<bool> A(100100,true);
  for(int i=2;i<=100010;i++){
    int up=sqrt(i)+1;
    for(int j=2;j<up;j++){
      if(i%j==0){
         A[i]=false;
        break;
      }
    }
  }

  vector<int> B(100100);
  for(int i=3;i<=100010;i+=2){
    B[i]=B[i-2];
    if(A[i]&&A[(i+1)/2]){
      B[i]++;
    }
  }
  for(int i=0;i<q;i++){
    int l,r;
      scanf("%d%d",&l,&r);
    if(l==1){
      l+=2;
    }
    printf("%d\n",B[r]-B[l-2]);
  }
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define ph push
#define ptc putchar
#define enter putchar('\n')
#define mod 998244353
using namespace std;
typedef pair<int,int> pii;
typedef double db;
typedef long double ldb;
typedef long long ll;
typedef long long lnt;
inline int read(){
	int x = 0;char c = getchar();
	while (!isdigit(c)) c = getchar();
	while (isdigit(c)) x = (x << 1) + (x << 3) + c - '0' , c = getchar();
	return x;
}
inline void write(int x){
	if (!x){
       ptc('0');
       return;
	}
	int dg[20] , len = 0;
	while (x) dg[len++] = x % 10 , x /= 10;
	while (len--) ptc(dg[len]+'0');
}
inline void writeln(int x){
	write(x);
	ptc('\n');
}
inline int add(int x,int y){
	x += y;if (x >= mod) x -= mod;
	return x;
}
inline int sub(int x,int y){
	x -= y;if (x < 0) x += mod;
	return x;
}
inline int qpow(int x,int y){
	int res = 1;
	while (y){
		if (y & 1) res = 1ll * res * x % mod;
		x = 1ll * x * x % mod;y >>= 1;
	}
	return res;
}
const int N = 1e5 + 10;
int n , a[N] , all , x;

int main(){
	scanf("%d%d",&n,&all);	
	for (int i = 1;i <= n;i++){
		scanf("%d",a + i);
	}
	sort(a + 1 , a + 1 + n);
	for (int i = 1;i <= n;i++){
		if ( (i != n && all >= a[i]) || (i == n && all == a[n])){
			x++;
			all -= a[i];
		}
	}
	
	cout<<x<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin >> a  >> b;
  int sum=0;
  if(a>b){sum=a; a--;}
  else {sum=b; b--;}
  if(a>b)sum+=a;
  else sum+=b;
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
int main(){
	long long i,n,mn;
	cin >> n;
	mn = n + 2;
	for(i=1;i*i<=n;i++){
		if(n%i==0){
			mn = min(mn,i + n/i - 2);
		}
	}
	cout << mn << endl;
}

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

int main(){
    int N;
    cin >> N;
    int A[210];
    for (int i=0; i<N;i++){
        cin >> A[i];
    }
    int count=0;
    bool even=true;
    while(1){
        for (int i=0; i<N; i++){
            if (A[i]%2==1){
                even=false;
            }
        }
        if (!even) break;
        for (int i=0; i<N; i++){
            A[i]/=2;
        }
        count++;
    }
    cout << count << endl;
}


Measured memory_bytes: 256
def main() -> None:
    A, B = map(int, input().split())
    A = A + 13 if A == 1 else A
    B = B + 13 if B == 1 else B
    if A > B:
        print("Alice")
    elif A < B:
        print("Bob")
    else:
        print("Draw")


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;

bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}

int main(){
  
  int n;
  cin>>n;
  int ans = (n-1)/2;
  cout<<ans<<endl;
      
  return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import heapq


class Tuple:
    def __init__(self, cost, y, x, dir):
        self.cost = cost
        self.y = y
        self.x = x
        self.dir = dir


    def __cmp__(self, other):
        return self.cost - other.cost


dir_x = [1, 0, -1, 0]
dir_y = [0, 1, 0, -1]


def solve():
    X, Y = map(int, raw_input().split())
    if X == 0 and Y == 0:
        return -1

    stage = [map(int, raw_input().split()) for _ in range(Y)]
    C = map(int, raw_input().split())

    costs = [[[float("inf") for _ in xrange(4)] for _ in xrange(X)] for _ in xrange(Y)]

    costs[0][0][0] = 0
    queue = []

    heapq.heappush(queue, Tuple(0, 0, 0, 0))

    while len(queue) > 0:

        current = heapq.heappop(queue)
        if costs[current.y][current.x][current.dir] < current.cost:
            continue

        for operation in range(4):
            if operation == 0:
                # ????????? ?????£??´?????????

                next_dir = current.dir
            elif operation == 1:
                # ????????? ??????

                next_dir = (current.dir + 1) % 4
            elif operation == 2:
                # ????????? ?????¢

                next_dir = (current.dir + 2) % 4
            else:
                # ????????? ??????

                next_dir = (current.dir + 3) % 4
            # ????????? ??´????????????????????¢?????????????????????????????????????????\???????????¢??????????????????????????§???????????????

            next_x = current.x + dir_x[next_dir]
            next_y = current.y + dir_y[next_dir]
            next_cost = costs[current.y][current.x][current.dir]
            if stage[current.y][current.x] != operation:
                next_cost += C[operation]
            if 0 <= next_x < X and 0 <= next_y < Y:
                if costs[next_y][next_x][next_dir] > next_cost:
                    costs[next_y][next_x][next_dir] = next_cost
                    data = Tuple(next_cost, next_y, next_x, next_dir)
                    heapq.heappush(queue, data)

    return min(costs[Y - 1][X - 1])


if __name__ == '__main__':
    while True:
        result = solve()
        if result < 0:
            break

        print result

Measured memory_bytes: 5592
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    x,y = LI()
    r = 0
    while x <= y:
        x *= 2
        r += 1

    return r



print(main())




Measured memory_bytes: 8136