akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define unless(flg) if ( !(flg) )
#define read cin<<
#define echo cout<<
#define fin <<'\n'
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
#define cinf(n,x) for(int UNCH=0;UNCH<(n);UNCH++) cin >> x[UNCH];
#define fcin(n,x) for(int UNCH=1;UNCH<=(n);UNCH++) cin>> x[UNCH];
#define memmin(x) memset((x),-1,sizeof((x)))
#define memzer(x) memset((x), 0,sizeof((x)))
#define meminf(x) memset((x),0x3f,sizeof((x)))
#define int long long
typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 1000000009;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>T abs(T &x){return x<0 ? -x : x;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int qp(int 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;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}



signed main(){

  int n,a,b;
  string str;

  cin >>n >> a >> b;
  if(abs(n-a) < abs(n-b)) cout <<"A\n";
  else cout <<"B\n";
  
  return 0;
}



struct xyz{ xyz(){ cin.tie(0), ios::sync_with_stdio(false); cout <<fixed<<setprecision(12);};}xyzzy;



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
  int N,i;
  cin >> N;
  for (i=0; i<N; i++) {
    string h = "";
    cin >> h;
    if (h == "Y") {
      cout << "Four" << endl;
      break;
    }
    if (i == N-1) {
      cout << "Three" << endl;
    }
  }
}


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

int main() {
  ll N; cin >> N;
  ll a[N];
  for (ll i = 0; i < N; i++) {
    cin >> a[i];
  }
  ll sum = 0; ll xsum = 0;
  ll res = 0;
  ll s = 0;
  for (ll t = 0; t < N; t++) {
    sum+= a[t];
    xsum^= a[t];
    if (sum == xsum) {res+= (t-s+1);}
    if (sum != xsum) {
      while (sum != xsum && s < t) {
        sum-= a[s];
        xsum^= a[s];
        s++;
      }
      res+= (t-s+1);
    }
  }
  cout << res << endl;
}

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

int main(){
    int N;
    int K;
    int step = 0;
    int ball;
    cin >> N;
    cin >> K;
    rep(i, N){
        cin >> ball;
        if (ball > K - ball){
            step += (K - ball) * 2;
        }
        else
        {
            step += ball * 2;
        }
        
    }
    cout << step << endl;
}

Measured memory_bytes: 3616
# grid BFS 最短経路
height, width, k = gets.split.map(&:to_i)
boards = []
height.times { boards << gets.chomp.split("") }

number_boards = Array.new(height) { Array.new(width, -1) }

boards.each_with_index do |row, row_i|
  row.each_with_index do |e, e_i|
    if e == "#"
      number_boards[row_i][e_i] = - 2
    end
  end
end

queue = [[0, 0, 0]]

until queue.empty?
  h, w, step = queue.shift

  if h > 0 && number_boards[h - 1][w] == - 1
    number_boards[h - 1][w] = step + 1
    queue << [h - 1, w, step + 1]
  end

  if h < height - 1 && number_boards[h + 1][w] == - 1
    number_boards[h + 1][w] = step + 1
    queue << [h + 1, w, step + 1]
  end

  if w > 0 && number_boards[h][w - 1] == - 1
    number_boards[h][w - 1] = step + 1
    queue << [h, w - 1, step + 1]
  end

  if w < width - 1 && number_boards[h][w + 1] == - 1
    number_boards[h][w + 1] = step + 1
    queue << [h, w + 1, step + 1]
  end
end

neccesary_tiles = number_boards[height - 1][width - 1] + 1
black_tiles = boards.flatten.count("#")
score = height * width - neccesary_tiles - black_tiles
puts neccesary_tiles <= 0 ? -1 : score


Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;
#define rep(i,end) for(ll i = 0; i < end ; i++ )
#define print(ans) cout << fixed << setprecision(15) << ans << endl;
typedef long long ll;
typedef vector<ll> vi;

double norm(ll x1, ll x2, ll y1, ll y2){
  return pow(pow(x1-x2,2) + pow(y1-y2, 2),0.5);
}

long long kaijou(ll x, ll mod){
  ll ideal = 1;
  rep(i, x){
    ideal *= x-i;
    ideal %= mod;
  }
  return ideal;
}

long long exp(ll a, ll n, ll mod){
  ll m = n;
  if (a == 1) return 1;
  vector<ll> subvec;
  ll cnt = 0;
  while (m>0){
    if ((m&1) == 1){
      subvec.push_back(cnt);
    }
    m >>= 1;
    cnt ++;
  }
  ll res = 1;
  vector<ll> vec;
  rep(i, cnt){
    a %= mod;
    vec.push_back(a);
    a = a*a%mod;
  }
  for (auto& e : subvec) {
    res = res*vec[e]%mod;
  }
  return res;
}

double sum(vector<double> vec){
  return accumulate(vec.begin(), vec.end(), 0);
}

int main() {
  ll X, Y, mod = pow(10, 9) + 7;
  cin >> X >> Y;
  if ((2*Y-X)%3 != 0 or 2*Y -X < 0 or (2*X-Y)%3 !=0  or 2*X -Y < 0){
    print(0);
  }
  else{
    ll a, b, ans, bunbo;
    a = (2*Y-X)/3;
    b = (2*X-Y)/3;
    ans = kaijou(a+b, mod);
    bunbo = kaijou(a, mod)*kaijou(b, mod)%mod;
    ans *= exp(bunbo, mod-2, mod);
    ans %= mod;
    print(ans);
  }
}

Measured memory_bytes: 3572
//  Created by liszt on 2019/07/27.
#include<bits/stdc++.h>
using namespace std;

int main(){
    int n; cin>>n;
    vector<int> p(n);
    for(int i=0;i<n;i++)cin>>p[i];
    
    int cnt=0;
    for(int i=0;i<n;i++){
        if(p[i]!=i+1)cnt++;
    }
    if(cnt>2){
        cout<<"NO"<<endl;
        return 0;
    }
    cout<<"YES"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long a,b,zg,ans;
int main()
{
      cin>>a>>b;
      zg=1;
      while(zg<=b/a)
      {
      	ans++;
      	zg*=2;
      }
      cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
n = int(input())
 
if n >= 1800: print(1)
elif n >= 1600: print(2)
elif n >= 1400: print(3)
elif n >= 1200: print(4)
elif n >= 1000: print(5)
elif n >= 800: print(6)
elif n >= 600: print(7)
elif n >= 400: print(8)

Measured memory_bytes: 9172
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
//#define p pair<int,int>
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
using namespace std;
int POW(int x,int y){return int(pow(double(x),double(y)));}


int main(){
	string s;
	cin>>s;
	ll a=0,b=0,c=0,d=1;
	rrep(i,s.size()){
		ll a1,b1,c1,d1;
		if(s[i]=='A'){
			a1=a+b;
			b1=b;
			c1=c;
			d1=d;
		}
		if(s[i]=='B'){
			a1=a;
			b1=b+c;
			c1=c;
			d1=d;
		}
		if(s[i]=='C'){
			a1=a;
			b1=b;
			c1=c+d;
			d1=d;
		}
		if(s[i]=='?'){
			a1=3*a+b;
			b1=3*b+c;
			c1=3*c+d;
			d1=3*d;
		}
		a=a1%mod;
		b=b1%mod;
		c=c1%mod;
		d=d1%mod;
	}
	cout<<a<<endl;


}


Measured memory_bytes: 512
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("faild to read char") as char)
        .take_while(|c| !c.is_whitespace())
        .collect();
    token
        .parse()
        .ok()
        .expect("faild to parse token")
}

fn main(){
    if ans(read(), read(), read()) {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn ans(n: i32, m: i32, k: i32) -> bool {
    for i in 0..(n + 1) {
        for j in 0..(m + 1) {
            if k == i * (m - j) + j * (n - i) {
                return true;
            }
        }
    }
    false
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  int N, D;
  cin >> N >> D;
  cout << ceil(1.0 * N / (2 * D + 1)) << endl;
  return 0;
}



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

}
return 0;
}


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

const int MAX_N = (int)1e6 + 5;
lint dp[2*MAX_N][3], cnt[2*MAX_N];

int main(){
    ios::sync_with_stdio(false), cin.tie(nullptr);
    int N, Q;
    string S;
    cin >> N >> S >> Q;

    for(int i=0;i<N;i++) cnt[i+1] = cnt[i] + (S[i]=='M');

    for(int i=0;i<Q;i++){
        int K; cin >> K;
        for(int j=0;j<=N;j++) for(int k=0;k<3;k++) dp[j][k] = 0;
        for(int j=0;j<N;j++){
            for(int k=0;k<3;k++) dp[j+1][k] += dp[j][k];
            if(S[j]=='D') dp[j+K][0] -= 1, dp[j+K][1] -= cnt[j+K] - cnt[j], dp[j+1][0]++;
            if(S[j]=='M') dp[j+1][1] += dp[j][0];
            if(S[j]=='C') dp[j+1][2] += dp[j][1];
        }
        cout << dp[N][2] << endl;
    }
    return 0;
}

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

int main()
{
    string s;
    int k;
    cin >> s >> k;
    int size = s.size();
    set<string> m;

    vector<string> v;

    for(int i = 0; i < size; ++i)
    {
        for(int j = 1; j <= k; ++j)
        {
            m.insert(s.substr(i, j));
        }
    }

    int cont = 1;
    for(auto i: m)
    {
        if(cont == k)
            cout << i << "\n";
        cont++;
    }
    return 0;
}

Measured memory_bytes: 4780
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const int MOD=1e9+7;
const int INF=2e9;
const double PI=acos(-1);


int main() {
    ios_base::sync_with_stdio(false);

    ll r,g,b,n;
    cin >> r >> g >> b >> n;
    int ans=0;
    rep(i,3001) {
        rep(j,3001) {
            ll s=n-(r*i+g*j);
            if (s>=0 && s%b==0) ++ans;
        }
    } 
    cout << ans << endl;
    
    return 0;   
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)    scanf("%d",&x)
#define sl(x)    scanf("%lld",&x)
#define ss(s)    scanf("%s",s)
#define pi(x)    printf("%d\n",x)
#define pl(x)    printf("%lld\n",x)
#define ps(s)    printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define in insert
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>    pii;
typedef pair<ll, ll>      pl;
typedef vector<int>       vi;
typedef vector<ll>        vl;
typedef vector<pii>       vpii;
typedef vector<pl>        vpl;
typedef vector<vi>        vvi;
typedef vector<vl>        vvl;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
#define MAXN   20000001 
int rng(int lim) {
    uniform_int_distribution<int> uid(0,lim-1);
    return uid(rang);
}

int mpow(int base, int exp); 
void ipgraph(int n, int m);
void dfs(int u, int par);

const int mod = 1'000'000'007;
const int N = 3e5, M = N;



void solve(){
    
   ll n,x,i;
   cin>>x>>n;
   map<int,int> m;
   fo(i,n)
   {
    ll temp;
    cin>>temp;
    m[temp]=1;
   }
   ll temp1=x,temp2=x;
   while(1)
   {
    if(m[temp1]==0)
    {
        cout<<temp1<<endl;
        break;
    }
    if(m[temp2]==0)
    {
        cout<<temp2<<endl;
        break;
    }
    --temp1;
    ++temp2;

   }

   //cout<<ans<<endl;

}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int t = 1;
   // cin >> t;
    while(t--) {
      solve();
    }

    return 0;
}

vl g[N];


int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(int n, int m){
    int i, u, v;
    while(m--){
        cin>>u>>v;
    u--, v--;
        g[u].pb(v);
        g[v].pb(u);
    }
}

void dfs(int u, int par){
    for(int v:g[u]){
        if (v == par) continue;
        dfs(v, u);
    }
}


Measured memory_bytes: 10656
from itertools import permutations
N=int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))
l=list(permutations(range(1,N+1)))
for i in range(len(l)):
    if P==l[i]:
        p=i
for i in range(len(l)):
    if Q==l[i]:
        q=i
print(abs(p-q))

Measured memory_bytes: 8052
N=int(input())
S=input()
cnt = 0
for i in range(1,N):
  if S[i] == 'E': cnt += 1
ans = cnt
for i in range(1,N):
  if S[i-1] == 'W': cnt += 1
  if S[i] == 'E': cnt -= 1
  ans = min(ans, cnt)
print(ans)


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

int main(){
  int a, b;
  
  cin >> a >> b;
  
  if(a > 12){
    cout << b << endl;
  }
  else if(a > 5){
    cout << b * 0.5 << endl;
  }
  else{
    cout << 0 << endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

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

        if(a < b) {
            if(b < c) {
                System.out.printf("%d %d %d\n", a, b, c);
            } else if(a < c) {
                System.out.printf("%d %d %d\n", a, c, b);
            } else {
                System.out.printf("%d %d %d\n",c, a, b);
            }
        } else {
            if(a < c) {
                System.out.printf("%d %d %d\n", b, a, c);
            } else if(b < c) {
                System.out.printf("%d %d %d\n", b, c, a);
            } else {
                System.out.printf("%d %d %d\n", c, b, a);
            }

        }
    }
}


Measured memory_bytes: 26204
#include<cstdio>

int main(){
  char number[1001];
  char ch;
  int cnt = 0;
  int sum = 0;

  while(1){
    scanf("%s", number);
    if(number[0] == '0') break;
    sum = 0;
    while(1){
      ch = number[cnt];

      if(ch == '\0') {
	cnt = 0;
	break;
      }

      sum += (ch - '0');
      cnt++;
    }
    printf("%d\n", sum);
  }
  return 0;
}

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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)

int main()
{
    lint n,m;cin >> n>>m;
    vector<lint> v(n,-1);
    
    REP(i, m) {
        lint s, c;
        cin >>s >> c;
        if(v[s-1]!=-1&&v[s-1]!=c){
            cout << -1 << "\n";
            return 0;
        }
        v[s - 1] = c;
    }
    REP(i, n)
        //cout << v[i]<<" ";
    if(n==1){
        if(v[0]<=0){
            cout << 0<<"\n";
        }else{
            cout << v[0] << "\n";
        }
        return 0;
    }
    if(v[0]==0){
        cout << -1 << "\n";
        return 0;
    }else if(v[0]==-1){
        cout << 1;
    }else{
        cout << v[0];
    }
    FOR(i,1,n){
        if(v[i]==-1){
            cout << 0;
        }else{
            cout << v[i];
        }
    }

    cout <<"\n";

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int X = (A); X <= (Y);++X)
#define _rep2(X, Y) for (int X = 0; X < (Y); ++X)
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X, Y) for (int X = (Y-1); X >= 0; --X)
#define all(X) (X).begin(),(X).end()
#define len(X) ((int)(X).size())
#define mod(n, m) (((n)%(m)+(m))%(m))
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MAX_N = 200000;
int N;
int A[MAX_N + 1];

int main() {
    cin >> N;
    rep(i, 1, N) cin >> A[i];

    map<int, int> mp;
    mp[1 + A[1]]++;
    ll ans = 0;
    for (int i = 2; i <= N; ++i) {
        if (mp.count(i - A[i]) > 0) {
            ans += mp[i - A[i]];
        }
        mp[i + A[i]]++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 13672
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
string str;
char board[3][3];
bool flag1;//丸の勝利
bool flag2;//罰の勝利
void check(){
	for(int i = 0;i < 3;i++){//縦方向
		if(board[i][0]!='s'&&board[i][0]==board[i][1]&&board[i][0]==board[i][2]){
			cout <<board[i][0]<<endl;
			return;
		}
	}
	for(int j = 0;j < 3;j++){//縦方向
		if(board[0][j]!='s'&&board[0][j]==board[1][j]&&board[1][j]==board[2][j]){
			cout <<board[0][j]<<endl;
			return;
		}
	}
	if(board[0][0]!='s'&&board[0][0]==board[1][1]&&board[0][0]==board[2][2]){//右斜め方向
		cout <<board[0][0]<<endl;
		return ;

	}
	if(board[0][2]!='s'&&board[0][2]==board[1][1]&&board[0][2]==board[2][0]){//左斜め方向
		cout <<board[0][2]<<endl;
		return ;
	}
	cout <<"d"<<endl;
}

int main(){
	while(cin>>str){
		int k = 0;
		for(int i = 0;i < 3;i++){
			for(int j = 0;j < 3;j++){
				board[i][j] = str[k];
				k++;
			}
		}
		check();
	}
	return 0;
}

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

void fnInput(vector<string>& rvsBoard)
{
  int nHigh, nWide;
  cin >> nHigh >> nWide;

  rvsBoard.resize(nHigh);
  for (int ny = 0; ny < nHigh; ny++)
    cin >> rvsBoard[ny];
}

int fnCountBomb(int ny, int nx, const vector<string>& cnrvsBoad)
{
  if (   ny >= 0  && ny < cnrvsBoad.size()
      && nx >= 0  && nx < cnrvsBoad[ny].size())
    if (cnrvsBoad[ny][nx] == '#')  return 1;
    else;

  return 0;
}

void fnMinesweeper(vector<string>& rvsBoard)
{
  const vector<int> cnvnDy = {-1, -1, -1,  0,  0,  1,  1,  1};
  const vector<int> cnvnDx = {-1,  0,  1, -1,  1, -1,  0,  1};
  for (int ny = 0; ny < rvsBoard.size(); ny++)
    for (int nx = 0; nx < rvsBoard[ny].size(); nx++)
      if (rvsBoard[ny][nx] == '.')
      {
        int nCount = 0;
        for (int i = 0; i < cnvnDy.size(); i++)
          nCount += fnCountBomb(ny + cnvnDy[i], nx + cnvnDx[i], rvsBoard);

        rvsBoard[ny][nx] = '0' + nCount;       // int → char 変換
      }
}

void fnResult(const vector<string>& cnrvsBoard)
{
  for (string sBoard : cnrvsBoard)
    cout << sBoard << endl;
}

int main()
{
  vector<string> vsBoard;

  fnInput(vsBoard);
  fnMinesweeper(vsBoard);
  fnResult(vsBoard);

  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <list>

using std::list;
using std::max;
using std::min;
using std::vector;

int main()
{
  int a, b;
  scanf("%d%d", &a, &b);
  if(a + b == 15) {
    puts("+");
  } else if(a * b == 15) {
    puts("*");
  } else {
    puts("x");
  }
  return 0;
}


Measured memory_bytes: 128
// AOJ ALDS1_4_C Dictionary
// 2018.4.27 bal4u

#include <stdio.h>

// バッファを経ずstdinから数値を得る
#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif
int in()
{
	int n = 0, c = gc();
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

int  tr['T'+1];
char f[33554432];

int main()
{
	int n, k, c;

	tr['A'] = 0, tr['C'] = 1, tr['G'] = 2, tr['T'] = 3;
	n = in();
	while (n--) {
		if (gc() == 'i') {
			k = 7; while (--k) gc();
			k++; while ((c = gc()) >= ' ') k <<= 2, k |= tr[c];
			f[k] = 1;
		} else {
			k = 5; while (--k) gc();
			k++; while ((c = gc()) >= ' ') k <<= 2, k |= tr[c];
			if (f[k]) pc('y'), pc('e'), pc('s');
			else      pc('n'), pc('o');
			pc('\n');
		}
	}
	return 0;
}



Measured memory_bytes: 2988
main :: IO ()
main = do
  (n:a:b:c:d:_) <- map read . words <$> getLine :: IO [Int]
  s <- getLine
  putStrLn $ if solve a b c d s then "Yes" else "No"

solve a b c d s 
  | c < d = simple
  | otherwise = simple && passable
  where
    simple = reachable a c && reachable b d
    reachable x y = proceedable . drop (x-1) . take y $ s
    proceedable (s:[]) = True
    proceedable (s:ss:sss)
      | s == '#' && ss == '#' = False
      | otherwise = proceedable (ss:sss)

    passable = go . drop (b-2) . take (d+1) $ road
      where
        road = map (== '.') s
        go (r:rs:[]) = False
        go (r:rs:rss:rsss)
          | r && rs && rss = True
          | otherwise = go (rs:rss:rsss)



Measured memory_bytes: 13692
#include<bits/stdc++.h>
using namespace std;
     
#define ll long long
#define loop(i,a,n) for(ll i=a;i<n;++i)
#define revloop(i,a,b) for(ll i=a;i>=b;--i)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define INF 1000000000000000000
#define MOD 998244353 

void func()
{
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    while(b<=a && k>0){
        b=b*2;
        k--;
    }
    while(c<=b && k>0){
        c=c*2;
        k--;
    }
    if(a<b && b<c){
        cout<<"Yes"<<"\n";
    }
    else{
        cout<<"No"<<"\n";
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r" , stdin);
    freopen("output.txt", "w" , stdout);
    #endif
 
    ll t=1;
    //cin>>t;
    while(t--)
    {
        func();
    }

}

Measured memory_bytes: 3664
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 c = sc.nextInt();

      if(a+b>=c){
        System.out.println("Yes");
      }
      if(a+b<c){
        System.out.println("No");
      }



  }
}


Measured memory_bytes: 21844
import java.util.*;
import java.util.function.*;
import java.util.stream.*;

public class Main{
	Scanner s=new Scanner(System.in);

	boolean isKaibunn(String t){
		int n=t.length();
		for(int i=0;i<n;++i){
			if(t.charAt(n-1-i)!=t.charAt(i)){
				return false;
			}
		}
		return true;
	}

	void solve(){
		String t=s.next();
		int n=t.length();

		boolean a=isKaibunn(t);
		String tb=t.substring(0,(n-1)/2);
		boolean b=isKaibunn(tb);
		String tc=t.substring((n+1)/2,n);
		boolean c=isKaibunn(tc);

		System.err.println(tb);
		System.err.println(tc);
		System.err.println(a);
		System.err.println(b);
		System.err.println(c);
		System.out.println(a&&b&&c?"Yes":"No");
	}

	public static void main(String[] A){
		new Main().solve();
	}

	int gInt(){
		return Integer.parseInt(s.next());
	}
	long gLong(){
		return Long.parseLong(s.next());
	}
	double gDouble(){
		return Double.parseDouble(s.next());
	}

	SupplyingIterator<Integer> ints(int n){
		return new SupplyingIterator<>(n,this::gInt);
	}
	SupplyingIterator<Long> longs(int n){
		return new SupplyingIterator<>(n,this::gLong);
	}
	SupplyingIterator<Double> doubles(int n){
		return new SupplyingIterator<>(n,this::gDouble);
	}
	SupplyingIterator<String> strs(int n){
		return new SupplyingIterator<>(n,s::next);
	}

	Range rep(int i){
		return Range.rep(i);
	}
	Range rep(int f,int t,int d){
		return Range.rep(f,t,d);
	}
	Range rep(int f,int t){
		return rep(f,t,1);
	}
	Range rrep(int f,int t){
		return rep(t,f,-1);
	}

	IntStream REP(int v){
		return IntStream.range(0,v);
	}
	IntStream REP(int l,int r){
		return IntStream.rangeClosed(l,r);
	}

	IntStream INTS(int n){
		return IntStream.generate(this::gInt).limit(n);
	}
	LongStream LONGS(int n){
		return LongStream.generate(this::gLong).limit(n);
	}
	Stream<String> STRS(int n){
		return Stream.generate(s::next).limit(n);
	}

}

class SupplyingIterator<T> implements Iterable<T>,Iterator<T>{
	int t;
	Supplier<T> supplier;

	SupplyingIterator(int t,Supplier<T> supplier){
		this.t=t;
		this.supplier=supplier;
	}

	@Override
	public Iterator<T> iterator(){
		return this;
	}

	@Override
	public boolean hasNext(){
		return t>0;
	}

	@Override
	public T next(){
		--t;
		return supplier.get();
	}

}

class Range implements Iterable<Integer>,PrimitiveIterator.OfInt{
	int to,cur,d;

	Range(int from,int to,int d){
		this.cur=from-d;
		this.to=to;
		this.d=d;
	}

	Range(int n){
		this(0,n-1,1);
	}

	@Override
	public Iterator<Integer> iterator(){
		return this;
	}

	@Override
	public boolean hasNext(){
		return (cur+d==to)||(d<0^cur+d<to);
	}

	@Override
	public int nextInt(){
		return cur+=d;
	}
	static Range rep(int i){
		return new Range(i);
	}
	static Range rep(int f,int t,int d){
		return new Range(f,t,d);
	}
	static Range rep(int f,int t){
		return rep(f,t,1);
	}
	static Range rrep(int f,int t){
		return rep(f,t,-1);
	}
}


Measured memory_bytes: 22868
#include <iostream>

int main()
{
    int n;

    char mark;
    int rank;

    const int cardNum = 13;
    bool S[cardNum] = {};
    bool H[cardNum] = {};
    bool C[cardNum] = {};
    bool D[cardNum] = {};

    std::cin >> n;

    while (n)
    {
        std::cin >> mark >> rank;
        switch (mark)
        {
        case 'S':
            S[rank - 1]=true;
            break;
        case 'H':
            H[rank - 1]=true;
            break;
        case 'C':
            C[rank - 1]=true;
            break;
        case 'D':
            D[rank - 1]=true;
            break;
        }
        n--;
    }

    for (int i = 0; i < cardNum; i++)
    {
        if (!S[i])
        {
            std::cout << "S " << i + 1 << std::endl;
        }
    }
    for (int i = 0; i < cardNum; i++)
    {
        if (!H[i])
        {
            std::cout << "H " << i + 1 << std::endl;
        }
    }
    for (int i = 0; i < cardNum; i++)
    {
        if (!C[i])
        {
            std::cout << "C " << i + 1 << std::endl;
        }
    }
    for (int i = 0; i < cardNum; i++)
    {
        if (!D[i])
        {
            std::cout << "D " << i + 1 << std::endl;
        }
    }
}


Measured memory_bytes: 3076
#include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;

int main() {
	int x, h;
	while (cin >> x >> h) {
		if (x == 0 && h == 0) break;
		printf("%.6lf\n", x * x + hypot(x / 2.0, h) * x * 2.0);
	}
}

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

using namespace std;

#define llint long long int
#define REP(i,s,l) for(llint i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

int main() {

    int hen;
    int nagasaSum = 0;
    cin >> hen ;

    vector<int> nagasa(hen);

    REP(i,0,hen){
        cin >> nagasa[i];
    }

    std::sort(nagasa.begin(), nagasa.end());

    REP(i,0,hen-1){
        nagasaSum += nagasa[i];
    }


    if(nagasaSum > nagasa[(hen-1)] ) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.Threading.Tasks;


class Program
{
	//Main
	static void Main(string[] args)
	{
		//読み込む
		string[] S = Console.ReadLine().Split(' ');
		int N = int.Parse(S[0]);
		long D = long.Parse(S[1]);
		long D2 = D*D;
		int ans = 0;

		//計算
		for(int i=0; i<N; i++){
			long[] line = Console.ReadLine().Split(' ').Select(j => long.Parse(j)).ToArray();
			long dist = line[0]*line[0] + line[1]*line[1];
			if(dist <= D2){
				ans++;
			}
		}

		//出力
		Console.WriteLine(ans);
	}
}



Measured memory_bytes: 23236
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <map>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef double ld;
const long long INF=(1LL<<62);
const double inf=pow(10,10);
double pi=3.141592653589793;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
const ll MOD = 1000000007;
void init(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
}
template <class T>
vector<ll> countVector(vector<T>v,T guard=0){
    ll size=v.size();
    v.push_back(guard);
    vector<ll>ret;
    ll count=1;
    for(int i=0;i<size;i++){
        if(v[i]==v[i+1]){
            count++;
        }else{
            ret.push_back(count);
            count=1;
        }
    }
    return ret;
}
ll gcd(ll a,ll b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

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

map< int64_t, int > prime_factor(int64_t n) {
  map< int64_t, int > ret;
  for(int64_t i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

int main(){
	init();
	ll N;cin>>N;
	ll ans=0;
	for(ll k=1;k*k<=N;k++){
		if(N%k!=0)continue;
		ll m=N/k-1;
		if(k<m)ans+=m;
	}
	cout<<ans<<endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
template<typename T>
using indexed_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define all(v)			((v).begin()), ((v).end())
#define SZ(v)			((int)((v).size()))
#define clr(v, d)		memset(v, d, sizeof(v))
#define has(c,i) 		((c).find(i) != end(c))
#define has_str(s, c)	((s).find(c) != string::npos)
typedef long long ll;
int main() {
#ifdef online_judge
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    string s;
    cin >> s;
    int cnt = count(all(s), 'o');
    cout << (cnt >= SZ(s)/2-1 ? "YES" : "NO");
    return 0;
}


Measured memory_bytes: 3616
import java.util.Scanner;

public class Main {
	Scanner sc = new Scanner(System.in);
	int cnt;
	int seki;
	int kingaku;
	int maisuu;
	int[] uriage = new int [4];
	
	public void syurui(){
		for (cnt=0;cnt<=3;cnt++){
			seki = sc.nextInt();
			maisuu = sc.nextInt();
			switch(seki) {
			case 1: kingaku=6000;  break;
			case 2: kingaku=4000;  break;
			case 3: kingaku=3000;  break;
			case 4: kingaku=2000;  break;
			}
			uriage[cnt] = kingaku*maisuu;			
		}
	}
	
	public void keisan(){
		for (cnt=0;cnt<=3;cnt++){
			System.out.println(uriage[cnt]);
		}
	}
	
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Main yo = new Main();
		yo.syurui();
		yo.keisan();
		
	}

}

Measured memory_bytes: 17304
#include <iostream>
#include <cstring>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cmath>
using namespace std;

int main(){
	ios::sync_with_stdio(false);
	int n;
	while(cin>>n){
		string str;
		int i,s,y;
		if(n==0){
			cout<<"0"<<endl;
		}
		else{
			while(n!=0){
			s=n/(-2);
			y=n%(-2);
			if(y<0){
				y+=2;
				s++;
			}
			str+=y+'0';
			n=s;
			}
			for(i=str.length()-1;i>=0;i--){
				cout<<str[i];
			}
			cout<<endl;	
			}	
	}
	return 0;
}

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

using namespace std;

int main(){
  int N;
  cin >> N;
  vector<int> nums, P, Q;

  for (int i = 0; i < N; i++){
    nums.push_back(i+1);
  }
  
  for (int i = 0; i < N; i++){
    int tmp;
    cin >> tmp;
    P.push_back(tmp);
  }

  for (int i = 0; i < N; i++){
    int tmp;
    cin >> tmp;
    Q.push_back(tmp);
  }

  int p=1, a=0, b=0;
  do{
    
    for (int i = 0; i < N; i++){
      if (nums[i] != P[i]){
        break;
      }
      if (i == N-1){
        a = p;
      }
    }

    for (int i = 0; i < N; i++){
      if (nums[i] != Q[i]){
        break;
      }
      if (i == N-1){
        b = p;
      }
    }
    p++;
  }while(next_permutation(nums.begin(), nums.end()));

  printf("%d\n", abs(a-b));
}


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

int main(void) {
	int N, M;
	scanf("%d %d", &N, &M);
	vector<int> L(M), R(M);
	int maxL = 0;
	int minR = N;
	for (int i = 0; i < M; i++) {
		scanf("%d %d", &L[i], &R[i]);
		maxL = max(maxL, L[i]);
		minR = min(minR, R[i]);
	}
	if (minR >= maxL) {
		printf("%d\n", minR - maxL + 1);
	} else {
		printf("%d\n", 0);
	}

	return 0;
}


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

int main(){
    string a, b;
    cin >> a >> b;
    string c = a + b;
    int num = stoi(c);
    int tmp = sqrt(num);
    if(pow(tmp, 2) == num) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0; 
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
int main()
{
    string s;
    int sum = 0;
    cin >> s;
    string sub = s;
    for (int bits = 0; bits < (1 << 4); bits++)
    {
        sum = (int)(s[0] - '0');
        sub = s;
        for (int i = 1; i < 4; i++)
        {
            if (bits & (1 << i))
            {
                sub.insert(i * 2 - 1, "+");
                sum += (int)(s[i] - '0');
            }
            else
            {

                sub.insert(i * 2 - 1, "-");
                sum -= (int)(s[i] - '0');
            }
        }
        // cout << sum << endl;
        sub.insert(sub.length(), "=7");
        if (sum == 7)
        {
            break;
        }
    }
    cout << sub << endl;
    return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;
typedef complex<ld> com;
constexpr int inf = 1000000000;
constexpr ll INF = 1000000000000000000;
constexpr ld EPS = 1e-12;
constexpr ld PI = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	
	string s, t;
	cin >> s >> t;
	int n = s.size(); int m = t.size();
	string k = s + s;
	vector<vector<int>> pl(26, vector<int>());
	rep(i, 2 * n) pl[k[i] - 'a'].pb(i);
	rep(i, 26) pl[i].pb(2 * n);
	int now = -1; int cnt = 0;
	rep(i, m) {
		int c = t[i] - 'a';
		int idx = upper_bound(all(pl[c]), now) - pl[c].begin();
		int nxt = pl[c][idx];
		if (nxt == 2 * n) {
			cout << -1 << '\n';
			return 0;
		}
		if (nxt >= n) {
			now = nxt - n; cnt++;
		}
		else now = nxt;
	}
	cout << (ll)cnt*n + now + 1 << '\n';
}

Measured memory_bytes: 1872
N, K = map(int, input().split())
h = list(map(int, input().split()))
dp = [float("inf") for _ in range(N)]
for i in range(min(N, K+1)):
  dp[i] = abs(h[i] - h[0])

for j in range(N):
  for k in range(min(N, K+1)):
    if dp[j] > dp[j-k] + abs(h[j] - h[j-k]):
      dp[j] = dp[j-k] + abs(h[j] - h[j-k])
print(dp[N-1])

Measured memory_bytes: 57184
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
#include <utility>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
#define rep(i,n) for(int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.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 int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z temp.cpp
//./a.exe



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

int n,d,x,sum;
cin >> n >> d >> x;
int a[n] = {};
rep(i,n) cin >> a[i];

sum = n;

rep(i,n){
    for(int j = 1;j < 101;j++){
        if((a[i]*j+1) <= d){
            sum++;
        }
    }
}
cout << sum+x << endl;


//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int H, W;
  cin >> H >> W;
  vector<vector<int>> mp(10,vector<int>(10));
  for(int i=0; i<10; i++){
    for(int j=0; j<10; j++){
      cin >> mp.at(i).at(j);
    }
  }
  vector<vector<int>> vec(H,vector<int>(W));
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      cin >> vec.at(i).at(j);
    }
  }
  
  vector<vector<int>> cost(10,vector<int>(10));
  for(int i=0; i<10; i++){
    for(int j=0; j<10; j++){
        cost.at(i).at(j) = mp.at(i).at(j);
    }
  }
  
  for(int k=0; k<10; k++){
    for(int i=0; i<10; i++){
      for(int j=0; j<10; j++){
        cost.at(i).at(j) = min(cost.at(i).at(j), cost.at(i).at(k) + cost.at(k).at(j));
      }
    }
  }
    
  int ans = 0;
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      if(vec.at(i).at(j) >= 0){
        int x = vec.at(i).at(j);
        ans += cost.at(x).at(1);
      }
    }
  }
  cout << ans << endl;     
}

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

int n;
int num[55], ans;

map<string, int> id;

string s;

int main()
{
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> s >> num[i], id[s] = i;
	cin >> s;
	for(int i = id[s] + 1; i <= n; i++) ans += num[i];
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define int long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));

#define dl(line) cerr << "RUN: until " << (line) << "th line." << endl
#define dv(name, value) cerr << (name) << " is " << (value) << endl
#define da(itr, v)  cerr << "["; REPI(itr, v){cerr << *itr << (itr != --v.end() ? ", " : "");} cerr << "]" << endl


void solve(long long N){
  int sum;
  FOR(i, 1, N+1) {
    if(i % 3 and  i % 5) sum += i;
  }
  cout << sum << endl;
}

signed main(){
  long long N;
  scanf("%lld",&N);
  solve(N);
}


Measured memory_bytes: 3660
#include<iostream>
using namespace std;
int N;
long X[1<<17];
long F[1<<17];
long mod=1e9+7;
long power(long a,long b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}
main()
{
	cin>>N;
	F[0]=1;
	for(long i=1;i<=N;i++)F[i]=F[i-1]*i%mod;
	for(int i=1;i<=N;i++)cin>>X[i];
	long ans=0;
	long t=0;
	for(int i=1;i<N;i++)
	{
		(t+=power(i,mod-2))%=mod;
		long now=F[N-1]*t%mod;
		(ans+=now*(X[i+1]-X[i])%mod)%=mod;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1792
THP,TAT,AHP,AAT = map(int,input().split())
while THP > 0 and AHP > 0 :
    AHP -= TAT
    THP -= AAT
if THP <= 0 and AHP > 0 :
    print("No")
elif AHP <= 0 and THP > 0 :
    print("Yes")
else:
    print("Yes")

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

int main() {
    int n, k; cin >> n >> k;
    vector<int> h(n);
    for (int i = 0; i < n; i++) cin >> h[i];
    sort(h.begin(), h.end());
    int ans = 1000000000;
    for (int i = 0; i < n - k + 1; i++) {
        ans = min(ans, h[k + i - 1] - h[0 + i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
#define mp make_pair
#define fs first
#define se second
#define pb push_back
#define all(v) (v).begin(), (v).end()

int main(){
  int N, M;
  cin>>N>>M;
  vector<pii> sc;
  int s, c;
  for(int i=0; i<M; i++){
    cin>>s>>c;
    sc.pb(mp(s, c));
  }
  for(int i=(N==1?0:pow(10, N-1)); i<pow(10, N); i++){
    string I = to_string(i);
    int ok = 0;
    for(int j=0; j<M; j++){
      if(I[sc[j].fs-1]-'0'==sc[j].se)ok++;
    }
    if(ok==M){
      cout<<I<<endl;
      return 0;
    }
  }
  cout<<-1<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<long long, long long> P;
#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#define int long long
template <typename T, typename U>
istream &operator>>(istream &in, pair<T, U>& p) {
    in >> p.first >> p.second;
    return in;
}
signed main(signed argc, char* argv[]) {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	const int MOD=1e9+7;
	int h,w,n;
	cin>>h>>w>>n;
	cout<<min((n-1)/h+1,(n-1)/w+1)<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#define llint long long

using namespace std;
typedef pair<llint, llint> P;

llint n;
llint a[100005];
vector<P> vec;
bool res[5];

bool get(llint x)
{
	llint p = upper_bound(vec.begin(), vec.end(), make_pair(x, 2LL)) - vec.begin() - 1;
	return vec[p].second;
}

int main(void)
{
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> a[i];
	sort(a+1, a+n+1);
	reverse(a+1, a+n+1);
	
	if(a[1] == 1){
		if(n%2) cout << "Second" << endl;
		else cout << "First" << endl;
		return 0;
	}
	if(n == 1){
		if(a[1]%2) cout << "Second" << endl;
		else cout << "First" << endl;
		return 0;
	}
	
	llint pre = 1;
	for(int i = 1; i <= n; i++){
		if(a[i+1] != a[i]){
			llint l = (pre-1)-a[i];
			llint d = i+a[i];
			vec.push_back(make_pair(l, d%2));
			pre = i+1;
		}
	}
	
	for(int i = 1; i < vec.size(); i++){
		if(vec[i-1].second == vec[i].second) continue;
		if(vec[i].first%2 != vec[i-1].second) vec[i].first++;
	}
	
	for(int i = 0; i < 5; i++) res[i] = get(i-2);
	if(res[0]&&res[1]&&res[2] || res[2]&&res[3]&&res[4]) cout << "First" << endl;
	else cout << "Second" << endl;
	
	return 0;
}

Measured memory_bytes: 4212
#include<stdio.h>

int main()
{
	int a, b;
	scanf("%d %d", &a, &b);
	int c = a + b, d = a - b, e = a * b;
	if(c > d && c > e) printf("%d\n", c);
	else if(d > e) printf("%d\n", d);
	else printf("%d\n", e);
	return 0;
}

Measured memory_bytes: 128
import sys
# input処理を高速化する
input = sys.stdin.readline

def main():
    N, K = map(int, input().split())
    lst_a = list(map(int, input().split()))

    # 石の個数が残りi個の局面で勝ちTrue 負け False　
    dp = [False] * (K+1)

    for i in range(1, K+1):
        for j in range(N):
            if i - lst_a[j] >= 0:
                dp[i] |= not(dp[i - lst_a[j]])
    
    if dp[K]:
        print('First')
    else:
        print('Second')

main()

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

int main(){
	string s;	cin>>s;
	vector<char> a(2*s.length());
	for(long long i=0;i<s.length();i++){
		a[i*2]=s[i];
	}

	long long ans=0;
	for(long long flag=0; flag<pow(2,s.length()-1); flag++){
		for(long long i=0;i<s.length()-1;i++){
			if((flag>>i)&1){
				a[2*i +1]='+';
			}else a[2*i +1]='_';
		}

		a[a.size()-1]='+';
		//for(long long i=0;i<a.size();i++)cout<<a[i];
		//cout<<endl;

		string t="";
		for(long long i=0;i<a.size();i++){
			//cout<<a[i];
			if(a[i]!='_')t.push_back(a[i]);
		}

		long long tmp=0;
		for(long long i=0;i<t.length();i++){
			if(t[i]=='+'){
				ans+=tmp;
				tmp=0;
			}else{
				tmp=(tmp*10)+(t[i]-'0');
			}
		}
	}

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


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

int main() {
  int w;
  while (cin >> w) {
    vector<int> ans;
    for (int i = 512; i >= 1; i /= 2)
      if (i <= w)
        ans.push_back(i), w -= i;

    reverse(ans.begin(), ans.end());

    for (int i = 0; i < ans.size(); ++i)
      if (i == ans.size() - 1)
        cout << ans[i] << endl;
      else
        cout << ans[i] << ' ';
  }
}


Measured memory_bytes: 3096
#include <stdio.h>


int main()
{
    int A,B,x;
    int a=0,b=0;
    scanf("%d%d%d",&A,&B,&x);
    


    if(x%500!=0) x+=500-x%500;
    if(A<B)
    {
        a=x/1000;
        if(x%1000>0)
        {
            a++;
        }
    }

   else if(A>2*B)
    {
        b=x/500;
        
    }

  else
    {
        a=x/1000;
        x=x%1000;
        b=x/500;
    }

    printf("%d\n",a*A+b*B);


}




Measured memory_bytes: 2100