akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

bool is_ok(vector<int64_t>& as, int64_t n, int64_t m, int64_t v, int64_t p, int64_t i)
{
	int64_t cv = (n - i);

	int64_t ti = p - 2;
	int64_t av = as[i] + m;

	if (as[ti + 1] > av) return false;

	int64_t rc = 0;
	FOR_LT(j, ti + 1, i) {
		rc += av - as[j];
	}

	int64_t nc = (v - cv - (ti + 1)) * m;

	return (nc <= rc);
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	int n; cin >> n;
	int m, v, p; cin >> m >> v >> p;

	vector<int64_t> as(n);
	for (auto& a : as) {
		cin >> a;
	}
	sort(as.begin(), as.end(), greater<int64_t>());

	int low  = p - 1;
	int high = n - 1;

	while (low != high) {
		int mid = (high + low) / 2;
		if (mid == low) mid++;
		bool c = is_ok(as, n, m, v, p, mid);
		if (c) {
			low = mid;
		}
		else {
			if (high == mid) high--;
			else high = mid;
		}
	}

	cout << (low + 1) << endl;

	return 0;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {    
    
  public static void main(String[] args) {              
     Scanner sc = new Scanner(System.in);
     
     String S = sc.next();
     
     int N = S.length();                              
     int current = N;
     
     
     while(current > 0){
         
             if(current >= 7){
                 String sub = S.substring(current-7,current);
                 if(sub.equals("dreamer")){
                     current -= 7;
                     continue;
                 }             
             }
             
             if(current >= 6){
                 String sub = S.substring(current - 6,current);
                 if(sub.equals("eraser")){
                     current -= 6;
                     continue;
                 }
             }
         
             if(current >= 5){
                 String sub = S.substring(current - 5,current);
                 if(sub.equals("dream") || sub.equals("erase")){
                     current -= 5;
                     continue;
                 }                                  
             }
                       
             System.out.println("NO");
             return;                                   
     }
     
     System.out.println("YES");     
     
  }          
}

Measured memory_bytes: 26892
mod=1e9+7

if __name__ == '__main__':
    L=input()
    N=len(L)
    DP1=[0]*(N)
    DP2=[0]*(N)
    DP1[0]=1
    DP2[0]=2

    for i in range(N-1):
        DP1[i+1]=3*DP1[i]
        if L[i+1]=="1":
            DP1[i+1]+=DP2[i]
            DP2[i+1]=2*DP2[i]
        else:
            DP2[i + 1] = DP2[i]
        DP1[i+1]%=mod
        DP2[i+1]%=mod

    print(int((DP2[N-1]+DP1[N-1])%mod))




Measured memory_bytes: 45936
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define abdelrahman010 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ordered_set tree<int, null_type, less_equal<int>,rb_tree_tag, tree_order_statistics_node_update>
typedef long long ll;
using namespace __gnu_pbds;
using namespace std;
const int N = 2e5 + 5;
int n , f[105][10];
int p[105][11] , c[1 << 10];
int memo[10][1 << 10];
int solve(int i , int mask) {
    if(i == 10)
        return mask ? c[mask] : -2e9;
    int &ans = memo[i][mask];
    if(~ans)
        return ans;
    return ans = max(solve(i + 1 , mask) , solve(i + 1 , mask | (1 << i)));
}
int main() {
    abdelrahman010
    cin >> n;
    for(int i = 0;i < n;i++)
        for(int j = 0; j < 10;j++)
                cin >> f[i][j];
    for(int i = 0;i < n;i++)
        for(int j = 0;j <= 10;j++)
            cin >> p[i][j];
    for(int i = 0;i < (1 << 10);i++)
        for(int j = 0;j < n;j++) {
            int cnt = 0;
            for(int k = 0;k < 10;k++)
                cnt += (((1 << k) & i) && f[j][k]);
            c[i] += p[j][cnt];
        }
    memset(memo , -1 , sizeof memo);
    cout << solve(0 , 0);
    return 0;
}


Measured memory_bytes: 256
import numpy as np

X, Y, A, B, C = list(map(int, input().split()))
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

p_sorted = sorted(p, reverse=True)
q_sorted = sorted(q, reverse=True)
r_sorted = sorted(r, reverse=True)

p_selected = p_sorted[0:X]
q_selected = q_sorted[0:Y]

list_selected = sorted((p_selected + q_selected + r_sorted), reverse=True)
list_top = list_selected[0:X+Y]
answer = np.sum(list_top)
print(answer)

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

using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  vector<list<int>> v(N);
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < M; ++j) {
      int a;
      cin >> a;
      v[i].push_back(a);
    }
  }
  int ans = 1e9;
  for (int i = M; i > 0; --i) {
    unordered_map<int, int> mp;
    for (int j = 0; j < N; ++j) {
      mp[v[j].front()]++;
    }
    int pre = 0, rem = 0;
    for (auto p : mp) {
      if (p.second > pre) {
        rem = p.first;
        pre = p.second;
      }
    }
    for (int j = 0; j < N; ++j) {
      v[j].remove_if([=](const int &x) { return x == rem; });
    }
    ans = min(ans, pre);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3072
#include<stdio.h>
int main(void)
{
	int a,b,c;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	if(a<b&&b<c)
	{
	printf("Yes\n");
	}
	else
	{
	printf("No\n");
	}
	return 0;
}


Measured memory_bytes: 1976
//問題URL
//

//解き方メモ
//
    
#include<iostream>
using namespace std;

#define ADD 0
#define SUB 1

int calc(int num,int op,int abcd){
    if( op == ADD ) {
      num += abcd;
    } else if( op == SUB ) {
      num -= abcd;
    } else {
      exit(-1);
    }

    return num;
}

void print_op(int op){
  if (op == ADD) {
    cout << "+";
  } else if(op == SUB) {
    cout << "-";    
  } else {
    exit(-1);
  }
}

int main(){
  int n;
  int a,b,c,d;

  cin >> n;
  a = n/1000;
  b = n/100%10;
  c = n/10%10;
  d = n%10;

  for (int i = 0; i < 2; i++) {
    int result1 = calc(a,i,b);
    for (int j = 0; j < 2; j++) {
      int result2 = calc(result1,j,c);
      for (int k = 0; k < 2; k++) {
	int result3 = calc(result2,k,d);
	if(result3 == 7){
	  cout << a;
	  print_op(i);
	  cout << b;
	  print_op(j);
	  cout << c;
	  print_op(k);
	  cout << d;
	  cout << "=7" << endl;

	  return 0;
	}
      }
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define All(v) v.begin(), v.end()
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;

const int MAX_N = (int)1e4 + 5;
int C[MAX_N], ans[MAX_N], used[MAX_N];
vector<int> G[MAX_N];

int bfs(int s){
    int cur = 0, res = 0;
    queue<int> q; q.push(s);
    used[s] = 1;
    ans[s] = C[cur++];

    while(!q.empty()){
        int u = q.front(); q.pop();
        for(auto v : G[u]){
            if(!used[v]){
                used[v] = 1;
                res += C[cur];
                ans[v] = C[cur++];
                q.push(v);
            }
        }
    }

    return res;
}


int main(){
    ios::sync_with_stdio(false), cin.tie(nullptr);
    int N; cin >> N;
    for(int i=0;i<N-1;i++){
        int a, b; cin >> a >> b, a--, b--;
        G[a].push_back(b), G[b].push_back(a);
    }
    for(int i=0;i<N;i++) cin >> C[i];

    sort(C, C+N); reverse(C, C+N);

    cout << bfs(0) << endl;
    for(int i=0;i<N;i++) cout << ans[i] << ' ';
    cout << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <cstring>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <fstream>
#include <unordered_set>

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>

ll h, n;
int main() {
	cin >> h >> n;
	vector<ll> a(n), b(n), dp(h + 1, INF);
	dp[h] = 0;
	REP(i, n)cin >> a[i] >> b[i];
	REP(i, n) {
		REPR(j, h) {
			ll nx = max(0ll, j - a[i]);
			dp[nx] = min(dp[nx], dp[j] + b[i]);
		}
	}
	cout << dp[0] << endl;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>
int main(void){
  char s[100023];
  scanf("%s", s);

  char ans[50030];

  int i;

  for (i = 0; i <= strlen(s) / 2; i++) {
    ans[i] = s[2*i];
  }

  printf("%s\n", ans);
  return 0;
}


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

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

        int N = Integer.parseInt(sc.next());
        int K = Integer.parseInt(sc.next());
        int[] sunuke = new int[N];
        int d, tmp;
        int cnt = N;

        Arrays.fill(sunuke, 0);

        for (int i = 0; i < K; i++) {
            d = Integer.parseInt(sc.next());
            for (int j = 0; j < d; j++) {
                tmp = Integer.parseInt(sc.next()) - 1;
                if (sunuke[tmp] == 0) {
                    cnt--;
                }
                sunuke[tmp]++;
            }
        }

        System.out.print(cnt);
    }
}

Measured memory_bytes: 41428
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <array>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, a, n) for (int i = a; i < (n); i++)
#define all(in) in.begin(), in.end()
const int INF = 1e9;
const int MOD = 1e9 + 7;
int main() {
    int N, H, W;
    cin >> N >> H >> W;
    int ans = (N - H + 1) * (N - W + 1);
    cout << ans << endl;
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using P = pair<ll, int>;

#define INF 1e18

struct Edge {
  int to;
  ll cost;
  Edge(int to=0, ll cost=0) : to(to), cost(cost) {}
};

string rev(string s) {
  reverse(s.begin(), s.end());
  return s;
}

int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  vector<int> c(n);
  rep(i,n) cin >> s[i] >> c[i];
  rep(i,n) {
    s.push_back(rev(s[i]));
    c.push_back(c[i]);
  }
  int idcnt = 1;
  vector< vector<int> > id(n*2);
  rep(i,n*2) {
    int l = s[i].size();
    id[i].resize(l);
    rep(j,l) id[i][j] = idcnt++;
  }

  vector< vector<Edge> > G(idcnt);
  rep(i1,n*2) {
    int l1 = s[i1].size();
    rep(j,l1) {
      int v = id[i1][j];
      rep(i2,n*2) {
        if (i1/n==i2/n) continue;
        int l2 = s[i2].size();
        int w = min(l2,l1-j);
        if (s[i1].substr(j,w) != s[i2].substr(0,w)) continue;
        int u;
        if (l2 > w) u = id[i2][w];
        else if (l1-j > w) u = id[i1][j+w];
        else u = 0;
        G[v].emplace_back(u,c[i2]);
      }
    }
  }

  vector<ll> dist(idcnt,INF);
  priority_queue<P, vector<P>, greater<P>> q;
  auto push = [&] (int v, ll x) {
    if (dist[v] <= x) return;
    dist[v] = x;
    q.emplace(x,v);
  };

  rep(i,n) push(id[i][0],c[i]);
  while (!q.empty()) {
    int v;
    ll c;
    tie(c,v) = q.top(); q.pop();
    if (c != dist[v]) continue;
    for (auto e : G[v]) push(e.to,c+e.cost);
  }

  ll ans = dist[0];
  rep(i,n*2) {
    int l = s[i].size();
    rep(j,l) {
      string t = s[i].substr(j);
      if (t == rev(t)) ans = min(ans, dist[id[i][j]]);
    }
  }
  if (ans == INF) ans = -1;

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3752
import sys
sys.setrecursionlimit(1000000000)
from itertools import count
from functools import lru_cache
from collections import defaultdict
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok
#


def main():
    a,_ = mis()
    b,_ = mis()
    print(int(a!=b))


main()


Measured memory_bytes: 3828
def is_kaibun(kaibun):
	for i in range(len(kaibun)//2):
		if kaibun[i] != kaibun[-i-1]:
			return False
	return True

def main():
	S = input()
	S2 = S[:(len(S)-1)//2]
	S3 = S[(len(S)+3)//2-1:]
	if is_kaibun(S) and is_kaibun(S2) and is_kaibun(S3):
		print('Yes')
	else:
		print('No')

if __name__ == "__main__":
    main()

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

int main() {
  int l, r, d;
  cin >> l >> r >> d;

  int ans = 0;
  for (int i = l; i <= r; i++) {
    if (i % d == 0) ans++;
  }

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

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Map = map<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
ll INF=1LL<<60;
ll MOD=1000000007;



int main(){
    ll N;
    cin >> N;
    vector<ll> L(N,0);
    vector<ll> R(N,0);
    ll recL=0;ll MaxL=0;
    for(ll i=0;i<N;i++){
        cin>>L[i]>>R[i];
        if(MaxL<L[i]){
            MaxL=L[i];
            recL=i;
        }
    ;}
    if(N==2){
        cout<<R[0]+R[1]-L[0]-L[1]+2<<endl;return 0;
    }
    vector<P> pq(0);
    for(ll i=0;i<N;i++){
        if(i!=recL)pq.push_back(P(R[i],L[i]))
    ;}
    sort(pq.begin(), pq.end());
    vector<ll> lmax(N-1,0);
    ll q=0;
    for(ll i=0;i<N-1;i++){
        q=max(q,pq[i].second);
        lmax[i]=q
    ;}
    //L[recL]が最大
    //最終的にrecL側のRの選考基準をｒとする
    //Rがpq[r]以上は仲間

    ll ans=0;

    //pq[0]が敵の時かつ仲間いるとき
    for(ll r=1;r<=N-2;r++){
        ans=max(ans,max(min(pq[r].first,R[recL])-MaxL+1,0LL)+max(pq[0].first-lmax[r-1]+1,0LL));
    ;}
    //全員敵
    ans=max(ans,max(pq[0].first-lmax[N-2]+1,0LL)+R[recL]-MaxL+1);
    //pq[0]が味方の時;
    ll ans2=0;
    ans2+=max(0LL,min(pq[0].first,R[recL])-MaxL+1);//味方
    ll check;
    for(ll i=0;i<N;i++){
        if(L[i]==pq[0].second&&R[i]==pq[0].first&&i!=recL){check=i;break;}
    ;}
    priority_queue<ll> vec;
    for(ll i=0;i<N;i++){
        if(i!=recL&&i!=check){
            vec.push(R[i]-L[i]+1);
        }
    ;}
    ans2+=vec.top();
    ans=max(ans,ans2);

    cout<<ans<<endl;


    return 0;
}


Measured memory_bytes: 6512
#include <stdio.h>

int main()
{
	int n, s = 0, i;
	int a[20], b[50], c[50];
	scanf("%d", &n);
	for(i = 0; i < n; i++){
		scanf("%d", &a[i]);
	}
	for(i = 0; i < n; i++){
		scanf("%d", &b[i]);
	}
	for(i = 0; i < n - 1; i++){
		scanf("%d", &c[i]);
	}
	for(i = 0; i < n; i++){
		s += b[a[i] - 1];
		if(i > 0 && a[i] == a[i - 1] + 1){
			s += c[a[i - 1] - 1];
		}
	}
	printf("%d\n", s);
	return 0;
}

Measured memory_bytes: 128
import java.io.*;

public class Main {
    public static void main(String[] args) {
        int n;


        try (InputScanner is = new InputScanner(System.in)) {
            n = is.ni();
        }
        System.out.println( n % 2 != 0 ? (n+1)/2:n/2);
    }

    //-------------------------------------------------------------------
    public static class InputScanner implements Closeable {
        private final BufferedReader br;
        private String[] element;
        private int elementIndex;

        public InputScanner(InputStream is) {
            this.br = new BufferedReader(new InputStreamReader(is));
        }

        public String next() {
            return this.nextElement();
        }

        //next int
        public int ni() {
            return Integer.parseInt(this.nextElement());
        }

        //next long
        public long li() {
            return Long.parseLong(this.nextElement());
        }

        //next int array
        public int[] nia(int n) {
            int[] arr = new int[n];
            for (int i = 0; i < n; i++) {
                arr[i] = this.ni();
            }
            return arr;
        }

        private void readLine() {
            try {
                this.element = this.br.readLine().split("\\s");
            } catch (IOException e) {
                e.printStackTrace();
            }
            this.elementIndex = 0;
        }

        private String nextElement() {
            if (!hasElement()) {
                this.readLine();
            }
            return this.element[this.elementIndex++];
        }

        private boolean hasElement() {
            return this.element != null && this.element.length > this.elementIndex;
        }

        @Override
        public void close() {
            if (this.br != null) {
                try {
                    this.br.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
//-------------------------------------------------------------------
}


Measured memory_bytes: 21332
#abc155b
import sys

n=int(raw_input())
a=map(int,raw_input().split())
b=[]
for i in range(n):
 if a[i]%2==0:
  b.append(a[i])
for i in range(len(b)):
 if not (b[i]%3==0 or b[i]%5==0):
  print 'DENIED'
  sys.exit()
print 'APPROVED'


Measured memory_bytes: 2568
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String [] d = new String[n];
		String [] dd = new String[n];
		int count = 0;
		for(int i = 0; i < n; i++) {
			d[i] = sc.next();
			dd[i] = "0";
		}
		for(int i = 0; i < n; i++) {
			boolean same = true;
			for(int j = 0; j < n;j++) {
				if(d[i].equals(dd[j])) {
					same = false;
					break;
				}
			}
			dd[i] = d[i]; 
			if(same)count++;
		}
		System.out.println(count);
		sc.close();
	}

}


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

using namespace std;

int selectionSort(int A[], int);

int main()
{
  int N,A[100],k;
  cin>>N;
  for(int i=0;i<N;i++) cin>>A[i];
  k=selectionSort(A,N);
  for(int i=0;i<N;i++){
    if(i) cout<<" ";
    cout<<A[i];
  }
  cout<<endl;
  cout<<k<<endl;
}
  

int selectionSort(int A[],int n)
{
  int k=0,min,j,i;
  for(i=0;i<n;i++){
    min=i;
    for(j=i;j<n;j++){
      if(A[j]<A[min]) min=j;
    }
    swap(A[i],A[min]);
    if(A[i]!=A[min]) k++;
  }
  return k;
}



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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int X, A;
  cin >> X;
  cin >> A;
  
  if (X < A) {
    cout << 0;
  } else {
    cout << 10;
  }

}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		String[] s = saori.nextHayami().split("");
		int ans = 0;
		int count =0;
		for(int i = 0;i < s.length;i++){
			if(s[i].equals("A") || s[i].equals("C") || s[i].equals("G") || s[i].equals("T")){
				count++;
			} else {
				ans = Math.max(ans, count);
				count = 0;
			}
		}
		ans = Math.max(ans, count);
		System.out.println(ans);
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 21204
a, b, k = map(int, input().split())
y_a=[]
y_b=[]
for i in range(1, a+1):
  if a%i==0:
    y_a.append(i)
for i in range(1, b+1):
  if b%i==0:
    y_b.append(i)

d=[]
for yai in y_a:
  if yai in y_b:
    d.append(yai)
print(d[-k])

Measured memory_bytes: 3064
/*  
     author : masaow    
     g++ : 17.3.20  
*/        
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define forn(i,a,b)        for( i = a ; i < b  ; i++ )
#define debug(x)           cout << #x << " " << x << " -- "
#define I__O               ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ll                 long long  
#define p(x) 			   cout << x << "\n" ; 
#define MOD                100000007
#define pi                 pair<int,int>
#define vi                 vector <int>
#define pb                 push_back
#define vp                 vector <pair<ll,ll>>
#define endl               cout << "\n"
#define mi                 map <int,int> 
#define f1                 first 
#define s1                 second    
#define in                 insert
#define all(x)             x.begin(),x.end() 
using namespace std ; 
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set; 
const int N = 1e2+7;  
/*  
    time : 12 : 14    
    date : 19.01.2020
*/    
// int L,R,mid,target,idx ;
const ll INF = 1e11+7 ;
ll dp[N][100005];   
ll a[N][2] ;
ll n,W; 
// ll solve(ll state,ll w ) { 
// 	if(state == n )
// 		return dp[state] = 0  ;
// 	// cerr << dp[state] << ' ' ; 	 
// 	if(dp[state] != INF)
// 		return dp[state] ; 
// 	ll result  = 0    ;
// 	if(a[state][0] + w <= W) 
// 		result  =  a[state][1] + solve(state+1,a[state][0]+w) ; 
// 	result = max(result,solve(state+1,w)) ;
// 	return (dp[state] = max(result, dp[state + 1]));
// } 
int tests() 
{	
	int i,j ; 
	scanf("%lld %lld",&n,&W) ;
	forn(i,1,n + 1)
		forn(j,0,2)
			scanf("%lld",&(a[i][j])) ; 
	ll ans = 0;
	//debug(solve(0, 0));
	for(int i = 1; i <= n; i++){
		for(int j = 0; j <= W; j++){
			dp[i][j] = max((j >= a[i][0] ? dp[i - 1][j - a[i][0]] + a[i][1] : 0), dp[i - 1][j]);
			ans = max(ans, dp[i][j]);
		}
	}
	cout << ans << '\n';
	return 0 ; 
}
int32_t main(){
    I__O ;   
    int cases = 1 ; 
 	// cin >> cases;  
    while(cases--)
	    tests(); 
	return 0 ; 
}

Measured memory_bytes: 79360
blood_count = {"A"=>0, "B"=>0, "AB"=>0, "O"=>0}

while input_data = gets
  blood_type = input_data.chomp.split(',')
  blood_count[blood_type[1]] += 1
end

blood_types = ["A", "B", "AB", "O"]
blood_types.each { |blood|
  puts blood_count[blood]
}

Measured memory_bytes: 6096
#include <bits/stdc++.h>
#define ll long long
#define all(a) (a).begin(), (a).end()
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz() size()
#define fr first
#define sc second
#define pb push_back
#define er erase
#define in insert
#define pi pair<int,int>
#define pii pair<pair<int,int>,int>
#define mp make_pair
#define int long long
#define rc(s) return cout<<s,0
#define rcc(s) cout<<s,exit(0)
using namespace std;
 
const int mod=1e9+7;
const int modx=998244353;
const int per=666013;
 
struct mat{
    int rows,cols;
    int arr[55][55];
    mat operator*(mat cappa){
        mat sah;
        sah.cols = cappa.cols;
        sah.rows = rows;
        for(int i = 1 ; i <= rows ; i++)
        for(int j = 1 ; j <= cappa.cols; j++)sah.arr[i][j] = 0;
        for(int i = 1 ; i <= rows ; i++){
            for(int j = 1 ; j <= cappa.cols; j++){
                for(int k = 1 ; k <= cols ; k++){
                    sah.arr[i][j] += arr[i][k]*cappa.arr[k][j];
                    sah.arr[i][j]%=mod;
                }
            }
        }
        return sah;
    }
};
 
int n,k;
 
int32_t main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
    srand(chrono::steady_clock::now().time_since_epoch().count());
    cin >> n >> k;
    mat tab;
    tab.rows=n;
    tab.cols=n;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            cin >> tab.arr[i][j];
        }
    }
    mat tz=tab;
    --k;
    for(int i=0LL;(1LL<<i)<=k;i++){
        if(k&(1LL<<i)) tab=tab*tz;
        tz=tz*tz;
    }
    int rez=0LL;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            rez+=tab.arr[i][j];
            rez%=mod;
        }
    }
    cout << rez;
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
typedef pair<int,int> P;
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define rep(i, n) for (lint i = 0; i < (n); i++)
#define INF 1e+8
#define all(x) (x).begin(),(x).end()
#define pb push_back
lint d[205][205]={0};
lint n,m,r;
vector<lint> vr;
int res=INF;
int main(){
    cin>>n>>m>>r;
    rep(i,n){
        rep(j,n){
            if(i!=j){
                d[i][j]=INF;
            }
        }
    }
    vr.resize(r);
    rep(i,r) {
        cin>>vr[i];
        vr[i]--;
    }   
    rep(i,m){  
        lint a,b,c;
        cin>>a>>b>>c;
        a--;
        b--;
        d[a][b]=c;
        d[b][a]=c;
    }     
    for(int k=0;k<n;k++){
        for(int i=0;i<n;i++){
             for(int j=0;j<n;j++){
                d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
            }  
        }
    }
    sort(vr.begin(),vr.end());
    do{
        int sum=0;
        for(int i=0;i<r-1;i++){
            sum+=d[vr[i]][vr[i+1]];
        }
        res=min(res,sum);
    }while (next_permutation(vr.begin(), vr.end()));
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
#include<algorithm>
#include<vector>
#define N_ 1001000
using namespace std;
int n, m, Deg[N_], Q[N_], head, tail, D[N_], Res, cnt;
int B1[101000], B2[101000];
vector<int>E[N_], G[101000];
void Make_Edge(int a, int b, int c){
    E[a].push_back(b*2+c);
}
int main(){
    int i, a, b, c, x, sz, j;
    scanf("%d%d",&n,&m);
    cnt = 2*n;
    for(i=1;i<=m;i++){
        scanf("%d%d%d",&a,&b,&c);
        if(c==1){
            Make_Edge(n+a,b,1);
        }
        else{
            Make_Edge(cnt+1,cnt+4,1);
            Make_Edge(cnt+3,cnt+2,1);
            G[a].push_back(cnt+1);
            G[b].push_back(cnt+3);
            cnt+=4;
        }
    }
    for(i=1;i<=n;i++){
        Make_Edge(i,i+n,0);
        sz = G[i].size();
        if(!sz)continue;
        B1[i] = cnt+1;
        for(j=0;j<sz;j++){
            cnt++;
            Make_Edge(cnt,G[i][j],0);
            if(j)Make_Edge(cnt, cnt-1,0);
        }
        B2[i] = cnt+1;
        for(j=sz-1;j>=0;j--){
            cnt++;
            Make_Edge(cnt,G[i][j],0);
            if(j!=sz-1)Make_Edge(cnt, cnt-1,0);
        }
        for(j=0;j<sz;j++){
            Make_Edge(i,G[i][j],0);
            Make_Edge(G[i][j]+1,n+i,0);
            if(j)Make_Edge(G[i][j]+1, B1[i]+j-1,0);
            if(j!=sz-1)Make_Edge(G[i][j]+1, B2[i]+sz-j-2,0);
        }
    }
    for(i=1;i<=cnt;i++){
        for(j=0;j<E[i].size();j++){
            Deg[E[i][j]/2]++;
        }
    }
    for(i=1;i<=cnt;i++){
        if(!Deg[i])Q[++tail] = i;
    }
    while(head < tail){
        x = Q[++head];
        Res = max(Res, D[x]);
        for(i=0;i<E[x].size();i++){
            Deg[E[x][i]/2]--;
            D[E[x][i]/2] = max(D[E[x][i]/2], D[x] + E[x][i]%2);
            if(!Deg[E[x][i]/2])Q[++tail] = E[x][i]/2;
        }
    }
    if(tail != cnt){
        printf("Infinite\n");
        return 0;
    }
    printf("%d\n",Res);
}

Measured memory_bytes: 71856
#include <stdio.h>
int main(void){
    long long int A[101][101],B[101][101];
    int n, m, l;
    int i, j, k;
    scanf("%d %d %d",&n ,&m ,&l);
    for(i = 0; i < n; i++){
    	for(j = 0; j < m; j++){
	    	scanf("%lld",&A[i][j]);
	    }
    }
    for(i = 0; i < m; i++){
    	for(j = 0; j < l; j++){
    		scanf("%lld",&B[i][j]);
    	}
    }
    long long int c;
    for(i = 0; i < n; i++){
    	for(j = 0; j < l; j++){
    	    c = 0;
		    for(k = 0; k < m; k++){
			    c += A[i][k] * B[k][j];
		    }
		    if(j > 0){
		        printf(" ");
		    }
		    printf("%lld",c);
	    }
	    printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2104
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

const ll MOD = 1e9 + 7;

int main() {
  ll N;
  while (cin >> N) {
    map<ll, ll> dp;
    function<ll(ll)> solve = [&](ll S) {
      if (dp.count(S)) return dp[S];
      if (S == 0) return dp[S] = 1;
      ll res = 0;
      for (int a = 0; a <= 2; a++) {
        if (a > S) break;
        res += solve((S - a) / 2);
        res %= MOD;
      }
      return dp[S] = res;
    };
    cout << solve(N) << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define uint unsigned int
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repr(i, a, b) for (int i = a; i >= b; i--)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define sz(a) (a).size()
#define pb(a) push_back(a)
#define eb(...) emplace_back(__VA_ARGS__)
#define mp(a, b) make_pair(a, b)
#define mt(...) make_tuple(__VA_ARGS__)
using namespace std;
using pii = pair<int, int>;
template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
constexpr int MOD = 1000000007;
constexpr int INF = 1LL << 30;
constexpr double EPS = 1e-10;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int A, B, C;
  cin >> A >> B >> C;
  if (A+B < C) {
    cout << (A+B) + B + 1 << endl;
    return 0;
  }
  cout << C + B << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn = 1e6 + 10; 
const double pi = acos(-1.0);

inline ll read()
{
    ll kk=0,f=1;
    char cc=getchar();
    while(cc<'0'||cc>'9'){if(cc=='-')f=-1;cc=getchar();}
    while(cc>='0'&&cc<='9'){kk=(kk<<1)+(kk<<3)+cc-'0';cc=getchar();}
    return kk*f;
}

int main(void)
{
	int k,a,b;
	k =read();
	a =read();b =read();
	b++;
    for(int i=a;i<b;i++)
    {
    	if(i%k==0){
			printf("OK");
			return 0;
		}
	}
	printf("NG");	
	return 0;
}

Measured memory_bytes: 3700
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
double dis(double x,double y)
{
    if(x<=0 && y>=0)
    {
        return abs(x)+y;
    }
    if(x>=0 && y<=0)
    {
        return abs(x)+abs(y);
    }
    return abs(abs(x)-abs(y));
}
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    double t,mn=INT_MAX,ans,x,y;
    int n;
    cin>>n;
    cin>>x>>y;
    x*=1000;
    y*=1000;
    for(int i=1; i<=n; i++)
    {
        double a,cur;
        cin>>a;
        cur=(x)-(a*6);
        cur=dis(y,cur);
        if(cur<mn){
            mn=cur;
            ans=i;
        }
    }
    cout<<ans<<endl;


    return 0;
}


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

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

const ll mod =  1000000007;  //出力は (ans % mod + mod) % mod  (負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INF = 1152921504606846976

int main()
{
    int n; cin >> n;
    int a[n];
    rep(i,n) cin >> a[i];
    int ans[n];
    for(int i = n; i > 0; i--){
        int tmp = i;
        int cnt = 0;
        if(i > n/2){
            ans[i-1] = a[i-1];
        }else{
            while(tmp <= n){
                tmp += i;
                if(tmp <= n) cnt += ans[tmp-1]; 
            }
            //if(i == 3) cout << cnt << endl;
        }
        ans[i-1] = (cnt-a[i-1] + 2) % 2;
    }
    int k = 0;
    rep(i,n) if(ans[i]) k++;
    cout << k << endl;
    rep(i,n) if(ans[i]) cout << i+1 << ' ';
}

Measured memory_bytes: 2432
s = input()
K = int(input())
s = list(s)

# print(diff)

for i in range(len(s)):
    if s[i] != 'a':
        dist = ord('z') - ord(s[i]) + 1
        if dist <= K:
            K -= dist
            s[i] = 'a'
# print(s)
temp = K % 26
s[-1] = chr(ord(s[-1]) + temp)
# print(s)

print(''.join(s))




Measured memory_bytes: 49776
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int iinf = 1 << 28;
const long long llinf = 1ll << 60;
const double PI = 3.14159265;


int main() {
    int n,m; cin>>n>>m;
    vector<vector<ll>> dp(m+1, vector<ll>(1<<n, llinf));
    for (int i = 0; i <= m; ++i) dp[i][0] = 0LL;
    vector<ll> cost(m);
    vector<int> mask(m);
    for (int i = 0; i < m; ++i) {
        int nboxes;
        cin >> cost[i] >> nboxes;
        int maskk = 0;
        for (int j = 0; j < nboxes; ++j) {
            int box; cin >> box;
            maskk |= 1 << (box - 1);
        }
        mask[i] = ~maskk;
    }
    for (int i = m-1; i >= 0; --i) {
        for (int j = 1; j < (1<<n); ++j) {
            dp[i][j] = min(dp[i+1][j], cost[i] + dp[i+1][j&mask[i]]);
        }
    }
    if (dp[0][(1<<n)-1] != llinf) {
        cout << dp[0][(1<<n)-1];
    } else {
        cout << "-1";
    }
    cout << endl;
    
    
    return 0;
}


Measured memory_bytes: 32384
#include "stdio.h"
#include "math.h"
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;
typedef long long ll;

int mySize = 1;
vector<ll> val;
vector<ll> lazy;
vector<int> width;

void lazyPropagate(int p) {
    if (lazy[p] > 0) {
        val[p] += lazy[p] * width[p];
        if (p < mySize - 1) {
            lazy[(p * 2) + 1] += lazy[p];
            lazy[(p * 2) + 2] += lazy[p];
        }
        lazy[p] = 0;
    }
}

void add(int l1, int r1, int l2, int r2, int k, int x) {
    if (r1 <= l2 || r2 <= l1) {
        lazyPropagate(k);
        return;
    }
    if (l1 <= l2 && r2 <= r1) {
        lazy[k] += x;
        lazyPropagate(k);
        return;
    }
    int mid = (l2 + r2) / 2;
    lazyPropagate(k);
    add(l1, r1, l2, mid, (k * 2) + 1, x);
    add(l1, r1, mid, r2, (k * 2) + 2, x);
    val[k] = val[(k * 2) + 1] + val[(k * 2) + 2];
}

void add(int l1, int r1, int x) {
    add(l1, r1, 0, mySize, 0, x);
}

ll getSum(int l1, int r1, int l2, int r2, int k) {
    if (r1 <= l2 || r2 <= l1) {
        return 0;
    }
    if (l1 <= l2 && r2 <= r1) {
        lazyPropagate(k);
        return val[k];
    }
    int mid = (l2 + r2) / 2;
    lazyPropagate(k);
    ll sl = getSum(l1, r1, l2, mid, (k * 2) + 1);
    ll sr = getSum(l1, r1, mid, r2, (k * 2) + 2);
    return sl + sr;
}

ll getSum(int l1, int r1) {
    return getSum(l1, r1, 0, mySize, 0);
}

int main(){
    int n,q,command,l,r,value;
    scanf("%d %d",&n,&q);
    for(;mySize < n;mySize <<= 1);
    val = vector<ll>(mySize * 2,0);
    lazy = vector<ll>(mySize * 2,0);
    width = vector<int>(mySize * 2,1);
    
    for (int i = mySize - 2; i >= 0; --i) {
        width[i] = width[(i * 2) + 1] + width[(i * 2) + 2];
    }

    for(int i = 0;i < q;++i){
        scanf("%d" "%d" "%d",&command,&l,&r);
        --l;
        --r;
        // add(s,t,x): as,as+1,...,at にxを加算する。
        if(command == 0){
            scanf("%d",&value);
            add(l,r + 1,value);
        // getSum(s,t): as,as+1,...,atの合計値を出力する。
        }else{
            printf("%lld\n",getSum(l,r + 1));
        }
    }
}



Measured memory_bytes: 10092
#include <iostream>
#include <vector>
#include <functional>
#include <algorithm>
#include <utility>
#include <queue>

using namespace std;
using ll = long long int; 
#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)

const ll INF = 1e16;
const int MAX_N = 1e5;
const int MAX_V = 1e5;
struct edge{
    int t;
    ll c;
    edge(int _t,ll _c){
        t = _t;
        c = _c;
    };
};

typedef pair<ll,int> P;
vector<edge> graph[MAX_N];

//sから各頂点への最短ルートを計算する
void dijkstra(int s, int V, vector<ll> &d){
    // greater<P>を指定することでfirstが小さい順に取り出せるようにする
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d.begin(),d.end(), INF);
    d[s] = 0;
    que.push(P(0,s));

    while(!que.empty()){
        P p = que.top(); que.pop();
        int v = p.second;
        if(d[v] < p.first) continue;
        for(int i = 0; i < graph[v].size(); i++){
            edge e = graph[v][i];
            //cout << "d[e.t]:" << d[e.t] << ", d[v]+e.c:" << d[v]+e.c << endl;
            if(d[e.t] > d[v] + e.c){
                d[e.t] = d[v] + e.c;
                que.push(P(d[e.t],e.t));
            }
        }
    }
}

//kから各頂点の距離を計算する？
int main(){
    int n;
    cin >> n;
    int a,b;
    ll c;
    vector<ll> to_k(n,0);//各頂点からkへの最短

    rep(i,n-1){//辺の数はn-1本である
        cin >> a >> b >> c;
        a--;
        b--;
        graph[a].emplace_back(b,c);//グラフを構築
        graph[b].emplace_back(a,c);//グラフを構築
    }

    int q,k;
    cin >> q >> k;
    k--;
    dijkstra(k,n,to_k);//kから各頂点への最短距離

    int x,y;
    rep(i,q){
        cin >> x >> y;
        x--;y--;
        cout << to_k[x] + to_k[y] << endl;
    }
    return 0;
}


Measured memory_bytes: 11120
use std::error::Error;
use std::io;
use std::cmp;

fn main() {
    if let Err(e) = run() {
        println!("{}", e);
    }
}

fn run() -> Result<(), Box<Error>> {
    let mut s = String::new();
    io::stdin().read_line(&mut s)?;
    let s :Vec<i32> = s.trim().split(" ")
        .map(|x| x.parse().expect(""))
        .collect();
    println!("{}", cmp::max(0, cmp::min(s[1], s[3]) -cmp::max(s[0], s[2])));
    Ok(())
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i, l, r) for(register int i = l; i < r; i++)
#define hrp(i, l, r) for(register int i = l; i <= r; i++)
#define rev(i, r, l) for(register int i = r; i >= l; i--)
#define pb push_back
#define int ll
#ifndef JOEON
#define D(...)
#define R(x, l)
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
template<typename tn> inline tn next(void);
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v);
signed main(void)
{
	#ifdef JOEON
//		freopen("C:\Users\Joeon\Desktop\IN.txt", "r", stdin);
//		freopen("C:\Users\Joeon\Desktop\OUT.txt", "w", stdout);
	#endif
	ios::sync_with_stdio(false);
	cin.tie(0);
	string str = next<string>();
	int cost = 700, t = 0;
	rep(i, 0, 3) t += str[i] == 'o';
	cout<<cost+t*100<<endl;
	return 0;
}
template<typename tn> inline tn next(void)
{
	tn k;
	cin>>k;
	return k;
}
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v)
{
	rep(i, 0, v.size()) os<<v[i]<<' ';
	return os;
}

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

int main(){
    vector<vector<int>> grid(3,vector<int>(3,0));
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            cin>>grid[i][j];
        }
    }
    int N;
    cin>>N;
    vector<int> vt(N,0);
    for(int i=0;i<N;i++){
        cin>>vt[i];
        for(int k=0;k<3;k++){
            for(int j=0;j<3;j++){
                if(grid[k][j]==vt[i]){
                    grid[k][j]=-1;
                }
            }
        }
    }
    for(int i=0;i<3;i++){
        if(grid[i][0]==grid[i][1]&&grid[i][0]==grid[i][2]&&grid[i][0]==-1){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    for(int i=0;i<3;i++){
        if(grid[0][i]==grid[1][i]&&grid[0][i]==grid[2][i]&&grid[2][i]==-1){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    if(grid[0][0]==grid[1][1]&&grid[1][1]==grid[2][2]&&grid[0][0]==-1){
        cout<<"Yes"<<endl;
        return 0;
    }
    if(grid[0][2]==grid[1][1]&&grid[1][1]==grid[2][0]&&grid[1][1]==-1){
        cout<<"Yes"<<endl;
        return 0;
    }
    cout<<"No"<<endl;
    return 0;
    
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();

        List<Integer> values = new ArrayList<Integer>();
        for (int i = 0; i < N; i++) {
            values.add(sc.nextInt());
        }

        List<Integer> costs = new ArrayList<Integer>();
        for (int i = 0; i < N; i++) {
            costs.add(sc.nextInt());
        }

        int max = 0;
        for (int i = 0; i < N; i++) {
            int profit = values.get(i) - costs.get(i);
            if (profit > 0) {
                max += profit;
            }
        }

        System.out.println(max);
    }
}

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

using namespace std;

#define pii pair<int,int>
#define ll long long
#define s second
#define f first

ll n,a,b;
ll ans;

int main(){
  cin >> n >> a >> b;
  ans+=a*(n/(a+b));
  n%=(a+b);
  cout << ans+min(a,n);
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O2")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

const double PI = acos(-1);
constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

struct Book{string title, author, date;};

bool matchTitle(string& s, string& t){
    int n = LEN(s), m = LEN(t);
    if(t=="*") return true;
    if(n<m) return false;
    REP(i, n-m+1){
        if(s.substr(i, m)==t){
            return true;
        }
    }
    return false;
}

bool geq(string& dt1, string& dt2){
    if(dt1=="*" or dt2=="*") return true;
    return dt1 <= dt2;
}

class Task{
public:
    void solve(istream& in, ostream& out){
        int N;
        in>>N;
        vc<Book> B(N);
        for(auto& b : B) in>>b.title>>b.author>>b.date;
        int Q;
        in>>Q;
        while(Q--){
            string title, author, from, to;
            in>>title>>author>>from>>to;
            for(auto& b : B){
                bool ok = true;
                ok &= matchTitle(b.title, title);
                ok &= matchTitle(b.author, author);
                ok &= geq(from, b.date);
                ok &= geq(b.date, to);
                if(ok) out<<b.title<<'\n';
            }
            if(Q) out<<'\n';
        }
    }
};

int main(){
    istream& in(cin);
    ostream& out(cout);
    ios_base::sync_with_stdio(false);
    in.tie(nullptr), out.tie(nullptr);
    Task solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 3256
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long 
#define REP(i, a, b) for (ll i = a; i < b; i++)
#define REPI(i, a, b) for (ll i = b - 1; i >= a; i--)
#define i_os ios::sync_with_stdio(0);  cin.tie(0);  cout.tie(0);
#define INF (ll)1e18 + 100
#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl
#define MAX 1e6
/*SOME BITMASK KNOWLEDGE
1)x & (x - 1):sets the last one bit of x to zero
power of two exactly when x & (x − 1) = 0.
2)x & -x:sets all the one bits to zero, except last one bit
3)x | (x - 1):inverts all the bits after the last one bit*/
#define o_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define o_setll tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
typedef tree<pair<ll, ll>,null_type,less<pair<ll, ll>>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set

int main() 
{
	ll n,m;
	cin>>n>>m;
	string s = "";
	REP(i,0,n) s.push_back('0');

	unordered_map<ll,ll> um;
	REP(i,0,m){
		ll x,y;
		cin>>x>>y;
		if(um.count(x) && um[x] != y){
			cout<<-1<<endl;
			return 0;
		}
		if(x == 1 && y == 0 && n > 1){
			cout<<-1<<endl;
			return 0;
		}
		s[x-1] = y + '0';
		um[x] = y;
	}
	if(s[0] == '0' && n > 1) s[0] = '1';
	cout<<s<<endl;
	return 0;
}



Measured memory_bytes: 256