akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main() {
    #ifdef DEBUG
    std::ifstream in("/home/share/inputf.in");
    std::cin.rdbuf(in.rdbuf());
    #endif
    int N, ans = 0;
    cin >> N;
    vector<int> V(N), C(N);
    for(int i = 0; i < N; i++) {
        cin >> V[i];
    }
    for (int i = 0; i < N; i++) {
        cin >> C[i];
    }
    for(int i = 0; i < N; i++) {
        ans += max(V[i] - C[i], 0);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
 
//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};
 
int main()
{
	int a = 0;
	int tmp;
	REP(i, 4){
		cin >> tmp;
		a += tmp;
	}

	cout << a / 60 << endl << a %  60 << endl;


}


Measured memory_bytes: 3092
#include <stdio.h>

int main(void) {
  int h, w, n;
  
  scanf("%d", &h);
  scanf("%d", &w);
  scanf("%d", &n);
  
  printf("%d\n", (n - 1) / ((h > w) ? h : w) + 1);
  
  return 0;
}


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

using namespace std;

typedef long long ll;

const int inf = 1e9;
const int maxN = 1000000;

ll f(ll n) {
	return n * (n+1) * (n+2) / 6;
}

vector<int> makeS(int mod, int d) {
	vector<int> res;
	for (int n = 1; f(n) <= maxN; ++n) {
		if ( f(n) % mod == d ) {
			res.push_back( f(n) );
		}
	}
	return res;
}
vector<int> solve(const vector<int>& s) {
	vector<int> dp(maxN+1, inf); dp[0] = 0;
	for (int i = 0; i < s.size(); ++i) {
		for (int j = 0; j <= maxN; ++j) {
			int nj = j + s[i];
			if (nj <= maxN) {
				dp[nj] = min(dp[nj], dp[j]+1);
			}
		}
	}
	return dp;
}

int main() {
	vector<int> s0 = makeS(1, 0);
	vector<int> s1 = makeS(2, 1);
	vector<int> dp1 = solve(s0);
	vector<int> dp2 = solve(s1);
	int N;
	while (cin >> N, N) {
		cout << dp1[N] << " " << dp2[N] << endl;
	}
}

Measured memory_bytes: 10504
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main(int argc, char * argv[]) {
    int N, K;
    cin >> N >> K;

    int max = (N - 1) * (N - 2) / 2;
    if (K > max) {
        cout << -1 << endl;
        return 0;
    }

    vector<pair<int, int>> edges;
    for (int i = 2; i <= N; ++i) {
        edges.emplace_back(1, i);
    }
    int cnt = max;

    int x = 2, y = 3;
    while (cnt > K) {
        edges.emplace_back(x, y);
        y += 1;
        if (y > N) {
            x += 1;
            y = x + 1;
        }
        cnt -= 1;
    }

    cout << edges.size() << endl;
    for (auto & e : edges) {
        cout << e.first << " " << e.second << endl;
    }

    return 0;
}


Measured memory_bytes: 384
from operator import itemgetter
from collections import deque
N = int(input())
AB = [list(map(int,input().split())) for _ in range(N)]
AB = deque(sorted(AB,key = itemgetter(1)))
ans = "Yes"
time = 0
while len(AB) != 0:
    tmp = AB.popleft()
    time += tmp[0]
    if time > tmp[1]:
        ans = "No"
        break
print(ans)

Measured memory_bytes: 55532
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <iomanip>
#include <limits.h>

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBUG = true;

vector< bool > prime_table(ll n) {
  vector< bool > prime(n + 1, true);
  if(n >= 0) prime[0] = false;
  if(n >= 1) prime[1] = false;
  for(int i = 2; i * i <= n; i++) {
    if(!prime[i]) continue;
    for(int j = i + i; j <= n; j += i) {
      prime[j] = false;
    }
  }
  return prime;
}

int main(){

    vector<bool> table = prime_table(1000000);
    ll x;
    cin >> x;

    for(ll i = x; i <= 1000000; i++){
        if( table[i] ) {
            cout << i << endl;
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#include<cmath>
using namespace std;
int main(){
int N,C,K;
cin >> N >> C >> K;
int t[100010];
for(int i = 0; i< N;i ++)cin >> t[i];

sort(t,t+N);

int p = 1 ;
int ans = 1;
int x = t[0];
for(int i = 1; i < N; i++){
  if(p == C){
    ans++;
    p = 1;
    x = t[i];
  }
  else if(t[i] > K+x){
    ans++;
    p=1;
    x=t[i];
  }
  else{
    p++;
  }
  
}
  cout << ans << endl;
}



Measured memory_bytes: 640
#include "bits/stdc++.h"
#define MAXN 100009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x)  cerr<< #x <<" = "<< x<<endl;
using namespace std;

typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
int dp[MAXN][26];
int main(){
    //freopen("file.in", "r", stdin);
    string s,t;
    cin>>s>>t;
    for(int i=0;i<26;i++)
    	dp[s.size()][i]=-1;
    for(int i=s.size()-1;i>=0;i--){
    	for(int j=0;j<26;j++)
			dp[i][j]=dp[i+1][j];	
		dp[i][s[i]-'a']=i;	
    }
    ll ans=0;
	int p=0;
    for(int i=0;i<t.size();i++){
 		if(~dp[p][t[i]-'a']){
 			ans+=dp[p][t[i]-'a']+1-p;
		 	p=dp[p][t[i]-'a']+1;
		 }
		else if(~dp[0][t[i]-'a']){
			ans+=s.size()-p;
			ans+=dp[0][t[i]-'a']+1;
			p=dp[0][t[i]-'a']+1;
		}
		else{
			puts("-1");
			return 0;
		}	
		if(p==s.size())
			p=0;
    }
    printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 10752
#include <iostream>

using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
ll sol(ll a,ll b){
    if(b==0)return a;
    return  sol(b,a%b);
}
ll N,K;
ll gcd(ll a,ll b){
    if(b==0)return a;
    return gcd(b,a%b);
}
#define MAXN 100001
ll A[MAXN];
int main(){
    cin >> N >> K;
    ll Max = 0;
    rep(i,N){
        cin >> A[i];
        Max = max(Max,A[i]);
    }
    ll gc = A[0];
    for(int i=1;i<N;i++){
        gc = gcd(A[i],gc);
    }
    while(Max>K){
        Max -= gc;
    }
    if(Max==K)cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;
    
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
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 (b<a) {a=b; return 1;} return 0;}


int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int ans = 0;
    int cur = 1;
    rep(i, n) {
        if (a[i] != cur) ans++;
        else cur++;
    }
    if (cur == 1) {
        cout << -1 << endl;
        return 0;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
import java.util.*;

class Main {
   public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      int H = Integer.parseInt(sc.next());
      int W = Integer.parseInt(sc.next());
      while (H != 0 && W != 0) {
         if (H > 300 || W > 300) break;
         for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
               System.out.print("#");
            }
            System.out.println();
         }
         System.out.println();
         H = Integer.parseInt(sc.next());
         W = Integer.parseInt(sc.next());
      }
   }
}

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

const int maxn = 2e5 + 10;
typedef long long int ll;
ll a[maxn];
void solved(){
	ll k,n;cin>>k>>n;
	for(int i = 1; i <= n; i++)cin>>a[i];
	ll M = 0;
	for(int i = 2; i <= n; i++){
		M = max(M,a[i] - a[i - 1]);
	}
	M = max(M,k + a[1] - a[n]);
	cout<<k - M<<endl;
}
int main(){
	solved();
	return 0;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//edit
class Solve {
public:
    void solve() {
        Int N, R;
        cin >> N >> R;
        Int I = R + 100 * max(10 - N, 0ll);
        cout << I << endl;
    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();


    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const int INF = 1001001001;
const int MOD = 1000000007;

template <typename T>
void print(const T &v);

int main()
{
    int n;
    cin >> n;
    n %= 10;
    if (n == 2 || n == 4 || n == 5 || n == 7 || n == 9)
    {
        cout << "hon" << endl;
        return 0;
    }
    else if (n == 3)
    {
        cout << "bon" << endl;
        return 0;
    }
    else
    {
        cout << "pon" << endl;
        return 0;
    }
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << " ";
        cout << v[i];
    }
    cout << endl;
}


Measured memory_bytes: 3628
#include <stdio.h>
#define MAX 2000
 
int solve(int,int);
int A[MAX],n;
 
int main(void){
  int S[MAX],i,m;
  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }

  scanf("%d",&m);
 
  for(i=0;i<m;i++){
    scanf("%d",&S[i]);
    if(solve(0,S[i])) printf("yes\n");
    else printf("no\n");
  }
   
  return 0;
}
 
int solve(int x,int y){
  if(A[x] == y) return 1;
  if(x+1 == n) return 0;
  if(solve(x+1,y-A[x]) || solve(x+1,y)) return 1;
  return 0;
}

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

template <class T>
T gcd(T a, T b) {
    if (a < b) std::swap(a, b);
    if (a % b == 0) return b;
    else return gcd(b, a % b);
}

int main() {
    long long n, x, mi;
    std::cin >> n >> x;
    mi = x;
    std::vector<long long> p(n);
    for (int i = 0; i < n; i++) {
        std::cin >> p[i];
        p[i] -= x;
        if (p[i] < 0) p[i] = -p[i];
    }
    auto ret = p[0];
    for (int i = 1; i < n; i++) ret = gcd(ret, p[i]);
    
    std::cout << ret << std::endl;

    return 0;
}

Measured memory_bytes: 1024
#include <vector>
#include <iostream>
using namespace std;
const int s = 10;
const vector<vector<int> > dx = {
	{ 0, 1, 1, 1, 2 },
	{ 0, 0, 0, 1, 1, 1, 2, 2, 2 },
	{ 0, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 4 }
};
const vector<vector<int> > dy = {
	{ 0, -1, 0, 1, 0 },
	{ 0, 1, 2, 0, 1, 2, 0, 1, 2 },
	{ 0, -1, 0, 1, -2, -1, 0, 1, 2, -1, 0, 1, 0 }
};
const vector<int> augx = { 1, 1, 2 };
const vector<int> augy = { 0, 1, 0 };
int n, a[14][14], x[18], y[18], t[18];
bool solve(int cx, int cy, int cnt) {
	if (cx == s - 2) return (cnt == n);
	if (a[cx][cy] == 0) return solve(cy + 1 == s ? cx + 1 : cx, cy + 1 == s ? 0 : cy + 1, cnt);
	x[cnt] = cx, y[cnt] = cy;
	for (int i = 0; i < 3; ++i) {
		t[cnt] = i;
		bool ok = true;
		for (int j = 0; j < dx[i].size() && ok; ++j) {
			int tx = cx + dx[i][j], ty = cy + dy[i][j];
			if (tx < 0 || s <= tx || ty < 0 || s <= ty || a[tx][ty] == 0) ok = false;
		}
		if (!ok) continue;
		for (int j = 0; j < dx[i].size() && ok; ++j) {
			--a[cx + dx[i][j]][cy + dy[i][j]];
		}
		if (solve(cx, cy, cnt + 1)) return true;
		for (int j = 0; j < dx[i].size() && ok; ++j) {
			++a[cx + dx[i][j]][cy + dy[i][j]];
		}
	}
	return false;
}
int main() {
	cin >> n;
	for (int i = 0; i < s; ++i) {
		for (int j = 0; j < s; ++j) {
			cin >> a[i][j];
		}
	}
	solve(0, 0, 0);
	for (int i = 0; i < n; ++i) {
		cout << y[i] + augy[t[i]] << ' ' << x[i] + augx[t[i]] << ' ' << t[i] + 1 << '\n';
	}
	return 0;
}


Measured memory_bytes: 3164
#include<stdio.h>

int main()
{
    int i, j, m, n, q;
    int s[100000];
    int t[50000];
    int flag = 0;
    int count = 0;

    scanf("%d", &n);

    for(i = 0; i < n; i++){

        scanf("%d", &s[i]);

    }
    scanf("%d", &q);

    for(i = 0; i < q; i++){

        scanf("%d", &t[i]);

    }

    m = n / 2;

    for(i = 0; i < q; i++){

        flag = 0;

        if(t[i] == s[m]){

                count++;
        }

        else if(t[i] > s[m]){

            j = m;

            while(flag == 0 && j < n){

                if(s[j] == t[i]){
                    count++;
                    flag = 1;
                }
                j ++;
            }
        }

        else if(t[i] < s[m]){

            j = 0;

            while(flag == 0 && j <  m){

                if(s[j] == t[i]){
                    count++;
                    flag = 1;
                }
                j ++;
            }
        }
    }

    printf("%d\n", count);

    return 0;
}


Measured memory_bytes: 2312
#!/usr/bin/ruby

input = STDIN.gets.split(" ")

a = input[0]
b = input[1]

str_ab = input[0].to_s + input[1].to_s

ab = str_ab.to_i

if ab**0.5 == (ab**0.5).to_i then
  puts 'Yes'
else
  puts 'No'
end


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

int INF = 1'000'000'000;
typedef tuple<double, int, int> T;

int main(){
    while (1){
        int n, m, p, a, b;
        cin >> n >> m >> p >> a >> b;
        a--; b--;
        if (m == 0) break;
        vector<int> ticket(n);
        for (int i = 0; i < n; i++) cin >> ticket[i];
        vector<vector<int>> load(m, vector<int>(m, INF));
        for (int i = 0; i < p; i++){
            int x, y, z;
            cin >> x >> y >> z;
            x--; y--;
            load[x][y] = min(load[x][y], z);
            load[y][x] = min(load[y][x], z);
        }
        vector<vector<bool>> check(m, vector<bool>((1 << n), false));
        priority_queue<T, vector<T>, greater<T>> que;
        double d = 0;
        int horse = 0;
        que.push(tie(d, a, horse));
        double ans = INF;
        while (que.size()){
            d = get<0>(que.top());
            a = get<1>(que.top());
            horse = get<2>(que.top());
            que.pop();
            if (check[a][horse]) continue;
            check[a][horse] = true;
            if (a == b){
                ans = d;
                break;
            }
            for (int i = 0; i < m; i++){
                if (load[a][i] != INF){
                    for (int j = 0; j < n; j++){
                        if ((horse >> j) & 1) continue;
                        double nd = d + (double)load[a][i] / ticket[j];
                        int nhorse = horse | (int)pow(2, j);
                        que.push(tie(nd, i, nhorse));
                    }
                }
            }
        }
        if (ans == INF) cout << "Impossible" << endl;
        else cout << ans << endl;
    }
}


Measured memory_bytes: 16088
N, M = map(int, input().split())
A = []
B = []
for i in range(N):
    A.append(input())
for i in range(M):
    B.append(input())

for h in range(N-M+1):
    for w in range(N-M+1):
        if list(map(lambda x:x[w:w+M], A[h:h+M])) == B:
            print("Yes")
            exit()

print("No")


Measured memory_bytes: 3060
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

def maxsum(e):
	n = 0
	while n*(n + 1)/2 <= int(e):
		n = n + 1 
	return n - 1

def solve(N):
	if N == 1:
		return 0
	fac = factorization(N)
	sum = 0
	for ret in fac:
		sum = sum + maxsum(ret[1])
	return sum

N = input()
print(solve(N))
 

Measured memory_bytes: 66236
#include "bits/stdc++.h"
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << endl

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

  int x;

  cin>>x;


  for(long long i=-1000;i<=1000;i++){

      for(long long j=-1000;j<=1000;j++){
        if(powl(i,5)-powl(j,5)==x){
          cout<<i<<" "<<j;
          return 0;
        }
      }

  }
  
     
  return 0;
}


Measured memory_bytes: 3672
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;
using ll = long long;

int main(){
  int N, A, B;
  cin >> N >> A >> B;
  cout << min( N*A, B) << endl;
  return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    string s;
    cin >> s;
    int c = -1,f = -1;
    for(int i = 0;i < s.size();i++)
    {
        if(s[i] == 'C')
        {
            c = i;
            break;
        }
    }
    for(int i = s.size() - 1;i >= 0;i--)
    {
        if(s[i] == 'F')
        {
            f = i;
            break;
        }
    }
    if(c < f && c != -1)
    {
        cout << "Yes\n";
    }
    else
    {
        cout << "No\n";
    }
    
    return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AAtCoderCrackers solver = new AAtCoderCrackers();
        solver.solve(1, in, out);
        out.close();
    }

    static class AAtCoderCrackers {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            out.println(in.nextInt() % in.nextInt() == 0 ? 0 : 1);
        }

    }
}



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

char s[48][101];

int main(){
  int W, B; scanf("%d%d", &W, &B);

  for(int i = 1; i <= 23; i++){
    fill(s[i] + 1, s[i] + 100, '.');
  }

  for(int i = 24; i <= 46; i++){
    fill(s[i] + 1, s[i] + 100, '#');
  }

  W--; B--;

  for(; B--; ){
    s[B / 49 * 2 + 2][B % 49 * 2 + 2] = '#';
  }

  for(; W--; ){
    s[W / 49 * 2 + 23 + 2][W % 49 * 2 + 2] = '.';
  }

  printf("%d %d\n", 46, 99);
  for(int i = 1; i <= 46; i++) puts(s[i] + 1);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
using namespace std;
 
int main()
{
    string s;
    cin >> s;
    int ans1 = 0;
    char c = '0';
    for (int i = 0; i < s.size(); i++){
        if (c == '0') c='1';
        else c ='0';
        if (s[i] == c)
            continue;
        else{
            ans1++;
        }
    }
    int ans2 = 0;
     c = '1';
    for (int i = 0; i < s.size(); i++){
        if (c == '0') c='1';
        else c ='0';
        if (s[i] == c)
            continue;
        else{
            ans2++;
        }
    }
    cout << min(ans1, ans2) << endl;
    return 0;
}

Measured memory_bytes: 512
#include<cstdio>
#include<iostream>

using namespace std;

int main()
{
	int a,b;
	int c,d;
	scanf("%d %d %d %d",&a,&b,&c,&d);
	
	for(int i=0;;i++)
	{
		if(i%2==0)
		{
			c=c-b;
			if(c<=0)
			{
				printf("Yes");
				break;
			}
		}
		else{
			a=a-d;
			if(a<=0)
			{
				printf("No");
				break;
			}
		}
	}
	return 0;
} 

Measured memory_bytes: 3844
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(){
    int N, count=0;
    if(scanf("%d",&N) < 1) exit(1);
    while(N>0){
        if(N%10==2) count++;
        N /=10;
    }
    printf("%d",count);
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <utility>
#include <limits>

using namespace std;

const int MOD = 1000000007;


inline int add(int a, int b)
{ 
  a += b;
  if (a >= MOD) a -= MOD;
  return a;
}

inline int sub(int a, int b)
{ 
  a -= b;
  if (a < 0) a += MOD;
  return a;
}

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

  int N, K;

  std::cin >> N >> K;

  vector<vector<int>> prefix = vector<vector<int>>(N+1, vector<int>(K+1, 0));
  prefix[0] = vector<int>(K+1, 1);

  int res = 0;

  for (int i = 1; i <= N; ++i)
  { 
    int kid;
    cin >> kid;

    for (int sum = 0; sum <= K; ++sum)
    { 
      int R = min(kid, sum);
      res = sub(prefix[i - 1][sum], (sum - R > 0 ? prefix[i - 1][sum - R - 1] : 0));
      prefix[i][sum] = add(res, (sum > 0 ? prefix[i][sum - 1] : 0));
    }
  } 

  std::cout << res;

  return 0;
}

Measured memory_bytes: 40192
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
#define int long long
const int inf = 999999999999999999;
typedef long long ll;
typedef long double ld;
int n, q, k;
struct P {
	int pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {
	int to, cost;
};
vector<B>e[100001];
int a[100001];
signed main() {
	cin >> n;
	a[n] = inf;
	for (int i = 1; i < n ; i++) {
		int b, c, d;
		cin >> b >> c >> d;
		e[b].push_back(B{ c,d });
		e[c].push_back(B{ b,d });
		a[i] = inf;
	}
	cin >> q >> k;
	priority_queue<P, vector<P>, greater<P>>p;
	p.push(P{ k,0 });
	a[k] = 0;
	while (!p.empty()) {
		P t = p.top(); p.pop();
		for (int i = 0; i < e[t.pos].size(); i++) {
			if (a[e[t.pos][i].to] > a[t.pos] + e[t.pos][i].cost) {
				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 (int i = 0; i < q; i++) {
		int b, c;
		cin >> b >> c;
		cout << a[b] + a[c] << endl;
	}
	getchar(); getchar();
}

Measured memory_bytes: 12400
s=input()
if s[0]!="A":
    s="A"+s
if len(s)>4:
    if s[4]!="A":
        s=s[:4]+"A"+s[4:]
if len(s)>6:
    if s[6]!="A":
        s=s[:6]+"A"+s[6:]
if s[-1]!="A":
    s+="A"
print("NO" if s!="AKIHABARA" else "YES")

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

#define int long long

int32_t main() {
	int k;
  	cin >> k;
  	if(k%7 == 0) {
    	k/=7;
    }
  	if(k == 1) {
    	cout << 1 << endl;
      	return 0;
    }
	int now = 1;
  	map<int,int> mp;
  	mp[1] = 1;
  	int ans = 1;
  	while(1) {
      now = now*10 + 1;
      now %= k;
      // cout << now << endl;
      if(mp.find(now) != mp.end()) {
      	break;
      }
      mp[now] = ++ans;
    }
  	if(mp.find(0)!=mp.end())
  		cout << mp[0] << endl;
  	else cout << -1 << endl;
  	return 0;
}


Measured memory_bytes: 66124
#include<bits/stdc++.h>
using namespace std;
# define MOD 1000000007

/*
	Provide two numbers and it'll return it's gcd
*/
long long int gcd(long long int a,long long int b){
	if(b==0) return a;
	return gcd(b,a%b);
}

long long int lcm(long long int a, long long int b){
	return (a*b)/gcd(a,b);
}

long long int power1(long long int base,long long int po){
	long long int ret = 1;

	while(po){
		if(po%2){
			ret = (ret*base)%MOD;
		}

		base = (base*base)%MOD;
		po/=2;
	}
	return ret;
}

int main(){
	vector<long long int> vec;

	long long int x;

	cin>>x;

	long long int ans = 100;

	int i = 0;
	
	while(ans<x){
		ans = ans*1.01;
		i++;
	}
	
	cout<<i<<endl;
}

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

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

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

// Self settings
// clang-format off
#define MAX_N 300000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
// clang-format on

int N;
int A[MAX_N + 1];
int B[MAX_N + 1];

void solve()
{
  vector<int> b(N + 1);
  for (int i = N; i >= 1; i--) {
    int sum = 0;
    for (int j = i + i; j <= N; j += i) {
      sum ^= b[j];
    }
    b[i] = sum ^ A[i];
  }
  vector<int> ans;
  for (int i = 1; i <= N; i++) {
    if (b[i]) ans.push_back(i);
  }
  cout << ans.size() << endl;
  REP(i, ans.size())
  {
    printf("%d%c\n", ans[i], i + 1 == ans.size() ? '\n' : ' ');
  }
}

int main(void)
{
  cin >> N;
  // 1-indexed
  REP(i, N) cin >> A[i + 1];
  solve();
  return 0;
}


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

struct Point { double x, y; };

void koch(int n, Point a, Point b) {
  if (n == 0) return;

  Point s,t,u;
  double th = 60.0 * M_PI / 180.0;

  s.x = (2.0 * a.x + 1.0 * b.x) / 3.0;
  s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;
  t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
  t.y = (1.0 * a.y + 2.0 * b.y) / 3.0;
  u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
  u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;

  koch(n - 1, a, s);
  printf("%.8f %.8f\n", s.x, s.y);
  koch(n - 1, s, u);
  printf("%.8f %.8f\n", u.x, u.y);
  koch(n - 1, u, t);
  printf("%.8f %.8f\n", t.x, t.y);
  koch(n - 1, t, b);
}

int main() {
  Point a, b;
  int n;

  scanf("%d", &n);

  a.x = 0;
  a.y = 0;
  b.x = 100;
  b.y = 0;

  printf("%.8f %.8f\n", a.x, a.y);
  koch(n, a, b);
  printf("%.8f %.8f\n", b.x, b.y);

  return 0;
}



Measured memory_bytes: 2616
# -*- coding: utf-8 -*-
# 標準入力の取得
S = input()

# 求解処理
T = ""
t = -1
result = True
while True:
    s = S[t]
    if s == "m":
        T = "dream" + T
    elif s == "e":
        T = "erase" + T
    elif s == "r":
        s = S[t-2]
        if s == "m":
            T = "dreamer" + T
        elif s == "s":
            T = "eraser" + T
        else:
            result = False
            break

    else:
        result = False
        break

    if len(S) == len(T):
        result = (S == T)
        break
    t = -len(T) - 1

# 結果出力
if result:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 3452
import java.util.*;
public class Main {
	public static void main(String[] args){
		
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
        int a = sc.nextInt();
		int b = sc.nextInt();
		
      	int divide = a/k;
      if (a%k==0) {System.out.println("OK");}
      else if (((divide+1)*k) <= b)
      {System.out.println("OK");}
      else {System.out.println("NG");}	
    
	}
}

Measured memory_bytes: 35464
#include<iostream>

using namespace std;

int X,Y;

int main()
{
    cin >> X >> Y;
    if( Y < 2*X || Y > 4*X){
        cout << "No" << endl;
        return 0;
    }
    for(int A=X;A>=0;A--){
        if((A*2 + (X-A)*4) == Y){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;

    return 0;
    
}

Measured memory_bytes: 3132
#include <stdio.h>

int main(){

  int a,b;
  int g;

  scanf("%d %d",&a,&b);
  g = gcd(a,b);
  printf("%d\n",g);

  return 0;

}

int gcd(int a, int b){

  int c = a%b;
  if(c==0)return b;
  else gcd(b,c);

}

Measured memory_bytes: 592
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int num,vet[200005],nex[200005],head[100005];
int s,ans,a[100005],b[100005],f[100005],flag[100005];
inline int read()
{
	char ch=getchar(),last='!'; int ans=0;
	while (ch<'0'||ch>'9') last=ch,ch=getchar();
	while (ch<='9'&&ch>='0') ans=ans*10+ch-48,ch=getchar();
	if (last=='-') ans=-ans;
	return ans;
}
void add(int u,int v)
{
	num++;
	vet[num]=v; nex[num]=head[u]; head[u]=num;
}
void dfs(int u)
{
	f[u]=1; b[++s]=u;
	for (int i=head[u]; i; i=nex[i])
		if (!f[vet[i]]) dfs(vet[i]);
}
int main()
{
	int n=read(),m=read();
	for (int i=1; i<=n; i++) a[i]=read();
	for (int i=1; i<=m; i++)
	{
		int x=read(),y=read();
		add(x,y); add(y,x);
	}
	for (int i=1; i<=n; i++)
		if (!f[i])
		{
			s=0; dfs(i);
			for (int j=1; j<=s; j++) flag[a[b[j]]]=1;
			for (int j=1; j<=s; j++) 
				if (flag[b[j]]) ans++;
			for (int j=1; j<=s; j++) flag[a[b[j]]]=0;
		}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 4736
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
int n;
int a[102];
int main() {
    cin >> n;
    double x, ans = 0;;
    for (int i = 1; i <= n; i++) {
        cin >> x;
        ans += 1 / x;
    }
    cout << 1 / ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{

    public static void main(String[]args){
        Scanner sc = new Scanner(System.in);
        long a=sc.nextInt();
        long b=sc.nextInt();
        long c=sc.nextInt();
        long d=sc.nextInt();
        long val1=a*c;
        long val2=a*d;
        long val3=b*c;
        long val4=b*d;
        long max=Math.max(Math.max(Math.max(val1,val2),val3),val4);
        System.out.println(max);
        }
    }


Measured memory_bytes: 35636
using System;
using System.Linq;

namespace C
{
	internal class Program
	{
		public static void Main(string[] args)
		{
			var n = int.Parse(Console.ReadLine());
			var an = Console.ReadLine().Split().Select(int.Parse).ToArray();

			var result = an[0];
			for (var i = 1; i < n; i++) { result = GetGcd(result, an[i]); }

			Console.WriteLine(result);
		}

		private static int GetGcd(int a, int b)
		{
			if (b > a)
			{
				var tmp = a;
				a = b;
				b = tmp;
			}

			while (a % b != 0)
			{
				var tmp = a;
				a = b;
				b = tmp % b;
			}

			return b;
		}
	}
}

Measured memory_bytes: 21728
list_numS = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
list_numH = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
list_numC = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
list_numD = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
count_num = int(input())
for count in range(count_num):
    suit, card_num = list(map(str, input().split()))
    if suit == "S":
        list_numS.remove(int(card_num))
    elif suit == "H":
        list_numH.remove(int(card_num))
    elif suit == "C":
        list_numC.remove(int(card_num))
    elif suit == "D":
        list_numD.remove(int(card_num))
for counts in range(1, len(list_numS) + 1):
    print("S", list_numS[counts - 1])
    counts += 1
for counth in range(1, len(list_numH) + 1):
    print("H", list_numH[counth - 1])
    counth += 1
for countc in range(1, len(list_numC) + 1):
    print("C", list_numC[countc - 1])
    countc += 1
for countd in range(1, len(list_numD) + 1):
    print("D", list_numD[countd - 1])
    countd += 1



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

int main() {
  int N, A;
  cin >> N;
  
  for(int i = 0; i < N; i++) {
    string S;
    cin >> S;
    if(S == "Y")
      A += 1;
  }
  
  if(A == 0)
    cout << "Three" << endl;
  else
    cout << "Four" << endl;
  
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <algorithm>

using namespace std;

int main()
{
    int n,x[100005],y[100005],t[100005];
    cin>>n;
    x[0]=0,y[0]=0,t[0]=0;
    for (int i=1;i<=n;i++)
    {
        cin>>t[i]>>x[i]>>y[i];
        if (abs(x[i]-x[i-1])+abs(y[i]-y[i-1])<=t[i]-t[i-1])
        {
            if (((t[i]-t[i-1])-(abs(x[i]-x[i-1])+abs(y[i]-y[i-1])))%2==1) {cout<<"No"<<endl; return 0;}
        }
        else
        {
            cout<<"No"<<endl; return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <math.h>
typedef long long ll;
using namespace std;

int main()
{
	int h, w, n;
	cin >> h >> w >> n;
	int cnt = 0;
	int total = 0;

	for (int i = 0; i < n; i++)
	{
		if (h > w)
		{
			total += h;
			cnt++;
		}
		else
		{
			total += w;
			cnt++;
		}

		if (total >= n) break;
	}

	cout << cnt << endl;
}

Measured memory_bytes: 256
from collections import Counter


def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)


def combination(n, r, mod=10**9+7):
    """
    nCr mod m
    """
    if n < r:
        return 0
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res


n, p = map(int, input().split())
a = list(map(int, input().split()))
b = [ai % 2 for ai in a]
c = Counter(b)

ans = 0
if p == 0:
    even = (2 ** c[0])
    odd = 1
    for i in range(2, c[1] + 1, 2):
        odd += combination(c[1], i)
    ans = even * odd
else:
    even = (2 ** c[0])
    odd = 0
    for i in range(1, c[1] + 1, 2):
        odd += combination(c[1], i)
    ans = even * odd

print(ans)

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  ll n;
  R n;
  ll a[n];
  rep(i,n) R a[i];
  sort(a,a+n);
  ll sum=0,ans=0;
  rep(i,n) {
    sum+=a[i];
    if(a[i]%2==0) continue;
    ans^=i+1;
  }
  if(ans) pr("first");
  else pr("second");
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 1024
import math
import keyword

def Next(): return input()
def NextInt(): return int(Next())
def NextInts(): return map(int,input().split())
def Nexts(): return map(str,input().split())
def NextIntList(): return list(map(int,input().split()))
def RowInts(n): return [input() for i in range(n)]

n = NextInt()
st = set()
for i in range(n):
    s = input()
    st.add(s)
print(len(st))

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

int main(){
    int rumax=0,rdmax = -2000000001,lumax = -2000000001,ldmax = -2000000001;
    int n,dmax=0;
    vector<pair<int,int>> v;
    cin >> n;
    rep(i,n){
        int x,y;
        cin >> x >> y;
        v.push_back({x,y});
        rumax = max(rumax,(x+y));
        rdmax = max(rdmax,(x-y));
        lumax = max(lumax,(y-x));
        ldmax = max(ldmax,(0-x-y));
    }

    for(auto u:v){
        dmax = max(rumax-(u.first+u.second),dmax);
        dmax = max(rdmax+(0-u.first+u.second),dmax);
        dmax = max(lumax+(u.first-u.second),dmax);
        dmax = max(ldmax+(u.first+u.second),dmax);
    }

    cout << dmax << endl;
}


Measured memory_bytes: 5288
lst1=[1,3,5,7,8,10,12]
lst2=[4,6,9,11]
lst3=[2]
a,b=map(int,input().split())
if a in lst1 and b in lst1:
    print("Yes")
elif a in lst2 and b in lst2:
    print("Yes")
elif a in lst3 and b in lst3:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
package main
import "fmt"

func main() {
	var N, K int
	var R, S, P int
	var T string

	fmt.Scan(&N, &K)
	fmt.Scan(&R, &S, &P)
	fmt.Scan(&T)

	var point int
	pointGet := make(map[rune]int,2)
	pointGet['r'] = P
	pointGet['p'] = S
	pointGet['s'] = R


	winFlg := make(map[int]bool, len(T))
	
	for num, r := range T[:N]{
		if num < K{
			point += pointGet[r]
			winFlg[num] = true
		} else {
			//k回前同じ手でない
			//k回前負けている
			if T[num] != T[num - K] || winFlg[num - K] == false {
				point += pointGet[r]
				winFlg[num] = true
			}
		}
		
	}
	fmt.Println(point)
}



Measured memory_bytes: 3072
using System;

namespace B
{
	class B
	{
		static void Main(string[] args)
		{
			string[] inputs = Console.ReadLine().Split(' ');
			int N = int.Parse(inputs[0]);
			int H = int.Parse(inputs[1]);
			int W = int.Parse(inputs[2]);

			int count = 0;
			for(int i=0; i<N; i++) {
				inputs = Console.ReadLine().Split(' ');
				int A = int.Parse(inputs[0]);
				int B = int.Parse(inputs[1]);
				if(A >= H && B >= W)
					count++;
			}
			Console.WriteLine(count);
		}
	}
}


Measured memory_bytes: 13140
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#define ll long long
using namespace std;
template <class T>
inline void rd(T &x)
{
	x=0; char c=getchar(); int f=1;
	while(!isdigit(c)){if(c=='-')f=-1; c=getchar();}
	while(isdigit(c)) x=x*10-'0'+c,c=getchar(); x*=f;
}
const int N=1e5+10;
int fa[N],n,q;
ll m;
struct Que { int x,y,c; }Q[N];
int find(int x) { return fa[x]==x?x:fa[x]=find(fa[x]); }
void FAIL() {
	printf("No");
	exit(0);
}
int main() {
	rd(n),rd(m),rd(q);
	for(int i=1;i<=n;++i) fa[i]=i;
	for(int i=1;i<=q;++i) {
		rd(Q[i].x),rd(Q[i].y),rd(Q[i].c);
		Q[i].x++,Q[i].y++;
		if(Q[i].c==0)
			fa[find(Q[i].x)]=find(Q[i].y);
	}
	int flg=0;
	for(int i=1;i<=q;++i) if(Q[i].c==1) {
		flg=1;
		if(find(Q[i].x)==find(Q[i].y)) FAIL();
	}
	int M=0;
	for(int i=1;i<=n;++i) M+=find(i)==i;
	if(m>M*(ll)(M-1)/2+(n-M)) FAIL();
	if(flg&&m<n) FAIL();
	printf("Yes");
	return 0;
}

Measured memory_bytes: 1792
//confilm 0LL and 1LL
//confilm cornercases such as 0
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecVec = vector<Vec>;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPR(i, n, 1)
#define co(n) cout << (n) << endl
#define cosp(n) cout << (n) << ' '
#define setp(n) cout << fixed << setprecision(n);
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T& b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T& b){if(a > b){a = b; return true;} return false;}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const double PI = acos(-1);
const double EPS = 1e-9;

bool desc(const P &a, const P &b){
	return a.sc > b.sc;
}

int main(void){
	ll n, m;
	cin >> n >> m;
	Vec a(n);
	rep(i, n) cin >> a[i];
	sort(all(a));

	VecP q(m);
	rep(i, m) cin >> q[i].fs >> q[i].sc;
	sort(all(q), desc);
	
	ll pos = 0, id = 0;
	while(pos < n && id < m){
		rep(i, q[id].fs){
			if(a[pos] < q[id].sc) a[pos++] = q[id].sc;
			else{
				pos = n;
				break;
			}
		}
		id++;
	}
	ll ans = 0;
	rep(i, n) ans += a[i];
	co(ans);

	return 0;
}


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

#define int long long
#define INF 1e18

int n;

vector<int> h;
vector<int> a;

struct node{
    node* l, *r;
    int val;
};

void Build(int l, int r, node *root){
    if(l == r){
        return;
    }
    node* L = new node{NULL,NULL,0};
    node* R = new node{NULL,NULL,0};
    root->l = L;
    root->r = R;
    int mid = (l+r) >> 1;
    Build(l, mid, root->l);
    Build(mid+1, r, root->r);
}

int Add(int l, int r, node *root, int val, int index){
    if(index < l || index > r) return root->val;
    if(index == l && index == r){
        root->val = val;
        return val;
    }
    int mid = (l+r)>>1;
    return root->val = max(Add(l,mid, root->l, val, index), Add(mid+1, r, root->r, val, index));
}

int getMax(int l, int r, node* root, int qL, int qR){
    if(qR < l || qL > r) return -INF;
    if(qR >= r && qL <= l) return root->val;
    int mid = (l+r)>>1;
    return max(getMax(l,mid, root->l, qL, qR), getMax(mid+1, r, root->r, qL, qR));
}

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

    h.resize(n+1);
    a.resize(n+1);

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

    node* root = new node{NULL, NULL, 0};

    Build(1,n,root);

    for(int i = 1; i <= n; i++){
        int maxi = getMax(1,n,root,1,h[i]-1);
        if(maxi == -INF) maxi = 0;
        Add(1,n,root,maxi+a[i],h[i]);
    }

    cout << root->val << endl;
}


Measured memory_bytes: 15872
#include<cstdio>
#include<cstring>
#include<algorithm>
#define N 20
using namespace std;

int n, m, map[N][N], x, y, z, w[32770], bin[N], f[32770][N], ans, s, ss;

int main(){
	scanf("%d%d", &n, &m);
	memset(map, 0, sizeof(map));
	for(int i=1; i<=m; i++){scanf("%d%d%d", &x, &y, &z); map[x][y]=map[y][x]=z;}
	bin[0]=1; for(int i=1; i<=n; i++)bin[i]=bin[i-1]<<1;
	for(int i=0; i<=bin[n]-1; i++){
		w[i]=0;
		for(int j=1; j<=n; j++)if(i&bin[j-1])
			for(int k=j+1; k<=n; k++)if(i&bin[k-1])w[i]+=map[j][k];
	}
	memset(f, -1, sizeof(f));
	for(int i=1; i<=bin[n]-1; i++)if(i&bin[0])
		for(int j=1; j<=n; j++)if(i&bin[j-1]){
			if(j==1){f[i][j]=w[i]; continue;}
			s=i-bin[j-1];
			for(int k=1; k<=n; k++)if(j!=k&&i&bin[k-1]&&map[k][j]){
				x=k>=2?bin[0]+bin[k-1]:bin[0];
				s-=x;
				for(int s1=s; s1>=0; s1=(s1-1)&s){
					ss=s1+x; if(f[ss][k]>=0)f[i][j]=max(f[i][j], f[ss][k]+w[i-ss]+map[k][j]);
					if(!s1)break;
				}
				s+=x;
			}
		}
	ans=-f[bin[n]-1][n];
	for(int i=1; i<=n; i++)
		for(int j=i+1; j<=n; j++)ans+=map[i][j];
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 2944
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int d = sc.nextInt();
		int t = sc.nextInt();
		int s = sc.nextInt();
		if (d <= t*s) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}
	
}


Measured memory_bytes: 36104
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {

  public static void main(String[] args) {
    solve(System.in, System.out);
  }

  static void solve(InputStream is, PrintStream os) {
    Scanner sc = new Scanner(is);

    /* read */
    int n = sc.nextInt();
    int k = sc.nextInt();
    String s = sc.next();

    boolean[] sbool = new boolean[n];
    for (int i = 0; i < n; i++) {
      sbool[i] = s.charAt(i) == '1';
    }

    /* logic */
    List<Block> blocks = partitioning(sbool);
    int longest = searchLongestMergedBlocks(blocks, k);
    os.println(longest);
  }

  private static List<Block> partitioning(boolean[] sbool) {

    List<Block> blocks = new ArrayList<>();

    int right = 0;
    for (int left = 0; left < sbool.length; left++) {

      while (right < sbool.length && (sbool[left] == sbool[right])) {
        right++;
      }

      // found the block. if the longest block, let's save
      if (blocks.isEmpty() || ((blocks.get(blocks.size() - 1).end) != right)) {
        Block block = new Block();
        block.start = left;
        block.end = right;
        block.handstanding = sbool[left];
        blocks.add(block);
      }
    }
    return blocks;
  }

  private static int searchLongestMergedBlocks(List<Block> blocks, int remaining) {

    int longest = 0;
    // search the every reversed result starting i-indexed block
    for (int i = 0; i < blocks.size(); i++) {
      Block start = blocks.get(i);

      int mergingBlocks = start.handstanding ? 2 * remaining : 2 * remaining - 1;
      int endIndex = Math.min(Math.max(mergingBlocks, 0) + i, blocks.size() - 1);
      Block end = blocks.get(endIndex);

      int length = end.end - start.start;

      if (length > longest) {
        longest = length;
      }
    }

    return longest;
  }


  private static class Block {

    boolean handstanding;

    // half-open interval
    int start;
    int end;

    @Override
    public String toString() {
      return "Block{" +
          "handstanding=" + handstanding +
          ", start=" + start +
          ", end=" + end +
          '}';
    }
  }

}

Measured memory_bytes: 28216
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define MSET(x,y) memset(x,y,sizeof(x))
#define M 
using namespace std;
int main()
{
    int n;
    while (~scanf("%d", &n)) {
        puts(n==3 || n==5 || n==7 ? "YES" : "NO");
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<cmath>
#include<limits>
#define ll long long
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define pint_INF 2000000000
#define ll_INF 	9223372036854775807
#define MOD 1000000007
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvc vector<vector<char>>
#define vll vector<long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int>>
#define sysp system("PAUSE")
#define pno cout << "no" << endl
#define pyes cout << "yes" << endl
#define pYes cout << "Yes" << endl
#define pNo cout << "No" << endl
using namespace std;

void A() {
	char c; cin >> c;
	if ('a' <= c && c <= 'z') {
		cout << "a" << endl;
	}
	else {
		cout << "A" << endl;
	}
}

void B(){
    int N,K; cin >> N >> K;
    vi vec(N);
    rep(i,N) cin >> vec[i];
    sort(ALL(vec));

    int ans = 0; rep(i,N) ans += vec[i];

    cout << ans << endl;
}

inline char itoc(int i) {
	char c;
	if (i == 0) i += 26;
	c = 'a' + (i - 1);
	return c;
}

void C(){
    ll N; cin >> N;
	string ans = "";
	while (N) {
		int m = N % 26;
		N /= 26;
		if (m == 0) N--;
		ans += itoc(m);
	}
	reverse(ans.begin(), ans.end());
	cout << ans << endl;
}
int main(){
    A();
}

Measured memory_bytes: 3616
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n + 1];
        for (int i = 1; i <= n; i++) {
            a[i] = sc.nextInt();
        }

        // 後ろから順にボールが入っているかをXORで計算していく
        int[] ball = new int[n + 1];
        for (int i = n; i >= 1; i--) {
            int sum = 0;
            for (int j = i + i; j <= n; j += i) {
                // i倍数の部分だけ計算しなおす
                sum ^= ball[j];
            }
            // iとXORする
            ball[i] = sum ^ a[i];
        }

        int ballCount = (int) Arrays.stream(ball).filter(s -> s != 0).count();
        if (ballCount == 0) {
            System.out.println(0);
        } else {
            // 先にボールの個数を出力して、それ以外はボールが入っている場所だけ出力
            System.out.println(ballCount);
            for (int i = 1; i <= n; i++) {
                if (ball[i] == 0) {
                    continue;
                }
                System.out.println(i);
            }
        }
    }
}



Measured memory_bytes: 73136
n = int(input())

a = 2
res = dict()

for i in range(1, 142):
    for j in range(1, 142):
        for k in range(1, 142):
            tmp = int(((i + j) ** 2 + (j + k) ** 2 + (k + i) ** 2) / 2)
            res[tmp] = res.get(tmp, 0) + 1

for i in range(n):
    print(res.get(i + 1, 0))


Measured memory_bytes: 78016