akhauriyash/Code-Regression huggingface dataset:
#include <iostream> 
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mk make_pair
#define MAX 1000001
ll prime[MAX];
#define FAST           ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define gcd __gcd
ll rec(vector<vector<ll> >& dp,vector<ll>& arr,int n,int i,int k,int w)
{
  ll ans=0;
  if(i>=n)
    return 0;

  if(dp[i][k]!=-1)
    return dp[i][k];


  if(k!=0)
  ans=max(rec(dp,arr,n,i+1,w,w),arr[i]+rec(dp,arr,n,i+1,k-1,w));
  else
  ans=max(rec(dp,arr,n,i+1,k,w),rec(dp,arr,n,i+1,w,w));

  return dp[i][k]=ans;

}

//ll t[400008];
// void build(vector<ll>& a, int v, int tl, int tr) {
//     if (tl == tr) {
//         t[v] = a[tl];
//     } else {
//         int tm = (tl + tr) / 2;
//         build(a, v*2, tl, tm);
//         build(a, v*2+1, tm+1, tr);
//         t[v] = max(t[v*2] ,t[v*2+1]);
//     }
// }

// ll maxi(int v, int tl, int tr, int l, int r) {
//     if (l > r) 
//         return 0;
//     if (l == tl && r == tr) {
//         return t[v];
//     }
//     int tm = (tl + tr) / 2;
//     return max(maxi(v*2, tl, tm, l, min(r, tm)) ,maxi(v*2+1, tm+1, tr, max(l, tm+1), r));
// }



// void update(int v, int tl, int tr, int pos, ll new_val) {
//     if (tl == tr) {
//         t[v] = new_val;
//     } else {
//         int tm = (tl + tr) / 2;
//         if (pos <= tm)
//             update(v*2, tl, tm, pos, new_val);
//         else
//             update(v*2+1, tm+1, tr, pos, new_val);
//         t[v] = max(t[v*2] ,t[v*2+1]);
//     }
// }


struct hash_pair {
   template <class T1, class T2>
   size_t operator()(const pair<T1, T2>& p) const{
      auto hash1 = hash<T1>{}(p.first);
      auto hash2 = hash<T2>{}(p.second);
      return hash1 ^ hash2;
   }
};

ll rec(ll a[],ll first,ll last,int n)
{
  if(first>last)
    return 0;

  ll temp=1000000000;
  ll ind=0;
  for(ll i=first;i<=last;i++)
   {
    if(temp>a[i])
    {
      temp=a[i];
      ind=i;
    }
   }
   for(ll i=first;i<=last;i++)
    a[i]-=temp;


return min(last-first+1,(rec(a,first,ind-1,n)+rec(a,ind+1,last,n)+temp));

}
int temp[1000002]={0};

void sieve()
{
  temp[1]=1;
  for(int i=2;i<1000002;i++)
  {
    if(temp[i]==0)
    { temp[i]=i;
      for(int j=i*2;j<1000002;j+=i)
      { 
        if(temp[j]==0)
        temp[j]=i;
      }
    }
  }

}


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

unordered_map<string,int> h;

string s;
for(int i=0;i<n;i++)
{
  cin>>s;
  h[s]++;  
}

cout<<"AC x "<<h["AC"]<<"\n";
cout<<"WA x "<<h["WA"]<<"\n";
cout<<"TLE x "<<h["TLE"]<<"\n";
cout<<"RE x "<<h["RE"]<<"\n";


return 0;
}


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

int main(){
  int a, b;
  cin >> a >> b;
  
  if ((a%3==0) || (b%3==0) || ((a+b)%3==0))
    cout << "Possible" << endl;
  else 
    cout << "Impossible" << endl;   
  return 0;
}

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

int main(){
    int n, m, prev=0;
    long long ans=0;
    scanf("%d", &n);
    while(n--){
        scanf("%d", &m);
        if(!prev) prev = m;
        else{
            if(prev > m){
                ans+=prev-m;    
            }
            else{
                prev = m;
            }
        }
    }
    printf("%lld", ans);
    return 0;
}

Measured memory_bytes: 3756
n=int(input())
a,b=map(int,input().split())
for i in range(n-1):
    c,d=map(int,input().split())
    if a<=c and b<=d:
        a,b=c,d
    elif c<a and b<=d:
        a,b=c*(-(-a//c)),d*(-(-a//c))
    elif a<=c and d<b:
        a,b=c*(-(-b//d)),d*(-(-b//d))
    elif c<a and d<b:
        if -(-a//c) > -(-(b//d)):
            a,b=c*(-(-a//c)),d*(-(-a//c))
        elif -(a//c) < -(-(b//d)):
            a,b=c*(-(-b//d)),d*(-(-b//d))
print(a+b)

Measured memory_bytes: 3064
#include<stdio.h>
#include<string.h>
int main()
{
	int i, n, s,t, sum = 0;
	scanf("%d", &n);
	int box[n];
	memset(box, 0, sizeof(box));
	for (i = 0; i < n-1; i++) {
		scanf("%d", &s);
		box[s - 1]++;
	}

	for (i = 0; i < n; i++)
		printf("%d\n", box[i]);
	return 0;
}

Measured memory_bytes: 2928
#include <algorithm>
#include <cstdio>
#include <cstdlib>

using namespace std;

namespace{
    long score(long s1, long s2, long s3)
    {
        return max({s1, s2, s3}) - min({s1, s2, s3});
    }

    // 縦3分割
    long trivert(long /*h*/, long w)
    {
        return w;
    }

    // 縦分割してから横分割
    long verthoriz(long h, long w)
    {
        long score_min = 9999999999;

        for(long i = 1; i <= h-1; ++i){
            long s_a = w * i;
            // 等分
            long score_even = score(s_a, w/2 * (h-i), (w-w/2) * (h-i));
            // 等分から1ずらす
            long score_noteven = 9999999999;
            if(w >= 4)
                score_noteven = score(s_a, (w/2-1) * (h-i), (w-w/2+1) * (h-i));

            if(score_min > score_even) score_min = score_even;
            if(score_min > score_noteven) score_min = score_noteven;
        }

        return score_min;
    }

    long solve(long h, long w)
    {
        if((h%3) == 0 || (w%3) == 0) return 0;

        long tv = trivert(h, w);
        long th = trivert(w, h);

        long vh = verthoriz(h, w);
        long hv = verthoriz(w, h);

        return min({tv, th, vh, hv});
    }
}

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

    long answer = solve(h, w);
    printf("%ld\n", answer);

    return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int sum = 0;
		String string = String.valueOf(N);
		for(int i = 0; i < string.length(); i++) 
		{
			sum += Integer.parseInt( string.substring(i,i+1) ) ;
		}
		if( N % sum == 0)
			System.out.println("Yes");
		else 
			System.out.println("No");
	}

}


Measured memory_bytes: 23764
import math
import numpy as np
import copy
from collections import defaultdict, Counter
from itertools import product
from bisect import bisect_left, bisect_right

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

N = int(input())
h = inpl()

INF = float('inf')

# 最小化問題なのでINFに初期化
dp = [ INF for _ in range(100010) ]

# 初期状態
dp[0] = 0

# ループ
for i in range(1, N):
    dp[i] = min(dp[i], dp[i-1] + abs(h[i] - h[i-1]))
    if i > 1:
        dp[i] = min(dp[i], dp[i-2] + abs(h[i] - h[i-2]))

print(dp[N-1])

Measured memory_bytes: 22796
N = int(input())
len_min = 51
min_i = 51
S = []

for i in range(N):
    Si = input()
    if len_min > len(Si):
        min_i = i
        len_min = len(Si)
    S.append(Si)

# 一番文字数が少ないSiに含まれる文字をmemoに記録して、
# 他の文字列にも含まれているかどうかを確認していく。
# 同じ文字が複数入っている場合を考慮してa1,a2と数字をつける。
memo = {}
for char in S[min_i]:
    count_char = S[min_i].count(char)
    for i in range(1, count_char+1):
        char_num = char+str(i)
        memo[char_num] = 1

# print(memo)
# ->{'c1': 1, 'b1': 1, 'a1': 1, 'a2': 1}

del S[min_i]

for Si in S:
    checked_char = {}
    for char in Si:
        if char in checked_char:
            continue
        count_char = Si.count(char)
        for i in range(1, count_char+1):
            char_num = char+str(i)
            try:
                memo[char_num] += 1
            except:
                pass
        checked_char[char] = None


ans = []
for char in memo:
    if memo[char] == N:
        ans.append(char[0])

ans.sort()
print("".join(ans))


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

int main() {
	int N;
	double ans = 0;
	cin >> N;

	for (int i = 0; i < N; i++) {
		double x;
		string v;
		cin >> x >> v;
		if (v == "JPY") {
			ans += x;
		}
		else if (v == "BTC") {
			ans += x * 380000;
		}
	}

	cout << fixed << setprecision(4) << ans << endl;
}

Measured memory_bytes: 256
#include <string.h>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iomanip>

using namespace std;
#define INF 1e9
#define MAX 100005
#define MOD 1000000007
#define Q queue
#define PQ priority_queue
#define fr first
#define sc second
#define pb push_back
#define mp make_pair
#define FOR( i, L, U ) for(int i=(int)L ; i<(int)U ; i++ )
#define FORD( i, U, L ) for(int i=(int)U ; i>=(int)L ; i-- )
#define wa cout<<"Wa"<<endl
#define READ(filename)  freopen(filename, "r", stdin);
#define WRITE(filename)  freopen(filename, "w", stdout);

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int> > vvi;
typedef map<int, int> mii;
typedef map<string, int> msi;
typedef map<int, string> mis;
typedef map<int , vector<int> > mvi;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;

void base(){
	 ios_base::sync_with_stdio(false);
	 cin.tie(NULL);
}


int main(){
	base();
	int n,arr[MAX];
	cin>>n;
	FOR(i,0,n){
		cin>>arr[i];
	}
	sort(arr,arr+n);
	cout<<abs(arr[n-1] - arr[0])<<endl;
	return 0;
}



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

int main()
{
	int N, K;
	cin >> N >> K;
	int num = 0;
	int h = 0;
	for (int i = 0; i < N; i++) {
		cin >> h;
		if (h >= K) {
			num++;
		}
	}

	cout << num;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int h,w,i,a;
    
    while(1){
        scanf("%d%d",&h,&w);
        
        if(h==0 && w==0) break;
        
        for(i=1;i<=h;i++){
            
            printf("%c",'#');
            
            for(a=2;a<w;a++){
                if(i==1 || i==h){
                    printf("%c",'#');
                }else{
                    printf("%c",'.');
                }
            }
            printf("%c\n",'#');
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 1984
class Dice:
    def __init__(self, array):
        self.top = array[0]
        self.south = array[1]
        self.east = array[2]
        self.west = array[3]
        self.north = array[4]
        self.bottom = array[5]

    def roll_n(self):
        self.top, self.south, self.north, self.bottom = self.south, self.bottom, self.top, self.north

    def roll_s(self):
        self.top, self.south, self.north, self.bottom = self.north, self.top, self.bottom, self.south

    def roll_e(self):
        self.top, self.east, self.west, self.bottom = self.west, self.top, self.bottom, self.east

    def roll_w(self):
        self.top, self.east, self.west, self.bottom = self.east, self.bottom, self.top, self.west

    def IsEqual(self, dice2):
        if (self.top, self.south, self.east, self.west, self.north, self.bottom) == (dice2.top, dice2.south, dice2.east, dice2.west, dice2.north, dice2.bottom):
            return True
        else:
            return False

n = int(input())

n1 = list(map(int, input().split()))
dice_1 = Dice(n1)

flag = False

for i in range(n-1):
    a = list(map(int, input().split()))
    dice_a = Dice(a)
    for i in range(4):
        dice_1.roll_n()
        for j in range(4):
            dice_1.roll_e()
            if dice_1.IsEqual(dice_a):
                flag = True
                break

dice_1.roll_e()

for i in range(4):
    dice_1.roll_n()
    for i in range(4):
        dice_1.roll_e()
        if dice_1.IsEqual(dice_a):
            flag = True
            break



if flag:
    print('No')
else:
    print('Yes')


Measured memory_bytes: 5608
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;

vector<int> p[100001];
int main() {
	int N, M;
	cin >> N >> M;
	for (int i = 0; i < N; i++) {
		int A, B;
		cin >> A >> B;
		p[A].push_back(B);
	}
	ll ans = 0;
	priority_queue<ll> que;
	for (int i = 1; i <= M; i++) {
		for (int j : p[i]) que.push(j);
		if (!que.empty()) {
			ans += que.top();
			que.pop();
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 5632
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
    #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif
        

fast();
//ll t;cin>>t;while(t--)
{
    string s,t;
    cin>>s>>t;
    ll ans=INT_MAX;
    for(int i=0;i<=s.length()-t.length();i++)
    {
      ll c=0;
      for(int j=0;j<t.length();j++)
      {
        if(s[i+j]!=t[j])
          c++;
      }
      ans=min(ans,c);
    }
    cout<<ans<<endl;
}
return 0;
}

Measured memory_bytes: 3664
use std::io;
use std::cmp;


fn main() {
    let n = read_one::<usize>();
    let mut ans = 0;
    let mut sum = 0;
    for _ in 0..n {
        let p = read_one::<usize>();
        sum += p;
        ans = cmp::max(ans, p);
    }
    println!("{}", sum - ans / 2);
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4352
import java.util.Scanner;
public class Main {


    public static void main(String[] args) {


        Scanner scan = new Scanner(System.in);
long N=scan.nextLong();
int k=0;

for(int i=1;i<12;i++) {
if(26*(Math.pow(26,i-1)-1)/25<N&&N<=26*(Math.pow(26,i)-1)/25){k=i;}
}

for(int i=1;i<k;i++){N=N-(long)Math.pow(26,i);}
String M=Long.toString(N-1,26);
int U=k-M.length();
for(int i=0;i<U;i++){M="0"+M;}

        String p="";;

for(int i=0;i<k;i++){
    if(M.substring(i,i+1).equals("0")){p=p+"a";}
    if(M.substring(i,i+1).equals("1")){p=p+"b";}
    if(M.substring(i,i+1).equals("2")){p=p+"c";}
    if(M.substring(i,i+1).equals("3")){p=p+"d";}
    if(M.substring(i,i+1).equals("4")){p=p+"e";}
    if(M.substring(i,i+1).equals("5")){p=p+"f";}
    if(M.substring(i,i+1).equals("6")){p=p+"g";}
    if(M.substring(i,i+1).equals("7")){p=p+"h";}
    if(M.substring(i,i+1).equals("8")){p=p+"i";}
    if(M.substring(i,i+1).equals("9")){p=p+"j";}
    if(M.substring(i,i+1).equals("a")){p=p+"k";}
    if(M.substring(i,i+1).equals("b")){p=p+"l";}
    if(M.substring(i,i+1).equals("c")){p=p+"m";}
    if(M.substring(i,i+1).equals("d")){p=p+"n";}
    if(M.substring(i,i+1).equals("e")){p=p+"o";}
    if(M.substring(i,i+1).equals("f")){p=p+"p";}
    if(M.substring(i,i+1).equals("g")){p=p+"q";}
    if(M.substring(i,i+1).equals("h")){p=p+"r";}
    if(M.substring(i,i+1).equals("i")){p=p+"s";}
    if(M.substring(i,i+1).equals("j")){p=p+"t";}
    if(M.substring(i,i+1).equals("k")){p=p+"u";}
    if(M.substring(i,i+1).equals("l")){p=p+"v";}
    if(M.substring(i,i+1).equals("m")){p=p+"w";}
    if(M.substring(i,i+1).equals("n")){p=p+"x";}
    if(M.substring(i,i+1).equals("o")){p=p+"y";}
    if(M.substring(i,i+1).equals("p")){p=p+"z";}


}
System.out.println(p);
    }
    }



Measured memory_bytes: 38688
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
s=[0]*(n+1)
for i in range(n):
    s[i+1] = s[i] + a[i]
c = Counter(s)
n = set(s)
ans = 0
for i in n:
    ans += ((c[i]*(c[i]-1))//2)
print(ans)

Measured memory_bytes: 52272
def main():
    r1, c1, r2, c2 = map(int, raw_input().split())
    MOD = 10 ** 9 + 7

    mod = 10 ** 9 + 7  # 出力の制限
    N = 10 ** 4
    g1 = [1, 1]  # 元テーブル
    g2 = [1, 1]  # 逆元テーブル
    inverse = [0, 1]  # 逆元テーブル計算用テーブル

    for i in range(2, r2 + c2 + 10):
        g1.append((g1[-1] * i) % mod)
        inverse.append((-inverse[mod % i] * (mod // i)) % mod)
        g2.append((g2[-1] * inverse[-1]) % mod)

    def cmb(n, r, mod):
        if (r < 0 or r > n):
            return 0
        r = min(r, n - r)
        return g1[n] * g2[r] * g2[n - r] % mod


    ans = 0
    for r in range(r1, r2 + 1):
        ans += ((cmb(r + c2 + 1, r + 1, MOD) % MOD) - (cmb(r + c1, r + 1, MOD) % MOD)) % MOD
        ans %= MOD

    print(ans % MOD)


if __name__ == '__main__':
    main()

Measured memory_bytes: 139616
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()){
            int n = sc.nextInt();
            numberOfArea(n);
        }
    }
    public static void numberOfArea(int n){
        int number = 1;
        for(int i = 1; i <= n; i++){
            number += i;
        }
        System.out.println(number);
    }
}



Measured memory_bytes: 26028
import java.util.*;
 
public class Main {
  public static void main(String[] args){
    Scanner sc= new Scanner(System.in);    
    int N = sc.nextInt();
    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();
    int D = sc.nextInt();
    String S = sc.next();
    
    S = S.substring(A-1, Math.max(C, D));
    
    if(S.contains("##")){     
      System.out.println("No");
    } 
    else if (B<C && C<D){
      System.out.println("Yes");
    }
    else if (C<B && B<D){
      System.out.println("Yes");
    }
    else if (B<D && D<C){
      if(S.substring(B-2, D+1).contains("...")){//B-2からD+1マスまで（１〜５）
        System.out.println("Yes");
      } else {
        System.out.println("No");
      }
   
    }
    
  }
 
}


Measured memory_bytes: 40576
import sys
input=sys.stdin.readline
W,H=map(int,input().split())
P=[int(input()) for _ in range(W)]+[float('inf')]
Q=[int(input()) for _ in range(H)]+[float('inf')]
P.sort(reverse=True)
Q.sort(reverse=True)
ans=0
W+=1
H+=1
while True:
    if W==H==1:
        break
    elif Q[-1]<P[-1] or (Q[-1]==P[-1] and W<=H):
        ans+=W*Q[-1]
        H-=1
        Q.pop()
    elif Q[-1]>P[-1] or (Q[-1]==P[-1] and W>H):
        ans+=H*P[-1]
        W-=1
        P.pop()
print(ans)

Measured memory_bytes: 11792
#include <bits/stdc++.h>
using namespace std;
#define data_type long long
#define endl "\n"

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    data_type n,i=1,c=0,a;
    data_type arr[60001]= {0};
    for(int i=1; i<=100; i++)
        {
            for(int j=1; j<=100; j++)
                {
                    for(int k=1; k<=100; k++)
                        arr[i*i+j*j+k*k+i*j+j*k+k*i]++;
                }
        }
    cin>>n;
    for(int i=1; i<=n; i++)
        cout<<arr[i]<<endl;


    return 0;
}




Measured memory_bytes: 4116
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;


#include "boost/multiprecision/cpp_int.hpp"
#include "boost/multiprecision/cpp_dec_float.hpp"
namespace mp = boost::multiprecision;
typedef mp::cpp_int LL;
typedef mp::number<mp::cpp_dec_float<1024>> DD;// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)

 
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define rrep(i,r,l) for(ll i=r;i>=l;i--)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"  //インタラクティブで消す！！！！！！！！！！！！！！！！！！！！！
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
template<class T,class S>
inline bool chmax(T &a, S b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T,class S>
inline bool chmin(T &a, S b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

void mod_print(ll k){
    ll P=1000;
    rep(y,1,P){
        ll x=mod(y*k);
        if(x+P>=i_7){
            x-=i_7;
        }
        if(abs(x)<=P){
            //cout<<x<<"/"<<y;
            cout<<setprecision(5)<<(dd)x/(dd)y;
            return;
        }
    }
    cout<<"nun"<<endl;
}
#define all(c) c.begin(),c.end()
//////////////////////////

int main(){fastio
    
    ll n;cin>>n;
    ll a[n];rep(i,0,n-1)cin>>a[i];
    ll ans=0;
    for(ll i=0;i<=n-1;i+=2){
        if(a[i]%2==1)ans++;
    }
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 3652
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<functional>
#include<map>
#include<unordered_set> 
#include<cmath>
using namespace std;
long long p = 998244353;
//long long p = 1000000007;
#define int long long
#define vel vector<long long>
#define vvel vector<vel>
#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define qin pair<int,pin>
#define V vector
#define Endl endl
#define veb vector<bool>
#define rev(s) reverse(s.begin(),s.end())
#define lower(h,val) lower_bound(h.begin(),h.end(),val)-h.begin()
#define upper(h,val) upper_bound(h.begin(),h.end(),val)-h.begin()
int max_kai = 150000;
vel kai(max_kai, 1);
vel inv_kai;
int rui(int a, int n) {
	if (n == 0) { return 1; }
	int x = rui(a, n / 2);
	x *= x; x %= p;
	if (n % 2 == 1) { x *= a; x %= p; }
	return x;
}
int inv(int a) { return rui(a, p - 2); }
void make_kai() {
	for (int i = 1; i < max_kai; i++) { kai[i] = kai[i - 1] * i; kai[i] %= p; }
	inv_kai = kai;
	rep(i, max_kai) { inv_kai[i] = inv(kai[i]); }
}
int nCr(int n, int r) {
	int a = kai[n] * inv_kai[r]; a %= p;
	a *= inv_kai[n - r]; a %= p;
	return a;
}
vel pa;
int root(int x) {
	if (pa[x] == -1) { return x; }
	int ans = root(pa[x]); pa[x] = ans;
	return ans;
}
void marge(int x, int y) {
	x = root(x);
	y = root(y);
	if (x != y) { pa[x] = y; }
}
#define Yes "Yay!"
#define No ":("
signed main() {
	int x, y; cin >> x >> y;
	if (x == 1 && y == 1) { cout << 100 * 10000 << endl; return 0; }
	int z = 4 - x;
	int w = 4 - y;
	if (z < 0) { z = 0; }
	if (w < 0) { w = 0; }
	cout << (z + w) * 10 * 10000 << endl;
	return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin>>s;
    int ans=0;
    for(int i=0;i<s.size()-1;i++){
        if(s[i]!=s[i+1]){
            ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
#include <string.h>
using namespace std;
int T, N, a, b, c, d, e, f;
char arr[102];
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> arr;
	int l = strlen(arr);
	int i;
	for (i = 0; i < l; i++)
	{
		char a;
		cin >> a;
		if (a != arr[i])
		{
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
}

Measured memory_bytes: 3640
from collections import defaultdict
n,m = map(int,input().split())
d = defaultdict(lambda:['WA',0])

for _ in range(m):
    i,j = input().split()
    if d[i][0] == 'WA':
        d[i][1] += 1
        d[i][0] = j
        
res = [d[x][1]-1 for x in d if d[x][0]=='AC']
print(len(res),sum(res))

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

const int DIM = 1e5 + 5;
const int MOD = 1e9 + 7;

int t[DIM], a[DIM], h[DIM];

int main( void ) {
    
    int n;
    cin >> n;
    
    for( int i = 1; i <= n; i ++ )
        cin >> t[i];
    for( int i = 1; i <= n; i ++ )
        cin >> a[i];
    
    int ans = 1;
    for( int i = 1; i <= n; i ++ ) {
        if( t[i] != t[i - 1] ) {
            if( h[i] == 0 )
                h[i] = t[i];
            else
            if( h[i] != t[i] )
                ans = 0;
        }
    }
    
    for( int i = n; i >= 1; i -- ) {
        if( a[i] != a[i + 1] ) {
            if( h[i] == 0 )
                h[i] = a[i];
            else
            if( h[i] != a[i] )
                ans = 0;
        }
    }
    
    for( int i = 1; i <= n; i ++ ) {
        if( h[i] == 0 )
            ans = ( 1LL * ans * min( t[i], a[i] ) ) % MOD;
        else {
            if( t[i] != t[i - 1] && t[i] > a[i] )
                ans = 0;
            if( a[i] != a[i + 1] && a[i] > t[i] )
                ans = 0;
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ul unsigned long long int
#define ld long double
#define f(t) for(ll i =0;i<t;i++)
#define vi vector<int>
#define vl vector<ul>
#define pb push_back
#define ff first
#define ss second
#define MOD 1000000007
#define inf 4e18
#define EPS 1e-3
#define PI 3.1415926535897932385
#define display(v) f(v.size())cout << v[i]<<" "
const double h = 1e-6;
const int MAX_  = 200005;
#define all(v) v.begin(),v.end()

inline ll mul(ll a, ll b){ return (a * 1ll * b) % MOD; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += MOD; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > MOD) c -= MOD; return c; }
ll sqr(ll x)
{
    return x*x;
}
 //////////////////////*********CODE***********/////////////////////
 //////////////////////////////////////////////////////////////////

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int m,k;  cin>>m>>k;
    int up = pow(2,m) - 1;
    if(m==1 && k==1)cout << -1;
    else if(k > up)cout << -1 ;
    else
    {
        if(k==0)
        {
            for(int i =0;i<=up;i++)cout << i << " " << i << " ";
        }
        else
        {
            cout << 0 << " " << k << " 0 ";
            for(int i =1;i<=up;i++)if(i!=k)cout << i << " ";
            cout << k << " ";
            for(int i = up;i>0;i--)if(i!=k)cout << i << " ";
        }
    }
    
    return 0;
}
    


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

int main() {
    int N,K;
    cin >> N >> K;
    int a;
    for(int i=0; i<N; ++i) cin >> a;
    int ans = 0;
    while(N > 1) {
        ++ans;
        N -= K - 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
 
using namespace std;
 
int main(){
 
  int a, b, c;
 
  cin >> a >> b >> c;
 
  if( a<b && b<c){
    cout << "Yes" << endl;
  }
 
  else {
    cout << "No" << endl;
  }
 
  return 0;
 
}

Measured memory_bytes: 3104
#include <stdio.h>
#include <stdlib.h>

#define MAX_N (100000)
#define MAX_M (100000)

int main(int argc, char *argv[]) {
  // read inputs
  int N, M, as[MAX_M], bs[MAX_M];
  scanf("%d %d", &N, &M);
  for (int i = 0; i < M; i++) {
    scanf("%d %d", &as[i], &bs[i]);
    as[i]--;  // NOTE : modified input
    bs[i]--;  // NOTE : modified input
  }

  // solve
  int cnts[MAX_N] = {};
  for (int i = 0; i < M; i++) {
    cnts[as[i]]++;
    cnts[bs[i]]++;
  }
  for (int i = 0; i < N; i++) {
    if (cnts[i] % 2 != 0) {
      printf("NO\n");
      return 0;
    }
  }
  printf("YES\n");
  
  return 0;
}


Measured memory_bytes: 1280
#include<stdio.h>


int main()
{
	int n;
	int iCount;
	long long int iSum = 0;
	int iMax = -1000000;
	int iMin = 1000000;
	int iNum;

	scanf("%d",&n);

	for (iCount =0;iCount<n;iCount++)
	{
		scanf("%d",&iNum);

		if (-1000000 > iNum || iNum > 1000000)
		{
			continue;
		}

		if (iMax<iNum)
		{
			iMax = iNum;
		}
		if(iMin > iNum)
		{
			iMin = iNum;
		}

		iSum = iSum + iNum;
	}

	printf("%d %d %lld\n",iMin, iMax, iSum);
}


Measured memory_bytes: 2100
def update_dp(i, j, n, c)
  return if $dp[i] <= j
  $dp[0] = [$dp[0], i+j].min if i < 6
  $dp[i] = j
  c.select{|x| x <= i}.map{|x| update_dp(i-x, j+1, n, c)}
end

n = gets.to_i
c = [59049, 46656, 7776, 6561, 1296, 729, 216, 81, 36, 9, 6]
$dp = Array.new(n+1, Float::INFINITY)
update_dp(n, 0, n, c)
p $dp[0]

Measured memory_bytes: 12924
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <set>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

bool check(string s, char c){
  bool flg = true;
  for(auto x:s) if(x!=c) flg = false;
  return flg;
}

signed main(){
  string s; cin>>s;
  int ans = INF;

  for(char c='a'; c<='z'; c++){
    string t = s;
    rep(i,s.size()){
      if(check(t,c)){
        ans = min(i,ans);
        break;
      }
      string nt = "";
      rep(j,t.size()-1){
        if(t[j]==c||t[j+1]==c) nt.PB(c);
        else nt.PB(t[j]);
      }
      t = nt;
    }
  }

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


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

int main() {
	int h, w;
	cin >> h >> w;
	vector<string>s(h);
	for (int i = 0; i < h; i++) {
		cin >> s[i];
	}
	vector<bool>row(h, false);
	vector<bool>col(w, false);
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (s[i][j] == '#'){
				row[i] = true;
				col[j] = true;
			}
		}
	}
	for (int i = 0; i < h; i++) {
		if (row[i]) {
			for (int j = 0; j < w; j++) {
				if (col[j]) {
					cout << s[i][j];
				}
			}
			cout << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e5+7;
ll p[100]={1ll},b[100],l[100]={1ll},n,k;
void init(){
    for(int i=1;i<55;i++){
        p[i] = 2*p[i-1]+1,b[i] = 2*b[i-1]+2;
        l[i] = p[i]+b[i];
    }
}
ll dfs(ll cur,ll len){
    if(!cur)return 1ll;
    if(len<=1)return 0ll;
    if(len == 1+l[cur-1])
        return p[cur-1];
    if(len == 2+l[cur-1])
        return p[cur-1]+1;
    if(len == l[cur] || len == l[cur]-1)
        return p[cur];
    if(len<1+l[cur-1])
        return dfs(cur-1,len-1);
    return p[cur-1]+1+dfs(cur-1,len-l[cur-1]-2);
}
int main(){
    init();
    cin>>n>>k;
    cout<<dfs(n,k)<<endl;
    return 0;
}


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

int main(){
    ll a, b, x;
    cin >> a >> b >> x;
    ll ans = 0;
    
    ans = b / x - a / x;
    if (a % x == 0)
    {
        ans++;
    }

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

Measured memory_bytes: 256
s1 = int(input())
s2 = int(input())
s3 = int(input())
s4 = int(input())
s5 = int(input())
s6 = int(input())
s7 = int(input())
s8 = int(input())
s9 = int(input())
s10 = int(input())

s = s1 + s2 + s3 + s4 + s5 + s6 + s7 + s8 + s9 + s10
print(s)


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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a,b;
    cin >> a >> b;
    int ns = 1;
    int ans=0;
    while(ns*a < b){
        ans += ns;
        ns *= a;
        //ns -= a;
    }
    if(ns == b) cout << ans;
    else{
        while(ns < b){
            ans++;
            ns += a - 1;
        }
        cout << ans;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stack>
#include<vector>
using namespace std;
vector<string> str,damn;
vector<string> lis;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,i,j,k,l,lst=0,numa=0,numb=0,ite,nowa=0,nowb=0;
	string s,t,hix;
	cin>>n>>s;
	for(i=0;i<2*n;i++){
		if(s[i]=='a'){
			numa++;
		}
		else{
			numb++;
		}
		if(numa==numb){
			str.push_back(s.substr(lst,i-lst+1));
			lst=i+1;
		}
	}
	for(i=0;i<str.size();i++){
		t=str[i];
		hix="";
		if(t[0]=='a'){
			ite=0;
			nowa=0;
			nowb=0;
			while(ite<t.size()){
				while(ite<t.size()&&t[ite]=='b'){
					ite++;
					nowb++;
				}
				if(ite==t.size()){
					break;
				}
				hix+="ab";
				j=nowa+1;
				while(j>nowb){
					if(t[ite]=='b'){
						nowb++;
					}
					else{
						nowa++;
					}
					ite++;
				}
			}
			if(damn.size()){
				t=damn.back();
			}
			if(damn.size()&&t[0]=='a'){
				t+=hix;
				damn.pop_back();
				damn.push_back(t);
			}
			else{
				damn.push_back(hix);
			}
		}
		else{
			nowb=0;
			for(j=0;j<t.size();j++){
				if(t[j]=='b'){
					nowb++;	
				}
				else{
					nowb--;
				}
				hix=max(hix,string(nowb,'b')+t.substr(j+1,t.size()-j-1));
			}
			damn.push_back(hix);
		}
	}
	for(i=0;i<damn.size();i++){
		while(lis.size()&&lis.back()<damn[i]){
			lis.pop_back();
		}
		lis.push_back(damn[i]);
	}
	for(i=0;i<lis.size();i++){
		cout<<lis[i];
	}
}

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

int main(){
	int a, b, c, temp;
	cin >> a >> b >> c ;
	
	if (b > c){
		temp = b;
		b = c;
		c = temp;
	}
	
	if (a > b){
		temp = a;
		a = b;
		b = temp;
	}
	
	if (b > c){
		temp = b;
		b = c;
		c= temp;
	}
	cout << a << " " << b << " " << c << endl;
	
	return 0;
}

Measured memory_bytes: 3088
#include<iostream>
#include<math.h>
using namespace std;

int main()
{
	int D, N;
	cin >> D >> N;
	if (N == 100) {
		printf("%d", (int)pow(100, D)*N+(int)pow(100,D));
	}
	else {
		printf("%d", (int)pow(100, D)*N);
	}

	return 0;
}

Measured memory_bytes: 256
cards = [[False for i in range(13)] for i in range(4)]
egara = ["S","H","C","D"]

n = int(input())
for i in range(n):
    a,b = input().split()
    b = int(b)

    cards[egara.index(a)][b - 1] = True
for i in range(4):
    for j in range(13):
        if (not cards[i][j]):
            print("{0} {1}".format(egara[i], j+1))



Measured memory_bytes: 5604
N = int(input())
A = [int(_) for _ in input().split()]
B = [int(_) for _ in input().split()]

# print(A)
# print(B)
# print(P_true)
def_Bsum = sum(B)

for i in range(N+1):
    if(i==0):
        if (A[i] < B[i]):
            B[i] -= A[i]
            A[i] = 0
        else:
            A[i] -= B[i]
            B[i] = 0

    if(0<i<N):
        if(A[i] < B[i-1]):
            B[i-1] -= A[i]
            A[i] = 0
        else:
            A[i] -= B[i-1]
            B[i-1] = 0

            if (A[i] < B[i]):
                B[i] -= A[i]
                A[i] = 0
            else:
                A[i] -= B[i]
                B[i] = 0

    if(i==N):
        if (A[i] < B[i-1]):
            B[i-1] -= A[i]
            A[i] = 0
        else:
            A[i] -= B[i-1]
            B[i-1] = 0


ans = def_Bsum - sum(B)
# print(def_Bsum)
# print(sum(B))

print(ans)




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

int main(){
	// sengen
	int x,a;
	// nyuryoku
	cin >> x >> a;
	// keisan
	if(x < a){
		cout << "0";
	}else{
		cout << "10";
	}
	// syutsuryoku
}

Measured memory_bytes: 3640
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
using namespace std;
typedef long long ll;
ll a[100001];
struct P{
	ll pos,cost;
};
struct B{
	ll to,cost;
};
struct L{
	ll from,to,cost;
};
vector<B>e[100001];
L l[200000];
struct T{
	ll x,cost;
};
T lo[200000];
bool operator<(P a,P b){return a.cost<b.cost;}
bool operator>(P a,P b){return a.cost>b.cost;}
bool operator<(T a,T b){return a.x<b.x;}
const ll inf=8000000000000000;
int main() {
	ll n,m,c;
	while(cin>>n>>m>>c){
		for(ll i=1;i<=n;i++){
			a[i]=inf;
			e[i].clear();
		}
		ll r=0;
		for(ll i=0;i<m;i++){
			ll u1,u2,u3;
			cin>>u1>>u2>>u3;
			e[u1].push_back(B{u2,u3});
			e[u2].push_back(B{u1,u3});
			l[i]=L{u1,u2,u3};
			r+=u3;
		}
		priority_queue<P, vector<P>, greater<P>>p;
		a[1]=0;
		p.push(P{1,0});
		while(!p.empty()){
			P t=p.top();p.pop();
			for(ll i=0;i<(ll)e[t.pos].size();i++){
				if(a[t.pos]+e[t.pos][i].cost<a[e[t.pos][i].to]){
					a[e[t.pos][i].to]=a[t.pos]+e[t.pos][i].cost;
					p.push(P{e[t.pos][i].to,a[e[t.pos][i].to]});
				}
			}
		}
		for(ll i=0;i<m;i++){
			ll k=max(a[l[i].from],a[l[i].to]);
			lo[i]=T{k,l[i].cost};
		}
		sort(lo,lo+m);
		ll sum=r;
		ll sum3=r;
		for(ll i=0;i<m;){
			ll k=lo[i].x;
			while(i<m&&lo[i].x==k){
				sum-=lo[i].cost;
				i++;
			}
			ll sum4=sum+k*c;
			sum3=min(sum3,sum4);
		}
		cout<<sum3<<endl;
	}
}

Measured memory_bytes: 25232
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")

#include <cstdio>
#include <cstdint>
#include <unistd.h>

using i64 = std::uint_fast32_t;

struct fio {
private:
  constexpr static int is = 1 << 17;
  char ib[is], *ip = ib + is;
public:
  inline fio& operator>>(char& c) {
    if (ip == ib + is) { read(STDIN_FILENO, ib, is); ip = ib; }
    c = *ip++;
    return *this;
  }
  inline fio& operator>>(i64& r) {
    char it;
    r = 0;
    if (ip + 16 > ib + is) while ((*this >> it, it & 16)) r = r * 10 + it - '0';
    else while ((it = *ip++) & 16) r = r * 10 + it - '0';
    return *this;
  }
};

fio fio;

namespace io {
  constexpr int is = 1 << 17;
  char ib[is], *ip = ib + is, it;
  inline char getc() {
    if (ip == ib + is) { read(STDIN_FILENO, ib, is); ip = ib; }
    return *ip++;
  }
  inline i64 scan() {
    i64 r = 0;
    if (ip + 16 > ib + is) while ((it = getc()) & 16) r = r * 10 + it - '0';
    else while ((it = *ip++) & 16) r = r * 10 + it - '0';
    return r;
  }
  constexpr int os = 1 << 17;
  char ob[os], *op = ob, ot;
  inline void putc(const char c) {
    *op++ = c;
    if (op == ob + os) { write(STDOUT_FILENO, ob, os); op = ob; }
  }
  /* x shoud be greater than or equal to zero */
  inline void print(i64 x) {
    char d[20];
    int i = 0;
    while (true) {
      d[i] = x % 10 + 48;
      x /= 10;
      ++i;
      if (x <= 0) break;
    }
    while (i--) {
      putc(d[i]);
    }
  }
  inline void flush() {
    write(STDOUT_FILENO, ob, op - ob);
  }
}

signed main() {
  i64 h, n;
  fio >> h >> n;
  i64 s = 0;
  for (int i = 0; i < n; i++) {
    i64 a;
    fio >> a;
    s += a;
  }
  if (s >= h) {
    puts("Yes");
  } else {
    puts("No");
  }
  return 0;
}

Measured memory_bytes: 256
import sys
import numpy as np
from math import ceil as C, floor as F, sqrt
from collections import defaultdict as D, Counter as CNT
from functools import reduce as R
import heapq as HQ

class Heap:
  def __init__(self, data, reverse=False):
    self.reverse = -1 if reverse else 1
    self.data = [self.reverse * d for d in data]
    HQ.heapify(self.data)
  def push(self, x): return HQ.heappush(self.data, self.reverse * x)
  def pop(self): return self.reverse * HQ.heappop(self.data)

ALP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
alp = 'abcdefghijklmnopqrstuvwxyz'
def _X(): return sys.stdin.readline().rstrip().split(' ')
def _S(ss): return tuple(ss) if len(ss) > 1 else ss[0]
def S(): return _S(_X())
def Ss(): return list(S())
def _I(ss): return tuple([int(s) for s in ss]) if isinstance(ss, tuple) else int(ss)
def I(): return _I(S())
def _Is(ss): return list(ss) if isinstance(ss, tuple) else [ss]
def Is(): return _Is(I())

n = S()
ans = 0
for x in n:
    ans += int(x)
print('Yes' if ans % 9 == 0 else 'No')

Measured memory_bytes: 27072
#include <algorithm>
#include <boost/optional.hpp>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < i##_MACRO; i++)
#define RANGE(i, a, b) for(int i = (a), i##_MACRO = (b); i < i##_MACRO; i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) std::begin(a), std::end(a)
#define RALL(a) std::rbegin(a), std::rend(a)
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define INT(x) (static_cast<int>(x))
#define PRECISION(x) std::fixed << std::setprecision(x)

using namespace std;

using ll = long long;
using VI = std::vector<int>;
using VI2D = std::vector<vector<int>>;
using VLL = std::vector<long long>;
using VLL2D = std::vector<vector<long long>>;

constexpr int INF = 2e9;
constexpr double EPS = 1e-10;
constexpr double PI = acos(-1.0);

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

template <typename T, std::size_t N>
struct make_vector_type {
	using type =
		typename std::vector<typename make_vector_type<T, (N - 1)>::type>;
};

template <typename T>
struct make_vector_type<T, 0> {
	using type = typename std::vector<T>;
};

template <typename T, size_t N>
auto make_vector_impl(const std::vector<std::size_t>& ls, T init_value) {
	if constexpr(N == 0) {
		return std::vector<T>(ls[N], init_value);
	} else {
		return typename make_vector_type<T, N>::type(
			ls[N], make_vector_impl<T, (N - 1)>(ls, init_value));
	}
}

template <typename T, std::size_t N>
auto make_vector(const std::size_t (&ls)[N], T init_value) {
	std::vector<std::size_t> dimensions(N);
	for(int i = 0; i < N; i++) {
		dimensions[N - i - 1] = ls[i];
	}
	return make_vector_impl<T, N - 1>(dimensions, init_value);
}

template <typename T>
std::vector<T> make_vector(std::size_t size, T init_value) {
	return std::vector<T>(size, init_value);
}

template <typename T>
constexpr int sign(T x) {
	return x < 0 ? -1 : x > 0 ? 1 : 0;
}

template <>
constexpr int sign(double x) {
	return x < -EPS ? -1 : x > EPS ? 1 : 0;
}

template <typename T, typename U>
constexpr void chmax(T& m, U x) {
	m = max<T>(m, x);
}

template <typename T, typename U>
constexpr void chmin(T& m, U x) {
	m = min<T>(m, x);
}

template <typename T>
constexpr T square(T x) {
	return x * x;
}

int main() {
	int n;
	cin >> n;
	VI c(n - 1);
	VI s(n - 1);
	VI f(n - 1);
	REP(i, n - 1) { cin >> c[i] >> s[i] >> f[i]; }

	REP(i, n) {
		int time = 0;
		RANGE(j, i, n - 1) {
			chmax(time, s[j]);
			int tmp = (time + f[j] - 1) / f[j];
			chmax(time, tmp * f[j]);
			time += c[j];
		}

		cout << time << endl;
	}
	return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
using ull = unsigned long long;

vector<int> find_ch(const string str, const char a) {
    vector<int> result;
    int pos = str.find(a);
    while (pos != string::npos) {
        result.push_back(pos);
        pos = str.find(a, pos+1);
    }
    return result;
}

int main() {
    string S, T, ans="Yes";
    vector<int> ch_pos;
    char s0, t0;
    cin >> S >> T;

    for (char c='a'; c<='z'; c++) {
        ch_pos = find_ch(T, c);
        for (int i=0; i<ch_pos.size(); i++) {
            if (i==0) s0 = S[ch_pos[i]];
            else {
                if (s0 != S[ch_pos[i]]) {
                    ans = "No";
                    break;
                }
            }
        }
        if (ans=="No") break;

        ch_pos = find_ch(S, c);
        for (int i=0; i<ch_pos.size(); i++) {
            if (i==0) t0 = T[ch_pos[i]];
            else {
                if (t0 != T[ch_pos[i]]) {
                    ans = "No";
                    break;
                }
            }
        }
        if (ans=="No") break;
    }

    cout << ans << endl;

    return 0;

}

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

using namespace std;

const int mod = 1e9 + 7;

static int fast_pow(int x, int y, int z) {
  int64_t ret = 1;
  for (; y; y >>= 1, x = (int64_t)x * x % z) {
    if (y & 1) ret = ret * x % z;
  }
  return ret;
}

int main() {
  std::ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> a(n + 1);
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    a[i] ^= a[i - 1];
  }
  vector<vector<int>> g(1 << 20);
  for (int i = 1; i <= n; i++) {
    g[a[i]].push_back(i);
  }
  long long ans = 0;
  if (g[0].size())
    ans = fast_pow(2, g[0].size() - 1, mod);
  auto get = [&](int l, int r) {
    return upper_bound(g[0].begin(), g[0].end(), r) - lower_bound(g[0].begin(), g[0].end(), l);
  };
  for (int z = 1; z < 1 << 20; z++) {
    if (g[z].empty()) continue;
    vector<int> vec;
    for (int i = 1; i < g[z].size(); i++) {
      vec.push_back(get(g[z][i - 1], g[z][i]));
    }
    vec.push_back(get(g[z].back(), n));
    vector<vector<long long>> f(vec.size() + 1, vector<long long>(2));
    f[0][0] = 1;
    for (int i = 1; i <= vec.size(); i++) {
      f[i][1] = (f[i - 1][1] + f[i - 1][0]) % mod; 
      f[i][0] = (f[i - 1][0] + f[i][1] * vec[i - 1]) % mod;
      if (i == vec.size()) {
        if (a[n] != 0) {
          if (z == a[n]) {
            cout << f[i - 1][0] << endl;
            exit(0);
          }
        } else {
          ans = (ans + f[i][1]) % mod;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 46176
while True:
    try:
        a=list(map(int,input().split()))
        b=list(map(int,input().split()))
        hit,blow=0,0
        ac=0
        for i in a:
            bc=0
            ac +=1
            for j in b:
                bc +=1
                if i==j:
                    if ac==bc:
                        hit +=1
                    else:
                        blow +=1
        print(hit,blow)
    except:break


Measured memory_bytes: 5592
N = int(input())
a = list(map(int, input().split()))
all_xor = a[0]
for j in range(1, len(a)):
    all_xor = all_xor ^ a[j]
answer = [0] * N
for i in range(N):
    answer[i] = all_xor ^ a[i]
    
print(' '.join(map(str, answer)))

Measured memory_bytes: 41760
import sys


def lcs(X, Y):
    len_x = len(X)
    dp = [0] * (len_x + 1)

    for y in Y:
        _dp = dp[:]
        for j, x in enumerate(X):
            if x == y:
                dp[j + 1] = _dp[j] + 1
    
            elif _dp[j + 1] < dp[j]:
                dp[j + 1] = dp[j]

    return dp[len_x]


n = int(sys.stdin.readline())
for i in range(n):
    X = sys.stdin.readline().rstrip()
    Y = sys.stdin.readline().rstrip()
    print(lcs(X, Y))



Measured memory_bytes: 5636
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int a,b,c,d;
  int k=1; 
  cin>>a>>b>>c>>d;
  while(!(a<=0) && !(c<=0))
  {
    if(k%2 == 0)
    { 
      a=a-d;
    }
    else
    {
      c=c-b;
    } 
    k++;
  }
  if(a > 0)
     cout<<"Yes";
  else
    cout<<"No";
}

Measured memory_bytes: 3592
from math import factorial
from collections import Counter

n = factorial(int(input()))
res = []
x = n
y = 2
while y*y <= x:
    while x % y == 0:
        res.append(y)
        x //= y
    y += 1
if x > 1:
    res.append(x)

res = Counter(res)
ans = 1
for v in res.values():
    ans = ans*(v+1) % (10**9+7)
print(ans)

Measured memory_bytes: 3444
def has_three(a):
    while a != 0:
        if a % 10 == 3:
            return True
        else:
            a /= 10
    return False


result = list()
n = int(raw_input())
for i in range(1, n + 1):
    if i % 3 == 0:
        result.append(i)
    elif has_three(i):
        result.append(i)
print(" " + " ".join(str(i) for i in result))

Measured memory_bytes: 6888