akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define MOD 1000000007 //S(vector).size()
using namespace std;
typedef long long ll;

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

  ll ans = (ll)n * (n - 1) / 2;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
# input
N = int(input())
W = [input() for n in range(N)]

# check
before = W[0]
for i in range(1, N):
    if W[i][0] != before[-1] or W[i] in W[:i]:
        print("No")
        exit(0)
    before = W[i]
print("Yes")

Measured memory_bytes: 3060
import java.util.*;
import java.io.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.lang.Math.*;

public class Main {

	int INF = 1 << 28;
	//long INF = 1L << 62;
	double EPS = 1e-10;

	void run() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), cnt=0;
		for(long i=0;i<n;i++) {
			if(!isAllow(sc.nextInt())) cnt++;
		}
		System.out.println(cnt);
	}
	
	boolean isAllow(long S) {
		for(long i=1;i*i<S;i++) {
			if((S-i)%(2*i+1) == 0) return true;
		}
		return false;
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 61008
#include <bits/stdc++.h>
using namespace std;
 
void fail(){
    cout << "No" << endl;
    exit(0);
}
 
int main(){
    int N;
    cin >> N;
    vector<pair<int, int>> task_p, task_n;
    for(int i=0; i<N; i++){
        string S;
        cin >> S;
        int s = 0, mn = 0;
        for(char c : S){
            s += (c == '(' ? 1 : -1);
            mn = min(mn, s);
        }
        int a = -mn, b = s;
        (b >= 0 ? task_p : task_n).emplace_back(a, b);
    }
    sort(task_p.begin(), task_p.end());
    int R = 0;
    for(auto& p : task_p){
        if(R < p.first) fail();
        R += p.second;
    }
    sort(task_n.begin(), task_n.end(), [](auto a , auto b){ return a.first+a.second > b.first+b.second; });
    for(auto& p : task_n){
        if(R < p.first) fail();
        R += p.second;
    }
    if(R) fail();
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 11540
#include <iostream>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <stack>
#define Endl endl
#define mp make_pair
#define rep(N) for(int i=0;i<N;i++)
#define repj(N) for(int j=0;j<N;j++)
#define ll long long 
#define pii pair<int,int>
#define pll pair<ll,ll>
#define For(I,N) for(int I=0;I<N;I++)
#define cinone(N) int N;cin>>N;
#define scanfone(N) int N;cin>>N;
#define cinng(N,M) int N[M];for(int yiuytvnm=0;yiuytvnm<M;yiuytvnm++) cin>>N[yiuytvnm];
#define scanfng(N,M) int N[M];for(int qrwuoiq=0;qrwuoiq<M;qrwuoiq++) scanf("%d",&N[qrwuoiq]);
#define over(A) {cout<<A<<endl;exit(0);}
#define all(A) A.begin(),A.end()
#define ceil(a,b) ((a-1)/b+1)
typedef unsigned long long ull;
const int inf=1039074182;
using namespace std;
int n;
int a[200005];
map <int,int> m;
int e[31];

int main()
{
//	freopen("input.txt","r",stdin);
	cin>>n;
	for(int i=0;i<n;i++)
	{
		scanf("%d",a+i);
		m[a[i]]++;
	}
	e[0]=1;
	for(int i=1;i<31;i++)
	{
		e[i]=e[i-1]*2;
	}
	sort(a,a+n);
	reverse(a,a+n);
	int res=0;
	for(int i=0;i<n;i++)
	{
		if(m[a[i]]==0) continue;
		for(int j=30;j>=1;j--)
		{
			if(e[j]<=a[i]) continue;
			int t=e[j]-a[i],fuck=m[t];
//			cout<<t<<endl;
			if(fuck>=2 || fuck==1 && t!=a[i])
			{
				res++;
				m[t]--;
				break;
			}
		}
		m[a[i]]--;
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 29824
/*
* @Author: kabbo
* @Date:   2020-04-19 20:49:56
* @Last Modified by:   kabbo
* @Last Modified time: 2020-04-19 20:52:10
*/
#include<bits/stdc++.h>
using namespace std;
#define mem(x,y) memset(x,y,sizeof(x));
#define eps 1e-9
#define pii pair<int,int>
#define sdi(x) scanf("%d",&x)
#define sdii(x,y) scanf("%d%d",&x,&y)
#define endl '\n'
#define ull unsigned long long
#define ll long long
const int mod=1e9+7;
using u64 = uint64_t;
using u128=__uint128_t;
void solve(){
  ll n,m;
  cin>>n>>m;
  vector<ll>v(m);
  ll sum=0;
  for(auto& x:v)
  	cin>>x,sum+=x;
  if(n-sum>=0){
  	cout<<n-sum<<endl;
  }
  else 
  	cout<<"-1"<<endl;
}
int main(){
	
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	/*int t;
	cin>>t;
	for(int i(1);i<=t;++i){*/
	 // printf("Case %d: ",i);
	  solve();
	//}
	#ifndef LOCAL_DEFINE
	  cerr<< "Time elapsed: "<<1.0*clock()/CLOCKS_PER_SEC <<"s.\n";
	#endif
	return 0;
}

Measured memory_bytes: 3876
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  int a[200009];
  cin>>n;
  for(int i=1;i<=n;i++){
    cin>>a[i];
  }
  if(n%2==0){
    for(int i=n;i>=2;i-=2){
      cout<<a[i]<<' ';
    }
    for(int i=1;i<n;i+=2){
      cout<<a[i];
      if(i==n-1)cout<<endl;
      else cout<<' ';
    }
  }
  else{
    for(int i=n;i>=1;i-=2){
      cout<<a[i]<<' ';
    }
    for(int i=2;i<=n-1;i+=2){
      cout<<a[i];
      if(i==n-1)cout<<endl;
      else cout<<' ';
    }
  }
  return(0);
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); ++i)
 
using namespace std;
using ll = long long;
 
int main(){
    int n;
    cin >> n;
    int cnt = 0;
    for(int i = 1; i <= n; i++){
        int a;
        cin >> a;
        if(i % 2 == 1 && a % 2 == 1) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3620
import java.util.*;
public class Main {
	public static void main(String[] args){
		//入力
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] A = new int[n];
		for(int i=0; i<n; i++){
			A[i] = sc.nextInt();
		}

		//
		int max=0;
		int temp=0;
		for(int i=0; i<n; i++){
			for(int j=i; j<n; j++){
				temp = A[i] - A[j];
				if(temp<0){
				temp = -temp;
				}
				if(max < temp){
				max=temp;
				}
			}
		}
		// 出力
		System.out.println(max);
	}
}

Measured memory_bytes: 21972
#include<iostream>
#include<cstring>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdio>
#include<cmath>
#define pb(in,tmp) in.push_back(tmp)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) loop(i,0,b)
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
using namespace std;
int main(){
  char in[8][8];
  rep(i,8)cin>>in[i];
  
  cout<<"90"<<endl;
  rep(i,8){
    rep(j,8)cout<<in[7-j][i];
    cout<<endl;
  }
  cout<<"180"<<endl;
  rep(i,8){
    rep(j,8)cout<<in[7-i][7-j];
    cout<<endl;
  }
  cout<<"270"<<endl;
  rep(i,8){
    rep(j,8)cout<<in[j][7-i];
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 1136
import java.util.*;

public class Main {

    static final int MOD = 1000000007;

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt(),b=sc.nextInt();
        int ans = 0;
        for(int i=1;i<13;i++){
            if(i<a) ans++;
            else if(i==a&&i<=b)ans++;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 21716
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <deque>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <fstream>
#define debug(x) cout << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;


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

  ll a,b,c,x,y;
  cin>>a>>b>>c>>x>>y;
  ll mx = max(x,y);
  ll ans = 1e15;
  for(ll i = 0; i <= 2 * mx; i += 2) {
    ll nx = x - i / 2;
    ll ny = y - i / 2;
    if(nx < 0) nx = 0;
    if(ny < 0) ny = 0;
    ans = min(ans, i * c + nx * a + ny * b);
  }
  cout << ans << endl;
  

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int n;
	int u,k,v;
	int box[101][101];
	int d[101];
	int i,j;
	int x,y;
	queue<int>que;
	
	cin>>n;
	for(i=1;i<=n;i++){
		d[i]=0;
		for(j=1;j<=n;j++){
			box[i][j]=0;
		}
	}
	for(i=0;i<n;i++){
		cin>>u>>k;
		for(j=0;j<k;j++){
			cin>>v;
			box[u][v]=1;
		}
	}
	d[1]=0;
	que.push(1);
	while(!que.empty()){
		x=que.front();
		que.pop();
		for(i=1;i<=n;i++){
			if(box[x][i]==1){
				y=i;
				if(d[y]==0){
					d[y]=d[x]+1;
					que.push(y);
				}
			}
		}
	}
	cout<<1<<" "<<d[i]<<endl;
	for(i=2;i<=n;i++){
		if(d[i]==0)	d[i]=-1;
		cout<<i<<" "<<d[i]<<endl;
	}
	return 0;
}
				
	


Measured memory_bytes: 3108
import java.util.*;

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

		Scanner sc=new Scanner(System.in);

		int a=sc.nextInt();
		int b=sc.nextInt();
		int x=sc.nextInt();
		if(x>=a && x<=a+b){
			System.out.println("YES");
		}else{
			System.out.println("NO");
		}
	}
}


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

public class Main{

	public static void main(String args[]){
		new Main().mainrun();
	}

	private Scanner scan;

	private void mainrun() {
		scan = new Scanner(System.in);

		int[] ans = new int[51];

		Arrays.fill(ans, 0);

		for(int a = 0;a < 10;a++ ) {
			for(int b = 0; b < 10;b++) {
				for(int c = 0;c < 10;c++) {
					for(int d = 0;d < 10;d++){
						ans[a + b + c + d]++;
					}
				}
			}
		}
		while(scan.hasNext()) {
			System.out.println(ans[scan.nextInt()]);
		}
		
		scan.close();
	}
}


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


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

	int x;
	cin >> x;

	long long ans = 1000 * (x/500);
	x %= 500;
	ans += 5 * (x/5);
	cout << ans << '\n';
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<sstream>
#include<string>
#include<numeric>
#include <algorithm>
#include<math.h>
#include<cstdio>
#include<string.h>
#include<unistd.h>
#include <array>
#include <map> 
#define ALL(a)  (a).begin(),(a).end()



using namespace std;
typedef long long ll;
struct point{
  int x;
  int y;

};
int gcd(int a, int b)
{
  if(a>b){
    return gcd(b,a);
  }
	return a == 0 ? b : gcd(b % a, a);
}
int lcm( int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm
int input(){
  int x;
  cin>>x;
  return x;
}

int moji(char in)
{
    int ans = (int)in-(int)'a';
    if((ans < 0) || (ans > 25)){
        ans = 26;
    }
    return ans;
}
const int VV=10;//場合に応じてVVの値のみ変更する必要あり
//dijkstra(s)sがスタート地点でそこからの最短距離を配列dで表す。正の重みのみ使用可能
int cost[VV][VV];
int d[VV];
bool used[VV];
void dijkstra(int s){
  fill(d,d+VV,100000);
  fill(used,used+VV,false);
  d[s]=0;
  while(true){
    int v=-1;
    for(int u=0;u<VV;u++){
      if(!used[u]&&(v==-1||d[u]<d[v]))v=u;
    }
    if(v==-1)break;
    used[v]=true;
    for(int u=0;u<VV;u++){
      d[u]=min(d[u],d[v]+cost[v][u]);
    }
  }

}

int compare_int(const void *a, const void *b)//qsort(quick sort利用時に使用)
{
    return *(int*)a - *(int*)b;
}

int binary_searchh(long long x,long long k[],int n){
  int l=0;
  int r=n;
  while(r-l>=1){
    int i=(l+r)/2;
    if(k[i]==x)return i;
    else if(k[i]<x)l=i+1;
    else r=i;
  }
  return -1;
}

struct File {
    int aa;
    int bb;

    File(const int& aa, const int& bb)
        : aa(aa), bb(bb) {}
};

bool operator<(const File& a, const File& b)
{
    // ファイル種別、ファイル名の順番で優先順位を付けて比較
    return std::tie(a.aa, a.bb) < std::tie(b.aa, b.bb);
}

long long kaijo(long long x){
  long long l=10*10*10*10*10*10*10*10*10+7;
  long long sum=1;
  for(int i=x;i>0;i--){
    sum*=i;
    if(sum>l){
      sum%=l;
    }
  }
  return sum;
}






int main(){
  string s;
  cin>>s;
  int a[26];
  for(int i=0;i<26;i++){
    a[i]=0;
  }
  for(int i=0;i<s.size();i++){
    a[s[i]-'a']++;
  }
  int idx;
  int max=-1;
  for(int i=0;i<26;i++){
    if(a[i]>max){
      max=a[i];
      idx=i+'a';
    }
  }
  int minn=10000;
  for(int i=0;i<26;i++){
    char word='a'+i;
    int num=0;
    string tmp1=s,tmp2;
    while(count(tmp1.begin(),tmp1.end(),word)!=tmp1.size()){
      tmp2=tmp1;
      tmp1="";
      for(int i=0;i<tmp2.size()-1;i++){
                if(tmp2[i]==word||tmp2[i+1]==word){
                    tmp1+=word;
                }else{
                    tmp1+=tmp2[i];
                }
            }
            num++;

    }
    minn=min(minn,num);
  }
  cout<<minn<<endl;


}





  
  

Measured memory_bytes: 256
s = input()
c = 0
d = 0
if 'W' in s:
  c += 1
if 'E' in s:
  c -= 1
if 'N' in s:
  d += 1
if 'S' in s:
  d -= 1
if c == d == 0:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3060
exec("def nWord(): nWord.cache = raw_input() if not hasattr(nWord, 'cache') or nWord.cache=='' else nWord.cache ; pos = nWord.cache.find(nWord.sep) ; ret, nWord.cache = (nWord.cache, '') if pos==-1 else (nWord.cache[:pos], nWord.cache[pos+1:].lstrip(nWord.sep)) ; return ret") ; exec("nWord.sep = ' '") ; exec("def ___nLine2(): ret, nWord.cache = (raw_input(), nWord.cache if hasattr(nWord, 'cache') else '') if not hasattr(nWord, 'cache') or nWord.cache=='' else (nWord.cache, '') ; return ret") ; exec('def nInt(): return int(nWord())') ; exec('def nFloat(): return float(nWord())') ; exec("def ___nAuto2():\n ret = nWord()\n try: return int(ret)\n except: pass\n try: return float(ret)\n except: return ret") ; exec("def nAuto(n=None): return ___nAuto2() if n is None else [___nAuto2() for i in range(n)]") ; exec("def nLine(n=None): return ___nLine2() if n is None else [___nLine2() for i in range(n)]")
 
N = nAuto()
S = nAuto(N)

def check(A):
    for i in range(N):
        for j in range(N):
            if S[(A+i) % N][j]!=S[(A+j) % N][i]:
                return 0
    return N
 
count = 0
for A in range(N):
    count += check(A)
print count


Measured memory_bytes: 32876
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;

const LL INF = (1LL << 60);

bool warshall_floyd(vector<vector<LL>> &dist) {
    int n = dist.size();
    rep(k, n) rep(i, n) if (dist[i][k] != INF) {
        rep(j, n) if (dist[k][j] != INF) {
            dist[i][j]= min(dist[i][j] , dist[i][k] + dist[k][j]);
            if (j == k and dist[j][k] < 0) return false;
        }
    }
    return true;
}

int main() {
    long long n, m, l; cin >> n >> m >> l;
    vector<vector<LL>> dist(n, vector<LL>(n, INF));
    rep(i, m) {
        int a, b; LL c;
        cin >> a >> b >> c;
        --a, --b;
        dist[a][b] = dist[b][a] = c;
    }
    warshall_floyd(dist);
    vector<vector<LL>> dist2(n, vector<LL>(n, INF));
    rep(i, n) rep(j, n) {
        if (dist[i][j] <= l) dist2[i][j] = dist2[j][i] = 1;
    }
    warshall_floyd(dist2);

    int q; cin >> q;
    rep(i, q) {
        int s, t; cin >> s >> t;
        --s, --t;
        LL d = dist2[s][t];
        if (d == INF) {
            cout << -1 << endl;
        } else {
            cout << d - 1 << endl;
        }
    }
}


Measured memory_bytes: 1920
#include <iostream>

using namespace std;

int main(){
    int N;
    cin >> N;
    int cnt1 = 0, cnt2 = 0, cnt4 = 0;
    for(int i = 0; i < N; i++){
        int a;
        cin >> a;
        if(a%4 == 0) cnt4++;
        else if(a%2 == 0) cnt2++;
        else cnt1++;
    }
    if(cnt1 > cnt4+1){
        cout << "No" << endl;
    }else if(cnt1 == cnt4+1){
        if(cnt2 == 0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
}

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

int main() 
{
    int a, b;
    cin >> a >> b;
    string s1 = "", s2 = "";
    for (int i=0; i<a; i++)
        s1+=to_string(b);
    for (int i=0; i<b; i++)
        s2+=to_string(a);
    cout << min(s1,s2);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	int D;
	cin >> D;
	if (D == 25)cout << "Christmas" << endl;
	if (D == 24)cout << "Christmas Eve" << endl;
	if (D == 23)cout << "Christmas Eve Eve" << endl;
	if (D == 22)cout << "Christmas Eve Eve Eve" << endl;
}

Measured memory_bytes: 256
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.root = [-1]*(n+1)
		self.rank = [0]*(n+1)

	def find(self, x):
		if(self.root[x] < 0):
			return x
		else:
			self.root[x] = self.find(self.root[x])
			return self.root[x]
			
	def unite(self, x, y):
		x = self.find(x)
		y = self.find(y)
		if(x == y):
			return 0
		elif(self.rank[x] > self.rank[y]):
			self.root[x] += self.root[y]
			self.root[y] = x
		else:
			self.root[y] += self.root[x]
			self.root[x] = y
			if(self.rank[x] == self.rank[y]):
				self.rank[y] += 1

	def size(self, x):
		return -self.root[self.find(x)]
		
n,m,*l = map(int,open(0).read().split())
edges = [(a,b) for a,b in zip(l[::2],l[1::2])]
ans = 0
for i in range(m):
	uf = UnionFind(n)
	for j in range(m):
		if i==j:
			continue
		else:
			a,b = edges[j]
			uf.unite(a,b)
	ans += uf.size(a)<n
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
int main(){
   char s[35];
   gets(s);
   int flag=0;
    for(int i=0;s[i]!='\0';i++){
        if(s[i]==' '&&s[i-1]==s[i+1]) flag++;
    }
    if(flag==2) printf("YES");
    else printf("NO");
    return 0;
}



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

int main(){
    long long K;
    cin >> K;
    long long counta=1;
    long long num=7;
    num%=K;
    long long i;
    for(i=0; i<2*K; i++){
        if(num==0){
            break;
        }else{
            counta++;
            num = (10*num+7)%K;
        }
    }
    if(i==2*K){
        cout << -1 << endl;
    }else{
        cout << counta << endl;
    }
    system("pause");
    return 0;
}

Measured memory_bytes: 3692
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int INF = (int)1e9 + 7;

int levenshtein_distance(string s, string t) {
    int m = s.length(), n = t.length();
    vector<vector<int>> dp(m + 1, vector<int>(n + 1, INF));
    for (int i = 0; i <= m; i++) dp[i][0] = i;
    for (int j = 0; j <= n; j++) dp[0][j] = j;
    for (int i = 0; i < m; i++) for (int j = 0; j < n; j++) {
        dp[i + 1][j + 1] = min({dp[i][j] + (s[i] != t[j]),  // substitution
                                dp[i][j + 1] + 1,           // insertion
                                dp[i + 1][j] + 1});         // deletion
    }
    return dp[m][n];
}

int main() {
    string s, t;
    cin >> s >> t;
    cout << levenshtein_distance(s, t) << endl;
    return 0;
}


Measured memory_bytes: 6916
n,m=map(int,input().split())
A={}
for i in range(m):
    num,result=input().split()
    if num not in A:
        A[num]=[result]
    else:
        A[num] +=[result]

ans,cnt=0,0
for v,m in A.items():
    if "AC" not in m:continue
    for i in m:
        if i=="AC":
            ans +=1
            break
        if i=="WA":
            cnt +=1

print(ans,cnt)

Measured memory_bytes: 30160
#include <bits/stdc++.h>
using namespace std;
int main()
  {int c[2], K; cin >> c[0] >> c[1] >> K;
  for (int i{}; K--; i = !i) c[i] /= 2, c[!i] += c[i];
  cout << c[0] << " " << c[1];}

Measured memory_bytes: 3568
n, q = list(map(int, input().split()))
s = input()
lr = [list(map(int, input().split())) for i in range(q)]

cnts = [0] * (n)
cnt = 0
for i in range(1, n):
    if s[i-1:i+1] == "AC":
        cnt += 1
    cnts[i] = cnt
     
for i in range(q):
    l, r = lr[i]
    print(cnts[r-1] - cnts[l-1])

Measured memory_bytes: 30636
import java.util.Scanner;

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

		num500 = X / 500;
		num5 = (X % 500) / 5;

		System.out.println(1000*num500+5*num5);
	}
}

Measured memory_bytes: 21844
#下，右，上，左，右下，右上，左下，左上
dy = [1, 0, -1, 0, 1, -1, 1, -1]
dx = [0, 1, 0, -1, 1, 1, -1, -1]

H, W = map(int, input().split())
S = []
for i in range(H):
    S.append(list(input()))

for y in range(H):
    for x in range(W):

        if S[y][x] == "#":
            continue

        cnt = 0

        for k in range(8):
            ny = y + dy[k]
            nx = x + dx[k]

            if ny < 0 or ny >= H or nx < 0 or nx >= W:
                continue

            if S[ny][nx] == "#":
                cnt += 1

        S[y][x] = str(cnt)

for y in range(H):
    print("".join(S[y]))

Measured memory_bytes: 3192
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

const int MAX = 100001;
const int MOD = 1000000007;

typedef long long ll;
typedef pair< int, int > pii;
typedef pair< ll, ll > pll;
typedef pair< ll, int > pli;
typedef pair< int, ll > pil;

int ceil(int x, int y){
  return (x % y == 0) ? x / y : x / y + 1;
}

int gcd(int x, int y){
  return y ? gcd(y, x % y) : x;
}

int lcm(int x, int y){
  return x / gcd(x, y) * y;
}

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

  int n;
  cin >> n;

  ll ans = (ll)n * (n - 1) / 2;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
use std::io::Read;

fn main() {
    let mut buf = String::new();

    // 標準入力から全部bufに読み込む
    std::io::stdin().read_to_string(&mut buf).unwrap();

    // 行ごとのiterが取れる
    let mut iter = buf.split_whitespace();
    let input: String = iter.next().unwrap().parse().unwrap();

    let mut patterns = Vec::new();
    // '+' の位置のパターンをbit全探索で作る (そのため-1する)
    // 外側のループが全体のパターン数
    for i in 0..(1 << input.len() - 1) {
        let mut row = Vec::new();
        for j in 0..input.len() {
            // j桁右シフトして最初のbitが1かチェック
            if ((i >> j) & 1) == 1 {
                row.push(j);
            }
        }
        patterns.push(row);
    }

    let mut result = 0;
    for pattern in patterns {
        let mut left = 0;
        for right in pattern {
            let n: u64 = input[left..right + 1].parse().unwrap();
            result += n;
            left = right + 1;
        }
        let n: u64 = input[left..].parse().unwrap();
        result += n;
    }
    println!("{:?}", result);
}


Measured memory_bytes: 4352
n = gets.to_i
num = gets.split.map(&:to_i)
num.sort!
ans = 0
if num[0] < 0 && num[-1] >= 0
  n.times{|i| ans += num[i].abs}
  puts ans
  while num.length > 2
    if num[1] < 0
      puts "#{num[-1]} #{num[0]}"
      num[-1] -= num[0]
      num.delete_at(0)
    else
      puts "#{num[0]} #{num[1]}"
      num[0] -= num[1]
      num.delete_at(1)
    end
  end
  puts "#{num[1]} #{num[0]}"
elsif num[0] >= 0 && num[-1] >= 0
  n.times{|i| ans += num[i].abs}
  puts ans-num[0]*2
  while num.length > 2
    puts "#{num[0]} #{num[1]}"
    num[0] -= num[1]
    num.delete_at(1)
  end
  puts "#{num[1]} #{num[0]}"
else
  n.times{|i| ans += num[i].abs}
  puts ans+num[-1]*2
  while num.length > 2
    puts "#{num[-1]} #{num[0]}"
    num[-1] -= num[0]
    num.delete_at(0)
  end
  puts "#{num[1]} #{num[0]}"
end


Measured memory_bytes: 14752
import numpy as np
N,M,C=map(int,input().split())
B=np.array([int(i) for i in input().split()]).T
A=[[int(i) for i in input().split()] for j in range(N)]
A=np.matrix(A)
print(sum([i+C>0 for i in (np.dot(A,B).T).A1]))

Measured memory_bytes: 12556
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
ll dp[100001][104][2];
// map< pair<ll,pair<ll,ll> > mp;
ll go(string str,ll d,ll pos=0,ll rem=0,ll tight=1)
{
	if(pos==str.length())
	{
		if(rem==0)
			return 1;
		else
			return 0;
	}
	else if(dp[pos][rem][tight]!=-1)
		return dp[pos][rem][tight];
	else if(tight==1)
	{
		ll res=0;
		for(ll i=0;i<=str[pos]-'0';i++)
		{
			if(i==str[pos]-'0')
				res=(res%mod+go(str,d,pos+1,(rem+i)%d,1)%mod)%mod;
			else
				res=(res%mod+go(str,d,pos+1,(rem+i)%d,0)%mod)%mod;
		}
		if(res<0)
			res+=mod;
		return dp[pos][rem][tight]=res%mod;	
	}
	else
	{
		ll res=0;
		for(int i=0;i<=9;i++)
			res=(res%mod+go(str,d,pos+1,(rem+i)%d,0)%mod)%mod;
		if(res<0)
			res+=mod;
		return dp[pos][rem][tight]=res%mod;
	}

}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	string k;
	cin>>k;
	ll d;
	cin>>d;
	memset(dp,-1,sizeof(dp));
	cout<<(go(k,d)-1+mod)%mod<<endl;
}


Measured memory_bytes: 262272
# include <iostream>
# include <cstdio>
# include <cstring>
# include <algorithm>
using namespace std;
const int maxm = 100 + 10;
bool
f[maxm],
q[maxm];

int main() {
	int n,
		now,
		ans;
	register int i, j;
	char s[maxm];
	scanf("%d", &n);
	scanf("%s", s);
	for (i = 0; i<n; i++) {
		f[s[i] - 'a'] = true;
		memset(q, false, sizeof(q));
		for (j = i + 1; j<n; j++) {
			q[s[j] - 'a'] = true;
		}
		now = 0;
		for (j = 0; j<26; j++) {
			if (f[j] && q[j]) {

				now++;
			}
		}
		ans = max(ans, now);
	}
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
string u="abcdefghijklmnopqrstuvwxyz";

LL solve2(LL a,LL b){
    return a/2*b;
}

LL solve3(LL a,LL b){
    LL s1,s2,s3;
    LL tem1,tem2;
    LL ans[2];
    LL t;
    t=a/3;
    for(int i=0;i<2;i++){
        t+=i;
        s1=t*b;
        s2=solve2(a-t,b);
        s3=a*b-s1-s2;
        tem1=max({s1,s2,s3})-min({s1,s2,s3});
        s2=solve2(b,a-t);
        s3=a*b-s1-s2;
        tem2=max({s1,s2,s3})-min({s1,s2,s3});
        ans[i]=min(tem1,tem2);
    }
return min(ans[0],ans[1]);
}
    
int main(){
    LL H,W;
    cin >> H >> W;
    if(H%3==0||W%3==0){
        puts("0");
        return 0;
    }
    cout << min(solve3(W,H),solve3(H,W)) << endl;
    return 0;
}

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



int main()
{

int arr[52];
int sum=0,temp;
int a,k;
cin>>a>>k;
for(int i=0;i<a;i++){

    cin>>arr[i];
    }

    for(int i=0;i< a;i++)
	{
		for(int j=i+1;j< a;j++)
		{
			if(arr[i]< arr[j])
			{
				temp 	=arr[i];
				arr[i]	=arr[j];
				arr[j]	=temp;
			}
		}
	}

    for(int i=0;i< k;i++)
    {
        sum+=arr[i];

    }
     printf("%d\n",sum);
    return 0;
}


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

int main(){
    int Month[12] = {0,31,29,31,30,31,30,31,31,30,31,30};
    int mon, day;
    while(cin>>mon>>day){
        if(!mon) break;
        int day_year = day;
        for(int i=0; i<mon; i++){
            day_year += Month[i];
        }
        switch(day_year%7){
            case 0: cout<<"Wednesday"; break;
            case 1: cout<<"Thursday"; break;
            case 2: cout<<"Friday"; break;
            case 3: cout<<"Saturday"; break;
            case 4: cout<<"Sunday"; break;
            case 5: cout<<"Monday"; break;
            case 6: cout<<"Tuesday"; break;
        }
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 1156
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<iomanip>

#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

#define debug(x) cout<<(#x)<<"="<<(x)<<", ";
#define debug1(x) debug(x) cout<<'\n';
#define debug2(x1, x2) debug(x1) debug(x2) cout<<'\n';
#define debug3(x1, x2, x3) debug(x1) debug(x2) debug(x3) cout<<'\n';
#define debug4(x1, x2, x3, x4) debug(x1) debug(x2) debug(x3) debug(x4) cout<<'\n';
#define debug5(x1, x2, x3, x4, x5) debug(x1) debug(x2) debug(x3) debug(x4) debug(x5) cout<<'\n';

#define fcout cout<<fixed<<setprecision(15)
#define repp(i,j,k) for(int i=j; i<k; ++i)
#define rep(i,j) repp(i,0,j)
#define rrep(i,j,k) for(int i=j; i>=k; --i)
#define all(x) (x).begin(), (x).end()
#define sort(x) sort(x.begin(), x.end())
#define lb(x,val) lower_bound(x.begin(), x.end(), val)
#define ub(x,val) upper_bound(x.begin(), x.end(), val)
#define pb(x) emplace_back(x);

typedef long long int lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef tuple<int, int, lli> tiil;

//const lli M=998244353ll;
const lli M=1000000007ll;
const double D=1.0;

int main(){
fast_io
int a,n; cin>>n>>a;
int ans=n%500;
if(ans<=a) cout<<"Yes";
else cout<<"No";
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int lld;

const lld mod = 1e9+7;
const lld INF = 1e9;
//const lld MAXN = 1e9;

int main()
{
	lld n,l[200] = {0};

	cin >> n;
	for(int i = 0; i < 2*n; i++)
	{
		cin >> l[i];
	}

	sort(l,l+2*n);

	lld sum = 0;

	for(int i = 0; i < 2*n; i++)
	{
		if (i % 2 == 0)
		{
			sum += l[i];
		}
	}

	cout << sum << endl;

	return 0;
}

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

struct node{
  int key;
  struct node *prev;
  struct node *next;
};

typedef struct node node;

void insertX(int);
int deleteX(int);
void deleteFirst(void);
void deleteLast(void);

node *sentinel; /* 番兵 */


int main() {

  int n;
  int inputKey;
  char inputOrder[12];

  node *printNode;

  int i;

  sentinel = (node *)malloc( sizeof( node ) );
  sentinel->next = sentinel;
  sentinel->prev = sentinel;


  scanf("%d", &n);

  for( i=0; i<n; i++) {
    scanf("%s", inputOrder);
    if( strcmp( inputOrder, "deleteFirst") == 0 ) {
      deleteFirst();
    }
    else if( strcmp( inputOrder, "deleteLast") == 0 ) {
      deleteLast();
    }
    else {
      scanf("%d", &inputKey);
      if( strcmp( inputOrder, "delete") == 0 ) {
	deleteX(inputKey);
      }
      else {
	insertX(inputKey);
      }
    }
  }

  for( printNode = sentinel->next; printNode->next != sentinel; printNode = printNode->next) {
    printf("%d ", printNode->key);
  }
  printf("%d\n", printNode->key);

  return 0;
}


void insertX(int x) {
  
  node *insNode;

  insNode = (node *)malloc( sizeof(node) );

  insNode->next = sentinel->next;
  sentinel->next->prev = insNode;
  sentinel->next = insNode;
  insNode->prev = sentinel;

  insNode->key = x;

}


int deleteX(int x) {
  
  node *delNode;

  /* deleteKeyと一致するノードをさがす */
  for( delNode=sentinel->next; delNode!=sentinel; delNode=delNode->next) {
    if(delNode->key == x) {
      break;
    }
  }
  if(delNode==sentinel){ /*該当するノードは存在しない */
    return 0;
  }

  /* ノードを削除する */
  delNode->prev->next = delNode->next;
  delNode->next->prev = delNode->prev;

  return 1;

}
  
void deleteFirst() {
  
  sentinel->next->next->prev = sentinel;
  sentinel->next = sentinel->next->next;

}


void deleteLast() {
  
  sentinel->prev->prev->next = sentinel;
  sentinel->prev = sentinel->prev->prev;

}

Measured memory_bytes: 34972
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;

    cout << x2 + y1 - y2 << " " << y2 - x1 + x2 << " " << x1 + y1 -y2 << " " << y1 -x1 +x2 << endl;
}

Measured memory_bytes: 764
/*input
2119
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const int MOD = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;

ll modpow(ll base, ll index, ll mod)
{
    ll ret = 1;
    while(index > 0)
    {
        if(index & 1) ret = (ret * base) % mod;
        base = (base * base) % mod;
        index >>= 1;
    }
    return ret;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s; cin >> s;
    int n = s.size();
    ll ans = 0;
	map<ll, ll> mapp;
    vector<ll> r(n + 1);
    for(int i = 1; i < n + 1; i++) r[i] = (r[i - 1] + (modpow(10, i - 1, 2019)) * (s[n - i] - '0')) % 2019;
	for(int i = 0; i < n + 1; i++) mapp[r[i]]++;
	for(auto it = mapp.begin(); it != mapp.end(); it++) ans += (it->second * (it->second - 1))/2;
	cout << ans;

    return 0;
}

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

template <
    typename TYPE,
    std::size_t SIZE>
std::size_t a_len(const TYPE (&array)[SIZE])
{
    return SIZE;
}

using namespace std;
using ll = long long int;
using vi = vector<ll>;

#define REPS(a, i, n) for (ll(i) = a; (i) < (n); ++(i))
#define REP(i, n) REPS(0, i, n)
#define ALL(x) (x).begin(), (x).end()

const int INF = 100001;

int main()
{
    string a,b;
    cin >> a >> b;
    REP(i,a.size()){
        string tmp ="";
        REP(j,a.size()){
            tmp += a[(i+j)%a.size()];
        }
        if(tmp == b){
            cout << "Yes" << endl;
            return 0;
        }
    }
        cout << "No" << endl;
}

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

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<((x))<<endl
#define fi first
#define se second

#define INF 2147483600

class UnionFind {
public:
  vector<int> par, rank; // parent(negative := its root and abs-value is its size), depth
  UnionFind(int sz) : par(sz, -1), rank(sz, 0){}
  int find(int x){
    if(par[x]<0) return x;
    else return par[x] = find(par[x]);
  }
  void unite(int x, int y){
    x=find(x); y=find(y);
    if(x==y) return;  // already belong to same tree
    if(rank[x] < rank[y]){  // y becomes parent node
      par[y] += par[x];
      par[x] = y;
    } else {  // x becomes parent node
      par[x] += par[y];
      par[y] = x;
      if(rank[x]==rank[y]) rank[x]++;
    }
  }
  bool same(int x, int y){ return find(x) == find(y); }
  int size(int x){ return -par[find(x)]; }
}; // END class UnionFind


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

  vector<vector<int> > lang2p(m, vector<int>());
  rep(i,n){
    int k;
    scanf("%d", &k);
    rep(j,k){
      int l;
      scanf("%d", &l);
      l--;
      lang2p[l].pb(i);
    }
  }

  UnionFind uf(n);
  rep(i,m) repl(j,1,lang2p[i].size()){
    uf.unite(lang2p[i][j], lang2p[i][0]);
  }

  if(uf.size(0)==n){
    cout<<"YES"<<endl;
  } else {
    cout<<"NO"<<endl;
  }

  return 0;
}


Measured memory_bytes: 4608
'''
自宅用PCでの解答
'''
import math
#import numpy as np
import itertools
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
mod = 10**9+7
alp = "abcdefghijklmnopqrstuvwxyz"

def main():
    n = input()
    ln = len(n)
    ma = sum(map(int,n))
    ma2 = int(n[0])-1+9*(ln-1)
    if ma < ma2:
        print(ma2)
    else:
        print(ma)


    return None

if __name__ == '__main__':
    main()


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

int main(void) {
	int N, H[100005],i,j,count=0,max=0,current;
	scanf("%d", &N);
	for (i = 0; i < N; i++) {
		scanf("%d", &H[i]);
	}
	for(i=0;i<N;i++){
		count = 0;
		current = H[i];
		j = i+1;
		while (current >= H[j] && j<N) {
			current = H[j];
			count++;
			j++;	
		}
			if (max <= count) {
				max = count;
			}
      i=i+count;
	}
	printf("%d", max);
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;

struct Segmenttree{
    int n;
    vector<long long> node;

    Segmenttree(vector<long long> v){
        n = (int)(v.size());
        node.resize(2*n);
        for(int i=0;i<n;i++) node[i+n] = v[i];
        for(int i=n-1;i>=0;i--) node[i] = max(node[i<<1],node[i<<1|1]);
    }
    //i番目の要素をxに変更する
    void update(int i,long long x){
        i += n;
        node[i] = x;
        while(i>1){
            i >>= 1;
            node[i] = max(node[i<<1],node[i<<1|1]);
        }
    }
    //[l,r)の要素のmaxを求める
    long long query(int l,int r){
        long long res = 0;
        l += n; r += n;
        while(l<r){
            if(l&1) res = max(res,node[l++]);
            if(r&1) res = max(res,node[--r]);
            l >>= 1; r >>= 1;
        }
        return res;
    }
    //i番目の要素にアクセス
    long long getval(int i){
        return node[i+n];
    }
};

int main(){
    int n,q;
    cin >> n >> q;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    Segmenttree seg(a);

    while(q--){
        int t,a,b;
        cin >> t >> a >> b;
        if(t==1){
            --a;
            seg.update(a,b);
        }else if(t==2){
            --a;
            cout << seg.query(a,b) << endl;
        }else if(t==3){
            --a;
            int l = a,r = n+1;
            while(r - l > 1){
                int m = (l+r)/2;
                if(seg.query(a,m)<b) l = m;
                else r = m;
            }
            cout << l+1 << endl;
        }
        /*
        rep(i,n){
            cout << seg.getval(i) << " ";
        }
        cout << endl;
        */
    }
    return 0;
}

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

string S, T; bool used[26], flag = false;

int main() {
	cin >> S;
	for (int i = S.size(); i >= 0; i--) {
		for (int j = 0; j < 26; j++) used[j] = false;
		for (int j = 0; j < i; j++) used[S[j] - 'a'] = true;
		int TT = -1; if (i < S.size()) TT = (S[i] - 'a');
		for (int j = TT + 1; j < 26; j++) {
			if (used[j] == false) {
				T = S.substr(0, i);
				T += ('a' + j);
				flag = true;
				break;
			}
		}
		if (flag == true) break;
	}
	if (flag == true) cout << T << endl;
	else cout << "-1" << endl;
	return 0;
}

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

int p,q,A,N;

int rec(int pos,int K,int x,int y,int prev){
    if(pos==K){
        if(x*q==y*p) return 1;
    }
    int res=0;
    for(int i=prev;y*i<=A;i++){
        if((x*i+y)*q<=y*i*p){
            res+=rec(pos+1,K,x*i+y,y*i,i);
        }
    }
    return res;
}

signed main()
{           
    while(true){
        cin>>p>>q>>A>>N;
        if(p==0) return 0;

        int ans=0;
        for(int K=1;K<=N;K++){
            ans+=rec(0,K,0,1,1);
        }
        cout<<ans<<endl;
    }
}



Measured memory_bytes: 2968
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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;

int main(){
  int n, d, x; cin >> n >> d >> x;

  int sum = 0;
  rep(i, n){
    int a; cin >> a;
    sum += 1 + (d-1)/a;
  }
  
  cout << sum + x << endl;

  return 0;
}


Measured memory_bytes: 256
n,k = map(int,input().split())
s = input()
c = 0
lr = 0
rl = 0
for i in range(n-1):
  if s[i] == s[i+1]:
    c += 1
  elif s[i] == 'L':
    lr += 1
  else:
    rl += 1
if k > min(lr,rl):
  if lr == rl:
    print(c+2*lr)
  else:
    print(c+min(lr,rl)*2+1)
else:
  print(c+2*k)

Measured memory_bytes: 3316
#include<bits/stdc++.h>
    using namespace std;
    # define ll long long int
     
    int main(){
    	#ifndef ONLINE_JUDGE
    		freopen("input.txt","r",stdin);
    		freopen("output.txt","w",stdout);
    	#endif
    	string s;
        cin>>s;
        for(int i=0;i<=2;i++){
            cout<<s[i];
        }
        cout<<endl;
    	
    }
    


Measured memory_bytes: 3628
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import math

N = int(input())
D, X = list(map(int, input().split()))
a = []
ans = 0
for i in range(N):
    a.append(int(input()))

for i in range(N):
    ans += math.ceil(D / a[i])

print(ans + X)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <cmath>
#include <map>
#include <iomanip>
#include <unordered_map>
#include <stack>

using namespace std;
typedef long long  ll;

const ll mod = 1000000007;

int main()
{
	ll N;
	cin >> N;
	vector<ll> a(N);
	for (ll i = 0; i < N; i++)
	{
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	if (N % 3 == 0)
	{
		if (a[0] == 0 && a[N / 3 - 1] == 0 && a[N / 3] == a[N - 1])
		{
			cout << "Yes" << endl;
			return 0;
		}
		else if (a[0] == a[N / 3 - 1] && a[N / 3] == a[2 * N / 3 - 1] && a[2 * N / 3] == a[N - 1] && (a[0]^a[N / 3]^a[2 * N / 3]) == 0 && a[0] != a[N / 3] && a[0] != a[2 * N / 3] && a[N / 3] != a[2 * N / 3])
		{
			cout << "Yes" << endl;
			return 0;
		}
		else
		{
			cout << "No" << endl;
			return 0;
		}
	}
	else
	{
		if (a[0] == 0 && a[N - 1] == 0)
		{
			cout << "Yes" << endl;
			return 0;
		}
		else
		{
			cout << "No" << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 1024
N,W = map(int,input().split())
wv = []
a = 0
for i in range(N):
    w,v = map(int,input().split())
    a = max(v,a)
    wv.append((w,v))
A = N*a
inf = 10**15
dp = [[inf]*(A+1) for i in range(N+1)]
dp[0][0] = 0
for i in range(1,N+1):
    for v in range(A+1):
        if v-wv[i-1][1]>=0:
            dp[i][v] = min(dp[i-1][v-wv[i-1][1]]+wv[i-1][0],dp[i-1][v])

        else:
            dp[i][v] = dp[i-1][v]

ans = 0

for j in reversed(range(A+1)):
    if dp[N][j]<=W:
        ans = j
        break
print(ans)

Measured memory_bytes: 120044
#include <algorithm>
#include <cassert>
#include <cstring>
#include <iostream>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

uint64_t count(void) {
  uint64_t N;
  cin >> N;
  vector<uint64_t> list;
  list.resize(N);
  {
    uint64_t v;
    cin >> v;
    if (v != 0) return 0;
    list[v]++;
  }
  for (int i = 0; i < N - 1; i++) {
    uint64_t v;
    cin >> v;
    if (v == 0) return 0;
    list[v]++;
  }
  uint64_t comb = 1;
  uint64_t sum = list[0];
  for (uint64_t i = 1; i < N; i++) {
    if (list[i] == 0) return 0;
    for (uint64_t k = 0; k < list[i]; k++) {
      comb *= list[i - 1];
      comb %= 998244353ULL;
    }
    sum += list[i];
    if (sum == N) break;
  }
  return comb;
}

int main(int argc, char *argv[]) {
  cout << count() << endl;
  return 0;
}


Measured memory_bytes: 1152
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
vector<ll> tree[200010];

ll ans[200010] = {};
ll dp[200010];
ll a[200010];
ll N;

void dfs2(ll cur, ll par){
    ll pos = lower_bound(dp, dp+N, a[cur]) - dp;
    ll prev_val = dp[pos];
    dp[pos] = a[cur];
    int lv = 0, rv = N+1;
    while(rv - lv > 1){
        int mid = (rv + lv) / 2;
        if(dp[mid] == INF){
            rv = mid;
        }else{
            lv = mid;
        }
    }
    ans[cur] = lv + 1;

    for(auto &e: tree[cur]){
        if(e == par) continue;
        dfs2(e, cur);
    }
    dp[pos] = prev_val;
}



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    rep(i,0,N) cin >> a[i];

    rep(i,0,N-1){
        ll u,v;
        cin >> u >> v;
        u--; v--;
        tree[u].push_back(v);
        tree[v].push_back(u);
    }

    vector<ll> v;
    v.push_back(-INF);
    v.push_back(INF);
    rep(i,0,N) v.push_back(a[i]);
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    rep(i,0,N){
        a[i] = lower_bound(v.begin(), v.end(), a[i]) - v.begin();
    }

    rep(i,0,N+10) dp[i] = INF;
    dfs2(0, -1);
    rep(i,0,N) print(ans[i]);
}

Measured memory_bytes: 34808
<?php
fscanf(STDIN,'%s',$S);
$W=str_split($S);
$judge1=0;
$judge2=0;
for ($i=0; $i <count($W) ; $i++) {
  // code...
  if ($i%2==0) {
    // code...
    if($W[$i]=='0'){
      $judge1++;
    }
  }else{
     if ($W[$i]=='1') {
       // code...
       $judge1++;
     }
  }
}
for ($i=0; $i <count($W) ; $i++) {
  // code...
  if ($i%2==0) {
    // code...
    if($W[$i]=='1'){
      $judge2++;
    }
  }else{
     if ($W[$i]=='0') {
       // code...
       $judge2++;
     }
  }
}
$judge=max($judge1,$judge2);
echo count($W)-$judge;
echo "\n";



 ?>


Measured memory_bytes: 21132
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;

const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : abs(x); }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : abs(x); }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;

	int xx = x2 - x1;
	int yy = y2 - y1;

	int x3 = x2 - yy;
	int y3 = y2 + xx;
	int x4 = x1 - yy;
	int y4 = y1 + xx;

	cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
	return 0;
}


Measured memory_bytes: 256
//***The night is the darkest just before the dawn***
 
#include<bits/stdc++.h>
using namespace std;
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long 
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"
 
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef long double ld;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

ll a[2*100002];
ll pre[2*100002];
ll dp[2*100002];
int main(){
    ll n;
    cin>>n;

    for1(i,n) {
        cin>>a[i];
        if(i!=1)
        pre[i]=pre[i-2]+a[i];
        else pre[i]=a[i];
        //cout<<pre[i]<<" ";
    }

    dp[1]=0;
    for(ll i=2;i<=n;i++){
        if(i%2==0){
            dp[i]=max(a[i]+dp[i-2],pre[i-1]);
        }
        else{
            dp[i]=max(dp[i-1],a[i]+dp[i-2]);
        }
    }
    cout<<dp[n];
}

Measured memory_bytes: 8332
a = int(input())
b = int(input())
c = int(input())
x = int(input())

counter = 0

for aa in range(0, a+1):
  for bb in range(0, b+1):
    for cc in range(0, c+1):
      if aa*500+bb*100+cc*50 == x:
        counter += 1
print(counter)

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

char a[4];

int main()
{
    int flag = 0;
    scanf("%s",a);
    for(int i = 0; i < 3; i++)
    {
        if(a[i] == a[i+1])
        {
            flag = 1;
            break;
        }
    }
    if(flag)
        printf("Bad\n");
    else
        printf("Good\n");
}


Measured memory_bytes: 256
N = input()
A_ls = map(int, input().split(' '))
A_ls = [i for i in A_ls if i % 2 == 0]
ls = [i for i in A_ls if i % 3 == 0 or i % 5 == 0]
if len(A_ls) == len(ls):
    print('APPROVED')
else:
    print('DENIED')

Measured memory_bytes: 9192