akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <algorithm>
#include <cmath>
#include <vector>
#include <regex> //正規表現
#include <map>
#include <set>
#include <cassert> //assart
#include <numeric>
#include <iterator>
#include <list>

using namespace std;
#define ll long long int
#define FOR(i,min,max) for(int i=(min);i<(max);i++)
#define FOReq(i,min,max) for(int i=(min);i<=(max);i++)
#define FORREV(i,max,min) for(int i=(max)-1;i>=(min);i--)
#define FORREVeq(i,max,min) for(int i=(max);i>=(min);i--)
const int  MOD=1e9+7;
const int  INF=2000000000;
const int INF2=  10000000;
const double  Micro=1e-5;

int UnUsedVariable(){
    if(INF || Micro || MOD || INF2){;}
    return 0;
}

#define pf printf
#define sf scanf
#define inarray(array,min,max) FOR(i,min,max){cin>>array[i];}
#define inarrayW(arrayA,arrayB,min,max) FOR(i,min,max){cin>>arrayA[i]>>arrayB[i];}
inline int isEven(int x){return x%2==0;}
inline int isOdd (int x){return x%2==1;}
#define br printf("\n");
#define OutputAndReturn0(x) {cout<<(x)<<endl;return 0;}

int EintN(int array[],const int num){
    for(int i=0;i<num;i++){printf("%d ",array[i]);}
    br;
    return 0;
}
int EintNN(const int heighth,const int width,int array[heighth][width]){
    FOR(i, 0, heighth){
        FOR(k, 0, width){
            {printf("%d ",array[i][k]);}
        }
        br;
    }
    br;
    return 0;
}
int Eint(string str,const int num){
    cerr<<str<<" is "<<num<<" now."<<endl;
    return 0;
}
int AllElementChange0(int array[],const int num){
    for(int i=0;i<num;i++){array[i]=0;}
    return 0;
}


int test(){
    return 0;
}

int Ap(){
    int ans;ans=0;
    
    return 0;
}

int Bp(){
    int ans;ans=0;
    
    return 0;
}

ll gcd(ll a,ll b){//最大公約数 なお一方が0なら答えは他方になるので番兵は０で良い また、負の数もOK -4%3=-1となるため
    if(b==0){
        return a;
    }else{
        return gcd(b,a%b);
    }
}

int Cp(){
    int ans;ans=0;
    int N,Q;
    string S;
    cin>>N>>Q>>S;
    int PositionAofAC[N],countAofAC[N];
    AllElementChange0(PositionAofAC, N);
    AllElementChange0(countAofAC, N);
    FOR(i, 1, N){
        if(S[i]=='C' and S[i-1]=='A'){PositionAofAC[i]=1;}
    }
    FOR(i, 1, N){
        countAofAC[i]=PositionAofAC[i]+countAofAC[i-1];
    }
    
    int answer[Q];
    FOR(i, 0, Q){
        int a,b;
        cin>>a>>b;
        answer[i]=countAofAC[b-1]-countAofAC[a-1];
    }
    FOR(i, 0, Q){
        cout<<answer[i]<<endl;
    }
    
    //EintN(PositionAofAC, N);
    //EintN(countAofAC, N);
    
    
    //OutputAndReturn0(ans);
    return 0;
}

int Dp(){
    int ans;ans=0;
    
    return 0;
}

signed main(){
    //test();
    //Ap();
    //Bp();
    Cp();
    //Dp();
    return 0;
}


Measured memory_bytes: 2240
from collections import defaultdict

n, m = map(int, input().split())
h_s = list(map(int, input().split()))

roads = defaultdict(list)
for i in range(m):
    a, b = map(int, input().split())
    roads[a].append(b)
    roads[b].append(a)

ans = n
for i in range(n):
    for couho in roads[i + 1]:
        if h_s[i] <= h_s[couho - 1]:
            ans -= 1
            break

print(ans)


Measured memory_bytes: 102944
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n; cin >> n;
  long long ans;
  for (ans = 1; ans * ans <= n; ++ans) {}
  cout << (ans - 1) * (ans - 1) << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
//#include <cmath>
#include <vector>
// #include <algorithm>
// #include <bits/stdc++.h>
using namespace std;

int main() {
  int n=0;
  cin >> n;

  vector<int> v(n);
  for(int i=0; i<n; i++)
    cin >> v[i];
  
  for(int j=n-1; j>=0; j--) {
    cout << v[j];
    if (j!=0) cout << " ";
  }

  cout << endl;
  return 0;
}



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

using namespace std;

#define pb push_back
#define mp make_pair
#define fs first
#define fst first
#define sc second
#define snd second
#define sz(X) (int)(X).size()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define fornr(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define forab(i, a, b) for(int i = int(a); i < int(b); i++)
#define all(X) X.begin(), X.end()

typedef long long ll;
typedef pair<int, int> pii;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef double dbl;
typedef long double ld;
typedef vector<int> vi;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, m, k;
    cin >> n >> m >> k;
    vector<vi> a(n, vi(m));
    forn(i, n) {
        string s;
        cin >> s;
        forn(j, m) a[i][j] = (s[j] - '0');
    }
    int M = (1 << (n - 1));
    int ans = 2e9;
    forn(mask, M) {
        vector<vi> b;
        b.pb(a[0]);
        int cnt = 0;
        forab(i, 1, n) {
            if (mask & (1 << (i - 1))) {
                forn(j, m) b.back()[j] += a[i][j];
            } else {
                b.pb(a[i]);
                cnt++;
            }
        }
        int l = sz(b);
        vector<vi> pref(l, vi(m + 1));
        forn(i, l) {
            forn(j, m) pref[i][j + 1] = pref[i][j] + b[i][j];
        }
        vi dp(m + 1, 1e9);
        dp[0] = 0;
        forab(i, 1, m + 1) {
            forn(prev, i) {
                bool ok = true;
                forn(j, l) {
                    if (pref[j][i] - pref[j][prev] > k) {
                        ok = false;
                        break;
                    }
                }
                if (ok) dp[i] = min(dp[i], dp[prev] + 1);
            }
        }
        ans = min(ans, dp[m] + cnt);
    }
    cout << ans-1 << "\n";
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
#include <list>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}
long long GCD(long long n, long long m) {
    return m ? GCD(m, n % m) : n;
}

int main(){
    int N,M; cin >> N >> M;
    string S,T; cin >> S >> T;
    ll g = GCD(N,M);
    ll out = N/g*M;
    N /= g; M /= g;
    bool f=true;
    for(long long i=0;i<g;i++){
        if(S[i*N] != T[i*M]){
            f = false;
            break;
        }
    }
    if(f) cout << out << endl;
    else cout << -1 << endl;

    return 0;
}


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

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

const ll INF=1e18;
const int MOD=1e9+7;

int main(){
    int N; cin >> N;
    ll a[N][N];
    bool use[N][N];
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            cin >> a[i][j];
            use[i][j]=true;
        }
    }
    ll ans=0;
    for(int k=0;k<N;k++){
        for(int i=0;i<N;i++){
            for(int j=0;j<N;j++){
                if(a[i][j]>(a[i][k]+a[k][j])){
                    cout << -1 << endl;
                    return 0;
                }else if((i!=k)&&(j!=k)){
                    if(a[i][j]==(a[i][k]+a[k][j])){
                        use[i][j]=false;
                    }   
                }
            }
        }
    }
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            if(use[i][j]) ans+=a[i][j];
        }
    }
    cout << ans/2 << endl;
}

Measured memory_bytes: 4424
#include<cstdio>
#include<cstring>
#include<iostream>
#include<cmath>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
using namespace std;
typedef long long LL;
const int MR=1e6+10;


int main(){
	LL n;
	cin>>n;
	LL ans=0;
	for(LL d=1;d<=n;d++){
		ans+=d*(n/d)*(n/d+1)/2;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3620
#include<iostream>
#include<algorithm>
#include <cassert>
#include<string>
#include<vector>
#include <utility>
#include <math.h>
#include<cmath>
#include<map>
#include <limits>
# include <iomanip>
#define INF 1000000009;
using namespace std;
int gcd(int a, int b) {
	while (a % b != 0) {
		int c = 0;
		c = a % b;
		a = b;
		b = c;
	}
	return  b;
}
int kaizyo(int a) {
	long long ans = 1;
	for (int i = a; i > 0; i--) {
		ans *= i;
		ans = ans % 1000000007;
		//cout << ans << endl;
	}
	ans = ans % 1000000007;
	return ans;
}
void keta(string s) {
	for (int i = 0; i < s.size(); i++) {

	}
}
int main() {
	int N = 0;
	cin >> N;
	int a[200005] = { 0 };
	int b[200005] = { 0 };
	for (int i = 1; i <= N; i++) {
		cin >> a[i];
		b[i] = a[i];
	}
	sort(a, a + N+1);
 // cout<<a[]<<endl;
	for (int i = 1; i <= N; i++) {
		if (b[i]<= a[N / 2]) {
			cout << a[N / 2 + 1] << endl;
		}
		else {
			cout << a[N / 2] << endl;
         
          
		}
	}
	return 0;
}


Measured memory_bytes: 3712
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<ctime>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<cstring>
#include<map>
#include<vector>
#include<set>
#define rep(i,j,k) for(register int i = j; i <= k; i++) 
#define dow(i,j,k) for(register int i = j; i >= k; i--)
#define fi first
#define se second
//#define P pair<ull,ull>
//#define PP pair<int,pair<int,int> >
//#define mp(a,b) make_pair(a,b)
#define ll long long
#define ull unsigned long long
using namespace std;
 
inline int read() { 
	int s = 0, t = 1; char c = getchar();
	while( !isdigit(c) ) { if( c == '-' ) t = -1; c = getchar(); }
	while( isdigit(c) ) s = s * 10 + c - 48, c = getchar();
	return s * t;
}

const int N = 305;
int n, m, f[N][N], num[N], l[N]; bool vis[N];
struct node{ int x, d; node(int a,int b) { x = a, d = b; } bool operator < (const node&rhs) const { return d < rhs.d; } };
queue<int> q;
vector<int> g[N];
inline bool check(int X) { 
//	cout<<"C "<<X<<endl;
	int y, z;
	while( !q.empty() ) q.pop();
	rep(i,1,m) vis[i] = 1, num[i] = 0, g[i].clear();
	rep(i,1,n) num[f[i][l[i]=1]]++, g[f[i][l[i]]].push_back(i);
	rep(i,1,m) if( num[i] > X ) q.push(i);
	while( !q.empty() ) { 
		int x = q.front(); q.pop();
		num[x] = 0, vis[x] = 0;
//		cout<<"W "<<x<<endl;
		for(vector<int>::iterator it = g[x].begin(); it != g[x].end(); it++) { 
			y = *it, l[y]++;
			while( l[y] <= m && !vis[f[y][l[y]]] ) l[y]++;
//			cout<<"T "<<y<<" "<<l[y]<<endl;
			if( l[y] <= m ) { 
				z = f[y][l[y]];
				num[z]++, g[z].push_back(y);
				if( num[z] > X ) q.push(z);
			} else return 0;
		} g[x].clear();
	} return 1;
}

int main() {
	n = read(), m = read();
	rep(i,1,n) rep(j,1,m) f[i][j] = read();
	int l = 1, r = n, mid;
	while( l < r ) { 
		mid = (l + r) >> 1;
		if( check(mid) ) r = mid;
		else l = mid + 1;
	} cout<<l<<endl;
	return 0; 
}

Measured memory_bytes: 1280
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <functional>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
using namespace std;

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

inline void init() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int n, a[101];

int f(int x) {
  if (1 <= x && x <= 399) {
    return 0;
  }
  if (400 <= x && x <= 799) {
    return 1;
  }
  if (800 <= x && x <= 1199) {
    return 2;
  }
  if (1200 <= x && x <= 1599) {
    return 3;
  }
  if (1600 <= x && x <= 1999) {
    return 4;
  }
  if (2000 <= x && x <= 2399) {
    return 5;
  }
  if (2400 <= x && x <= 2799) {
    return 6;
  }
  if (2800 <= x && x <= 3199) {
    return 7;
  }
  // 3200 ~
  return 8;
}

int main(void) {
  init();
  cin >> n;
  rep(i,n) cin >> a[i];

  int used[9] = {0}, x;

  rep(i,n) {
    x = f(a[i]);
    if (x != 8 && used[x] == 0) {
      used[x] = 1;
    }
    else if (x == 8) {
      used[x]++;
    }
  }

  int mi, ma, red;
  mi = ma = red = 0;
  
  for (int i = 0; i < 9; ++i) {
    if (i != 8 && used[i] == 1) {
      mi++;
      ma++;
    }
    else if (i == 8) {
      red = used[i];
    }
  }

  if (mi == 0 && red > 0) {
    mi = 1;
    ma = red;
  }
  else {
    ma = ma + red;
  }
  
  cout << mi << " " << ma << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <array>
#include <cmath>
#include <queue>
#include <stack>
#include <numeric>

using namespace std;


int main() {
	char a;
	cin >> a;
	if (a == 'Q' || a == 'W' || a == 'E' || a == 'R' || a == 'T' || a == 'Y' || a == 'U' || a == 'I' || a == 'O' || a == 'P' || a == 'L' || a == 'K' || a == 'J' || a == 'H' || a == 'G' || a == 'F' || a == 'D' || a == 'S' || a == 'A' || a == 'Z' || a == 'X' || a == 'C' || a == 'V' || a == 'B' || a == 'N' || a == 'M')cout << 'A';
	if (a == 'q' || a == 'w' || a == 'e' || a == 'r' || a == 't' || a == 'y' || a == 'u' || a == 'i' || a == 'o' || a == 'p' || a == 'l' || a == 'k' || a == 'j' || a == 'h' || a == 'g' || a == 'f' || a == 'd' || a == 's' || a == 'a' || a == 'z' || a == 'x' || a == 'c' || a == 'v' || a == 'b' || a == 'n' || a == 'm')cout << 'a';
}

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

int main()
{
    string str, ins, p;
    int q, a, b;
    cin >> str >> q;
    
    for (int i = 0; i < q; i++) {
        cin >> ins;
        if (ins == "print") {
            cin >> a >> b;
            for (int i = a; i <= b; i++) {
                putchar(str[i]);
            }
            putchar('\n');
        }
        else if (ins == "reverse") {
            cin >> a >> b;
            reverse(str.begin()+a, str.begin()+b+1);
        }
        else if (ins == "replace") {
            cin >> a >> b >> p;
            for (int i = a; i <= b; i++) {
                str[i] = p[i-a];
            }
        }
    }
}



Measured memory_bytes: 3216
n=int(input())
a=list(map(int, input().split()))
mod=10**9+7

from collections import Counter
c=Counter(a)

cnt_lst=[0]*n
for key in c:
    cnt_lst[key]+=c[key]

flag=True
if n%2==1:
    if cnt_lst[0]==1:
        cnt_lst.pop(0)
    else:
        flag=False
    for i in range(n-1):
        if (i%2==1 and cnt_lst[i]!=2) or (i%2==0 and cnt_lst[i]!=0):
            flag=False
else:
    for i in range(n):
        if (i%2==1 and cnt_lst[i]!=2) or (i%2==0 and cnt_lst[i]!=0):
            flag=False

print(2**(n//2)%mod if flag else 0)

Measured memory_bytes: 14692
import java.util.Scanner;
import java.util.Stack;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		Stack<String> s = new Stack<String>();

		while (sc.hasNext()) {
			String num = sc.nextLine();
			if (num.equals("0"))
				System.out.println(s.pop());
			else
				s.add(num);

		}
	}

}

Measured memory_bytes: 17156
n = int(input())
dat = list(map(int, input().split()))
dat_d = []

total = 0
for i in range( n):
    total += (dat[i] - (i+1))
    dat_d.append(dat[i] - (i+1))

#print(dat)
#print(dat_d)
#print(total)
#f = (total // n)
#print(f)

dat_d.sort()
#print(dat_d)
f = dat_d[n//2]

total = 0
for i in range( n):
    total += abs(dat_d[i] - f)

print(total)

Measured memory_bytes: 98132
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int bufIdx = 0;
    char[] buf = new char[s.length()];
    for (int i = 0; i < s.length(); i++) {
      char c = s.charAt(i);
      if (c == '0' || c == '1') {
        buf[bufIdx] = c;
        bufIdx++;
      } else if (c == 'B' && bufIdx != 0) {
        bufIdx--;
      }
    }
    
    for (int i = 0; i < bufIdx; i++) {
      System.out.print(buf[i]);
    }
    System.out.println();
  }
}

Measured memory_bytes: 21844
N, M = map(int, input().split())

num = [-1] * N
s = [0] * M
c = [0] * M

for i in range(M):
    s[i], c[i] = map(int, input().split())

ans = -1
check = True

for i in range(M):
    j = s[i] - 1
    if num[j] == -1:
        num[j] = c[i]
    if num[j] != c[i]:
        check = False
        break

if check:
    for i in range(N):
        if num[i] == -1:
            if i == 0:
                num[i] = 1
            else:
                num[i] = 0
    num_int = int("".join(map(str, num)))
    if len(num) == len(str(num_int)):
        ans = num_int

if M == 0:
    if N == 1:
        ans = 0
    elif N == 2:
        ans = 10
    elif N == 3:
        ans = 100

print(ans)


Measured memory_bytes: 3064
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var S = ReadLine();

        var ans = 0;
        var now = 0;

        for (int i = 0; i < S.Length; i++)
        {
            if (S[i] == 'R')
                now++;
            else
                now = 0;

            ans = Math.Max(ans, now);
        }

        WriteLine(ans);
    }
}


Measured memory_bytes: 25940
package main

import (
	"bufio"
	"fmt"
	"math/bits"
	"os"
	"reflect"
	"strconv"
)

const (
	maxBufSize = 1024 * 1024
)

var (
	sc = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, 1)
		sc.Buffer(buf, maxBufSize)
		sc.Split(bufio.ScanWords)
		return sc
	}()
	out = bufio.NewWriter(os.Stdout)
)

func solve(n int64, as []int64, xs [][]int64 , ys [][]int64) int64 {
	ret := int64(0)
LBL0:
	for b := 1; b < (1 << n); b ++ {
		for i, _ := range as {
			if (1 << i) & b == 0 {
				continue
			}
			for j, x := range xs[i] {
				y := ys[i][j]
				if y == 1 {
					if (1 << x) & b == 0 {
						continue LBL0
					}
				} else {
					if (1 << x) & b != 0 {
						continue LBL0
					}
				}
			}
		}
		bitCount := int64(bits.OnesCount64(uint64(b)))
		if bitCount > ret {
			ret = bitCount
		}
	}
	return ret
}


func main() {
	defer out.Flush()

	n := nextInt()
	as := make([]int64, n)
	xs := make([][]int64, n)
	ys := make([][]int64, n)

	for i, _ := range as {
		as[i] = nextInt()
		xs[i] = make([]int64, as[i])
		ys[i] = make([]int64, as[i])
		for j, _ := range xs[i] {
			xs[i][j] = nextInt() - 1
			ys[i][j] = nextInt()
		}
	}

	res := solve(n, as, xs, ys)
	fmt.Fprintln(out, res)
}

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextStringAsBytes() []byte {
	sc.Scan()
	return []byte(sc.Text())
}

func nextInt() int64 {
	a, _ := strconv.ParseInt(next(), 10, 64)
	return a
}

func nextFloat() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int64) []int64 {
	ret := make([]int64, n)
	for i := int64(0); i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}

func nextFloats(n int64) []float64 {
	ret := make([]float64, n)
	for i := int64(0); i < n; i++ {
		ret[i] = nextFloat()
	}
	return ret
}
func nextStrings(n int64) []string {
	ret := make([]string, n)
	for i := int64(0); i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func containStr(arr []string, target string) bool {
	for _, v := range arr {
		if v == target {
			return true
		}
	}
	return false
}

func PrintOut(src interface{}, joinner string) {
	switch reflect.TypeOf(src).Kind() {
	case reflect.Slice:
		s := reflect.ValueOf(src)
		for idx := 0; idx < s.Len(); idx++ {
			fmt.Fprintf(out, "%v", s.Index(idx))
			if idx < s.Len()-1 {
				fmt.Fprintf(out, "%s", joinner)
			} else {
				fmt.Fprintln(out)
			}
		}
	default:
		fmt.Fprintln(out, "orz")
	}
}

// mapからkeysとvaluesを返す
func splitKeyValue(m map[interface{}]interface{}) (keys, values []interface{}) {
	switch reflect.TypeOf(m).Kind() {
	case reflect.Map:
		s := reflect.ValueOf(m)
		for _, v := range s.MapKeys() {
			keys = append(keys, v)
			values = append(values, s.MapIndex(v))
		}
	default:
		fmt.Fprintln(out, "orz")
	}
	return
}


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

using ll = long long;
using ull = unsigned long long;
using st = string;
using db = double;
using vll = vector<long long>;
using vvll = vector<vll>;
using vst = vector<st>;
using vchar = vector<char>;
#define rep(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define vrep(i, vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
ll mod = 1000000007;


int main(){
  ull n;
  cin >> n;
  ull ans = 1;
  rep(i, 0, n) ans = ans * (i + 1) % mod;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define print(...) {for(auto x: __VA_ARGS__) cout<<x<<" ";}
#define debug(...) {cout<<#__VA_ARGS__": ";print(__VA_ARGS__);cout<<endl;}
using namespace std;

int n;

int main() {
    cin >> n;
    int a, b, ba;
    a = b = ba = 0;
    long long ans = 0;
    for(int i = 0; i < n; i++) {
        string s;
        cin >> s;
        int l = s.size();
        for(int i = 0; i < l; i++) {
            if(s.substr(i,2) == "AB")
                ans++;
        }
        if(s[0] == 'B')
            b++;
        if(s[l-1] == 'A')
            a++;
        if(s[0] == 'B' && s[l-1] == 'A')
            ba++;
    }

    a -= ba;
    b -= ba;
    if(a == 0 && b == 0 && ba > 0)
        ans += ba-1;
    else
        ans += ba + min(a, b);

    cout << ans << endl;
}


Measured memory_bytes: 256
use std::io;
use std::io::Read;

const modulus :usize = 1000000007;

fn main(){
    let mut stdin = io::stdin();
    let mut lines_str = String::new();
    let _ = stdin.read_to_string(&mut lines_str);
    let lines_vec = lines_str.lines().collect::<Vec<&str>>();
    let line0_vec = lines_vec[0].split(' ').collect::<Vec<&str>>();
    let n :usize = line0_vec[0].trim().parse().unwrap(); //n >= 3
    let mut k :usize = line0_vec[1].trim().parse().unwrap(); //k >= 2

    // prepare a table of factorials
    let mut fac_vec :Vec<usize> = Vec::new();
    let mut fac_inv_vec :Vec<usize> = Vec::new();
    fac_vec.push(1);
    fac_inv_vec.push(1);
    for i in 1..(n+1) {
        fac_vec.push((i*fac_vec[i-1]) % modulus);
        fac_inv_vec.push(mod_inv(fac_vec[i]));
    }
    let fac_vec = fac_vec;
    let fac_inv_vec = fac_inv_vec;

    // normalize k
    if k >= n {
        k = n - 1;
    }
    let k = k;

    let mut total = 0;
    for i in 0..(k+1) {
        let mut thispart = (fac_vec[n] * fac_inv_vec[i]) % modulus;
        thispart = (thispart * fac_inv_vec[n-i]) % modulus;
        thispart = (thispart * fac_vec[n-1]) % modulus;
        thispart = (thispart * fac_inv_vec[n-i-1]) % modulus;
        thispart = (thispart * fac_inv_vec[i]) % modulus;
        total = (total + thispart) % modulus;
    }

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

// https://math.nakaken88.com/textbook/cp-modulo-operation-inverse-element/
fn mod_pow(base :usize, index :usize) -> usize {
    if index == 0 {
        return 1;
    } else if index == 1 {
        return base % modulus;
    } else {
        if index % 2 == 0 {
            let tmp = mod_pow(base, index/2);
            return (tmp * tmp) % modulus;
        } else {
            let tmp = mod_pow(base, index/2);
            return (((tmp * tmp) % modulus) * base ) % modulus;
        }
    }
}

fn mod_inv(x :usize) -> usize {
    return mod_pow(x, modulus-2);
}

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

int main() {
  string S, T;
  cin >> S >> T;
  map<char, char> sm, tm;
  bool ok = true;

  rep(i,S.size()) {
    char s = S[i], t = T[i];
    if (sm.count(s) && sm[s]!=t) ok = false;
    if (tm.count(t) && tm[t]!=s) ok = false;
    sm[s] = t;
    tm[t] = s;
  }
  if (ok) puts("Yes");
  else puts("No");
  return 0;
}

Measured memory_bytes: 776
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		String blank = " ";
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		for (int i = 1; i <= n; i++) {
			int x = i;
			if (x %3 == 0) {
				System.out.print(blank + i);
				continue;
			}
			if (x %10 == 3) {
				System.out.print(blank + i);
				continue;
			}
			while ((x/= 10) != 0) {
				if (x %10 == 3) {
					System.out.print(blank + i);
					break;
				}
			}
		}
		System.out.println("");
	}
}

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> ans(n, 0);
  for (int i = 0; i < m; i++) {
    int s, c;
    cin >> s >> c;
    s = n - s;
    if (ans[s] != 0 && ans[s] != c) {
      cout << -1 << endl;
      return 0;
    }
    if (s == n - 1 && c == 0 && n != 1) {
      cout << -1 << endl;
      return 0;
    }
    ans[s] = c;
  }
  int ansi = 0;
  if (ans[n - 1] == 0 && n != 1)
    ans[n - 1] = 1;
  for (int i = 0; i < n; i++)
    ansi += ans[i] * pow(10, i);
  cout << ansi << endl;
}


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

class Main{

		public static void main(String[] args)throws IOException{
			InputStreamReader isr = new InputStreamReader(System.in);
			BufferedReader br = new BufferedReader(isr);
			String buf = br.readLine();
			int x = Integer.parseInt(buf);
			System.out.println(x*x*x);
	}
}

Measured memory_bytes: 24168
#include <iostream>
#include <string>

using namespace std;

int main(void){
	bool 	first=true;
	string	team;
	int	w,d,l;

	for(int n;cin >> n,n;){
		pair<string,int> *val,tmp;

		val = new pair<string,int>[n];

		for(int i=0;i<n;i++){
			cin >> team >> w >> l >> d;
			val[i]=make_pair(team,w*3+d);
		}

		for(int i=0;i<n-1;i++)
			for(int j=0;j<n-i-1;j++)
				if(val[j].second<val[j+1].second){
					tmp=val[j];
					val[j]=val[j+1];
					val[j+1]=tmp;
				}

		if(!first)
			cout << endl;
		else
			first=false;

		for(int i=0;i<n;i++)
			cout << val[i].first << "," << val[i].second << endl;
		delete [] val;
	}
	return 0;
}

Measured memory_bytes: 1216
#include <stdio.h>

int main(){
  int a,b;
  scanf("%d %d", &a, &b);
  if (a < b){
    printf("a < b\n");
      }
  if(a > b){
    printf("a > b\n");
      }
  if(a == b){
    printf("a == b\n");
  }
  return 0;
}

Measured memory_bytes: 580
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

#define SENTINEL 1000000000000000000

void merge(long long A[], long long left, long long mid, long long right){
  long long n1, n2, i, j, k;
  long long *L,*R;
  
  n1 = mid-left;
  n2 = right-mid;
  
  L = (long long*)malloc(sizeof(long long) *(n1 + 1));
  R = (long long*)malloc(sizeof(long long) *(n2 + 1));
  
  for(i = 0; i <= n1 - 1; i++){
    L[i] = A[left + i];
  }
  for(j = 0; j <= n2 - 1; j++){
    R[j] = A[mid + j];
  }
  
  L[n1] = SENTINEL;
  R[n2] = SENTINEL;
  
  i = 0;
  j = 0;
  
  for(k = left; k <= right - 1; k++){
   if(L[i] <= R[j]){
      A[k] = L[i];
      i++;
    }
    else{
      A[k] = R[j];
      j++;
    }
  }
  free(L);
  free(R);
}

void mergeSort(long long A[], long long left, long long right){
  long long mid;
  
  if(left + 1 < right){
    mid=(left + right)/2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}

int main(void){

    int N;

    scanf("%d", &N);

    long long a[N];

    for(int i = 0; i < N; i++){
        scanf("%lld", &a[i]);
    }

    mergeSort(a, 0, N);

    int x = 1;
    int ans = 0;

    for(int i = 1; i < N; i++){
        if(a[i] != a[i-1]){
            if(x > a[i-1]){
                ans += (x - a[i-1]);
            }else if(x < a[i-1]){
                ans += x;
            }
            x = 1;
        }else{
            x++;
        }
    }
    if(x > a[N-1]){
        ans += (x - a[N-1]);
    }else if(x < a[N-1]){
        ans += x;
    }

    printf("%d\n", ans);

    return 0;
}

Measured memory_bytes: 2964
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define PB push_back
#define MP make_pair
#define MOD 1000000007LL
#define endl "\n"
const ll UNDEF = -1;
const ll INF=1e18;
template<typename T> inline bool chkmax(T &aa, T bb) { return aa < bb ? aa = bb, true : false; }
template<typename T> inline bool chkmin(T &aa, T bb) { return aa > bb ? aa = bb, true : false; }

const ll MAXN=1e5+4;
const ll MAXP=MAXN;
bool sieve_array[MAXP+1];
ll sp[MAXP+1];
vector<ll> gpv;
void sieve() {
	for (ll i = 0; i <= MAXP; i++) {
		sieve_array[i] = true;
		sp[i]=INF;
	}
	sieve_array[0] = false; sieve_array[1] = false;
	ll lim = sqrt(MAXP)+1;
	for (ll i = 2; i <= lim; i++) {
		if(sieve_array[i]) {
			for (ll j = i*i; j <= MAXP; j+=i) {
				sieve_array[j] = false;
				chkmin(sp[j],i);
			}
		}
	}
	for (ll i = 2; i <= MAXP; i++) {
		if(sieve_array[i]) {
			gpv.PB(i);
			chkmin(sp[i],i);
		}
	}
}
map<ll,ll> factorize(ll x) {
	map<ll,ll> h;
	while(x>=MAXP) {
		bool found=false;
		for (auto &p:gpv) {
			if (p*p>x) break;
			if ((x%p)==0) {
				x/=p;
				h[p]++;
				found=true;
				break;
			}
		}
		if (!found) break;
	}
	if (x<MAXP) {
		while(x>1) {
		ll p=sp[x];
		x/=p;
		h[p]++;
		}
	}
	if (x>1) h[x]++;
	return h;
}
const ll xlim=1e10+1;
int main() {
	sieve();
	vector<ll> cpv;
	for (auto &w:gpv) {
		ll cw=w*w*w;
		if (cw>xlim) break;
		cpv.PB(cw);
	}
  ll n; scanf("%lld",&n);
	map<ll,ll> h;
	for (ll i=0;i<n;i++) {
		ll x; scanf("%lld",&x);
		for (auto &w:cpv) {
			if (x<w) break;
			while (x%w==0) x/=w;
		}
		h[x]++;
	}
	ll ans=0;
	if (h[1]>0) {
		ans++;
		h.erase(1);
	}
	for (auto &w:h) {
		map<ll,ll> factors=factorize(w.first);
		ll key=1;
		for (auto &w:factors) {
			ll ex=3-w.second;
			for (ll i=0;i<ex;i++) key*=w.first;
		}
		auto it=h.find(key);
		ll other;
		if (it==h.end()) {
			other=0;
		}
		else {
			other=it->second;
			h.erase(it);
		}
		ans+=max(w.second,other);
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 7424
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
ll n,a[200100];
map<ll,int>m;
int main(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    cin>>n;
    for(int i=0;i<n;i++){
    	cin>>a[i];
    }
    ll ans=0;
    for(int i=1;i<n;i++){
    	if(a[i]<a[i-1]){
    		ans+=a[i-1]-a[i];
    		a[i]=a[i-1];
    	}
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 5132
#include <stdio.h>
 
int main(){
  int i, j;
  char s[128];
  int k = 0;
  
  scanf("%s", s);
  j = atoi(s);
  
  for(i = 0; i < 3; i++){
    if(j % 10 == 1)
      k++;
    j /= 10;
  }
   
  printf("%d\n", k);
  return 0;
}

Measured memory_bytes: 128
a = []
for _ in range(3):
    a.append(list(map(int, input().split())))
n = int(input())

for _ in range(n):
    b = int(input())
    for i in range(3):
        for j in range(3):
            if a[i][j] == b:
                a[i][j] = 0

for i in range(3):
    f = True
    for j in range(3):
        if a[i][j] != 0:
            f = False
            break
    if f:
        print("Yes")
        exit(0)
    
    f = True
    for j in range(3):
        if a[j][i] != 0:
            f = False
            break
    if f:
        print("Yes")
        exit(0)

f = True
for i in range(3):
    if a[i][i] != 0:
        f = False
        break
if f:
    print("Yes")
    exit(0)

f = True
for i in range(3):
    if a[i][2 - i] != 0:
        f = False
        break
if f:
    print("Yes")
    exit(0)

print("No")

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

bool compare_year(pair<long long, long long> left, pair<long long, long long> right)
{
	return left.second < right.second;
}

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

	int N, M;
	scanf("%d %d", &N, &M);

	vector<long long> id(M);
	vector<vector<pair<long long, long long>>> ken(N, vector<pair<long long, long long>>()); // num year

	for (int i = 0; i < M; i++)
	{
		int P, Y;
		scanf("%d %d", &P, &Y);
		// cout << P << " " << Y << "\n";
		ken[P - 1].insert(ken[P - 1].end(), make_pair(i, Y));
	}
	// for (int i = 0; i < N; i++)
	// {
	// 	cout << i << "\n";
	// 	for (auto a : ken[i])
	// 	{
	// 		cout << a.first << " " << a.second << "\n";
	// 	}
	// }

	for (int i = 0; i < N; i++)
	{
		sort(ken[i].begin(), ken[i].end(), compare_year);
	}

	// cout << "=========\n";

	for (int i = 0; i < N; i++)
	{
		// cout << i << "\n";
		for (int j = 0; j < ken[i].size(); j++)
		{
			// cout << ken[i][j].first << " " << ken[i][j].second << "\n";
			id[ken[i][j].first] = (long long)(i + 1) * 1000000 + (long long)j + 1;
		}
	}

	for (int i = 0; i < M; i++)
	{
		printf("%012lld\n", id[i]);
	}

	return 0;
}

Measured memory_bytes: 7808
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);

		while (sc.hasNext()) {

			int num = sc.nextInt();
			int prime_count = 0;

			int [] array = new int[num+1];

			/*エラトステネスの篩*/

			for(int i=2; i<=num; i++){
				array[i] = 0;
			}

			for(int i=2; i<=num; i++){
				if(array[i] == 1) ;
				else{
					for(int j=i+i; j<=num; j=j+i){
						array[j] = 1;
					}
				}
			}

			for(int i=2; i<=num; i++){
				if(array[i] == 0) prime_count++;
			}
			System.out.println(prime_count);
		}
	}
}

Measured memory_bytes: 55028
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<cstring>
#include<queue>
#include<stack>
#include<numeric>
using namespace std;
#define INF (1 << 30) - 1
#define LINF 1LL << 60
const int MOD = 1000000007;
using ll = long long;
using P = pair<int, int>;

int main(){
  int n, m;
  cin >> n >> m;
  vector<int> a(m);
  int sum = 0;
  for(int i = 0; i < m; ++i){
  	cin >> a[i];
  	sum += a[i];
  }

  if(n < sum)cout << -1 << endl;
  else cout << n - sum << endl;
  return 0;
}


Measured memory_bytes: 3636
#include<iostream>
using namespace std;
int main(){
  int n;cin >> n;
  int res = n / 5 * 5;
  for(int i = 0;i < n / 500;i++){
    int t = n - (i + 1) * 500;
    int tmp = t / 5 * 5;
    tmp += (i + 1) * 1000;
    if(res < tmp)res = tmp;
  }
  cout << res << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdio>
#include <istream>
#include <sstream>
#include <iomanip>
#include <iterator>
#include <climits>
using namespace std;

typedef ostringstream OSS;
typedef istringstream ISS;

typedef vector<int> VI;
typedef vector< VI > VVI;

typedef long long LL;

typedef pair<int, int> PII;
typedef vector<PII> VPII;

#define X first
#define Y second

const LL MOD = 1000000007;

template<typename T>
void dump(T a, int n) { for (int i = 0; i < n; i++) cout << a[i] << (i == n - 1 ? '\n' : ' '); }

template<typename T>
void dump(T a) { dump<T>(a, a.size()); }

bool mycomp(pair<double, string> a, pair<double, string> b) {
	if (a.first != b.first) 
		return a.first > b.first;
	return a.second < b.second;
}

int main(void) {
	int N;
	while (cin >> N, N) {
		vector< pair<double, string> > list(N);

		for (auto &x : list) {
			string name;
			int cost;
			int time = 0;
			int time2 = 0;
			int seed;
			int price;
			int loop;

			cin >> name;
			cin >> cost;
			for (int j = 0, temp; j < 5; j++) {
				cin >> temp;
				time += temp;
				if (j >= 3) {
					time2 += temp;
				}
			}
			cin >> seed >> price >> loop;

			double effis = 1. *  (price * seed * loop - cost) / (time + (time2 * (loop - 1)));

			x.first = effis;
			x.second = name;
		}

		sort(list.begin(), list.end(), mycomp);

		for (auto &x : list) {
			cout << x.second << endl;
		}

		cout << "#" << endl;
	}

	return 0;
}

Measured memory_bytes: 1228
// template version 1.15
using namespace std;
#include <bits/stdc++.h>

// varibable settings
#define int long long
const int INF=1e18;

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(a, b, c) make_tuple(a, b, c)
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

#define divceil(a,b) ((a)+(b)-1)/(b)
#define is_in(x, a, b) ((a)<=(x) && (x)<(b))
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define slice(l, r) substr(l, r-l)

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
    #include "lib/dump.hpp"
#else
    #define dump(...) 42
    #define dump_1d(...) 42
    #define dump_2d(...) 42
    #define cerrendl 42
#endif
//}}}

signed main() {
    int n,m;cin>>n>>m;
    vector<int> a(n);
    int s = 0;
    rep(i, n) {
        cin>>a[i];
        s += a[i];
    }
    sort(all(a));
    reverse(all(a));
    dump(a);
    dump(s);
    int c = 0;
    rep(i, n){
        if (a[i]*4*m >= s) c++;
    }

    cout << (c>=m ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 256
n = int(input())
ablist = []

for i in range(n):
    t = list(map(int, input().split()))
    ablist.append(t)

ablist = sorted(ablist, key=lambda x: x[1])

t = 0
flag = True
for i in ablist:
    t += i[0]
    if t > i[1]:
        flag = False

if flag:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 94424
#include <cstdio>
#include <algorithm>
#define MAX_N 1000
#define MAX_W 1000
using namespace std;
int W;
int N; 

int w[MAX_N]; 
int v[MAX_N]; 
int dp[MAX_N + 1][MAX_W + 1];
bool input() 
{
  scanf("%d", &W);
  if(!W) return false;
  scanf("%d", &N);
  for (int i = 0; i < N; i++) 
  {
    scanf("%d,%d", &v[i], &w[i]);
  }
  return true;
}
void solve() 
{

  for (int i = 0; i < N; i++) 
  {
    for (int j = 0; j <= W; j++) 
    {
      if (j < w[i])
      {
        dp[i + 1][j] = dp[i][j];
      } 
      else 
      {
        dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i]);
      }
    }
  }
}

int main() 
{

  int cnt = 0;

  while (input())
  {
    solve();
    int i;
    for (i = W; i >= 0; i--) 
    {
      if (dp[N][W] != dp[N][i]) break;
    }
    printf("Case %d:\n", ++cnt);
    printf("%d\n", dp[N][W]);
    printf("%d\n", i + 1);
  }

  return 0;
}

Measured memory_bytes: 4948
#include <bits/stdc++.h>
using namespace std;
#define push_back pb
#define make_pair mp
using ll =  long long;
const int INF = 0x3f3f3f3f;
const int MAX_M = 1e5+10;
const int DAT_SIZE =  (1<<18)-1;
int N, M;
int L[MAX_M],R[MAX_M];

ll data[DAT_SIZE], datb[DAT_SIZE];

void add(int a, int b, int x, int k, int l, int r)
{
	if(a <=l && b >= r) data[k] += x;
	else if(b > l && a < r){
		datb[k] += (min(b,r) - max(a,l))*x;
		add(a,b,x,2*k+1, l, (l+r)/2);
		add(a,b,x,2*k+2, (l+r)/2, r);
	}
}

ll sum(int a, int b, int k, int l, int r)
{
	if(a >= r || b <= l) return 0;
	else if(a <= l && b >= r) return data[k]*(r-l) + datb[k];
	else{
		ll ret = (min(b,r)-max(a,l))*data[k];
		ret += sum(a, b, 2*k+1, l, (l+r)/2);
		ret += sum(a, b, 2*k+2, (l+r)/2, r);
		return ret;
	}
}

void solve()
{
	for(int i=0;i<M;++i){
		add(L[i],R[i]+1,1,0,0,N);
	}
	int ans = 0;
	for(int i=0;i<N;++i){
		if(sum(i,i+1,0,0,N)==M)ans++;
	}
	cout << ans << endl;
}

int main()
{
	ios::sync_with_stdio(false);
	cin >> N >> M;
	for(int i=0;i<M;++i){
		cin >> L[i] >> R[i];
		L[i]--,R[i]--;
	}
	solve();
	return 0;
}

Measured memory_bytes: 4096
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
#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++)
#define INF 2e9
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long a,b,gyo0=0,gyo1=0,re0=0,re1=0,h,w,count;
    string s;
    cin>>a>>b;
    if(a==1){
        a=INF;
    }
    if(b==1){
        b=INF;
    }
    if(a>b){
        cout<<"Alice";
    }
    if(a==b){
        cout<<"Draw"<<'\n';
    }
    if(a<b){
        cout<<"Bob";
    }
    return(0);
}



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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
// static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

int main(void) {
    int n;
    cin >> n;

    vector<int> a(n);
    for(int in=0;in<n;in++) {
        cin >> a.at(in);
    }

    int ans = 0;
    for(int in=0;in<n;in++) {
        if(in%2==0&&a.at(in)%2==1) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3628
#include<iostream>

#include <vector>
#include <list>
#include<stack>
#include<queue>
#include<array>

#include <set>
#include<map>

#include<string>
#include<stdlib.h>

#include<algorithm>
#include <functional>
#include<math.h>

#include<fstream>
#include<iomanip>
#include<assert.h>

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

#define FOR(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<<str<<endl

constexpr int INF = 100000;
constexpr ll INFL = (1ll << 60);
constexpr ll MOD = 1000000007;// 10^9+7


							  //変数
int N;
vector<pair<ll, ll>> xy;






//サブ関数
//入力
void input()
{
	cin >> N;
	REP(i, N) {
		ll a, b;
		cin >> a >> b;
		xy.push_back({ a,b });
	}
}


//計算
void calc()
{
	bool even = ((xy[0].first + xy[0].second + INFL) % 2 == 0);
	for (auto p : xy) {
		if (even) {
			if ((p.first + p.second + INFL) % 2 != 0) { cout << -1 << endl; return; }
		}
		else {
			if ((p.first + p.second + INFL) % 2 != 1) { cout << -1 << endl; return; }
		}
	}
	constexpr int m = 40;
	cout << m << endl;
	ll D = (even ? 2 : 1);
	REP(i, m - 8) {
		D *= 2;
	}
	D /= 2;

	ll d = D;
	REP(i, m - 8) {
		cout << d << " ";
		d /= 2;
	}
	REP(i, 8)cout << "1 ";
	cout << endl;

	for (auto p : xy) {
		ll x = p.first;
		ll y = p.second;
		d = D;
		REP(i, m) {
			ll u = y - x;
			ll v = x + y;
			if (u >= 0) {
				if (v >= 0) {
					cout << "U";
					y -= d;
				}
				else {
					cout << "L";
					x += d;
				}
			}
			else {
				if (v >= 0) {
					cout << "R";
					x -= d;
				}
				else {
					cout << "D";
					y += d;
				}
			}
			if (d > 1)d /= 2;
			//cerr << " " << d << endl;
		}

		//cerr <<"res"<< x << " " << y << endl;
		cout << endl;
	}
}


//出力
void output()
{

}


//デバッグ
void debug()
{
	int N;
	cin >> N;
}


//メイン関数
int main()
{
	input();
	calc();
	output();
	debug();

	return 0;
}


Measured memory_bytes: 256
/**
**	author : Raghav
**	codechef:raghav_456
**	codeforces:raghavramola7
**/
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long int
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void Raghav()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int e1, e2, e3;
	e1 = 0;
	e2 = 0;
	e3 = 0;
	e3 = e1 + e2;
}
int32_t main()
{
	Raghav();
	int n, a, sum = 0;
	cin >> n;
	vector<int>v;
	vector<int>s;
	for (int i = 1; i <= n; i++)
	{
		cin >> a;
		v.pb(a);
	}
	for (int i = 1; i <= n; i++)
	{
		cin >> a;
		s.pb(a);
	}
	for (int i = 0; i < n; i++)
	{
		if (v[i] > s[i])
			sum += v[i] - s[i];
	}
	cout << sum;
	return 0;
}

Measured memory_bytes: 3612
M, N = map(int, input().split())
mod = 1000000007

def modpow(a, n, mod):
  res = 1
  while (n > 0):
    if (n & 1):
      res = res * a % mod
    a = a * a % mod
    n >>= 1
  return res


print(modpow(M, N, mod))



Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;
int main() {
  char c;
  cin >> c;
  if (c=='a'||c=='i'||c=='u'||c=='e'||c=='o') {
    cout << "vowel" << endl;
  }
  else {
    cout << "consonant" << endl;
  }
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
#define rep(i,a,b) for (int i = (a); i < (b); i++)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef complex<double> com;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const int inf = 2e9;



int main(){
	int n; cin >> n;
	vector<ll> a(n);
	ll sum = 0;
	rep(i, 0, n) {
		cin >> a[i]; sum += a[i];
	}
	if (sum % (1LL * n * (n + 1) / 2)) {
		printf("NO"); return 0;
	}
	sum /= (1LL * n * (n + 1) / 2);
	rep(i, 0, n) {
		ll d = a[i] - a[(i - 1 + n) % n];
		if (sum - d < 0 || (sum - d) % n != 0) {
			printf("NO"); return 0;
		}
	}
	printf("YES");
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long int

int main()
{
 	std::ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  	//ll tt;	cin>>tt;	while(tt--)
  	{
  		ll n,m,i;
  		cin>>n>>m;

  		for(i=0;i<max(n,m);i++)	cout<<min(n,m);
  	}
 	cerr<<" Execution : "<<(1.0*clock())/CLOCKS_PER_SEC<<"s \n";
    return 0;  		
}

Measured memory_bytes: 256