akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner scn = new Scanner(System.in);
        while(true) {
            int a = scn.nextInt();
            int b = scn.nextInt();
            if(a == 0 && b == 0) break;

            for(int i = 0; i < a; i++){
                for(int j = 0; j < b; j++){
                    if((i + j) % 2 == 0) System.out.printf("#");
                    else System.out.printf(".");
                }
                System.out.printf("\n");
            }
            System.out.printf("\n");
        }
    }
}


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

using namespace std;

int main() {

    int N;
    cin >> N;

    long long A[N + 1]; 
    for (int i = 1; i <= N; i++) {
        cin >> A[i];
    }

    for (int i = 1; i <= N; i++) {
        if (A[i] == 0) {
            cout << "0" << endl;
            return 0;
        }
    }

    long long ans = 1;

    for (int i = 1; i <= N; i++) {
        if (A[i] <= 1000000000000000000 / ans) {
            ans *= A[i];
        } else {
            cout << "-1" << endl;
            return 0;
        }
    }

    cout << ans << endl;

}

Measured memory_bytes: 4384
#include <iostream>
#include <cstring>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); ++i)

int main(){
  char s[10];
  cin >> s;
  int n = strlen(s);
  
  long long ans = 0;
  rep(i, 1 << (n- 1)) {
    long long tmp = s[0] - '0';
    rep(j, n-1) {
      if ((i >> j) & 1) {
        ans += tmp;
        tmp = 0;
      }
      tmp = 10 * tmp + s[j+1] - '0';
    }
    ans += tmp;
  }
  cout << ans << endl;
}

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

void fnInput(int64_t& rnNum)
{
  cin >> rnNum;
}

int fnDigitsCheck(int64_t nDivisor)
{
  int nDigitCnt = 0;
  while (nDivisor)
  {
    nDigitCnt++;
    nDivisor /= 10;
  }

  return nDigitCnt;
}

int fnMultiplCheck(int64_t nNum)
{
  int nMinDigit = fnDigitsCheck(nNum);
                                           
  for (int64_t n = 2; n * n <= nNum; n++)  // int型 n では n * n が int型の範囲を
  {                                        // 超えて桁落ちが発生し 永久ループとなる
    if (nNum % n != 0)  continue;          // nNum の平方根を超えない整数～nNum
    int64_t nOtr = nNum / n;               // で左記検査を行うと TLE となる
    nMinDigit = min(nMinDigit, fnDigitsCheck(nOtr));
  }
  return nMinDigit;
}

int main()
{
  int64_t nNum;
  
  fnInput(nNum);
  cout << fnMultiplCheck(nNum) << endl;

  return 0;
}

Measured memory_bytes: 256
N = int(input())
S = input()
LB = 0
RW = S.count(".")
ans = LB +RW
for x in range(N):
    if S[x] == "#":
        LB += 1
    else:
        RW -= 1
    count = LB +RW
    if count < ans:
        ans = count
print(ans)

Measured memory_bytes: 3500
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
  Name:- OMHARI 
  Institution:- UNIVERSIT OF CALCUTTA(INFORMATION TECHNOLOGY)
  Email:- omharicu@gmail.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#include<bits/stdc++.h>
using namespace std; 

#define ull unsigned long long
#define ll long long
#define ul unsigned long
#define db double
#define pb push_back
#define mp make_pair
#define el "\n"
#define vll vector <ll>
#define vi vector <int>
#define all(v) (v.begin(), v.end()) 
#define rall(v) (v.rbegin(), v.rend()) 
const ll mod = 1e9+7;

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

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
     #endif
    /***************-Code starts from here-***************/
    char s;
    cin>>s;
    if(s>=65 && s<=90)
    cout<<"A";
    else
    cout<<"a";
    return 0; 
} 

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

using namespace std;

int main()
{
    int n,a[2][101],dp[2][101];
    scanf("%d",&n);
    for(int i=0;i<n;i++) scanf("%d",&a[0][i]);
    for(int i=0;i<n;i++) scanf("%d",&a[1][i]);
    memset(dp,0,sizeof(dp));
    dp[0][0]=a[0][0];
    for(int i=1;i<n;i++) dp[0][i]=dp[0][i-1]+a[0][i];
    for(int i=0;i<n;i++) dp[1][i]=max(dp[1][i-1]+a[1][i],dp[0][i]+a[1][i]);
    printf("%d\n",dp[1][n-1]);
    return 0;
}


Measured memory_bytes: 256
#define _USE_MAT_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <stack>
#include <deque>
#include <numeric>
#include <functional>
using namespace std;

int main() {
    int N, K;
    cin >> N >> K;
    vector<int>A(200000+1,0);
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        A[a]++;
    }
    vector<int>kind;
    for (int i = 0; i <= 200000; i++)if (A[i] > 0)kind.push_back(A[i]);
    sort(kind.begin(), kind.end());

    int ans = 0;
    if (kind.size() >= K) {
        for (int i = 0; i < kind.size() - K; i++)ans += kind[i];
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2168
#define _USE_MATH_DEFINES
#include<iostream>
#include<algorithm>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#define ll long long
#define str string
#define ld long double
#define vec vector
#define vll vec<ll>
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,b,a) for(ll i=b;i>=a;i--)
#define ALL(a) a.begin(),a.end()
#define rALL(a) a.rbegin(),a.rend()
#define kai "\n"
#define yuque priority_queue
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define mie min_element
#define mae max_element
#define tos to_string
#define sep setprecision
#define lob lower_bound
#define upb upper_bound
#define nep next_permutation
#define MOD 1000000007ll
#define MIN (1e-10)
#define equal(a,b) (abs((a)-(b))<MIN)
#define v2 ten
#define chokusen senbun
#define kakkei vec<ten>
using namespace std;
void solve();
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed;
	solve();
}
struct pea{
	ll f,s;
	bool operator<(const pea &p)const{
		return f!=p.f?f<p.f:s<p.s;
	};
};
struct tri{
	ll f,s,t;
	bool operator<(const tri &p)const{return f<p.f;};
};
class ten{
public:
	ld x,y;
	ten operator+(ten p){return{x+p.x,y+p.y};}
	ten operator-(ten p){return{x-p.x,y-p.y};}
	ten operator*(ld k){return{k*x,k*y};}
	ten operator/(ld k){return{x/k,y/k};}
	ld abs(){return sqrt(abs2());}
	ld abs2(){return x*x+y*y;};
	bool operator<(const ten &p)const{return x!=p.x?x<p.x:y<p.y;};
	bool operator==(const ten &p)const{
		return (-MIN<x-p.x)&&(x-p.x<MIN)&&(-MIN<y-p.y)&&(y-p.y<MIN);
	};
	ld naiseki(v2 b){return x*b.x+y*b.y;}
	ld gaiseki(v2 b){return x*b.y-y*b.x;}
};
struct senbun{ten p1,p2;};
struct en{ten o;ld r;};
void dijkstra(const vec<vec<pea>> &c,ll v,vll &d){
	d[v]=0;
	ll n=c.size();
	ll count=1;
	vec<bool> seen(n,false);
	seen[v]=true;
	yuque<pea> hen;
	rep(i,0,c[v].size())hen.push({-c[v][i].f,c[v][i].s});
	while(count!=n){
		pea k=hen.top();hen.pop();
		while(seen[k.s]){
			k=hen.top();
			hen.pop();
		}
		d[k.s]=-k.f;
		count++;
		seen[k.s]=true;
		rep(i,0,c[k.s].size())hen.push({k.f-c[k.s][i].f,c[k.s][i].s});
	}
}
void solve(){
	ll n;cin>>n;
	vec<vec<pea>> c(n);
	rep(i,0,n){
		ll u,k;
		cin>>u>>k;
		rep(j,0,k){
			ll v,w;
			cin>>v>>w;
			c[u].pub({w,v});
		}
	}
	vll ans(n);
	dijkstra(c,0,ans);
	rep(i,0,n)cout<<i<<' '<<ans[i]<<kai;
}


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

int main(){
  int n;
  stack<int> a;
  cin >> n;
  vector<int> b(n);
  for(int i=0;i<n;i++) cin >> b[i];
  while(!b.empty()){
    bool e = true;
    for(int i=b.size()-1;i>=0;i--){
      if(i+1 == b[i]){
        a.push(b[i]);
        b.erase(b.begin()+i);
        e = false;
        break;
      }
    }
    if(e){
      cout << -1 << endl;
      return 0;
    }
  }
  while(!a.empty()){
    cout << a.top() << endl;
    a.pop();
  }
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int n,x,C,i,j,k;

  while(1){
    C=0;
    scanf("%d %d",&n,&x);
    if(n==0 && x==0) break;

    for(i=1; i<=n; i++){

      for(j=1; j<=n; j++){

	for(k=1; k<=n; k++){

	  if(i + j + k == x){

	    if(i != j && j != k && k != i) C++;
	  }
	}
      }
    }
  
    printf("%d\n",C/6);
  }

  return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define CST(x) cout << fixed << setprecision(x)
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pl = pair<ll, ll>;
const ll MOD = 1000000007;
const int inf = 1e9 + 10;
const ll INF = 4e18;
const ll dy[4] = {1, 0, -1, 0};
const ll dx[4] = {0, 1, 0, -1};
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);

	int n, k;
	cin >> n >> k;
	ll sum = 0;
	repl(i, k, n + 2) {
		sum += i * n - (i - 1) * i + 1;
		sum %= MOD;
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;
int main()
{
    int n;cin>>n;
    vector<pair<ll,ll>> v(n);
    for(int i=0;i<n;i++){
        cin>>v[i].first>>v[i].second;
    }
    map<pair<ll,ll>,ll> mp;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(i==j)continue;
            auto m=make_pair(v[i].first-v[j].first,v[i].second-v[j].second);
            mp[m]++;
        }
    }
    ll ans=0;
    for(auto e:mp){
        //cout<<e.first.first<<":"<<e.first.second<<endl;
        ans=max(ans,e.second);
    }
    cout<<n-ans<<endl;
}

Measured memory_bytes: 384
#include<stdio.h>
#include<string.h>

#define MAX 100005

typedef struct{
  int parent;
  int left;
  int right;
}Roll;

int max(int h1,int h2){
  if(h1>h2)return h1;
  else return h2;
}

int Depth(int root,int d,int *Dep,Roll *Tree){
  if(root==-1)return -1;
  Dep[root]=d;
  Depth(Tree[root].left,d+1,Dep,Tree);
  Depth(Tree[root].right,d+1,Dep,Tree);
  return 0;
}

int Height(int root,Roll *Tree,int *Hei){
  int h1=0,h2=0;
  if(Tree[root].left!=-1)
    h1=Height(Tree[root].left,Tree,Hei)+1;
  if(Tree[root].right!=-1)
    h2=Height(Tree[root].right,Tree,Hei)+1;

    return Hei[root]=max(h1,h2);
}
 
int sibl(int root,Roll *Tree){
  if(Tree[root].parent==-1)return -1;
  if(Tree[Tree[root].parent].left!=root&&Tree[Tree[root].parent].left!=-1)return Tree[Tree[root].parent].left;
  if(Tree[Tree[root].parent].right!=root&&Tree[Tree[root].parent].right!=-1)return Tree[Tree[root].parent].right;
  return -1;
}

void print(int root,Roll *Tree,int *Hei,int *Dep){ 
  printf("node %d: ",root);
  printf("parent = %d, ",Tree[root].parent);
  printf("sibling = %d, ",sibl(root,Tree));
  int deg=0;
  if(Tree[root].left!=-1)deg++;
  if(Tree[root].right!=-1)deg++;
  printf("degree = %d, ",deg);
  printf("depth = %d, ",Dep[root]);
  printf("height = %d, ",Hei[root]);
  if(Tree[root].parent==-1)printf("root");
  else if(Tree[root].left==-1&&Tree[root].right==-1)printf("leaf");
  else printf("internal node");
  printf("\n");
}


int main(){
  Roll Tree[MAX];
  int Dep[MAX],Hei[MAX];
  int id,left,right,root = 0;
  int i,n;
  scanf("%d",&n);
  for(i=0;i<n;i++) Tree[i].parent=-1;
  for(i=0;i<n;i++){
    scanf("%d%d%d",&id,&left,&right);
    Tree[id].left=left;
    Tree[id].right=right;
    if(left!=-1)Tree[left].parent=id;
    if(right!=-1)Tree[right].parent=id;
  }
  for(i=0;i<n;i++)
    if(Tree[i].parent==-1)
      root=i;
  Depth(root,0,Dep,Tree);
  Height(root,Tree,Hei);
  for(i=0;i<n;i++)
    print(i,Tree,Hei,Dep);
  return 0;
}

Measured memory_bytes: 624
H, W, D = map(int, input().split())
X = [(0, 0) for _ in range(H*W)]
Y = [0] * (H*W)
for i in range(H):
    A = [int(a) - 1 for a in input().split()]
    for j in range(W):
        X[A[j]] = (i, j)
for i in range(H*W - D):
    Y[i+D] = Y[i] + abs(X[i+D][0] - X[i][0]) + abs(X[i+D][1] - X[i][1])
for _ in range(int(input())):
    l, r = map(int, input().split())
    print(Y[r-1] - Y[l-1])

Measured memory_bytes: 15628
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using P = pair<int,int>;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

//----***定数***----
#define MOD 1000000007
#define INF 100000000000000000
#define EPS 1e-9
const vector<vector<int>> DXY={{-1,0},{1,0},{0,-1},{0,1}};

//----***パーツ***----
#define fi first
#define se second
#define pb push_back
#define re return
#define br break

//----***入出力***---
void print() { std::cout << "\n"; }
template <class T>void print(const T &x) {std::cout << x<<"\n";}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0);
#define dbg cerr<<"🥺🥺🥺🥺🥺🥺"<<endl;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}initial_;


signed main(){
  string S,T;cin>>S>>T;
  REP(i,0,S.size()){
    if(i==T.size()){
      cout<<S.at(i)<<"\n";
      re 0;
    }
    cout<<S.at(i)<<T.at(i);
  }
  cout<<endl;
  

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N=2e5+5,M=2e3+5,mod=1e9+7;
int dp[2*M][2*M],n,a[N],b[N],p[N],inv[N],ans;
int mod_pow(int x, int n){
	int ret = 1;
	while (n){
		if (n & 1) ret = 1LL * ret * x % mod;
		x = 1LL * x * x % mod;
		n >>= 1;
	}
	return ret;
}
void precalc(){
    p[0] = 1; inv[0] = 1;
	for (int i = 1; i < N; i++) p[i] = 1LL * p[i - 1] * i % mod;
	for (int i = 1; i < N; i++) inv[i] = mod_pow(p[i], mod - 2);
}
int C(int x, int y){
	if (x < y) return 0;
	return 1LL * p[x] * inv[y] % mod * inv[x - y] % mod;
}
int main()
{
    precalc();
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d%d",&a[i],&b[i]);
        dp[M-a[i]][M-b[i]]++;
    }
    for(int i=1;i<2*M;i++){
        for(int j=1;j<2*M;j++){
            dp[i][j]=(dp[i][j]+dp[i-1][j])%mod;
            dp[i][j]=(dp[i][j]+dp[i][j-1])%mod;
        }
    }
    for(int i=1;i<=n;i++){
        ans=(ans+dp[M+a[i]][M+b[i]])%mod;
        ans=(ans+mod-C(2*a[i]+2*b[i],2*b[i]))%mod;
    }
    ans = 1LL * ans * mod_pow(2, mod - 2) % mod;
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 66176
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<map>
#include<cmath>
#define ll long long
#define mx 800
#define max(x,y) ((x)>(y)?(x):(y))
#define min(x,y) ((x)<(y)?(x):(y))
#define fur(i,x,y) for(i=x;i<=y;i++)
#define fdr(i,x,y) for(i=x;i>=y;i--)
#define Fur(i,x,y) for(ll i=x;i<=y;i++)
#define Fdr(x,y) for(ll i=x;i>=y;i--)
#define in2(x,y) in(x);in(y)
#define in3(x,y,z) in2(x,y);in(z)
#define in4(a,b,c,d) in2(a,b);in2(c,d)
#define clr(x,y) memset(x,y,sizeof(x))
using namespace std;
/*---------------------------------------*/
namespace fib{char b[300000]= {},*f=b;}
#define gc ((*fib::f)?(*(fib ::f++)):(fgets(fib::b,sizeof(fib::b),stdin)?(fib::f=fib::b,*(fib::f++)):-1))
inline void in(ll &x){x=0;char c;bool f=0;while((c=gc)>'9'||c<'0')if(c=='-')f=!f;x=c-48;while((c=gc)<='9'&&c>='0')x=x*10+c-48;if(f)x=-x;}
namespace fob{char b[300000]= {},*f=b,*g=b+300000-2;}
#define pob (fwrite(fob::b,sizeof(char),fob::f-fob::b,stdout),fob::f=fob::b,0)
#define pc(x) (*(fob::f++)=(x),(fob::f==fob::g)?pob:0)
struct foce{~foce(){pob;fflush(stdout);}} _foce;
namespace ib{char b[100];}
inline void out(ll x){if(x==0){pc(48);return;}if(x<0){pc('-');x=-x;}char *s=ib::b;while(x) *(++s)=x%10,x/=10;while(s!=ib::b) pc((*(s--))+48);}
inline void outn(ll x){out(x);pc('\n');}
inline ll jdz(ll x){return x>0?x:-x;}
/*------------------------------------------------------------------------------------------------*/

/*------------------------------------------------------------------------------------------------*/
#define N 100011
bool v[101][101];
ll n=100,m=100,a,b;
inline void sc(){Fur(i,1,50){Fur(j,1,100)pc(v[i][j]?'.':'#');pc('\n');}}
int main(){
	in2(a,b);a--;b--;out(100);pc(' ');outn(100);
	for(ll i=1;i<=49;i+=2)
	if(a>0)
		for(ll j=1;j<=99;j+=2)
		if(a>0){v[i][j]=1;a--;}else break;
	sc();
	Fur(i,1,50)Fur(j,1,100)v[i][j]=1;
	for(ll i=2;i<=50;i+=2)
	if(b>0)
		for(ll j=1;j<=99;j+=2)
		if(b>0){v[i][j]=0;b--;}else break;
	sc();	
}
/*

*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,k,a[1001],ans;
int main()
{
	cin>>n>>k;
	for(int i=1;i<=n;i++)cin>>a[i];
	sort(a+1,a+n+1);
	for(int i=1;i<=k;i++)ans+=a[i];
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string s;
  cin>>s;
  ll count=0,si=s.size();
  for(int bit=0;bit<(1<<si-1);bit++){
    int flag=0;
    vector<string> su(15);
    for(int i=0;i<si;i++){
      su[flag]+=s[i];
      if(bit & (1<<i)){
	flag++;
      }
    }
    for(int i=0;i<si;i++){
      count+=atoll(su[i].c_str());
    }
  }
  cout<<count<<'\n';
  return(0);
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(int i=0; i<n; i++)
#define reps(i, s, e) for(int i=s; i<e; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define reprs(i, s, e) for(int i=e-1; i>=s; i--)

int main(){

    int n; cin >> n;
    ll a[n];
    rep(i, n){
        cin >> a[i];
    }

    ll s[n+1];
    s[0] = 0;

    reps(i, 1, n+1){
        s[i] = s[i-1] + a[i-1];
    }

    sort(s, s+n+1);
    map<ll, ll> mp;

    rep(i, n+1){
        mp[s[i]]++;
    }

    vector<ll> v;
    for(auto p : mp){
        if(p.second >= 2){
            v.push_back(p.second);
        }
    }

    ll ans = 0;
    for(auto x : v){
        ans += x*(x-1)/2;
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 15872
h, w = gets.split.map(&:to_i)
s = h.times.map{gets.chomp.chars}
dy = [-1, -1, 0, 1, 1, 1, 0, -1]
dx = [0, 1, 1, 1, 0, -1, -1, -1]
h.times{|y| w.times{ |x|
    print s[y][x]=="#" ? "#" : (0..7).count{|i|
        a, b = y + dy[i], x + dx[i]
        0 <= a && a < h && 0 <= b && b < w && s[a][b] == "#"
    }}
    puts ''
}

Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define f0(i,a,n) for(ll i=a;i<n-1;i++)
#define f(i,a,n) for(ll i=a;i<n;i++)
#define f1(i,a,n) for(ll i=a;i<=n;i++)
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define T ll t=1; cin>>t; while(t--)
#define c(a) cin>>a;

int main()
{
    fast;
    int n,bill=0;
    c(n);
    f1(i,1,10)
    {
        bill=i*1000;
        if (bill>=n) break;
    }
    cout<<bill-n<<endl;
    return 0;
}

Measured memory_bytes: 3648
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N,X=MAP()
L=LIST()

cnt=1
sm=0
for i in range(N):
    sm+=L[i]
    if sm<=X:
        cnt+=1
    else:
        break
print(cnt)


Measured memory_bytes: 3064
from collections import Counter

N, C = map(int, input().split())
D = [list(map(int, input().split())) for _ in range(C)]
grid = [list(map(lambda x: int(x) - 1, input().split())) for _ in range(N)]

group = [Counter() for _ in range(3)]
for i in range(N):
    for j in range(N):
        group[(i + j) % 3][grid[i][j]] += 1

ans = float('inf')
for c0 in range(C):
    for c1 in range(C):
        if c0 == c1:
            continue
        for c2 in range(C):
            if c2 == c0 or c2 == c1:
                continue
            cnt = 0
            color = [c0, c1, c2]
            for G, nc in zip(group, color):
                for c in list(G.keys()):
                    cnt += G[c] * D[c][nc]
            ans = min(ans, cnt)

print(ans)


Measured memory_bytes: 48604
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll n, m;
    cin >> n >> m;
    vector<vector<ll>> G(3*n);

    rep(i, 0, m) {
        ll x, y;
        cin >> x >> y;
        x--, y--;
        G[x].emplace_back(y+n);
        G[x+n].emplace_back(y+2*n);
        G[x+2*n].emplace_back(y);
    }

    ll s, t;
    cin >> s >> t;
    s--, t--;

    // dist[v] :  頂点sからvまでの距離
    vector<ll> dist(3*n, -1);
    queue<ll> que;
    dist[s] = 0;
    que.push(s);
    while(!que.empty()) {
        auto cur = que.front();
        que.pop();
        for(auto nv : G[cur]) {
            if(dist[nv] == -1) {
                que.push(nv);
                dist[nv] = dist[cur] + 1;
            }
        }
    }
    if(dist[t] == -1) cout << -1 << endl;
    else cout << dist[t]/3 << endl;
}

Measured memory_bytes: 18944
from fractions import gcd


def lcm(a, b):
    """
    aとbの最小公倍数を計算します。
    """
    return a * b // gcd(a, b)


X, Y = map(int, input().split())
a = lcm(X, Y)
if a == X:
    print(-1)
else:
    print(a - X)

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

vector <long long> A;

void DecompositPrime(long long n)
{
    // # initial value
    long long a = 2;
    // # sqrt(n) ≧ a ( n ≧ a * a ) 
    while (n >= a * a) {
        // # n%a = 0 or not
        // # if so, n /= a
        // # else, a++ 
        if (n % a == 0) {
            //printf("%d * ", a);
            A.push_back(a);
            n /= a;
        } else {
            a++;
        }
    }
    // # push back the remaining
    //printf("%d\n", n);
    if(n!=1) A.push_back(n);
}

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

    DecompositPrime(N);
    int a_size = (int) A.size();

    long long ans=0, count=0;
    bool flag=false;

    for(int i=0; i<a_size; i++){
        if(i!=a_size-1 && A[i+1]==A[i]){
            flag = true;
            count++;
            continue;
        }else if(flag){
            count++;
            // n(n+1)/2 = Sum; n= (-1 + sqrt(1+8*sum))/2
            double nd,sum;
            sum = (double) count;
            nd = (-1 + sqrt(1+8*sum))/2;
            ans += (long long) nd;

            flag = false;
            count = 0;
            continue;
        }
        ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3592
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int main(){
int x,y,z;
cin>>x>>y>>z;
x-=z;
int s=x/(y+z);
cout<<s<<endl;
return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int a, b;
	cin >> a >> b;

	for (int i = 1; i <= 10000; ++i) {
		int tax1 = i * 0.08;
		int tax2 = i * 0.1;
		if (tax1 == a && tax2 == b) {
			cout << i << "\n";
			return 0;
		}
	}

	cout << "-1\n";

	return 0;

}

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

#pragma warning(disable:4996)
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("-ffloat-store")

 
using namespace std;
 
#define int long long
#define ll long long
#define vi vector <int>
#define vii vector <pair<int,int> >
#define rep(i,a,b) for (int i=a;i<b;i++)
#define repD(i,a,b) for (int i=a;i>b;i--)
#define pb push_back
#define pii pair <int,int>
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define MOD 1000000007
#define PI 3.14159265359
 
#define deb(x) {x}
#ifndef local
	#define deb(x) ;
#endif
///----------------------------------------------------------------------------------

int n,q;
int arr[200005];
vi adj[200005];

void dfs(int so=0,int P=-1, int v=0)
{
	int temp=arr[so]+v;
	arr[so]+=v;
	
	for (auto x:adj[so])if (x!=P)dfs(x,so,temp);
	
}
void solve()
{
	cin>>n>>q;
	int u,v;
	rep(i,0,n-1)
	{
		cin>>u>>v;adj[u-1].pb(v-1);adj[v-1].pb(u-1);
	}
	while(q--)
	{
		cin>>u>>v;
		arr[u-1]+=v;
	}
	dfs();
	rep(i,0,n)cout<<arr[i]<<" ";
}

signed main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);
 	
 	#ifdef local
    //freopen("input.txt","r",stdin);
    ///freopen("output.txt","w",stdout);
    clock_t qwertyuiop = clock();
    #endif
 
 	int t=1;
    //cin>>t;
    
    rep(a,0,t)
    {
        ///cout<<"Case #"<<a+1<<": ";
        solve();
	}
	
    #ifdef local
    {qwertyuiop = clock() - qwertyuiop;double time_taken = ((double)qwertyuiop)/CLOCKS_PER_SEC;cerr<<fixed<<setprecision(5)<<"\n\nTime Taken : "<<time_taken<<" seconds\n";}
	#endif
}



Measured memory_bytes: 24960
def powermod(a, p, mod):
    if p == 0:
        return 1
    elif p % 2 == 0:
        return (powermod(a, p//2, mod) ** 2) % mod
    else:
        return ((powermod(a, (p-1)//2, mod) ** 2) % mod) * a % mod

def combinationmod(n,r):
    if r == 0 or n == r:
        return 1
    mod = 10 ** 9 + 7
    factorial = 1
    for i in range(n):
        factorial = (factorial * (i+1)) % mod
        if i+1 == r:
            fact_1 = factorial
        if i+1 == n-r:
            fact_2 = factorial
        if i+1 == n:
            fact_0 = factorial
    return fact_0 * powermod(fact_1,mod-2,mod) % mod * powermod(fact_2,mod-2,mod) % mod
    
X,Y = map(int,input().split())
if (X + Y) % 3 == 0 and X <= 2 * Y and 2 * X >= Y:
    turns = (X + Y) // 3
    print(combinationmod(turns, min(X,Y) - turns))
else:
    print(0)

Measured memory_bytes: 3316
#include <iostream>
#include <iterator>
//#include <fstream>
//#include <iomanip>
//#include <omp.h>
#include <vector>
//#include <string>
#include <algorithm>
//#include <stdlib.h>
using namespace std;

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

	vector<int> scores;
	vector<int> scores5;
	int score;
	int total_bottom2top = 0;
	for (int i = 0; i < N; i++)
	{
		cin >> score;
		total_bottom2top += score;
		if (score % 5 == 0)
			scores5.push_back(score);
		else
			scores.push_back(score);
	}

	sort(scores5.begin(), scores5.end());
	sort(scores.begin(), scores.end());
	copy(scores5.begin(), scores5.end(), back_inserter(scores));

	for (int i = 0; i < N; i++)
	{
		if (total_bottom2top % 10 != 0)
			break;
		total_bottom2top -= scores.at(i);
		//cout << scores.at(i) << endl;
	}

	cout << total_bottom2top;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 200005
#define LL long long
#define inf 0x3f3f3f3f3f3f3f3fLL
#define pr pair<int,int>
#define mp(x,y) make_pair(x,y)
using namespace std;

int read(){
	char c=getchar();
	int t=0,f=1;
	while(c>'9'||c<'0') f=(c=='-')?-1:1,c=getchar();
	while(c>='0'&&c<='9') t=t*10+c-'0',c=getchar();
	return t*f;
}

int n,m,K,mn=2,tp,l[N],r[N],a[N],b[N];
LL tmp,sum,L[N],R[N],dp[N],st[N],ans=inf;
LL dec(LL x,LL y){return (x-y<0)?(x-y+K):(x-y);}

struct Segment_Tree{
	int mn[N<<2];
	void build(int x,int L,int R){
		mn[x]=n+1;
		if(L==R) return;
		int mid=(L+R)>>1;
		build(x<<1,L,mid),build(x<<1|1,mid+1,R);
	}
	void modify(int x,int L,int R,int l,int r,int v){
		if(v>=mn[x]) return;
		if(L==l&&R==r) return (void)(mn[x]=v);
		int mid=(L+R)>>1;
		if(r<=mid) modify(x<<1,L,mid,l,r,v);
		else if(l>mid) modify(x<<1|1,mid+1,R,l,r,v);
		else modify(x<<1,L,mid,l,mid,v),modify(x<<1|1,mid+1,R,mid+1,r,v);
	}
	int query(int x,int L,int R,int po){
		int mid=(L+R)>>1,ret=mn[x];
		if(L==R) return ret;
		if(po<=mid) ret=min(ret,query(x<<1,L,mid,po));
		else ret=min(ret,query(x<<1|1,mid+1,R,po));
		return ret;
	}
}T;

int main(){
	n=read(),K=read();
	for(int i=1;i<=n;i++){
		a[i]=read(),b[i]=read(),mn=min(mn,b[i]);
		tmp=sum,sum=dec(sum,(a[i]<<1)%K);
		if(b[i]==1){
			if((a[i]<<1)>K){puts("-1");return 0;}
			L[i]=tmp,R[i]=sum;
		}
		else L[i]=0,R[i]=K-1;
		st[++tp]=L[i],st[++tp]=R[i];
	}
	if(mn==2){
		ans=0;
		for(int i=1;i<=n;i++) ans+=a[i]<<1;
		return printf("%lld\n",ans),0;
	}
	sort(st+1,st+tp+1),m=unique(st+1,st+tp+1)-st-1;
	for(int i=1;i<=n;i++){
		l[i]=lower_bound(st+1,st+m+1,L[i])-st;
		r[i]=lower_bound(st+1,st+m+1,R[i])-st;
	}
	T.build(1,1,m);
	for(int i=n;i;i--){
		int po=T.query(1,1,m,l[i]);
		if(po!=n+1) dp[i]=dp[po]+dec(L[po],L[i]);
		if(l[i]<=r[i]){
			if(r[i]<m) T.modify(1,1,m,r[i]+1,m,i);
			if(l[i]>1) T.modify(1,1,m,1,l[i]-1,i);
		}
		else if(r[i]+1<l[i]) T.modify(1,1,m,r[i]+1,l[i]-1,i);
	}
	for(int i=1;i<=m;i++){
		int po=T.query(1,1,m,i);
		ans=(po==n+1)?0:min(ans,dp[po]+dec(L[po],st[i]));
	}
	for(int i=1;i<=n;i++) ans+=a[i]<<1;
	printf("%lld\n",ans);
}

Measured memory_bytes: 11520
#include<cstdio>
int main(){
    int x,y;
    while(~scanf("%d%d",&x,&y)){
        if(x<y){
            printf("0\n");
        //    printf("%d is less than %d, so we should print 0.\n",x,y);
        }
        else{
            printf("10\n");
         //   printf("%d is not less than %d, so we should print 10.\n",x,y);
        }
    }
    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <iostream>

using namespace std;

int main() {

	int a[5];
	int kari;

	cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4];

	for (int j = 4; j > 0; j--) {
		for (int i = 0; i < j; i++) {
			if(a[i] < a[i+1]) {
				kari = a[i];
				a[i] = a[i+1];
				a[i+1] = kari;
			}
		}
	}

	cout << a[0];

	for (int i = 1; i < 5; i++) {
		cout << " " << a[i] ;
	}

	cout << endl;

	return 0;
}

Measured memory_bytes: 1164
#include<algorithm>
#include<iostream>
#include<cstring>
#include<iomanip>
#include<sstream>
#include<cstdio>
#include<string>
#include<vector>
#include<bitset>
#include<queue>
#include<cmath>
#include<stack>
#include<set>
#include<map>
#define rep(i,x,n) for(int i=x;i<=n;i++)
#define per(i,n,x) for(int i=n;i>=x;i--)
#define sz(a) int(a.size())
#define rson mid+1,r,p<<1|1
#define pii pair<int,int>
#define lson l,mid,p<<1
#define ll long long
#define pb push_back
#define mp make_pair
#define se second
#define fi first
using namespace std;
const double eps=1e-8;
const int mod=1e9+7;
const int N=1e5+10;
const int inf=1e9;
char s[N];
int main(){
	//ios::sync_with_stdio(false);
	//freopen("in","r",stdin);
	cin>>s;
	int n=strlen(s);
	if(s[2]==s[3]&&s[4]==s[5]) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;

int main() {
    int a,b;
    cin >> a >> b;
    if(a >= 13) cout << b << endl;
    else if(a >= 6) cout << b/2 << endl;
    else cout << 0 << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    int K; cin >> K;
    int n = S.length();
    rep(i, n) {
        if (S[i] != 'a' && 'z' - S[i] < K) {
            K -= 'z' - S[i];
            K--;
            S[i] = 'a';
        }
    }
    K %= 26;
    if ('z' - S[n - 1] < K) {
        K -= 'z' - S[n - 1];
        K--;
        S[n - 1] = 'a';
    }
    
    S[n - 1] = S[n - 1] + K; 
    cout << S << endl;


    return 0;
}


Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod998 = 998244353;
const ll intmax = 2147483647;
const ll llmax = 9223372036854775807;
const char sp = ' ';

int N, M,s[3001];
ll f[3001],inv[3001], DP[3001][3001];
string S;
vector<pair<int, int>>v;
ll pw(ll x, int y) {
	ll a = 1;
	while (y) {
		if (y & 1)a = a*x%mod;
		x = x*x%mod;
		y /= 2;
	}
	return a;
}

ll comb(int n, int r) {
	if (n < r)return 0;
	return f[n] * inv[r] % mod*inv[n - r] % mod;
}

int main() {
	cin >> N >> M >> S;
	int mxr = 0;
	for (int i = 0; i < M; i++) {
		int l, r;
		cin >> l >> r;
		if (r > mxr) {
			mxr = r;
			v.push_back({ l,r });
		}
	}
	v.push_back({ N + 1,N + 1 });
	f[0] = 1;
	for (int i = 0; i < 3000; i++) {
		f[i + 1] = f[i] * (i + 1) % mod;
	}
	for (int i = 0; i <= 3000; i++) {
		inv[i] = pw(f[i], mod - 2);
	}
	for (int i = 0; i < N; i++) {
		s[i + 1] = s[i] + S[i] - '0';
	}
	DP[s[v.front().first - 1]][0] = 1;
	for (int i = 0; i < v.size() - 1; i++) {
		if (v[i].second < v[i + 1].first) {
			for (int j = 0; j <= N; j++) {
				DP[s[v[i + 1].first - 1]][i + 1] += DP[j][i] * comb(v[i].second - v[i].first + 1, s[v[i].second] - j);
				DP[s[v[i + 1].first - 1]][i + 1] %= mod;
			}
		}
		else {
			for (int j = 0; j <= N; j++) {
				int t = s[v[i].second] - j;
				for (int k = max(0, v[i + 1].first - v[i].second - 1 + t); k <= t&&k <= v[i + 1].first - v[i].first; k++) {
					DP[j + k][i + 1] += DP[j][i] * comb(v[i + 1].first - v[i].first, k);
					DP[j + k][i + 1] %= mod;
				}
			}
		}
	}
	cout << DP[s[N]][v.size() - 1] << endl;
}

Measured memory_bytes: 35456
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <queue>
#include <cstring>
#include <string>
#include <stack>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
using namespace std;

#define pb push_back
#define All(a) a.begin(), a.end()
#define met(a, b) memset(a, b, sizeof(a))
#define rep1(i, l, r) for(int i = l; i <= r; ++i)
#define rep2(i, l, r) for(int i = l; i < r; ++i) 
#define per(i, r, l) for(int i = r; i >= l; --i)
typedef long long ll;
typedef double db;
typedef long double ldb;
const int NIL = -1;
const int oo = 0x3f3f3f3f;
const ll INF = 2e18;
const db eps = 1e-8;
const db PI = acos(-1.0);
const int maxn = 2e5 + 7;
const int mod = 1e9 + 7;

struct node
{
	int x, y;
	node(int a, int b):x(a), y(b){}
};

ll C1[maxn], C2[maxn];

inline int read(void)
{
	int x = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9')	{ if(ch == '-') f = -1; ch = getchar(); } 
	while(ch >= '0' && ch <= '9') {	x = (x << 1) + (x << 3) + ch - '0';	ch = getchar();	}
	return x * f;
}

inline void write(ll x)
{
	if(x < 0) { putchar('-'); x = -x; }
    if(x>=10) write(x/10); 
	putchar(x%10+'0'); 
}

ll find(ll a, ll b)
{
	if(a == 1) return 1;
	ll ans = b / a + 1;
	ans = ans * find(a*ans-b, b) % b;
	return ans;
}

int main(void)
{
	int n = read(), m = read(), a = read(), b = read();
	node begin(1, 1), mid(n-a, b+1), end(n, m);
	C1[0] = C2[0] = 1;
	int n1 = n-a-1+b, n2 = a+m-b-1;
	C1[n1] = C2[n2] = 1;
	rep1(i, 1, n1/2) C1[n1-i] = C1[i] = C1[i-1] * (n1 - i + 1) % mod * find(i, mod) % mod;
	rep1(i, 1, n2/2) C2[n2-i] = C2[i] = C2[i-1] * (n2 - i + 1) % mod * find(i, mod) % mod;
//	if((n1&1)== 0) cout<<C1[n1/2-1]<<" "<<C1[n1/2]<<" "<<C1[n1/2+1]<<endl;
//	else cout<<C1[n1/2]<<" "<<C1[n1/2+1]<<endl;
//	if((n2&1) == 0) cout<<C2[n2/2-1]<<" "<<C2[n2/2]<<" "<<C2[n2/2+1]<<endl;
//	else cout<<C2[n2/2]<<" "<<C2[n2/2+1]<<endl;
	ll ans = 0;
	while(mid.x > 0 && mid.y <= m)
	{
		ans = (ans + C1[mid.y-1] * C2[end.y-mid.y] % mod) % mod;
		--mid.x;
		++mid.y;
	}
	cout<<ans;
	
	return 0;
} 

Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>

int main( int argc, char *argv[] )
{
    int n, x, y;
    int c[2001];

    scanf( "%d %d %d", &n, &x, &y );

    for( int i=0; i<n; i++ ) c[i] = 0;

    for( int i=1; i<=n-1; i++ ) for( int j=i+1; j<=n; j++ ) {
        int t1 = j - i;
        int t2 = abs(x-i) + 1 + abs(y-j);
        int t = t1 < t2 ? t1 : t2;
        c[t] ++;
    }

    for( int i=1; i<n; i++ ) printf( "%d\n", c[i] );
}


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

int main(){

  int x, a, b;

  cin >> x >> a >> b;

  if(b-a > x){
    cout << "dangerous" <<  endl;
  }else if(b <= a){
    cout << "delicious" << endl;
  }else{
    cout << "safe" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#define llint long long

using namespace std;

llint n;
llint a[200005];

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> a[i];
	
	int odd = 0, even = 0;
	for(int i = 1; i <= n; i++){
		if(a[i]%2) odd++;
		else even++;
	}
	if(odd && even){
		if(odd % 2 == 0) cout << n-2 << endl;
		else cout << n-1 << endl;
	}
	else cout << 0 << endl;
	
	return 0;
}



Measured memory_bytes: 4716
S = input()

S = set(S)
flag = True
alphabet = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
for i in alphabet:
    if i not in S:
        print(i)
        flag = False
        break
if flag:
    print("None")

Measured memory_bytes: 9168
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <list>
#include <vector>

int main() {
	int D, N;
	std::scanf("%d %d", &D, &N);
	int ans = 0;
	for (int i = 0; i < N; ++i) {
		ans += (int) std::pow(100, D);
		if (ans % (int) std::pow(100, D + 1) == 0) {
			ans += (int) std::pow(100, D);
		}
	}
	std::printf("%d", ans);
}

Measured memory_bytes: 256
h,w=map(int,input().split())
a=[]
s="#"*(w+2)
for i in range(h):
  a.append([i for i in input()])
  a[i].insert(0,"#")
  a[i].append("#")
print(s)
for i in a:
  print("".join(i))
print(s)

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

using namespace std;

typedef long long int ll;
typedef pair<int,int> ii;

const int N = 1e5 + 5;

int a,b,c,ans;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  cin >> a >> b >> c;
  if (a == b && b == c) {
    if (a % 2 == 1)
      cout << "0\n";
    else
      cout << "-1\n";
    return 0;
  }
  while(1) {
    if (a % 2 == 1 || b % 2 == 1 || c % 2 == 1)
      break;
    int ta = b / 2 + c / 2;
    int tb = a / 2 + c / 2;
    int tc = a / 2 + b / 2;
    a = ta;
    b = tb;
    c = tc;
    ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import bisect
import re

N, Q = map(int, input().split())
S = input()
P = [list(map(int, input().split())) for _ in range(Q)]

r = re.compile('AC')
a = [x.start() for x in r.finditer(S)]

if a:
    for q in P:
        p1 = bisect.bisect_left(a, q[0] - 1)
        p2 = bisect.bisect_right(a, q[1] - 2)
        print(p2 - p1)
else:
    for q in P:
        print(0)


Measured memory_bytes: 30464
use std::io;
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut n = String::new();
    io::stdin().read_line(&mut n).unwrap();
    n.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut n = String::new();
    io::stdin().read_line(&mut n).unwrap();
    n.trim()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
fn main() {
    let mut count = [0; 26];
    loop {
        let s: String = read();
        if s == String::default() {
            break;
        }
        for c in s.chars() {
            if c.is_lowercase() {
                count[c as usize - 97] += 1;
            } else if c.is_uppercase() {
                count[c as usize - 65] += 1;
            }
        }
    }
    for i in 0..26 {
        println!("{} : {}", (i + 97) as u8 as char, count[i]);
    }
}



Measured memory_bytes: 5028
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using P = pair<int,int>;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0L)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

//----***定数***----
#define MOD 1_000_000_007
#define INF 10*10
#define EPS 1e-9

//----***パーツ***----
#define fr first
#define se second

//----***入出力***---
#define print(out) cout<< out  << "\n";
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0);
#define dbg cerr<<"🥺🥺🥺🥺🥺🥺"<<endl;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}initial_;

int N,M,K;
string S;

signed main(){
  cin>>N;
  int a;
  vector<int> v(N,0);
  REP(i,1,N){
    cin>>a;
    a--;
    v[a]++;
  }
  REP(i,0,N){
    print(v[i])
  }



}


Measured memory_bytes: 4764
import java.util.Scanner;

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

            int n = sc.nextInt();
            int k = sc.nextInt();
            int hoge = 1;
            for(int i = 0; i < n; i++){
                if(hoge <= k){
                    hoge *= 2;
                }
                else{
                    hoge += k;
                }
            }            
            System.out.println(hoge);

            sc.close();
		  }
}

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

using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)

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

#define MAX 100005
#define INF 1001001001

int main(int, char**)
{
  string t;
  cin >> t;

  int ts = t.size();
  vector<int> sa(ts+1), rank(ts+1);
  int k;

  auto comp_sa = [&] (int i, int j) -> bool {
    if (rank[i] != rank[j]) return rank[i] < rank[j];
    int ri = i+k<=ts ? rank[i+k] : -1;
    int rj = j+k<=ts ? rank[j+k] : -1;
    return ri < rj;
  };

  rep(i,ts+1) {
    sa[i] = i;
    rank[i] = i < ts ? t[i] : -1;
  }
  for (k = 1; k <= ts; k <<= 1) {
    sort(sa.begin(), sa.end(), comp_sa);
    int tmpr = 0;
    vector<int> tmpr_v(ts+1);
    rep(i,ts+1) {
      tmpr_v[sa[i]] = tmpr;
      if (i < ts && comp_sa(sa[i], sa[i+1])) tmpr++;
    }
    rep(i,ts+1) rank[i] = tmpr_v[i];
  }

  int q;
  cin >> q;
  vector<int> ans;
  rep(i,q) {
    string p;
    cin >> p;

    int l = 0, r = ts;
    int found = 0;
    while (r>=l) {
      int m = (r+l)/2;
      int res = t.compare(sa[m], p.size(), p);
      if (res < 0) l = m+1;
      else if (res > 0) r = m-1;
      else {
        found = 1;
        break;
      }
    }
    ans.push_back(found);
  }
  for (auto a : ans) cout << a << endl;

  return 0;
}



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

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; }

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


  for(int i = 1; i*k <= b; i++){
    if(i*k >= a && i*k <= b){
      cout<<"OK";
      return 0;
    }
  }
  cout<<"NG";
}


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

int main()
{
string S;cin>>S;
int ans=1000;
for(int i=0;i<S.size()-2;i++)ans=min(ans,abs(100*(S[i]-'0')+10*(S[i+1]-'0')+S[i+2]-'0'-753));
printf("%d",ans);
}

Measured memory_bytes: 256
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};

#[fastout]
fn main() {
    input! {//
        n:usize,t:usize,s:usize
    }
    yn(n <= t * s);
}
pub fn yn(ans: bool) {
    if ans {
        println!("Yes");
    } else {
        println!("No");
    }
}


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

int main(){
    int N;
    int C[501];
    int S[501];
    int F[501];
    int ans[501]={};


    cin >> N;
    for(int i=1;i<N;i++){
        cin >> C[i] >> S[i] >> F[i];
    }

    for(int i=1;i<=N;i++){
        int time_now=0;
        for(int j=i;j<N;j++){
            if(S[j]>time_now){
                time_now=S[j];
            }
            int temp=(time_now-S[j])%F[j];
            if (temp){
                time_now+=(F[j]-temp);
            }
            time_now+=C[j];
        }
        ans[i]=time_now;
    }

    for(int i=1;i<=N;i++){
        cout << ans[i] << "\n";
    }


    return 0;
}

Measured memory_bytes: 256