akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		int N = int.Parse(str[0]);
		int Q = int.Parse(str[1]);
		string s = Console.ReadLine();
		int[]A = new int[N];
		for(var i=1;i<N;i++){
			if(s.Substring(i-1,2)=="AC"){
				A[i] = A[i-1]+1;
			} else {
				A[i] = A[i-1];
			}
		}
		for(var i=0;i<Q;i++){
			string[] str2 = Console.ReadLine().Split();
			int L = int.Parse(str2[0]);
			int R = int.Parse(str2[1]);
			int ans = A[R-1]-A[L-1];
			Console.WriteLine(ans);
		}
	}
}

Measured memory_bytes: 16328
//#define LOCAL

#include <fstream>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <cstring>
#include <climits>
#include <set>

//#define int long long
//typedef long long ll;
using ll = long long;
using R = double;

//#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,bg,ed) for(ll i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)

#define MOD 1000000007

using namespace std;

typedef vector<int> V;
typedef vector<V> VV;



signed main()
{
    int N;
    string S;

    cin >> N;
    cin >> S;
    bool update = true;
    while (update) {
        update = false;
        int open = 0;
        REP(i,S.length()) {
            if (S[i] == '(') {
                open++;
            } else {
                open--;
                if (open < 0) {
                    S = '(' + S;
                    update = true;
                    break;
                }
            }
        }
    }

    update = true;
    while (update) {
        update = false;
        int close = 0;
        for (int i=S.length()-1; i>=0; i--) {
            if (S[i] == ')') {
                close++;
            } else {
                close--;
                if (close < 0) {
                    S = S + ')';
                    update = true;
                    break;
                }
            }
        }
    }

    cout << S << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define MAX 1000010

int main(){
	bool prime[MAX];
	prime[0]=prime[1]=0;
	for(int i=0;i<MAX;i++){
		prime[i]=1;
	}
	prime[0]=prime[1]=0;
	for(int i=2;i<MAX;i++){
		if(prime[i]==1){
			for(int j=2;i*j<MAX;j++){
				prime[i*j]=0;
			}
		}
	}
	int prime_under_num[MAX];
	prime_under_num[0]=0;
	for(int i=1;i<MAX;i++){
		prime_under_num[i]=prime_under_num[i-1]+prime[i];
	}
	
	int n;
	while((scanf("%d",&n))!=EOF){
		printf("%d\n",prime_under_num[n]);
	}
	
	
}

Measured memory_bytes: 5908
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#include<cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
#define sz size()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;

ll dp[110][110];

string query(int n){
    cout << n << endl;
    fflush(stdout);
    string res;
    cin >> res;
    if(res == "Vacant")exit(0);
    return res;
}

int main(){
    int n;
    cin >> n;
    int l = 0, r = n - 1;
    string x = query(l);
    string y = query(r);
    while(1){
        int mid = (l + r) / 2;
        string z = query(mid);
        if((z == x) != (l % 2 == mid % 2)){
            r = mid;
            y = z;
        }
        else {
            l = mid;
            x = z;
        }
    }
}

Measured memory_bytes: 3836
#include "bits/stdc++.h"
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--)
#define chmin(a,b) (a)=min((a),(b));
#define chmax(a,b) (a)=max((a),(b));
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) cerr<<(#v)<<":";for(auto(x):(v)){cerr<<" "<<(x);}cerr<<endl;
#define printVS(vs) cerr<<(#vs)<<":"<<endl;for(auto(s):(vs)){cerr<<(s)<< endl;}
#define printVV(vv) cerr<<(#vv)<<":"<<endl;for(auto(v):(vv)){for(auto(x):(v)){cerr<<" "<<(x);}cerr<<endl;}
#define printP(p) cerr<<(#p)<<(p).first<<" "<<(p).second<<endl;
#define printVP(vp) cerr<<(#vp)<<":"<<endl;for(auto(p):(vp)){cerr<<(p).first<<" "<<(p).second<<endl;}

inline void output(){ cerr << endl; }
template<typename First, typename... Rest>
inline void output(const First& first, const Rest&... rest) {
    cerr << first << " "; output(rest...);
}

using ll = long long;
using Pii = pair<int, int>;
using TUPLE = tuple<int, int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vp = vector<Pii>;
const int inf = 1ll << 60;
const int mod = 1e9 + 7;
using Graph = vector<vector<int>>;

string s;
vvi dp;

int rec(int i, int f) {
  if (dp[i][f] != -1) return dp[i][f];
  if (f == 1) {
    return dp[i][f] = (3 * rec(i+1, f)) % mod;
  }
  else {
    if (s[i] == '0') {
      return dp[i][f] = rec(i+1, f);
    }
    else {
      int x = rec(i+1, 1);
      int y = (2 * rec(i+1, 0)) % mod;
      return dp[i][f] = (x + y) % mod;
    }
  }
}

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

  cin >> s;
  int n = s.size();

  // 0: '=', 1:'<'
  dp.resize(n+1, vi(2, -1));
  dp[n][0] = 1;
  dp[n][1] = 1;

  cout << rec(0, 0) << endl;
}


Measured memory_bytes: 10576
#define _CRT_SECURE_NO_WARNINGS

#include<bits/stdc++.h>

using namespace std;

#define PI			3.14159265
#define OO			1e9
#define SS       	second
#define FF       	first
#define Trace(n)  	cout<< #n <<" = "<< n << endl; 
#define ll			long long
#define endl		"\n"
#define EPS		    1e-9
//#define MOD         1e9 + 7	    
int dx[] = { 0, 0, -1, 1, 1, 1, -1, -1 };
int dy[] = { -1, 1, 0, 0, 1, -1, 1, -1 };

void fast()
{
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
}


int main()
{
	fast();

	int n;

	cin >> n;

	vector<int> v(n);

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

	int mx_indx, mx;
	int mn_indx, mn;

	mx = 0;
	mn = 0;

	for (int i = 0; i < n; i++)
	{
		if (v[i]>mx)
			mx = v[i], mx_indx = i;
	}

	for (int i = 0; i < n; i++)
	{
		if (i == mx_indx)
			continue;

		if (v[i] <= mx)
		{
			if (v[i]>mn)
			{
				mn = v[i];
				mn_indx = i;
			}
		}
	}
	for (int i = 0; i < n; i++)
	{
		if (i == mx_indx)
			cout << v[mn_indx] << endl;
		else
			cout << v[mx_indx] << endl;
	}
}

Measured memory_bytes: 2432
#include <bits/stdc++.h> 
#define int long long
#define quickie ios_base::sync_with_stdio(false); cin.tie(NULL);
#define rep(i, a, b) for(int i=a; i<b; i++)
#define rep1(i, a, b) for(int i=a; i<=b; i++)
#define repp(i, a, b) for(int i=b-1; i>=a; i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define db double
#define mi map<int, int>
#define mc map<char, int>
#define ms map<string, int>
#define vi vector<int>
#define qi queue<int>
#define MI(x) power(x, mod-2)
#define test int t; cin >> t;
//#define mod 1000000007LL
#define mod 998244353 
using namespace std;
int power(int x, int y) ;
int gcd(int a, int b) ;

signed main() {
    quickie
    string s ;
    cin >> s ;
    sort(s.begin(), s.end()) ;
    if(s[0] == s[1] && s[2] == s[3] && s[1] != s[2]) cout << "Yes\n" ;
    else cout << "No\n" ;
}

int power(int x, int y) {
    int res = 1; x %= mod;
    while (y > 0) {
        if (y & 1)
            res = (res*x) % mod;
        y = y>>1;
        x = (x*x) % mod;
    }
    return res%mod;
}
 
int gcd(int a,int b){
    if(a==0) return b;
    return gcd(b%a,a);
}

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

string s, t, u;
int a, b;

int main(){
  cin >> s >> t;
  cin >> a >> b;
  cin >> u;
  if (s == u){
    cout << (a-1) << ' ' << b;
  }
  else{
    cout << a << ' ' << (b-1);
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define pb push_back
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef pair<ll, int> plli;
typedef vector<pii> vpii;
typedef tree<pii, null_type, less<pii>, rb_tree_tag,
    tree_order_statistics_node_update> ost;

const int N=110000;
const int B=2500;
const ll LIMIT=1e11;
ll es[B], p[B], np;
unordered_map<ll, ll> cnt;
unordered_map<ll, ll> dop;

int main() {
    ll i, j, k, n, r, s, t, q, ans=0;
    scanf("%lld", &n);
    for(i=2; i<B; i++) if(!es[i]) {
        p[np++]=i;
        for(j=i; j<B; j+=i) es[j]=1;
    }
    for(i=0; i<n; i++) {
        scanf("%lld", &t);
        q=r=1;
        for(j=0; j<np; j++) {
            for(k=0; t%p[j]==0; k++) t/=p[j];
            k%=3;
            if(k==1) q*=p[j]*p[j], r*=p[j];
            if(k==2) q*=p[j], r*=p[j]*p[j];
            if(q>LIMIT) q=0;
        }
        r*=t;
        s=sqrt(t);
        while(s*s>t) s--;
        while(s*s<t) s++;
        if(s*s==t) q*=s;
        else if(q*(double)t*t<LIMIT) q*=t*t;
        else q=0;
        cnt[r]++;
        if(!cnt.count(q)) cnt[q]=0;
        dop[r]=q;
        dop[q]=r;
    }
    for(auto z:cnt) {
        tie(t, s)=z;
        if(t==1) ans++;
        else if(t>dop[t])
            ans+=max(cnt[t], cnt[dop[t]]);
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 14608
#include<stdio.h>
int main()
{
    int A,B,C;

    scanf("%d %d %d", &A,&B,&C);

    int x = B/A;
    
    if(x < C){
        printf("%d\n",x);
    }else{
        printf("%d\n",C);
    }
    return 0;
}

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

const int INF = 1 << 17;

struct SegmentTree {
    vector<long long> dat;
    int n;
    

    SegmentTree(int i){
        n= 1;
        while(n < i){
            n *= 2;
        }
        dat.resize(2*n-1,INF);
    }

    void update(int k, long long a){
        k += n -1;
        dat[k] = a;
        while(k>0){
            k = (k-1)/2;
            dat[k] = min(dat[k*2+1],dat[k*2+2]);
        }
    }

    long long getVal(int k){
        k += n -1;
        return dat[k];
    }

    long long query(int a, int b){
        return queryRecursive(a,b,0,0,n);
    }

    private:
    long long queryRecursive(int a, int b,int k,int l,int r){
        if(r <= a || b <= l){
            return INF;
        }
        if(a<= l && r <= b){
            return dat[k];
        }
        long long vl = queryRecursive(a,b,k*2+1,l,(l+r)/2);
        long long vr = queryRecursive(a,b,k*2+2,(l+r)/2,r);
        return min(vl,vr);
    }
};


void solve(long long N, std::vector<long long> h, std::vector<long long> a){
    SegmentTree seg = SegmentTree(N);
    for(int i=0;i<N;i++){
        // cerr << "i=" << i << endl;
        long long minV = seg.query(0,h[i]);
        if(minV >0){
            seg.update(h[i], -a[i]);
            continue;
        }
        // cerr << "i=" << i << "h=" << h[i] <<"minV=" << minV << endl;
        seg.update(h[i], minV-a[i]);
    }
    long long ans =0;
    for(int i=0;i<N;i++){
        ans = max(ans,-seg.getVal(h[i]));
    }
    cout << ans << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> h(N);
    for(int i = 0 ; i < N ; i++){
        int a;
        cin >> a;
        a--;
        h[i] = a;
    }
    std::vector<long long> a(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&a[i]);
    }
    solve(N, std::move(h), std::move(a));
    return 0;
}


Measured memory_bytes: 7424
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using vll = vector<ll> ;
#define all(v) v.begin(),v.end()
#define MAX_V 210

int d[MAX_V][MAX_V];
int N;

int main(){
  int N,M,R;cin>>N>>M>>R;
  vector<int> r(R);rep(i,R){cin>>r[i];r[i]--;}
  rep(i,N)rep(j,N)d[i][j]=1e9;
  rep(i,M){
    int a,b,c;cin>>a>>b>>c;a--,b--;
    d[a][b] = c;
    d[b][a] = c;
  }
  rep(k,N){
    rep(i,N){
      rep(j,N){
        d[i][j] = min(d[i][j],d[i][k]+d[k][j]);
      }
    }
  }
  ll ans = 1e9;
  sort(all(r));
  do{
    ll ans_tmp = 0;
    rep(i,r.size()-1){
      ans_tmp += d[r[i]][r[i+1]];
    }
    ans = min(ans, ans_tmp);
  }while(next_permutation(all(r)));
  cout << ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll n;
  R n;
  ll a[5];
  rep(i,5) R a[i];
  sort(a,a+5);
  pr((ll)ceil((double)n/a[0])+4);
}

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


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

// 比較演算子を自動生成
#define CAT(a, b) a ## b
#define COMP_1(v1) return lhs.v1 < rhs.v1
#define COMP_2(v1, ...) if (lhs.v1 != rhs.v1) COMP_1(v1); COMP_1(__VA_ARGS__)
#define COMP_3(v1, ...) if (lhs.v1 != rhs.v1) COMP_1(v1); COMP_2(__VA_ARGS__)
#define COMP_4(v1, ...) if (lhs.v1 != rhs.v1) COMP_1(v1); COMP_3(__VA_ARGS__)
#define COMP_5(v1, ...) if (lhs.v1 != rhs.v1) COMP_1(v1); COMP_4(__VA_ARGS__)
#define LESS_THAN(n, ...) bool operator<(const A & rhs) const { auto& lhs = *this; CAT(COMP_, n)(__VA_ARGS__); }

#define MAXC(c, x) (c = max(c, x))
#define MINC(c, x) (c = min(c, x))

#define FOR(i, s, n) for(ll i = (s); i < (ll)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(c) (c).begin(), (c).end()

// 10^x (by math)
#define TEN(x) ((ll)1e##x)

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;

void solution(istream& cin, ostream& cout) {
	ll k; cin >> k;
	string s; cin >> s;
	if (s.size() <= k) {
		cout << s << endl;
	}
	else {
		cout << s.substr(0, k) << "..." << endl;
	}
}

int main() {
#ifdef INPUT_FROM_FILE
	ifstream cin("sample.in");
	ofstream cout("sample.out");
#endif
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(50);

	solution(cin, cout);
}


Measured memory_bytes: 3656
def g_c_d(x, y):
    if x == 0:
        return y
    elif y == 0:
        return x
    else:
        return g_c_d(y, x % y)


def l_c_m(x, y):
    return x * y // g_c_d(x, y)


a, b = map(int, input().split())
c = input()
d = input()
lcm = l_c_m(a, b)
gcd = g_c_d(a, b)
for i in range(0, gcd):
    if c[i * a // gcd] != d[i * b // gcd]:
        print(-1)
        exit()
print(lcm)


Measured memory_bytes: 3316
// author : Kartikey Tewari
// date: 2020-02-09   20:32:48
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define endl '\n'
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);

    string a;
    cin >> a;
    int b=a.length();
    for (int i=0;i<=b-1;i++)
    {
        cout << "x";
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
/**
 * author  : UshanGhosh
 * created : 2020-08-06 23:11:17
**/ 

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

#define    ll      long long
#define    pii     pair<int,int>
#define    vii     vector<int>
#define    vcc     vector<char>
#define    pll     pair<long long, long long>
#define    mem     memset
#define    sof     sizeof
#define    co1     __builtin_popcountll
#define    PB      push_back
#define    UB      upper_bound
#define    LB      lower_bound
#define    MP      make_pair
#define    TS      to_string
#define    F       first
#define    S       second
#define    endl    '\n'

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    long long a,b,c,d,e,f,i,j,k,m,n,o,x,y;
    cin>>n;
    if(n>=30) cout<<"Yes\n";
    else cout<<"No\n";
}

Measured memory_bytes: 3644
A, B = gets.split(' ').map(&:to_i)

grid = Array.new(50){'.' * 100} + Array.new(50){'#' * 100}
(B - 1).times do |i|
  grid[i / 25 * 2][(i % 25) * 2] = '#'
end
(A - 1).times do |i|
  grid[51 + i / 25 * 2][(i % 25) * 2] = '.'
end
puts "100 100"
puts grid

Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, K;
  cin >> A >> B >> C >> K;
  
  if(A > K){
    cout << K;
  }else if (A + B >= K){
  	cout << A;
  }else{
  	int ans = A;
    int num = K - A - B;
    ans -= num;
    cout << ans;
  }
}

Measured memory_bytes: 3632
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long ll;
int N;
int main() {
    cin>>N;

    int X,Y;
    X=N*800;
    Y=(N/15)*200;
    cout<<X-Y<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define ll long long int
#define fo(i,n) for(i=0;i<(n);i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define ps(x,y)         fixed<<setprecision(y)<<x
#define PI 3.1415926535897932384626
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pl;
typedef vector<int>     vi;
typedef vector<ll>      vl;
typedef vector<pii>     vpii;
typedef vector<pl>      vpl;
typedef vector<vi>      vvi;
typedef vector<vl>      vvl;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
//==============================================================================================================


int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());

    int x; cin>>x;
    if(x>=30)printf("Yes\n");
    else printf("No\n");
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define eb emplace_back
#define all(v) v.begin(),v.end()
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
const ll INF=1LL<<60;
template<class T> void chmin(T &a,T b){a=min(a,b);}
template<class T> void chmax(T &a,T b){a=max(a,b);}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	ll n,p;cin>>n>>p;
	string s;cin>>s;
	ll res=0;
	if(p==2){
		for(int i=0;i<n;i++){
			if((s[i]-'0')%2==0){
				res+=(i+1LL);
			}
		}
		cout<<res<<endl;
		return 0;
	}else if(p==5){
		for(int i=0;i<n;i++){
			if((s[i]-'0')%5==0){
				res+=(i+1LL);
			}
		}
		cout<<res<<endl;
		return 0;
	}
	reverse(all(s));
	vector<ll> cnt(p);
	ll t=1LL;
	ll sum=0;
	cnt[0]++;
	for(int i=0;i<n;i++){
		ll k=t*(s[i]-'0')%p;
		sum+=k;
		sum%=p;
		res+=cnt[sum];
		cnt[sum]++;
		t*=10LL;
		t%=p;
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 720
#include <stdio.h>


int main(void)
{	
	long n, i, a[10000], min=0, max, sum=0;

	scanf("%ld", &n );
	
	for(i=0; i<n; i++){
		scanf(" %ld", &a[i]);
		if(i==0){ min = a[i]; max = a[i];  }
		else{
			if(min > a[i]) min = a[i];
			if(max < a[i]) max = a[i];

		}
		sum = sum + a[i];
	}
	
	printf("%ld %ld %ld\n", min, max, sum);
	
	//getchar();
	//getchar();
	return 0;
}

Measured memory_bytes: 676
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int n, k;
  cin >> n >> k;
  cout << n - k + 1 << endl;
}


Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A
def A():
    return

#B
def B():
    return

#C
def C():
    n = I()
    v = LI()
    d = [defaultdict(int) for i in range(2)]
    for i in range(n):
        d[i%2][v[i]] += 1
    if len(d[0].keys()) == len(d[1].keys()) == 1:
        if d[0].keys() == d[1].keys():
            ans = n//2
        else:
            d = [list(d[i].values()) for i in range(2)]
            ans = sum(d[0])-max(d[0])+sum(d[1])-max(d[1])
    else:
        d = [sorted(list(d[i].items()),key = lambda x:-x[1]) for i in range(2)]
        if d[0][0][0] != d[1][0][0]:
            ans = -d[0][0][1]-d[1][0][1]
            for i in range(len(d[0])):
                ans += d[0][i][1]
            for i in range(len(d[1])):
                ans += d[1][i][1]
        else:
            ans = -d[0][0][1]-d[1][1][1]
            for i in range(len(d[0])):
                ans += d[0][i][1]
            for i in range(len(d[1])):
                ans += d[1][i][1]
            ans2 = -d[0][1][1]-d[1][0][1]
            for i in range(len(d[0])):
                ans2 += d[0][i][1]
            for i in range(len(d[1])):
                ans2 += d[1][i][1]
            ans = min(ans,ans2)
    print(ans)
#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == "__main__":
    C()


Measured memory_bytes: 67360
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<cmath>
#include<cstring>
#include<set>
#include<climits>
#include<deque>
#include <iomanip>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define all(a) a.begin(),a.end()
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define size(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
llfor;ll mod=1000000007;
/*pi*/double pi=acos(-1);
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll ans=1;rep(i,0,n){ans*=x;ans%=mod;}return ans;}
/*階乗*/ll fact(ll x){ll ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)*fact(n-r)/fact(r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
/*Fibonacci数列*/ll fib(ll x){ll fibo[x+10];fibo[0]=1;fibo[1]=1;fibo[2]=1;rep(i,3,x+1)fibo[i]=fibo[i-1]+fibo[i-2];return fibo[x];}
/*桁数*/ll dig(ll n){ll d=1,tmp=n;while(tmp/10>0){tmp/=10;d++;}return d;}
//ll ans=0;
////////////////////////////////////////////////////////////
int main(){
 ll a[5],k;
 rep(i,0,3)sc(a[i]);
 cin>>k;
// stirng s;cin>>s;
 ll ans;
 //a<b<c
 if(a[1]==0||a[2]==0){
  pn;return 0;
 }
 while(a[1]<=a[0]){
  a[1]*=2;
  ans++;
 // cout<<ans<<" "<<a[1]<<endl;
 }
 while(a[2]<=a[1]){
  a[2]*=2;
  ans++;
  //acout<<ans<<" "<<a[2]<<endl;
 }
 if(ans<=k){
  py;return 0;
 }
 pn; 
return 0;}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
using namespace std;
using ll = unsigned long long;
#define REP(i, n) for(ll i = 0; i < n; i++)
#define MOD (ll)(1e9 + 7)
int main(){
  ll n;
  cin >> n;
  vector<ll> a(n);
  REP(i, n){
    cin >> a[i];
  }
  vector<vector<ll>> c(63, vector<ll>(2));
  ll ans = 0;
  REP(i, n){
    REP(j, 63){
      ll f = (a[i] >> j) & 1LL;
      ans += c[j][f ^ 1] * ((1LL << j) % MOD) % MOD;
      c[j][f]++;
      ans %= MOD;
     }
  }
  cout << ans << endl;
}


Measured memory_bytes: 2560
from collections import deque
h,w=map(int,input().split())
l=[]
v=0

for _ in range(h):
  b=[0 if i=="." else 1 for i in input()]
  v+=b.count(1)
  l.extend([b])

dq=deque([])
dq.append((0,0,1))

while dq:
  x,y,d=dq.popleft()
  if x==w-1 and y==h-1:break
  for (dx,dy) in zip([-1,1,0,0],[0,0,-1,1]):
    nx=x+dx
    ny=y+dy
    if 0<=nx<w and 0<=ny<h and not l[ny][nx]:
      l[ny][nx]=2
      dq.append((nx,ny,d+1))

if x==w-1 and y==h-1:
  print(h*w-v-d)
else:
  print(-1)

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

using namespace std;

int main(){
	string str;
	string ans;
	getline(cin,str);
	for(int i=0;i<str.size();i++){
		str[i] = toupper(str[i]);
	}
	cout << str << endl;
	return 0;
}

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

class Program {
  static void Main() {
    int n = int.Parse(Console.ReadLine());
    Console.WriteLine(Input(n).Distinct().Count());
  }

  static IEnumerable<int> Input(int n) {
    while (n-- > 0) yield return int.Parse(Console.ReadLine());
  }
}

Measured memory_bytes: 13268
#include <algorithm>
#include <cstdio>
const int N=205,inf=100000;
int fst[N],cnt[N],d[N],S,T,nodes,tot=1;
char s[105];
struct Edge{
	int to,f,nxt;
}e[20010];
void add(int x,int y,int z){
	e[++tot].to=y;e[tot].f=z;e[tot].nxt=fst[x];fst[x]=tot;
	e[++tot].to=x;e[tot].f=z;e[tot].nxt=fst[y];fst[y]=tot;
}
int Sap(int x,int delta){
	if (x==T) return delta;
	int z=nodes,sum=0;
	for (int i=fst[x];i;i=e[i].nxt)
	if (e[i].f){
		int y=e[i].to;
		if (d[x]==d[y]+1){
			int w=Sap(y,std::min(e[i].f,delta-sum));
			e[i].f-=w;e[i^1].f+=w;sum+=w;
			if (d[S]>=nodes || sum==delta) return sum;
		}
		z=std::min(z,d[y]);
	}
	if (!sum){
		if (--cnt[d[x]]==0) d[S]=nodes;
			else ++cnt[d[x]=z+1];
	}
	return sum;
}
int main(){
	int h,w;
	scanf("%d%d\n",&h,&w);
	S=0;T=h+w+1;nodes=T+1;
	for (int i=1;i<=h;i++){
		scanf("%s",s+1);
		for (int j=1;j<=w;j++){
			if (s[j]=='o') add(i,j+h,1);
			if (s[j]=='S') add(S,i,inf),add(S,j+h,inf);
			if (s[j]=='T') add(i,T,inf),add(j+h,T,inf);
		}
	}
	int ans=0;
	for (;d[S]<nodes;) ans+=Sap(S,inf);
	if (ans>=inf) ans=-1;
	printf("%d\n",ans);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Measured memory_bytes: 384
import sys
import math
from fractions import gcd
# import queue
# from collections import Counter
# from itertools import accumulate
# from functools import reduce

def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""
# 標準入力取得
## 文字列
 =  sys.stdin.readline().rstrip()
 =  list(sys.stdin.readline().rstrip())

## 数値
 =  int(sys.stdin.readline())
 =  map(int, sys.stdin.readline().split())
 =  list(map(int, sys.stdin.readline().split()))
 =  [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""

A, B, K =  map(int, sys.stdin.readline().split())
X = [x for x in range(A, min(A + K, B + 1))] + [x for x in range(max(B - K + 1, A), B + 1)]
for x in sorted(list(set(X))):
    print(x)

Measured memory_bytes: 65352
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <map>
#include <set>
#include <utility>
#include <queue>
#include <bitset>
#include <math.h>
#include <numeric>
#include <stack>

using namespace std;
 
#define rep(i,m,n) for(int i=m;i<(int)(n);i++)
#define endl '\n'
typedef long long ll;

int gcd(int x,int y){
    return y ? gcd(y,x%y) : x;
}

ll GetDigit(ll num){
    return std::to_string(num).length();
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int r; cin >> r;
    cout<<r*r<<endl;
}
//単調増加の時、二分探索を使うO(log n)

Measured memory_bytes: 256
from queue import deque

n = int(input())
li = [[] for _ in range(n)]
length = {}
length_path = [0]*n

for i in range(n-1):
    u,v,w = map(int,input().split())
    u,v = u-1,v-1
    if u < v:
        length[(u,v)] = w
    else:
        length[(v,u)] = w
    li[u].append(v)
    li[v].append(u)

q,k = map(int,input().split())
k -= 1

work_queue = deque([])
visited = [False]*n

work_queue.append(k)

while work_queue:
    now = work_queue.popleft()
    visited[now] = True
    for i in li[now]:
        if visited[i]:
            continue
        work_queue.append(i)
        visited[i] = True
        if now < i:
            length_path[i] = length_path[now]+length[(now,i)]
        else:
            length_path[i] = length_path[now]+length[(i,now)]

for i in range(q):
    x,y = map(int,input().split())
    x,y = x-1,y-1
    print(length_path[x]+length_path[y])

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

using namespace std;

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

    int a, b;
    cin >> a >> b;
    a--;
    b--;
    a = (a + 12) % 13;
    b = (b + 12) % 13;
    if (a > b) {
        cout << "Alice";
    } else if (a < b) {
        cout << "Bob";
    } else {
        cout << "Draw";
    }
}


Measured memory_bytes: 256
#include <cstdio>

int S(int);

int main(){
    int N;
    scanf("%d",&N);
    if(N % S(N) == 0){
        printf("Yes");
    }else{
        printf("No");
    }
    printf("\n");

    return 0;
}

int S(int m){
    int ans = 0; 
    while(m != 0){
        ans += m % 10;
        m = m / 10;
    }

    return ans;
}

Measured memory_bytes: 128
import java.util.*;
import java.io.*;


public class Main {
	
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(in.readLine());
		int[] top = new int[n];
		int[] bot = new int[n];
		String[] r = in.readLine().split("\\s++");
		for(int i = 0; i < n; i++) {
			top[i] = Integer.parseInt(r[i]);
		}
		r = in.readLine().split("\\s++");
		for(int i = 0; i < n; i++) {
			bot[i] = Integer.parseInt(r[i]);
		}
		for(int i = 1; i < n; i++) {
			top[i] += top[i-1];
		}
		for(int i = n - 2; i >= 0; i--) {
			bot[i] += bot[i+1];
		}
		int best = 0;
		for(int i = 0; i < n; i++) {
			if(top[i] + bot[i] > best) best = top[i] + bot[i];
		}
		System.out.println(best);
	}
}

Measured memory_bytes: 21332
N = int(input())

cands = [1]
for i in range(1, 7):
  if 6**i <= N:
    cands.append(6**i)
  if 9**i <= N:
    cands.append(9**i)

dp = [10**6] * (N+1)
dp[0] = 0
for i in range(1, N+1):
  for c in cands:
    if c <= i:
      dp[i] = min(dp[i], dp[i-c]+1)

print(dp[-1])

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

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

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

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


int main()
{
    ll N, M;
    cin >> N >> M;
    
    vec H(N);
    mat G(N);
    REP(i,0,N) cin >> H[i];
    ll a, b;
    REP(i,0,M) {
        cin >> a >> b;
        --a; --b;
        G[a].pb(b);
        G[b].pb(a);
    }

    ll cnt = 0, m;
    bool f;
    REP(i,0,N) {
        m = H[i];
        f = true;
        FORR(v,G[i]) {
            if(m <= H[v]) {
                f = false;
                break;
            }
        }
        if(f) ++cnt;
    }
    PR(cnt);

    return 0;
}

/*



*/

Measured memory_bytes: 9796
#include <cstdio>
typedef long long lint;
int const N=1e5+10;
int n,a[N];
int gcd(int x,int y)
{
    if(x==-1 || y==-1) return -x*y;
    if(x==0) return y;
    else return gcd(y%x,x);
}
int g1[N],g2[N];
int main()
{
    scanf("%d",&n);
    lint sum=0;
    for(int i=1;i<=n;i++) scanf("%d",&a[i]),sum+=a[i];
    if(n%2==0)
    {
        if(sum%2==1) printf("First");
        else printf("Second");
        return 0;
    }
    if(sum%2==0) {printf("First"); return 0;}
    int cur=0;
    while(true)
    {
        bool flag=false;
        sum=0;
        for(int i=1;i<=n;i++) sum+=a[i];
        g1[0]=-1; g2[n+1]=-1;
        for(int i=2;i<=n;i++) g1[i]=gcd(g1[i-1],a[i]);
        for(int i=n-1;i>=1;i--) g2[i]=gcd(g2[i+1],a[i]);
        int g;
        for(int i=1;i<=n&&!flag;i++)
        {
            if(a[i]==1) continue;
            g=gcd(gcd(g1[i-1],g2[i+1]),a[i]-1);
            if(((sum-1)/g)%2==1) flag=true;
        }
        if(flag)
            for(int i=1;i<=n;i++) a[i]/=g;
        else
        { 
            if(cur==0) printf("Second");
            else printf("First");
            return 0; 
        } 
        cur^=1;
    }
    return 0;
}

Measured memory_bytes: 1280
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.lang.Math;
import java.math.*;

public class Main {
    public static void main(String[] args) {
        FS reader = new FS();
        // write reader
        System.out.println(48-reader.nextInt());
    }

    // Read Class
    static class FS {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
    
        private int readByte() { return hasNextByte() ? buffer[ptr++] : -1;}
        private boolean isPrintableChar(int c) {return 33 <= c && c <= 126;}
        private void skipUnprintable() {while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
    
        public boolean hasNext() { skipUnprintable(); return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public int nextInt() {
            return (int)nextLong();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while(true) {
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if(b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }
    }
}



Measured memory_bytes: 21204
#include<bits/stdc++.h>
using namespace std;
long X,Y,Z,K,i,x,y,z;
vector<long>A,B,C,ABC;
main(){
  cin>>X>>Y>>Z>>K;
  A.resize(X);
  B.resize(Y);
  C.resize(Z);
  for(i=0;i<X;i++)cin>>A[i];
  for(i=0;i<Y;i++)cin>>B[i];
  for(i=0;i<Z;i++)cin>>C[i];
  sort(A.rbegin(),A.rend());
  sort(B.rbegin(),B.rend());
  sort(C.rbegin(),C.rend());
  for(x=0;x<X;x++){
    for(y=0;y<Y;y++){
      for(z=0;z<Z;z++){
        if((x+1)*(y+1)*(z+1)>K)break;
        ABC.push_back(A[x]+B[y]+C[z]);
      }
    }
  }
  sort(ABC.rbegin(),ABC.rend());
  for(i=0;i<K;i++)cout<<ABC[i]<<endl;
}


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

int main() {
  int D, G;
  cin >> D >> G;
  vector<int> ps(D), cs(D);
  for (int i = 0; i < D; i++) cin >> ps.at(i) >> cs.at(i);
  
  int answer = 10000000;
  for (int bit = 0; bit < (1 << D); bit++) {
    int total = 0, solved = 0, rest = -1;
    vector<int> mask(D, 0);
    for (int i = 0; i < D; i++) {
      if (bit & (1 << i)) {
        total +=  (i + 1) *  100 * ps.at(i) + cs.at(i);
        solved += ps.at(i);
        mask.at(i) = 1;
      }
    }
    for (int i = 0; i < D; i++) {
      if (mask.at(i) == 0) {
        rest = max(rest, i);
      }
    }
    int j = 1;
    while (rest > -1 && total < G && j < ps.at(rest)) {
      total += (rest + 1) * 100;
      solved++;
      j++;
    }
    if (total >= G) answer = min(answer, solved);
  }
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int A,B,C;
    cin>>A>>B>>C;
    if(A+B+C>=22){
        cout<<"bust"<<endl;
    }
    if(A+B+C<=21){
        cout<<"win"<<endl;
    }
}


Measured memory_bytes: 256
#!/usr/bin/env python

def main():
    a, b, c, k = map(int, input().split())
    ret = 0

    if k < a:
        ret += k
        print(ret)
    else:
        ret += a
        k -= a
        if k < b:
            print(ret)
        else:
            k -= b
            ret -= k
            print(ret)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9124
a = list(map(int, input().split()))
import sys
sys.setrecursionlimit(100000)

if (2*a[0]- a[1])%3 != 0:
    print(0)
else:
    if (2*a[1] - a[0])%3 != 0:
        print(0)
    else:
        if 2*a[0]-a[1]<0 or 2*a[1]-a[0]< 0:
            print(0)
        else:
            x = (2*a[1] - a[0])//3
            y = (2*a[0]- a[1])//3
            def cmb(n, r):
                if n - r < r: r = n - r
                if r == 0: return 1
                if r == 1: return n

                numerator = [n - r + k + 1 for k in range(r)]
                denominator = [k + 1 for k in range(r)]

                for p in range(2,r+1):
                    pivot = denominator[p - 1]
                    if pivot > 1:
                        offset = (n - r) % p
                        for k in range(p-1,r,p):
                            numerator[k - offset] /= pivot
                            denominator[k] /= pivot

                result = 1
                for k in range(r):
                    if numerator[k] > 1:
                        result *= int(numerator[k])

                return result
        
            print((cmb(x+y,x))%(10**9 + 7))

Measured memory_bytes: 102028
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class TaskB {
        int n;
        int m;

        boolean r(int x, int y) {
            return x >= 0 && x < n && y >= 0 && y < m;
        }

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            n = in.nextInt();
            m = in.nextInt();
            char[][] v = new char[n][];
            for (int i = 0; i < n; ++i) v[i] = in.next().toCharArray();
            Dir[] w = {
                    new Dir(0, 1),
                    new Dir(-1, 0),
                    new Dir(0, -1),
                    new Dir(0, -1),
                    new Dir(1, 0),
                    new Dir(1, 0),
                    new Dir(0, 1),
                    new Dir(0, 1)
            };
            for (int i = 0; i < n; ++i) {
                for (int j = 0; j < m; ++j) {
                    if (v[i][j] == '#') {
                        out.print("#");
                        continue;
                    }
                    int s = 0;
                    int x = i;
                    int y = j;
                    for (int k = 0; k < 8; ++k) {
                        x += w[k].x;
                        y += w[k].y;
                        if (!r(x, y)) continue;
                        if (v[x][y] == '#') ++s;
                    }
                    out.print(s);
                }
                out.println();
            }
        }

        class Dir {
            int x;
            int y;

            public Dir(int x, int y) {
                this.x = x;
                this.y = y;
            }

        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 21588
inf = int(input())
i = 0
table = []
buil = [[[0]*10 for i in range(3)]for i in range(4)]

while(i < inf):
    b,f,r,v = map(int,input().split())
    b -=1
    f -=1
    r -=1
    buil[b][f][r] += v
    if buil[b][f][r] > 9: buil[b][f][r] = 9
    elif buil[b][f][r] < 0: buil[b][f][r] = 0
    i += 1

for i in range(4):
        if i != 0: print("#"*20)
        for j in range(3):
                for k in range(10):
                    print(" %d" %(buil[i][j][k]),end ="")
                print()

    


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

int main() {
   string b;
   cin >> b;
   if(b=="A")cout << "T" <<endl;
   if(b=="T")cout << "A" <<endl;
   if(b=="G")cout << "C" <<endl;
   if(b=="C")cout << "G" <<endl;
}

Measured memory_bytes: 3620
while True:
    n=input()
    if n==0:break
    m=input()
    s=raw_input()
    Pn="I"+"OI"*n
    cnt,pl=0,len(Pn)
    for i in range(pl,m+1):
        if s[i-pl:i]==Pn:
            cnt+=1
    print cnt

Measured memory_bytes: 36832
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

void pakuri_sort(int N, ll A[]) {
	const int b = 8;
	ll tmp[200001];
	rep(k, 4) {
		int kazu[1 << b] = {}, kazu2[1 << b] = {};
		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
		for (int i = N - 1; i >= 0; i--) tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];
		k++;
		rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
		for (int i = N - 1; i >= 0; i--) A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i];
	}
}

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


	int R = getint(), C = getint(), N = getint();
	int RC3 = R + C + R;
	int RC4 = R + C + R + C;
	ll A[200000];
	int k = 0;
	rep(i, N) {
		int x = getint(), y = getint();
		int mae = k;
		ll k2 = ll(i) << 32;
		if (y == 0) A[k++] = k2 + x;
		else if (x == R) A[k++] = k2 + y + R;
		else if (y == C) A[k++] = k2 - x + RC3;
		else if (x == 0) A[k++] = k2 - y + RC4;
		x = getint();
		y = getint();
		if (y == 0) A[k++] = k2 + x;
		else if (x == R) A[k++] = k2 + y + R;
		else if (y == C) A[k++] = k2 - x + RC3;
		else if (x == 0) A[k++] = k2 - y + RC4;
		if (mae + 2 != k) k = mae;
	}

	pakuri_sort(k, A);

	int kazu = 0;
	int B[200000] = {};
	int OK = 1;
	rep(i, k) {
		int j = A[i] >> 32;
		if (B[j]) {
			if (B[j] != kazu--) OK = 0;
		}
		else B[j] = ++kazu;
	}

	if (OK) printf("YES\n");
	else printf("NO\n");

	Would you please return 0;
}

Measured memory_bytes: 4224