akhauriyash/Code-Regression huggingface dataset:
def factor(n):
    for i in range(2, n+1):
        if n % i == 0:
            l = factor(n // i)
            l.append(i)
            return l
    return []

from collections import Counter
N = int(input())
c = Counter()
for i in range(1, N+1):
    c += Counter(factor(i))
p = 1
for _, i in c.items():
    p *= (i+1)
    p %= 1000000007
print(p)




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

typedef long long ll;
const int mod=1e9+7;

ll mod_Power(ll a,ll b,ll p) {
    ll res=1;
    while(b>0) {
        if(b&1) res=res*a%p;
        a=a*a%p;
        b>>=1;
    }
    return res;
}

ll mod_C(ll a,ll b,ll p) {
    ll res1=1,res2=1;
    for(ll i=1; i<=b; i++) {
        res1=res1*(a-i+1)%p;
        res2=res2*i%p;
    }
    return res1*mod_Power(res2,p-2,p)%p;;
}

int main(){
	ll n,a,b;
	cin>>n>>a>>b;
	cout<<(((mod_Power(2,n,mod)-1-mod_C(n,a,mod)+mod)%mod-mod_C(n,b,mod)+mod)%mod)<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define ld long double
#define endl '\n'
const int mod=1e9+7;
const int inf=1e17+10;
#define F first
#define S second
#define pb push_back
#define all(x) x.begin(),x.end()
#define si(a) a.size()
#define pii pair<int,int>
using namespace std;



int32_t main() {
   std::ios::sync_with_stdio(false);cin.tie(NULL);
   string s;
   cin>>s;
   int a=0,b=0;
   for(char c:s)
   {
       if(c=='A')a++;
       else b++;
   }
   if(a&&b)cout<<"Yes\n";
   else cout<<"No\n";
   return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
const int mod=1e9+7;
char m[1005][1005];
int dp[2][10005];
int main() {
	
	int h,w;
	cin>>h>>w;
	dp[0][1]=1;
	int a=1,b=0;
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			cin>>m[i][j];
			if ( m[i][j] == '#' )  dp[a][j] = 0;
			else dp[a][j] = (dp[b][j]+ dp[a][j-1]) % mod;
		}
		swap(a,b);
	}
	cout<<dp[b][w];
	return 0;
}

Measured memory_bytes: 1280
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
using namespace std;
using ll =long long;
int main() {
	ll N;
	ll sum=0;
	cin >> N;
	for (int i = 1; i <= N; i++) {
		if (i % 5 != 0&& i % 3 != 0) {
 
 
			sum += i;
		}
	}
	cout << sum;
}

Measured memory_bytes: 3580
#include <stdio.h>

int main() {
  int n, i, ns[100];
  scanf("%d", &n);
  for(i = 0; i < n; ++i) scanf("%d", &ns[i]);
  for(i = n - 1; i >= 0; --i) printf("%d%s", ns[i], (i == 0) ? "\n" : " ");
  return 0;
}

Measured memory_bytes: 596
package main
 
import (
  "fmt"
)
 
func main() {
  var s string
  fmt.Scanf("%s", &s)
  
  ans := 0
  for i := 0; i < 6; i++ {
    if s[i:i+1] == "1" {
     ans++
    }
  }
  fmt.Printf("%d\n", ans)
}

Measured memory_bytes: 1832
n = int(input())
if n < 1 or n > 100:
    exit()

n1 = input()

i = len(n1)
if i < 1 or i > 100:
    exit()

n2 = '...'

if n >= i:
    print(n1)
else:
    print(n1[:n] + n2)

Measured memory_bytes: 9116
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n, k = list(map(int, readline().split()))

    comb1 = [0] * (n + 1)
    comb2 = [0] * (n + 1)

    comb1[0] = 1
    comb2[0] = 1

    for i in range(1, n + 1):
        comb1[i] = comb1[i - 1] * (n + 1 - i)
        comb2[i] = comb2[i - 1] * (n - i)
        comb1[i] %= MOD
        comb2[i] %= MOD
        inv = pow(i, MOD - 2, MOD)
        comb1[i] *= inv
        comb2[i] *= inv
        comb1[i] %= MOD
        comb2[i] %= MOD

    r = min(k, n - 1)
    ans = 0
    for i in range(r + 1):
        ans += comb1[n - i] * comb2[n - 1 - i]
        ans %= MOD

    print(ans)


if __name__ == '__main__':
    main()


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

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long int
#define INF 1000000007
#define llINF 1000000000000000007
#define v(i) vector<i>
#define vv(i) vector<vector<i>>
// cin.eof() 入力個数の問題
// int num = atoi(string.c_str()); 文字列の整数変換
int keta(ll n){int ans=0;while(n>0){n /= 10; ans++;}return ans;}
ll _pow(ll a,ll b){ll ans = 1;rep(i,b){ ans *= a;}return ans;}

int main() {
int n;cin>>n;
ll l[n];
rep(i,n) cin>>l[i];
int count=0;
for(int i = 0 ; i < n-2;i++){
    for(int j = i;j < n-1;j++){
        for(int k = j;k<n;k++){
            if(l[i] != l[j] &&l[j]!= l[k]&& l[k] != l[i]){
                ll a=l[i] ,b=l[j],c=l[k];
                if((a+b>c)&&(b+c>a)&&(c+a>b)) count++;
            }
        }
    }
}
cout<<count<<endl;
    return 0;
}


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

const int INF = 100100100;
const int MOD = (int)1e9 + 7;
typedef long long ll;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); ++i)


int main() {
  int a,b,c,d;
  cin >> a >> b >> c;
  int t = a*b;
  if (t > c) t = c;
  cout << t << endl;
}


Measured memory_bytes: 3628
import java.util.Scanner;


public class Main {
	Scanner sc;
	
	boolean solve(double p[][]){
		double vec[][]=new double[2][2];
		for(int i=0;i<2;++i){
			for(int j=0;j<2;++j){
				vec[i][j]=p[i*2+1][j]-p[i*2][j];
			}
		}
		return vec[0][0]*vec[1][1]-vec[0][1]*vec[1][0]==0;
	}
	
	double nd(){
		return sc.nextDouble();
	}
	
	void io(){
		sc=new Scanner(System.in);
		int n=sc.nextInt();
		for(int k=0;k<n;++k){
			double[][] point=new double[4][2];
			for(int i=0;i<4;++i){
				for(int j=0;j<2;++j){
					point[i][j]=nd();
				}
			}
			System.out.println(solve(point)?"YES":"NO");
		}
	}

	public static void main(String[] args) {
		new Main().io();
	}
}

Measured memory_bytes: 20496
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<cctype>
#define ld long double
#define ll long long int
#define ull unsigned long long int
using namespace std;
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;}
const long long INF=1LL<<60;


int main(void){
	ios::sync_with_stdio(false); cin.tie(0);
	
	
	int i,m,n,nu;
	cin>>n>>m;
	int num[n]={0};
	for(i=0;i<m*2;i++){
		cin>>nu;
		num[nu-1]++;
	}
	for(i=0;i<n;i++)cout<<num[i]<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 100

int main(){
  int A[N];
  int i,j,k,n,temp,flag,num;

  scanf("%d",&n);

  for(i = 0; i < n; i++){
    scanf("%d",&A[i]);
  }

  flag=1;

  while(flag==1){

    flag=0;

    for(j = n-1; j >= 1; j--){

      if(A[j] < A[j-1]){
	temp = A[j];
	A[j] = A[j-1];
	A[j-1] = temp;
	flag = 1;

	num++;
      }
      
    }//for

  }//while

  for(k = 0; k < n; k++){
    printf("%d",A[k]);
    if(k != n-1) printf(" ");
    else printf("\n");
  }

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

  return 0;

}



Measured memory_bytes: 2068
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n) for(int i = 0; i < (n); i++)

/* exchange */
#define chmin(a, b) (a) = min((ll)(a), (ll)(b))
#define chmax(a, b) (a) = max((ll)(a), (ll)(b))

/* output */
#define I(x) cin >> x;
#define D(x) cerr << (x) << " ";
#define BR cerr << "\n";
#define P(x) cout << (x) << endl;
#define FIX cout << fixed << setprecision(10);

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;

ll N = 0;
ll ret = 0;
vl table(1000005, 0);
vl vec(64, 0);

int main(void){
  
  I(N);

  FOR(i, 2, 1000005) {
    if (table[i] != -1) {
      ll d = 2 * i;
      while(d < 1000005) {
        table[d] = -1;
        d += i;
      }
      table[i] = 0;
      while(N % i == 0) {
        table[i] += 1;
        N /= i;
      }
    }
  }
  ll th = 2;
  ll v = 1;
  FOR(i, 1, 64) {
    if (i <= th) {
      vec[i] = v;
    } else {
      th += v + 2;
      v += 1;
      vec[i] = v;
    }
  }
  FOR(i, 2, 1000005) {
    if (table[i] != -1) {
      ret += vec[table[i]];
    }
  }
  if (N != 1) ret += vec[1];

  P(ret);

}


Measured memory_bytes: 11036
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>
#include <queue>
#include <set>
#include <bitset>
#include <map>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<long long> vll;
typedef queue<int, int> qii;
typedef pair<int, int> pii;
typedef pair<string, int> psi;

#define PI 3.14159265359
#define rep(i,a) for(int i=0;i<a;i++)

//int型を受け取ってその桁数を返す
int check_digits(int n, int m) {
	int digits = 0;
	while (n != 0) {
		n /= m;
		digits++;
	}
	return digits;
}

//int型を受け取ってその各桁の和を返す
int sum_digits(int n) {
	int sum = 0;
	int N = n;
	while (N) {
		sum += N % 10;
		N /= 10;
	}
	return sum;
}


//最大公約数を返す関数
int gcd(int n, int m) {
	while (n != 0) {
		if (n < m) swap(n, m);
		n = n % m;
	}
	return m;
}


//2点間の距離を返す
float dis(int x1, int y1, int x2, int y2) {
	return sqrt(pow(abs(x1 - x2), 2) + pow(abs(y1 - y2), 2));
}


//入力された文字列が回文か判断してboolを返す
bool is_kaibun(string s) {
	string s_r(s.rbegin(), s.rend());
	return (s == s_r);
}


void yes() { cout << "Yes" << endl; }
void no() { cout << "No" << endl; }


//提出言語もしっかり確認して…
//問題文を落ち着いて読む！
//型に注意！！
//出力例もちゃんと全部見る！！！！！
int main() {
	int n;
	cin >> n;
	vector<pair<int, int>> s(n);
	rep(i, n)s[i].second = i+1;
	int temp;
	rep(i,n){
		cin >> temp;
		s[i].first = temp;
	}
	sort(s.begin(), s.end());
	rep(i, n)cout << s[i].second<< " ";
	cout << endl;

	system("pause");
	return 0;
}


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

int main(){
	int n;
	
	cin>>n;
	
	double a[n+1];
	
	string s[n+1];
	
	double ans;
	
	for(int i=1;i<=n;i++){
		cin>>a[i]>>s[i];
		if(s[i]=="JPY"){
			ans+=a[i]*1.0;
		}else{
			ans+=a[i]*1.0*380000;
		}
	}
	cout<<ans<<endl;
	
	return 0;
}

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

int main() {
    int n, k, m;
    while (cin >> n >> k >> m, n) {
        vector<int> v(n);
        for (int i=0; i<n; ++i) v[i] = i+1;
        int pos = m-1;
        while (1 < (int)v.size()) {
            v.erase(v.begin() + pos);
            pos --;
            pos = (pos + k) % (int)v.size();
        }
        cout << v[0] << endl;
    }
    return 0;
}

Measured memory_bytes: 1252
#include <iostream>
#include <vector>
#include <iomanip>

int main() {
	int k, n;
	std::cin >> n >> k;

	std::vector<int> ps(n);
	for (auto&& e : ps)
		std::cin >> e;

	
	int subsum = 0;
	for (int i = 0; i < k; ++i)
		subsum += ps[i];

	int l = 0, r = k;
	int max = subsum;
	while (r != n) {
		subsum += ps[r];
		subsum -= ps[l];

		if (subsum > max)
			max = subsum;

		++l, ++r;
	}

	std::cout << std::fixed << std::setprecision(7) << (max + k) * 0.5 << std::endl;
}

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

#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;

const ll MOD  = 1e9+7;
const ll LINF = 1LL << 60;
const int INF = 1e9 + 7;

int main(){
    ll a, b, c;
    cin >> a >> b >> c;
    if(a==b && a == c)cout << "No";
    else if(a==b || a == c || b==c) cout << "Yes";
    else cout << "No";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k,x,ans=0;
  vector<int> v;
  cin>>n>>k;
  for(int i=0;i<n;i++){
    cin>>x;
    v.push_back(x);
  }
  sort(v.begin(),v.end(),greater<int>());
  for(int i=0;i<k;i++){
    ans+=v[i];
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int a[100];
int main()
{
	int n, total = 0;
	scanf("%d", &n);
	for(int i = 0; i < n; scanf("%d", &a[i++])){}
	for(int i = 1; i; total += i)
	{
		i = 0;
		for(int j = 0, k = true; j < n; ++j)
		{
			if(a[j])
			{
				--a[j];
				i += k;
				k = false;
			}
			else
			{
				k = true;
			}
		}
	}
	printf("%d\n", total);
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define long int64_t

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

	int n;
	cin >> n;
	vector<int> a( n );
	for( int i = 0; i < n; ++i ) { cin >> a[i]; }
	int q;
	cin >> q;

	while( q-- ) {
		int b, e;
		cin >> b >> e;
		auto it = a.begin();
		reverse( it+b, it+e );
	}

	for( int i = 0; i < n; ++i ) {
		cout << a[i] << (i < n-1 ? ' ' : '\n');
	}

	return 0;
}



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

int main() {
  long int i, j, N, min, flag;
  flag = 0;
  cin >> N;
  if(N >1000000){
    for(i = 1; i <= N/10000; i++){
    if(0 == N % i){
      j = N / i;
        //初回
        if(flag == 0){
           min = (j + i) - 2;
          flag = flag + 1;
        }
        //２回目以降
        if(min > (j + i) - 2){
          min = (j + i) - 2;
        }
     }
    }
  }else{
  for(i = 1; i <= N; i++){
    if(0 == N % i){
      j = N / i;
        //初回
        if(flag == 0){
           min = (j + i) - 2;
          flag = flag + 1;
        }
        //２回目以降
        if(min > (j + i) - 2){
          min = (j + i) - 2;
        }
     }
  }
  }
   cout << min << endl;
}



Measured memory_bytes: 256
var input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
var obj = {
  "list" : input,
  "index" : 0,
  "max" : input.length,
  "next" : function(){
    if(!this.hasNext()){throw "NoSuchElementException:次に要素は無いよ";}
    var returnObj = this.list[this.index];
    this.index++;
    return returnObj;
  },
  "hasNext" : function(){return (this.index < this.max);}
}
Main();
function next(){return obj.next();}
function hasNext(){return obj.hasNext();}
function myout(t){console.log(t);}//standard output
function myerr(t){console.error(t);}//standard error
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  var N = myconv(next(),1);
  var list = {};
  for(var i = 0; i < N; i++){
    var tmp = myconv(next(),6);
    tmp = myconv(tmp.sort(),0);
    if(list[tmp] == null){
       list[tmp] = 0;
    }else{
       list[tmp]++;
    }
  }
  var output = 0;
  var keys = Object.keys(list);
  for(var i = 0; i < keys.length; i++){
    output += list[keys[i]] * (list[keys[i]] + 1) / 2;
  }
  myout(output);
}

Measured memory_bytes: 44748
import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			int K = scan.nextInt();
			int N = scan.nextInt();
			
			int[] A = new int[N];
			for(int i = 0;i<N;i++) {
				A[i] = scan.nextInt();
			}
			
			int maxdist = 0;
			int maxnum = 0;
			
			for(int i = 0;i<N;i++) {
				if(i == N-1) {
					int dist = K-A[i]+A[0];
					if(maxdist<dist) {
						maxdist = dist;
						maxnum = i;
					}
				}else {
					int dist = A[i+1]-A[i];
					if(maxdist<dist) {
						maxdist = dist;
						maxnum = i;
					}
				}
			}
			
			//System.out.println(maxnum);
			
			if(maxnum == (N-1)) {
				System.out.println(A[maxnum]-A[0]);
			}else {
				int a = A[maxnum];
				int b = K-A[maxnum+1];
				System.out.println(a+b);
			}
			
			
			
			
			
			
		}
		
		
	}
		

}


Measured memory_bytes: 85872
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

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

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n=I()
  l1=LI()
  l2=LI()
  l3=LI()

  ans=0
  b=-1
  for i,x in enumerate(l1):
    ans+=l2[x-1]
    if x==b+1:
      ans+=l3[b-1]
    b=x
  return ans

# main()
print(main())


Measured memory_bytes: 7848
# dfs

def dfs(lst_args, n_each_digit, i_num, n_calc):
    if i_num == len(lst_args):
        return n_calc + int(n_each_digit)
    return dfs(lst_args, lst_args[i_num], i_num + 1, int(n_each_digit) + n_calc) + dfs(lst_args, n_each_digit + lst_args[i_num], i_num + 1, n_calc)

lst = [x for x in input()]
print(dfs(lst, lst[0], 1, 0))

Measured memory_bytes: 3060
X,N=map(int, input().split())
p_ls=list(map(int, input().split()))

i=0
while True:
	ans_n=X-i
	if ans_n not in p_ls:
		print(ans_n)
		break
	
	ans_p=X+i
	if ans_p not in p_ls:
		print(ans_p)
		break
	
	i+=1



# 2darray [[0] * 4 for i in range(3)]

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

using namespace std;
const long mod = 1000000007;
typedef long long lint;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(N) for(int i = 0; i < (int)(N); i++)
#define all(x) (x).begin(),(x).end()
#define length(x) ((int)(x).size())
#define prln(s) cout<<s<<endl;

#define str(s) string s;cin>>s;
#define int1(x) int x;cin>>x;
#define int2(x,y) int x,y;cin>>x>>y;

int main() {
  int1(x);
  int2(y,z);

  printf("%d %d %d", z, x ,y);
}


Measured memory_bytes: 256
#include<iostream>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;

int main(){
	int n, m;
	cin >> n >> m;

	int cnt[50] = {};
	REP(i, m){
		int a, b;
		cin >> a >> b;

		cnt[a - 1]++;
		cnt[b - 1]++;
	}

	REP(i, n) cout << cnt[i] << endl;
	return 0;
}

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

#include <iostream>
using namespace std;
int A,B,C;
int main() {
	cin>>A>>B>>C;
	if(A==B)cout<<C<<endl;
	if(A==C)cout<<B<<endl;
	if(B==C)cout<<A<<endl;


	return 0;
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

int nextInt() { int x; scanf("%d", &x); return x;}

int main2() {
  string s; cin >> s;
  int N = s.size();
  s = '_' + s;

  bool possible = true;
  if (s[1] == '0') possible = false;
  if (s[N] == '1') possible = false;
  for (int i = 1; i < N; i++) {
    if (s[i] != s[N-i]) possible = false;
  }
  if (!possible) {
    cout << -1 << endl;
    return 0;
  }

  int one = count(ALL(s), '1');
  for (int i = 1; i + 1 <= one; i++) {
    cout << i << " " << i + 1 << endl;
  }

  int a = 1;
  int b = one + 1;
  for (int i = 1; i < N; i++) {
    if (s[i] == '0') {
      cout << a << " " << b << endl;
      b++;
    } else {
      a++;
    }
  }
  cout << one << " " << b << endl;


  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define FORR(x, arr) for(auto& x:arr)
#define ITR(x, c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;
typedef pair<int, int> P;

int n;

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> n;
	map<char, int> mp;
	FOR(i, n) {
		char c;
		cin >> c;
		mp[c]++;
	}
	cout << (mp.size()==4 ? "Four" : "Three") << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;

typedef long long ll;

template<class t>
inline bool chmax(t &a, t b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class t>
inline bool chmin(t &a, t b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

// {delicious, kind}
vector<pair<ll, int>> sushi;
// {kind, count}
map<int, int> counter;

ll solve(const int n, const int k) {
    ll cand = 0;
    ll delicious = 0;
    ll kinds = 0;
    vector<ll> replacables;

    for (int i = 0; i < k; i++) {
        pair<ll, int> su = sushi[i];
        counter[su.second]++;
        delicious += su.first;
        if (counter[su.second] == 1) {
            kinds++;
        } else {
            replacables.push_back(su.first);
        }
    }

    cand = delicious + kinds * kinds;
    // printf("cand: %lld\n", cand);

    for (int i = k; i < n; i++) {
        if ((int) replacables.size() == 0) {
            break;
        }
        pair<ll, int> su = sushi[i];
        if (counter[su.second] > 0) continue;
        counter[su.second]++;
        ll replace = replacables.back();
        replacables.pop_back();
        delicious -= replace;
        delicious += su.first;
        kinds++;
        chmax(cand, delicious + kinds * kinds);

    }

    return cand;
}

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

    sushi.resize(n);
    for (int i = 0; i < n; i++) {
        int t, d;
        cin >> t >> d;
        sushi[i] = {d, t};
    }
    sort(sushi.begin(), sushi.end());
    reverse(sushi.begin(), sushi.end());

    cout << solve(n, k) << endl;

    return 0;
}


Measured memory_bytes: 5116
import java.util.*;
public class Main {
	static Scanner s = new Scanner(System.in);
	public static void main(String __[]){
		int in[]= {s.nextInt(),s.nextInt(),s.nextInt()};
		Arrays.sort(in);
		System.out.println(in[0]==5&&in[1]==5&&in[2]==7?"YES":"NO");
	}
}

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

int main(){
  int n, d;
  cin >> n >> d;
  vector<vector<int>> x(n, vector<int>(d));
  for(int i = 0; i < n; i++){
    for(int j = 0; j < d; j++){
      cin >> x[i][j];
    }
  }
  
  int count = 0;
  for(int i = 0; i < n - 1; i++){
    for(int j = i + 1; j < n; j++){
      int distance2 = 0;
      for(int k = 0; k < d; k++){
        int m_s_distance1 = x[j][k] - x[i][k];
        distance2 += m_s_distance1 * m_s_distance1;
      }
      for(int k = 1; k*k <= distance2; k++){
        if(k*k == distance2){
          count++;
        }
      }
    }
  }
  
  cout << count << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int n,i,j,x;

  scanf("%d",&n);

  for(i = 1;i <= n;i++){
    x = i;
    
    if(x % 3 == 0) printf(" %d",i);
    else{
	
      for(j = 0;;j++)
	{
	  if(x % 10 ==3) {
	    printf( " %d",i);
	    break;
	  }
	  x /= 10;
	  if(x == 0)break;
	}
    }
  }
      

  printf("\n");
  return 0;
}



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

int main()
{	int count =0 ,n; 
	string a,b;

	cin >>a >> b;
	n= a.size();
	for (int i=0 ; i< n; i++ )
	{
		if (a[i]!=b[i])
		count++ ;
		
	} 
	
		
	cout<< count ;
	return 0;
	
	}
	
	


Measured memory_bytes: 3904
from collections import deque

LIST = deque()
n = int(input())
for loop in range(n):
    command = input()
    if command == 'deleteFirst':
        LIST.popleft()
    elif command == 'deleteLast':
        LIST.pop();
    else:
        com,num = command.split()
        if com == 'insert':
            LIST.appendleft(num)
        elif com == 'delete':
            try:
                LIST.remove(num)
            except:
                pass
print(' '.join(LIST))


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

int main() {
  int N, a, b, c, d, e, f, g, h, i, x;
  cin >> N;
  i = N % 10;
  h =(N - i) % 100 / 10;
  g =(N - i - 10 * h) % 1000 / 100;
  f =(N - i - 10 * h - 100 * g) % 10000 / 1000;
  e =(N - i - 10 * h - 100 * g - 1000 * f) % 100000 / 10000;
  d =(N - i - 10 * h - 100 * g - 1000 * f - 10000 * e) % 1000000 / 100000;
  c =(N - i - 10 * h - 100 * g - 1000 * f - 10000 * e - 100000 * d) % 10000000 / 1000000;
  b =(N - i - 10 * h - 100 * g - 1000 * f - 10000 * e - 100000 * d - 1000000 * c) % 100000000 / 10000000;
  a =(N - i - 10 * h - 100 * g - 1000 * f - 10000 * e - 100000 * d - 1000000 * c - 10000000 * b) % 1000000000 / 100000000;
  x = a + b + c + d + e + f + g + h +i;
  
  if (N % x == 0){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int s;
    cin>>s;
    int ans=1;
    set<int>se;
    se.insert(s);
    while(true)
    {
        if(s%2==0)
        {
            s=s/2;
            ans++;
            if(se.count(s))
                break;
            se.insert(s);
        }
        else
        {
            s=3*s+1;
            ans++;
             if(se.count(s))
                break;
            se.insert(s);
        }
    }
   cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
/*
まとめて操作してよさそう
3回
3*A枚用意 3*A/B回換金
2分探索
ああ、ちがいそう
AB無限ループできるのか
2ターン換金操作をするので、差がB-A<=2ならK+1か
そうじゃない場合。
まずA枚ためて、そこからずっとBAループ
お金が余らないように最後調整
基本的にすぐ換金が考えやすいか

2 5
K bis money
1 2   0
2 0   1
3 5   0
4 3   1
5 8   0
6 6   1
7 11  0
-A+B-A+B-A+B-A+...+Bでおわるか、+1でおわるか。
*/
int main(){
  ll K,A,B,bis=1; cin>>K>>A>>B;
  if(B-A<=2 || K<=A){
    cout<<K+1<<endl;
    return 0;
  }
  K-=A-1;
  bis=A;
  if(K%2==0)//Bでおわる
    bis+=B*(K/2)-A*(K/2);
  else
    bis+=B*(K/2)-A*(K/2)+1;
  cout<<bis<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>

using namespace std;

int n;
pair<pair<string, int>, int> p[105];

int main(void)
{
	cin >> n;
	string s; int x;
	for(int i = 0; i < n; i++){
		cin >> s >> x;
		p[i] = make_pair(make_pair(s, -x), i);
	}
	sort(p, p+n);
	for(int i = 0; i < n; i++){
		cout << p[i].second+1 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
def iin(): return int(input())
def nl(): return list(map(int, input().split()))

n, m = nl()
a = nl()

b = [0]
for x in a:
    t = (b[-1] + x) % m
    b.append(t)

ans = 0
d = dict()
for x in b:
    t = d.get(x, 0)
    ans += t
    d[x] = t + 1

print(ans)

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

using namespace std;

int main(int argc, const char *argv[]) {
  array<array<int, 3>, 3> c;
  for (int i = 0; i < 3; ++i) {
    for (int j = 0; j < 3; ++j) {
      cin >> c[i][j];
    }
  }

  bool ans = false;
  for (int a1 = 0; a1 <= 100 && !ans; ++a1) {
    int a2, a3, b1, b2, b3;
    array<int, 3> va, vb;
    va[0] = a1;
    vb[0] = c[0][0] - va[0];
    vb[1] = c[0][1] - va[0];
    vb[2] = c[0][2] - va[0];
    va[1] = c[1][0] - vb[0];
    va[2] = c[2][0] - vb[0];

    bool ok = true;
    for (int i = 0; i < 3 && ok; ++i) {
      for (int j = 0; j < 3 && ok; ++j) {
        if (c[i][j] == va[i] + vb[j]) {
          continue;
        }

        ok = false;
      }
    }

    if (ok) {
      ans = ok;
    }
  }

  cout << (ans ? "Yes" : "No") << '\n';
  return 0;
}

Measured memory_bytes: 3632
#maspyさんを参考に
import sys
#import numpy as np
#from numba import njit
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# この最適化がよくわからん。Numpyループなら行けるらしい
# 400msくらいは最低でもかかるけど、N=10^5でも2でも変わらんと言う
#@njit('(i4[::1],)', cache=True)
def solve(A):
  # エラトステネス古いって値側のバリエーションとして配列をとるんや
  # maxA = 10**6って言うのがポイントっぽいなあ。。
    count = np.zeros(10**6 + 10, np.int32)
    for x in A:
        if count[x] > 1:
            continue
        count[::x] += 1
    ret = 0
    for x in A:
        ret += count[x] == 1
    return ret

def solve2(A):
  count = [0 for _ in range(10**6 + 10)]
  for x in A:
    if count[x] > 1:
      continue
    for a in range(0,len(count),x):
      count[a] += 1
  ret = 0
  for x in A:
    ret += (1 if count[x] == 1 else 0)
  #print(count[:24])
  return ret
  
# このコードわからなかった。一行目のNをSKIPしたリストになっている。。
#A = np.array(read().split(), np.int32)[1:]
N = int(input())
A = list(map(int, input().split()))
# この手法だとソート不要なのか？？だから早いのか？？
print(solve2(A))


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

typedef long long ll;

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

    int h,w,n;
    cin >> h >> w >> n;
    int a = max(h,w);
    cout << ceil((double)n/a) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <utility>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cmath>
#include <numeric>

using namespace std;

using vi = vector<int>;
#define loop(i, n) for (int i = 0; i < (int)n; i++)

int main() {
    int k, n; cin >> k >> n;
    vi a(n, 0); loop(i, n) cin >> a[i];
    vi b(n, 0); 
    loop(i, n - 1) {
        b[i] = a[i + 1] - a[i];
    }
    b[n - 1] = a[0] + k - a[n - 1];
    sort(b.begin(), b.end());
    cout << k - b[n - 1] << endl;
}

Measured memory_bytes: 1792
#include<iostream>

using namespace std;

int main(){
    int x, y;
    
    cin >> x >> y;

    if(x == 1 || x == 3 || x == 5 || x == 7 || x == 8 || x == 10 || x == 12){
        if(y == 1 || y == 3 || y == 5 || y == 7 || y == 8 || y == 10 || y == 12){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }else if(x == 4 || x == 6 || x == 9 || x == 11){
        if(y == 4 || y == 6 || y == 9 || y == 11){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }else{
        if(y == 2){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}

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

int main() {
  string c1, c2, c3;
  cin >> c1;
  cin >> c2;
  cin >> c3;
  cout << c1.at(0) << c2.at(1) << c3.at(2) << endl;
}


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

int main() {
    int n,k;
    cin>>n>>k;
    vector<int> p(n);
    rep(i,n){
        cin>>p[i];
    }
    sort(p.begin(),p.end());
    ll ans = 0;
    rep(i,k){
        ans += p[i];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <deque>
#include <string>
#include <stack>
#include <unordered_set>
#include <cmath>
#define endl '\n'
#define ll unsigned long long
//#define mod 1000000007
#define NCONS 101

using namespace std;

int main(void)
{
	cin.tie(NULL); ios_base::sync_with_stdio(false);
	string N; cin >> N;
	if (N[0] == N[2])
		cout << "Yes";
	else
		cout << "No";

	return 0;
}

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

using namespace std;

int main(void)
{
    string s;
    int i, n;

    cin >> s;

    n = s.size();

    for(i=0; i<n; i++){
        if(i%2==0){
            cout << s[i];
        }
    }

    cout << endl;

    return 0;
}

Measured memory_bytes: 512
#include<iostream>
using namespace std;
#define l long long
#define pb push_back
#define mem(a,n) memset(a,n,sizeof(a))
#define find(a,n) find(a.begin(),a.end(),n)
/*bool isprime(l n)
{
	for(l i=2;i*i<=n;i++)
	{
		if(n%i==0)
			return false;
	}
	return true;
}
l bfs(vector<l> like[],vector<l> dislike[],l s,bool vis[])
{
	vector<l> ans;
	queue<l> q;
	vis[s]=1;
	q.push(s);
	while(q.empty()==false)
	{
		l temp=q.front();
		ans.pb(temp);
		q.pop();
		for(l i=0;i<like[temp].size();i++)
		{
			if(vis[like[temp][i]]==0)
			{
				q.push(like[temp][i]);
				vis[like[temp][i]]=1;
			}
		}
	}
	for(l i=0;i<ans.size();i++)
	{
		for(l j=0;j<dislike[ans[i]].size();j++)
		{
			if(find(ans,dislike[ans[i]][j])!=ans.end())
			{
				l pos=find(ans,dislike[ans[i]][j])-ans.begin();
				vis[dislike[ans[i]][j]]=0;
				ans.erase(ans.begin()+pos);
			}
		}
	}
	return ans.size();
}*/
void frooty()
{
	l n;
	cin>>n;
	l a,b;
	cin>>a>>b;
	for(l i=a;i<=b;i++)
	{
		if(i%n==0)
		{
			cout<<"OK"<<"\n";
			return ;
		}
	}
	cout<<"NG"<<"\n";
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    l t=1;
  //  cin>>t;
    while(t--)
    {
    	frooty();	
	}
}

Measured memory_bytes: 3648
#include <cstring>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <numeric>
#include <stack>

using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define eb emplace_back
#define F first
#define S second
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);
typedef unordered_map<ll, ll> mpll;
typedef unordered_map<char, ll> mpcl;
typedef pair<ll, ll> P;
typedef vector<ll> vll;

int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
#pragma clang diagnostic pop
#endif
        ll x, y, z, k;
        cin >> x >> y >> z >> k;
        vll a(x), b(y), c(z);
        rep(i, x) cin >> a[i];
        rep(i, y) cin >> b[i];
        rep(i, z) cin >> c[i];

        vll ab;
        rep(i, x) rep(j, y) ab.eb(a[i] + b[j]);
        sort(ab.begin(), ab.end(), greater<>());
        priority_queue<ll, vector<ll>, greater<>> que;
        rep(i, min(x * y, k)) {
            rep(j, z) {
                if (que.size() < k) que.push(ab[i] + c[j]);
                else if (que.top() < ab[i] + c[j]) {
                    que.pop();
                    que.push(ab[i] + c[j]);
                }
            }
        }

        vll ans(k);
        rep(i, k) {
            ans[k - i - 1] = que.top();
            que.pop();
        }
        rep(i, k) printf("%lli\n", ans[i]);


#ifdef MY_DEBUG
    }
#endif
    return 0;
}

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





int main() {
  
  int64_t x;
  cin>>x;
  
  
  int answer=0;
  
  int sum=0;
  
  
  while (sum<x){
    answer++;
    sum+=answer;
  }

  
  
  cout<<answer<<endl;
  
    
    
    
  
  
}












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

int main()
{
	int n;
	cin >> n;
	bool isPlus;
	vector<int> v;
	if (n == 0)
	{
		cout << 0 << endl;
		return 0;
	}
	else if (n > 0)
	{
		isPlus = true;
		int tmp = n;
		while (tmp>0)
		{
			if (tmp & 1 == 1)
			{
				v.push_back(1);
			}
			else
			{
				v.push_back(0);
			}
			tmp = (tmp >> 1);
		}
		v.push_back(0);
		v.push_back(0);
		v.push_back(0);
		v.push_back(0);
		v.push_back(0);

		for (int i = 0; i < v.size(); i++)
		{
			if (i % 2 == 0) //plus
			{
				while (v[i] > 1)
				{
					v[i] -= 2;
					v[i + 1]++;
				}
			}
			else
			{
				while (v[i] > 1)
				{
					v[i] -= 2;
					v[i + 1]++;
				}
				if (v[i] > 0)
				{
					v[i + 1]++;
				}
			}
		}
		for (int i = v.size() - 1; i >= 0; i--)
		{
			if (v[i] == 0)
			{
				v.erase(v.begin() + i);
			}
			else
			{
				break;
			}
		}
		for (int i = v.size() - 1; i >= 0; i--)
		{
			cout << v[i];
		}
		cout << endl;
	}
	else // n<0
	{
		isPlus = false;
		n = -n;

		int tmp = n;
		while (tmp>0)
		{
			if (tmp & 1 == 1)
			{
				v.push_back(1);
			}
			else
			{
				v.push_back(0);
			}
			tmp = (tmp >> 1);
		}
		v.push_back(0);
		v.push_back(0);
		v.push_back(0);
		v.push_back(0);
		v.push_back(0);

		for (int i = 0; i < v.size(); i++)
		{
			if (i % 2 == 1) //plus
			{
				while (v[i] > 1)
				{
					v[i] -= 2;
					v[i + 1]++;
				}
			}
			else
			{
				while (v[i] > 1)
				{
					v[i] -= 2;
					v[i + 1]++;
				}
				if (v[i] > 0)
				{
					v[i + 1]++;
				}
			}
		}
		for (int i = v.size() - 1; i >= 0; i--)
		{
			if (v[i] == 0)
			{
				v.erase(v.begin() + i);
			}
			else
			{
				break;
			}
		}
		for (int i = v.size() - 1; i >= 0; i--)
		{
			cout << v[i];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 256
module module1
  
  sub main()
    dim N As integer = Console.Readline
    Dim bunsi As Integer
    
    If N Mod 2 = 0 Then
      bunsi = N/2
    else
      bunsi = (N+1)/2
    end if
    
    console.writeline((bunsi/N).ToString("0.000000000"))
    
  end sub
end module

Measured memory_bytes: 13268
/*  -*- coding: utf-8 -*-
 *
 * a.cc: A: Two Rectangles
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;

  printf("%d\n", max(a * b, c * d));
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        long c = sc.nextLong();
        //String s = sc.next();
//        int[] a = new int[n];
//        for (int i = 0 ; i < n ; i++) {
//            a[i] = sc.nextInt();
//        }

        long ans = 0;
        if (a + b >= c - 1) {
            System.out.println(b + c);
        } else {
            System.out.println(a + b + 1 + b);
        }

    }

}

Measured memory_bytes: 23252
N = int(input())
S = input()
cnt_b = [0] * (N+1)
cnt_w = [0] *(N+1)
for i in range(len(S)):
   cnt_b[i+1] = cnt_b[i]
   cnt_w[i+1] = cnt_w[i]
   if S[i] == '.':
      cnt_w[i+1] +=1
   else:
      cnt_b[i+1] +=1

ans = 1000000
for i in range(N+1):
   cost = cnt_b[i] + cnt_w[N] - cnt_w[i]
   ans = min(cost, ans)
print(ans)

Measured memory_bytes: 14824
a = input()
s = 'AKIHABARA'

a_idx = 0
s_idx = 0
ans = 'YES'
while a_idx < len(a) and s_idx < len(s):
    if a[a_idx] != s[s_idx]:
        if s[s_idx] == 'A':
            s_idx += 1
            continue
        else:
            ans='NO'
            break
    a_idx += 1 
    s_idx += 1 

if s_idx == len(s) and a_idx != len(a) :
    ans = 'NO'

if s_idx != len(s) and a_idx == len(a) :
    if s[s_idx] == 'A' and len(s[s_idx:]) == 1:
        ans = 'YES'
    else:
        ans = 'NO'
print(ans)

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

int main() {
long long N, K;
cin >> N >> K;
vector<int> Array(N);
vector<int> count(N);
for(int i = 0; i < N; i++){
cin >> Array.at(i);}
for(int i = 0; i < N; i++){
count.at((Array.at(i) - 1))++;}
sort(count.begin(), count.end());
int sum = 0;
for(int i = 0; i < N - K; i++){
sum += count.at(i);}
cout << sum << endl;}


Measured memory_bytes: 1792
#include <cstdio>

int main() {
  int E, Y;
  scanf("%d %d", &E, &Y);
  if (E == 1) {
    printf("%d\n", Y+1867);
  } else if (E == 2) {
    printf("%d\n", Y+1911);
  } else if (E == 3) {
    printf("%d\n", Y+1925);
  } else if (E == 4) {
    printf("%d\n", Y+1988);
  } else {
    if (Y < 1912) {
      printf("M%d\n", Y-1867);
    } else if (Y < 1926) {
      printf("T%d\n", Y-1911);
    } else if (Y < 1989) {
      printf("S%d\n", Y-1925);
    } else {
      printf("H%d\n", Y-1988);
    }
  }
}



Measured memory_bytes: 2740
n, m, x, y = [int(s) for s in input().split()]
lx = [int(s) for s in input().split()]
ly = [int(s) for s in input().split()]
lx.append(x)
ly.append(y)
mx = max(lx)
my = min(ly)
print("No War" if mx < my else "War")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep0(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define mREP(i,a,b) for (int i = a; i > (b); --i)
#define all(x) (x).begin(),(x).end()
const int INF = 1000000007;
typedef long long ll;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int main(){
  string s;
  cin>>s;
  if("2019/04/30" >= s){
    cout<<"Heisei"<<endl;
  }
  else{
    cout<<"TBD"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
mo=10**9+7
s=input()
n=len(s)
dp=[[0]*(1+n) for i in range(3)]
cc=0
for i in range(n):
    c=s[i]
    if c=='A':
        da=1
        db=0
        dc=0
        dd=1
    elif c=='B':
        da=0
        db=1
        dc=0
        dd=1
    elif c=='C':
        da=0
        db=0
        dc=1
        dd=1
    elif c=='?':
        da=1
        db=1
        dc=1
        dd=3
        
    dp[0][i+1]=dp[0][i]*dd+da*pow(3,cc,mo)
    dp[1][i+1]=dp[1][i]*dd+dp[0][i]*db
    dp[2][i+1]=dp[2][i]*dd+dp[1][i]*dc
    dp[0][i+1]%=mo
    dp[1][i+1]%=mo
    dp[2][i+1]%=mo
    if c=='?':
        cc+=1

print(dp[2][n]%mo)

Measured memory_bytes: 45168
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <math.h>
#include<algorithm>
#include <utility>
using namespace std;
#define INF 100000000
#define NAN -1
int main() {
	int w, ans;
	cin >> w;
	ans = 32 * w;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3124
#include <bits/stdc++.h>
 
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long
using namespace std;
void file(){
	#ifndef ONLINE_JUDGE
    	freopen("tst.txt", "r", stdin);
	#endif	
}
const int N=1e5+5,MAX=3e7,MOD=1e9+7;
 
int n;
int a[N],b[N];
ll ans;
int main()
{	
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	//file();

	scanf("%d",&n);
	//memset(memo,-1,sizeof(memo));

	for(int i=0;i<=n;i++)scanf("%d",&a[i]);
	for(int i=0;i<n;i++)scanf("%d",&b[i]);

	for(int i=0;i<n;i++){
		if(b[i]>=a[i]){
			ans+=a[i];
			b[i]-=a[i];
		}
		else {
			ans+=b[i];
			b[i]=0;
		}
		ans+=min(a[i+1],b[i]);
		a[i+1]-=min(a[i+1],b[i]);
	}

	printf("%lld\n",ans );
	
}

Measured memory_bytes: 1024
/*
  Author: Alokit Kumar
  */
 #include<bits/stdc++.h>
 using namespace std;
 #define int long long
 int32_t main()
 {
   int t,n,i,j,k,l,s=0,q,b,c;
  cin>>n;
  int a[n];
  for(i=0;i<n;i++) cin>>a[i];
  for(i=0;i<n;i++) s=s^a[i];
  for(i=0;i<n;i++)
   cout<<(s^a[i])<<" ";
 }

Measured memory_bytes: 5148
from collections import Counter
n=int(input())
a=[input()for i in range(n)]
a.extend(["AC","TLE","WA","RE"])
c=Counter(a)

d=c["AC"]-1
e=c["WA"]-1
f=c["TLE"]-1
g=c["RE"]-1

print("{} {} {}".format("AC","x",d))
print("{} {} {}".format("WA","x",e))
print("{} {} {}".format("TLE","x",f))
print("{} {} {}".format("RE","x",g))


Measured memory_bytes: 16616
//#include "stdc++.h"
#include<bits/stdc++.h>
#include<iostream>
#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;
typedef vector<int> vi;
#define m1 make_pair
#define pb push_back
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
inline ll gcd(ll a,ll b){if(a==0) return b;return gcd(b%a,a);}
inline ll power(ll a,ll n,ll m){if(n==0) return 1;ll p=power(a,n/2,m);p=(p*p)%m;if(n%2) return (p*a)%m;else return p; }
#define flush fflush(stdout)
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
int main()
{
    int n;
    cin>>n;
    int k;
    cin>>k;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    ll dp[k+1][n+1];
    memset(dp,(ll)0,sizeof(dp));
    for(int i=0;i<=n;i++)
        dp[0][i]=1;
    for(int i=1;i<=k;i++)
    {
        for(int j=1;j<=n;j++)
        {
            dp[i][j]=(dp[i-1][j]%MOD+dp[i][j-1]%MOD)%MOD;
            if(a[j-1]<=(i-1))
                dp[i][j]=(dp[i][j]-dp[i-1-a[j-1]][j-1]+MOD)%MOD;
        }
    }
    cout<<dp[k][n]<<endl;
    return 0;
}


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

using namespace std;

const int maxn = 3005;

double p[maxn];
double dp[maxn][maxn];

int main()
{
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> p[i];
    }
    dp[0][0] = 1;
    dp[1][0] = 1 - p[1];
    for(int i = 2; i <= n; i++){
        dp[i][0] = dp[i - 1][0] * (1 - p[i]);
    }
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= i; j++){
            dp[i][j] += dp[i - 1][j - 1] * p[i] + dp[i - 1][j] * (1 - p[i]);
        }
    }
    double ans = 0;
    for(int i = n / 2 + 1; i <= n; i++){
        //cout << dp[n][i] << " ";
        ans += dp[n][i];
    }
    printf("%.10lf", ans);
    return 0;
}


Measured memory_bytes: 68992
#include <bits/stdc++.h>
#define int long
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
int gcd(int a,int b){return b ? gcd(b,a%b) : a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}

std::vector<bool> IsPrime;

void sieve(size_t max){
    if(max+1 > IsPrime.size()){   
        IsPrime.resize(max+1,true);
    }
    IsPrime[0] = false;
    IsPrime[1] = false;

    for(size_t i=2; i*i<=max; ++i)
        if(IsPrime[i])
            for(size_t j=2; i*j<=max; ++j)
                IsPrime[i*j] = false;
}


main() {
    int Q; cin >> Q;
    int S[100001];
    sieve(100001);
    rep(i,100001){
        if(!i)S[i]=0;
        else if(IsPrime[i] && IsPrime[(i+1)/2]){
            S[i]=S[i-1]+1;
        }
        else S[i]=S[i-1];
    }
    rep(i,Q){
        int l,r; cin >> l >> r;
        cout << S[r]-S[l-1] << endl;
    }

    return 0;
}

Measured memory_bytes: 1408
#include <algorithm>
using namespace std;

int a[4],b[4];
int main(){
  int i,j,h,l;
  for(;~scanf("%d%d%d%d%d%d%d%d",a,a+1,a+2,a+3,b,b+1,b+2,b+3);printf("%d %d\n",h,l)){
    for(i=h=l=0;i<4;i++)for(j=0;j<4;j++)if(a[i]==b[j])i==j?h++:l++;
  }
}

Measured memory_bytes: 0
import java.util.*;


public class Main {
	public static void main(String args[]){
		Scanner in = new Scanner(System.in);
		while(in.hasNext()){
			try{
				double a = in.nextInt();
				double b = in.nextInt();	
				double S = (a * b)/3.305785; 
				System.out.println(S);
			}catch(Exception e){
				System.exit(0);
			}
		}
	}
}

Measured memory_bytes: 17312