akhauriyash/Code-Regression huggingface dataset:
#define mod 1000000007
#include<time.h>
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<map>
#include<queue>
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
const ll INF=0x7fffffffffffffff;
const int inf=0x7fffffff;
const int N=2e5+5;
clock_t start,finish;
void time_in(){start=clock();}
void time_out(){finish=clock();double tim=(double)(finish-start)/CLOCKS_PER_SEC;printf("Running time is %lf\n",tim);}
ll mul(ll a,ll b){ll s=0;while(b){if(b&1)s=(s+a)%mod;a=(a<<1)%mod;b>>=1;}return s%mod;}
ll pow_mul(ll a,ll b){ll s=1;while(b){if(b&1)s=mul(s,a);a=mul(a,a);b>>=1;}return s;}
ll poww(ll a,ll b){ll s=1;while(b){if(b&1)s=(s*a)%mod;a=(a*a)%mod;b>>=1;}return s%mod;}
int t,cas;
int n,m,k;
int main()
{
	int a,b;
	while(~scanf("%d%d",&a,&b))
	{
		if(a<b)
		{
			printf("0\n");
		}
		else
		{
			printf("10\n");
		}
	}
}


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

/* snippet: useful macros and functions */
#define ARC(i, a, b) for(Int i = (a); i < (b); ++i)
#define RC(i, n) ARC(i, 0, n)
#define ARCH(i, a, b) for(Int i = (a) - 1; i >= (b); --i)
#define RCH(i, n) ARCH(i, n, 0)
template<class T> T ant(const T &a, const T &b){ return a > b ? a : b; }
template<class T> T ont(const T &a, const T &b){ return a < b ? a : b; }
template<class T> T rng(const T &a, const T &b){ return a < b ? b - a : a - b; }
template<class T> void th(T &a, const T &b, T (*f)(const T &, const T &)){ a = f(a, b); }
#define anth(a, b) th(a, b, ant)
#define onth(a, b) th(a, b, ont)

/* snippet: modint library */
template<class T, int MOD>
class Modint{
	T val;
public:
	Modint(T val = 0) : val(val % MOD + (val > 0 ? 0 : MOD)) {}
	operator T(){ return val; }
	Modint &operator+=(const Modint &a){ val += a.val; if(val >= MOD) val -= MOD; return *this; }
	Modint &operator-=(const Modint &a){ val -= a.val; if(val < 0) val += MOD; return *this; }
	Modint &operator*=(const Modint &a){ val = val * a.val % MOD; return *this; }
	void inverse(){T x[2]={MOD,val},a[2]={0,1};int i;for(i=0;x[!i];i^=1){a[i]-=x[i]/x[!i]*a[!i];x[i]=x[i]%x[!i];}if(!i)a[i]+= MOD;val=a[i];}
	Modint &operator/=(Modint a){ a.inverse(); return *this *= a; }
	friend Modint modpow(Modint a, int n){ Modint ret(1); while(n){ if(n & 1) ret *= a; a *= a; n >>= 1; } return ret; }
	friend Modint operator+(Modint a, const Modint &b){ return a += b; }
	friend Modint operator-(Modint a, const Modint &b){ return a -= b; }
	friend Modint operator*(Modint a, const Modint &b){ return a *= b; }
	friend Modint operator/(Modint a, const Modint &b){ return a /= b; }
	friend std::ostream &operator<<(std::ostream &os, const Modint &a){ return os << a.val; }
};

/* snippet: using declarations */
using Int = long long;
using std::cout;
using std::cin;
using std::endl;
using Mint = Modint<long long, 1000000007>;

Int count[3000] = {1};

int main(){
	std::string s;
	cin >> s;
	Int t = 1, x = 0;
	Int len = s.size();
	RC(i, len){
		x = (x + (s[len - i - 1] - '0') * t) % 2019;
		t = t * 10 % 2019;
		++count[x];
	}
	Int ans = 0;
	RC(i, 2019){
		ans += count[i] * (count[i] - 1) / 2;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3784
#include <bits/stdc++.h>
#define int long long
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int a[200001],b[200001],ans,q,s,t,r,l,h,n;
main(){
	cin>>n>>q>>s>>t;
	r(i,n+1)scanf("%lld",&a[i]);
	r(i,n){
		b[i]=a[i+1]-a[i];
		if(b[i]<0)ans-=b[i]*t;
		else ans-=b[i]*s;
	}
	r(i,q){
		scanf("%lld%lld%lld",&l,&r,&h);l--;
		if(b[l]<0)ans+=b[l]*t;
		else ans+=b[l]*s;
		if(r!=n&&l!=r){
		  if(b[r]<0)ans+=b[r]*t;
		  else ans+=b[r]*s;
		}
		b[l]+=h;
		if(l!=r)b[r]-=h;
		if(b[l]<0)ans-=b[l]*t;
		else ans-=b[l]*s;
		if(r!=n&&l!=r){
		  if(b[r]<0)ans-=b[r]*t;
		  else ans-=b[r]*s;
		}
		printf("%lld\n",ans);
	}
}

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

int main( void ){
	
	lint a, b, t;
	
	cin >> a >> b >> t;
	
	cout << ( t / a ) * b << endl;
	
	return 0;
	
}

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

int main(){
  string S;
  cin>>S;
  int A,B,C,D;
  A=S.at(0)-48;
  B=S.at(1)-48;
  C=S.at(2)-48;
  D=S.at(3)-48;
  if(A+B+C+D==7) cout<<A<<'+'<<B<<'+'<<C<<'+'<<D<<"=7"<<endl;
  else if(A+B+C-D==7) cout<<A<<'+'<<B<<'+'<<C<<'-'<<D<<"=7"<<endl;
  else if(A+B-C+D==7) cout<<A<<'+'<<B<<'-'<<C<<'+'<<D<<"=7"<<endl;
  else if(A-B+C+D==7) cout<<A<<'-'<<B<<'+'<<C<<'+'<<D<<"=7"<<endl;
  else if(A+B-C-D==7) cout<<A<<'+'<<B<<'-'<<C<<'-'<<D<<"=7"<<endl;
  else if(A-B+C-D==7) cout<<A<<'-'<<B<<'+'<<C<<'-'<<D<<"=7"<<endl;
  else if(A-B-C+D==7) cout<<A<<'-'<<B<<'-'<<C<<'+'<<D<<"=7"<<endl;
  else cout<<A<<'-'<<B<<'-'<<C<<'-'<<D<<"=7"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(ll i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()

const int INIT = 0;
struct segmentTree{
private:
    int n;
    vector<int> node;

public:
    segmentTree(vector<int> vec){
        int sz = vec.size();
        n = 1;while(n<sz)n*=2;
        node.resize(2*n-1,INIT);

        For(i,0,sz){
            node[i+(n-1)] = vec[i];
        }
        for(int i=n-2;i>-1;i--){
            node[i] = node[2*i+1]|node[2*i+2];//演算子は適当に
        }
    }
    void update(int x,int val){
        x+=(n-1);
        node[x]=val;
        while(x){
            x=(x-1)/2;
            node[x] = node[2*x+1]|node[2*x+2];//演算子は適当に
        }
    }
    //区間[a,b) k:今見ているノード 

    int get(int a, int b, int k=0, int l=0, int r=-1) {
        // 最初に呼び出されたときの対象区間は [0, n)
        if(r < 0) r = n;

        // 要求区間と対象区間が交わらない
        if(r <= a || b <= l) return INIT;

        // 要求区間が対象区間を完全に被覆
        if(a <= l && r <= b) return node[k];

        // 要求区間が対象区間の一部を被覆 -> 子について探索を行う
        // 左側の子を vl ・ 右側の子を vr としている
        // 新しい対象区間は、現在の対象区間を半分に割ったもの
        int vl = get(a, b, 2*k+1, l, (l+r)/2);
        int vr = get(a, b, 2*k+2, (l+r)/2, r);
        int val = vl|vr;//演算子は適当に
        return val;
    }
};
void Main(){
    int n,q;
    string s;
    cin>>n>>s>>q;
    vector<int> vec(n);
    For(i,0,n){
        vec[i]=1<<(s[i]-'a');
    }
    segmentTree segTree(vec);
    For(_,0,q){
        int t;
        cin >> t;
        if(t==1){
            int i;
            char c;
            cin >> i >> c;
            i--;
            segTree.update(i,1<<(c-'a'));
        }
        else if(t==2){
            int l,r;
            cin >> l >> r;
            l--;
            cout << __builtin_popcount(segTree.get(l,r)) << endl;
        }
    }
}
int main(){
    Main();
    return 0;
}

Measured memory_bytes: 8836
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
using namespace std;
int main(){
	string s;
	cin >> s;
	int cnt = 0;
	for (int i = 0; i < 3; i++) {
		if (s[i] == '1')cnt++;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>

int main(){
    int i,j,n,count[26];
    for(int i = 0; i < 26; i++){
        count[i] = 0;
 	}
    char ch;
    while(scanf("%c",&ch)!=EOF){
        if(ch>='a' && ch<='z'){
            count[ch-'a']++;
        }
        else if(ch>='A'&& ch<='Z'){
            count[ch-'A']++;
        }
    }
    for(j=0;j<26;j++){
        printf("%c : %d\n",j+'a',count[j]);
    }
    return 0;
}


Measured memory_bytes: 2684
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
using namespace std;

int main(){

    char a;
    cin >> a;
    if('A'<=a && a<='Z'){
        cout << "A" << endl;
    }
    else{
        cout << "a" << endl;
    }
    return 0;
}


Measured memory_bytes: 3632
/*input

*/


// assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
#define ll          long long int
#define pb          push_back
#define pii         pair<ll ,ll >
#define vpii        vector< pii >
#define vi          vector<ll >
#define vs			vector< string >
#define vvi         vector< vector< ll > >
#define inf			(ll)1e18
#define all(it,a)   for(auto it=(a).begin();it!=(a).end();it++) 
#define F           first
#define S           second
#define sz(x)       (ll )x.size()
#define rep(i,a,b)	for(ll  i=a;i<b;i++)
#define repr(i,a,b) for(ll  i=a;i>b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define whatis(x)   cout << #x << " is " << x << "\n";
#define graph(n)    adj(n,vector< ll > () )
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define debug(x)     cout << #x << " " << x << endl;
#define debug_p(x)   cout << #x << " " << x.F << " " << x.S << endl;
#define debug_v(x)   {cout << #x << " "; for (auto ioi : x) cout << ioi << " "; cout << endl;}
#define debug_vp(x)  {cout << #x << " "; for (auto ioi : x) cout << '[' << ioi.F << " " << ioi.S << ']'; cout << endl;}
#define debug_v_v(x) {cout << #x << "/*\n"; for (auto ioi : x) { for (auto ioi2 : ioi) cout << ioi2 << " "; cout << '\n';} cout << "*/" << #x << endl;}

int solve()
{
ll n;cin>>n;
set<string> s;
rep(i,0,n) 
{
	string k;cin>>k;
	s.insert(k);
}

cout<<sz(s);	


	return 0;
}

int main()
{
	auto start = chrono::high_resolution_clock::now();

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

	ll test_cases=1;
	//cin>>test_cases;
	while(test_cases--)
		solve();

	auto stop = chrono::high_resolution_clock::now();
	auto duration = chrono::duration_cast<chrono::milliseconds>(stop-start);
	//cout<<"\nduration: "<<(double)duration.count()<<" milliseconds";
}

Measured memory_bytes: 19140
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')
in_nl = lambda: list(map(int, readline().split()))
in_nl2 = lambda H: [in_nl() for _ in range(H)]
in_map = lambda: [s - ord('a') for s in readline() if s != ord('\n')]
in_map2 = lambda H: [in_map() for _ in range(H)]
in_all = lambda: map(int, read().split())


def main():

    N = in_n()
    grid = in_map2(N)

    cnt = 0
    for i in range(N):
        tmp_grid = [[0] * N for _ in range(N)]
        for y in range(N):
            for x in range(N):
                tmp_grid[(y + i) % N][x] = grid[y][x]

        # print(tmp_grid)

        flag = True
        for y in range(N):
            for x in range(N):
                if tmp_grid[y][x] != tmp_grid[x][y]:
                    flag = False

        if flag:
            cnt += N

    print(cnt)


if __name__ == '__main__':
    main()


Measured memory_bytes: 110140
use num_traits::One;
use proconio::input;
use std::cmp::min;
use std::ops::Mul;
const MAX: usize = 210000;
fn main() {
    input! {
        n:usize,
        k:usize,
        a:[usize;n]
    }
    let a1: Vec<usize> = a.iter().map(|x| x - 1).collect::<Vec<_>>();
    let ans = pow(&Perm { p: a1 }, k).p;
    print!("{}", ans[0] + 1);
}
#[derive(Clone)]
struct Perm {
    p: Vec<usize>,
}

impl Mul for Perm {
    type Output = Self;
    fn mul(self, other: Self) -> Self {
        let n = min(self.p.len(), other.p.len());
        let mut ret: Vec<usize> = vec![0; n];
        for i in 0..n {
            ret[i] = self.p[other.p[i]];
        }
        Self { p: ret }
    }
}
impl One for Perm {
    fn one() -> Self {
        Self {
            p: (0..MAX).collect::<Vec<usize>>(),
        }
    }
}

fn pow<M: std::ops::Mul + num_traits::One + Clone>(x: &M, n: usize) -> M {
    let mut p = n;
    let mut cur = x.clone();
    let mut ret = M::one();
    while p > 0 {
        if (p & 1) == 1 {
            ret = ret.clone() * cur.clone();
        }
        cur = cur.clone() * cur.clone();
        p >>= 1;
    }
    ret
}


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

ll mod = 1e9 + 7;

int main() {
  int N;
  cin >> N;

  vector<int> A(N);
  rep(i, N) cin >> A[i];

  vector<int> v(N, 0);
  rep(i, N) {
    int n = (N - 1 - A[i]) / 2;
    if (n < 0)
      continue;
    v[n]++;
  }

  if (N % 2 != 0 && v[N / 2] != 1) {
    cout << 0 << endl;
    return 0;
  }

  ll ans = 1;
  rep(i, N / 2) {
    if (v[i] != 2) {
      ans = 0;
      break;
    }

    ans *= v[i];
    ans %= mod;
  }

  cout << ans << endl;
}

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

using ll =                   long long int;
using pll =                  pair<ll, ll>;
#define endl                 "\n"
#define space                " "
#define TLE_na_ho            ios_base::sync_with_stdio(false);cin.tie(NULL)
#define MAX_SIZE             1024
#define MOD                  1000000007
#define pb                   push_back
#define fi                   first
#define se                   second
#define rep(i,a,n)           for(ll i=a;i<n;i++)
#define repe(i,a,n)          for(ll i=a;i<=n;i++)
#define repr(i,a,n)          for(ll i=a;i>=n;i--)
#define ain(arr,n)           for(ll i1=0;i1<n;i1++ ) cin>>arr[i1]
#define aout(arr,n)          for(ll i1=0;i1<n;i1++ ) cout<<arr[i1]<<space


int main()
{
    TLE_na_ho;
    //READ THE QUESTION PROPERLY!!
    ll t;
    t=1;
    //cin>>t;
    while(t--){
    	ll n;
    	cin>>n;
    	ll v[n];
    	ain(v,n);
    	ll c[n];
    	ain(c,n);

    	ll ans=0;
    	rep(i,0,n)
    	{
    		if(v[i]>c[i])
    			ans+=v[i]-c[i];
    	}

    	cout<<ans;
    }

}


Measured memory_bytes: 3692
m,d = map(int,input().split())

ans = 0

for i in range(2,m+1):
	for j in range(d+1):
		if i==j//10*(j-(j//10)*10) and j>=20 and j-(j//10)*10>=2:
			#print(i,j)
			ans = ans + 1
			#print(j//10,(j-(j//10)*10))
print(ans)

Measured memory_bytes: 38512
#include <bits/stdc++.h>
using intl = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define repd(i, n) for(intl i = (intl)(n); i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define repid(i, a, b) for(intl i = (intl)(a); i >= (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin,(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define int intl
#define itn intl
#define double ld
#define pb push_back
#define mp make_pair
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool flag){
    if(flag)cout << "Yes" << endl;
    else cout << "No" << endl;
}
void fp(bool flag, string s, string t){
    if(flag)cout << s << endl;
    else cout << t << endl;
}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl digit10(intl a){
    if(!a)return 1;
    intl b = 0;
    while(a){
        a /= 10;
        b++;
    }
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    intl n;
    cin >> n;
    intl a,b;
    cin >> a >> b;
    intl cnt = 0;
    if(a + n < b)cnt = b - n - a;
    else if(b + n < a)cnt = a - n - b;
    cout << cnt << 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;
typedef long long int ll;
typedef pair<ll, ll> P;
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; }

ll bit[70];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, k;
    cin >> n >> k;
    rep(i,n){
        ll a;
        cin >> a;
        rep(j,61){
            if(a>>j & 1) ++bit[j];
        }
    }
    ll ans = 0, two = 1;
    rep(j,60) two *= 2LL;
    for(int j = 60; j >= 0; --j){
        if(k < two){
            ans += two * bit[j];
            two /= 2;
            continue;
        }
        if(bit[j] <= n - bit[j]){
            ans += two * (n - bit[j]);
            k -= two;
        }
        else{
            ans += two * bit[j];
        }
        two /= 2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
using namespace std;
using ll=long long;
ll gcd(ll a, ll b){
  if(a<b){ll t=a; a=b; b=t;}
  if(a%b==0) return b;
  else return gcd(b, a%b);
}
int main(){
  ll a, b;
  cin >> a >> b;
  cout << (a*b)/gcd(a, b);
  return 0;
}

Measured memory_bytes: 256
n=int(input())
s=input()
x=[]
abc='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
for i in range(len(s)):
    idx=abc.find(s[i])
    x.append(abc[(idx+n)%26])
for i in range(len(s)):
    print(x[i],end='')
print()

Measured memory_bytes: 43504
import java.util.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main {

	int INF = 1 << 28;
	int w, h;
	Point s, g;
	
	int[][] map;
	boolean[][] visited;
	
	int dpx[] = {4, 2};
	int dpy[] = {2, 4};
	int dx[] = {-1,0,1,0};
	int dy[] = {0,-1,0,1};
	
	void run() {
		Scanner sc = new Scanner(System.in);
		for(;;) {
			w = sc.nextInt();
			h = sc.nextInt();
			if(w == 0 && h == 0) break;
			s = new Point(sc.nextInt(), sc.nextInt());
			g = new Point(sc.nextInt(), sc.nextInt());
			int n = sc.nextInt();
			
			map = new int[h+2][w+2];
			visited = new boolean[h+2][w+2];
			
			for(int i=0;i<n;i++) {
				int c = sc.nextInt();
				int d = sc.nextInt();
				int x = sc.nextInt();
				int y = sc.nextInt();
				for(int j=x;j<x+dpx[d];j++) for(int k=y;k<y+dpy[d];k++)
					map[k][j] = c;
			}
//			for(int i=0;i<h;i++) {
//				for(int j=0;j<w;j++) System.out.print(map[i+1][j+1] + " ");
//				System.out.println();
//			}
			if(dfs()) System.out.println("OK");
			else System.out.println("NG");
		}
	}
	
	boolean isGoal(Point p) {
		return p.x == g.x && p.y == g.y;
	}
	boolean dfs() {
		LinkedList<Point> queue = new LinkedList<Point>();
		queue.add(s);
		if( map[s.y][s.x] == 0) return false;
		while(!queue.isEmpty()) {
			Point p = queue.removeFirst();
//			System.out.println(p.x + " " + p.y + " " + map[p.y][p.x]);
			visited[p.y][p.x]= true; 
			if(isGoal(p)) return true;
			
			for(int i=0;i<4;i++) {
				if(!visited[p.y+dy[i]][p.x+dx[i]] && map[p.y+dy[i]][p.x+dx[i]] == map[s.y][s.x])
					queue.addLast(new Point(p.x+dx[i], p.y+dy[i]));
			}
		}
		
		return false;
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
	
	class Point {
		int x, y;
		Point(int x, int y) {
			this.x = x;
			this.y = y;
		}
	}
}

Measured memory_bytes: 0
<?php

$n = trim(fgets(STDIN));

$count = 0;

for($i=0; $i<$n; $i++) {
    fscanf(STDIN, "%d %d", $a, $b);
    if ($a == $b) {
        $count++;
        if ($count >= 3) {
            break;
        } else {
            continue;
        };
    } elseif ($a != $b) {
        $count = 0;
    }
}

if ($count >= 3) {
    echo "Yes" . PHP_EOL;
} else {
    echo "No" . PHP_EOL;
}

Measured memory_bytes: 16208
#include <bits/stdc++.h>
#include<algorithm>
#include<cmath>
using namespace std;
int main() 
{
    int n;
    string m;
    cin >> n >> m;
    int dp[n+1][n+1];
    int ans = 0;
    memset(dp,0,sizeof(dp));
    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            if(m.at(i-1)==m.at(j-1)&&dp[i-1][j-1]<(j-i)){
                dp[i][j] = dp[i-1][j-1]+1;
                ans = max(ans,dp[i][j]);
            }
            else{
                dp[i][j] = 0;
            }
        }
    }
    cout << ans;
    std::cin.get();
}


Measured memory_bytes: 97920
#include <bits/stdc++.h>
using namespace std;
 
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef pair<int,ii> iii;
typedef pair<int, iii> iiii;
typedef pair<double, ii> dii;
typedef long long ll;
typedef pair<ll, ii> lii;
const int INF = 1000000000;
const double EPS = 1e-9;
#define LSOne(S) (S & (-S))
int mods(int a, int b) { return (b + (a%b)) % b; }


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    ll a, b;

    cin >> a >> b;

    if ((a+b) & 1) cout << "IMPOSSIBLE\n";
    else cout << (a+b)/2 << '\n';

    return 0;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(readline())
AB = list(map(int,read().split()))

A = AB[:N+1]; B = AB[N+1:]

B.append(0)
rest = 0
answer = 0
for a,b in zip(A,B):
    x = rest if rest < a else a
    answer += x; a -= x
    x = a if a<b else b
    answer += x; rest = b-x

print(answer)

Measured memory_bytes: 21984
import numpy as np
H,W,A,B=np.array(list(map(int, input().split())))

for row in range(H):
    if  row<=B-1:
        print(''.join(list(map(str, [1 if i<=A-1 else 0 for i in range(W)]))))
    else:
        print(''.join(list(map(str, [0 if i<=A-1 else 1 for i in range(W)]))))

Measured memory_bytes: 15208
import sys
sys.setrecursionlimit(100000000)


def main():
    solve()


def solve():
    for data in get_dataset():
        print search(data)


def search(data):
    count = 0
    H = len(data)
    W = len(data[0])
    for i in xrange(H):
        for j in xrange(W):
            if data[i][j] == '.':
                continue
            _search(i, j, H, W, data[i][j], data)
            count += 1
    return count


def _search(i, j, H, W, cell, data):
    data[i][j] = '.'
    for a in xrange(i-1, i+2):
        if not -1 < a < H:
            continue
        for b in xrange(j-1, j+2):
            if not -1 < b < W:
                continue

            if a != i and b != j:
                continue

            if data[a][b] == '.':
                continue

            if cell == data[a][b]:
                _search(a, b, H, W, cell, data)
    return


def get_dataset():
    dataset = []
    while True:
        line = raw_input().rstrip().split()
        H = int(line[0])
        if H == 0:
            break

        data = []
        for i in xrange(H):
            data.append(list(raw_input().rstrip()))
        dataset.append(data)
    return dataset


if __name__ == '__main__':
    main()

Measured memory_bytes: 15764
_ = input()
a, b = [int(i) for i in input().split()]
P = [int(i) for i in input().split()]

cnt = {0:0, 1:0, 2:0}

for p in P:
  if p <= a:
    cnt[0] += 1
  elif p <= b:
    cnt[1] += 1
  else:
    cnt[2] += 1

print(min(cnt.values()))

Measured memory_bytes: 8964
#include <bits/stdc++.h>
#define REP(i,n)   for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(long long i=(a);((a)<(b)?i<=(b):i>=(b));((a)<(b)?++i:--i))
#define ALL(v)     (v).begin(),(v).end()
#define debug(x)   cerr<<#x<<": "<<(x)<<endl
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
constexpr int    INF=1e9;
constexpr double EPS=1e-9;
constexpr int    MOD=1e9+7;
template<class Type>
void line(const Type &a){int cnt=0;for(const auto &elem:a){cerr<<(cnt++?' ':'>');cerr<<elem;}cerr<<endl;}

template<typename Type,typename Type_k>
Type ipow(Type n,Type_k k){//n^k. O(log n).
	if(k==0) return 1;
	Type res=ipow(n*n,k/2);
	if(k&1) res*=n;
	return res;
}

template<typename Type,typename Type_k>
llong nCk(Type n,Type_k k){
	if(n-k<k) k=n-k;
	llong res=1LL;
	REP(i,k) res=res*(n-i)/(i+1);
	return res;
}

int main(){//Refering other editorials.
	int n,p;
	cin>>n>>p;
	
	int cnt[2]={};
	REP(i,n){
		int a;
		cin>>a;
		cnt[a&1]++;
	}
	
	llong ans;
	llong tmp=ipow(2LL,cnt[0]);
	if(p==0){
		llong tmpp=0LL;
		for(int i=0;i<=cnt[1];i+=2) tmpp+=nCk(cnt[1],i);
		debug(tmpp);
		ans=tmp*tmpp;
	}else{
		if(cnt[1]==0) ans=0LL;
		else{
			llong tmpp=0LL;
			for(int i=1;i<=cnt[1];i+=2) tmpp+=nCk(cnt[1],i);
			debug(tmpp);
			ans=tmp*tmpp;
		}
	}
	
	cout<<ans<<endl;
}

Measured memory_bytes: 3564
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
# def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  x=I()
  if 400<=x<600:
    return 8
  elif 600<=x<800:
    return 7
  elif 800<=x<1000:
    return 6
  elif 1000<=x<1200:
    return 5
  elif 1200<=x<1400:
    return 4
  elif 1400<=x<1600:
    return 3
  elif 1600<=x<1800:
    return 2
  elif 1800<=x<2000:
    return 1

# main()
print(main())


Measured memory_bytes: 10664
#include <bits/stdc++.h>
#define ll  long long int
#define ull unsigned long long int 
#define pb  push_back
#define mp  make_pair
#define pii pair<int, int>
using namespace std;

const ll mod = 1e9+7;
const int N = 1e4;
const int K = 1e2;
string s;
int d;
ll dp[N+1][K+1] = {0};
bool check[N+1][K+1] = {0};

ll dp_recurse(int k, int remainder){
	//cout << k << " " << remainder << endl;
	if(k==0){
		if(remainder == 0){
			return 1;
		}
		return 0;
	}

	if(check[k][remainder] == 1){
		return dp[k][remainder];
	}

	ll sum = 0;
	for(int i=0;i<10;i++){
		sum = (sum + dp_recurse(k-1, (remainder - i%d + d)%d ) )%mod;
	}

	dp[k][remainder] = sum;
	check[k][remainder] = 1;
	return sum;
}

void solve(){
    //solve here//
	cin >> s;
	cin >> d;

	int remainder = 0;
	ll ans = 0;
	int len = s.size();
	for(int i=0;i<len-1;i++){
		int num = int(s[i]-'0');

		for(int j=0;j<num;j++){
			ans = (ans + dp_recurse(len-i-1, (-remainder - j%d + 3*d)%d ))%mod;
			//cout << ans << " " << len-i-1 << " " << j << endl;
		}

		remainder = (remainder + num)%d;
	}

	int num = int(s[len-1]-'0');
	for(int i=0;i<=num;i++){
		if((remainder+i)%d==0){
			ans = (ans+1)%mod;
		}
	}

	ans = (ans-1+mod)%mod;
	//cout << d << " " << s << endl;
	cout << ans << endl;
}


int main(){
    ll t=1;
    //cin >> t;
    while(t--){
        solve();
    }
}



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

using namespace std;

#define lli long long
#define ld long double
#define mod 1000000007 
#define set(n) cout << fixed << setprecision(n)    
#define fi first
#define se second
#define mp make_pair
#define pll pair<lli, lli>
#define endl '\n'

const double PI = acos(-1);
const double epsilon = 1e-7;  // floating point precision

bool check(int minSize, vector<int>& v, int k) {
    int kk = k;
    for(int i = 0; i < v.size(); i++) {
        kk -= (v[i] / minSize  - 1 + min(1, v[i] % minSize));
        if(kk < 0) {
            return false;
        }
    }
    return true;
}

signed main(void) {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, k;
    cin >> n >> k;
    vector<int> v(n);
    for(int i = 0; i < n; i++) {
        cin >> v[i];
    }
    int l = 1, r = 1e9;
    int ans = 1e9;
    while(l <= r) {
        int mid = (l + r) / 2;
        if(check(mid, v, k)) {
            ans = min(ans, mid);
            r = mid - 1;
        }
        else {
            l = mid + 1;
        }
    }         
    cout << ans << endl;
}


Measured memory_bytes: 3916
n = int(input())
a = list(map(int, input().split()))
# 偶数の要素が3でも5でも割り切れないかのbool
if any([(i % 3 != 0) and (i % 5 != 0) for i in a if not i % 2]):
    print('DENIED')
else:
    print('APPROVED')

Measured memory_bytes: 2940
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static Reader;
using static System.Math;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;

public static class P
{
    public static void Main()
    {
        var t1 = NextLong;
        var t2 = NextLong;
        var a1 = NextLong;
        var a2 = NextLong;
        var b1 = NextLong;
        var b2 = NextLong;
        var alast = a1 * t1 + a2 * t2;
        var blast = b1 * t1 + b2 * t2;
        if (alast == blast)
        {
            Console.WriteLine("infinity");
            return;
        }

        if (blast > alast)
        {
            var tmp1 = a1;
            var tmp2 = a2;
            a1 = b1;
            a2 = b2;
            b1 = tmp1;
            b2 = tmp2;
        }

        var max = Max(alast, blast);
        var abs = Abs(alast - blast);
        var valid = -1L;
        var invalid = max / abs + 10;
        while (invalid - valid > 1)
        {
            var mid = (invalid + valid) / 2;
            var diff = abs * mid;
            if (diff + a1 * t1 <= b1 * t1) valid = mid;
            else invalid = mid;
        }
        var res = valid * 2 + 1;
        if (abs * valid + a1 * t1 == b1 * t1) res--;
        Console.WriteLine(Max(0, res));
    }
}


static class Reader
{
    const int BUF_SIZE = 1 << 12;
    static Stream Stream = Console.OpenStandardInput();
    static byte[] Buffer = new byte[BUF_SIZE];
    static int ptr = 0;
    static void Move() { if (++ptr >= Buffer.Length) { Stream.Read(Buffer, 0, BUF_SIZE); ptr = 0; } }


    public static long NextLong
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        get
        {
            long res = 0; while (Buffer[ptr] < 48) Move();
            do { res = res * 10 + (long)(Buffer[ptr] ^ 48); Move(); } while (48 <= Buffer[ptr]);
            return res;
        }
    }
}

Measured memory_bytes: 13140
/*
    Author: Alam Khan
    AUST CSE 40th Batch

*/

#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef deque<ll> dl;
typedef stack<ll> stl;
typedef set<ll> sl;
typedef map<string, ll> msl;
typedef map<ll,ll> mll;
typedef tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
#define sf(n)     scanf("%lld",&n)
#define sff(n,m)     scanf("%lld %lld",&n,&m)
#define sfff(n,m,r)     scanf("%lld %lld %lld",&n,&m,&r)
#define sfs(n)     scanf("%s",n)
#define pf(n)     printf("%lld\n",n)
#define pff(n,m)     printf("%lld %lld\n",n,m)
#define pfff(n,m,r)     printf("%lld %lld %lld\n",n,m,r)
#define pfs(n)     printf("%s\n",n)
#define pfcs(i,n)     printf("Case %lld: %lld\n",i,n)
#define pb     push_back
#define prf     printf
#define inf     2e18
#define low     -1000000000000
#define PI        acos(-1.0)
#define rep1(i,n) for(i=1;i<n;i++)
#define rep0(i,n) for(i=0;i<n;i++)
#define rep(i,a,n) for(i=a;i<n;i++)
#define repe1(i,n) for(i=1;i<=n;i++)
#define repe0(i,n) for(i=0;i<=n;i++)
#define repe(i,a,n) for(i=a;i<=n;i++)
#define endl  "\n"
#define FAST  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fr freopen("input.txt","r",stdin)
#define fw freopen("output.txt","w",stdout)

int main()
{
    ll i,n,t,k,j,x=0,y=0,m;
    cin>>x>>y;
    if(x*2==y || x*4==y)
    {
        cout<<"Yes"<<endl;
        return 0;
    }
    while(x>0 && x*2!=y)
    {
        x--;
        y-= 4;
    }
    if(x*2==y)
    {
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
    return 0;
}



Measured memory_bytes: 3652
/*
Author: CNYALI_LK
LANG: C++
PROG: E.cpp
*/
#include<bits/stdc++.h>
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define all(x) x.begin(),x.end()
using namespace std;
const double eps=1e-8;
const double PI=acos(-1.0);
typedef long long ll;
template<class T>void chkmin(T &a,T b){a=a<b?a:b;}
template<class T>void chkmax(T &a,T b){a=a>b?a:b;}
template<class T>T sqr(T a){return a*a;}
template<class T>T mmin(T a,T b){return a<b?a:b;}
template<class T>T mmax(T a,T b){return a>b?a:b;}
template<class T>T aabs(T a){return a<0?-a:a;}
#define min mmin
#define max mmax
#define abs aabs
const ll mod=998244353;
ll p[233];
struct zb{
	ll x,y;
};
zb a[233];
ll cmp(zb a,zb b){return a.x<b.x||a.x==b.x&&a.y<b.y;}
int main(){
#ifdef cnyali_lk
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
#endif
	ll n,ans;
	scanf("%lld",&n);
	p[0]=1;
	for(ll i=1;i<=n;++i){p[i]=p[i-1]<<1;if(p[i]>=mod)p[i]-=mod;scanf("%lld%lld",&a[i].x,&a[i].y);}
	sort(a+1,a+n+1,cmp);
	ans=p[n]-n-1;
	for(ll i=1;i<=n;++i)for(ll j=i+1;j<=n;++j){
		ll no=0;
		for(ll k=1;k<j;++k)if(k!=i&&(a[j].x-a[i].x)*(a[i].y-a[k].y)==(a[j].y-a[i].y)*(a[i].x-a[k].x)){no=1;break;}
		if(!no){
///			debug("(%lld,%lld) (%lld,%lld)",a[i].x,a[i].y,a[j].x,a[j].y);
			ll tot=2;
			for(ll k=j+1;k<=n;++k){
				if((a[j].x-a[i].x)*(a[i].y-a[k].y)==(a[j].y-a[i].y)*(a[i].x-a[k].x)){++tot;/*debug(" (%lld,%lld)",a[k].x,a[k].y);*/}
			}
//			debug("\n");
			ans-=p[tot]-tot-1;
		}
	}	
	printf("%lld\n",(ans%mod+mod)%mod);
	return 0;
}



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

int main()
{
	long long int A,B,K;
	cin>>A>>B>>K;
	if(K<=A)
	{
		A=A-K;
		cout<<A<<" "<<B<<endl;
	}
	else if(K>A && K<=(A+B))
	{
		long long int  temp=K-A;
		A=0;
		B=B-temp;
		cout<<A<<" "<<B<<endl;
		
	}
	else 
	{
		cout<<"0 0\n";
			}
	
	
	return 0;
}

Measured memory_bytes: 256
// finish date: 2018/2/10

#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>>
        vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
typedef vector<vector<vector<double>>> vvvd;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, pair<int, int>> plii;
const int bigmod = 998244353;//1000000007;
const int INF = 1050000000;
const long long INFll = 100000000000000000;


//足し算
int add(int a, int b) {
    return (int) (((ll) a + b + bigmod) % bigmod);
}

//引き算
int sub(int a, int b) {
    return (int) (((ll) a - b + bigmod) % bigmod);
}

//掛け算
int mul(int a, int b) {
    return (int) (((ll) (a % bigmod) * (b % bigmod)) % bigmod);
}

int modpow(int a, int b) {
    if (b == 0) return 1;
    int temp = modpow(a, b / 2);
    if (b % 2 == 1) return mul(mul(temp, temp), a);
    else {
        return mul(temp, temp);
    }
}

//割り算(分母だけ)  -  逆元(求めたい数とbigmodを渡す)
int divide(int a, int p = bigmod, int b = -1) {
    if (b < 0) b = p - 2;  //int gyakugen(int a, int p, int b = p - 2とできなかったため。)
    if (b == 0) return 1;
    else if (b % 2 == 0) {
        int d = divide(a, p, b / 2);
        return mul(d, d);
    } else {
        return mul(a, divide(a, p, b - 1));
    }
}

vi fact;


//nやkが大きな場合nCkをO(1)で求めるようにプログラムを適切に変更する。
int nCk_gyakugen(int n, int k, int p = bigmod) {
    if (k == 0) return 1;
    if (n == 0) 0;
    if (n < k) return 0;
    int denominator = fact[n];
    int molecule1 = fact[k];
    int molecule2 = fact[n - k];
    return mul(denominator, mul(divide(molecule1), divide(molecule2)));
}

int main() {
    string S;
    cin >> S;
    unsigned int N = S.length();
    fact = vi(N + 1);
    fact[0] = 1;
    FOR(i, 1, fact.size()) {
        fact[i] = mul(fact[i - 1], i);
    }
    int R = 0, B = 0;
    vvi dp(N + 1, vi(N + 1, 0));
    dp[0][0] = 1;
    rep(i, N) {
        switch (S[i]) {
            case '0':
                R += 2;
                break;
            case '1':
                R += 1;
                B += 1;
                break;
            case '2':
                B += 2;
                break;
            default:
                break;
        }
        rep(j, N) {
            if (j + 1 <= R) {
                dp[i + 1][j + 1] = add(dp[i + 1][j + 1], dp[i][j]);
            }
            if ((i + 1) - j <= B) {
                dp[i + 1][j] = add(dp[i + 1][j], dp[i][j]);
            }
        }
    }

    int ans = 0;
    rep(i, N + 1) {
        ans = add(ans, mul(dp[N][i], nCk_gyakugen(N, R - i)));
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 16000
fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();

    for c in s.chars() {
        match c {
            'P' => {
                print!("P");
            }
            'D' => {
                print!("D");
            }
            '?' => {
                print!("D");
            }
            _ => {}
        }
    }
}

Measured memory_bytes: 2280
#include<stdio.h>
#include<string.h>
int main(){
	int n,a,b;
	int max=-1E9,tmp;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d %d",&a,&b);
		if(a>=max){
			max=a;
			tmp=b;
		}
	}
	printf("%d\n",max+tmp);
	return 0;
}

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

using namespace std;

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef int64_t ll; typedef vector<int> VI; typedef pair<int,int> pii;
const ll mod = 1e9+7;

	ll lcm(ll x, ll y){ return (x  / __gcd(x, y) * y ); }

int main()
{
	
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >>n;
	ll ans = 1LL;
	rep(i,n){
		ll t; cin >>t;
		ans = lcm(ans, t);
	}
	cout << ans <<"\n";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <list>
#include <cctype>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)

locale l = locale::classic();

int main(){
    int a,b,t;
    cin >> a >> b >> t;
    cout << b*(t/a) << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <ctime>

#define Rep(i, n) for (int i = 1; i <= n; i ++)
#define Rep0(i, n) for (int i = 0; i <= n; i ++)
#define RepG(i, x) for (int i = head[x]; i; i = edge[i].next)
#define v edge[i].to
#define mp(a, b) make_pair(a, b)

using namespace std;

typedef long long LL;
const int N = 4010;
const int mod = 1e9 + 7;
int f[N][N][2], s[N][N];

int main()
{
	int n, m, k;
	scanf("%d%d%d", &n, &m, &k);
	f[0][0][0] = 1;
	Rep0(i, n) s[0][i] = 1;
	LL ans = 0;
	Rep(i, max(n, m) * 2) {
		Rep0(j, n){
			f[i][j][0] = (f[i - 1][j][0] + f[i - 1][j][1]) % mod;
			if (j){
				if (j - k >= 0) f[i][j][1] = (s[i - 1][j - 1] - s[i - 1][j - k] + mod) % mod;
				else f[i][j][1] = s[i - 1][j - 1];
			}
			s[i][j] = (f[i][j][0] + f[i][j][1]) % mod;
			if (j) s[i][j] = (s[i][j] + s[i][j - 1]) % mod;
		}
		Rep(j, n) if (j % (k - 1) == n % (k - 1) && ((k - 1) * i - j + 1) <= m && ((k - 1) * i - j + 1) % (k - 1) == m % (k - 1)){
			ans = (ans + f[i][j][1]) % mod;}
	}
	printf("%lld\n", ans);
	
	return 0;
}

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

#define CEIL(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))

using namespace std;
using ll = long long;
using pii = pair<int, int>;

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'000'000'001;
constexpr ll LLINF = 4'000'000'000'000'000'001;
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int n, k;
    cin >> n >> k;
    double p = 0;
    for(int i = 1; i <= n; ++i){
        int t = i;
        double pp = (double)1 / n;
        while(t < k){
            t *= 2;
            pp *= 0.5;
        }
        p += pp;
    }
    cout << p << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //int:2*10**9
typedef long double ld;
typedef pair<ll,ll> P;
#define REP(i,n) for(ll i = 0; i<(ll)(n); i++)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define vec2(name,i,j,k) vector<vector<ll>> name(i,vector<ll>(j,k))
#define vec3(name,i,j,k,l) vector<vector<vector<ll>>> name(i,vector<vector<ll>>(j,vector<ll>(k,l)))
#define pb push_back
#define MOD 1000000007 //998244353
#define PI 3.141592653
#define INF 100000000000000 //14
//cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
int main(){
    ll x; cin >> x;
    cout << (2199-x)/200 << endl;
}

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

using namespace std;

#define ull unsigned long long
#define ll long long
#define int long long
#define ld long double

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

#define MX LLONG_MAX
#define MN LLONG_MIN

const ll mod=1e9+7;
const ll N=1e5+5;

ll powermodm(ll x,ll n,ll M){ll result=1;while(n>0){if(n % 2 ==1)result=(result * x)%M;x=(x*x)%M;n=n/2;}return result;}
ll power(ll _a,ll _b){ll _r=1;while(_b){if(_b%2==1)_r=(_r*_a);_b/=2;_a=(_a*_a);}return _r;}
ll gcd(ll a,ll b){if(a==0)return b;return gcd(b%a,a);}          
ll lcm(ll a,ll b){return (max(a,b)/gcd(a,b))*min(a,b);}

int32_t main()                  
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,c=0;
    cin>>n;
    ll a[n];
    for(ll i=0;i<n;i++)
        cin>>a[i];
    for(ll i=1;i<n-1;i++)
    {
        vector<ll> v;
        v.pb(a[i-1]);
        v.pb(a[i]);
        v.pb(a[i+1]);
        sort(v.begin(),v.end());
        if(v[1]==a[i])
            c++;
    }
    cout<<c;
    return 0;
}

Measured memory_bytes: 256
// AtCoder Beginner Contest 127 - Problem C: Prision (https://abc127.contest.atcoder.jp/tasks/abc127_c) 
#include <bits/stdc++.h>

using namespace std;

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

    int N, M;
    cin >> N >> M;

    int L, R;
    cin >> L >> R;

    int a = L, b = R;

    while (--M)
    {
        cin >> L >> R;

        a = max(a, L);
        b = min(b, R);

        if (b < a)
        {
            cout << 0 << endl;
            return 0;
        }
    }

    cout << b - a + 1 << '\n';

    return 0;
}


Measured memory_bytes: 256
//yukicoder@cpp14
//author:luckYrat(twitter:@luckYrat_)
//競技プログラミングから逃げるな
//https://www.youtube.com/watch?v=z_B9iJ8r4ic

//せんげん！
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <bitset>

#include <cctype>
#include <utility>
#include <climits>


//なまえくーかん！
using namespace std;
using ll = long long;
using P = pair<ll,ll>;

//てーすう！
const int mod = 1000000007;
const int inf = (1<<30)-1;
const ll linf = (1LL<<62LL)-1;
const double EPS = (1e-10);

//でふぁいん！
#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)

//みじかく！
#define pb push_back
#define fir first
#define scn second
#define ednl endl

//いぇすのー！
#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")

//きんぼーnほーこー！！
P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる

計算量は変わらないが楽できるシリーズ
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる
*/
int nw[200001];
int ans[200001];
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}
int main(){
  int n;cin>>n;
  int a[n];
  for(int i = 1; n >= i; i++){
    cin>>a[i];
  }
  int k = 0;
  for(int i = n; 0 < i; i--){
    if(nw[i]!=a[i]){
      ans[i]=1;
      k++;
      nw[i]=(nw[i]+1)%2;
      nw[1]=(nw[1]+1)%2;
      for(int j = 2; i >= j*j; j++){
        if(!(i%j)){
          nw[j]=(nw[j]+1)%2;
          if(j*j!=i)nw[i/j]=(nw[i/j]+1)%2;
        }
      }
    }
  }
  cout << k << endl;
  if(!k)return 0;
  
  for(int i = 1; n >= i; i++){
    if(ans[i]==1){
      cout << i;k--;
      if(k)cout << " ";
    }
  }
  cout << endl;
}

Measured memory_bytes: 3200
def find_num(lst, value):
    return [i for i, x in enumerate(lst) if x == value]

def resolve():
    X,N = map(int,input().split())
    if N == 0:
        print(X)
    else:
        p = list(map(int,input().split()))
        p.sort()
        idx = find_num(p,X)
        if idx == []:
            print(X)
        else:
            for i in range(1,100):
                if p[idx[0] - i ] != X - i or idx[0] - i == -1:
                    print(X-i)
                    break
                if idx[0] + i == N:
                    print(X+i)
                    break
                elif p[idx[0] + i ] != X + i:
                    print(X+i)
                    break
resolve()

Measured memory_bytes: 9220
#include <iostream>
#include <string>
#include <vector>
#include <tuple>
#include <algorithm>
#include <cmath>
#include <cstdio>

using namespace std;

int main() {
    int A, B;
    cin >> A >> B;
    if (A < 10 && B < 10) {
        cout << A * B;
    } else {
        cout << -1;

    }

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
    char ch;
    int x,c[26]= {0};
 
    while(scanf("%c",&ch)!=EOF)
    {
        if(ch>='A' && ch<='Z')
        {
            x=ch-'A';
            c[x]+=1;
        }
        else if(ch>='a' && ch<='z')
        {
            x=ch-'a';
            c[x]+=1;
        }
    }
 
    for(x=0,ch='a'; x<26; x++,ch++)
    {
        printf("%c : %d\n",ch,c[x]);
    }
    return 0;
}


Measured memory_bytes: 2148
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cmath>
#include<string>
#include <sstream>
using namespace std;
 
typedef long long ll;


string toString(int i){
	std::string out_string;
	std::stringstream ss;
	ss << i;
	out_string = ss.str();
	return out_string;
}

int main(){
	
	int n;
	cin >> n;
	
	int cnt = 0;
	for(int i=1;i<=n;++i){
		
		if(toString(i).size()%2 == 1) cnt++;
	}
	cout << cnt <<endl;
	
	return 0;
}


Measured memory_bytes: 256
N = gets.to_i
class S
	def initialize(s)
		@l = 2 ** (N - 1).bit_length
		@heap = Array.new(@l * 2){0}
		a = "a".ord
		N.times{|i|
			@heap[@l + i] = 1 << (s[i].ord - a)
		}
		(@l - 1).downto(1){|i|
			@heap[i] = @heap[i * 2] | @heap[i * 2 + 1]
		}
		#warn @heap.map{|i|"%x" % i}.inspect
	end
	def replace(i, c)
		#warn "replace(#{i}, #{c})"
		l = @l + i
		c = 1 << (c.ord - "a".ord)
		return if @heap[l] == c
		@heap[l] = c
		l >>= 1
		while l > 0
			tmp = @heap[l]
			@heap[l] = @heap[l * 2] | @heap[l * 2 + 1]
			break if tmp == @heap[l]
			l >>= 1
		end
		#warn @heap.inspect
	end
	def count_r(l, r, n = 1, min = 0, max = @l - 1)
		#warn "count_r(#{l}, #{r}, #{n}, #{min}, #{max})"
		if l <= min and r >= max
			return @heap[n]
		end
		result = 0
		c = (min + max+ 1) / 2
		if l < c
			result |= count_r(l, r, n * 2, min, c - 1)
		end
		if r >= c
			result |= count_r(l, r, n * 2 + 1, c, max)
		end
		result
	end
	def count(l, r)
		b = count_r(l, r)
		c = 0
		while b > 0
			c += 1 if b & 1 == 1
			b >>= 1
		end
		c
	end
end
$s = S.new(gets)
Q = gets.to_i
Q.times{
	q = gets.split
	case q[0]
	when "1"
		$s.replace(q[1].to_i - 1, q[2])
	when "2"
		puts $s.count(q[1].to_i - 1, q[2].to_i - 1)
	end
}


Measured memory_bytes: 10648
#include <iostream>
#include <string>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <tuple>
#include <sstream>
#include <typeinfo>
#include <fstream>
#include <random>
#include <queue>
#include <deque>
#include <iterator>
#include <map>
using namespace std;



int main()
{
	ios::sync_with_stdio(0);
	int K, S;
	cin >> K >> S;

	int cnt = 0;
	for (int x = 0; x <= min(S,K); ++x) {
		for (int y = 0; y <= min(S - x,K); ++y) {
			int z = S - x - y;
			if (0 <= z and z <= K) {
				cnt++;
			}
		}
	}

	cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256