akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int c[500001];

int main(){
  int n;
  cin>>n;
  int len=0,mx=0;
  while(n--){
    int x;
    cin>>x;
    mx=max(mx,x);
    x=min(x,(int)5e5);
    if(!c[0]&&(len<x||(len==x&&mx<=x))){
      while(++c[x]==2)c[x--]=0;
      int llen=max(len,1);
      while(c[llen])llen++;
      len=llen-1;
      cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
  }
  return 0;
}

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

int gcd(int a,int b,int c)
{
	int minv;
	if(a<b)
	  minv=a;
	else
	  minv=b;
	if(c<minv)
	  minv=c;
	while(a%minv!=0||b%minv!=0||c%minv!=0)
	{
		minv--;
	}
	
	return minv;
	
}

int main()
{
	int k,i,j,l;
	long long sum=0;
	cin>>k;
	for(i=1;i<=k;i++)
	   for(j=1;j<=k;j++)
	      for(l=1;l<=k;l++)
	          sum+=gcd(i,j,l);
	          
	cout<<sum;
	
	return 0;
	
} 

Measured memory_bytes: 3620
#include <bits/stdc++.h>
const int INF=1e9,MOD=1e9+7;
const long long LINF=1e18;
using namespace std;
#define int long long
//template
std::vector<int> dpa(1234567,0),dpb(1234567,1),memo(1234567,0);
int pw(int n,int k){
  int res=1;
  while(k){
    if(k&1)res*=n;res%=MOD;
    n*=n;n%=MOD;
    k>>=1;
  }
  return res;
}
//main
signed main(){
  int N;cin>>N;
  std::vector<int> v(N);
  for(int i=0;i<N;i++)cin>>v[i];
  int now=0,zco=0;
  for(int i=0;i<N;i++){
    now^=v[i];
    if(now==0)zco++;
    else{
      dpb[now]+=dpa[now]*(zco-memo[now]);dpb[now]%=MOD;
      dpa[now]+=dpb[now];dpa[now]%=MOD;
      memo[now]=zco;
    }
  }
  if(now)cout<<dpb[now]<<endl;
  else{
    int ans=0;
    for(int i=0;i<1234567;i++)ans+=dpa[i];
    cout<<(ans+pw(2,zco-1))%MOD<<endl;
  }
}


Measured memory_bytes: 33152
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
const long long INFLL = 1LL << 60;
const int INFINT = 1 << 30;
const long long MOD = 1e9 + 7;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<pair<int, int>> p(n);
    rep(i, n) cin >> p[i].first >> p[i].second;
    sort(p.begin(), p.end());
    rep(i, n) cout << p[i].first << " " << p[i].second << "\n";
}



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

#define deb(...) cerr << "[" << #__VA_ARGS__ << "] : [", DBG(__VA_ARGS__) 
void DBG() {
  cerr << "]\n";
}
template<typename T, typename ...Args> void DBG(T first, Args... args) {
  cerr << first; if (sizeof...(args))cerr<<", "; DBG(args...);
}

/////////////////////////// GLOBAL ///////////////////////////

/////////////////////////// GLOBAL ///////////////////////////
void solve() {
  int x, k, d;
  cin>>x>>k>>d;
  int rq = floor(abs(x)/d);

  if(x==0){
    if(k%2==0){
      cout<<x<<"\n";
    }else cout<<min(abs(x+d), abs(x-d))<<"\n";
  }else{
    if(x>0){
      if(k < rq){
        cout<<min(abs(x-k*d), abs(x+k*d))<<"\n";
      }else{
        int moves = k-floor(x/d);
        int c = x - floor(x/d)*d;
        if(moves%2 == 0) cout<<abs(c)<<"\n";
        else{
          cout<<min(abs(c+d), abs(c-d))<<"\n";
        }
        // deb(c, moves);
      }

    }else{
      if(k < rq){
        cout<<min(abs(x-k*d), abs(x+k*d))<<"\n";
      }else{
        int moves = k-floor(abs(x)/d);
        int c = x + floor(abs(x)/d)*d;
        if(moves%2 == 0) cout<<abs(c)<<"\n";
        else{
          cout<<min(abs(c+d), abs(c-d))<<"\n";
        }
        // deb(c, moves);
      }
    }
  }
}

int32_t main() {
  #ifndef ONLINE_JUDGE
  clock_t tStart = clock();
  freopen("in.txt", "r", stdin);
  //freopen("output.txt","w",stdout);
  #endif 
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int t=1;
  //cin >> t;
  for (int tt=1;tt<=t;tt++) {
    //cout << "Case #"<<tt<<": ";
    solve();
  }
  #ifndef ONLINE_JUDGE
    cerr << "\nRun Time -> "<<(double)(clock()-tStart)/CLOCKS_PER_SEC <<" sec\n";
  #endif
}


Measured memory_bytes: 3640
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque> 
#include <string>


using namespace std;

int k, x;

int main()
{
	scanf("%d%d", &k, &x);
	int l = x - k + 1;
	int r = x + k - 1;
	
	printf("%d", l);
	for (int i = l + 1 ; i <= r ; i++)
		printf(" %d", i);
		
	printf("\n");

			
	return 0;
}


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

#define SIS std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define lowbit(x) (x & -x)
#define PI 3.14159265358979323846264338327950L
typedef long long ll;
using namespace std;
const int MAX = 0x7ffffff;
const int N = 100005;
int t;
int n , m , h[N];
void slove()
{
	int a , b;
	cin >> n >> m;
	vector<int> ma(n + 1);
	for(int i = 1;i <= n;i ++)
		cin >> h[i] , ma[i] = 0;
	for(int i = 0;i < m;i ++)
	{
		cin >> a >> b;
		ma[a] = max(ma[a] , h[b]);
		ma[b] = max(ma[b] , h[a]);
	}
	int ans = 0;
	for(int i = 1;i <= n;i ++)
	{
		ans += h[i] > ma[i];
	}
	cout << ans << endl;
}
int main()
{
	SIS;
	slove();
}

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    ll N;
    cin >> N;
    map<ll,ll> A;
    REP(i,0,N) {
        ll a;
        cin >> a;
        ++A[a-1];
        ++A[a];
        ++A[a+1];
    }

    ll X = 0;
    FORR(a,A) X = MAX(a.second,X);
    PR(X);

    return 0;
}

/*



*/

Measured memory_bytes: 9536
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int a[10];
	for(int i=0;i<10;i++)
		cin>>a[i];
	sort(a,a+10);
	cout<<a[9]<<endl<<a[8]<<endl<<a[7]<<endl;
	return 0;
}

Measured memory_bytes: 1176
//Sani buyuk Osman Pasa Plevneden cikmam diyor.
//FatihSultanMehmedHan
//Abdulhamid Han
//Bismillahirrahmanirrahim

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long int lo;
typedef pair< int,int > PII;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(lo i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo MAX = -1000000000000000000;
const lo MIN = 1000000000000000000;
const lo inf = 10000000000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 500005;
const lo mod = 1000000007;

lo n,m,b,a[li],k,flag,mx=inf;
lo cev;
string s;
vector<lo> v;
void solve(){
	scanf("%lld",&n);
	FOR{
		scanf("%lld",&a[i]);
	}
	//~ cev=inf;
	for(lo j=1;j<n;j++){
		cev=0;
		lo cev1=0;
		for(lo i=1;i<=j;i++){
			cev+=a[i];
		}
		for(lo i=j+1;i<=n;i++) cev1+=a[i];
		mx=min(mx,abs(cev-cev1));
	}
	printf("%lld\n",mx);
	//~ return 0;
}
int main(void){
	solve();
}


Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    ( $($t:ty),* ) => {{
        let mut s = String::new();
        std::io::stdin().read_line(&mut s);
        let mut splits = s.trim().split_whitespace();
        ($( { splits.next().unwrap().parse::<$t>().unwrap() },)*)
    }}
}

#[allow(unused_macros)]
macro_rules! invec {
    ( $ t : ty ) => {{
        let mut s = String::new();
        match std::io::stdin().read_line(&mut s) {
            Ok(0) => Vec::<$t>::new(),
            Ok(n) => s
                .trim()
                .split_whitespace()
                .map(|s| s.parse::<$t>().unwrap())
                .collect::<Vec<$t>>(),
            Err(_) => Vec::<$t>::new(),
        }
    }};
}

#[allow(unused_must_use)]
#[allow(unused_variables)]
fn solve() {
    let (n,) = input!(usize);
    let mut a = invec!(u32);

    a.sort();

    let first = a[0] as f32;

    let ans: f32 = a.iter().fold(first, |acc, &x| (acc as f32 + x as f32) / 2.0);

    println!("{}", ans);
}

fn main() {
    solve();
}


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

using namespace std;
using ll = long long;

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

  int n, x, t;
  cin >> n >> x >> t;
  int d = n / x;
  if (n % x > 0)
    d++;
  cout << d * t << endl;

  return 0;
}


Measured memory_bytes: 3648
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;


/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

int n;
ll a[220000];

int main() {
#ifdef FASTIO
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> a[i], a[i] -= i;
	}
	sort(a, a + n);
	ll x = a[n / 2];
	ll ans = 0;
	for (int i = 0; i < n; ++i)
		ans += abs(a[i] - x);
	cout << ans << "\n";
	return 0;
}




Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int i=a; i<n; i++)
#define repr(i,a,n) for(int i=a; i>=n; i--)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long int ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

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

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

int main() {
    int n, k; cin >> n >> k;
    int a[26] = {};
    string p;
    rep(i,0,n) {
        cin >> p;
        a[ p[0] - 'A' ]++;
    }

    int ans = 0;
    bool ok = true;
    while(ok) {
        sort(a, a+26, greater<int>());
        rep(i,0,k) {
            if(a[i] <= 0) ok = false;
            else a[i]--;
        }
        if(ok) ans++;
    }

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

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <limits>
#include <boost/range/irange.hpp>
#include <boost/range/adaptors.hpp>

using namespace std;
using namespace boost;
using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long int;

int main() {
    uint N;
    cin >> N;
    uint a{1};
    while (a <= N){
        a*=2;
    }
    cout << a/2;
    return 0;
}

Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
    int n = sc.nextInt();
    int cnt = 0;

    for (int i = 1; i <= n; i++) {
      int tmp = sc.nextInt();
      if (map.containsKey(tmp)) {
        if (map.get(tmp) == i) {
          cnt++;
          continue;
        }
      }
      map.put(i, tmp);
    }

    System.out.println(cnt);

  }
}

Measured memory_bytes: 66144
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
const int MOD=1e9+7;
#ifndef HOME
#define cerr if(0)cerr
#endif

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    int x;
    cin>>x;
    int a[n];
    vector<int>v;
    v.push_back(x);
    for(int i=0;i<n;i++){
        cin>>a[i];
        v.push_back(a[i]);
    }
    sort(v.begin(),v.end());
    int d=0;
    for(int i=1;i<v.size();i++){
        d=__gcd(d,v[i]-v[i-1]);
    }
    cout<<d<<endl;
    
    return 0;
    
}



Measured memory_bytes: 1912
/**
 * https://atcoder.jp/contests/abc168/tasks/abc168_a
 * 
 * いろはちゃんは、人気の日本製ゲーム「ÅtCoder」で遊びたい猫のすぬけ君のために日本語を教えることにしました。
 * 日本語で鉛筆を数えるときには、助数詞として数の後ろに「本」がつきます。
 * この助数詞はどんな数につくかで異なる読み方をします。
 * 具体的には、999 以下の正の整数 N について、「N 本」と言うときの「本」の読みは
 * N の 1 の位が 2,4,5,7,9 のとき hon
 *・N の 1 の位が 0,1,6,8 のとき pon
 *・N の 1 の位が 3 のとき bonです。
 *・N が与えられるので、「N 本」と言うときの「本」の読みを出力してください。
 *
 * 制約
 * N は 999 以下の正の整数
 */
export function Main(input: string) {
  // 問題文解体エリア
  const num = Number(input).valueOf();

  // console.log(nums);
  // 問題解決エリア
  const answer = fuck(num);

  //出力エリア
  console.log(answer.toString());
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
// 提出する時にコメントアウト解除せよ
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

export function fuck(num:number): string {
  const hons = ["2", "4", "5", "7", "9"];
  const pons = ["0", "1", "6", "8"];
  const bons = ["3"];

  const numStr = num.toString();
  const numOn1 = numStr.substr(numStr.length - 1);
  if (hons.indexOf(numOn1) >= 0) {
    return "hon";
  } else if (pons.indexOf(numOn1) >= 0) {
    return "pon";
  } else if (bons.indexOf(numOn1) >= 0) {
    return "bon";
  }
  return "fuck";
}

Measured memory_bytes: 29564
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.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; }
using ll = long long;
const ll MOD = 1e9+7; ll LLINF = 1LL << 60; int INF = INT_MAX;

//

int main(){
    int n; cin>>n;
    cout<<n/3<<endl;
}

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

int main()
{
    int a, b, c, mul ;
    cin >> a >> b >> c ;
    mul = (a*100) + (b*10) + c ;
    if(mul % 4 == 0) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
s = input()
ans = [0] * len(s)
R = 0
L = 0
for i in range(len(s)):
    if s[i] == "R":
        R += 1
    else:
        ans[i] += R // 2
        ans[i - 1] += -(-R // 2)
        R = 0
    if s[-i - 1] == "L":
        L += 1
    else:
        ans[-i - 1] += L // 2
        ans[-i] += -(-L // 2)
        L = 0

print(*ans)


Measured memory_bytes: 78228
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    cin >> n >> k;
    int arr[n+k+5],i;
    for(i=1;i<=n;i++)
    cin >> arr[i];

    int dp[n+k+5];
    memset(dp,-1,sizeof(dp));
    dp[1]=0;
    for(i=1;i<=n;i++)
    {
        for(int j=1;j<=k;j++)
        dp[i+j]= dp[i+j]==-1?(dp[i]+abs(arr[i+j]-arr[i])):min(dp[i+j],dp[i]+abs(arr[i+j]-arr[i]));
    }

    cout<<dp[n]<<endl;

    return 0;
}

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

int main()
{
    int w, h, x, y, r;
    
    cin >> w >> h >> x >> y >> r;
    
    if ((x - r < 0 || x + r > w) || (y - r < 0 || y + r > h)) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
}


Measured memory_bytes: 3092
import java.util.Scanner;
import java.util.Comparator;
import java.util.Arrays;
import java.math.BigInteger;
class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();
    long A[] = new long[N];
    long add = 0;
    A[0] = scan.nextLong();
    for(int i = 1; i < N; i++){
      A[i] = scan.nextLong();
      if(A[i] < A[i-1]){
        add += A[i-1] -A[i];
        A[i] = A[i-1];
      }
    }
    System.out.println(add);
  }
}

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

int n,a[100001];
int main(){
  cin >> n;
  int del = 0;
  for(int i=0;i<=100000;i++) a[i] = 0;
  for(int i=0;i<n;i++){
    int x;
    cin >> x;
    if(x <= 100000) a[x]++;
    else del++;
  }

  for(int i=0;i<=100000;i++){
    if(i <= a[i]) del += a[i]-i;
    else del += a[i];
  }
  cout << del << endl;
  return 0;
}


Measured memory_bytes: 640
n = gets.to_i
a, b = gets.split.map(&:to_i)
points = gets.split.map(&:to_i)
k = points.count{ |p| p <= a }
l = points.count{ |p| p > a && p <= b }
m = points.count{ |p| p > b }
puts [k, l, m].min


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define ALL(a) (a).begin(), (a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
typedef pair<ll, ll> pii;
const ll INF = 1LL << 58;
const ll MOD = 1000000007;
typedef vector<pii> vpii;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

/* a と b の最大公約数を返す関数 */
long long GCD(long long a, long long b)
{
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}

/* a と b の最小公倍数を求める */
long long LCM(long long a, long long b)
{
    long long g = GCD(a, b);
    return a / g * b;
}

signed main()
{
    int N, M;
    cin >> N >> M;
    int ans;
    if (N < 10)
        cout << M + 100 * (10 - N) << endl;
    else
        cout << M << endl;

    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main{
	public static void main(String[] args) throws IOException {
		try (BufferedReader br = new BufferedReader(
				new InputStreamReader(System.in))) {

			String in = br.readLine();
			String chr[] = in.split("");
			Arrays.sort(chr);
			String[] ans = {"a", "b", "c"};
			System.out.println(Arrays.equals(chr, ans)?"Yes":"No");

		}
	}
}

Measured memory_bytes: 25472
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author silviase
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ESumOfGcdOfTuplesHard solver = new ESumOfGcdOfTuplesHard();
        solver.solve(1, in, out);
        out.close();
    }

    static class ESumOfGcdOfTuplesHard {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // gcd(a,b,c) -> x となるような組の数をメモしておく
            int n = in.nextInt();
            int k = in.nextInt();
            ModInt[] mem = new ModInt[k + 1];
            ModInt res = new ModInt(0);
            for (int i = k; i >= 1; i--) {
                mem[i] = new ModInt(k / i).pow(n);
                for (int j = i * 2; j <= k; j += i) {
                    mem[i] = mem[i].sub(mem[j]);
                }
                res = res.add(mem[i].mul(i));
            }
            out.println(res.getVal());

        }

    }

    static class ModInt {
        long val;
        int MOD = (int) 1e9 + 7;

        public ModInt(long i) {
            this.val = (i + MOD) % MOD;
        }

        public ModInt mul(long l) {
            return new ModInt(this.val * l);
        }

        public ModInt add(ModInt m) {
            return new ModInt(this.val + m.getVal());
        }

        public ModInt sub(ModInt m) {
            return new ModInt(this.val - m.getVal());
        }

        public ModInt pow(long l) {
            ModInt res = new ModInt(1);
            ModInt v = new ModInt(this.val);
            while (l > 0) {
                if (l % 2 != 0) {
                    res = res.mul(v.val);
                }
                v = v.mul(v.val);
                l /= 2;
            }
            return res;
        }

        public long getVal() {
            return val;
        }

        public String toString() {
            return Long.toString(val);
        }

    }
}



Measured memory_bytes: 58920
#include<bits/stdc++.h>
using namespace std;
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define rep(i,n) for(int i=0; i<(n); ++i)
#define per(i,n) for(int i=n-1;i>=0;++i)
#define rep1(i,n) for(int i=1; i<=n; ++i)
#define per1(i,n) for(int i=n; i>=1; ++i)
#define debug cout << "line : " << __LINE__ << " debug" << endl
#define Dcout(N) cout << setprecision(20) << N << endl
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() ) //被り削除
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define INF 1e8
#define MOD 1000000007
typedef long long ll;


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

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

      for(int i = n;i>=2;i--){
          b[a[i]]++;
      }

      rep1(i,n){
          cout << b[i] << endl;
      }


      return 0;
}


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

namespace abc124_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int a = int.Parse(input[0]);
            int b = int.Parse(input[1]);

            int sum = 0;
            for (int i = 0; i < 2; i++)
            {
                if (a >= b)
                {
                    sum = sum + a;
                    a = a - 1;
                }
                else
                {
                    sum = sum + b;
                    b = b - 1;
                }
            }
            Console.WriteLine(sum);
            Console.ReadLine();
        }
    }
}


Measured memory_bytes: 11092
N = int(input())
shop = []
for i in range(N):
    shop.append(list(map(int, input().split())))
prof = []
for i in range(N):
    prof.append(list(map(int, input().split())))

ans = -10000000000
for i in range(1, 1024):
    anstemp = 0
    open = "{:010b}".format(i)
    for j in range(N):
        count = 0
        for k in range(10):
            if open[k] == "1" and shop[j][k] == 1:
                count += 1
        anstemp += prof[j][count]
    ans = max(ans, anstemp)
print(ans)


Measured memory_bytes: 42092
N,W = map(int, input().strip().split(" "))
oj = []
for i in range(N):
    tmp = list(map(int, input().strip().split(" ")))
    oj.append(tmp)

#dp = [0] * (W+1)
M = 100 * 1001
dp = [10**10] * M

dp[oj[0][1]] = oj[0][0]

for i in range(1,N):
    for j in range(M, -1, -1):
        if j + oj[i][1] < M:
            dp[j + oj[i][1]] = min(dp[j + oj[i][1]], dp[j] + oj[i][0])
    dp[oj[i][1]] = min(dp[oj[i][1]], oj[i][0])

v = 0
for i in range(M):
    if dp[i] <= W:
        v = i
print(v)


Measured memory_bytes: 41580
#include<bits/stdc++.h>
#define MAXN 100007

int arr[MAXN];

int cul(int a,int b)
{
	if(a % b == 0) return b;
	else return cul(b,a%b);
}

int main()
{
	int n,x; 
  scanf("%d %d",&n,&x);
	for(int i = 0; i < n; i++) 
	{
		int num; 
      scanf("%d",&num);
		arr[i] = abs(num-x);
	}
	if(n == 1) 
	{
		printf("%d\n",arr[0]);
		return 0;
	}
	
	int ans = cul(arr[0],arr[1]);
	for(int i = 2; i < n; i++)
		ans = cul(arr[i],ans);
	
	printf("%d\n",ans);
	return 0;
} 

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<algorithm>
#include<functional>

int main() {
	int n = 0,s = 0;
	int l = 0, m = 0;
	std::cin >> n;
	std::vector<int> in;
	std::vector<int> x;
	for (int i = 0; i < n; i++) {
		std::cin >> s;
		in.push_back(s);
	}
	x = in; std::sort(x.begin(), x.end());
	l = x[n / 2 - 1]; m = x[n / 2];
	for (int i = 0; i < n; i++) {
		if (in[i] > l) {
			std::cout << l << std::endl;
		}
		else {
			std::cout << m << std::endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 3828
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

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

    d = ceil(pow(100, d));
    if (n == 100) {
        n++;
    }

    cout << n * d << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
	ll n,w;
	cin >> n >> w;
	ll value[n],wt[n];
	for(int i=0;i<n;i++)cin >> wt[i] >> value[i];
    ll dp[n][w+1];
    memset(dp,0,sizeof(dp));
    for(ll i=0;i<n;i++)dp[i][0]=0;
    for(ll j=1;j<=w;j++){
    if(wt[0]>j)dp[0][j]=0;
    else dp[0][j]=value[0];
    //cout << dp[0][j] << " ";
    }
   // cout << endl;
    for(ll i=1;i<n;i++){
    for(ll j=1;j<=w;j++){
    if(j<wt[i])dp[i][j]=dp[i-1][j];
    else
    dp[i][j]=max(value[i]+dp[i-1][j-wt[i]],dp[i-1][j]);
    //cout << " " << dp[i][j];
    }
    //cout << endl;
    }
    cout << dp[n-1][w];
}

Measured memory_bytes: 78336
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define sc(x) scanf("%d",&x);
int main(){
    int x, y;
    string s1, s2, s;
    cin >> s1 >> s2;
    if (s1.size() > s2.size()) cout << "GREATER" << endl;
    else if (s1.size() < s2.size()) cout << "LESS" << endl;
    else {
        for (int i = 0; i < s1.size(); i++){
            s = s1[i]; x = atoi(s.c_str());
            s = s2[i]; y = atoi(s.c_str());
            if (x > y){
                cout << "GREATER" << endl;
                break;
            }else if (x < y){
                cout << "LESS" << endl;
                break;
            }
            if (i == s1.size() - 1) cout << "EQUAL" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>

using namespace std;

int a[205];

int main(){
	int n,m;
	cin >> n >> m;
	int sum = 0,ans = 0x7fffffff,tot = 0;
	for(int i = 1; i <= n; i++){
		a[i] = i + m - 1;
		sum += a[i];
	}
	for(int i = 1; i <= n; i++){
		if(abs(sum-(sum-a[i])) < ans){
			ans = abs(sum-(sum-a[i]));
			tot = sum - a[i];
		}
	}
	cout << tot;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<typeinfo>
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
typedef long long int ll;
using namespace std;

int main(){
  int N,T;
  cin>>N>>T;
  int t=0,a=0;
  ll ans=0;
  cin>>t;
  for(int i=1;i<N;i++){
    cin>>t;
    if(t-a>T){
      ans+=T;
    }else{
      ans+=t-a;
    }
    a=t;
  }
  ans+=T;
  cout<<ans<<endl;
  return 0;
}


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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

vector<ll> divisor(ll n)
{
    vector<ll> res;
    for (ll i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            res.emplace_back(i);
            if (i * i != n) res.emplace_back(n / i);
        }
    }
    sort(res.begin(), res.end());
    return res;
}

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

    int n; cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];

    map<int, int> mp;
    for (int i = 0; i < n; i++) mp[a[i]]++;

    a.emplace_back(inf);
    sort(a.begin(), a.end());

    
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (mp[a[i]] > 1) continue;
        auto v = divisor(a[i]);
        bool flag = true;
        for (auto &e: v) {
            if (e == a[i]) continue;
            if (binary_search(a.begin(), a.end(), e)) {
                flag = false;
                break;
            }
        }
        if (flag) ans++;
    }
    cout << ans << endl;

    // auto x = divisor(24);
    // for (auto &e: x) cout << e << endl;
    return 0;
}


Measured memory_bytes: 14256
def solve(first_sign)
    pos_flag=first_sign
    acc=0
    ret=0
    A.each do |a|
        acc+=a
        if pos_flag
            if acc<=0
                ret+=1-acc
                acc=1
            end
        else
            if acc>=0
                ret+=1+acc
                acc=-1
            end
        end
        pos_flag=!pos_flag
        #p [ret,acc]
    end
    #puts
    return ret
end

N=gets.to_i
A=gets.split.map(&:to_i)

p [solve(true),solve(false)].min


Measured memory_bytes: 8580
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	input := scanner.Text()

	param, _ := strconv.Atoi(input)
	fmt.Println(param * param * param)
}



Measured memory_bytes: 1088
import java.util.HashMap;
import java.util.Scanner;

class Main{
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a[] = new int[n-1];
		for(int i=0;i<n-1;i++)
			a[i] = sc.nextInt();
		int res[] = new int[n];
		for(int i=0;i<a.length;i++) {
			res[a[i]-1]=res[a[i]-1]+1;
		}
		for(int i=0;i<n;i++) {
			System.out.println(res[i]);
		}
	}
}

Measured memory_bytes: 64292
import java.awt.*;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);

        int h = sc.nextInt();
        int w = sc.nextInt();

        boolean[][] meiro = new boolean[h][];
        Queue<Point> queue = new ArrayDeque<>();

        for (int i = 0; i < h; i++) {
            String[] s = sc.next().split("");
            boolean[] row = new boolean[w];
            for (int j = 0; j < w; j++) {
                if (s[j].equals("#")) {
                    row[j] = true;
                    queue.add(new Point(j, i));
                }
            }
            meiro[i] = row;
        }

        // 上下左右（分岐先）の座標を配列に入れておくと、forループで回して処理できるので便利
        int[] dx = {0, 1, 0, -1};
        int[] dy = {-1, 0, 1, 0};

        int[][] searched = new int[h][w];
        int ans = 0;
        while (!queue.isEmpty()) {
            Point p = queue.poll();
            ans = searched[p.y][p.x];
            for (int k = 0; k < 4; k++) {
                int x = p.x + dx[k];
                int y = p.y + dy[k];
                // 分岐先の座標が、2つのif文の条件を満たすなら先頭に追加
                if (x >= 0 && x < w && y >= 0 && y < h) {
                    if (!meiro[y][x]) {
                        searched[y][x] = searched[p.y][p.x] + 1;
                        meiro[y][x] = true;
                        queue.add(new Point(x, y));
                    }
                }
            }
        }

        System.out.println(ans);
    }
}

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

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

#define p_ary(ary,a,b,i) do { cout << "["; for (int i = a;i < b;++i) cout << ary[i] << (b-1 == i ? "]\n" : ", "); } while(0)
#define p_map(map,it) do {cout << "{";for (auto it = map.begin();;++it) {if (it == map.end()) {cout << "}\n";break;}else cout << "" << it->first << "=>" << it->second << ", ";}}while(0)

int main () {
    int n,m;
    string s,t;
    cin >> s >> t;
    n = s.size();m = t.size();
    vector<vector<P>> dp(2,vector<P>(m+1,P(0,"")));
    for (int k = 0;k < n;++k) {
        int i = k%2;
        for (int j = 0;j < m;++j) {
            if (s[k] == t[j]) {
                if (dp[i][j].first+1 > dp[i^1][j].first && dp[i][j].first+1 > dp[i][j+1].first) dp[i^1][j+1] = P(dp[i][j].first+1,dp[i][j].second+s[k]);
                else dp[i^1][j+1] = (dp[i^1][j].first > dp[i][j+1].first ? dp[i^1][j] : dp[i][j+1]);
            } else dp[i^1][j+1] = (dp[i^1][j].first > dp[i][j+1].first ? dp[i^1][j] : dp[i][j+1]);
        }

    }
    cout << dp[n&1][m].second << endl;
    return 0;
}

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

void findTheAns(long long odd){
	if(odd % 2 == 0){
		cout << "YES" << endl;
	}
	else{
		cout << "NO" << endl;
	}
}

int main() {
	long long n , num;
	cin >> n;
	
	long long odd = 0;
	for(long long i = 0; i < n; i++){
		cin >> num;
		if(num % 2 == 1){
			odd++;
		}
	}
	findTheAns(odd);
}

Measured memory_bytes: 3040
N = int(input())
H = [int(h) for h in input().split()]
A = [int(a) for a in input().split()]

#区間の最大値を求めるセグメント木
seg = [0]*(2*N-1)
#for i in range(2*N-2, N-2, -1):
#    seg[i] = A[i-N+1]
    
#for i in range(N-2, -1, -1):
#    seg[i] = max(seg[2*i+1], seg[2*i+2])
    
def update(k, x):
    k += N-1
    seg[k] = x
    while k:
        k = (k-1)//2
        seg[k] = max(seg[2*k+1], seg[2*k+2])
        
def query(p, q):
    p += N-1
    q += N-2
    res = 0
    while q-p > 1:
        if p&1 == 0:
            res = max(res, seg[p])
        if q&1 == 1:
            res = max(res, seg[q])
            q -= 1
        p //= 2
        q = (q-1)//2
    if p == q:
        res = max(res, seg[q])
    else:
        res = max(res, seg[p], seg[q])
    return res

dp = [0]*N
dp[0] = A[0]
update(H[0]-1, A[0])
for i in range(N-1):
    dp[i+1] = query(0, H[i+1])+A[i+1]
    update(H[i+1]-1, dp[i+1])
    
print(max(dp))

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

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define BIT(X,i) ((X>>i)&1)
#define REP(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define ina(x,n) rep(x_i,n) cin>>x[x_i]
#define outa(x,n) rep(x_i,n) cerr<<x[x_i]<<" \n"[x_i==n-1]

using ll  = long long int;
using vl  = vector<ll>;
using vvl = vector<vl>;
using pll = pair<ll, ll>;
using vll = vector<pll>;

const int inf = (1<<28);
const ll infl = (1LL<<60);
const int mod = 1e9+7;

int main() {
    int a, b; cin >> a >> b;
    int ans = -1;
    for (double x = 1; x <= 1000; x += 1.0) {
        if (floor(x * 0.08) == a && floor(x * 0.10) == b) {
            ans = x;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 764
//#include "pch.h"
#include <stdio.h>
#include <stdlib.h>

int main()
{
	int P, Q, R;
	int min;

	scanf("%d %d %d", &P, &Q, &R);
	min = P + Q;
	min = min > P + R ? P + R : min;
	min = min > Q + R ? Q + R : min;
	printf("%d", min);

	return 0;
}

Measured memory_bytes: 128
from fractions import gcd
N, K = map(int, raw_input().split(' '))
A = map(int, raw_input().split(' '))
 
M = max(A)
G = reduce(gcd, sorted(A))
 
if not K % G and K <= M:
    print 'POSSIBLE'
else:
    print 'IMPOSSIBLE'

Measured memory_bytes: 12636
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef pair<int, int> pair;
const int inf = 1000000000; //10^9
const ll inff = 1000000000000000000; //10^18

int main(){
    int n;
    cin >> n;
    vector<int> h(n);
    rep(i, n) cin >> h[i];

    for (int i = 0; i < n; i++) {
        if (i == 0) h[i]--;
        else if(h[i-1] < h[i]) h[i]--;
        else if(h[i-1] == h[i]) continue;
        else if(h[i-1] > h[i]) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 3732
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 40;
typedef pair<ll, ll> P;
int main()
{
    ll N, K;
    cin >> N >> K;
    vector<vector<ll>> td(N);
    rep(i, N) {
        ll t, d;
        cin >> t >> d;
        t--;
        td[t].push_back(d);
    }
    rep(i, N) {
        if ((int)td[i].size() == 0) td[i].push_back(-INF);
        sort(all(td[i]));
        reverse(all(td[i]));
    }
    sort(all(td), [](vector<ll> a, vector<ll> b) {
                        return (a[0] > b[0]);   
                    });
    ll res = 0;
    priority_queue<ll, vector<ll>> que;

    rep(i, K) {
        res += td[i][0];
        repd(j, 1, td[i].size()) que.push(td[i][j]);
    }

    repd(i, K, N) {
        rep(j, td[i].size()) que.push(td[i][j]);
    }

    ll ans = res + K * K;
    for (ll k = K - 1; k > 0; k--) {
        ll ct = que.top();
        if (ct > td[k][0]) {
            res -= td[k][0];
            res += ct;
            que.pop();
            que.push(td[k][0]);
        }
        chmax(ans, res + k * k);
    }

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

Measured memory_bytes: 8696
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#include <cstring>
#include <map>
#include <queue>
#include <string>
#include <set>
#define pb push_back
#define mod 1000000007
#define all(x) x.begin(),x.end()
#define inf (int)(1e9)
using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;

vector<int> a;
int ok;

bool check(int x){
  //cout<<":"<<x<<" ;"<<ok<<endl;
  ll tmp=a[x];
  for(int i=0;i<a.size();i++){
    if(i==x) continue;
    if(tmp>=ok) break;
    if(tmp*2>=a[i]){
      tmp+=a[i];
    }
    else return false;
  }
  ok=a[x];
  return true;
}

int main(void){
  int n,x;
  cin>>n;
  for(int i=1;i<=n;i++){
    cin>>x;
    a.pb(x);
  }
  sort(a.begin(),a.end());
  ok=1e9;
  int l,r,m;
  l=0;r=a.size()-1;
  while(l<r-1){
    m=(l+r)/2;
    if(check(m)) r=m;
    else l=m;
  }
  if(check(0)) cout<<a.size()<<endl;
  else cout<<a.size()-r<<endl;
  return 0;
}

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

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) a[i] = i + 1;
	vector<int> p(n), q(n);
	for (int i = 0; i < n; i++) cin >> p[i];
	for (int i = 0; i < n; i++) cin >> q[i];
	int it = 0, f1 = -1, f2 = -1;
	do {
		it++;
		if (a == p) f1 = it;
		if (a == q) f2 = it;
	} while (next_permutation(a.begin(), a.end()));
	cout << abs(f1 - f2) << '\n';
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define sign(x) ((x==0)?1:-1)


int main(){
	int H,W;
	cin>>H>>W;
	vector<string> S(H);
	for(int i=0;i<H;i++)cin>>S[i];
	
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			if(S[i][j]=='.'){
				int cnt = 0;
				for(int x=-1;x<=1;x++){
					for(int y=-1;y<=1;y++){
						if(i+x<0||i+x>=H)continue;
						if(j+y<0||j+y>=W)continue;
						if(S[i+x][j+y]=='#')cnt++;
					}
				}
				S[i][j]='0'+cnt;				
				
			}
		}
	}
	
	for(int i=0;i<H;i++)cout<<S[i]<<endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std; using ll = long long;
using ull = unsigned long long; using P = pair<int, int>;
const int INF = 1e9; const int MOD = 1000000007;
const int dx[] = {-1,0,1,0}; const int dy[] = {0,-1,0,1};
//const int dx[] = {-1,-1,-1, 0, 0, 1, 1, 1}; const int dy[] = {-1, 0, 1,-1, 1,-1, 0, 1};
#define PI 3.14159265358979323846264338327950L //setprecision(15)
#define MAX_N 100000
int main() {
	int N; cin >> N;
	vector<P> v(N);
	rep(i, N) {
		cin >> v[i].first;
		v[i].second = i + 1;
	}
	sort(v.begin(), v.end());
	rep(i, N) {
		cout << v[i].second;
		if (i == N - 1) cout << endl;
		else cout << " ";
	}
}

Measured memory_bytes: 3936
package main

import "fmt"

func main() {
	var a, b, n uint64
	fmt.Scan(&a, &b, &n)
	if a%n != 0 {
		a = n * (1 + a/n)
	}
	if b%n != 0 {
		b = n * (b / n)
	}
	var cnt uint64
	if a > b {
		cnt = 0
	} else {
		cnt = 1 + (b-a)/n
	}
	fmt.Println(cnt)
}


Measured memory_bytes: 512
import Data.List
main = do
  n <- readLn
  ps <- map read . words <$> getLine
  qs <- map read . words <$> getLine
  let a = sort $ permutations [1..n]
      r = length $ takeWhile (<= ps) a
      t = length $ takeWhile (<= qs) a
  print $ abs(r - t)
  


Measured memory_bytes: 21116
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();

            while (true)
            {
                int input = int.Parse(Console.ReadLine());

                if (input == -1) break;

                string temp = input == 0 ? "0" : "";

                while (input > 0)
                {
                    temp += input % 4;
                    input /= 4;
                }
                temp = new string(temp.Reverse().ToArray());
                sb.AppendLine(temp);
            }
            Console.Write(sb);
        }
    }
}

Measured memory_bytes: 9668
import { readFileSync } from 'fs'

const range = (start: number, end: number) =>
  Array(end - start).fill(null).map((v, i) => i + start)

function main(input: string) {
  const [r, D, x] = input.split(' ').map(Number)

  const memo = { 2000: x }

  const recurrence = (year: number) =>
    memo[year] = r * memo[year - 1] - D

  range(2001, 2011).forEach(year =>
    console.log(recurrence(year))
  )
}

main(readFileSync('/dev/stdin', 'utf8').trim())


Measured memory_bytes: 7756
import bisect

n,m,k = map(int,input().split())
a = tuple(map(int,input().split()))
b = tuple(map(int,input().split()))

sa = [0]
for ai in a:
  sa.append(sa[-1]+ai)
sb = [0]
for bi in b:
  sb.append(sb[-1]+bi)
#print(sa)
#print(sb)

ans = 0
for i in range(len(sa)):
  if k < sa[i]:
    break
  r = bisect.bisect_right(sb,k-sa[i])
  ans = max(i+r-1,ans)
print(ans)

Measured memory_bytes: 140536
N = input()
S, T = input().split(' ')
# map*lambda式で文字列を入れ子に結合しlist化する
ans = []
ans = list(map(lambda s1,s2: s1+s2, list(S), list(T)))
# 空文字.joinの引数にlistを指定して最終文字列化
print(''.join(ans))

Measured memory_bytes: 2940
H,W,D = map(int,input().split())

M = {}

for h in range(H):
    A = list(map(int,input().split()))
    for w in range(len(A)):
        M[A[w]] = [h,w]

anslist = []
for d in range(1,D+1):
    ans = 0
    sub_anslist = [ans]
    now = M[d]
    for i in range(d+D,(H*W)+1,D):
        nex = M[i]
        ans += abs(nex[0]-now[0])+abs(nex[1]-now[1])
        sub_anslist.append(ans)
        now = nex
    anslist.append(sub_anslist)

Q = int(input())
output = []
for q in range(Q):
    L,R = map(int,input().split())
    left = anslist[(L-1)%D][(L-1)//D]
    right = anslist[(R-1)%D][(R-1)//D]
    output.append(str(right-left))
        
print("\n".join(output))

Measured memory_bytes: 37184
/**
 * @author      : Luis Miguel Baez <es.luismiguelbaez@gmail.com>
 * @created     : Thursday August 13, 2020
 */

#include <bits/stdc++.h>

using namespace std;

#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define ms(arr, value) memset(arr, value, sizeof arr)
#define ll    int64_t

#define pii   pair<int, int>
#define piii  tuple<int, int, int>
#define pll   pair<ll, ll>
#define plll  tuple<ll, ll, ll>

#define F  first
#define S  second

const int oo  = (int)(1e9);
const ll lloo  = (ll)(1e18);

const int N = int(1e5) + 10;

class Task {
public:
    int n, w;
    vector<pair<int, int>> A;
    // (peso, valor)
    
    ll dp[110][N];

    ll go(int index, int W) {
        if(index > n) return 0;
        ll &ans = dp[index][W];
        if(ans != -1) return ans;
        
        if(W-A[index].F < 0) {
            return go(index+1, W);
        }

        ll x = A[index].S + go(index+1, W-A[index].F);
        ll y = go(index+1, W);
        ans = max(x, y);
        return ans;
    }

    ll solveOne(istream &in, ostream &out) {
        in >> n >> w;
        A.resize(n+1);
        int w_i, v_i;
        for(int i = 1; i <= n; ++i){
            in >> w_i >> v_i;
            A[i] = {w_i, v_i};
        }
        memset(dp, -1, sizeof dp);
        ll ans = go(1, w);
        return ans;  
    }
    
    void solve(istream &in, ostream &out) {
        int t=1;
        while(t--) {
            out << solveOne(in, out) << endl;
        }
    }
};

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


Measured memory_bytes: 89608
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
const ll mod=1e9+7;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    vector<ll>heroes;
    vector<ll>city;
    for(int i=0;i<n+1;i++){
        ll a;
        cin>>a;
        city.push_back(a);
    }
    for(int i=0;i<n;i++){
        ll a;
        cin>>a;
        heroes.push_back(a);
    }
    ll res=0;
    for(int i=0;i<n;i++){
        res+=min(heroes[i],city[i]);
        ll aa=city[i];
        ll bb=heroes[i];
        city[i]=max(ll(0),aa-bb);
        heroes[i]=max(ll(0),bb-aa);
        if(city[i]==0){
            aa=city[i+1];
            bb=heroes[i];
            res+=min(heroes[i],city[i+1]);
            city[i+1]=max(ll(0),aa-bb);
            heroes[i]=max(ll(0),bb-aa);
        }
    }
    cout<<res<<endl;
    return 0;
    }


Measured memory_bytes: 2548
def main():
    w, h, n = map(int, input().split())
    f = [[1] * w for _ in range(h)]

    for _ in range(n):
        x, y, a = map(int, input().split())
        if a == 1:
            for i in range(h):
                for j in range(x):
                    f[i][j] = 0
        if a == 2:
            for i in range(h):
                for j in range(x, w):
                    f[i][j] = 0
        if a == 3:
            for i in range(h - y, h):
                for j in range(w):
                    f[i][j] = 0
        if a == 4:
            for i in range(h - y):
                for j in range(w):
                    f[i][j] = 0

    ans = 0
    for l in f:
        ans += sum(l)
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
import java.util.*;
public class Main {

    public static void main(String[] args) {
        Scanner スキャナー = new Scanner(System.in);
        byte 数字 = スキャナー.nextByte();
        if (数字 == 1){
            System.out.println("Hello World");
        }else if (数字 == 2){
            int 二歳[] = new int[2];
            二歳[0] = スキャナー.nextInt();
            二歳[1] = スキャナー.nextInt();
            System.out.println(二歳[0]+二歳[1]);
        }

    }
}

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

int main()
{
  char a;
  cin >> a;

  if ((int)a >= 97)
  {
    cout << "a"
         << "\n";
  }
  else
  {
    cout << "A"
         << "\n";
  }

  return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>
int main(void) {
    int i = 0, j;
    char c, S[6];
    while ((c = getchar()) != EOF) S[i++] = c;
    for (j = 0; j < i - 1; j++) {
        if (S[j] == 'A' && S[j + 1] == 'C') {
            printf("Yes\n");
            return 0;
        }
    }
    printf("No\n");
    return 0;
}

Measured memory_bytes: 128