akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;
using ll = long long;

int chack(int n){
    int cnt = 0;
    for(; n % 2 == 0; cnt++, n /= 2);
    return cnt;
}

int main()
{
    int n;
    cin >> n;
    int nax = 0;
    int ans = 1;
    for(int i = 1; i <= n; i++){
        if(chack(i) > nax){
            nax = chack(i);
            ans = i;
        }
    }
    cout << ans << endl;
}

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


using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cout(n) cout<<fixed<<setprecision(n)

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

    ll n;
    cin>>n;
    vector<vector<P>> v(n+1);

    FOR(i,0,n-1){
      ll in1,in2,c;
      cin>>in1>>in2>>c;
      v[in1].emplace_back(P(in2,c));
      v[in2].emplace_back(P(in1,c));
    }

    vector<ll> used(n+1,-1);
    deque<ll> que;
    que.push_back(1);
    used[1] = 0;
    while(!que.empty()){
      ll edge = que.front();
      que.pop_front();
      FOR(i,0,v[edge].size()){
       ll to = v[edge][i].first;
       ll co = v[edge][i].second;
        if(used[to]==-1){
          used[to] = used[edge] + co;
          que.push_back(to);
        }
      }
    }

    FOR(i,1,n+1){
      cout<<used[i]%2<<endl;
    }
}


Measured memory_bytes: 8704
fun main(args: Array<String>) {
    val N = nextInt()
    val A = listOfInt()
    var sum = 0L
    var min = Int.MAX_VALUE
    var fu = 0
    A.forEachIndexed { index, a ->
        var b: Int
        if (a < 0) { fu += 1; b = -a }
        else b = a
        sum += b
        if (min > b) min = b
    }
    val ans = if (fu % 2 == 1) sum - min * 2 else sum
    println(ans)
}
fun next() = readLine()!!
fun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)

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

int main() {
    int n;
    cin>>n;
    vector<int>p(n);
    for(int i=0;i<n;i++) cin>>p.at(i);
    
    sort(p.begin(),p.end());
    if(n%2==0){
        cout<<p.at(n/2)-p.at(n/2-1);
    }
    else{
        cout<<"1"<<endl;
    }

    
}


Measured memory_bytes: 3748
from itertools import chain
N, K = map(int, input().split())
S = input()
LS = []
pre = S[0]
ctr = 0
for s in chain(S, '2'):
    if s == pre:
        ctr += 1
    else:
        LS.append(ctr)
        ctr = 1
        pre = s
if S[0] == '0':
    LS = [0] + LS
if S[-1] == '0':
    LS = LS + [0]
ans = 0
sumi = 0
for i in range(len(LS)):
    if i <= 2*K:
        sumi += LS[i]
    else:
        sumi += LS[i] - LS[i-2*K-1]
    if not i % 2:
        ans = max(ans, sumi)
print(ans)

Measured memory_bytes: 4980
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

void insert(int);
void inorder(Node);
void preorder(Node);
Node  find(Node,int);

Node root;

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  while(x!=NIL){
    y=x;
    if(z->key < x->key){
    x = x->left;
    }
    else {
      x = x->right;
    }
  }
  z->parent=y;
  if(y==NIL){
    root=z;
  }
  else {if(z->key < y->key){
      y->left = z;
    }else {y->right = z;
    }
  }
}

void inorder(Node u){
  if(u==NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node u){
  if(u==NIL)return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}
Node find(Node u,int k){
  while(u!=NIL && k!=u->key){
    if(k<u->key)
      u=u->left;
    else
      u=u->right;
  }
  return u;
}

int main(){
  int n, i, a;
  char com[20];
  Node u;
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'i' ){
      scanf("%d", &a);
      insert(a);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
    else if ( com[0] == 'f' ){
      scanf("%d", &a);
      u=find(root,a);
      if(u!=NIL)printf("yes\n");
      else printf("no\n");
    }
  }

  return 0;
}



Measured memory_bytes: 20540
{-# LANGUAGE CPP                 #-}
{-# LANGUAGE DataKinds           #-}
{-# LANGUAGE KindSignatures      #-}
{-# LANGUAGE ScopedTypeVariables #-}

import           Control.Applicative
import           Data.Int
import           Data.Proxy
import           GHC.TypeLits

main :: IO ()
main = do
    [m, n] <- map read.words <$> getLine :: IO [Int]
    print $ (fromIntegral m :: IntMod) ^ n

type IntMod = GF (1000000007 :: Nat)

newtype GF (p :: Nat) = GF{ unGF :: Int64 } deriving Eq

modulus :: forall p. (KnownNat p) => GF p -> Int64
modulus _ = fromIntegral $ natVal (Proxy :: Proxy p)
{-# INLINE modulus #-}

instance Show (GF p) where
    show = show . unGF

instance (KnownNat p) => Num (GF p) where
    x + y = case modulus x of { m ->
            case unGF x + unGF y of { xy ->
                if xy < m then GF xy else GF (xy - m)
            }}
    x - y = case unGF x - unGF y of { xy ->
                if xy >= 0 then GF xy else GF (xy + modulus x)
            }
    x * y = GF $ unGF x * unGF y `rem` modulus x
    abs = fromIntegral . unGF
    signum = id
    fromInteger x = GF . fromIntegral $ x `mod` natVal (Proxy :: Proxy p)

Measured memory_bytes: 3708
#include<bits/stdc++.h>
#define rep(i, n) for (ll i=0;i<(n);i++)
using namespace std;
#define vecout(v) for(int i=0;i<v.size();i++) {cout<<v[i]<<endl;}
typedef long long ll;

int k, n;
bool counter(string s, char c){
    rep(i, s.size()){
        if (s[i]==c) {
            return true;
        }
    }
    return false;
}
int dfs(string s){
    int ans=0;
    ll si = stoll(s);
    if (si>n) return 0;
    if(counter(s, '3')==true&&counter(s, '5')==true&&counter(s, '7')==true) ans++;
    string a=s; 
    string b=s;
    string c=s;
    a.push_back('3');
    b.push_back('5');
    c.push_back('7');
    //cout<<a<<endl;
    //cout<<ans<<endl;
    ans+=dfs(a);
    ans+=dfs(b);
    ans+=dfs(c);
    return ans;
}
int main(void){
    cin>>n;
    string first;
    first.push_back('0');
    int ans=dfs(first);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <set>
#include <cstdio>
#include <cstring>
using namespace std;
int i,n,v[9999];
main(){for(;scanf("%d",&n),n;){
	set<int>s;
	for(memset(v,0,sizeof(v)),i=1;i<n;i++)s.insert(i*i%n);
	set<int>::iterator is,iS;
	for(is=s.begin();is!=s.end();is++)for(iS=is;++iS!=s.end();v[i>(n-1)/2?n-i:i]++)i=*iS-*is;
	for(i=1;i<=(n-1)/2;i++)printf("%d\n",v[i]*2);
}}

Measured memory_bytes: 1308
def bobbleSort(L, n):
  cnt = 0
  flag = True
  while flag:
    flag = False
    for i in range(n-1, 0, -1):
      if L[i] < L[i-1]:
        L[i], L[i-1] = L[i-1], L[i]
        flag = True
        cnt += 1
  return L, cnt

N = int(input())
A = list(map(int, input().split()))
A, t = bobbleSort(A, N)
print(' '.join(map(str, A)), t, sep='\n')


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

const int INF = 1e9;

int main() {
  int s;
  cin>>s;
  int ai = s;
  int m = 1;
  set<int> a;
  a.insert(ai);
  while (true) {
    ++m;
    if (ai % 2 == 0) {
      ai = ai / 2;
    } else {
      ai = 3 * ai + 1;
    }
    if (a.find(ai) != a.end()) {
      break;
    }
    a.insert(ai);
  }
  cout<<m<<endl;
}

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main()
{
int A, B;
	cin >> A >> B;
	ce(max(A-2*B,0))
    return 0;
}



Measured memory_bytes: 256
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
import itertools
from functools import *
from itertools import permutations,combinations,groupby
import sys
import bisect
import string
import math
import time
import random
def Golf():
    *a,=map(int,open(0))
def S_():
    return input()
def IS():
    return input().split()
def LS():
    return [i for i in input().split()]
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def NI(n):
    return [int(input()) for i in range(n)]
def NI_(n):
    return [int(input())-1 for i in range(n)]
def StoI():
    return [ord(i)-97 for i in input()]
def ItoS(nn):
    return chr(nn+97)
def LtoS(ls):
    return ''.join([chr(i+97) for i in ls])
def GI(V,E,Directed=False,index=0):
    org_inp=[]
    g=[[] for i in range(n)]
    for i in range(E):
        inp=LI()
        org_inp.append(inp)
        if index==0:
            inp[0]-=1
            inp[1]-=1
        if len(inp)==2:
            a,b=inp
            g[a].append(b)
            if not Directed:
                g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp
            aa=(inp[0],inp[2])
            bb=(inp[1],inp[2])
            g[a].append(bb)
            if not Directed:
                g[b].append(aa)
    return g,org_inp
def GGI(h,w,search=None,replacement_of_found='.',mp_def={'#':1,'.':0}):
#h,w,g,sg=GGI(h,w,search=['S','G'],replacement_of_found='.',mp_def={'#':1,'.':0}) # sample usage
    mp=[1]*(w+2)
    found={}
    for i in range(h):
        s=input()
        for char in search:
            if char in s:
                found[char]=((i+1)*(w+2)+s.index(char)+1)
                mp_def[char]=mp_def[replacement_of_found]
        mp+=[1]+[mp_def[j] for j in s]+[1]
    mp+=[1]*(w+2)
    return h+2,w+2,mp,found
def bit_combination(k,n=2):
    rt=[]
    for tb in range(n**k):
        s=[tb//(n**bt)%n for bt in range(k)]
        rt+=[s]
    return rt
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['YES','NO']

mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
u_alp=string.ascii_uppercase
ts=time.time()
#sys.setrecursionlimit(10**7)
input=lambda: sys.stdin.readline().rstrip()
 
def ran_input():
    import random
    n=random.randint(4,16)
    rmin,rmax=1,10
    a=[random.randint(rmin,rmax) for _ in range(n)]
    return n,a

show_flg=False
show_flg=True

ans=0

h,n=LI()
a=[]
ab=[]
for i in range(n):
    x,y=LI()
    ab.append((x,y))
ab.sort(key=lambda x:-x[0])
a=[i for i,j in ab]
b=[j for i,j in ab]
dp=[[0]+[inf]*(h) for i in range(n+1)]    
dp[0][0]=0

for i in range(n):
    for j in range(h+1):
        dp[i+1][min(h,j+a[i])]=min(dp[i+1][j]+b[i],dp[i+1][min(h,j+a[i])],dp[i][min(h,j+a[i])])

ans=dp[n][h]

print(ans)


Measured memory_bytes: 362884
n = int(input())
A = list(map(int, input().split()))
B = []
C = []
for i in range(n):
    if i % 2 == 0:
        B.append(A[i])
    else:
        C.append(A[i])
if len(B) > len(C):
    ans = list(reversed(B)) + C
    print(*ans)
else:
    ans = list(reversed(C)) + B
    print(*ans)

Measured memory_bytes: 26180
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

long double a[1000004];
signed main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);  
   
 #ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
 #endif
 
// -------------------------------------Code starts here---------------------------------------------------------------------     

   int n;
   long double k;
   cin>>k;
   cin>>n;
   for(int i=0;i<n;i++)
      cin>>a[i];
   long double mn=1e18;
   if(n==1)
   {
      cout<<0;
      return 0;
   }
   
   for(int i=0;i<n;i++)
   {
      if(a[(i+n-1)%n]>a[i])
         mn=min(mn,a[(i+n-1)%n]-a[i]);
      else
         mn=min(mn,k-(a[i]-a[(i+n-1)%n]));
   }
   cout<<mn;


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

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
const long long INF = 1LL << 60;
// const int INF=1010101010;
using Graph = vector<vector<int>>;

#define MAX_V 100010

struct edge {
  int to;
  long long cost;
};
typedef pair<long long, int> P;  // first は最短距離, second は頂点番号

vector<edge> tree[MAX_V];
long long d[MAX_V];
int n;

// s: 開始地点の頂点
void dijkstra(int s) {
  // greater<P> を指定することで first が小さい順に取り出せるようにする
  priority_queue<P, vector<P>, greater<P>> que;
  fill(d, d + n, INF);
  d[s] = 0;
  que.push(P(0, s));

  while (!que.empty()) {
    P p = que.top();
    que.pop();
    int v = p.second;
    if (d[v] < p.first) {
      continue;
    }
    for (int i = 0; i < tree[v].size(); i++) {
      edge e = tree[v][i];
      if (d[e.to] > d[v] + e.cost) {
        d[e.to] = d[v] + e.cost;
        que.push(P(d[e.to], e.to));
      }
    }
  }
}

int main() {
  cin >> n;

  for (int i = 0; i < n - 1; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    tree[a].push_back(edge{b, c});
    tree[b].push_back(edge{a, c});
  }
  int q, k;
  cin >> q >> k;
  dijkstra(k - 1);
  for (int i = 0; i < q; i++) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    cout << d[x] + d[y] << endl;
  }
  return 0;
}

Measured memory_bytes: 11120
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();
    
    for (int i = 1; i <= B; i++) {
      if ((A*i) % B == C) {
        System.out.println("YES");
        return;
      }
    }
    System.out.println("NO");
  }
}

Measured memory_bytes: 23252
import sys

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

line_max = []
for i in range(len(c)):
    line_max.append(max(c[i]))

flag = False

for i in range(line_max[0] + 1):
    for j in range(line_max[1] + 1):
        for k in range(line_max[2] + 1):
            cnt = 0
            for l in range(3):
                x = c[0][l] - i
                y = c[1][l] - j
                z = c[2][l] - k
                if x >= 0 and y >= 0 and z >= 0:
                    if x == y and y == z and z == x:
                        cnt += 1
            
            if cnt == 3:
                flag = True

print("Yes") if flag else print("No")

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

template <typename T>
using GPQ = priority_queue<T, vector<T>, greater<T>>;

void solve(){
    int n;
    cin >> n;
    ll ans = 0;
    vector<pair<int, int>> A, B;
    for (int i = 0; i < n; ++i) {
        int k, l, r;
        cin >> k >> l >> r;
        ans += max(l, r);
        if(l > r) A.emplace_back(k, l-r);
        else B.emplace_back(n-k, r-l);
    }
    sort(A.begin(),A.end());
    sort(B.begin(),B.end());
    GPQ<int> s;
    for (auto &&e : A) {
        s.emplace(e.second);
        while(s.size() > e.first){
            ans -= s.top();
            s.pop();
        }
    }
    while(!s.empty()) s.pop();
    for (auto &&e : B) {
        s.emplace(e.second);
        while(s.size() > e.first){
            ans -= s.top();
            s.pop();
        }
    }
    cout << ans << "\n";
}

int main() {
    int t;
    cin >> t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 5596
package main

import (
  "fmt"
)

func main(){
  
  var P, Q, R int
  
  fmt.Scan(&P)
  fmt.Scan(&Q)
  fmt.Scan(&R)
  
  if(( P >= Q) && ( P >= R)){
    fmt.Print(Q + R)
  } else if (( Q >= P) && (Q >= R)){
    fmt.Print(P + R)
  } else if (( R >= P) && (R >= Q)){
    fmt.Print(Q + P)
  } 
}

Measured memory_bytes: 512
/**
**	author : Raghav
**	codechef:raghav_456
**	codeforces:raghavramola7
**/
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define endl            "\n"
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define deb(x)          cout<<#x<<" "<<x<<endl
#define ar 				array
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void Raghav()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
bool compare(pair<int, int>&a, pair<int, int>&b)
{
	return a.first < b.first;
}
int cb(int number)
{
	return (int)log2(number) + 1;
}
int32_t main()
{
	Raghav();
	int n;
	cin >> n;
	if (n < 600)
		cout << 8;
	else if (n < 800)
		cout << 7;
	else if (n < 1000)
		cout << 6;
	else if (n < 1200)
		cout << 5;
	else if (n < 1400)
		cout << 4;
	else if (n < 1600)
		cout << 3;
	else if (n < 1800)
		cout << 2;
	else
		cout << 1;

	return 0;
}

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

int const MAXN=100000, MAXE=100000;

int N, E;

std::vector<int> G[MAXN];

int L[MAXN];

int length(int v) {
  if(L[v]>= 0) return L[v];
  int ret=0;
  for(auto it=G[v].begin(); it!=G[v].end(); ++it) {
    ret = std::max(ret, length(*it));
  }
  return L[v] = ret+1;
}

int main() {
  std::cin >> N >> E;

  std::fill(L, L+N, 0);
  for(int i = 0; i < E; ++i) {
    int x, y;
    std::cin >> x >> y;
    G[x-1].push_back(y-1);
    L[x-1] = -1;
  }
  int ret = 0;
  for(int i = 0; i < N; ++i) {
    ret = std::max(ret, length(i));
  }
  std::cout << ret << std::endl;
  return 0;
}


Measured memory_bytes: 8192
#include<iostream>
#include <string.h>
#include <algorithm>
#include <string>
using namespace std;

int gcd( int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	// ユークリッドの方法
	while( m != n )
	{
		if ( m > n ) m = m - n;
		else         n = n - m;
	}
	return m;
}//gcd
int main()
{
    int n,k;
    cin >> n >> k;
    string s;
    cin >> s;

    for(int i = 0;i < n;i++)
    {        
        if(i == k-1)
        {
            s[i] = s[i]+32;
        }
    }

        cout << s << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long a = sc.nextLong();
        long b = sc.nextLong();
        long min_blue = a * (n / (a + b));
        if (n % (a + b) <= a) {
            System.out.println(min_blue + n % (a + b));
        } else {
            System.out.println(min_blue + a);
        }
        sc.close();
    }
}

Measured memory_bytes: 23892
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define PB_VEC(Itr1,Itr2) (Itr1).insert((Itr1).end(),(Itr2).begin(),(Itr2).end())
typedef long long ll;


int main(){

    while(true){
        int n,m;
        cin>>n>>m;
        if(n==0&&m==0)break;
        
        map<string,ll> tosen;
        REP(i,n){
            string s;
            ll cost;
            cin>>s>>cost;
            tosen[s]=cost;
        }
        
        ll ans=0;
        REP(i,m){
            string s;
            cin>>s;
            for(auto itr=tosen.begin();itr!=tosen.end();itr++){
                string tos=itr->first;
                REP(j,tos.size()){
                    if(tos[j]!='*'&&tos[j]!=s[j])goto nextf;
                }
                ans+=itr->second;
            nextf:;
            }
        }
        
        cout<<ans<<endl;
        
    }
    
    return 0;
}

Measured memory_bytes: 3012
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, A, B):
    return '%d %d'%(min(A, B), max((A+B)-N, 0) )


def main():
    # N = read_int()
    N, A, B = read_int_n()
    print(slv(N, A, B))


if __name__ == '__main__':
    main()


Measured memory_bytes: 7868
#include<bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<=(b);++i)
#define DEC(i,a,b) for(int i=(a);i>=(b);--i)
#define DEBUG(x) cerr<<#x" == "<<x<<endl
using namespace std;
int n,m,x,a,b;
int main(){
	cin>>n>>m>>x;
	REP(i,1,m){
		int k;cin>>k;
		if(k<x)++a;if(k>x)++b;
	}
	cout<<min(a,b)<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;


int main() {
  ios_base::sync_with_stdio(false);
  int X, A, B;
  cin >> X >> A >> B;
  cout << min(X * A, B);
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
    int n;
    cin >> n;
    int a[n+1];
    for(int i=0;i<n;i++)cin >> a[i+1];

    bool check[n+1];
    for(int i=0;i<n;i++)check[i+1] = false;

    int pointer = 1;
    int ans = 0;
    while(pointer != 2){
        //cout << pointer << "->";
        ans++;
        check[pointer] = true;
        pointer = a[pointer];
        //cout << pointer << ":" << ans << endl;;
        if(check[pointer]){
            cout << "-1" << endl;
            return 0;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 768
n, m = map(int, input().split())

if n % 2 or m < n//4:
  for i in range(m):
    print(i+1, n-i)
else:
  for i in range(n//4):
    print(i+1, n-i)
  for i in range(n//4, m):
    print(i+1, n-i-1)

Measured memory_bytes: 9136
import heapq
from collections import defaultdict as dd
from bisect import bisect_left
N, M, S = map(int, input().split())
costs = dd(dict)
times = dd(dict)
MAX = 0
for _ in range(M):
    u, v, a, b = map(int, input().split())
    MAX += a
    costs[u][v] = costs[v][u] = a
    times[u][v] = times[v][u] = b
Cs = [0]
Ds = [0]
for _ in range(N):
    c, d = map(int, input().split())
    Cs.append(c)
    Ds.append(d)

thres = [[] for _ in range(N+1)]
vals = [[] for _ in range(N+1)]

q = []
heapq.heappush(q, (0, 1, S))
while q:
    if all(thres):
        break
    c, i, m = heapq.heappop(q)
    if thres[i] and thres[i][-1] >= m:
        continue
    thres[i].append(m)
    vals[i].append(c)
    for to in costs[i].keys():
        cost = costs[i][to]
        t = times[i][to]
        if m >= cost:
            heapq.heappush(q, (c+t, to, m-cost))

    if m < MAX:
        heapq.heappush(q, (c+Ds[i], i, m+Cs[i]))

for i in range(2, N+1):
    print(vals[i][0])

Measured memory_bytes: 83664
s = input()
n = int(s[0])*100 + int(s[1])*10 + int(s[2])
for i in range(1, len(s)-2):
    if abs(753-n) > abs(753-(int(s[i])*100 + int(s[i+1])*10 + int(s[i+2]))):
        n = int(s[i])*100 + int(s[i+1])*10 + int(s[i+2])
print(abs(753-n))

Measured memory_bytes: 38256
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
 
using namespace std;
typedef long long ll;
 
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
long long int mod = 998244353;
// memset(a,0,sizeof(a)); →全部０にする
 
vector<ll> G[100005];
vector<P> tree[100010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
//↓,→,↑,←
 
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,a,b) for(i=a;i<=b;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl

ll rui(ll abc,ll bed){
	//aのb乗を計算する
	if(bed==0){return 1;}
	else{
		ll ced = rui(abc,bed/2);
		ced *= ced;
		ced %= mod;
		if(bed%2==1){ced*=abc; ced%=mod;}
		return ced;
	}
} 

ll i,j,k,ii,jj;
ll n,m,num,sumxor,sum,ans;
ll a,b,c,d,e,f,g,h,w,v;
//ll x[800005],y[800005],z[900005];
ll d1[500005],d2[500005],d3[500005],d4[500005];
ll dp[1000][1000];

int main(){	
	cin>>h>>w;
	for(i=0;i<h;i++){
		for(j=0;j<w;j++){
			cin >> dp[i][j];
		}
	}
	for(i=0;i<h;i++){
		for(j=0;j<w;j++){
			if(dp[i][j]%2==1){			
				if(j<w-1){
					d1[num] = i;
					d2[num] = j;
					d3[num] = i;
					d4[num] = j+1;
					dp[i][j]--;
					dp[i][j+1]++;
					num++;
				}else if(i<h-1){
					d1[num] = i;
					d2[num] = j;
					d3[num] = i+1;
					d4[num] = j;
					dp[i][j]--;
					dp[i+1][j]++;
					num++;
				}
			}
		}
	}


				
	//assert(num <= h*w);
	p(num);
	for(i=0;i<num;i++){
		pe(d1[i]+1);pe(d2[i]+1);pe(d3[i]+1);p(d4[i]+1);
	}

	
	return 0;
}

Measured memory_bytes: 28160
#include <bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin>>s;
  string ans;
  int j=-1;
  for(int i=0;i<s.length();i++)
  {
    if(s[i]=='B' && ans.length()!=0)
    {
      ans.pop_back();
    }
    else if(s[i]=='0' ||s[i]=='1')
    {
      ans.push_back(s[i]);
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		Stack<String> stack = new Stack<String>();
		String s2 = ".";
		boolean flag = true;
		while(true){
			String s = sc.nextLine();
			if(s.equals(".") && s2.charAt(s2.length()-1) == '.') break;
			for(int i = 0; i < s.length(); i++){
				if(s.charAt(i) == '['){
					stack.push("[");
				}else if(s.charAt(i) == ']'){
					if(stack.empty()){
						flag = false;
						continue;
					}
					String a = stack.pop();
					if(!a.equals("[")){
						flag = false;
					}
				}else if(s.charAt(i) == '('){
					stack.push("(");
				}else if(s.charAt(i) == ')'){
					if(stack.empty()){
						flag = false;
						continue;
					}
					String a = stack.pop();
					if(!a.equals("(")){
						flag = false;
					}
				}else if(s.charAt(i) == '.'){
					if(!stack.empty()) flag = false;
					if(flag) System.out.println("yes");
					else System.out.println("no");
					flag = true;
					stack.clear();
				}
			}
			s2 = s;
		}
	}
}

Measured memory_bytes: 45728
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
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; }



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

  cout << (N-(int)(N/2))/N << endl;
  

}



Measured memory_bytes: 256
import bisect
N = int(input())
L = list(map(int, input().split()))
L.sort()

res = 0
# l[i] >= l[j] > p
# a = 
for i in range(2, N):
    cnt = 0
    for j in range(i):
        p = L[i] - L[j]
        k = bisect.bisect_right(L, p)
        cnt += i - k
        if k <= j:
          cnt -= 1
    res += cnt
print(res//2)

Measured memory_bytes: 43100
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define rrep(i, n) for(int i = (int)(n); i>=0; --i)
struct fast_ios { fast_ios(){cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast_ios_;

int main()
{
    string s, t;
    cin >> s >> t;
    if(s.size() +1 != t.size())
    {
        cout << "No" << endl;
        return 0;
    }

    rep(i, s.size())
    {
        if(s[i]!=t[i])
        {
            cout << "No" << endl;
            return 0;
        }
    }

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

Measured memory_bytes: 3672
function main(input){
  input = input.split("\n");
  var n = parseInt(input[0]);

  var a = input[1].split(" ").map(x => parseInt(x))

  //console.log(a);


  var tama = [];
  var answer = [];
  var hanbun = Math.floor(n / 2);

// tamaは0が値なしになる
  for (var i = n; i > hanbun; i--){
    tama[i] = a[i-1];
    if (tama[i] == 1) {
      answer.push(i);
    }
  }

  for (var i = hanbun; i>0; i--){
    var hantei = a[i-1];
    for (var j = 2; i*j <= n; j++){
      hantei += tama[i*j];
    }
    tama[i] = hantei%2;
    if (tama[i] == 1) {
      answer.push(i);
    }
  }

//console.log(tama);
//console.log(answer);

console.log(answer.length);
for (var i = 0; i < answer.length; i++) {
  process.stdout.write(answer[i]+" ");
}



}
 
 
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 30288
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size() 

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

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

	x=c;
	x++;
	cout<<(char)x<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
using vp = vector<pii>;
using vi = vector<int>;

int main () {

  int probqtd, kindsofdrink, probp, newsec;
  vi sectosolve {0};
  vi secaux {0};
  cin >> probqtd;
  while (probqtd--) {
    int aux;
    cin >> aux;
    sectosolve.push_back(aux);
  }
  cin >> kindsofdrink;
  while (kindsofdrink--) {
    secaux = sectosolve;
    cin >> probp >> newsec;
    secaux[probp] = newsec;
    cout << std::accumulate(secaux.begin(), secaux.end(), 0) << endl;
    secaux.clear();
  }

  return 0;
}


Measured memory_bytes: 256
import bisect

N = int(input())
A = list(map(int,input().split()))
assert len(A) == N
A.sort()
largest = A[-1]

acum = [0] * N
acum[0] = A[0]
for i in range(1, N):
    acum[i] = A[i] + acum[i-1]


def solve():
    unreachable = None
    for i in range(N-2,-1,-1):
        bi = bisect.bisect(A, 2*A[i])
        if 2*acum[bi-1] < A[i+1]:
            unreachable = i
            break
    if unreachable is None:
        return N
    return N - unreachable - 1


print(solve())

Measured memory_bytes: 63856
'use strict';

const main = arg => {
    const input = arg.trim().split('\n');		//Each line (l) of input is input[l]

    let ans = [], words;

    words = input[1].split(' ');

    for (var i = 0; i < Number(input[0]); i++) {

        ans.push(words[0].charAt(i));
        ans.push(words[1].charAt(i));
    }

    console.log(ans.join(''));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include <iostream>
 #include <complex>
 #include <stdio.h>
 #include<cmath>
 using namespace std;
 typedef complex<double>xy_t;
 xy_t P[110];

 double cross_product(xy_t a, xy_t b) //??????
 { return (conj(a) * b).imag(); }

int main(){
    int n=0;
    double x,y,sum=0.0;
    while(scanf("%lf,%lf",&x,&y)!=EOF)
        {
            P[n++]=xy_t(x,y);
        }
    for(int i=0;i+2<n;i++)
        {
            xy_t a=P[0],b=P[i+1],c=P[i+2];
            sum+=cross_product(b-a,c-a);
        }
        cout<<sum/2<<endl;
 }

Measured memory_bytes: 3260
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int numH = scan.nextInt();
		int numW = scan.nextInt();

		char[][] charBef = new char[numH + 2][numW + 2];

		for (int j = 0; j <= numW + 1; j++) {
			charBef[0][j] = '.';
			charBef[numH + 1][j] = '.';
		}

		for (int i = 1; i <= numH; i++) {
			StringBuilder strSB = new StringBuilder();
			strSB.append(".");
			strSB.append(scan.next());
			strSB.append(".");
			charBef[i] = strSB.toString().toCharArray();
		}

		String result = "Yes";

		for (int i = 1; i <= numH; i++) {
			for (int j = 1; j <= numW; j++) {

				if (charBef[i][j] == '#') {
					if (charBef[i - 1][j] == '#' || charBef[i][j - 1] == '#' || charBef[i + 1][j] == '#'
							|| charBef[i][j + 1] == '#') {
						continue;
					} else {
						result = "No";
					}
				}
			}
		}

		System.out.println(result);
	}
}


Measured memory_bytes: 21716
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
using namespace std;
void solve()
{
    ll n,m,k;
    cin>>n>>m>>k;
    vector<ll>arr(n),brr(m);
    for(int i=0;i<n;++i)
    {
        cin>>arr[i];
        if(i) arr[i]+=arr[i-1];
    }
    for(int i=0;i<m;++i)
    {
        cin>>brr[i];
        if(i) brr[i]+=brr[i-1];
    }
    int st1=upper_bound(arr.begin(),arr.end(),k)-arr.begin();
    int st2=upper_bound(brr.begin(),brr.end(),k)-brr.begin();
    int book=max(st1,st2);
    for(int i=0;i<n;++i)
    {
        if(arr[i]>k)
        {
            break;
        }
        else
        {
            int rem=k-arr[i];
            int st2= upper_bound(brr.begin(),brr.end(),rem)-brr.begin();
            //cout<<st2<<' '<<i<<endl;
            book=max(book,i+st2+1);
        }
    }
    cout<<book<<endl;
}

int main()
{
    fast;
    int t;
    solve();
}


Measured memory_bytes: 6372
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
int main()
{
    int n,k;
    char c;
    string str;
    cin>>n>>k;
    cin>>str;
    str[k-1]=tolower(str[k-1]);
    cout<<str<<endl;
    return 0;
    
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

string s;
int K;
int main() {
    cin >> s >> K;
    for(int i = 0; i < s.size(); i++) {
        int dist = 26 - (s[i] - 'a');
        if(s[i] != 'a' && dist <= K) {
            K -= dist;
            s[i] = 'a';
        }
    }
    s[s.size()-1] = ((s[s.size()-1]-'a' + K)%26) + 'a';
    cout << s << "\n";
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <math.h>
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i = 1; i <= (n); ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (ll)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
ll gcd(ll a,ll b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const int INF=1e9;
const ll MX = 1e18;
const int MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);
 
int main() {
  v(bool) s(200001),t(200001);
  int n,m;
  cin>>n>>m;
  rep(i,m){
    int a,b;
    cin>>a>>b;
    if(a==1) s[b]=true;
    if(b==n) t[a]=true;
  }
  bool ja=false;
  rep(i,200001){
    if(s[i]&&t[i]) ja=true;    
  }
  if(ja) cout<<"POSSIBLE"<<endl;
  else cout<<"IMPOSSIBLE"<<endl;
}

Measured memory_bytes: 3680
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(int i=0;i<n;i++)
#define int long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define mod 1000000007
#define inf 1e15
#define key 1e9
using namespace std;
typedef pair<int, int>P;
void yes() { cout << "Yay!" << endl; }
void no() { cout << ":(" << endl; }
template<class T> inline void chmax(T& a, T b) {
	a = std::max(a, b);
}
template<class T> inline void chmin(T& a, T b) {
	a = std::min(a, b);
}
const int MAX = 330000;
int fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}
long long COMB(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y)* mod_pow(kai(y, y), mod - 2, mod) % mod;
}
void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
	cerr << " " << to_string(H);
	debug_out(T...);
}

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
struct edge { int to, cost; };
class UnionFind {
protected:
	int* par, * rank, * size;
public:
	UnionFind(unsigned int size) {
		par = new int[size];
		rank = new int[size];
		this->size = new int[size];
		rep(i, size) {
			par[i] = i;
			rank[i] = 0;
			this->size[i] = 1;
		}
	}
	int find(int n) {
		if (par[n] == n)return n;
		return par[n] = find(par[n]);
	}
	void unite(int n, int m) {
		n = find(n);
		m = find(m);
		if (n == m)return;
		if (rank[n] < rank[m]) {
			par[n] = m;
			size[m] += size[n];
		}
		else {
			par[m] = n;
			size[n] += size[m];
			if (rank[n] == rank[m])rank[n]++;
		}
	}
	bool same(int n, int m) {
		return find(n) == find(m);
	}
	int getsize(int n) {
		return size[find(n)];
	}
};
int n, h;
signed main() {
	cin >> h >> n;
	if (h % n == 0)cout << h / n << endl;
	else cout << h / n + 1 << endl;
	ggr
}


Measured memory_bytes: 256
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug1: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug2: "<<x<<" "<<y<<endl;
#define bug3(x, y, z) cout<<"zdongdebug3: "<<x<<" "<<y<<" "<<z<<endl;
using namespace std;
typedef long long ll;
const int maxn = 3005;
const int mod = 998244353;

int n,m;
int a[maxn];

ll f[maxn][maxn];

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  cin>>n>>m;
  ll ret = 0;
  for(int i=1;i<=n;i++)cin>>a[i];
  for(int i=1;i<=n;i++){
    if(a[i]<=m) {
      ret = (ret + (n - i + 1) * f[i - 1][m - a[i]]%mod)%mod;
      if(a[i]==m){
        ret = (ret + i * ll(n-i+1)%mod)%mod;
      }
    }
    for(int j=1;j<=m;j++){
      f[i][j] = f[i-1][j];
      if(j-a[i]>=1)f[i][j] = (f[i][j]+f[i-1][j-a[i]])%mod;
    }
    if(a[i]<=m)f[i][a[i]] = (f[i][a[i]] + i)%mod;
  }
  cout<<ret<<endl;
  return 0;
}

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

typedef long long ll;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define ANS(n) cout << (n) << endl

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(a);i>=(b);i--)

#define ALL(obj) (obj).begin(),(obj).end()

#define pii pair<int,int>

#define pb(a) push_back(a)
#define mp make_pair

int main()
{
	int n;
	cin >> n;
	int ans = 1;
	int lastA;
	cin >> lastA;
	int joutai = -1;	//unknown : -1 , increasing : 0 , decreasing : 1
	FOR(i,1,n){
		int a;
		cin >> a;
		if(lastA < a){
			if(joutai == 1){
				ans++;
				joutai = -1;
			}else if(joutai == -1){
				joutai = 0;
			}
		}else if(lastA > a){
			if(joutai == 0){
				ans++;
				joutai = -1;
			}else if(joutai == -1){
				joutai = 1;
			}
		}
		lastA = a;
	}
	ANS(ans);
	return 0;
}


Measured memory_bytes: 256
N,M = map(int,input().split())
A = [list(input()) for i in range(N)]
B = [list(input()) for i in range(M)]
ans = "No"
for i in range(N-M+1):
    for j in range(N-M+1):
        ans = "Yes"
        for k in range(M):
            for l in range(M):
                #print(i+k,j+l,k,l)
                if A[i+k][j+l] != B[k][l]:
                    ans = "No"
                    break
            if ans == "No":
                break
        if ans == "Yes":
            break
    else:
        continue
    break
print(ans)

Measured memory_bytes: 3064
import math
f = []
while True:
    try:
        st = input().strip().split(',')
        x,y = list(map(float,st ))
        f.append(x + y*1j)
    except EOFError:
        break

px = [p.real for p in f]
ox = (max(px) + min(px)) / 2.0

py = [p.imag for p in f]
oy = (max(py) + min(py)) / 2.0

fo = ox + oy * 1j

ss = 0.0
for i in range(len(f)):
    if i == len(f)-1:
        j = 0
    else:
        j = i + 1
    a = abs(f[i]-fo)
    b = abs(f[j]-fo)
    c = abs(f[j]-f[i])
    z = (a + b + c) / 2.0
    s = math.sqrt(z*(z-a)*(z-b)*(z-c))
    ss += s
print("%.6f" % ss)

Measured memory_bytes: 7516
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <map>

using namespace std;

int main()
{
    int a, b;
    long long int ans = 0;

    cin >> a >> b;

    if (abs(a-b) > 1) {
        ans = 0;
    }
    else {
        ans = 1;
        for (int i = 1; i <= a; i++) {
            ans *= i;
            ans %= 1000000007;
        }
        for (int i = 1; i <= b; i++) {
            ans *= i;
            ans %= 1000000007;
        }
        if (abs(a-b) == 0) {
            ans *= 2;
            ans %= 1000000007;
        }
    }

    cout << ans << endl;

}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;

int main()
{
	int n, m;
	char input[1000000];
	string str;

	scanf("%d %d", &n, &m);

	scanf("%s", input);
	str = input;

	vector<int> move;

	int loc = n;

	while (loc)
	{
		int lmax;

		lmax = loc - (loc - m > 0 ? loc - m : 0);

		int next;
		next = loc;

		for (int i = lmax; i >= 1; i--)
		{
			if (str[loc - i] == '0')
			{
				next = loc - i;

				break;
			}
		}

		if (next == loc)
		{
			printf("-1\n");

			return 0;
		}

		move.push_back(loc - next);

		loc = next;
	}

	for (int i = move.size() - 1; i >= 0; i--)
	{
		printf("%d ", move[i]);
	}

	printf("\n");

	return 0;
}

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

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	string s;
	cin >> s;
	int n = s.length(), cnt = 0;
	if (n == 1){
		cout << 0 << "\n";
	}else{
		for (int i = 0; i < n/2; ++i){
			if (s[i] != s[n-1-i]) ++cnt;
		}
		cout << cnt << "\n";
	}
	return 0;
}


Measured memory_bytes: 3632