akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
//#include <unistd.h>
//#include <stdio.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll INF = 1LL << 60;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b; return true;}return false;}
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b; return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
//素数判定O(sqrt(N))
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}

ll fac[510000], finv[510000], inv[510000];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < 510000; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
//nのm乗をMODで割ったあまりO(logN)
ll modpow(ll n,ll m,ll MOD){
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n) % MOD;
        m >>= 1;
        n *= n;
        n %= MOD;
    }
    return res;
}

//printf("%.10f\n", N);
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/
/*
    cout << fixed << setprecision(15);
*/
int main(){
    ll X,A,B;
    cin >> X >> A >> B;
    if(A >= B){
        cout << "delicious" << endl;
        return 0;
    }
    else if(B - A <= X){
        cout << "safe" << endl;
        return 0;
    }
    cout << "dangerous" << endl;
}

Measured memory_bytes: 3612
import scala.io.{StdIn => in}

object Main extends App {
  val Array(a, b) = in.readLine.split(" ").map(_.toInt)

  val ans = a match {
    case a if a <= 5 => 0
    case a if a <= 12 => b / 2
    case _ => b
  }

  println(ans)
}

Measured memory_bytes: 25540
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=1; i<(int)(n); i++)
int D, c[27], s[366][27];

int sco(vector<int> &t){
int S=0, L[27]={};
REP(i, D){
  S+=s[i][t[i]];
  L[t[i]]=i;
  REP(j, 27){ S-=c[j]*(i-L[j]); }
  cout << S << "\n";
}
return S;
}

int main(){
  cin >> D; D++;
  REP(i, 27){ cin >> c[i]; }
  REP(i, D){ REP(j, 27){ cin >> s[i][j]; } }
  vector<int> t(D), last(27, 0);
  REP(i, D){ cin >> t[i]; }
  sco(t);
}

Measured memory_bytes: 3632
s = input()
a = 0
if(len(s)%2 == 1):
    print('No')
else:
    for i in range(len(s)//2):
        if(s[2*i] != 'h' or s[2*i+1] != 'i'):
            a = 1
            print('No')
            break
    if(a == 0):
        print('Yes')

Measured memory_bytes: 3060
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			String s = sc.next();
			String t = sc.next();
			if(t.charAt(0)=='X') break;
			
			char[] a = s.toCharArray();
			char[] b = t.toCharArray();
			
			if(s.contains("_")==true){
				if(b[0]=='D') System.out.print(s);
				else{
					if(b[0]=='U' && (int)a[0]>96) a[0]-=32;
					else if(b[0]=='L' && (int)a[0]<96) a[0]+=32;
					for(int i=0;i<a.length;i++){
						if(a[i]=='_') a[i+1]-=32;
						else System.out.print(a[i]);
					}
				}
			}else{
				if(b[0]=='D'){
					if((int)a[0]<96) a[0]+=32;
					for(int i=0;i<a.length;i++){
						if((int)a[i]<96){
							System.out.print('_');
							a[i]+=32;
						}
						System.out.print(a[i]);
					}
				}else{
					if(b[0]=='U' && (int)a[0]>96) a[0]-=32;
					else if(b[0]=='L' && (int)a[0]<96) a[0]+=32;
					for(int i=0;i<a.length;i++) System.out.print(a[i]);
				}
			}
			System.out.println();	
		}	
	}	
}

Measured memory_bytes: 17212
//
//  main.cpp
//
// https://atcoder.jp/contests/abc131/tasks/abc131_f

#include <algorithm>
#include <array>
#include <assert.h>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = long long;
using ull = unsigned long long;

struct UnionFind {
    vector<size_t> parent;
    vector<size_t> rank;
    size_t find_parent(size_t x) {
        if (parent[x] == x) {
            return x;
        } else {
            parent[x] = find_parent(parent[x]);
            return parent[x];
        }
    }
    explicit UnionFind(size_t size) {
        parent.resize(size);
        rank.resize(size);
        for (size_t i = 0; i < size; i++) {
            parent[i] = i;
            rank[i] = 0;
        }
    }
    virtual ~UnionFind() {}
    void unite(size_t x, size_t y) {
        size_t px = find_parent(x);
        size_t py = find_parent(y);
        if (px == py) {
            return;
        }
        if (rank[px] < rank[py]) {
            parent[px] = py;
        } else if (rank[px] > rank[py]) {
            parent[py] = px;
        } else { // rank[px] == rank[py]
            parent[py] = px;
            rank[px]++;
        }
    }
    bool is_same(size_t x, size_t y) {
        return find_parent(x) == find_parent(y);
    }
    unordered_map<size_t, set<size_t>> create_map_parent_to_elements() {
        unordered_map<size_t, set<size_t>> ans;
        for (size_t i = 0; i < parent.size(); i++) {
            size_t parent = find_parent(i);
            if (ans.find(parent) == ans.end()) {
                ans[parent] = {i};
            } else {
                ans[parent].insert(i);
            }
        }
        return ans;
    }
};

int main(int argc, char* argv[]) {
    int N;
    cin >> N;
    UnionFind tree(N);
    vector<pair<int, int>> pts;
    map<int, int> x_to_idx;
    map<int, int> y_to_idx;
    for (int i = 0; i < N; i++) {
        int x, y;
        cin >> x >> y;
        pts.push_back(make_pair(x, y));
        if (x_to_idx.find(x) != x_to_idx.end()) {
            tree.unite(i, x_to_idx[x]);
        } else {
            x_to_idx[x] = i;
        }
        if (y_to_idx.find(y) != y_to_idx.end()) {
            tree.unite(i, y_to_idx[y]);
        } else {
            y_to_idx[y] = i;
        }
    }
    unordered_map<size_t, set<size_t>> parent_idx_to_groups = tree.create_map_parent_to_elements();
    ll count = 0;
    for (const pair<size_t, set<size_t>>& parent_group : parent_idx_to_groups) {
        const set<size_t>& group = parent_group.second;
        set<int> x_coords;
        set<int> y_coords;
        for (size_t idx : group) {
            x_coords.insert(pts[idx].first);
            y_coords.insert(pts[idx].second);
        }
        count += x_coords.size() * y_coords.size();
    }
    cout << count - pts.size() << endl;
}



Measured memory_bytes: 21364
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

ll gcd(ll a,ll b){
    ll temp;
    while(b){
        temp=b;
        b=a%b;
        a=temp;
    }
    return a;
}

int main(){
    ll n,m; cin>>n>>m;
    string s,t; cin>>s>>t;
    ll g=gcd(n,m);
    ll ans=m*n/g;
    rep(i,g){
        if(s[n/g*i]!=t[m/g*i]) ans=-1;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
//g++ -std=c++11 

using namespace std;

long long x;

int main(){
	cin >> x;
	if(x == 0) {
		cout << 1 << endl;
	} else {
		cout << 0 << endl;
	}

}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
//using namespace boost::multiprecision;
typedef long long int ll;
typedef long double ld;
#define MOD 1000000007
#define ALL(obj) (obj).begin(),(obj).end()
template<class T>inline bool chmax(T& a,T b){if (a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T& a,T b){if (a>b){a=b;return 1;}return 0;}
const long long INF = 1LL << 60;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
//四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

struct edge{//グラフに使うヤツ
    ll from,to,cost;
};

typedef vector<vector<edge> > G;
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}


int main(){
    ll n;
    cin >> n;
    string s,t;
    cin >> s >> t;
    ll ans=1;
    ll x=-1;
    for (ll i=0;i<n;i++){
        if (x==-1){
            if (s[i]==t[i]){
                ans*=3;
                x=0;
            }else{
                ans*=6;
                x=1;
                i++;
            }
        }else if (x==0){
            if (s[i]==t[i]){
                ans*=2;
            }else{
                ans*=2;
                x=1;
                i++;
            }
        }else{
            if (s[i]==t[i]){
                x=0;
            }else{
                ans*=3;
                i++;
            }
        }
        ans%=MOD;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3600
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
ka = a + b + c
x = int()
n = int(input())
for i in range(n):
    k = int(input())
    if k in ka: ka[ka.index(k)] = x
ans = "No"
if ka[0] == x and ka[1] == x and ka[2] == x:ans = "Yes"
elif ka[3] == x and ka[4] == x and ka[5] == x:ans = "Yes"
elif ka[6] == x and ka[7] == x and ka[8] == x:ans = "Yes"
elif ka[0] == x and ka[3] == x and ka[6] == x:ans = "Yes"
elif ka[1] == x and ka[4] == x and ka[7] == x:ans = "Yes"
elif ka[2] == x and ka[5] == x and ka[8] == x:ans = "Yes"
elif ka[0] == x and ka[4] == x and ka[8] == x:ans = "Yes"
elif ka[2] == x and ka[4] == x and ka[6] == x:ans = "Yes"
print(ans)


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

struct Node{
    int key;
    Node *right,*left,*parent;
};

Node *nil,*root;

void insert(int k){
    Node *y=nil;
    Node *x=root;
    Node *z=new Node;
    z->key=k;
    z->right=nil;
    z->left=nil;
    while(x!=nil){
        y=x;
        if(z->key<x->key) x=x->left;
        else x=x->right;
    }
    z->parent=y;
    if(y==nil) root=z;
    else if(z->key<y->key) y->left=z;
    else y->right=z;
}

void inorder(Node *u){
    if(u==nil) return;
    inorder(u->left);
    cout<<' '<<u->key;
    inorder(u->right);
}

void preorder(Node *u){
    if(u==nil) return;
    cout<<' '<<u->key;
    preorder(u->left);
    preorder(u->right);
}

int main(){
    int m,k;
    string com;
    cin>>m;
    for(int i=0;i<m;i++){
        cin>>com;
        if(com[0]=='i'){
            cin>>k;
            insert(k);
        }
        else if(com[0]=='p'){
            inorder(root);
            cout<<endl;
            preorder(root);
            cout<<endl;
        }
    }
}


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

int main() {
  string S;
  int K;
  cin >> K >> S;
  if (S.size() <= K) {
    cout << S << endl;
  } else {
    for (int i = 0;i < K;i++) {
      char s = S.at(i);
      cout << s ;
    }
    cout << "..." << endl;
  }
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <iostream>
#include <string>

using namespace std;


long long int RepeatSquaring(long long int N, long long int P, long long int M){
  long long int res = 1;
    while(P>0){
        if(P & 1) res = res * N % M;
        N = N * N % M;
        P >>= 1;
    }
    return res;
}

int main(){
long long int n,k,a[100010];
  
  cin >> n >> k;
  
  long long int ans = 0;
  long long int res = 0;
  
for(int i=k;i>=1;i--){
   
   a[i] = RepeatSquaring((k/i),  n, 1000000007);
  for(int j=2;j*i<=k;j++){
  
   a[i] -= (a[i*j] -1000000007);
  a[i] %= 1000000007;
    
}
  
  res += a[i]*i;
  res %= 1000000007;
}
  
  cout << res % 1000000007 << endl;
}


Measured memory_bytes: 4304
//code by lynmisakura.wish to be accepted
/****************************/
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<vector>
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
/***************************/
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<pair<int,int>> vpi;

const long long Mod = 998244353;
const long long mod = 1000000007;
const long long INF = 10000000000000;

#define pb push_back
#define mp make_pair
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()
#define Rep(n) for(int i = 0;i < n;i++)
#define rep(i,n) for(int i = 0;i < n;i++)
	
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll qp(ll a, ll b) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
ll qp(ll a, ll b, int mo) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }

#define _GLIBCXX_DEBUG
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
/***************************/

int main(void){
	//1000000
	int k,x;cin >>x >> k;
	for(int i = k - x + 1;i <= k + x - 1;i++) cout << i << " ";
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
# coding: utf-8

N = int(input())
A = list(map(int, input().split(" ")))

now_kabu = 0
shoji = 1000
for i in range(N-1):
    if A[i+1] > A[i]:
        now_kabu += shoji // A[i]
        shoji -= shoji // A[i] * A[i]
    if now_kabu != 0:
        shoji += A[i+1] * now_kabu
        now_kabu = 0

print(shoji)


Measured memory_bytes: 9160
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
using ll = long long;
int main(){
	int N;
	ll X;
	cin>>N>>X;
	vector<ll> a(N);
	rep(i,N) cin>>a[i];
	sort(all(a));
	ll suma = 0;
	rep(i,N) suma += a[i];
	if(suma == X){
		cout<<N<<endl;
		return 0;
	}
	rep(i,N){
		X -= a[i];
		if(X<0){
			cout<<i<<endl;
			return 0;
		}
	}
	cout<<N-1<<endl;
}


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

int main(void){
    int N, i, j, tmp, result;
    scanf("%d", &N);
    int a[N];
    for(i = 0; i < N; i++){
        scanf("%d", &a[i]);
    }
    
    for(i = 0; i < N-1; i++){
        for(j = N-1; j > i; j--){
            if(a[j-1] > a[j]){
                tmp = a[j];
                a[j] = a[j-1];
                a[j-1] = tmp;
            }
        }
    }

    result = 0;
    for(i = N-1; i >= 0;){
        result = result + a[i];
        i--;
        if(i >= 0){
            result = result - a[i];
            i--;
        }
    }
    printf("%d", result);
    
    return 0;
}

Measured memory_bytes: 128
import java.util.*;
import java.math.*;
import java.lang.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long[] a = new long[n];

    for (int i = 0; i < n; i++) {
      a[i] = sc.nextLong();
      if (a[i] == 0) {
        System.out.println(0);
        return;
      }
    }

    Arrays.sort(a);

    long ans = 1;

    for (int i = 0; i < n; i++) {
      if (ans > 1000000000000000000L/a[i]) {
        System.out.println(-1);
        return;
      }
      ans *= a[i];
    }

    System.out.println(ans);

  }

}


Measured memory_bytes: 61968
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define INF 1000000001
//0=48,A=65,a=97

int main() {
    int n;
    string s;
    cin >> n >> s;
    vector<vector<bool>> l(n, vector<bool>(10, false)),r(n, vector<bool>(10, false));
    for(int i = 1; i < n-1; i++) {
        l[i]=l[i-1];
        l[i][(int)s[i-1]-48]=true;
    }
    for(int i = n-2; i >=1; i--) {
        r[i]=r[i+1];
        r[i][(int)s[i+1]-48]=true;
    }

    vector<set<int>> a(10);
    for(int i = 1; i < n-1; i++) {
        int m=(int)s[i]-48;
        for(int j = 0; j < 10; j++) {
            for(int k = 0; k < 10; k++) {
                if(l[i][j] && r[i][k]){
                    a[m].insert(j*10+k);
                }
            }
        }
    }

    int ans=0;
    for(int i = 0; i < 10; i++) {
        ans += a[i].size();
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 7468
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(ll i=a;i<=b;i++)
#define FORD(i,a,b) for(ll i=a;i>=b;i--)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define sqr(x)  ((x) * (x)) 
#define cub(x)  ((x) * (x) * (x))
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
// ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll cnt;
vector<int> g;

int InsertionSort(int a[], int n, int g){
  FOR(i,g,n-1){
    int v = a[i];
    int j = i-g;
    while(j>=0 && a[j]>v){
      a[j+g] = a[j];
      j -= g;
      ++cnt;
    }
    a[j+g] = v;
  }
}

/* 
  g = 1, 4, 13, 40, 121...
  g(n+1) = 3*g(n) + 1 の減少数列を用いると
  O(N^1.25)で計算できることが予測されている

  最後には必ずg==1の通常InsertionSortを行う
*/

int shellSort(int a[], int n){
  for(int h=1; ; ){
    if(h>n) break;
    g.PB(h);
    h = 3*h + 1;
  }

  FORD(i,SZ(g)-1,0) InsertionSort(a,n,g[i]);
}

int main(){
  int n; cin >> n;
  int a[n];
  FOR(i,0,n-1) cin >> a[i];
  cnt = 0;
  shellSort(a,n);

  cout << SZ(g) << endl;
  FORD(i,SZ(g)-1,0){
    if(i!=SZ(g)-1) cout << " ";
    cout << g[i]; 
  }
  cout << endl;
  cout << cnt << endl;
  FOR(i,0,n-1) {
    cout << a[i] << endl;
    // if(i!=n-1) cout << endl;
  }
}


Measured memory_bytes: 7076
#include<stdio.h>
int main(){
  int i,j,flag,k=0;
  while(1){
    scanf("%d %d",&i,&j);
    flag=0;
    if(i==0 && j==0)break;
    if(k!=0){
      printf("\n");
    }
    k++;
    for(i=i;i<=j;i++){
      if(i%400==0){
	printf("%d\n",i);
	flag=1;
      }
      else if(i%4==0 && i%100!=0){
	printf("%d\n",i);
	flag=1;
      }
    }
    if(flag==0){
      printf("NA\n");
    }
  }
  return (0);
}

Measured memory_bytes: 616
#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 <cmath>
#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
using namespace std;

int main(){
  int A,B,C,K;
  cin >> A >> B >> C;
  cin >> K;
  for(int i = 1;i <= K;i++){
    if(A >= B){
      B = B * 2;
    }else if(B >= C){
      C = C * 2;
    }else{
      C = C * 2;
    }
    //cout << A << B << C << endl;
  }
  if(A < B && B < C){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


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

int main() {
	int n; cin >> n;
	vector<pair<string, int>> playlist(n);
	for (int i = 0; i < n; i++) {
		cin >> playlist[i].first >> playlist[i].second;
	}
	string x; cin >> x;

	int ans = 0;
	for (int i = 0; i < n; i++) {
		ans += playlist[i].second;
	}

	for (int i = 0; i < n; i++) {
		ans -= playlist[i].second;
		if (playlist[i].first == x) {
			break;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
md = input().split()

m = int(md[0])
d = int(md[1])

ans = 0
for i in range(1, m+1):
	for j in range(22, d+1):
		j1 = j%10
		j2 = int(j/10)
		if j1 >= 2 and j1 * j2 == i:
			ans += 1

print(ans)

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

int main(){
	string s;
	cin >> s;
	int n = s.size();

	string t, u;

	for(int i = 0; i != n; ++i){
		if((i % 2) == 0){
			t += "0";
			u += "1";
		}
		else{
			t += "1";
			u += "0";
		}

	}

	int a = 0, b = 0;

	for(int i = 0; i != n; ++i){
		if(t[i] != s[i])
			++a;
		if(s[i] != u[i])
			++b;
	}

	cout << min(a, b);
}











Measured memory_bytes: 768
import java.util.Scanner;

public class Main {
	public static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		//A
		/*int N = sc.nextInt();
		String N_S = String.valueOf(N);
		char N1,N2,N3,N4;
		N1 = N_S.charAt(0);
		N2 = N_S.charAt(1);
		N3 = N_S.charAt(2);
		N4 = N_S.charAt(3);
		if((N1==N2&&N1==N3)||(N2==N4&&N3==N4))
			System.out.println("Yes");
		else
			System.out.println("No");*/

		//B
		/*int N =sc.nextInt();
		ArrayList<Long> List = new ArrayList<Long>();
		List.add((long) 2);
		List.add((long) 1);
		for(int i = 2 ; i <= N ; i++){
			List.add(List.get(i-1)+List.get(i-2));
		}
		System.out.println(List.get(N));*/

		//C
		String N = sc.next();
		char N1,N2,N3,N4;
		N1 = N.charAt(0);
		N2 = N.charAt(1);
		N3 = N.charAt(2);
		N4 = N.charAt(3);
		int A = Integer.parseInt(""+N1);
		int B = Integer.parseInt(""+N2);
		int C = Integer.parseInt(""+N3);
		int D = Integer.parseInt(""+N4);
		int ans  = (A+B+C+D-7)/2;
		String op1 = "+";
		String op2 = "+";
		String op3 = "+";

		if(ans == 0){

		}else if(B==ans){
			op1 = "-";
		}else if(C==ans){
			op2 = "-";
		}else if(D==ans){
			op3 = "-";
		}else if(B+C==ans){
			op1 = "-";
			op2 = "-";
		}else if(B+D==ans){
			op1 = "-";
			op3 = "-";
		}else if(C+D==ans){
			op2 = "-";
			op3 = "-";
		}else if(B+C+D==ans){
			op1 = "-";
			op2 = "-";
			op3 = "-";
		}

		System.out.println(A+op1+B+op2+C+op3+D+"=7");
	}
}



Measured memory_bytes: 21844
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        double root = Math.sqrt(n);
        long ans = n;
        for (int i = 1; i < root + 1; i++) {
            if (n % i != 0) {
                continue;
            }
            long l = i;
            long r = n / i;
            ans = Math.min(ans, l + r - 2);
        }
        System.out.println(ans);

        sc.close();
    }
}


Measured memory_bytes: 23124
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#define N 200005
#define ll long long
using namespace std;
inline char get(){
	const int TOP=1000000;
	static char T[TOP],*x=T,*y=T;
	return x==y&&(y=(x=T)+fread(T,1,TOP,stdin),x==y)?EOF:*x++;
}
inline ll read (){
	register ll num;int sign=1;register char c;
	while (((c=get())<'0'||c>'9')&&c!='-');c=='-'?num=sign=0:num=c-48;
	while ((c=get())>='0'&&c<='9')num=(num<<3)+(num<<1)+(c-48);
	return sign?num:-num;
}
int n,m,ans,x,y;
int cnt[N],tot[N],A[N]; 
void add(int x){
	if(x<=0)return;
	if(!cnt[x])++ans;cnt[x]++;
}
void del(int x){
	if(x<=0)return;
	if(cnt[x]==1)--ans;cnt[x]--;
}
int main(){
	n=read();m=read();
	for(int i=1;i<=n;++i){
		A[i]=read();tot[A[i]]++;add(A[i]-tot[A[i]]+1);
	}
	while(m--){
		x=read();y=read();del(A[x]-tot[A[x]]+1);
		tot[A[x]]--;tot[y]++;A[x]=y;add(y-tot[y]+1);printf("%d\n",n-ans);
	}
} 

Measured memory_bytes: 4608
main = do
    s <- getLine
    print $ solve 0 0 s

solve k _ [] = k
solve k a ('A':cs) = solve k (a+1) cs
solve k 0 ('B':'C':cs) = solve k 0 cs
solve k a ('B':'C':cs) = solve (k+a) a cs
solve k a (_:cs) = solve k 0 cs

Measured memory_bytes: 13948
import java.util.Scanner;
     
     
    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();

            if (b/k>(a-1)/k){
                System.out.println("OK");
            } else {
                System.out.println("NG");
            }
        }
    }

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

using ll = long long;

const ll MOD = 998244353;

ll mod_pow(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

int main() {
    ll N;
    cin >> N;
    vector<ll> f(N + 1, 1);
    rep(i, N) {
        f[i + 1] = (f[i] * (i + 1)) % MOD;
    }
    ll ans = mod_pow(3, N, MOD);
    for (int i = N / 2 + 1; i <= N; i++) {
        ll x = f[N] * mod_pow(f[i], MOD - 2, MOD);
        x %= MOD;
        x *= mod_pow(f[N - i], MOD - 2, MOD);
        x %= MOD;
        x *= mod_pow(2, N - i, MOD) * 2;
        x %= MOD;
        ans += MOD - x;
        ans %= MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 78336
#include<bits/stdc++.h>
using namespace std;
const int maxn=5050,p=1e9+7;
vector<int>v[maxn];
int n,siz[maxn],dp[maxn][maxn],g[maxn],f[maxn];
void dfs(int x,int fa){
	dp[x][1]=1;siz[x]=1;
	for(auto y:v[x]){
		if(y==fa)continue;
		dfs(y,x);
		for(int i=1;i<=siz[x]+siz[y];++i)g[i]=0;
		for(int i=1;i<=siz[x];++i)
			for(int j=0;j<=siz[y];++j)
				g[i+j]=(g[i+j]+1ll*dp[x][i]*dp[y][j]%p)%p;
		for(int i=0;i<=siz[x]+siz[y];++i)dp[x][i]=g[i];
		siz[x]+=siz[y];
	}
	for(int i=2;i<=siz[x];++i)dp[x][0]=(dp[x][0]+p-1ll*f[i]*dp[x][i]%p)%p;
}
int main(){
	cin>>n;
	for(int i=1,x,y;i<n;++i)cin>>x>>y,v[x].push_back(y),v[y].push_back(x);
	f[0]=1;
	for(int i=2;i<=n;i+=2)f[i]=1ll*f[i-2]*(i-1)%p;
	dfs(1,0);
	cout<<(p-dp[1][0]);
}

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

int main() {
    int n;
    cin >> n;
    if (n % 1000 == 0)
        cout << 0 << endl;
    else if ((n % 1000) < 1000)
        cout << 1000 - n % 1000 << endl;

    return 0;
}

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

const ll INF=1e15;
int N;
int arr[3005];

ll dp[3005][3005][2];

ll solve(int L,int R,int turn)
{
    ll &ret=dp[L][R][turn];
    if(ret!=-1)return ret;
    if(L>R)return 0;
    ret=-INF;
    if(turn==0) ret=max(solve(L+1,R,1-turn)+arr[L],solve(L,R-1,1-turn)+arr[R]);
    if(turn==1) ret=min(solve(L+1,R,1-turn)-arr[L],solve(L,R-1,1-turn)-arr[R]);
    return ret;


}

int main()
{
    cin>>N;
    for(int i=0;i<N;i++)
        cin>>arr[i];
    memset(dp,-1,sizeof(dp));
    cout<<solve(0,N-1,0);
}


Measured memory_bytes: 141440
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int main() {
    int n;
    cin >> n;
    map<int, int> mp1, mp2;
    rep(i, n) {
        int v;
        cin >> v;
        if (i % 2 == 0) mp1[v]++;
        else mp2[v]++;
    }
    vpair vp1, vp2;
    for (auto x : mp1) {
        vp1.emplace_back(x.se, x.fi);
    }
    for (auto x : mp2) {
        vp2.emplace_back(x.se, x.fi);
    }

    if (vp1.size() == 1) vp1.emplace_back(0, 0);
    if (vp2.size() == 1) vp2.emplace_back(0, 0);
    int ans;
    sort(rall(vp1));
    sort(rall(vp2));
    //show_pair(vp1);
    //show_pair(vp2);
    if (vp1[0].se != vp2[0].se) ans = vp1[0].fi + vp2[0].fi;
    else {
        ans = max(vp1[0].fi + vp2[1].fi, vp1[1].fi + vp2[0].fi);
    }
    ans = n - ans;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6136
#include<iostream>
#include<climits>
#include<cstdlib>
using namespace std;
int main()
{
  int n,a[20],sum,min,i,j;
  while(cin>>n,n){
    sum=0;
    for(i=0;i<n;i++){
      cin>>a[i];
      sum+=a[i];
    }
    min=INT_MAX;
    for(i=(1<<n)-1;i>=0;i--){
      int s=0;
      for(j=0;j<n;j++)if(i&(1<<j))s+=a[j];
      if(min>abs(sum-s-s))min=abs(sum-s-s);
    }
    cout<<min<<endl;
  }
}

Measured memory_bytes: 868
def main():
    friends, min_height = [int(i) for i in input().split()]
    input_heights = [int(i) for i in input().split()]

    sorted_heights = sorted(input_heights)

    over_friends = 0

    for i in range(friends):
        if sorted_heights[i] < min_height:
            continue
        else:
            over_friends = friends - i
            break
    
    print(over_friends)

if __name__ == '__main__':
    main()

Measured memory_bytes: 51440
while True:
  a,op,b=input().split()
  a=int(a)
  b=int(b)
  if op == "?":
    break
  if op == "+":
    print("{}".format(a + b)) 
  if op == "-":
    print("{}".format(a - b)) 
  if op == "*":
    print("{}".format(a * b)) 
  if op == "/":
    print("{}".format(int(a / b))) 



Measured memory_bytes: 5596
sx, sy, tx, ty = map(int, input().split())
 
ans = ""
 
ans += "U" * (ty - sy) + "R" * (tx - sx)
ans += "D" * (ty - sy) + "L" * (tx - sx)
ans += "L" + "U" * (ty - sy + 1) + "R" * (tx - sx + 1) + "D"
ans += "R" + "D" * (ty - sy + 1) + "L" * (tx - sx + 1) + "U"
print(ans)

Measured memory_bytes: 8944
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>	
#include <deque>
#include <set>
#include <climits>
#include <memory>
#include <numeric>
#include <utility>


#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define fore(i,a) for(auto &i:a)
#define INF INT_MAX/2;
#define PI 3.14159265358979323846264338327950L;
const int INF2 = 1001001001;
typedef long long ll;
using namespace std;
using vi = vector<int>;
using vll = vector<ll>;
ll mod = 1e9 + 7;
//ll llmax = 10000000000000000000ll;
using namespace std;
using Graph = vector<vector<int>>;



int cnt_digit(ll N)
{
	int digit = 0;

	while (N > 0)
	{
		N /= 10;
		digit++;
	}
	return digit;
}


 // 最大公約数計算
 
ll gcd(ll a, ll b)
{
	if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a % b);
	}
}
// 最小公倍数の計算

ll lcm(ll a, ll b)
{
	ll g = gcd(a, b);

	return a / g * b;
}

struct union_find
{
	vector<int> par, r;
	union_find(int n)
	{
		par.resize(n);
		r.resize(n);
		init(n);
	}


	void init(int n)
	{
		for (int i = 0; i < n; i++) par[i] = i;
		for (int i = 0; i < n; i++) r[i] = 0;
	}

	int find(int x)
	{
		if (par[x] == x)return x;
		else return find(par[x]);
	}

	void unite(int x, int y)
	{
		x = find(x);
		y = find(y);

		if (r[x] < r[y])
		{
			par[x] = y;
		}
		else
		{
			par[y] = x;
			if (r[x] == r[y])
			{
				r[x]++;
			}
		}
	}
};

const int MAX_N = 110000;

int memo[MAX_N];

int rec(int n) {
	if (n == 0)return 0;
	if (memo[n] != -1)return memo[n];

	int res = n;

	for (int pow6 = 1; pow6 <= n; pow6 *= 6)res = min(res, rec(n - pow6) + 1);

	for (int pow9 = 1; pow9 <= n; pow9 *= 9)res = min(res, rec(n - pow9) + 1);

	return memo[n] = res;
}

int calc(int x) {
	int ret = 0;
	while (x % 2 == 0) {
		x /= 2;
		ret++;
	}

	return ret;
}

int a[12][12];
int D;
ll G;
vector<ll> P, C;

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

	cin >> a >> b;
	
	cout << (a-1)*(b-1) << endl;

}
	

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <math.h>
using namespace std;

using lli = long long int;
using Vint = vector<int>;
using Vlli = vector<lli>;
using Wint = vector<Vint>;
using Wlli = vector<Vlli>;
using pii = pair<int, int>;
using pll = pair<lli, lli>;

const int MOD = 1e9 + 7;
const int INFi = 2e9 + 1;
const lli INFl = (lli)(9e18) + 1;
const vector<pii> DXDY = {make_pair(1, 0), make_pair(-1, 0), make_pair(0, 1), make_pair(0, -1)};
const char BR = '\n';

#define FOR(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define FOReq(i, a, b) for(int (i) = (a); (i) <= (b); (i)++)
#define rFOR(i, a, b) for(int (i) = (b); (i) >= (a); i--)
#define FORstep(i, a, b, step) for(int (i) = (a); i < (b); i += (step))
#define REP(i, n) FOR(i, 0, n)
#define rREP(i, n) rFOR(i, 0, (n-1))
#define vREP(i, vec) for(auto &(i) : (vec))


template <class T> inline int argmin(vector<T> vec){return min_element(vec.begin(), vec.end()) - vec.begin();}
template <class T> inline int argmax(vector<T> vec){return max_element(vec.begin(), vec.end()) - vec.begin();}
template <class T> inline void chmax(T &a, T b){a = max(a, b);}
template <class T> inline void chmin(T &a, T b){a = min(a, b);}
inline int toInt(string &s){int res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
inline int toInt(const string s){int res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
inline long long int toLong(string &s){lli res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
inline long long int toLong(const string s){lli res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
template <class T> inline std::string toString(T n){
  if(n == 0) return "0";
  std::string res = "";
  if(n < 0){n = -n;while(n != 0){res += (char)(n % 10 + '0'); n /= 10;} std::reverse(res.begin(), res.end()); return '-' + res;}
  while(n != 0){res += (char)(n % 10 + '0'); n /= 10;} std::reverse(res.begin(), res.end()); return res;
}

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


lli func(lli a, lli b){
  lli res = 0;
  while(b != 0){
    if(a < b) std::swap(a, b);
    else{
      if(a % b == 0){
        res += (2 * (a / b) - 1) * b;
        a = 0;
      }
      else{
        res += 2 * (a / b) * b;
        a %= b;
      }
    }
  }
  return res;
}


int main(void){
  lli n, x; cin >> n >> x;
  /* f(a, b) := 平行四辺形(a, b)で考える軌跡の長さ
  *  漸化式 f(a, b) = 2b + f(a-b, b) if a > b
  *                = 2a + f(a, b - a) if a < b
  *                = b if a == b
  */
  cout << func(n-x, x) + n<< BR;
  return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,s,n) for(int i=s;i<n;i++)
#define per(i,s,n) for(int i=n-1;i>=s;i--)
#define fi first
#define se second
#define all(c) c.begin(),c.end()
typedef long long int ll;
typedef pair<int, int> P;
typedef long double ld;
void Ans(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}

const ll INF=1001001001;
const ll mod=1000000007;

int main(){
  int a,b;
  cin>>a>>b;
  
  cout<<a*b<<endl;
}



Measured memory_bytes: 3632
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstring>

using namespace std;

#define INF 999999999

int main(){
	int ans, n, q, po[101], ins, i,j, m;
	
	while(1){
		cin >> n >> q;
		if(!n) break;
		for(i=0; i<=100; i++) po[i] = 0;
		ans = 0;
		for(i=0; i<n; i++){
			cin >> m;
			for(j=0; j<m; j++){
				cin >> ins;
				po[ins]++;
			}
		}
		ans = 0;
		for(i=1;i<=100;i++){
			if(po[i] >= q && po[i] > po[ans]){
				ans = i;
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= end; --i)
#define iter(i, c) for (auto i = (c).begin(); i != (c).end(); ++i)
#define riter(i, c) for (auto i = (c).rbegin(); i != (c).rend(); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;

ll M;

ll dfs1(const vector<vector<int>>& graph, vector<bool>& visited, vector<ll>& dp, int node) {
    visited[node] = true;
    ll res = 1;
    rep(i, 0, graph[node].size()) {
        if (visited[graph[node][i]]) {
            continue;
        }
        ll child_val = dfs1(graph, visited, dp, graph[node][i]) + 1;
        res = (res * child_val) % M;
    }
    return dp[node] = res;
}

void dfs2(const vector<vector<int>>& graph, vector<ll>& dp, vector<ll>& ans, int node, int parent) {
    ans[node] = 1;
    rep(i, 0, graph[node].size()) {
        ans[node] = (ans[node] * (dp[graph[node][i]] + 1)) % M;
    }
    int n = (int)graph[node].size();
    vector<ll> lcum(n, 0), rcum(n, 0);
    rep(i, 0, n) {
        lcum[i] = rcum[i] = (dp[graph[node][i]] + 1) % M;
    }
    rep(i, 1, n) {
        lcum[i] = (lcum[i] * lcum[i - 1]) % M;
    }
    rrep(i, n - 1, 0) {
        rcum[i] = (rcum[i] * rcum[i + 1]) % M;
    }
    rep(i, 0, n) {
        if (graph[node][i] == parent) {
            continue;
        }
        dp[node] = 1;
        if (i > 0) dp[node] = (dp[node] * lcum[i - 1]) % M;
        if (i < n - 1) dp[node] = (dp[node] * rcum[i + 1]) % M;
        dfs2(graph, dp, ans, graph[node][i], node);
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N >> M;
    int u, v;
    vector<vector<int>> graph(N);
    rep(i, 0, N - 1) {
        cin >> u >> v;
        --u, --v;
        graph[u].push_back(v);
        graph[v].push_back(u);
    }
    vector<bool> visited(N, false);
    vector<ll> dp(N);
    dfs1(graph, visited, dp, 0);
    vector<ll> ans(N);
    dfs2(graph, dp, ans, 0, -1);
    rep(i, 0, N) {
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 20608
N = int(input())
D, X = map(int,input().split())
for i in range(N):
    A_i = int(input())
    count = 0
    while True:
        day = count*A_i + 1
        if day > D:
            break
        else:
            X += 1
            count += 1
print(X)


Measured memory_bytes: 2940
use proconio::input;
use std::collections::HashMap;

fn main() {
    input! {
        n: usize,
        k: usize,
        mut teleporters: [usize; n],
    }

    teleporters = teleporters.iter().map(|x| x-1).collect();
    let mut positions = HashMap::new();
    let mut way = vec![];
    let mut now = 0;
    let mut pos = 0;

    while now < k {
        if let Some(previous) = positions.get(&pos) {
            let one_round = now - previous;
            let remain = (k - now) % one_round; 
            pos = way[previous + remain];
            //println!("previous {} remain {}", previous, remain);
            break;
        } else {
            positions.insert(pos, now);
        }
        way.push(pos);
        pos = teleporters[pos];
        now += 1;
    }

    println!("{}", pos+1);

}


Measured memory_bytes: 13464
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    String s = sc.next();
    
    if(a < 3200)
    	System.out.println("red");
    else
    	System.out.println(s);
    
  }
}

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

template <typename T>
class SegTree{
private:
  int n;
  vector<T> dat;
  T query_sub(int a, int b, int k, int l, int r);

public:
  SegTree(int _n);
  void update(int k, T a);
  T query(int a, int b);  // [a,b)
};

template <typename T>
SegTree<T>::SegTree(int _n){
   n = 1;
   while(n < _n) n *= 2;
   dat = vector<T>(2*n-1,INF);
}

template <typename T>
void SegTree<T>::update(int k, T a){
  k += n-1;
  dat[k] = a;
  while(k > 0){
    k = (k-1)/2;
    dat[k] = min(dat[2*k+1], dat[2*k+2]);
  }
}

template <typename T>
T SegTree<T>::query_sub(int a, int b, int k, int l, int r){
  if(r <= a || b <= l) return INF;
  if(a <= l && r <= b) return dat[k];
  T vl = query_sub(a, b, k*2+1, l, (l+r)/2);
  T vr = query_sub(a, b, k*2+2, (l+r)/2, r);
  return min(vl,vr);
}

template <typename T>
T SegTree<T>::query(int a, int b){
  return query_sub(a, b, 0, 0, n);
}

int main(){
    ll n; ll x;
    cin >> n >> x;
    SegTree<ll> st(n);
    rep(i,n) {
        ll a;
        cin >> a;
        st.update(i,a);
    }
    ll ans = INF;
    rep(i,n){
        ll c = x*i;
        rep(j,n){
            if(j-i < 0) c += min(st.query((j-i+n)%n,n),st.query(0,j+1));
            else c += st.query(j-i,j+1); 
        }
        ans = min(ans,c);
    }
    cout << ans << endl;
    return 0;
}

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

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

Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as BS
import qualified Data.Maybe as MA
import qualified Data.List as L

main = do
    xs <- L.sort . fmap (fst . MA.fromJust . BS.readInt) . BS.words <$> BS.getLine
    putStrLn $ if L.length (L.nub xs) == 2 then "Yes" else "No"


Measured memory_bytes: 380
#include <iostream>
#include <vector>
#include <cstring>
#include <stack>
using namespace std;

string s,t,ss;
int S,T;
int table[500005];
vector<int> g[2200000];
int in[2200000];
stack<int> st;
vector<int> topo;
int ans;
int dp[2200000];
int aa[27];
void init() {
  table[0] = -1;
  table[1] = 0;
  for(int i = 2, j = 0; i <= t.length();) {
    if(t[i-1] == t[j]) {
      table[i] = j + 1;
      i++;
      j++;
    }
    else if(j > 0) {
      j = table[j];
    }
    else {
      table[i] = 0;
      i++;
    }
  }
}

void ma() {
  for(int i = 0, j = 0; i + j < ss.length();) {
    if(t[j] == ss[i+j]) {
	j++;
	if(j == t.length()) {
	 
	  if(i < S) {
	    // cout << "i = "<<i<<"   (i + j)%S = "<<(i + j)%S << endl;
	    g[i].push_back((i+j)%S);
	    in[(i+j)%S]++;
	  }
	}
    }
    
    else{
   
      i = i + j - table[j];
      if(j > 0) {
	j = table[j];
      }
    }
  }
}
      
      
      
      
  
int main() {

  cin >> s >> t;
  S = s.length();
  T = t.length();

  while(ss.length() < S + T) ss += s;
 
  init();
  // cout << s << endl;
  /*  for(int i = 0; i <= t.size(); i++) {
    cout << "table["<<i<<"] = "<<table[i] << endl;
    }*/
  ma();


  for(int i = 0; i < S; i++) {
    if(in[i] == 0) st.push(i);
  }

  while(!st.empty()) {
    int v = st.top();
    st.pop();
    //  cout << "v = "<<v << endl;
    topo.push_back(v);
    for(int i = 0; i < g[v].size(); i++) {
      int u = g[v][i];
      in[u]--;
      if(in[u] == 0) st.push(u);
    }
  }
  //  for(int i = 0; i < topo.size(); i++) cout << topo[i] << endl;


  if(topo.size() != S) {
    cout << -1 << endl;
    return 0;
  }

  for(int i = 0; i < topo.size(); i++) {
    int u = topo[i];
    for(int j = 0; j < g[u].size(); j++) {
      int e = g[u][j];
      dp[e] = dp[u] + 1;
      ans = max(ans,dp[e]);
    }
  }

  cout << ans << endl;
}
  

  

  

  


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

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
const int MAX_V = 200011;
const int LOG_V = 19;
int depth[MAX_V];
int parent[LOG_V][MAX_V];

void build_lca(VI G[], int N, const int root=0) {
    depth[root] = 0;
    parent[0][root] = root;
    VI ord; ord.reserve(N);
    ord.push_back(root);
    REP (i_, N) {
	int v = ord[i_];
	EACH (e, G[v]) if (*e != parent[0][v]) {
	    ord.push_back(*e);
	    depth[*e] = depth[v] + 1;
	    parent[0][*e] = v;
	    // G[*e].erase(remove(G[*e].begin(), G[*e].end(), v), G[*e].end()); // remove parent edge
	}
    }
    REP (t, LOG_V-1) REP (v, N) parent[t+1][v] = parent[t][parent[t][v]];
}

int lca(int x, int y) {
    if (depth[x] < depth[y]) swap(x, y);
    REP (t, LOG_V) if ((depth[x] - depth[y]) & (1 << t)) x = parent[t][x];
    if (x == y) return x;
    for (int t=LOG_V; t--;) {
	if (parent[t][x] != parent[t][y]) {
	    x = parent[t][x];
	    y = parent[t][y];
	}
    }
    return parent[0][x];
}

int distance(int x, int y, int z=-1) { // number of edges
    if (z == -1) z = lca(x, y);
    return depth[x] + depth[y] - 2 * depth[z];
}

int N;
void read_graph(VI G[]) {
    REP (i, N-1) {
	int x, y;
	scanf("%d%d", &x, &y);
	x--; y--;
	G[x].push_back(y);
	G[y].push_back(x);
    }
}

int Lstart, Sstart;
VI L[200011], S[200011];

bool inf[200011];
bool use[200011];
int dist[200011];

void bfs0() {
    memset(use, 0, sizeof use);
    VI ord; ord.reserve(N);
    ord.push_back(Lstart);
    use[Lstart] = true;
    dist[Lstart] = 0;
    for (int i=0; i<(int)ord.size(); i++) {
	int v = ord[i];
	EACH (e, L[v]) if (!use[*e] && depth[*e] > dist[v]+1) {
	    ord.push_back(*e);
	    use[*e] = true;
	    dist[*e] = dist[v] + 1;
	}
    }
}

void MAIN() {
    scanf("%d%d%d", &N, &Lstart, &Sstart);
    Lstart--;
    Sstart--;
    read_graph(L);
    read_graph(S);
    build_lca(S, N, Sstart);

    REP (v, N) {
	EACH (e, L[v]) if (distance(v, *e) >= 3) {
	    inf[v] = true;
	}
    }

    bfs0();

    REP (v, N) {
	if (use[v] && inf[v]) {
	    puts("-1");
	    return;
	}
    }

    int ans = 0;
    REP (v, N) if (use[v]) {
	amax(ans, depth[v]*2);
    }
    printf("%d\n", ans);
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 40940
#include <iostream>
#include <string>

using namespace std;

int main(int argc, char const *argv[])
{
    string S;
    cin >> S;
    if (S[2] == S[3] && S[4] == S[5])
    {
        cout << "Yes" << endl;
    }else
    {
        cout << "No" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
N = int(input())
S = [input() for _ in range(N)]

cnt = {}
for i, Si in enumerate(S):
    cnt.setdefault(Si, 0)
    cnt[Si] += 1

for key in ('AC', 'WA', 'TLE', 'RE'):
    cnt.setdefault(key, 0)
    ans = '{0} x {1}'.format(key, cnt[key])
    print(ans)

Measured memory_bytes: 16324
#include <iostream>
#include <vector>

int main(){
	int n, m;
	std::cin >> n >> m;

	std::vector<int> city(n, 0);
	for(int i = 0; i < m; ++i){
		int a, b;
		std::cin >> a >> b;
		++city.at(a - 1);
		++city.at(b - 1);
	}

	for(int d : city){
		std::cout << d << std::endl;
	}

	return 0;
}


	


Measured memory_bytes: 256