akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cctype>
#include <string>
#include <map>
#include <set>
#include <math.h>
#include <cmath>
#define ll long long
#define lli long long int

using namespace std;
using P = pair<int,int>;

int main(){

  int X;
  cin >> X;
  int ans = 1;

  for (int b = 2; b < X; b++) {
    int power = b*b;
    for (int p = 2;; p++) {
      if(power > X) break;
      ans = max(ans, power);
      power *= b;
    }
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3552
N = int(input())
AL = []
BL = []

for i in range(N):
	A, B =list(map(int,input().split()))
	AL.append(A)
	BL.append(B)

c = 0
for i in range(N):
	x = BL[-1 -i] - ((AL[-1 -i] + c) % BL[-1 -i])
	if x == BL[-1 -i]:
		x = 0
	c += x

print(c)

Measured memory_bytes: 11136
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define pb push_back
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#define endl '\n'
#define ll long long
#define f first
#define s second
#define FAST cin.tie(0), cout.tie(0), ios::sync_with_stdio(0)
#define debug(x) cout << "DEBUG " << x << endl
#define debug2(x, y) cout << "DEBUG " << x << " " << y << endl
#define debug3(x, y, z) cout << "DEBUG " << x << " " << y << " " << z<< endl
#define debug4(x, y, z, o) cout << "DEBUG " << x << " " << y << " " << z<< " " << o << endl
using namespace std;
typedef pair<ll, ll> pii;
typedef vector<vector<ll>> mat;
const ll mod = 1e9+7;
const int MAXN = 1e5+5;

int fat[1005];


int main() {
	ll x;
	cin >> x;
	ll k = 100;
	ll y = 0;
	while(k < x) {
		k += k/100;
		y++;
	}
	cout << y << endl;
}


Measured memory_bytes: 3636
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

MOD = 10 ** 9 + 7
n, m = lr()
X = np.array(lr())
Y = np.array(lr())
coef_x = np.arange(n)*2 - (n-1)
X *= coef_x
xsum = (X%MOD).sum() % MOD
coef_y = np.arange(m)*2 - (m-1)
Y *= coef_y
ysum = (Y%MOD).sum() % MOD
answer = xsum * ysum % MOD
print(answer % MOD)


Measured memory_bytes: 24040
/*{{{*/
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <unordered_map>
#include <unordered_set>
#include <cassert>
using namespace std;
typedef pair<int, int> PP;
typedef long long LL;
#define pb push_back
#define fr first
#define sc second
#define bitcnt __builtin_popcount
#define all(x) x.begin(), x.end()
inline int ri() {int x; scanf("%d", &x); return x;}
#define rep2(i, n, ...) for (int i = 0; i < (n); i ++) 
#define rep3(i, a, b, ...) for (int i = (a); i < (b); i ++)
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define drep2(i, n, ...) for (int i = (n) - 1; i >= 0; i --)
#define drep3(i, a, b) for (int i = (a) - 1; i >= (b); i --)
#define drep(...) GET_MACRO(__VA_ARGS__, drep3, drep2)(__VA_ARGS__)
template<typename T>inline bool smax(T&a, T b){if(a<b){a=b;return true;}return false;} 
template<typename T>inline bool smin(T&a, T b){if(a>b){a=b;return true;}return false;} 
/*}}}*/


const int maxn = 100010;
int cnt[maxn], g[maxn], n, m;

int main() {
  #ifdef _TEST_
  freopen("input.txt", "r", stdin);
  //freopen("out.txt", "w", stdout);
  #endif
  ios::sync_with_stdio(false);
  cin >> n >> m;
  rep(i, n) cnt[i] = 1, g[i] = 0;
  g[0] = 1;
  rep(i, m) {
    int x, y; cin >> x >> y;
    x --; y --;
    if (g[x]) {
      g[y] = 1;
      if (cnt[x] == 1) g[x] = 0;
    }
    cnt[x] --; 
    cnt[y] ++;
  }
  rep(i, 1, n) g[0] += g[i];
  cout << g[0] << endl;
  

  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rep_ll(i,n) for(ll i = 0; i < (ll)(n); i++)
using namespace std;
typedef long long ll;
typedef unsigned long long u_ll;
typedef pair<int, int> pair_;
const long double PI = (acos(-1));
const int INF = 1001001001;
const int dx[] = {-1, 0, 1, 0}; const int dy[] = {0, -1, 0, 1};
ll mod = 1000000007;
int main(){
    string s;

    cin >> s;

    rep(i, 3) cout << s[i];

    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define eps 1e-7
#define PI acos(-1)
#define de(x) cout<<#x<<'='<<x<<" , "
#define dee(x) cout<<#x<<'='<<x<<endl
#define sz(x) x.size()
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define mset(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back
typedef long long LL;
typedef pair<int,int> pii;
typedef vector<int> vi;

const int MAXN=1e5+555;

LL gcd(LL a,LL b){ return b?gcd(b,a%b):a; }

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



Measured memory_bytes: 764
A,B = map(str,input().split())
La = [int(A[:3]),int(A[3:])]
Lb = [int(B[:3]),int(B[3:])]
L = 900 - (La[0] - 100) - (999 - Lb[0])
ch1 = int(A[1] + A[0])
ch2 = int(B[1] + B[0])
if Lb[1] < ch2:
  L -= 1
if ch1 < La[1]:
  L -= 1
print(L)
  


Measured memory_bytes: 9044
N,M = map(int,input().split())
arr1 = []
arr2 = []
arr3 = []
arr4 = []
arr5 = []
arr6 = []
arr7 = []
arr8 = []

for i in range(N):
  a,b,c = map(int,input().split())
  arr1.append(int(a+b+c))
  arr2.append(int(a-b+c))
  arr3.append(int(a+b-c))
  arr4.append(int(a-b-c))
  arr5.append(int(-a+b+c))
  arr6.append(int(-a-b+c))
  arr7.append(int(-a+b-c))
  arr8.append(int(-a-b-c))

arr1.sort(reverse=True)
arr2.sort(reverse=True)
arr3.sort(reverse=True)
arr4.sort(reverse=True)
arr5.sort(reverse=True)
arr6.sort(reverse=True)
arr7.sort(reverse=True)
arr8.sort(reverse=True)

print(max(sum(arr1[:M]),sum(arr2[:M]),sum(arr3[:M]),sum(arr4[:M]),sum(arr5[:M]),sum(arr6[:M]),sum(arr7[:M]),sum(arr8[:M])))


Measured memory_bytes: 39024
n=int(input())
if n==2:print(2);exit()
if n==3:print(5);exit()
for i in range(n,n+111):
  for j in range(2,int(n**0.5)+1):
    if i%j ==0:
      break
    if j==int(n**0.5):
      print(i)
      exit()

Measured memory_bytes: 38896
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    sc.close();
    
    for(int i=0;i<8;i++){
      if(n<Math.pow(2,i)){
        System.out.println((int)Math.pow(2,i-1));
        return;
      }
    }
  }
}

Measured memory_bytes: 25684
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll MOD = 1000000007;
#define all(v) v.begin(), v.end()

int main(){
  ll S;
  cin >> S;
  cout << 0 << " " << 0 << " " << 1000000000 << " " << 1 << " ";
  cout << 1000000000-(S-1)%1000000000-1 << " " << (S-1)/1000000000+1 << endl;
  
}



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

using namespace std;

typedef long long ll;

int main() {
    ll N;
    cin >> N;
    ll A[N];
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }

    ll ANS[N];
    ll index;
    for (int i = 0; i < N; i++) {
        index=A[i];
        ANS[index]=(i+1);
    }

    for (int i = 1; i < N+1; i++) {
        cout << ANS[i] << endl;
    }


    return 0;
}



Measured memory_bytes: 2432
#include <bits/stdc++.h>
#define ll long long
#define pll pair<ll, ll>
#define str string
#define fi first
#define se second
#define pb push_back
#define SET(a, b) memset(a, b, sizeof(a))
#define ff fflush(stdout)
#define IN(a) freopen(a, "r", stdin)
#define OUT(a) freopen(a, "w", stdout) 
#define eps 1e-6
#define PI atan(1) * 4
#define mod 1000000007
using namespace std;
int main () {
	ll a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q;
	scanf("%lld %lld %lld", &a, &b, &c);
	if ((b * 10 + c) % 4 == 0) printf("YES\n");
	else printf("NO\n");
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
   int a,b,c,d,n,m;
   scanf("%d %d %d %d",&a,&b,&c,&d);
   if((a<0)||(a>1000))	printf("error\n");
   else if((b<0)||(b>1000))	printf("error\n");
   else if((c<0)||(c>1000))	printf("error\n");
   else if((d<0)||(d>1000))	printf("error\n");
   
   if(a>=b)	n=b;
   else		n=a;

   if(c>=d)	m=d;
   else		m=c;
   
   printf("%d\n",n+m);
   return 0;
}



Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define INF 1e9
typedef long long ll;
using namespace std;

int main() {
    int n,x; cin >> n >> x;
    int allnum = 0;
    int minnum = INF;
    rep(i,n){
        int m; cin >> m;
        allnum += m;
        minnum = min(minnum,m);
    }
    cout << (x-allnum)/minnum + n << endl;;

    return 0;
}

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

int main(void) {
  
  int n,a,b,p,c=0,d=0,e=0;
  
  cin>>n>>a>>b;
  
  for(int i=0;i<n;i++){
      
      cin>>p;
      
      if(p<=a){
          c++;
      }
      if(a+1<=p && p<=b){
          d++;
      }
      if(b+1<=p){
          e++;
      }
  }
  
  cout<<min(min(c,d),e);
  
  
  return 0;
}


Measured memory_bytes: 256
#coding:utf-8
import sys,os
from collections import defaultdict, deque
from fractions import gcd
from math import ceil, floor
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    XLMIIS = lambda x: [LMIIS() for _ in range(x)]
    YN = lambda c : print('Yes') if c else print('No')
    MOD = 10**9+7

    K,N = LMIIS()

    A = LMIIS()
    D = []
    pre = 0
    max_diff = A[0] + K - A[-1]
    for ai in A:
        max_diff = max(max_diff,ai-pre)
        pre = ai
    
    print(K-max_diff)

    

if __name__ == '__main__':
    main()

Measured memory_bytes: 100464
#include <stdio.h>

int main(void){
	int n;
	while(scanf(" %d", &n) != EOF){
		printf("3C");
		if(n%39==0) printf("39\n");
		else if(n%39 < 10) printf("0%d\n", n%39);
		else printf("%d\n", n%39);
	}

	return 0;
}

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

int main() {
    int A, B, C;
    cin >> A >> B >> C; 
    vector<int> vec = {A, B, C};
    sort(vec.begin(), vec.end());
    reverse(vec.begin(), vec.end());
    if ((vec.at(0) - vec.at(1)) % 2 == 0 && (vec.at(1) - vec.at(2)) % 2 == 0) {
      cout << (vec.at(0) * 2 - vec.at(1) - vec.at(2)) / 2 << endl;
    }
    else if ((vec.at(0) - vec.at(1)) % 2 == 1 && (vec.at(1) - vec.at(2)) % 2 == 0) {
      cout << (vec.at(0) * 2 - vec.at(1) - vec.at(2) + 1) / 2 << endl;
    }
    else {
      cout << ((vec.at(0) * 2 - vec.at(1) - vec.at(2) + 1) / 2) + 1 << endl;
    }
}


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


using namespace std;

int data[12+1+1][12+1+1];

int func(int y,int x){
	if(data[y][x] <= 0)return 0;
	queue<int> size;
	queue<int> posX;
	queue<int> posY;
	int dx[4] = {-1,0,1,0},dy[4] = {0,1,0,-1};

	size.push(1);
	posX.push(x);
	posY.push(y);

	while(true){
		if(posX.size()==0){
			break;
		}
		int tmpX = posX.front();
		int tmpY = posY.front();
		int tmpS = size.front();
		posX.pop();
		posY.pop();
		size.pop();
		if(data[tmpY][tmpX] <=0)continue;

		data[tmpY][tmpX] = -2;
		for(int i=0;i<4;i++){
			posX.push(tmpX+dx[i]);
			posY.push(tmpY+dy[i]);
			size.push(tmpS+1);
		}
	}
	return 1;
}

int main(){

	//初期化
	for(int i=0;i<=13;i++){
		for(int j=0;j<=13;j++){
			data[i][j] = 0;
			if(i==0 || i == 13 || j==0 || j==13){
				data[i][j] = -1;
			}
		}
	}

	string str;
	//データ入力
	while(cin>>str){
		for(int j=1;j<=12;j++){
			data[1][j] = str[j-1] - '0';
		}
		for(int i=2;i<=12;i++){
			cin>>str;
			for(int j=1;j<=12;j++){
				data[i][j] = str[j-1] -'0';
			}
		}
		int sum = 0;
		for(int i=1;i<=12;i++){
			for(int j=1;j<=12;j++){
				sum += func(i,j);
			}
		}

		cout<<sum<<endl;
	}

	return 0;
}

Measured memory_bytes: 1196
#include<stdio.h>
int main(){
  char S[100],T[100],U[100];
  int A,B;
  scanf("%s %s",S,T);
  scanf("%d %d",&A,&B);
  scanf("%s",U);
  if(S[0] == U[0])
	printf("%d %d",A-1,B);
  else if(T[0] == U[0])
    printf("%d %d",A,B-1);
  return 0;
}

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

string S;

int main()
{
    cin >> S;

    int cnt=S[0];

    for(int i=1;i<4;i++)
    {
        if(cnt==S[i])
        {
            cout << "Bad" << endl;
            return 0; 
        }
        else cnt=S[i];
    }

    cout << "Good" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<string.h>
#include<vector>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<climits>
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    vector<int>values;
    vector<int>costs;
    for(int i=0;i<n;i++){
        int value;
        cin>>value;
        values.push_back(value);
    }
    for(int i=0;i<n;i++){
        int cost;
        cin>>cost;
        costs.push_back(cost);
    }
    int ans = 0;
    for(int i=0;i<n;i++){
        if(values[i]>costs[i]){
            ans+=abs(values[i]-costs[i]);
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 384
#include "bits/stdc++.h"

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=(n); i--)
#define LREP(lst,itr) for(auto itr = lst.begin(); itr != lst.end(); ++itr)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define P(s) cout<<(s)<<endl
#define P2(a, b) cout<<(a)<<" "<<(b)<<endl
#define P3(a, b, c) cout<<(a)<<" "<<(b)<<" "<<(c)<<endl
#define V2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

// インデックスの指定方法
// 
// strangeorange  こんな文字列が与えられた時
// 123456789ABCD  添字の対応はこんな感じ。0から始まってないことに注意！
// 
// range2つを抜き出す
// match(2,7,8,D)
// 
// 左側は目的の文字列と被らない、右側は被る
// 何故かはロリハの計算方法を見れば理解できるはず

long long const MS = 2;
const long long mod[] = {999999937LL, 1000000007LL}, base = 9973;
struct rolling_hash {
    int n;
    vector<long long> hs[MS], pw[MS];
    rolling_hash(){}
    rolling_hash(const string &s) {
        n = s.size();
        for (int i = 0; i < MS; i++) {
            hs[i].assign(n+1,0);
            pw[i].assign(n+1,0);
            hs[i][0] = 0;
            pw[i][0] = 1;
            for (int j = 0; j < n; j++) {
                pw[i][j+1] = pw[i][j]*base%mod[i];
                hs[i][j+1] = (hs[i][j]*base+s[j])%mod[i];
            }
        }
    }

    long long hash(int l, int r, int i) {
        return ((hs[i][r]-hs[i][l]*pw[i][r-l])%mod[i]+mod[i])%mod[i];
    }

    bool match(int l1, int r1, int l2, int r2) {
        bool ret = 1;
        for (int i = 0; i < MS; i++) ret &= hash(l1,r1,i)==hash(l2,r2,i);
        return ret;
    }
};

rolling_hash rh;
int N;

bool C(ll len){//ここに条件を書く
    map<pair<int, int>, int> mp;
    mp.clear();
    REP(i,0,N-len+1){
        int hash1 = rh.hash(i,i+len,0);
        int hash2 = rh.hash(i,i+len,1);
        pair<int, int> hash_pair = make_pair(hash1, hash2);
        if(mp.count(hash_pair) && mp[hash_pair]<=i){
            return true;
        }else if(!mp.count(hash_pair)){
            mp[hash_pair]=i+len;
        }
    }
    return false;
}

ll nibutan(ll lb, ll ub){
    while(ub-lb>1){
        ll mid=(lb+ub)/2;
        if(C(mid)) lb=mid;
        else ub=mid;
        //cout << lb<<" "<<ub <<endl;
    }
    return lb;
}

int main(){
    string S;
    cin >> N >> S;
    rh = rolling_hash(S);
    P(nibutan(0,N));
}

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

using namespace std;

typedef vector<int> vec;
const int N=1e4+10;

int V,E;
vec G[N],rG[N],res;
bool used[N];
int cmp[N];
int k;

void add(int s,int t)
{
    G[s].push_back(t);
    rG[t].push_back(s);
}

void dfs(int v)
{
    used[v]=true;
    for(int i=0;i<G[v].size();i++)
    {
        int to=G[v][i];
        if(!used[to])
        {
            dfs(to);
        }
    }
    res.push_back(v);
}

void rdfs(int v,int color)
{
    used[v]=true;
    cmp[v]=color;
    for(int i=0;i<rG[v].size();i++)
    {
        int to=rG[v][i];
        if(!used[to])
        {
            rdfs(to,color);
        }
    }
}

void scc()
{
    memset(used,0,sizeof(used));
    for(int i=0;i<V;i++)
    {
        if(!used[i])
        {
            dfs(i);
        }
    }
    memset(used,0,sizeof(used));
    k=0;
    for(int i=res.size()-1;i>=0;i--)
    {
        if(!used[res[i]])
        {
            rdfs(res[i],k++);
        }
    }
}

int main()
{
    cin>>V>>E;

    for(int i=0;i<E;i++)
    {
        int s,t;
        cin>>s>>t;
        add(s,t);
    }

    scc();

    int q;
    cin>>q;

    while(q--)
    {
        int u,v;
        cin>>u>>v;
        cout<<(cmp[u]==cmp[v])<<endl;
    }

    return 0;
}



Measured memory_bytes: 4676
/*
https://drken1215.hatenablog.com/entry/2020/03/08/020200
とても勉強させていただいた記事
*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;

const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()

ll N;
int P;
string S;

//整数の性質大切

ll solve(){
    if(P==2||P==5){
        ll res=0;
        //[l,r)の区間なので、rがわかれば、そのrを持つlはrから左側全てなので、N-iを加算することでもとまる
        //また、P==2||P==5の時、合同式の性質に引っかかるので、例外。
        //また、解説中の2,5の時の条件を満たすものはS[r-1]%P==0を満たすときと言い換えられるため、以下の式となる
        rep(i,N)if((S[N-i-1]-'0')%P==0)res+=N-i;
        return res;
    }
    vector<ll> val(P,0);//持つのはP以下の数となるので
    ll tenfactor=1;//何桁目か
    ll cur=0;//余り
    val[cur]++;
    rep(i,N){
        //N-i-1で右側から探索
        //tenfactorを用いることで文字列を数値に変換するのを早く行っている？
        //文字列操作にかかる計算量は大きいと聞く
        //llの範囲超えないか？と思ったが、Pで余りを取っているのでその心配はない
        //curの状態が法Pで保たれているならば、桁を付けていく操作に問題はないんだろうか……？
        //合同式の性質的に、同じ法の中での足し算は大丈夫……だったからだと思う。
        cur=(cur+(S[N-i-1]-'0')*tenfactor)%P;
        tenfactor=(tenfactor*10)%P;
        val[cur]++;//余りの数をカウント
    }
    ll res=0;
    rep(p,P)res+=val[p]*(val[p]-1)/2;//同じ余りが条件を満たすので、余りの組み合わせを求める。
    return res;
}

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

    cout<<solve()<<endl;

    return 0;
}

//a=97,z=122

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

int main(){
    string s;
    cin >> s;
    int n = s.length();
    if (s[n-1] == 's'){
        cout << s << "es" << endl;
    } else{
        cout << s << "s" << endl;
    }
    return 0;
}

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

int main() {
  int y,m,d;
  char a,b;
  cin >> y >> a >> m >> b >> d  ;
  if(m < 4) cout << "Heisei" <<endl;  
  else if(m==4 && d<=30) cout << "Heisei" << endl;
  else cout << "TBD" << endl;
}

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

int main(){
  int N;
  cin>>N;
  int f,t;
  int a;
  f=t=0;
  for(int i=0;i<N;i++){
    cin>>a;
    if(a%4==0)f++;
    else if(a%2==0)t++;
  }
  if(2*f+1>=N||2*f+t>=N)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


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

using namespace std;

typedef pair<int,string> P;

int main(){
  int d[4] = {-1,1,-4,4};
  map<string,int> ans;
  ans["01234567"] = 0;
  queue<P> que;
  que.push(P(0,"01234567"));

  while(que.size()){
    P p = que.front(); que.pop();
    int k = ans[p.second];
    for(int i = 0;i < 4;i++){
      int n = p.first + d[i];
      if(i == 0 && n == 3)continue;
      if(i == 1 && n == 4)continue;
      if(n >= 0 && n < 8){
	       string tmp;
	       tmp = p.second;
	       tmp[p.first] = tmp[n];
         tmp[n] = '0';
         if(ans.find(tmp) == ans.end()){
	          ans[tmp] = k + 1;
	          que.push(P(n,tmp));
	        }
        }
      }
    }
  string s;
  char t;
  while(cin >> t){
    s += t;
    for(int i = 0;i < 7;i++){
      cin >> t;
      s += t;
    }
    cout << ans[s] << endl;
    s.clear();
  }

  return 0;

}

Measured memory_bytes: 5424
class SWAG():
    def __init__(self,unit,f):
        self.fold_r=[unit]
        self.fold_l=[unit]
        self.data_r=[]
        self.data_l=[]
        self.f=f
    def __refill_right(self):
        temp=[]
        n=len(self.data_l)
        for _ in range(n//2):
            temp.append(self.popleft())
        for _ in range(n//2,n):
            self.append(self.popleft())
        for t in temp[::-1]:
            self.appendleft(t)
    def __refill_left(self):
        temp=[]
        n=len(self.data_r)
        for _ in range(n//2):
            temp.append(self.pop())
        for _ in range(n//2,n):
            self.appendleft(self.pop())
        for t in temp[::-1]:
            self.append(t)
    def append(self,x):
        self.fold_r.append(self.f(self.fold_r[-1],x))
        self.data_r.append(x)
    def appendleft(self,x):
        self.fold_l.append(self.f(self.fold_l[-1],x))
        self.data_l.append(x)
    def pop(self):
        if not self.data_r:
            self.__refill_right()
        self.fold_r.pop()
        return self.data_r.pop()
    def popleft(self):
        if not self.data_l:
            self.__refill_left()
        self.fold_l.pop()
        return self.data_l.pop()
    def fold_all(self):
        return self.f(self.fold_r[-1],self.fold_l[-1])
n,k,*p=map(int,open(0).read().split())
c=[0]
for a,b in zip(p,p[1:]):c+=c[-1]+(a<b),
*c,f=[b-a==k-1for a,b in zip(c,c[k-1:])]
x=not f
s_min=SWAG(10**18,lambda a,b:a if a<b else b)
s_max=SWAG(0,lambda a,b:a if a>b else b)
*_,=map(s_min.append,p[:k-1])
*_,=map(s_max.append,p[1:k])
for i,(a,b,c)in enumerate(zip(p,p[k:],c)):
    f|=c
    s_min.append(p[i+k-1])
    s_max.append(b)
    if not c and(a!=s_min.fold_all()or b!=s_max.fold_all()):x+=1
    s_min.popleft()
    s_max.popleft()
print(x+f)

Measured memory_bytes: 29212
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abc059_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            string s1 = (input[0].Substring(0, 1).ToUpper());
            string s2 = (input[1].Substring(0, 1).ToUpper());
            string s3 = (input[2].Substring(0, 1).ToUpper());

            for (int i = 0; i < 1; i++)
            {
                Console.WriteLine(s1 + s2 + s3);
                
            }
            Console.Read();
        }
    }
}


Measured memory_bytes: 11092
n,m=map(int,input().split())
a=[int(input())  for _ in range(m)]

flag=[True]*(n+1)
for i in range(m):
    flag[a[i]]=False

dp=[0]*(n+1)
dp[0]=1
if flag[1]:
    dp[1]=1
else:
    dp[1]=0
for i in range(2,n+1):
    if flag[i]:
        dp[i]=dp[i-1]+dp[i-2]

print(dp[n]%1000000007)


Measured memory_bytes: 460788
import math
a, b, h, m = map(int, input().split())
la = 2*math.pi*m/60
sa = 2*math.pi*(h*60+m)/720
d = math.sqrt((a*math.cos(sa)-b*math.cos(la))**2+(a*math.sin(sa)-b*math.sin(la))**2)
print(d)

Measured memory_bytes: 9580
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

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

func main() {
	sc.Split(bufio.ScanWords)

	s := getString()
	x := make(map[int]int)
	for _, v := range s {
		x[int(v)]++
	}
	ans := "yes"
	for _, v := range x {
		if v >= 2 {
			ans = "no"
		}
	}
	out(ans)
}


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

int main(){
	int n;
	cin >> n;
	double ans = 0;
	rep(i,n){
		int a;
		cin >> a;
		ans += 1.0/a;
	}
	ans = 1/ans;
	printf("%.10f\n", ans);
	return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FFOR(i,a,b) for(int i=(a);i<=(b);i++)
#define REP(i,b) FOR(i,0,b)
#define RREP(i,b) FFOR(i,1,b)
#define PB push_back
#define F first
#define S second
#define BE(c) c.begin(),c.end()
using namespace std;
typedef long long LL;
typedef LL ut;
typedef long double ld;
typedef pair<ut,ut> pr;
typedef vector<pr> Vpr;
typedef vector<ut> VI;
typedef pair<pr, ut> ppr;
typedef priority_queue<pr,Vpr, greater<pr> > PQ;
const int SIZE=5+3*1e+4;
const ut INF=1<<30;
const ld eps=1e-6;
const LL mod=7+1e+9;
 
int main() {
	string s;
	cin >> s;
	bool c = false, f = false;
	REP(i,s.size()){
		if(s[i] == 'C')
			c = true;
		if(c && s[i] == 'F')
			f = true;
	}
	if(c && f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
    return 0;	
}


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

public class Main {

	public static void main(String[] args) {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		String buffer;
		try {
			while ((buffer = reader.readLine())  != null) {
				Integer H = Integer.valueOf(buffer.substring(0, buffer.indexOf(" ") == -1 ? buffer.length() : buffer.indexOf(" ")));
				buffer = buffer.substring(buffer.indexOf(" ") + 1);
				Integer W = Integer.valueOf(buffer.substring(0, buffer.indexOf(" ") == -1 ? buffer.length() : buffer.indexOf(" ")));
				if (H == 0 && W == 0) {
					return;
				}
				for (int i = 0; i < H; i++) {
					for (int j = 0; j < W; j++) {
						System.out.print("#");
					}
					System.out.println();
				}
				System.out.println();
			}
		} catch (Exception ex) {
			ex.printStackTrace();
		}
	}
}

Measured memory_bytes: 31648
#include <stdio.h>

int main(void) {
  int x, a, b;
  scanf("%d %d %d", &x, &a, &b);
  if (a - b >= 0)
    printf("delicious\n");
  else if (b - a <= x)
    printf("safe\n");
  else
    printf("dangerous\n");
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
using ll = long long;

int main(){
    int N;
    ll in, med_left, med_right;
    vector<ll> x, x_sorted;

    cin >> N;
    //input
    for(int i=0; i<N; i++){
        cin >> in;
        x.push_back(in);
    }

    x_sorted = x;
    sort(x_sorted.begin(), x_sorted.end());
    med_left = x_sorted[N/2-1];
    med_right = x_sorted[N/2];

    for(int i=0; i<N; i++){
        if(x[i]<=med_left){
            cout << med_right << endl;
        }else{
            cout << med_left << endl;
        }
    }
    return 0;
    
}

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

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(){
	int n,k;
	vector<int> h(100010);
	
	cin >> n >> k;
	vector<long long> cost(100010,INF);

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

	cost[0] = 0;
	for(int i=1; i<n; i++){
		for(int j=1;j<=min(k,i);j++){
			chmin(cost[i],cost[i-j]+abs(h[i]-h[i-j]));
		}
	}

	cout << cost[n-1] << endl;
}

Measured memory_bytes: 4588
import math
N, M = map(int, input().split())
switch = [0] * N
pattern = 2 ** N
ans = 0
for i in range(M):
  temp = input().split()[1:]
  for j in temp:
    switch[int(j) - 1] += (1 << i )
  
p = list(map(int, input().split()))
pbin = 0
temp = 1
for i in p:
  pbin += i * temp
  temp *= 2

for i in range(pattern):
  temp = 0
  j = 0
  while i > 0:
    if i & 1 == 1 :
      temp = temp ^ switch[j]
    j += 1
    i = i >> 1
  if pbin == temp:
    ans += 1
print(ans)


Measured memory_bytes: 9124
#include <iostream>
#include <utility>
#include <tuple>
#include <vector>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include <functional>
#include <climits>
#include <numeric>
#include <queue>
#include <cmath>
#include <iomanip>
#include <array>
#include <string>

int main() {
	int n; std::cin >> n;
	if (n == 1) {
		std::cout << "1\n0\n";
	}
	else if (n == 2) {
		std::cout << "2\n0\n11\n";
	}
	else {
		std::cout << n - 1 << '\n';
		for (auto i = 2; i <= n; ++i) {
			std::cout << '1';
			for (auto j = 0; j < i - 2; ++j) std::cout << '0';
			std::cout << "1\n";
		}
	}
}



Measured memory_bytes: 3084
var d:array[0..100]of boolean;
    n,i,x,a:longint;
begin
  readln(n);
  for i:=1 to n do
  begin
    read(x);
    if not d[x] then
    begin
      d[x]:=true;
      inc(a);
    end;
  end;
  writeln(a);
end.

Measured memory_bytes: 128
N = int(input())
H = list(map(int,input().split()))

F = [0*N for _ in range(N+1)]
F[2] = abs(H[0]-H[1])

for i in range(3,N+1):
    f1,f2 = 0,0
    f1 = abs(H[i-1]-H[i-2])+F[i-1]
    f2 = abs(H[i-1]-H[i-3])+F[i-2]
    F[i] = min(f1,f2)

print(F[-1])

Measured memory_bytes: 13928
from collections import Counter

n = int(input())
c = list(map(int,input().split()))
s = Counter(c)
t = list(s.items())
nag = len(t)
x = 0
ans = 0

for i in range(nag):
    x += (t[i][1]*(t[i][1]-1))//2
    
for j in range(n):
    ans = x - s[c[j]] + 1 
    print(ans)

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

#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())

#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
#define LL long long
#define Dev 1000000007

//cout << (c)?"Yay!":":(" << endl;

// sort(a.begin(), a.end(), std::greater<int>());
using namespace std;

int main()
{

    long long int a, b, n;
    cin >> a >> b >> n;
    long long int ans = 0;
    if (b > n)
    {
        ans = a * n / b;
    }
    else
    {
        ans = a * (b - 1) / b;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define clr(i, j)     memset(i, j, sizeof(i))
using namespace std;
 
#define ll long long
ll n,m;
ll dp[1000][(1 << 13)];
ll a[10000];
 ll armask[10000];
 ll msk;
ll solve(ll i,ll mask){
    
    if(mask==(1ll << n) - 1){
        return 0;
    }if(i==m){
        return 1e9;
    }ll &ret=dp[i][mask];
    if(ret!=-1){
        return ret;
    }
   ret=min( solve(i+1,mask|armask[i])+a[i] ,solve(i+1,mask));
   return ret;
}

int main()
{
    //cout<<pow(2,12);
   cin>>n>>m;
   for(int i=0;i<n;i++){
       msk|=(1<<i);
   }
   clr(dp,-1);
    for(ll i=0;i<m;i++){
       ll b;
        cin>>a[i]>>b;
        ll mask=0;
       for(ll j=0;j<b;j++){
           ll x;
           cin>>x;
           mask|=(1<<(x-1));
       }armask[i]=mask;
    }
    ll ans=solve(0,0);
    if(ans==1e9){cout<<-1;}else{cout<<ans;}
   
}

Measured memory_bytes: 67748
import numpy as np
n,k=map(int,input().split())
s=np.arange(n)+1
s=k/s
s=np.ceil(np.log2(s))
s=np.power(0.5,s)
s=np.where(s<1,s,1)
s=np.sum(s)/n
print(s)

Measured memory_bytes: 20388
#include<iostream>
using namespace std;
int main()
{
  int a,b,c,k;
  int cnt;
  cin>>a>>b>>c>>k;
  if(k<=a)
  {
    cout<<k;
    exit(0);
  }else
  {
    k=k-a;
    if(k<=b)
    {cout<<a;exit(0);}
    else
    {
      k=k-b;
      a=a-k;
      cout<<a;
    }
  }
  return 0;
}

Measured memory_bytes: 3672
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
inline int read(){
	int x=0,f=1;char ch;
	do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');
	do{x=x*10+ch-'0';ch=getchar();}while(ch>='0'&&ch<='9');
	return x*f;
}
int main(){
	int a=read(),b=read(),c=read();
	if (a+b>=c) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 256
use proconio::*;

fn run() {
    input! {
        n: usize,
        a: [usize; n],
    }
    let mut ans = 0usize;
    let mut map = std::collections::BTreeMap::new();
    for (i, &a) in a.iter().enumerate() {
        if i >= a {
            let d = i - a;
            ans += map.get(&d).map_or(0, |p| *p);
        }
        *map.entry(i + a).or_insert(0) += 1;
    }
    println!("{}", ans);
}

fn main() {
    run();
}

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

int main()
{
  string s;
  cin >> s;
  if(s[0] == s[2]) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime> 
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

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

	string s;
	cin >> s;
	if ((int)s.size() >= 4 && s[0] == 'Y' && s[1] == 'A' && s[2] == 'K' && s[3] == 'I') {
		cout << "Yes\n";
	} else {
		cout << "No\n";
	}
}

Measured memory_bytes: 3036
package main
 
import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)
 
func main() {
	H := nextInt64()
    fmt.Println(caracal(H))
}

func caracal(h int64) int64 {
  if h == 1 {
     return 1 
  }
  return caracal(h / 2) * 2 + 1
}

var stdin = initStdin()
 
func initStdin() *bufio.Scanner {
	bufsize := 1 * 1024 * 1024 // 1 MB
	var stdin = bufio.NewScanner(os.Stdin)
	stdin.Buffer(make([]byte, bufsize), bufsize)
	stdin.Split(bufio.ScanWords)
	return stdin
}
 
func nextString() string {
	stdin.Scan()
	return stdin.Text()
}
 
func nextBytes() []byte {
	stdin.Scan()
	return stdin.Bytes()
}
 
func nextInt() int {
	i, _ := strconv.Atoi(nextString())
	return i
}
 
func nextInt64() int64 {
	i, _ := strconv.ParseInt(nextString(), 10, 64)
	return i
}


Measured memory_bytes: 640
#include <stdio.h>
int main(h, n, t, s)
{
    s=0;
    scanf("%d%d", &h, &n);
    while(n--)
    {
        scanf("%d", &t);
        s+=t;
        if(s>=h) break;
    }
    printf("%s\n", (s>=h)?"Yes":"No");
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string.h>
#include<queue>
#include<utility>
#include<algorithm>
#include<math.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int cnt=0,a;
	for(int i=1;i<=n;i++){
		cin>>a;
		if(a!=i) cnt++;
	}
	if(cnt>2) cout<<"NO";
	else cout<<"YES";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define ul unsigned long long int
#define va vector<long long int> a 
#define vb vector<long long int> b
#define debug() for(ll l=0;l<50;l++){}
#define fast cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
const ll M = 998244353;
const ll inf = 1e18+5;
const ll INF=INT_MAX;
using namespace std;
ll bs(ll arr[], ll l, ll r, ll x){
	ll mid=0;
    if (r >= l){
		if (arr[mid] == x) return mid; 
        if (arr[mid] > x) return bs(arr, l, mid - 1, x); 
        return bs(arr, mid + 1, r, x); 
    }
    return -1;
}
ll power(ll x,ul y,ll p){
	ll res = 1;
	x = x % p;
	if(x == 0) return 0;
	while (y > 0){
		if (y & 1) res = (res*x) % p;
		y = y>>1;
		x = (x*x) % p;
		}
	return res;
}
const int max1=500001;
pair<int,int>st[4*max1];
int arr[max1],arr1[max1];
void buildtree(int si,int ss,int se){
	if(ss==se){
        st[si].first=arr1[ss];
        st[si].second=arr1[ss];
		return;
	}
	int mid=ss+(se-ss)/2;
	buildtree(2*si,ss,mid);
	buildtree(2*si+1,mid+1,se);
	if(arr1[mid]>arr1[mid+1]) st[si].first=st[2*si].first+st[2*si+1].first;
    else st[si].second=st[2*si].second+st[2*si+1].second;
	
}
int query(int si,int ss,int se,int qs,int qe){
	if(qs>se || qe<ss) //completely outside
		return INF;
	if(ss>=qs && se<=qe)
		return st[si].first;
	int mid=ss+(se-ss)/2;
	int l=query(2*si,ss,mid,qs,qe);
	int r=query(2*si+1,mid+1,se,qs,qe);
	return min(l,r);
}
int geteven(int si,int ss,int se,int qs,int qe){
	if(ss>qe || se<qs) //completely outside
		return 0;
	if(ss>=qs && se<=qe)
		return st[si].second;
	int mid=ss+(se-ss)/2;
	int l=geteven(2*si,ss,mid,qs,qe);
	int r=geteven(2*si+1,mid+1,se,qs,qe);
	return l+r;
}
int getodd(int si,int ss,int se,int qs,int qe){
	if(qs>se || qe<ss) //completely outside
		return 0;
	if(ss>=qs && se<=qe)
		return st[si].first;
	int mid=ss+(se-ss)/2;
	int l=getodd(2*si,ss,mid,qs,qe);
	int r=getodd(2*si+1,mid+1,se,qs,qe);
	return l+r;
}
void update(int si,int ss,int se,int qi,int newval){
	if(ss==se){
        if(arr[ss]%2==1) st[si]={0,1};
        else st[si]={1,0};
		arr[ss]=newval;
		return;
	}
	int mid=ss+(se-ss)/2;
	if(qi<=mid) update(2*si,ss,mid,qi,newval);
	else update(2*si+1,mid+1,se,qi,newval);
	st[si].first=st[2*si].first+st[2*si+1].first;
    st[si].second=st[2*si].second+st[2*si+1].second;
}
void solve(){
	ll n,sum=0;
	cin>>n;
	for(ll i=1;i<n;i++){
		if(n%i==0) sum+=n/i -1;
		else sum+=n/i;
		//sum+=(n-2*i)*2 +1;
	}
	cout<<sum<<"\n";
	
}
int main(){
	fast;
	ll t=1;
	//cin>>t;
	while(t--) solve();
	return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>
#include <numeric>
#include <iomanip>
#include <cstring> 
using namespace std;
using ll=long long;

#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define LLONG_MAXs 9223372036854775800

#include <iostream>
#include <cmath>
using namespace std;
 

 
bool isPrimeNum( ll x ){ // 素数である場合 true を返す
  if( x <= 1 ){ // 1以下である場合は素数でないことがすぐにわかる
    return false;
  }
  // sqrt( double型 ) は引数の平方根を double型で返すので、int型でキャスト
  int n = (int)sqrt( (double)x );
  for( int i = 2; i <= n; i++ ){
    if( x % i == 0 ){ // 割り切る整数がある場合、即判定終了
      return false;
    }
  }
  return true; // 割り切る整数がない場合、素数である
}

constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
constexpr ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll abs(ll a,ll b){
if(a>=b)return a-b;
if(a<b)return b-a;
}
constexpr ll min(ll a,ll b){
if(a>=b)return b;
if(a<b)return a;
}

constexpr ll max(ll a,ll b){
if(a>=b)return a;
if(a<b)return b;
}

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

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main() {

  ll C[3][3];

    cin>>C[0][0]>>C[0][1]>>C[0][2];
    cin>>C[1][0]>>C[1][1]>>C[1][2];
    cin>>C[2][0]>>C[2][1]>>C[2][2];

  int flag=0;
 
  ll a1a2=C[0][1]-C[0][0];
  ll a2a3=C[0][2]-C[0][1];
  ll b1b2=C[1][0]-C[0][0];
  ll b2b3=C[2][0]-C[1][0];

  if(a1a2!=C[1][1]-C[1][0])flag++;
  if(a1a2!=C[2][1]-C[2][0])flag++;
  if(a2a3!=C[1][2]-C[1][1])flag++;
  if(a2a3!=C[2][2]-C[2][1])flag++;

  if(b1b2!=C[1][1]-C[0][1])flag++;
  if(b1b2!=C[1][2]-C[0][2])flag++;
  if(b2b3!=C[2][1]-C[1][1])flag++;
  if(b2b3!=C[2][2]-C[1][2])flag++;
  if(flag==0){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}
 


Measured memory_bytes: 256
n = list(input())
if len(n) == 1:
    print(n[0])
    exit()
n = [int(n[i]) for i in range(len(n))]
m = set(n[1:])
if m == {9}:
    print(sum(n[1:]) + n[0])
    exit()
else:
    print(9*(len(n)-1) + n[0] -1)

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

int main(){
	int n,a[305000],ans=4e6;
	string s;
	cin>>n>>s;
	a[0]=(s[0]=='E');
	for(int i=1; i<n; i++)a[i]=a[i-1]+(s[i]=='E');
	for(int i=0; i<n; i++)ans=min(ans,i-a[i-1]+a[n-1]-a[i]);
	cout<<ans<<endl;
}


Measured memory_bytes: 1796
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        char[] S = scanner.next().toCharArray();
        scanner.close();

        boolean[] has = new boolean[26];

        for (char c : S) {
            has[c - 'a'] = true;
        }

        for (int i = 0; i < 26; i++) {
            if (!has[i]) {
                System.out.println((char) ('a' + i));
                return;
            }
        }

        System.out.println("None");
    }
}

Measured memory_bytes: 26368
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define pii pair<int,int>
#define pll pair<ll,ll>
#define IT iterator
#define PB push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define UPD(x,y) (((x)+=(y))>=mo?x-=mo:233)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));
#define debug puts("wzpakking")
using namespace std;
const int N=10000005;
const int mo=998244353;
int fac[N],inv[N],P2[N],n;
int power(int x,int y){
	int s=1;
	for (;y;y/=2,x=1ll*x*x%mo)
		if (y&1) s=1ll*s*x%mo;
	return s;
}
void init(){
	fac[0]=inv[0]=inv[1]=P2[0]=1;
	For(i,2,N-1) inv[i]=1ll*inv[mo%i]*(mo-mo/i)%mo;
	For(i,1,N-1) inv[i]=1ll*inv[i-1]*inv[i]%mo;
	For(i,1,N-1) fac[i]=1ll*fac[i-1]*i%mo;
	For(i,1,N-1) P2[i]=2ll*P2[i-1]%mo;
}
int C(int x,int y){
	if (x<0||y<0||y>x) return 0;
	return 1ll*fac[x]*inv[y]%mo*inv[x-y]%mo;
}
int main(){
	init();
	scanf("%d",&n);
	int ans=power(3,n);
	For(i,n/2+1,n) ans=(ans+mo-2ll*P2[n-i]*C(n,i)%mo)%mo;
	printf("%d\n",ans);
}

Measured memory_bytes: 117376
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int INF=INT_MAX;
const ld PI=3.1415926535838797323;
const ld E=2.71828183;
const int MOD=1e9+7;
vi bfs(vector<vi>adj,int src){
    //adjacency list, not-weighted, possibly directed ,src is 1-indexed, adj[0].size()=0!!!
    //for n vertices, adj.size()=n+1. (constructed via push_back() ).

    queue<int>q;
    q.push(src);
    vi dst(adj.size(),INF);
    dst[src]=0;
    while(!q.empty()){
        int c=q.front();
        q.pop();
        for(int nbr:adj[c]){
            if(dst[nbr]==INF){
                dst[nbr]=dst[c]+1;
                q.push(nbr);
            }
        }
    }
    return dst;
}
vi bfsParents(vector<vi>adj,int src){
    vi parents=vi(adj.size(),INF);
    parents[src]=-1;
    queue<int>q;
    q.push(src);
    vi dst(adj.size(),INF);
    dst[src]=0;
    while(!q.empty()){
        int c=q.front();
        q.pop();
        for(int nbr:adj[c]){
            if(dst[nbr]==INF){
                parents[nbr]=c;
                dst[nbr]=dst[c]+1;
                q.push(nbr);
            }
        }
    }
    return parents;
}
int powMod(int base,int exp,int mod){
    //base^exp %mod
    int ans=1;
    for(int i=0; i<exp; i++)
        ans=((ans%mod)*(base%mod))%mod;
    return ans;
}
vi divisorsOf(int n){
    //vector of divisors of n (inc. 1 , excl.n)
    vi ans;
    for(int i=1; i*i<=n; i++){
        if(n%i==0)
            ans.push_back(i);
        if(i*i!=n && i!=1)
            ans.push_back(n/i);
    }
    return ans;
}

void solve();

int main() {
    //  int t;
    //cin >> t;
    //while(t--)
    solve();
}
void solve(){
    string s,t;
    cin >> s >> t;
    for(int i=0; i<s.size(); i++)
        if(s[i]!=t[i]){
            cout << "No\n";
            return;
        }
    cout << "Yes\n";

}

Measured memory_bytes: 3596
H , W , A , B = map(int,input().split())
before = 1
after = 0
for i in range(H):
    ans_row = []
    if i == B:
        before = 0
        after = 1
    for j in range(W):
        if A <= j:
            ans_row.append(before)
        else:
            ans_row.append(after)
    print(*ans_row , sep = "")

Measured memory_bytes: 5364
#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP1(i,a,b) for (int i = a; i <= (int)(b); i++)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }

int main() {
  string s;
  cin >> s;
  if ( SZ(s)==3 ) {
    reverse(ALL(s));
  }
  cout << s;
  return 0;
}


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

int sumof(int p[],int N)
{
  int max=0;
  int sum=0;
 
  for(int i=1; i<=N; i++){
    if(p[i] > max){
      max =p[i];
    }
  } 
  for(int i=1; i<=N; i++){
         sum += p[i];
      }
  return sum-max/2;
}

int main(void)
{
  int *n;
  int N;
  
  scanf("%d", &N);
  n = calloc(N, sizeof(int));
  
  for(int i=1; i<=N; i++){
   scanf("%d\n", &n[i]);
  }
  printf("%d", sumof(n,N));
  free(n);
  return 0;
  
}

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

using namespace std;
char s[100005],t[100005];
vector<int> pos[26];
int slen,tlen;
bool have[26];

int main()
{
    scanf("%s%s",s,t);
    slen = strlen(s);
    tlen = strlen(t);
    for(int i=0;i<tlen;++i){
        have[t[i]-'a']=true;
    }

    for(int i=0;i<slen;++i){
        pos[s[i]-'a'].push_back(i);
        have[s[i]-'a']=false;
    }

    for(int i=0;i<26;++i){
        if(have[i]){
            printf("-1\n");return 0;
        }
    }

    long long ans = 1,now=0;
    for(int i=0;i<tlen;){
        auto np = lower_bound(pos[t[i]-'a'].begin(),
                              pos[t[i]-'a'].end(),now%slen);
        if(np==pos[t[i]-'a'].end()){
            now = (now/slen+1)*slen;continue;
        }
        now = now/slen*slen+*np;
        if(now>=ans){
            ans=now+1;++i;++now;continue;
        }
        ++i;++now;
    }
    printf("%lld\n",ans);
    return 0;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

const double PI = acos(-1);
#define MOD 1000000007

#define PB push_back
#define F first
#define S second
#define all(a) (a).begin(), (a).end()
#define sz(x) (ll)x.size()
#define el <<'\n'

#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sqr(a) ((a) * (a))

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
main()
{
    optimize();
    ll n,m,i;
    cin>>n>>m;
    cout<< n*(n-1)/2+m*(m-1)/2 el;
}










Measured memory_bytes: 256