akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
const ll INF = 1e18;
const int INT_INF = 1e9;
const ll MOD = 1e9+7;
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; }
using namespace std;

int A, B, C;

int main() {
    cin >> A >> B >> C;
    int rem = A - B;
    cout << max(C - (A - B), 0) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const double eps = 1E-18;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a % b);
}

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	mint operator^(const ll& t)const {
		if (!t) return 1;
		mint a = *this^(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;

typedef vector<mint> vmint;
typedef vector<vector<mint>> vvmint;
typedef vector<vector<vector<mint>>> vvvmint;


///////////////////////////
ll p(ll n) {
	if (n == 0) { return 1; }
	return 10 * p(n - 1);
}

int main() {
	ll D;
	cin >> D;

	ll ans = 0;

	rep(d, 18) {
		ll t = 1;

		ll X = D;
		//cout << d << endl;

		rep(i, (d + 1) / 2) {

			ll j = X % 10;

			if (j < 0) { j += 10; }

			ll a = 10 - j;
			if (a == 10) { a = 0; }
			ll b = -j;

			if (abs(X - b * (p(d - 2 * i) - 1)) < abs(X - a * (p(d - 2 * i) - 1))) { a = b; }

			X -= a * (p(d - 2 * i) - 1);
			X /= 10;

			if (i == 0 && a >= 0)t *= 10 - abs(a) - 1;
			else t *= 10 - abs(a);

			//cout << i<<" "<<a<<" "<<X << endl;
		}

		if (X == 0) {
			if (d % 2 == 0) { ans += t * 9; }
			ans += t;
		}

	}

	cout << ans << endl;

}


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

int main() {
	ll a, b;
	int k;
	cin >> a >> b >> k;
	rep(i, k) {
		if (i % 2 == 0) {
			b += a / 2;
			a /= 2;
		}
		else {
			a += b / 2;
			b /= 2;
		}
	}
	cout << a << " " << b << endl;
}

Measured memory_bytes: 256
using System;
class Mainclass
{
    static void Main()
    {
        int[] s = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
        if (s[0] == s[1])
        {
            Console.WriteLine("Draw");
        }
        else if (s[0] == 1 || s[1] == 1)
        {
            Console.WriteLine(s[0] == 1 ? "Alice" : "Bob");
        }
        else
        {
            Console.WriteLine(s[1] < s[0] ? "Alice" : "Bob");
        }
    }
}

Measured memory_bytes: 27504
use std::io;

fn main() {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    let v: Vec<u64> = buf.split_whitespace().into_iter().map(|el| el.parse().unwrap()).collect();
    let mut count = 0; 
    let target = v[2];
    for x in v[0]..(v[1] + 1) {
        if target%x == 0 {
            count += 1;
        }
    }
    println!("{}", count);
}


Measured memory_bytes: 5028
#include <iostream>
#include <string>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	int n, a, b;
	string s;
	cin >> n >> a >> b >> s;
	int tuuka = 0;
	int oversea = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'a' && tuuka < (a + b)) {
			cout << "Yes" << endl;
			tuuka++;
		}
		else if (s[i] == 'b' && tuuka < (a + b) && oversea < b) {
			cout << "Yes" << endl;
			tuuka++;
			oversea++;
		}
		else {
			cout << "No" << endl;
		}
	}

}


Measured memory_bytes: 896
import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class Main {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);
	static boolean debug = false;

	static void solve() {
		int n = in.nextInt();
		int t = in.nextInt();
		int[] a = new int[n];
		for (int i=0; i<n; i++) {
			a[i] = in.nextInt();
		}

		int min = Integer.MAX_VALUE;
		int d = 0;
		for (int i=0; i<n; i++) {
			min = Math.min(min, a[i]);
			d = Math.max(d, a[i] - min);
		}

		int cnt = 0;
		HashMap<Integer,Integer> map = new HashMap<>();
		for (int i=0; i<n; i++) {
			cnt += map.getOrDefault(a[i]-d, 0);
			map.put(a[i], map.getOrDefault(a[i], 0)+1);
		}

		out.println(cnt);
	}

	public static void main(String[] args) {
		debug = args.length > 0;
		long start = System.nanoTime();

		solve();
		out.flush();

		long end = System.nanoTime();
		dump((end - start) / 1000000 + " ms");
		in.close();
		out.close();
	}

	static void dump(Object... o) { if (debug) System.err.println(Arrays.deepToString(o)); }
}

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

double dp[3000][3000];

int main(){
    int N;
    cin >> N;
    dp[0][0] = 1;
    rep(i, N) {
        double p;
        cin >> p;
        for (int j = 0; j <= N; j++) {
            dp[i + 1][j] += dp[i][j] * (1 - p);
            dp[i + 1][j + 1] += dp[i][j] * p;
        }
    }
    double ans = 0;
    for (int i = N / 2 + 1; i <= N; i++) {
        ans += dp[N][i];
    }
    cout << fixed << setprecision(10) << ans << endl;
}

Measured memory_bytes: 74036
import sys 
L,R = map(int, input().split())

if R-L >= 2019:
    print(0)
    sys.exit()
elif R-L == 1:
    print((R*L)%2019)
    sys.exit()

ans = 4000

for i in range(L,R):
    for j in range(i+1,R+1):
        number = (i*j)%2019
        ans = min(ans,number)

print(ans)  

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

int main() {
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;

    //s->t
    for (int i = 0; i < tx - sx; i++) cout << "R";
    for (int i = 0; i < ty - sy; i++) cout << "U";
    //t->s
    for (int i = 0; i < tx - sx; i++) cout << "L";
    for (int i = 0; i < ty - sy; i++) cout << "D";
    //s->t
    cout << "D";
    for (int i = 0; i < tx - sx + 1; i++) cout << "R";
    for (int i = 0; i < ty - sy + 1; i++) cout << "U";
    cout << "L";
    //t->s
    cout << "U";
    for (int i = 0; i < tx - sx + 1; i++) cout << "L";
    for (int i = 0; i < ty - sy + 1; i++) cout << "D";
    cout << "R";

    cout << endl;
    return 0;
}

Measured memory_bytes: 256
N = gets.chomp.to_i
a = gets.chomp.split.map(&:to_i)
Q = gets.chomp.to_i
BC = Q.times.map{gets.chomp.split.map(&:to_i)}
sum = a.sum

arr = [0] * ((10 ** 5) + 1)

(0...N).each do |j|
  arr[a[j]] += 1
end

(0...Q).each do |i|
  sum += ((BC[i][1] - BC[i][0]) * arr[BC[i][0]])
  t = arr[BC[i][0]]
  arr[BC[i][1]] += t
  arr[BC[i][0]] = 0
  puts sum
end

Measured memory_bytes: 23108
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

bool f(int x) {
    int keta = 0;
    while (x) {
        keta++;
        x /= 10;
    }
    return keta%2 == 1;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        if (f(i)) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string.h>
using namespace std;
int main(void){
    // Your code here!
    char s[1003];
    
    scanf("%s",s);
    
    int n;
    n = strlen(s);
    //printf("%d\n",n);
    
    if(s[n-1]=='s')
    {
        //s[n] = 'e';
        //s[n+1] = 's';
        strcat(s,"es");
        printf("%s\n",s);
    }
    else
    {
        //s[n] = 's';
        //s[n+1] = 0;
        strcat(s,"s");
        printf("%s\n",s);
    }
}


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

int main() {
  int N;
  int a = 1;
  unsigned long int b = 1;

  cin >> N;

  for(int i = 0; i < N; ++i) {
    b = (b * a) % 1000000007;
    ++a;
  }
  
  cout << b << endl;
}

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

struct node{
  int cost;
  int now;
  bool tick;
  node(int c,int n,bool t):cost(c),now(n),tick(t){};
  bool operator >(const node &e)const{
    return cost>e.cost;
  }
};

int main()
{
  int n,m;
  for(;cin>>n>>m,m;)
    {
      int edge[n][n];
      bool dp[2][n];
      memset(edge,-1,sizeof(edge));
      memset(dp,false,sizeof(dp));
      for(int i=0;i<m;i++)
	{
	  int a,b,c;
	  cin>>a>>b>>c;
	  a--;b--;
	  edge[a][b]=c;
	  edge[b][a]=c;
	}
      priority_queue<node,vector<node>,greater<node> >qu;
      qu.push(node(0,0,true));
      int ans=-1;
      while(!qu.empty())
	{
	  node tmp = qu.top();
	  qu.pop();
	  if(tmp.now==n-1)
	    {
	      ans=tmp.cost;
	      break;
	    }
	  if(tmp.tick)
	    {
	      if(dp[0][tmp.now])
		continue;
	      dp[0][tmp.now]=true;
	    }
	  else
	    {
	      if(dp[1][tmp.now])
		continue;
	      dp[1][tmp.now]=true;
	    }

	  if(tmp.tick)
	    {
	      for(int i=0;i<n;i++)
		{
		  if(edge[tmp.now][i]!=-1)
		    {
		      for(int j=0;j<n;j++)
			{
			  if(edge[i][j]!=-1 && !dp[1][j])
			    qu.push(node(tmp.cost,j,false));
			}
		    }
		}
	    }
	  for(int j=0;j<n;j++)
	    {
	      if(edge[tmp.now][j]!=-1)
		{
		  if(tmp.tick && !dp[0][j])
		    qu.push(node(tmp.cost+edge[tmp.now][j],j,true));
		  else if(!tmp.tick && !dp[1][j])
		    qu.push(node(tmp.cost+edge[tmp.now][j],j,false));
		}
	    }
	  
	}
      if(ans==-1)
	cout<<"NA"<<endl;
      else
	cout<<ans<<endl;
    }
}

Measured memory_bytes: 1248
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main()
    {
        string[] arr = Console.ReadLine().Split(' ');
        int N = int.Parse(arr[0]);
        int M = int.Parse(arr[1]);
        //if (N < M)
        {
            Console.WriteLine(N == M ? "Yes" : "No");
        }

    }
}

Measured memory_bytes: 11092
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
using namespace std;
typedef long long ll;
int mod(ll a){return a%1000000007;};
typedef pair<int,int> i_i;



int main(){
    int h,w,n;cin>>h>>w>>n;
    int a[n+1];for(int i=1;i<=n;i++)cin>>a[i];
    int map[h][w];
    int num=1;
    for(int i=0;i<=h-1;i++){
        if(i%2==0){
            for(int j=0;j<=w-1;j++){
                if(a[num]>0){
                    map[i][j]=num;
                    a[num]--;
                }else{
                    num++;
                    map[i][j]=num;
                    a[num]--;
                }
            }
        }else{
            for(int j=w-1;j>=0;j--){
                if(a[num]>0){
                    map[i][j]=num;
                    a[num]--;
                }else{
                    num++;
                    map[i][j]=num;
                    a[num]--;
                }
            }
        }
    }
    
    for(int i=0;i<=h-1;i++){
        for(int j=0;j<=w-1;j++){
            if(j!=w-1){
                cout<<map[i][j]<<" ";
            }else{
                cout<<map[i][j]<<endl;
            }
        }
    }
    
    return 0;
}


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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

int main()
{
    int x, a, b;
    cin >> x >> a >> b;

    cout << (b <= a ? "delicious" : b <= x + a ? "safe" : "dangerous") << '\n';

    return 0;
}


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

using namespace std;

int main() {

    int e;

    while(cin >> e, e) {

        int x, y, z, m = 1 << 24;

        for(z = 0; z * z * z <= e; ++z) {
            y = floor(sqrt(e - z * z * z));
            m = min(m, (e - y * y - z * z * z) + y + z);
        }

        cout << m << endl;

    }

}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#define DIM 100007
#define INF 1000000007
using namespace std;

long long n,a[DIM],b[DIM],c[DIM],d[DIM][3];

int main()
{
    cin>>n;
    for(int i = 1; i <= n; ++i)
        cin>>a[i]>>b[i]>>c[i];

    for(int i = 1; i <= n; ++i)
    {
        d[i][0] = max(d[i-1][1],d[i-1][2]) + a[i];
        d[i][1] = max(d[i-1][0],d[i-1][2]) + b[i];
        d[i][2] = max(d[i-1][0],d[i-1][1]) + c[i];
    }

    cout<<max(d[n][0],max(d[n][1],d[n][2]));
    return 0;
}


Measured memory_bytes: 4992
ARG_N = gets.to_i
ARG_P = gets.split.map(&:to_i)
ARG_Q = gets.split.map(&:to_i)

deta = []
p_list = ARG_P.map do |x|
  r = x - deta.find_all{|k| k < x }.count
  deta.push(x)
  r
end
deta = []
q_list = ARG_Q.map do |x|
  r = x - deta.find_all{|k| k < x }.count
  deta.push(x)
  r
end
result = 0

def kaijo x
  result = 1
  while(x > 1) do
    result *= x
    x -= 1
  end
  result
end

ARG_N.times do |i|
  result += (p_list[i] - q_list[i]) * kaijo(ARG_N-(i+1))
end
puts result.abs

Measured memory_bytes: 1788
/*** 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[55];
vector<ll> vertex[25];
map<lpair, ll> mp;
ll now = 0;
bool dfs(ll cur, ll par, ll dst){
    bool flg = false;
    for(auto &e: tree[cur]){
        if(e == par) continue;
        flg |= dfs(e, cur, dst);
    }
    if(cur == dst){
        flg = true;
    }
    if(flg){
        if(par != -1) vertex[now].push_back(mp[{cur, par}]);
    }
    return flg;

}

ll power(ll x, ll n){
    if(n == 0) return 1LL;
    ll res = power(x * x, n/2);
    if(n % 2 == 1) res = res * x;
    return res;
}

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

    rep(i,0,N-1){
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
        tree[a[i]].push_back(b[i]);
        tree[b[i]].push_back(a[i]);
        mp[{a[i], b[i]}] = i;
        mp[{b[i], a[i]}] = i;
    }
    ll M;
    cin >> M;
    ll u[25], v[25];
    rep(i,0,M){
        cin >> u[i] >> v[i];
        u[i]--; v[i]--;
    }
    rep(i,0,M){
        bool res = dfs(u[i], -1, v[i]);
        now++;
    }
    ll ans = 0;
    rep(bit,1,(1LL<<M)){
        bool check[55] = {};
        rep(i,0,M){
            if((bit>>i) & 1){
                for(auto &e: vertex[i]){
                    check[e] = true;
                }
            }
        }
        ll cnt = 0;
        rep(i,0,N){
            if(check[i]) cnt++;
        }
        ll res = power(2, N-1-cnt);
        ll tt = __builtin_popcount(bit);
        if(tt % 2 == 1){
            ans += res;
        }else{
            ans -= res;
        }
    }
    ans = power(2, N-1) - ans;
    print(ans);

    

}

Measured memory_bytes: 256
// chrono::system_clock::now().time_since_epoch().count()
#include<bits/stdc++.h>

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << " = " << x << endl;

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef complex<double> cd;

const int P = 200003;
const int G = 2;
const double PI = acos(-1.0);

int addMod(int a, int b, int m) {
  a += b;
  
  if (m <= a) {
    a -= m;
  }
  
  return a;
}

int mulMod(int a, int b, int m) {
  return a * 1ll * b % m;
}

int binPow(int a, int b, int m) {
  int ret = 1;
  
  while (b > 0) {
    if (b & 1) {
      ret = mulMod(ret, a, m);
    }
    
    a = mulMod(a, a, m);
    b >>= 1;
  }
  
  return ret;
}

int n, arr[P], mem[P];
ll cnt[P], cnt2[2 * P];
cd tmp[3 * P];
int pw[2 * P];

ll f(ll x) {
  return x * (x - 1) / 2;
}

void fft(cd p[], int n, bool invert) {
  int k = 0;
  
  while ((1 << k) < n) {
    ++k;
  }
  
  assert((1 << k) == n);
  
  for (int i = 0; i < n; ++i) {
    int i2 = 0;
    
    for (int j = 0; j < k; ++j) {
      if ((i >> j) & 1) {
        i2 += (1 << (k - j - 1));
      }
    }
    
    if (i2 < i) {
      swap(p[i], p[i2]);
    }
  }
  
  for (int len = 2; len <= n; len <<= 1) {
    double ang = 2 * PI / len * (invert ? -1 : 1);
    cd wlen(cos(ang), sin(ang));
    
    for (int i = 0; i < n; i += len) {
      cd w(1);
      
      for (int j = 0; j < len / 2; ++j) {
        cd u = p[i + j], v = p[i + j + len / 2] * w;
        p[i + j] = u + v;
        p[i + j + len / 2] = u - v;
        w *= wlen;
      }
    }
  }
  
  if (invert) {
    for (int i = 0; i < n; ++i) {
      p[i] /= n;
    }
  }
}

void solve() {
  scanf("%d", &n);
  
  for (int i = 1, j = 0; i <= n; ++i) {
    int x;
    scanf("%d", &x);
    
    if (x) {
      arr[++j] = x;
    }
  }
  
  while (n > 0 && arr[n] == 0) {
    --n;
  }
  
  fill(mem, mem + P, -1);
  
  for (int i = 0, cur = 1; i < 2 * P; ++i) {
    if (mem[cur] == -1) {
      mem[cur] = i;
    }
    
    pw[i] = cur;
    cur = mulMod(cur, G, P);
  }
  
  for (int i = 1; i <= n; ++i) {
    ++cnt[mem[arr[i]]];
  }
  
  for (int i = 0; i < P; ++i) {
    tmp[i] = cd(cnt[i]);
  }
  
  int m = P;
  
  while (m & (m - 1)) {
    ++m;
  }
  
  m += m;
  fft(tmp, m, false);
  
  for (int i = 0; i < m; ++i) {
    tmp[i] *= tmp[i];
  }
  
  fft(tmp, m, true);
  
  for (int i = 0; i < 2 * P; ++i) {
    cnt2[i] = (ll)(tmp[i].real() + 0.5);
  }
  
  ll ans = 0;
  
  for (int i = 0; i < 2 * P; ++i) {
    ll cur = cnt2[i];
    
    if (i % 2 == 0) {
      cur -= cnt[i / 2] * cnt[i / 2];
      cur /= 2;
      cur += f(cnt[i / 2]);
    }
    else {
      cur /= 2;
    }

    ans += cur * 1ll * pw[i];
  }
  
  printf("%lld\n", ans);
}

int main() {
  int tt = 1;
  
  while (tt--) {
    solve();
  }

  return 0;
}




Measured memory_bytes: 20044
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        string[] line = Console.ReadLine().Trim().Split(' ');
        var d = int.Parse(line[0]);
        var x = int.Parse(line[1]);
        var ctotal = 0;
        for (int i = 0; i < n; i++)
        {
            var count = 1; var cc = 1;
            var a = int.Parse(Console.ReadLine().Trim());
            while (true)
            {
                if (cc < d  && cc + a <= d) { count++; cc += a; }
                else break;
            }
            ctotal += count;
        }
        Console.WriteLine(ctotal + x);
    }
}


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

using namespace std;

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

#define mp make_pair

const int p = 1000000007;


int mul(int a, int b) {
    return (1LL * a * b) % p;
}

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

int sub(int a, int b) {
    int s = (a+p-b);
    if (s>=p) s-=p;
    return s;
}

int po(int a, int deg)
{
    if (deg==0) return 1;
    if (deg%2==1) return mul(a, po(a, deg-1));
    int t = po(a, deg/2);
    return mul(t, t);
}

int inv(int n)
{
    return po(n, p-2);
}


mt19937 rnd(time(0));

/*struct DSU {
    vector<int> sz;
    vector<int> parent;

    int maxx = 1;

    void make_set(int v) {
        parent[v] = v;
        sz[v] = 1;
    }

    int find_set(int v) {
        if (v == parent[v])
            return v;
        return parent[v] = find_set(parent[v]);
    }

    void union_sets(int a, int b) {
        a = find_set(a);
        b = find_set(b);
        if (a != b) {
            if (sz[a] < sz[b])
                swap(a, b);
            parent[b] = a;
            sz[a] += sz[b];
        }
        maxx = max(maxx, sz[a]);
    }

    DSU(int n) {
        sz.resize(n);
        parent.resize(n);
        for (int i = 0; i < n; i++) make_set(i);
    };
};*/

/*
const int N = 1200000;

vector<int> facs(N), invfacs(N);

void init()
{
    facs[0] = 1;
    for (int i = 1; i<N; i++) facs[i] = mul(facs[i-1], i);
    invfacs[N-1] = inv(facs[N-1]);
    for (int i = N-2; i>=0; i--) invfacs[i] = mul(invfacs[i+1], i+1);
}

int C(int n, int k)
{
    if (n<k) return 0;
    return mul(facs[n], mul(invfacs[k], invfacs[n-k]));
}*/

string nxt(string s, char c)
{
    //cout<<s<<endl;
    int n = s.size();
    string res;
    for (int i = 0; i<n-1; i++)
    {
        if (s[i]==c||s[i+1]==c) res+=c; else res+=s[i];
    }
    return res;
}

bool check(string s)
{
    int n = s.size();
    bool check = true;
    for (int i = 0; i<n-1; i++) if (s[i]!=s[i+1]) check = false;
    return check;
}

int solve(string s, char c)
{
    int cnt = 0;
    while (!check(s))
    {
        cnt++; s = nxt(s, c);
    }
    return cnt;
}


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


    string s;
    cin>>s;
    int res = 1000;
    for (char c = 'a'; c<='z'; c++) res = min(res, solve(s, c));
    cout<<res<<endl;

    //cout<<solve(s, 'v');





}

Measured memory_bytes: 256
int main(){
   int n, x;
   int Y, i, j, k;
 
   while(1){
     scanf("%d %d", &n, &x);
     if(n == 0 && x == 0){
        break;
     }
     Y = 0;
 
     for(i = 1; i < n-1; i++){
        for(j = i+1; j < n; j++){
           for(k = j+1; k < n+1; k++){
              if(i+j+k == x)
                 Y = Y+1;
           }
        }
     }
     printf("%d\n", Y);
  }
  return 0;
}

Measured memory_bytes: 1812
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

pair<pair<int,int>, pair<int, int>> E[200001];
int H[100001];
int P[100001][20];
int D[100001], RD[100001];

int oya(int A, int B) {
	if (B == 0) return A;
	int k = 31 - __builtin_clz(B);
	return oya(P[A][k], B - (1 << k));
}
void dfs(int A, int B, int C, int d) {
	RD[A] = B;
	D[A] = d;
	P[A][0] = C;
	int mae = C;
	rep(i, 19) {
		P[A][i + 1] = P[mae][i];
		mae = P[A][i + 1];
	}
	for (int i = H[A]; i; i = E[i].first.second) {
		if (E[i].first.first != C) dfs(E[i].first.first, B + E[i].second.first, A, d + 1);
	}
}

pair<int, int> QE[300001];
int QH[100001];
int CD[100001], CN[100001];
void dfs2(int A, int C) {
	int tmp;
	for (int i = QH[A]; i; i = tmp) {
		tmp = QE[i].second;
		QE[i].second = CN[QE[i].first];
		QE[i].first = CD[QE[i].first];
	}
	for (int i = H[A]; i; i = E[i].first.second) {
		if (E[i].first.first != C) {
			CD[E[i].second.second] += E[i].second.first;
			CN[E[i].second.second]++;
			dfs2(E[i].first.first, A);
			CD[E[i].second.second] -= E[i].second.first;
			CN[E[i].second.second]--;
		}
	}
}


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

	
	int N, Q;
	cin >> N >> Q;
	for (int i = 1; i < N + N - 1; i++) {
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		E[i] = mp(mp(b, H[a]), mp(d, c));
		H[a] = i++;
		E[i] = mp(mp(a, H[b]), mp(d, c));
		H[b] = i;
	}

	dfs(1, 0, 0, 0);

	int motoD[100000], y[100000];
	rep(i, Q) {
		int x, u, v;
		cin >> x >> y[i] >> u >> v;

		if (D[u] > D[v]) swap(u, v);
		int sa = D[v] - D[u];

		int L = 0;
		int R = D[u];
		while (L < R) {
			int half = (L + R) / 2;
			if (oya(u, half) == oya(v, sa + half)) R = half;
			else L = half + 1;
		}
		int o = oya(u, L);
		motoD[i] = RD[u] + RD[v] - RD[o] * 2;
		QE[i * 3 + 1] = mp(x, QH[u]);
		QH[u] = i * 3 + 1;
		QE[i * 3 + 2] = mp(x, QH[v]);
		QH[v] = i * 3 + 2;
		QE[i * 3 + 3] = mp(x, QH[o]);
		QH[o] = i * 3 + 3;
	}

	dfs2(1, 0);

	rep(i, Q) {
		motoD[i] -= QE[i * 3 + 1].first + QE[i * 3 + 2].first - 2 * QE[i * 3 + 3].first;
		motoD[i] += (QE[i * 3 + 1].second + QE[i * 3 + 2].second - 2 * QE[i * 3 + 3].second) * y[i];
		co(motoD[i]);
	}

	Would you please return 0;
}

Measured memory_bytes: 20864
number_of_word= int(input())
repeat_lenth=int(number_of_word/2)
tmp_word= input()

if (number_of_word % 2) == 0:

  if tmp_word[:repeat_lenth] == tmp_word[repeat_lenth:]:
    print ('Yes')
  else:
    print ('No')
else:
  print ('No')

Measured memory_bytes: 2940
import math
MOD = 10 ** 9 + 7

X, Y = map(int, input().split())

if (X + Y) % 3 != 0:
    print (0)
    exit()

x = X - (X + Y) // 3
y = Y - (X + Y) // 3

if x < 0 or y < 0:
    print (0)
    exit()

if x < y:
    x, y = y, x

# tmp = math.factorial(y)
tmp = 1
for i in range(1, y + 1):
    tmp *= i
    tmp %= MOD

ans = 1
for i in range(x + 1, x + y + 1):
    ans *= i
    ans %= MOD

def modinv(a, m): #mod. m でのaの逆元 a^{-1}を計算する
    b = m
    u = 1
    v = 0
    while b:
        t = a//b
        a -= t * b
        a, b = b, a
        u -= t * v
        u, v = v, u
    
    u %= m
    if u < 0:
        u += m
    return u

tmp = modinv(tmp, MOD)

ans *= tmp

ans %= MOD

print (ans)

# print (x, y)

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF ((long long)1e18)
#define MOD ((int)1e9+7)
#define endl "\n"

#define yn(f) ((f)?"Yes":"No")
#define YN(f) ((f)?"YES":"NO")

#define MAX_N 5100

int par[MAX_N];
int myrank[MAX_N];
int min_[MAX_N];
int used[MAX_N];

void init(int n){
	for(int i = 0; i < n; i++){
		par[i] = i;
		myrank[i] = 1;
		min_[i] = INF;
	}
}

int find(int x){
	if(par[x] == x){
		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;
	
	if(myrank[x] < myrank[y]){
		par[x] = y;
		myrank[y] += myrank[x]; 
	} else {
		par[y] = x;
		myrank[x] += myrank[y]; 
		// if(myrank[x] == myrank[y]) myrank[x]++;
	}
}

signed main(){
	// cin.tie(0);
	// ios::sync_with_stdio(false);
	// cout<<fixed<<setprecision(10);
	
	int N, M;
	
	vector<pair<string,int>> x;
	string s, t;
	int ans = 0;
	
	cin>>N;
	
	init(N+10);
	x.resize(N);
	
	for(int i = 0; i < N; i++){
		cin>>x[i].first>>x[i].second;
	}
	
	sort(x.begin(), x.end());
	
	cin>>M;
	
	for(int i = 0; i < M; i++){
		cin>>s>>t;
		pair<string,int> a, b;
		a = make_pair(s,-1ll);
		b = make_pair(t,-1ll);
		int c = lower_bound(x.begin(), x.end(),a) - x.begin();
		int d = lower_bound(x.begin(), x.end(), b) - x.begin();
		unite(c,d);
	}
	for(int i = 0; i < N; i++){
		// cout<<i<<" "<<find(i)<<" "<<myrank[i]<<endl;
		min_[find(i)] = min(x[i].second,min_[find(i)]);
	}
	for(int i = 0; i < N; i++){
		if(used[find(i)]) continue;
		used[find(i)] = true;
		ans += min_[find(i)]*myrank[find(i)];
	}
	
	cout<<ans<<endl;
	return 0;
}


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

#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define endl '\n'

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, int> pdi;

const ll INF = 1e18;
const int MAXN = 3e5 + 5;



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

	int N; cin >> N;
	int ans = 0;
	while(N) {
		if(N%10 == 7) ans = 1;
		N /= 10;
	}
	if(ans) cout << "Yes";
	else cout << "No";

}

Measured memory_bytes: 3636
def partition(A, p, r):
    x = A[r]
    i = p-1
    for j in range(p, r):
        if A[j] <= x:
            i += 1
            memo = A[i]
            A[i] = A[j]
            A[j] = memo
    memo = A[i+1]
    A[i+1] = x
    A[r] = memo
    return i+1, A

n = int(input())
a = list(map(int, input().split()))

index, aList = partition(a, 0, len(a)-1)
aList[index] = "[" + str(aList[index]) + "]"

print(*aList)


Measured memory_bytes: 16384
import sys,collections as cl,bisect as bs,math,heapq as hq
sys.setrecursionlimit(100000)
Max = sys.maxsize
def l(): #intのlist
	return list(map(int,input().split()))
def m(): #複数文字
	return map(int,input().split())
def onem(): #Nとかの取得
	return int(input())
def s(x): #圧縮
	a = []
	aa = x[0]
	su = 1
	for i in range(len(x)-1):
		if aa == x[i+1]:
			a.append([aa,su])
			aa = x[i+1]
			su = 1
		else:
			su += 1
	a.append([aa,su])
	return a
def jo(x): #listをスペースごとに分ける
	return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
	return max(map(max,x))

def LIS(L):
  L = L[::-1]
  LIS=[]
  for i in L:
    pos = bs.bisect_right(LIS,i) 
    if len(LIS) <= pos:
      LIS.append(i)
    else:
      LIS[pos]=i
  return len(LIS)

n = onem()

a = []
c = 0
for i in range(n):
	a.append(onem())


print(LIS(a))


Measured memory_bytes: 56280
X=int(input())
J=1000
N=[0]*J
for i in range(0,J):
    N[i]=i**5
for i in range(0,J):
    for j in range(0,J):
        if abs(N[i]-N[j])==X:
            print(int(max(N[i],N[j])**(1/5)),int(min(N[i],N[j])**(1/5)))
            exit()
        elif N[i]+N[j]==X:
            print(int(N[i]**(1/5)),int(-1*N[j]**(1/5)))
            exit()


Measured memory_bytes: 9384
#include <stdio.h>
int main(void)
{
    long int n;
    scanf("%ld\n",&n);
    long int p[200005]={};
    long int place[200005]={};
    for(int q=0;q<n;q++)
    {
        scanf("%ld\n",&p[q]);
        p[q]-=1;
        place[p[q]]=q;
    }
    long int leng=0;
    long int maxleng=0;
    long int keep=-1;
    long int poi=0;
    while(poi<n)
    {
        if(keep<place[poi])
        {
            keep=place[poi];
            leng++;
            //printf("##%ld,place:%ld##\n",poi,place[poi]);
        }
        else
        {
            if(maxleng<leng)maxleng=leng;
            leng=1;
            keep=place[poi];
            //printf("$$%ld,place:%ld$$\n",poi,place[poi]);
        }
        
        poi++;
    }
    if(maxleng<leng)maxleng=leng;
    printf("%ld\n",n-maxleng);
    return 0;
}


Measured memory_bytes: 3328
def find(x):
    if x == T[x]:
        return x
    T[x] = find(T[x])
    return T[x]

def mergeT(x, y):
    a = find(x)
    b = find(y)
    if a != b:
        if NumTable[a] > NumTable[b]:
            T[b] = a
            NumTable[a] += NumTable[b]
        else:
            T[a] = b
            NumTable[b] += NumTable[a]

N, M = list(map(int, input().split()))
edge = [list(map(int, input().split())) for i in range(M)]
edge.reverse()

T = [i for i in range(N+1)]
NumTable = [1 for i in range(N+1)]

L = []
ans = N * (N-1) //2
for i in edge:
    L.append(ans)
    a = find(i[0])
    b = find(i[1])
    if a != b:
        ta = NumTable[a]
        tb = NumTable[b]
        mergeT(a, b)
        ans -= ta * tb
        mergeT(a, b)

for i in reversed(L):
    print(i)
    




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

#define ll long long
#define repeat(i, x) for (register ll i = 0; i < x; i++)

class DisjointSet
{
public:
  vector<int> parent;

  DisjointSet(int n) : parent(n)
  {
    for (int i = 0; i < n; i++)
      parent[i] = i;
  }

  void join(int a, int b)
  {
    parent[findSet(b)] = findSet(a);
  }

  int findSet(int a)
  {
    return a == parent[a] ? a : parent[a] = findSet(parent[a]);
  }

  bool same(int a, int b)
  {
    return findSet(a) == findSet(b);
  }
};

int main(void)
{
  int N, M;

  cin >> N >> M;
  int result = N - 1;

  DisjointSet disjointSet(N);

  for (int i = 0; i < M; i++)
  {
    int A, B;
    cin >> A >> B;
    A--;
    B--;

    if (!disjointSet.same(A, B))
    {
      disjointSet.join(A, B);
      result--;
    }
  }

  cout << result << endl;

  return 0;
}

Measured memory_bytes: 3768
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int v[] = new int[n];
        int c[] = new int[n];
        int ans = 0;
        for(int i = 0;i<n;i++){
            v[i] = Integer.parseInt(sc.next());
        }
        for(int i = 0;i<n;i++){
            c[i] = Integer.parseInt(sc.next());
        }
        for(int i = 0;i<n;i++){
            int diff = v[i] - c[i];
            if(diff > 0){
                ans += diff;
            }
        }
        System.out.println(ans);
    }
}

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

		UnionFindTree uft = new UnionFindTree(n);
		for(int i = 0; i < m; i++) {
			uft.union(sc.nextInt()-1, sc.nextInt()-1);
		}

		int cnt = 0;
		for(int i = 0; i < n; i++) {
			if(uft.same(i, p[i]-1) == true)
				cnt++;
		}

		System.out.println(cnt);
	}
}

class UnionFindTree {

	int[] parent; //インデックスにとノードを対応させ、そのルートノードのインデックスを格納
	int[] rank; //parentと同様に、木の高さを格納

	public UnionFindTree(int size) {
		this.parent = new int[size];
		this.rank = new int[size];

		for (int i = 0; i < size; i++) {
			makeSet(i);
		}
	}

	public void makeSet(int i) {
		parent[i] = i;
		rank[i] = 0; //集合の高さ
	}

	public void union(int x, int y) {
		int xRoot = find(x);
		int yRoot = find(y);

		//xが属する木の方が大きい場合
		if (rank[xRoot] > rank[yRoot]) {
			parent[yRoot] = xRoot; //yの親をxに更新

		} else if(rank[xRoot] < rank[yRoot]) {
			parent[xRoot] = yRoot;

		} else if (xRoot != yRoot){
			parent[yRoot] = xRoot;
			rank[xRoot]++; //同じ高さの木がルートの子として着くから大きさ++;
		}
	}

	//引数の属する木のルートのidを返す
	public int find(int i) {
		if (i != parent[i]) {
			parent[i] = find(parent[i]);
		}
		return parent[i];
	}

	//同じ木に属しているか
	public boolean same(int x, int y) {
		return find(x) == find(y);
	}
}

Measured memory_bytes: 90668
#include <bits/stdc++.h>
using namespace std;
#define x_ real()
#define y_ imag()
#define cross(a, b) (conj(a)*(b)).imag()
#define dot(a, b) (conj(a)*(b)).real()
#define PI acos(-1)
#define F first
#define S second
#define fastIO ios_base::sync_with_stdio(false), cin.tie(NULL)
#define fileIO freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef complex<ld> point;
typedef tuple<int, int, int> line;
typedef vector<point> polygon;
typedef pair<double, double> pd;
pair<int, int> dirs[] = { {1, 2}, {-1, 2}, {2, 1}, {2, -1}, {-2, 1}, {-2, -1}, {1, -2}, {-1, -2} };



int main() {
	fastIO;
	string s;
	cin >> s;
	cout << string(s.size(), 'x');


}


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


int main(){
    string s;cin>>s;
    if(s=="hi"||s=="hihi"||s=="hihihi"||s=="hihihihi"||s=="hihihihihi")cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

    









Measured memory_bytes: 256
/** 
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

#include <bits/stdc++.h>
using namespace std;

#define DEBUG
#ifndef DEBUG
#define endl "\n"
#endif

const double PI=3.1415926535897932384626433;
typedef long long ll;
#define fori(n) for(ll i=0; i<(n); i++)

#define cins(s) string s; cin>>s;
#define cini(i) int i; cin>>i;
#define cinll(l) ll l; cin>>l;
#define cind(d) double d; cin>>d;
#define cinai(a, n) vi a(n); fori(n) { cin>>a[i]; }
#define cinall(a, n) vll a(n); fori(n) { cin>>a[i]; }
#define cinas(s, n) vs s(n); fori(n) { cin>>s[i]; }

typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<vll> vvll;

template<typename T>
void floyd_warshal(vector<vector<T>> &d, int n) {
    for (int k = 0; k < n; ++k) {
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < n; ++j) {
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
}

int main() {
cin.tie(nullptr);
std::ios::sync_with_stdio(false);
    cini(N);    // Towns
    cini(M);    // Roads
    cinll(L);    // Tank size

    const ll INF=1e18;
    vvll fw(N, vll(N, INF));
    for(int i=0; i<N; i++)
        fw[i][i]=0;

    for(int i=0; i<M; i++) {
        cini(a);    
        cini(b);
        cini(c);
        if(c<=L) {
            a--;
            b--;
            fw[a][b]=c;
            fw[b][a]=c;
        }
    }

    floyd_warshal(fw, N);

    for(int i=0; i<N; i++)
        for(int j=0; j<N; j++)
            if(fw[i][j]<=L)
                fw[i][j]=1;
            else
                fw[i][j]=INF;
        
    floyd_warshal(fw, N);

    cini(Q);
    for(int i=0; i<Q; i++) {
        cini(s);
        cini(t);
        s--;
        t--;
        ll ans=fw[s][t];
        if(ans>N)
            cout<<-1<<endl;
        else
            cout<<ans-1<<endl;
    }

}



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

const ll inf = 1e18L + 5;

void max_self(int& a, int b ){
    a = max(a, b);
}

double solve( vector<double> &arr, int limit, int ind, vector<vector<double> > &memo ) {
    if( ind == arr.size() )
        return 1.0;

    if( memo[ind][limit] != (double)(-1) ) 
        return memo[ind][limit];

    double ret1 = arr[ind] * solve(arr, limit, ind + 1, memo);
    double ret2 = 0.0;
    if( limit > 1 )
        ret2 = ((double)1 - arr[ind]) * solve(arr, limit - 1, ind + 1, memo);

    return memo[ind][limit] = ret1 + ret2;
}

int main() {
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif

    int N;
    cin>>N;
    vector<double> arr(N, 0);
    
    for( int i = 0; i < N; i++) {
        cin>>arr[i];
    }

    int limit = N % 2 == 1 ? N/2 + 1 : N/2;
    
    vector<vector<double> > memo(N, vector<double>(limit+1, (double)(-1)));
    std::cout << std::setprecision(9) << std::fixed;
    double result = solve(arr, limit, 0, memo);
    cout<<result<<endl;
    return 0;
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

int main() {
  int k;
  cin >> k;
  int a, b;
  cin >> a >> b;
  rep(i, 1000) {
    if (a <= i * k && i * k <= b) {
      cout << "OK" << endl;
      return 0;
    }
  }
  cout << "NG" << endl;
}


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

int64_t keta(int64_t n){
  int64_t res=0;
  if(n==0) return 0;
  while(n>0){
    ++res;
    n -= n%10;
    n /= 10;
  }
  return res;
}

int main(){
  int N;
  cin>>N;
 
  //a[i][j]はN以下の末尾i+1先頭j+1の数の総数
  vector<vector<int64_t>> a(9,vector<int64_t>(9));

  for(int i=0;i<9;++i){
    for(int j=0;j<9;++j){
      for(int k=1;k<=N;++k){
      if(k%10==i+1 && k/int(pow(10,keta(k)-1))==j+1) ++a[i][j];
      }
    }
  }

  int64_t sum=0;
  for(int i=0;i<9;++i){
    for(int j=0;j<9;++j){
      sum += a[i][j]*a[j][i];
    }
  }

  cout<<sum<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long int MOD = 1000000007;
const long long  INF = 1LL << 60;

int main(void){
    int N, M; cin >> N >> M;
    vector<int> danger(100005, 0); 
    for(int i = 0; i < M; i++){
        int index;
        cin >> index;
        danger[index] = 1;
    }
    
    vector<ll> dp(N+10, 0);
    dp[0] = 1;
    for(int i = 0; i < N; i++){
        if (danger[i]){
            dp[i] = 0;
            continue;
        }
        dp[i+1] = (dp[i+1] + dp[i]) % MOD;
        dp[i+2] = (dp[i+2] + dp[i]) % MOD;
    }
    cout << dp[N] << endl;
}


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


int main(){
  int n;
  cin>>n;
  vector<int> a(n+2,0);
  
  for(int i=1;i<=n;i++){
    cin>>a[i];
  }

  ll total=0;
  for(int i=1;i<(int)a.size();i++){
    total+=abs(a[i]-a[i-1]);
  }

  for(int i=1;i<=n;i++){
    ll tmp=total;
    tmp-=abs(a[i-1]-a[i]);
    tmp-=abs(a[i]-a[i+1]);
    tmp+=abs(a[i-1]-a[i+1]);
    cout<<tmp<<endl;
  }

  return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define _rep(i,m,n) for(long long int i = m; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main(){
   string n; cin >> n;
   if(n[0] == '7' || n[1] == '7' || n[2] == '7')cout << "Yes" << endl;
   else cout << "No" << endl; 

}

Measured memory_bytes: 3624
! 2019.10.27
!
      program answer
      implicit none
      integer :: A
      integer :: B
      integer :: ans
!
      read(*,*) A,B
!
      ans = A * B
      if(A > 9 .or. B > 9) then
        ans = -1
      end if
      write(*,*) ans
      end program answer

Measured memory_bytes: 768
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ALDS1_6_D
{
    class Program
    {
        static private int[] inputArray;

        static void Main(string[] args)
        {
            Console.ReadLine();

            inputArray = Console.ReadLine()
                                .Split(' ')
                                .Select(s => int.Parse(s))
                                .ToArray();

            int i = -1;

            for (int j = 0; j < Program.inputArray.Length - 1; j++)
            {
                if (inputArray[j] <= inputArray[inputArray.Length - 1])
                {
                    i++;
                    int tmp = inputArray[i];
                    inputArray[i] = inputArray[j];
                    inputArray[j] = tmp;
                }
            }

            int tmp2 = inputArray[i + 1];
            inputArray[i + 1] = inputArray[inputArray.Length - 1];
            inputArray[inputArray.Length - 1] = tmp2;

            inputArray.Take(i + 1)
                      .ToList()
                      .ForEach(h => Console.Write(string.Format("{0}{1}", h, " ")));

            Console.Write(string.Format("[{0}]", inputArray[i + 1]));

            inputArray.Skip(i + 2)
                      .ToList()
                      .ForEach(k => Console.Write(string.Format("{0}{1}", " ", k)));
            Console.WriteLine();
        }
    }
}



Measured memory_bytes: 28844
A = int(input())
B = int(input())
C = int(input())
X = int(input())

count = 0
for i in range(A+1) :
    for j in range(B+1) :
        for k in range(C+1) :
            if X == 500*i + 100*j + 50*k :
                count += 1

print(count)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long lli;
typedef long double lld;
#define mod 1000000007
#define mod2 998244353
#define fori(n) for (int i = 0; i < n; i++)
#define forj(n) for (int j = 0; j < n; j++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define endl "\n"
#define sortvec(a) sort(a.begin(), a.end())

void print(){cout<<endl;}
template<typename T,typename... Args>
void print(T a, Args... args) {cout<<a<<" ";print(args...);}
lli llipowerp(lli x, lli y, lli p)
{
    lli res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1) res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
lli binarySearch(vector<int> arr, int l, int r, int x)
{
    if (r >= l)
    {
        lli mid = l + (r - l) / 2;
        if (arr[mid] == x)
            return mid;
        if (arr[mid] > x)
            return binarySearch(arr, l, mid - 1, x);
        return binarySearch(arr, mid + 1, r, x);
    }
    return -1;
}
template <typename T>
inline void printvec(vector<T> inp){
    for(auto it:inp) cout<<it<<" ";
    cout << endl;
}
//---------------------------------------------------------------------------------


int main(){

    int n;
    cin>>n;
    set<string> inp;
    string x;
    fori(n){
        cin>>x;
        inp.insert(x);
    }
    cout<<inp.size()<<endl;
}

Measured memory_bytes: 19236
#include<bits/stdc++.h>
using namespace std;
const int N=233;
int m,n,a[N][N],b[N][N]; bool vis[N][N];
int main(){
	scanf("%d%d",&m,&n);
	int i,j,x,y;
	for (i=1; i<=m; i++)
		for (j=1; j<=n; j++) scanf("%d",&a[i][j]);
	for (i=1; i<=m; i++)
		for (j=1; j<=n; j++)
			for (x=0; x<=100; x++)
				for (y=0; y<=100; y++) b[x][y]=max(b[x][y],a[i][j]-i*x-j*y);
	for (i=1; i<=m; i++)
		for (j=1; j<=n; j++)
			for (x=0; x<=100; x++)
				for (y=0; y<=100; y++)
					if (b[x][y]==a[i][j]-i*x-j*y) vis[i][j]=1;
	for (i=1; i<=m; i++)
		for (j=1; j<=n; j++) if (!vis[i][j]){
			puts("Impossible"); return 0;
		}
	puts("Possible");
	printf("202 %d\n",200+101*101);
	for (i=1; i<=100; i++) printf("%d %d X\n",i,i+1);
	for (i=102; i<=201; i++) printf("%d %d Y\n",i+1,i);
	for (i=0; i<=100; i++)
		for (j=0; j<=100; j++) printf("%d %d %d\n",i+1,j+102,b[i][j]);
	puts("1 102");
	return 0;
}

Measured memory_bytes: 512
import sys
import numpy as np
MOD = 10 ** 9 + 7

n = int(sys.stdin.readline().rstrip())
a = np.array(sys.stdin.readline().split(), dtype=np.int64)

def main():
  x = a[:, None] >> np.arange(60) & 1
  x = x.sum(axis=0)
  y = n - x
  res = x * y  % MOD * ((1 << np.arange(60)) % MOD)
  print(res.sum() % MOD)

if __name__ == '__main__':
  main()

Measured memory_bytes: 299156
#include<bits/stdc++.h>
using namespace std;
int main()
{

    int n,k;
    cin>>n>>k;
    vector<int>v;
    vector<int>s(n+1,0);
    for(int i=0;i<n;i++)
    {
        int p;
        cin>>p;
        v.push_back(p);
    }
     s[1] = 0;
     s[2] = abs(v[1]-v[0]);

     for(int i=3;i<=n;i++)
     {
         int val = INT_MAX;
         if(i<=k)
         {
             for(int j=1;j<i;j++)
             {
                 val = min(val,(s[j]+abs(v[i-1]-v[j-1])));
             }
             s[i] = val;
         }
         else
         {
             for(int j = (i-k);j<i;j++)
             {
                  val = min(val,(s[j]+abs(v[i-1]-v[j-1])));
             }
             s[i] = val;
         }
     }

     cout<<s[n]<<endl;

    return 0;
}

Measured memory_bytes: 4292