akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
using namespace std;
using ll = long long;
#define rep(i,a,b) for(int i=(a); i<(b); i++)
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
ll gcd(ll a, ll b){if (a%b == 0)  return(b);else  return(gcd(b, a%b));}
ll lcm(ll a, ll b){return a * b / gcd(a, b);}
/* map<string,int> */
/* 大文字を小文字に変換 tolower*/
/* 小文字を大文字に変換 toupper*/
/* 辞書順 next_permutation(a.begin(),a.end()) */
 
int main () {
    int n,m,x;
    cin >> n >> m >> x;
    vector <int> c(n);
    vector <vector <int> > a(n,vector<int>(m));
    for(int i =0; i<n;i++) {
        cin >> c[i];
        for(int j = 0;j<m;j++) {
            cin >> a[i][j];
        }
    }
    int ans = 100000000;
    for(int bit=0; bit <(1<<n); bit++) {
        vector <int> v(m);
        bool flag = true;
        int sum = 0;
        rep(i,0,n) {
           if (bit & 1 <<i) {
               rep(j,0,m) {
                   v[j] += a[i][j];
               }
               sum += c[i];
           }
        }
        rep(i,0,m) {
            if (v[i] < x) {
                flag = false;
            }
        }
        if (flag) {
            ans = min(ans, sum);
        }
    }
    if (ans == 100000000) {
        cout << -1 << endl;
    } else {
        cout << ans << endl;
    }
}

Measured memory_bytes: 3192
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    ll d;
    cin >> d;
    int cnt = 0;
    rep(i, n) {
        ll a, b;
        cin >> a >> b;
        if(d*d >= a*a + b*b) cnt++;
    }

    cout << cnt << endl;
}

Measured memory_bytes: 3644
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int main(void){
	int i,j,len,flg;
	char s[27];
	cin>>s;
	len=strlen(s);
	flg=1;
	for(i=0;i<len-1;i++){
		for(j=i+1;j<len;j++){
			if(s[i]==s[j]){
				flg=0;
				break;
			}
		}
		if(flg==0) break;
	}
	if(flg==1) cout<<"yes"<<endl;
	else cout<<"no"<<endl;
	return 0;
}

Measured memory_bytes: 256
import itertools,sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N,M = LI()
a = set([I() for _ in range(M)])
dp = [0]*(N+1) #1_indexed
dp[0] = 1
dp[1] = 0 if 1 in a else 1
for i in range(1,N+1):
    if i in a:
        dp[i] = 0
        continue
    if i-2>=0:
        dp[i] = (dp[i-1]+dp[i-2])%(10**9+7)
print(dp[-1])


Measured memory_bytes: 13212
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
typedef unsigned int ui;
int main() {
	ll pas[51][51];
	int i,j;
	for (i = 0; i < 51; i++) {
		for (j = 0; j < 51; j++) {
			if (i == 0 || j == 0) {
				pas[i][j] = 1;
			}
			else {
				pas[i][j] = pas[i - 1][j] + pas[i][j - 1];
			}
		}
	}
	int n, a, b;
	cin >> n >> a >> b;
	ll v[50]; ll V;
	for (i = 0; i < n; i++) {
		cin >> V;
		v[i] = V;
	}
	sort(v, v + n);
	vector<int> check;
	check.push_back(a);
	ll ssum[51]; ssum[0] = 0;
	for (i = 1; i <= 50; i++) {
		ssum[i] = ssum[i - 1] + v[n-i];
	}
	for (i = a+1; i <= b; i++) {
		if (ssum[i] * (i - 1) > ssum[i - 1] * i) {
			check.pop_back();
			check.push_back(i);
		}
		else if (ssum[i] * (i - 1) == ssum[i - 1] * i) {
			check.push_back(i);
		}
		else {
			break;
		}
	}
	int l = check.size();
	double out = ssum[check[l - 1]] / (double)check[l-1];
	cout << fixed << setprecision(6) << out << endl;
	int c, d; ll count = 0;
	for (i = 0; i < l; i++) {
		c = 0; d = 0;
		for (j = 0; j < n; j++) {
			if (v[n - check[i]] == v[j]) {
				c++;
				if (j >= n-check[i])d++;
			}
		}
		count += pas[c - d][d];
	}
	cout << count << endl;
	char nyaa; cin >> nyaa;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position move_pattern[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr start, itr goal){ for(auto i = start; i != goal; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
#define mod long(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl(long(n))
#define fcout cout << fixed << setprecision(10)
#define highest(x) (63 - __builtin_clzl(x))
struct combination{ vector<long> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } long C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };

using int64 = long long;

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

int main(){
    long N, P;
    cin >> N >> P;
    auto factorizated = prime_factor(P);
    long ans = 1;
    for(auto i: factorizated){
        ans *= power(i.first, i.second / N, 1e18);
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
import java.util.*;
import java.io.PrintWriter;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static int MOD = 1000000007;
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int m1 = parseInt(sc.next());
		int d1 = parseInt(sc.next());
		int m2 = parseInt(sc.next());
		int d2 = parseInt(sc.next());
		sc.close();
		out.println(m1==m2?0:1);
	}
}


Measured memory_bytes: 22356
// input! macro is published in the following URLs.
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
// https://github.com/tanakh/competitive-rs.git
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        k: usize,
    }
    let ans = if n % k == 0 { 0 } else { 1 };
    println!("{}", ans);
}


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

int main(void){
  string s;
  int start, end;

  cin >> s;

  for(int i = 0; i < s.size(); i ++)
    if(s.at(i) == 'A'){
      start = i;
      break;
    }
    
  for(int i = s.size()-1; i >= 0; i --)
    if(s.at(i) == 'Z'){
      end = i;
      break;
    }

  cout << end - start + 1 << endl;

  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n-1;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 999999

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin >> n;
	vector<ll> x(n);
	REP(i, n){cin >> x[i];}
	vector<ll> sorted_x(n);
	sorted_x = x;
	sort(sorted_x.begin(), sorted_x.end());
	ll s_median = sorted_x[n/2-1];
	ll l_median = sorted_x[n/2];
	REP(i, n){
		if (x[i] > s_median){cout << s_median << endl;}
		else {cout << l_median << endl;}
	}
}

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

int main(){
	string s;
	cin>>s;
	vector<char>ans;
	for(int i=0;i<s.size();i++){
		if(s[i]=='0'){
			ans.push_back('0');
		}
		else if(s[i]=='1'){
			ans.push_back('1');
		}
		else{
			if(ans.size()!=0){
				ans.pop_back();
			}
		}
	}
	for(int i=0;i<ans.size();i++){
		cout<<ans.at(i);
	}
	cout<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int a,b,c,d,ans=0;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    if(a<c) a=c;
    if(b>d) b=d;
    ans=b-a;
    if(ans<0) ans=0;
    printf("%d",ans);
    return 0;
}

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

int dp[3001][3001];
string s,t;

void printString(int m,int n){
    int x = max(dp[m-1][n],max(dp[m-1][n-1],dp[m][n-1]));
    if(x==0)
        if(dp[m][n]!=0)
            return void(cout<<s[m-1]);
        else return;
    if(x < dp[m][n]){
        printString(m-1,n-1);
        cout<<s[m-1];
        return;
    }
    if(dp[m-1][n]==x) return printString(m-1,n);
    if(dp[m][n-1]==x) return printString(m,n-1);
}

int main(){
    cin >> s >> t;
    int m = s.length(),n = t.length();
    memset(dp,0,sizeof dp);

    for(int i = 1;i <= m;i++){
        for(int j = 1;j <= n;j++){
            if(s[i-1] == t[j-1]) dp[i][j] = dp[i-1][j-1]+1;
            else dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
        }
    }
    printString(m,n);
}

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

int main(){
    int a,b,c,n;
    cin >> a;
    cin >> b;
    cin >> c;
    if( a > b ){ n = a;
                 a = b;
                 b = n;}
    if( b > c ){ n = b;
                 b = c;
                 c = n;}
    if( a > b ){ n = a;
                 a = b;
                 b = n;}
    cout << a <<" "<< b <<" "<< c << endl;
    return 0;
}
    


Measured memory_bytes: 3076
#include<iostream>
using namespace std;
int main(){
  int paper[10][10],x,y,size,i,j;
  string s;
  for(i=0; i<10; i++)
    for(j=0; j<10; j++)
      paper[i][j]=0;

  while(cin>>s){
    x=s.at(0)-'0';
    y=s.at(2)-'0';
    size=s.at(4)-'0';
      paper[x][y]++;
      if(x>0) paper[x-1][y]++;
      if(x<9) paper[x+1][y]++;
      if(y>0) paper[x][y-1]++;
      if(y<9) paper[x][y+1]++;

    if(size>=2){
      if(x>0&&y>0) paper[x-1][y-1]++;
      if(x<9&&y>0) paper[x+1][y-1]++;
      if(x>0&&y<9) paper[x-1][y+1]++;
      if(x<9&&y<9) paper[x+1][y+1]++;
    }
    if(size>=3){
      if(x>1)paper[x-2][y]++;
      if(y>1)paper[x][y-2]++;
      if(x<8)paper[x+2][y]++;
      if(y<8)paper[x][y+2]++;
    }
  }

  int n=0,max=0;
  for(i=0; i<10; i++){
    for(j=0; j<10; j++){
      if(paper[i][j]==0)n++;
      if(paper[i][j]>max)max=paper[i][j];
    }
  }
  cout<<n<<"\n"<<max<<endl;
}

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

#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << " = " << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define SP << " " <<

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<int> vec;
typedef vector<P> pvec;
typedef vector<vector<int>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<int> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<int,vector<int>,greater<int>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;

const vector<int> DX = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> DY = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const ll INF = (1LL << 60); // 1152921504606846976
const double PI = (3.141592653589794);
const double EPS = (0.0000000001); // 10^(-10)

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> inline T ceil(T a, T b) {return T((a + b - 1) / b);}
template<class T> inline T round(T a, T b) {return T(a / b);}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }
template <class T> inline void out(T &a) { bool flag=true; for(auto&x:a){if(flag) {flag=false;} else{ cout << ' '; } cout<<x; } cout << endl; }



//----------------------------------------------------------------
int nmax=200000; // 2*(10^5)
vvec G(nmax);





void solve4ts()
{
    
    
    int ans=0;
    int a,b,c;
    cin>>a>>b>>c;
    for(int i=a;i<=b;i++){
        if(i%c==0) ans++;
    }
    cout<<ans<<endl;
    
    
}
//-----------------------------------------------------------------

signed main(){ ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(15);
    int repeat = 1;
    // cin >> repeat;
    while(repeat--) solve4ts();
}

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

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;

constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433;

template <class T> vector<T> make_v(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto make_v(size_t N,T... t){return vector<decltype(make_v(t...))>(N,make_v(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}


//Digit Sum
long long Digit_Sum(long long N, long long K) {
    long long sum = 0;
    for (; N > 0; N /= K) sum += N % K;
    return sum;
}

int main() {
    int N; cin >> N;
    int ans = 0;
    for(int i = 1; i <= N; ++i){
        string S = to_string(i);
        if(S.size()%2) ans++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#pragma comment(linker, "/STACK:10240000")
#include <bits/stdc++.h>

using namespace std;

int main ()
{
    long long x, y;
    scanf ("%lld%lld", &x, &y);
    int ans = 0;
    while (x <= y)
    {
        x *= 2;
        ans ++;
    }
    printf ("%d\n", ans);
    return 0;
}


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

int n;

int main()
{
    while(~scanf("%d",&n))
    {
        int x=n*800;
        int y=(n/15)*200;
        printf("%d\n",x-y);
    }
}


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

int main() {

    ll S;
    cin >> S;
    const ll MOD = 1e9 + 7;

    vector<vector<ll>> d(2010, vector<ll>(2010, 1));
    FOR(i, 1, S+1) {
        FOR(j, 1, i) {
            d[i][j] = (d[i-1][j-1] + d[i-1][j]) % MOD;
        }
    }

    ll ans = 0;

    rep(i, S) {
        if (S - 2*(i+1) - 1 >= i) {
            ans = (ans + d[S-2*(i+1)-1][i]) % MOD;
        }
        else break;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 34932
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int k = sc.nextInt();

		int[][] white = new int[k][k];
		int[][] black = new int[k][k];

		int whiteTotal = 0;
		int blackTotal = 0;

		int[][] whiteLeftBelow = new int[k][k];
		int[][] blackLeftBelow = new int[k][k];
		int[][] whiteRightAbove = new int[k][k];
		int[][] blackRightAbove = new int[k][k];

		for(int i=0;i<n;i++) {
			int x = sc.nextInt();
			int y = sc.nextInt();
			boolean isWhite = sc.next().equals("W");
			int xmod = x%k;
			int ymod = y%k;
			if((x/k)%2==0 ^ (y/k)%2==0) {
				isWhite = !isWhite;
			}

			if(isWhite) {
				white[xmod][ymod]++;
				whiteTotal++;
			} else {
				black[xmod][ymod]++;
				blackTotal++;
			}
		}

		whiteLeftBelow[0][0]=white[0][0];
		blackLeftBelow[0][0]=black[0][0];
		for(int i=0;i<k;i++) {
			for(int j=0;j<k-1;j++) {
				if(i==0) {
					whiteLeftBelow[i][j+1]=whiteLeftBelow[i][j]+white[i][j+1];
					blackLeftBelow[i][j+1]=blackLeftBelow[i][j]+black[i][j+1];
				} else {
					whiteLeftBelow[i][j+1]=whiteLeftBelow[i][j]+whiteLeftBelow[i-1][j+1]-whiteLeftBelow[i-1][j]+white[i][j+1];
					blackLeftBelow[i][j+1]=blackLeftBelow[i][j]+blackLeftBelow[i-1][j+1]-blackLeftBelow[i-1][j]+black[i][j+1];
				}
			}
			if(i<k-1) {
				whiteLeftBelow[i+1][0]=whiteLeftBelow[i][0]+white[i+1][0];
				blackLeftBelow[i+1][0]=blackLeftBelow[i][0]+black[i+1][0];
			}
		}

		whiteRightAbove[k-1][k-1]=white[k-1][k-1];
		blackRightAbove[k-1][k-1]=black[k-1][k-1];
		for(int i=k-1;i>=0;i--) {
			for(int j=k-1;j>=1;j--) {
				if(i==k-1) {
					whiteRightAbove[i][j-1]=whiteRightAbove[i][j]+white[i][j-1];
					blackRightAbove[i][j-1]=blackRightAbove[i][j]+black[i][j-1];
				} else {
					whiteRightAbove[i][j-1]=whiteRightAbove[i][j]+whiteRightAbove[i+1][j-1]-whiteRightAbove[i+1][j]+white[i][j-1];
					blackRightAbove[i][j-1]=blackRightAbove[i][j]+blackRightAbove[i+1][j-1]-blackRightAbove[i+1][j]+black[i][j-1];
				}
			}
			if(i>0) {
				whiteRightAbove[i-1][k-1]=whiteRightAbove[i][k-1]+white[i-1][k-1];
				blackRightAbove[i-1][k-1]=blackRightAbove[i][k-1]+black[i-1][k-1];
			}
		}

		//count total hopes

		int ans = 0;
		for (int i=0;i<k;i++) {
			for(int j=0;j<k;j++) {
				int tmp = whiteLeftBelow[i][j] + (i+1<k && j+1<k ? whiteRightAbove[i+1][j+1] : 0) + blackTotal
						- blackLeftBelow[i][j] - (i+1<k &&  j+1<k ? blackRightAbove[(i+1)%k][(j+1)%k] : 0);
				if(ans < tmp) {
					ans = tmp;
				}

				tmp = blackLeftBelow[i][j] + (i+1<k && j+1<k ? blackRightAbove[i+1][j+1] : 0 ) + whiteTotal
						-  whiteLeftBelow[i][j] - (i+1<k && j+1<k ? whiteRightAbove[i+1][j+1] : 0);

				if(ans < tmp) {
					ans = tmp;
				}
			}
		}

		System.out.println(ans);

	}

}


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

int main() {
  int n;
  string s;
  cin >> n;
  cin >> s;
  int q;
  cin >> q;

  set<int> pos[26];
  for ( int i = 0; i < n; i++ ) {
    pos[s[i]-'a'].insert(i);
  }

  while ( q-- > 0 ) {
    int type;
    cin >> type;
    if ( type == 1 ) {
      int i;
      char c;
      cin >> i >> c;
      i--;
      pos[s[i]-'a'].erase(i);
      pos[c-'a'].insert(i);
      s[i] = c;
    }
    if ( type == 2 ) {
      int l, r;
      cin >> l >> r;
      l--;
      r--;
      int kind = 0;
      for ( int i = 0; i < 26; i++ ) {
        set<int>::iterator it = pos[i].lower_bound(l);
        set<int>::iterator last = pos[i].upper_bound(n);
        if ( it != last && *it <= r ) {
          kind++;
        }
      }
      cout << kind << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 27240
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <deque>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <iomanip>
using namespace std;

int main()
{
    int num;
    cin >> num;
    vector<int> v;
    for(int i=0;i<num;i++){
        int tmp;
        cin >> tmp;
        v.push_back(tmp);
    }
    vector<int> ans;
    ans.push_back(0);
    ans.push_back(1000000);
    for(int i=0;i<num-1;i++){
        ans.push_back(ans[i]+abs(v[i+2]-v[i]));
        ans[i+1]=min(ans[i+1],ans[i]+abs(v[i+1]-v[i]));
    }
    cout << ans[num-1] << endl;
    return 0;
}

Measured memory_bytes: 1400
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;
typedef long long ll;
int main() {
	int N;
	cin >> N;
	vector<int> B(N);
	for(int i = 0; i < N; i++) {
		int x;
		cin >> x;
		B[i] = x - (i + 1);
	}
	sort(B.begin(), B.end());
	int b;
	if(N % 2 == 1) {
		b = B[(N - 1)/2];
	} else {
		b = (B[N / 2] + B[(N - 2) / 2]) / 2;
	}
	ll res = 0;
	for(int i = 0; i < N; i++) {
		res += abs(B[i] - b);
	}
	cout << res << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
using LP=pair<ll,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007,MOD2=998244353;

ll power(ll n,ll p){
    if(p==0){return 1;}
    if(p%2==1){return n*power(n,(p-1)/2)*power(n,(p-1)/2);}
    else{return power(n,p/2)*power(n,p/2);}
}

int main() {
    ll N;
    cin>>N;
    string ans;
    int keta=1;
    ll N2=N;
    while(N>power(26,keta)){
        N-=power(26,keta);
        keta++;
    }
//cout<<N<<endl;
--N;
    
    rep(i,keta){
        ans.pb('a'+N%26);
        N/=26;
    }
    reverse(ans.begin(),ans.end());
    cout<<ans<<endl;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    if(s=="ABC"){
        cout<<"ARC"<<'\n';
    }
    else{
        cout<<"ABC"<<'\n';
    }
    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define sf scanf
#define pf printf
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define endl '\n'
using namespace std;

typedef long long LL;
typedef unsigned long long ULL;

const int N = 1e3+50;
const int INF = 2e9;
const double PI = acos(-1);

int arr[2000][2000];

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

    memset(arr,0,sizeof(arr));

    int k=44;
    int n = k*k-k+1;
    // int n=21, k=5;
    int angka = 2;
    for(int i=0;i<k;++i){
        for(int j=0;j<k;++j){
            if(j == 0){
                arr[i][j] = 1;
            }else{
                arr[i][j] = angka;
                angka++;
            }
        }
    }

    angka = 2;
    int cnt = 0;
    for(int i=k;i<n;++i){
        arr[i][0] = angka;
        cnt++;
        if(cnt == k-1){
            cnt = 0;
            angka++;
        }
    }

    angka = arr[1][1];
    cnt = 0;
    int blok;
    for(int j = 1; j < k; ++j){
        for(int t=0;t<k-1;++t){
            blok = 2;
            for(int i = k+t; i <= n ;){
                int realpos;
                if(i == k+t) realpos = i;
                else realpos = i + cnt;
                if(realpos > blok*(k-1)){
                    realpos -= k-1;
                }
                arr[realpos][j] = angka;
                i = realpos + k-1;
                blok++;
            }
            angka++;
        }
        cnt++;
    }
    

    pf("%d %d\n",n,k);
    for(int i=0;i<n;++i){
        for(int j=0;j<k;++j){
            if(j) pf(" ");
            pf("%d",arr[i][j]);
        }
        pf("\n");
    }

    return 0;
}

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

using namespace std;

int main()
{
	int N, K;
	cin >> N >> K;
	string S;
	cin >> S;

	// 1-0-1-0-...-1-0-1
	vector < int >nums;
	int now = 1;
	int cnt = 0;
	for (int i = 0; i < N; i++) {
		if (S[i] == (char)('0' + now)) {
			cnt++;
		} else {
			nums.push_back(cnt);
			now = 1 - now;
			cnt = 1;
		}
	}
	if (cnt != 0) {
		nums.push_back(cnt);
	}

	if (nums.size() % 2 == 0) {
		nums.push_back(0);
	}

	int add = 2 * K + 1;

	int ans = 0;

	int left = 0;
	int right = 0;

	int sum = 0;

	for (int i = 0; (size_t) i < nums.size(); i += 2) {
		int nextLeft = i;
		int nextRight = min(i + add, (int)nums.size());

		while (left < nextLeft) {
			sum -= nums[left];
			left++;
		}

		while (right < nextRight) {
			sum += nums[right];
			right++;
		}

		ans = max(sum, ans);
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1020
#include<stdio.h>
int main()
{
    int n,k,x,y,sum;
    scanf("%d %d %d %d",&n,&k,&x,&y);
    if(n>=1&&k>=1&&x>=1&&y>=1&&n<=10000&&k<=10000&&x<=10000&&y<=10000)
    {
        if(n<=k)
        sum=n*x;
        else
        sum=x*k+(n-k)*y;
        printf("%d",sum);

    }
    return 0;
}


Measured memory_bytes: 128
S= input()
T=input()
mi = 3000
for i in range(0,len(S)-len(T)+1):
    c = 0
    for j in range(0,len(T)):
        #print(S[i+j]+":"+T[j])
        
        if S[i+j] != T[j]:
            c += 1

        #print(c)
    if mi > c:
        mi = c
print(mi)

Measured memory_bytes: 9072
/*---------------------------------

 @Author:   Dicer
 @DateTime: 2019-05-19 20:12:22
---------------------------------*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
inline ll qpow(ll a,ll b,ll mod){ll res=1;while(b){if(b&1)res = (res*a)%mod;a=(a*a)%mod;b>>=1;}return res;}
const double eps = 1e-8;
const int INF = 0x3f3f3f3f;
const int mod = 1e9+7;
const int MAXN = 2e5 + 7;

vector<pii> G[MAXN];
bool col[MAXN];

void dfs(int x, int fa = 0, bool odd = 0){
	col[x] = col[fa]^odd;
	for(auto p: G[x]){
		if(p.first == fa)	continue;
		dfs(p.first, x, p.second%2);
	}
}
int main(int argc, char const *argv[])
{

	int n;
	cin >> n;
	int u, v, w;
	for(int i = 1; i < n; ++i){
		cin >> u >> v >> w;
		G[u].push_back({v, w});
		G[v].push_back({u, w});
	}
	col[0] = 1;
	dfs(1);
	for(int i = 1; i <= n; ++i)	cout << col[i] << endl;
	return 0;
}

Measured memory_bytes: 10496
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
using namespace std;

int main(){
   int x1, y1;
   int x2, y2;
   int x3, y3;
   int x4, y4;
   cin >> x1 >> y1 >> x2 >> y2;

   if ((x1 < x2) && (y1 == y2)) { // →
      x3 = x2;
      y3 = y2 + abs(x2 - x1);

      x4 = x1;
      y4 = y3;
   }
   else if ((x1 < x2) && (y1 < y2)) { // ↗️
      x3 = x2 - abs(y2 - y1);
      y3 = y2 + abs(x2 - x1);

      x4 = x3 - abs(x2 - x1);
      y4 = y3 - abs(y2 - y1);
   }
   else if ((x1 == x2) && (y1 < y2)) { // ↑
      x3 = x2 - abs(y2 - y1);
      y3 = y2;

      x4 = x3;
      y4 = y1;
   }
   else if ((x1 > x2) && (y1 < y2)) { // ↖️
      x3 = x2 - abs(y2 - y1);
      y3 = y2 - abs(x1 - x2);

      x4 = x3 + abs(x1 - x2);
      y4 = y3 - abs(y2 - y1);
   }
   else if ((x1 > x2) && (y1 == y2)) { // ←
      x3 = x2;
      y3 = y2 - abs(x1 - x2);

      x4 = x1;
      y4 = y3;
   }
   else if ((x1 > x2) && (y1 > y2)) { // ↙️
      x3 = x2 + abs(y1 - y2);
      y3 = y2 - abs(x1 - x2);

      x4 = x3 + abs(x1 - x2);
      y4 = y3 + abs(y1 - y2);
   }
   else if ((x1 == x2) && (y1 > y2)) { // ↓
      x3 = x2 + abs(y1 - y2);
      y3 = y2;

      x4 = x3;
      y4 = y1;
   }
   else if ((x1 < x2) && (y1 > y2)) { // ↘️
      x3 = x2 + abs(y1 - y2);
      y3 = y2 + abs(x2 - x1);

      x4 = x3 - abs(x2 - x1);
      y4 = y3 + abs(y1 - y2);
   }
   cout << x3 << " " << y3 << " " << x4 << " " << y4;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<iostream>
using namespace std;
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define mod 1000000007
#define PI 3.1415926535897932384626433
#define se second
#define fi first
#define pb push_back
#define T true
#define F false
#define endl "\n"
typedef char ch;
typedef bool boll;
typedef string st;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef set < string > sst;
typedef set < long long > sl;
typedef queue < long long > que;
typedef vector < long long > vec;
typedef map < long long, long long > mll;
typedef pair < long long, long long > pll;
typedef vector < pair < long long, long long > > vpl;
typedef pair < long long, unsigned long long > pul;

int main()
{
    fast;
    int s,w;
    cin >> s >> w;
    if(w>=s) cout << "unsafe";
    else cout << "safe";
    
    return 0;
}


Measured memory_bytes: 3688
import math
A, B, K = map(int, input().split())
l = []
for k in range(min([K, math.floor((B - A + 1)/2)])):
    l.append(k + A)
for k in range(min([K, math.ceil((B - A + 1) / 2)])):
    l.append(B - k)
l.sort()
for i in l:
  print(i)

Measured memory_bytes: 3064
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop;

void main() {
    auto N = readln.chomp.to!int;
    auto edges = new int[][](N);
    foreach (i; 0..N-1) {
        auto s = readln.split.map!(to!int);
        edges[s[0]-1] ~= s[1]-1;
        edges[s[1]-1] ~= s[0]-1;
    }

    if (N == 2) {
        writeln("Second");
        return;
    } else if (N == 3) {
        writeln("First");
        return;
    }

    
    bool first = false;
    
    int dfs(int n, int p) {
        int[] tmp;
        foreach (m; edges[n]) if (m != p)
            tmp ~= dfs(m, n);

        if (tmp.sum > 1)
            first = true;

        //writeln(n, tmp);
        return tmp.sum ? 0 : 1;
    }

    
    if (dfs(0, -1))
        first = true;
    
    writeln( first ? "First" : "Second" );
}


Measured memory_bytes: 12284
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)

	ans := 0
	for i := 0; i < N; i++ {
		var a int
		fmt.Scan(&a)
		for a%2 == 0 {
			ans++
			a /= 2
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1280
n = STDIN.gets.to_i
a = STDIN.gets.chomp.split(" ").map{|x| x.to_i}.sort

if (n&1) == 1
  for i in 0..(n-1) do
    if i == 0 && a[i] != 0
      puts 0
      exit
    elsif 2*((i+1)/2) != a[i]
      puts 0
      exit
    end
  end
else
  for i in 0..(n-1) do
    if ((i == 0) || (i == 1)) && a[i] != 1
      puts 0
      exit
    elsif ((i/2)*2 + 1) != a[i]
      puts 0
      exit
    end
  end  
end

puts (2**(n/2))%((10**9) + 7)


Measured memory_bytes: 10248
H, W, K = gets.split.map(&:to_i)
MOD = 10 ** 9 + 7
dp = Array.new(H + 1) { Array.new(W, 0) }
dp[0][0] = 1
H.times do |h|
    (0...(1 << (W-1))).each do |bit|
      W.times do |w|
      #check
      flag = false
      (1...W).each do |i|
        if bit[i] == 1 && bit[i - 1] == 1
          flag = true
        end
      end
      next if flag
      # fiber
      if w != W - 1 && bit[w] == 1
        target = w + 1
      elsif w != 0 && bit[w - 1] == 1
        target = w - 1
      else
        target = w
      end
      dp[h + 1][target] = (dp[h + 1][target] + dp[h][w]) % MOD
  end
end
end
puts dp[H][K-1]


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

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef LOCAL
#define debug(x...) cerr <<"at line "<< __LINE__<<": [" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> 
using ordered_set= tree<T, null_type, 
		less<T>, 
		rb_tree_tag, tree_order_statistics_node_update> ;
template<class T> 		
using ordered_mset= tree<T, null_type, 
		less_equal<T>, 
		rb_tree_tag, tree_order_statistics_node_update> ;
		
*/
 
/*
 
PBDS
-------------------------------------------------
			0 based indexing
-------------------------------------------------			 
1) insert(value)
2) erase(value)
3) order_of_key(value) // Number of items strictly smaller than value
4) *find_by_order(k) : K-th element in a set (counting from zero)
 
*/
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
//mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());	

const int mx=1e7+5;

int mark[mx];

void sieve()
{
	for(int i=2;i<mx;i++)
	{
		if(!mark[i])
		{
			for(int j=2*i;j<mx;j+=i) if(!mark[j]) mark[j]=i;
		}
	}
}

ll divisors(int n)
{
	map<int,int>fact;
	
	while(mark[n])
	{
		fact[mark[n]]++;
		n/=mark[n];
	}
	
	if(n>1) fact[n]++;
	
	ll ans=1LL;
	
	for(auto it: fact) ans*=1LL*(it.second+1);
	
	return ans;
}
		

void solve()
{
	sieve();
	
	int n;
	cin>>n;
	
	ll ans=0;
	
	for(int i=1;i<=n;i++) ans+=1LL*i*divisors(i);
	
	cout<<ans;
	
}		

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	solve();
	
	#ifdef LOCAL
	cerr<<"\nTime elapsed: " << 1000.0 * clock() / CLOCKS_PER_SEC << " ms\n";
	#endif
	
	
	return 0;
}

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

int main(){
	int n;
	cin >> n;
	int ans = 100000;
	for(int i=0; i < n; i++){
		ans *= 1.05;
		if(ans % 1000){
			ans -= (ans % 1000);
			ans += 1000;
		}
	}
	cout << ans << endl;
	return 0;
}

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

using ll = long long;
#define int long long

// [a -> b-1]
#define reps(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
// [0 -> a-1]
#define rep(i, a) reps(i, 0, (a))
// [a-1 -> b]
#define rreps(i, a, b) for (int i = (int)((a)-1); i >= (int)(b); i--)
// [a-1 -> 0]
#define rrep(i, a) rreps(i, a, 0)
#define all(v) (v).begin(), (v).end()
// next_permutation(all(v))
#define PERM(v) next_permutation(all(v))
/*sort(all(v));
 * (v).erase(unique(all(v)), v.end())*/
#define UNIQUE(v)\
	sort(all(v));\
	(v).erase(unique(all(v)), v.end())
#define MINV(v) min_element(all(v))
#define MAXV(v) max_element(all(v))
#define MIN3(a, b, c) min(min(a, b), c)
#define MIN4(a, b, c, d) min(MIN3(a, b, c), d)
#define MIN5(a, b, c, d, e) min(MIN4(a, b, c, d), e)
#define MIN6(a, b, c, d, e, f) min(MIN5(a, b, c, d, e), f)
#define MAX3(a, b, c) max(max(a, b), c)
#define MAX4(a, b, c, d) max(MAX3(a, b, c), d)
#define MAX5(a, b, c, d, e) max(MAX4(a, b, c, d), e)
#define MAX6(a, b, c, d, e, f) max(MAX5(a, b, c, d, e), f)
// b is [a, c)
#define RANGE(a, b, c) ((a) <= (b) && (b) < (c))
// c is [a, e) && d is [b, f)
#define RANGE2D(a, b, c, d, e, f) (RANGE((a), (c), (e)) && RANGE((b), (d), (f)))
#define chmin(a, b) a = min(a, (b))
#define chmin3(a, b, c) a = MIN3(a, (b), (c))
#define chmin4(a, b, c, d) a = MIN4(a, (b), (c), (d))
#define chmin5(a, b, c, d, e) a = MIN5(a, (b), (c), (d), (e))
#define chmin6(a, b, c, d, e, f) a = MIN6(a, (b), (c), (d), (e), (f))
#define chmax(a, b) a = max(a, (b))
#define chmax3(a, b, c) a = MAX3(a, (b), (c))
#define chmax4(a, b, c, d) a = MAX4(a, (b), (c), (d))
#define chmax5(a, b, c, d, e) a = MAX5(a, (b), (c), (d), (e))
#define chmax6(a, b, c, d, e, f) a = MAX6(a, (b), (c), (d), (e), (f))
#define fcout cout << fixed << setprecision(15)
#define YES(f) cout << ((f) ? YES_STR : NO_STR) << endl;

using namespace std;

int solve(int n, int p) {
	vector<int> v(n, 0);
	int w = p;
	for (int i = 0; ; i = (i + 1) % n) {
		if (w) v[i]++, w--;
		else w += v[i], v[i] = 0;
		if (v[i] == p) return i;
	}
}

signed main() {
	int n, p;
	while (cin >> n >> p, n) cout << solve(n, p) << endl;
}




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

#define LL long long
#define fi first
#define se second
#define mp make_pair
#define pb push_back

using namespace std;

LL gcd(LL a,LL b){return b?gcd(b,a%b):a;}
LL lcm(LL a,LL b){return a/gcd(a,b)*b;}
LL powmod(LL a,LL b,LL MOD){LL ans=1;while(b){if(b%2)ans=ans*a%MOD;a=a*a%MOD;b/=2;}return ans;}
const int N = 2e5 +11;
int n,a[N],b[N],c[N];
int cnt;
int main(){
	ios::sync_with_stdio(false);
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i],b[i]=i;	
	for(int i=1;i<=n;i++){
		if(a[i]!=b[i])cnt++;
	}
	if(cnt<=2)cout<<"YES\n";
	else cout<<"NO\n";
	return 0;
}

Measured memory_bytes: 256
let n, x = Scanf.scanf "%d %d\n" (fun n x -> (n, x))

let ar = Array.init n (fun _ -> Scanf.scanf "%d " (fun x -> x))

let ar' = Array.copy ar

let count = ref 0

let count' = ref 0

let () =
  for i = 0 to n - 2 do
    let sum = ar.(i) + ar.(i + 1) in
    if sum > x then count := !count + (sum - x)
  done ;
  for i = 0 to n - 2 do
    let sum = ar'.(i) + ar'.(i + 1) in
    if sum > x then (
      count' := !count' + (sum - x) ;
      ar'.(i + 1) <- max 0 (ar'.(i + 1) - (sum - x)) )
  done ;
  Printf.printf "%d\n" (min !count !count')

Measured memory_bytes: 6016
#include<iostream>
#include<algorithm>
#include<iterator>
#include<vector>
#include<string>
#include<map>

using namespace std;


#define mod(cans) cans%10**9+7
#define cin_pl(x,y) for(int i=0;i<x;i++){cin>>y[i];}
#define pl_twin(x,y,z) for(int i=0;i<x;i++){cin>>y[i]>>z[i];}
#define debug(x) cout << "Debug" << x << "\n"
#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 st(s) size_t size = s.length()
#define prians(Answer) cout<<Answer<<"\n"
#define com_div(x,Co) for(int i=1;i<x+1;i++){if(x%i==0){Co++;}}
#define TF(X) X==1?cout<<"Yes\n":cout<<"No\n"
#define elcon else{continue;}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<vector<int>> matrix;
typedef pair<int,int> pr;
typedef vector<pr> vpt;
typedef greater<int> gi;

int main()
{
    int x,a,b;
    cin>>x>>a>>b;
    cout<<(x-a)%b;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {
	int n;
	int b = -10000000000;
	int c = 10000000000;
	long long sum = 0;
	cin >> n;
	int a[n];
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	for(int j=0;j<n;j++){
		if(b < a[j]) {b = a[j];}
	}
	for(int k=0;k<n;k++){
		if(c > a[k]) {c = a[k];}
	}
	for(int l=0;l<n;l++){
		sum += int(a[l]);
	}
	cout << c << " " << b << " " << sum << endl;

	return 0;
}


Measured memory_bytes: 3124
import java.util.*;

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

    int A = sc.nextInt();
    int B = sc.nextInt();

    if(A<9 && B<9){
      System.out.println("Yay!");
    } else {
      System.out.println(":(");
    }
  }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define IFOR(i, m, n) for(ll i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

/* 二項係数 C(n,k) mod p を計算 */
const int MOD = 1000000007;
const int MAX = 201000;
long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

long long COM(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll modpow(ll a , ll b, ll m){
  if (b == 0) return 1;
  ll ret;
  if (b%2 == 0){
    ll  t = modpow(a, b/2, m)%m;
    ret = t*t %m;
  }else{
    ll t = modpow(a, (b-1)/2,m)%m;
    ret = a*t %m * t % m;
  }
  ret %= m;
  return ret;
}

int main(){
  COMinit();
  ll B,W; cin >> B >> W;
  ll N = B+W;
  // iターン後にB=0となる確率，W=0となる確率
  vector<ll> b(N,0), w(N,0);

  FOR(i,B,N){
    b[i] = (b[i-1] + (COM(i-1,i-B) * modpow(inv[2],i, MOD))%MOD)%MOD ;
  }

  FOR(i,W,N){
    w[i] = (w[i-1] + (COM(i-1,i-W) * modpow(inv[2],i, MOD))%MOD)%MOD ;
  }

  FOR(i,1,N+1){
    ll ans = ((MOD+1-b[i-1]+w[i-1])%MOD * inv[2])%MOD;
    cout << ans << endl;
  }
}



Measured memory_bytes: 9984
import bisect

n = int(input())
d = [int(i) for i in input().split()]
m = int(input())
t = [int(i) for i in input().split()]

d.sort()
t.sort()

d.append(0)
d_val = []
d_cnt = []
cnt = 1
for i in range(1, n+1):
    if d[i-1] != d[i]:
        d_cnt.append(cnt)
        d_val.append(d[i-1])
        cnt = 1
    else:
        cnt += 1

t.append(0)
t_val =[]
t_cnt = []
cnt = 1
for i in range(1, m+1):
    if t[i-1] != t[i]:
        t_cnt.append(cnt)
        t_val.append(t[i-1])
        cnt = 1
    else:
        cnt += 1

flag = True
if t_val[0] in d_val:
    n_begin = d_val.index(t_val[0])
else:
    flag = False
if t_val[-1] in d_val:
    n_end = d_val.index(t_val[-1])
else:
    flag = False
if flag:
    for i in range(len(t_val)):
        idx = bisect.bisect_left(d_val,t_val[i], n_begin, n_end+1)
        if d_val[idx] != t_val[i]:
            flag=False
            break
        if d_cnt[idx] < t_cnt[i]:
            flag=False
            break
        else:
            n_begin = idx + 1

if flag:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 35816
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <climits>
#include <cstring>

using namespace std;

#define int long long
#define rep(i, n) for (int i=0;i<(int)(n);++i)
#define rep1(i, n) for (int i=1;i<=(int)(n);++i)
#define range(i, l, r) for (int i=l;i<(int)(r);++i)
#define rrange(i, l, r) for (int i=r-1;i>=(int)(l);--i)
#define unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

using vi=vector<int>;
using pii=pair<int, int>;
using ll=long long;

bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
int read(){int a;scanf("%lld",&a);return a;}

const int mod = 1e9 + 7;

int N, K;

int rui[1000010];

signed main()
{
	cin >> N >> K;

	rep(i, N) {
		int a, b; cin >> a >> b;
		rui[a] += b;
	}

	range(i, 1, 100010) {
		rui[i] += rui[i - 1];
	}

	int ok = 100010, ng = 0;

	while (abs(ok - ng) > 1) {
		int m = (ok + ng) / 2;

		if (rui[m] >= K) {
			ok = m;
		} else {
			ng = m;
		}
	}

	cout << ok << endl;
}



Measured memory_bytes: 1024