akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

using namespace std;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    ll N;
    cin >> N;
    vector<ll> A(N),C(N);
    ll sum = 0;
    rep(i,N){
        cin >> A[i];
        sum += A[i];
    }
    ll b = (N+1)*N/2;
    if(sum % b != 0 ){
        cout << "NO" << endl;
        return 0;
    }
    ll k = sum / b;
    rep(i,N){
        C[i] = A[i] - A[(i+1)%N] + k;
    }
    ll cnt = 0;
    rep(i,N){
        if(C[i]%N!=0){
            cout << "NO" << endl;
            return 0;
        }else cnt += abs(C[i])/N;
    }
    if(cnt==k)cout << "YES" << endl;
    else cout << "NO" << endl;
}


Measured memory_bytes: 1792
import sys
import math

input = sys.stdin.readline


a = input().rstrip()

vowel = ['a', 'i', 'u', 'e', 'o']
flag = False

for i in vowel:
    if (i == a):
        flag = True

if (flag == True):
    print('vowel')
else:
    print('consonant')


Measured memory_bytes: 2940
#include<iostream>
#include<string>
#include<cstdlib>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++ i)
#define LL long long

int main()
{
  LL a;
  cin >> a;
  
  string b;
  cin >> b;
  b.erase(1, 1);
  
  int n = stoi(b);
  
  cout << (a * n) / 100LL << endl;
  return 0;
}


Measured memory_bytes: 3572
#include<stdio.h>

int main(void)


{


char str[1010];


int i,sum;


scanf("%s",str);


while(str[0]!='0'){


i=0;


sum=0;


while(str[i]){


sum+=str[i]-'0';


i++;


}


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


scanf("%s",str);


}


return 0;


}

Measured memory_bytes: 2708
import java.util.Scanner;

class Main
{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		
		int[] a = new int[300];
		int[] b = new int[300];
		int i = 0;
		
		a[0] = 1;
		b[0] = 1;
		
		while(!(a[i] == 0 && b[i] == 0)){
			i++;
			a[i] = scan.nextInt();
			b[i] = scan.nextInt();}
			
		for(int q=1; q<i; q++){
			for(int j=0; j<a[q]; j++){
				for(int h=0; h<b[q]; h++){
				if(j==0 || j==a[q]-1 || h==0 || h==b[q]-1){
					System.out.print("#");}
				else{
					System.out.print(".");}}
				System.out.print("\n");}
				System.out.print("\n");}
	}
}


Measured memory_bytes: 34820
// ORZ YJZ
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define rep(i,a,b) for(int (i) = (a); (i) <= (b); i++)
#define repd(i,a,b) for(int (i) = (a); (i) >= (b); i--)
#define foreach(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); it++)
#define mp make_pair
#define pb push_back
using namespace std;
#define is_digit(c) ((c) >= '0' && (c) <= '9')
#define is_upper(c) ((c) >= 'A' && (c) <= 'Z')
#define is_lower(c) ((c) >= 'a' && (c) <= 'z')
#define readchar() ((char)fgetc(stdin))
#define printchar(c) fputc((c), stdout)
void readline(char *s) {int len=0;char c;for(c=readchar(); c!='\n'; s[len++]=c, c=readchar());s[len]=0;}
void readstr(char *s) {int len=0;char c;for(c=readchar(); c!=' '&&c!='\n'; s[len++]=c, c=readchar());s[len]=0;}
void printstr(const char *s) {int len=strlen(s);rep(i,0,len-1) printchar(s[i]);}
void to_lower(char *s, int L, int R) {rep(i,L,R) if (is_upper(s[i])) s[i]=s[i]-'A'+'a';}
void to_upper(char *s, int L, int R) {rep(i,L,R) if (is_lower(s[i])) s[i]=s[i]-'a'+'A';}
ll readll() {
	char c;ll ans=0, x=1;for (c=readchar(); !is_digit(c)&&c!='-'; c=readchar());
	if (c=='-') x=-1, c=readchar();for (; is_digit(c); ans=ans*10+c-'0', c=readchar());return ans*x;
}
void printll(ll x) {
	int a[25], cnt=0;if (x==0) { printchar('0'); return; }if (x<0) printchar('-'), x=-x;
	for (; x; a[cnt++]=x-x/10*10, x/=10);repd(i,cnt-1,0) printchar(a[i]+'0');
}
#define readint() ((int)readll())
#define printint(x) printll((ll)(x))
int n, a[200005];
int main() {
	n=readint();rep(i,1,n) a[i]=readint();
	ll sum=0;
	rep(i,1,n) sum+=a[i];
	ll x=0, y=sum, ans=1000000000000000ll;
	rep(i,1,n-1) {
		x+=a[i];y-=a[i];
		ans=min(ans,abs(x-y));
	}
	printll(ans);
	return 0;
}


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

int n;

void dfs(string s, char max)
{
    if(s.length() == n)
    {
        cout << s << endl;
    }
    else
    {
        for(char c = 'a'; c <= max; c++)
        {
            dfs(s + c, (c != max) ? max : max + 1);
        }
    }

}

int main()
{
    cin >> n;
    dfs("", 'a');

    return 0;
}


Measured memory_bytes: 1536
# n = 参考書
# m = あるごズム和
# x = すべての理解度
import itertools
n, m, x = map(int, input().split())

books = []
able = [0 for _ in range(m)]

for i in range(n):
    book = list(map(int, input().split()))
    books.append(book)
    for idx, j in enumerate(book[1:]):
        able[idx - 1] += j

if min(able) < x:
    print(-1)
    exit()

ans = float('INF')
for flags in list(itertools.product(range(2), repeat=n)):
    able = [0 for _ in range(m)]
    cost = 0
    for bo, flag in enumerate(flags):
        if flag:
            book = books[bo]
            for idx, j in enumerate(book):
                if idx == 0:
                    cost += j
                else:
                    able[idx - 1] += j

    if min(able) >= x:
        ans = min(cost, ans)

print(ans)



Measured memory_bytes: 9648
#include <bits/stdc++.h>
using ll = long long;
using itn = int;
using namespace std;
int GCD(int a, int b){
    return b ? GCD(b, a%b) : a;
}
int main(){
    ll a,b,c,x,y;
    cin >> a >> b >> c >> x >> y;
    ll res=0;
    //x,yの大小比較 yを大きくする
    if(x>y){
        swap(x,y);
        swap(a,b);
    }
    if(a+b > 2*c){
        res = x*2*c;
    }else{
        res = x*a+x*b;
    }
    y-=x;
    if(b>2*c){
        res += y*2*c;
    }else{
        res += y*b;
    }
    cout << res << endl;

}


Measured memory_bytes: 256
N, Y = map(int, input().split())

max_x = min(Y // 10000, N)
max_y = min(Y // 5000, N)

ans = [-1, -1, -1]
for x in range(max_x + 1):
    for y in range(max_y + 1):
        z = N - x - y
        if z < 0:
            continue
        if 10000 * x + 5000 * y + 1000 * z == Y:
            ans = [x, y, z]
            break
print(*ans)


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

using namespace std;

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
	return 0;
}


Measured memory_bytes: 3624
la =[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input())
print(la[k-1])

Measured memory_bytes: 3060
#include <cstdio>
#include <string>
 
class List
{
    int* data_; //[4000000];
    int begin_;
    int end_;
public:
    List()
    {
        data_ = new int[4000000];
        begin_ = 2000000;
        end_  = 2000000;
    }
    // ~List()
    // {
    //     delete[] data_;
    // }
    void Insert(int X)
    {
        --begin_;
        data_[begin_] = X;
    }
    void Delete(int X)
    {
        int Index = end_;
        for(int i = begin_; i < end_; ++i){
            if(X == data_[i]){
                Index = i;
                break;
            }
        }
        if(Index == end_) return;
        for(int i = Index; i < end_; ++i){
            data_[i] = data_[i+1];
        }
        end_--;
    }
    void DeleteFirst()
    {
        begin_++;
    }
    void DeleteLast()
    {
        end_--;
    }
    void Show()const
    {
        printf("%d", data_[begin_]);
        for(int i = begin_ + 1; i < end_; ++i){
            printf(" %d", data_[i]);
        }
        printf("\n");
    }
};
 
int main()
{
    List list;
    int n, X;
    std::scanf("%d\n", &n);
    char com[1024];
    for(int i = 0; i < n; ++i){
        std::fgets(com, 1024, stdin);
        if(com[6] == 'F'){
            list.DeleteFirst();
        }else
        if(com[6] == 'L'){
            list.DeleteLast();
        }else{
            int v = 0;
            for(int j = 7; com[j] >= '0' && com[j] <= '9'; ++j){
                v = v*10 + (com[j] - '0');
            }
            if(com[0] == 'i'){
                list.Insert(v);
            }else
            if(com[0] == 'd'){
                list.Delete(v);
            }
        }
    }
    list.Show();
    return 0;
}

Measured memory_bytes: 6632
unittest
{
	assert( [ "6" ].parse.expand.solve == 3 );
	assert( [ "2" ].parse.expand.solve == 2 );
	assert( [ "11" ].parse.expand.solve == 5 );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto x = input.front.to!( long );
	return tuple( x );
}

auto solve( long x )
{
	auto t = 0L;
	for( auto d = 0L; d < x; d += t )
	{
		t++;
	}
	return t;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
	int A[100],N,i,j,minj,t,cou=0;
	
	scanf("%d",&N);
	
	for(i=0; i<N; i++){
		scanf("%d",&A[i]);
	}
	
	for(i=0; i<N-1; i++){
		minj=i;
		
		for(j=i; j<N; j++){
			if( A[j]<A[minj] ){
				minj=j;
			}
		}
			t=A[i];
			A[i]=A[minj];
			A[minj]=t;
			
			if(i != minj){cou++;}
			
			}
	
	for(i=0; i<N; i++){
			if(i>0){printf(" ");}
		printf("%d",A[i]);
	}
	printf("\n");
	printf("%d\n",cou);
	
	return 0;
}

Measured memory_bytes: 604
/*
AuThOr GaRyMr
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int n,a[20],b[20],dp[1<<18][55];
int get(int prev,int next){
	return (abs(prev-next)&1)? b[prev]:a[prev];
}
int get_bit(int mask,int pos){
	return mask&(1<<(pos-1));
}
int main(){
	fastio;
	cin>>n;
	rb(i,1,n) cin>>a[i];
	rb(i,1,n) cin>>b[i];
	rep(i,1<<18)
		rep(j,55) dp[i][j]=INF+22;
	rb(mask,1,(1<<n)-1){
		if(__builtin_popcount(mask)==1)
		{
			rb(i,1,n) 
				if(get_bit(mask,i)){
					dp[mask][get(i,1)]=abs(__builtin_popcount(mask)-i);
				}
		}
		else
		rb(i,1,n){
			if(get_bit(mask,i)){
				int prev=mask-(1<<(i-1));
				int cost=0;
				rb(j,i+1,n){
					if(get_bit(prev,j)){
						cost++;
					}
				}
				cost=abs(__builtin_popcount(mask)-(i+cost));
				rb(j,1,get(i,__builtin_popcount(mask))){
					if(dp[prev][j]>INF) continue;
					dp[mask][get(i,__builtin_popcount(mask))]=min(dp[mask][get(i,__builtin_popcount(mask))],dp[prev][j]+cost);
				}
			}
		}
//		string TT="";
//		int save=mask;
//		rb(i,1,n){
//			if(save&1) TT="1"+TT;
//			else TT="0"+TT;
//			save>>=1;
//		}
//		rb(j,1,50){
//			if(dp[mask][j]<INF){
//				cout<<TT<<" "<<j<<" "<<dp[mask][j]<<endl;
//			}
//		}
	}	
	int res=INF+1;
	rb(i,1,54){
		res=min(res,dp[(1<<n)-1][i]);
	}
	cout<<((res>INF)? -1:res)<<endl;
	return 0;
}


Measured memory_bytes: 56576
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 1555,mo=1e9+7;
int power(int a,ll n){
	ll res=1;
	while(n){
		if(n&1)res=1LL*res*a%mo;a=1LL*a*a%mo;n>>=1;
	}
	return res;
}
int cnt,cntblo,cntb,cnted,n,m;ll k;char s[N][N];
void mul(int _a[2][2],int b[2][2],int c[2][2]){
	int a[2][2]={0};
	rep(i,0,1)rep(j,0,1)rep(k,0,1)
		a[i][j]=(a[i][j]+1LL*b[i][k]*c[k][j])%mo;
	rep(i,0,1)rep(j,0,1)_a[i][j]=a[i][j];
}
int main() {
	read(n);read(m);read(k);
	rep(i,1,n)scanf("%s",s[i]+1);
	rep(i,1,n)rep(j,1,m)cnt+=s[i][j]=='#';
	bool b1=0,b2=0;
	rep(i,1,n)b1|=s[i][1]=='#'&&s[i][m]=='#';
	rep(i,1,m)b2|=s[1][i]=='#'&&s[n][i]=='#';
	if(b1&&b2||k<=1){puts("1");return 0;}
	if(!b1&&!b2){printf("%lld\n",power(cnt,k-1));return 0;}
	if(b1){
		static char t[N][N];
		rep(i,1,n)rep(j,1,m)t[j][i]=s[i][j];
		swap(n,m);memcpy(s,t,sizeof(t));
	}
	rep(i,1,n)rep(j,1,m)if(s[i][j]=='#'&&s[i-1][j]!='#'){
	//	printf("[%d %d]\n",i,j);
		int r;for(r=i;r<=n;r++)if(s[r][j]!='#')break;
		//[j,r-1]
		cntblo++;
	}
	rep(i,1,n)rep(j,1,m)if(s[i][j]=='#'&&s[i+1][j]=='#')cntb++;
	rep(i,1,m)cnted+=s[1][i]=='#'&&s[n][i]=='#';
	int a[2][2]={0};a[0][0]=cnt;a[0][1]=mo-cntb;a[1][1]=cnted;
	int ans[2][2]={0};ans[0][0]=ans[1][1]=1;
	k-=2;
	while(k){
		if(k&1)mul(ans,ans,a);
		mul(a,a,a);k>>=1;
	}
	
	cout<<(1LL*ans[0][0]*cntblo+1LL*ans[0][1]*cnted)%mo;
	return 0;
}


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

int n;
vector<int> a;

int main() {
    cin >> n;
    for(int i = 1; i <= n; ++i) {
        int x; cin >> x;
        a.push_back(x - i);
    }
    sort(a.begin(), a.end());
    int b = a[a.size() / 2];
    long long ans = 0;
    for(int i = 0; i < n; ++i) ans += abs(a[i] - b);
    cout << ans;
}


Measured memory_bytes: 1400
#define __USE_MINGW_ANSI_STDIO 0
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <set>
#include <numeric>
#include <bitset>
#include <map>
#include <limits.h>
#include <iomanip>
using namespace std;
typedef unsigned long ul;
typedef pair<ul, ul> P;
const int INF = 1e9;
 
long long gcd(long long x, long long y){
			if (x==0)return y;
      if(y==0)return x;
      if(x<y){
				long long temp = x;
			x = y;
				y = temp;
			}
			long long r = x % y;
				while(r!=0){
					x = y;
					y = r;
				r = x % y;
	    		}
			return y;
	    }

   
int main(){
	double N,K;
	cin >> N >> K;
	double c = 0;
	for(int i= 1;i<=N;i++){
		int tmp = 0;
		for(int j = i;j<K;j=j*2){
			tmp++;
		}
		double c_tmp=1;
		for(int k=0;k<tmp;k++){
			c_tmp=c_tmp*0.5;
		}
		
		
		
		c+=(1/N)*c_tmp;
		
	}
	cout << fixed;
	cout << setprecision(9) << c  << endl;
}


Measured memory_bytes: 384
import numpy as np
N = int(input())
A = list(int(input())for i in range(N))
A.sort()
A = np.array(A)
C1,C2 = [],[]
if N%2 == 1:
    C1 = [-2]*int(N/2-1)+[-1]*2+[2]*int(N/2)
    C2 = [-2]*int(N/2)+[1]*2+[2]*int(N/2-1)
else:
    C1 = [-2]*int(N/2-1)+[-1]+[1]+[2]*int(N/2-1)
    C2 = [-2]*int(N/2-1)+[-1]+[1]+[2]*int(N/2-1)
C1 = np.array(C1)
C2 = np.array(C2)
ans = max(sum(A*C1),sum(A*C2))
print(ans)

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;

constexpr int atcoder_mod = 1e9+7;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}

class ConnectNodeInfo{
	vector<vector<pair<ll,ll>>> graph;
public:
	ConnectNodeInfo(int node_num){
		graph.resize(node_num);
	}
	void AddConnection(ll u,ll v,ll w){
		graph[u].emplace_back(v,w);
		graph[v].emplace_back(u,w);
	}
	vector<pair<ll,ll>>& operator[](ll index){
		return graph[index];
	}
	size_t size(){return graph.size();}
};

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

	int N=in(),M=in();
	ConnectNodeInfo connection(N);
	REP(i,M){
		int u=in(),v=in();
		connection.AddConnection(u-1,v-1,1);
	}
	vector<int> C(N-1);
	iota(ALL(C),1);
	ll sum = 0;
	do{
		bool connect = true;
		int prev = 0;
		for(auto& x:C){
			if(find_if(ALL(connection[prev]),[&](const pair<ll,ll>& lhs){return lhs.first==x;})==connection[prev].end()){
				connect = false;
				break;
			}
			prev = x;
		}
		if(connect) sum++;
	}while(next_permutation(ALL(C)));

	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#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++)
typedef long long ll;

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    bool flag = true;
    int tmp = A;
    while (tmp % B != 0){
        if (tmp % B == C){
            cout << "YES" << endl;
            flag = false;
            break;
        }
        else{
            tmp += A;
        }
    }
    if (flag) {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define thaonguyen main
#define endl '\n'
#define pb push_back

using namespace std;

const int ThaoNguyen = 3e5+5, mod = 998244353, inf = 1e15;

int gt[ThaoNguyen];

namespace THAONGUYEN
{
	string sum1(string a, string b)
	{
		string res="";
		int carry=0, x;
		while(a.length()<b.length())
		{
			a='0'+a;
		}
		while(b.length()<a.length())
		{
			b='0'+b;
		}
		for(int i=a.length()-1; i>=0; i--)
		{
			x=a[i]+b[i]-96;
			res=(char)(x%10+48+carry)+res;
			carry=x/10;
		}
		if(carry)
		{
			res='1'+res;
		}
		return res;
	}
	
	string mul1(string a, int b)
	{
		string res="";
		int carry=0, x;
		for(int i=a.length()-1; i>=0; i--)
		{
			x=(a[i]-48)*b+carry;
			res=(char)(x%10+48)+res;
			carry=x/10;
		}
		if(carry>0)
		{
			res=(char)(carry+48)+res;
		}
		return res;
	}
	
	string mul2(string a, string b)
	{
		string res="";
		for(int i=0; i<a.length(); i++)
		{
			res+='0';
			res=sum1(res, mul1(b, (int)(a[i]-48)));
			cout<<res<<endl;
		}
		return res;
	}
	
	void prep()
	{
		gt[1]=1;
		for(int i=2; i<ThaoNguyen-1; i++)
		{
			gt[i]=(gt[i-1]*i)%mod;
		}
	}
	
	int binpow(int n, int k, int mod)
	{
		int m = n%mod, i=1, ans=1;
		{
			while(i<=k)
			{
				int temp=i&k;
				if(temp>0)
				{
					ans=(ans*m)%mod;
				}
				i<<=1, m=(m*m)%mod;
			}
		}
		return ans;
	}
	
	int rev_mod(int n, int mod)
	{
		return binpow(n, mod-2, mod);
	}
	
	int C(int k, int n)
	{
		if(k==0||k==n)
		{
			return 1;
		}
		else
		{
			return ((((gt[n]%mod)*rev_mod(gt[k], mod))%mod)*rev_mod(gt[n-k], mod))%mod;
		}
	}
}

using namespace THAONGUYEN;

int n, a, b, k;
signed thaonguyen()
{
	ios::sync_with_stdio(false), cin.tie(0);
	prep();
	cin>>n>>a>>b>>k;
	int ans=0;
	for(int i=0; i<=n; i++)
	{
		if((k-i*a)%b==0)
		{
			int cac=(k-i*a)/b;
			if(cac>n||cac<0)
			{
				continue;
			}
			ans+=(C(cac, n)*C(i, n))%998244353;
			ans%=998244353;
//			int mat=cac+i-n;
//			cac-=mat;
//			int j=i-mat;
//			ans+=(((C(cac, n)*C(j, n-cac))%998244353)*C(mat, n-cac-j))%998244353;
		}
	}
	//tai sao minh lai sai dwaidhwasdwa
	cout<<ans%998244353;
	return 0;
}

Measured memory_bytes: 2560
package main

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

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	for n > 0 {
		n -= 1000
	}
	fmt.Fprintln(writer, -n)
}


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

using Int = long long int;
using UInt = unsigned long long int;

Int Ceil(Int a, Int b) {
    if (a % b == 0) {
        return a / b;
    } else {
        return a / b + 1;
    }
}

int main(void) {
    Int n;
    cin >> n;
    Int rt, ra;
    cin >> rt >> ra;
 
    Int t, a;
    for (Int i = 1; i < n; ++i) {
        cin >> t >> a;
        Int times = max(Ceil(rt, t), Ceil(ra, a));
        rt = t * times;
        ra = a * times;
    }
    cout << rt + ra << endl;
    return 0;
}


Measured memory_bytes: 3632
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <string.h>
using namespace std;

#define ISEQ(c) (c).begin(), (c).end()
typedef long long ll;

int main() {
  while (true) {
    int n;
    cin >> n;
    if (!n) break;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
      cin >> a[i];
    }
    int res = -1000000000;
    for (int i = 0; i < n; i++) {
      int sum = 0;
      for (int j = i; j < n; j++) {
	sum += a[j];
	res = max(res, sum);
      }
    }
    cout << res << endl;
  }
}

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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { return a * b / GCD(a, b); }

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

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

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

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  int n;string s;
  cin>>n>>s;
  rep(i,s.size()){
    if(s[i]+n>90)s[i]=s[i]+n-26;
    else s[i]=s[i]+n;
  }
  cout<<s<<endl;
  
}


Measured memory_bytes: 256
n,m=map(int,input().split())
ac=[[0,False] for i in range(n)]
for i in range(m):
    p=list(input().split(" "))
    x=p[0]
    y=p[1]
    if ac[int(x)-1][1]==True:
        pass
    else:
        if y=="WA":
            ac[int(x)-1][0]+=1
        elif y=="AC":
            ac[int(x)-1][1]=True
counter=0
acc=0
for i in range(n):
    if ac[i][1]:
        acc+=1
        counter+=ac[i][0]
print(acc,counter)

Measured memory_bytes: 13172
#include<cstdio>
using namespace std;
int n;
long long m,a[100005],qzh[100005],ans;
struct sd{int num,c;}cnt[50000000];
int main()
{
	scanf("%d%lld",&n,&m);for(int i=0;i<=49999999;++i) cnt[i].num=cnt[i].c=0;
	for(int i=1;i<=n;++i) scanf("%lld",&a[i]);
	for(int i=1;i<=n;++i) qzh[i]=qzh[i-1]+a[i];
	for(int i=0;i<=n;++i) {
		int now=(int)(qzh[i]%m);
		int modal=now%50000000;
		while(cnt[modal].num&&cnt[modal].num!=now) {++modal;if(modal==50000000) modal=0;}
		if(cnt[modal].num) cnt[modal].c++;
		else {cnt[modal].num=now;cnt[modal].c++;}
	}
	for(int i=0;i<=49999999;++i) {
		long long nnn=cnt[i].c;
		ans+=nnn*(nnn-(long long)1)/(long long)2;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 392320
n = int(input())
h = list(map(int, input().split()))
            
def bubble(inputlist):
    for i in range(len(inputlist)-1):
        if inputlist[i] > inputlist[-1]:
            return False
    return True
cnt = 0
for i in range(n):
    is_candidate = True
    for j in range(i):
        if h[j] > h[i]:
            is_candidate = False
            break
    if is_candidate:
        cnt+=1
print(cnt)

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


signed main() {
    int n;
    cin >> n;
    vector<vi> a(2, vi(n));
    rep(i, 2){
        rep(j, n){
            cin >> a[i][j];
        }
    }
    ll ans = 0;
    /* cout << "--------" << endl; */

    rep(i, n){
        ll tmp = 0;
        rep(j, i+1){
            tmp += a[0][j];
            /* cout << a[0][j] << " "; */
        }
        repa(j, i, n){
            tmp += a[1][j];
            /* cout << a[1][j] << " "; */
        }
        /* cout << "\n"; */
        ans = max(ans, tmp);
    }
    cout << ans << endl;

}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)x.size())
#define FOR(i,a,b) for (int i=a;i<=b;++i)
#define FORD(i,a,b) for (int i=a;i>=b;--i)
using namespace std;
typedef long long LL;
typedef pair<int,int> pa;
typedef vector<int> vec;
void getint(int &v){
    char ch,fu=0;
    for(ch='*'; (ch<'0'||ch>'9')&&ch!='-'; ch=getchar());
    if(ch=='-') fu=1, ch=getchar();
    for(v=0; ch>='0'&&ch<='9'; ch=getchar()) v=v*10+ch-'0';
    if(fu) v=-v;
}
bool u[500010];
LL ans,t;
int l[500010],now,n,rp,r[500010],p[500010],q[500010],P,Q;
bool cmp(int A,int B){
	return (l[A]>l[B]);
}
bool cmp1(int A,int B){
	return (r[A]<r[B]);
}
void RF(){
	FOR(i,1,n) p[i]=i;
	sort(p+1,p+n+1,cmp);
	FOR(i,1,n) q[i]=i;
	sort(q+1,q+n+1,cmp1);
	//right first
	P=Q=1;
	now=0;
	t=0;
	memset(u,0,sizeof(u));
	for (rp=1;;++rp){
		while (P<=n && u[p[P]]) ++P;
		while (Q<=n && u[q[Q]]) ++Q;
		if (rp&1){
			if (P>n || l[p[P]]<=now){
				t+=abs(now);
				break;
			}
			u[p[P]]=1;
			t+=l[p[P]]-now;
			now=l[p[P]];
		}
		else{
			if (Q>n || r[q[Q]]>=now){
				t+=abs(now);
				break;
			}
			u[q[Q]]=1;
			t+=now-r[q[Q]];
			now=r[q[Q]];
		}
	}
	ans=max(ans,t);
}
int main(){
	cin>>n;
	FOR(i,1,n) getint(l[i]),getint(r[i]);
	ans=0;
	RF();
	FOR(i,1,n) swap(l[i],r[i]),l[i]=-l[i],r[i]=-r[i];
	RF();
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 7040
/*

Parallelism(https://onlinejudge.u-aizu.ac.jp/problems/0021)
前

*/
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <complex>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <iomanip>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second
#define Pqaz(T) priority_queue<T,vector<T>,greater<T>>
#define Pqza(T) priority_queue<T>
#define put(x) cout << x;
#define putsp(x) cout << x << ' ';
#define putln(x) cout << x << endl;
#define ENJYU std::ios::sync_with_stdio(false);std::cin.tie(0);

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef complex<double> comp;
typedef vector <int> vec;
typedef vector <ll> vecll;
typedef vector <double> vecd;
typedef vector <vec> mat;
typedef vector <vecll> matll;
typedef vector <vecd> matd;

//vector の中身を出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

const int MAX = 200000;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const ll INFL = 1e18;
const int MOD = 1000000007;

int dx4[4]={1,0,-1,0};
int dy4[4]={0,1,0,-1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

//********************************template END****************************************//

//外積を計算する関数
double gaiseki(comp a, comp b)
{
	return (conj(a)*b).imag();
}

void solve(void){

	int N;
	cin >> N;
	while(N--)
	{

		double xs[4], ys[4];
		rep(4, i)
		{
			cin >> xs[i] >> ys[i];
		}

		vector <comp> ps(4);
		rep(4, i)
		{
			ps[i] = comp(xs[i], ys[i]);
		}

		//直線AB,CDに対応するベクトルl,m
		comp l = ps[1]-ps[0], m = ps[3]-ps[2], r = polar(1., PI/360);

		l *= r, m *= r;

		cout << (abs(gaiseki(l, m)) < EPS ? "YES" : "NO") << endl;

	}

}

int main(void){
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}



Measured memory_bytes: 3180
#include <bits/stdc++.h>
using namespace std;
long N;
void solve()
{
    long ans=2000000001;
    while(N--)
    {
        long A,B;
        cin>>A>>B;
        ans=ans<A+B?ans:A+B;
    }
    cout<<ans<<endl;
}
int main()
{
    while(cin>>N)
        solve();
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static int gcd(int a, int b){
    int x = a;
    int y = b;
    while (y != 0){
      int c = x;
      x = y;
      y = c % y;
    }
    return x;
  }
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();
    int ga = gcd(A, B);
    if (C != 0){
      if (C % ga == 0){
        System.out.println("YES");
      }
      else{
        System.out.println("NO");
      }
    }
    else{
      System.out.println("YES");
    }
  }
}


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

using namespace std;

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

	int n;
	cin >> n;

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

	sort(a.begin(), a.end());
	double ans = (a[0] + a[1]) / 2.0;

	for(int i = 2; i < n; i++) {
		ans = (ans + a[i]) / 2.0;
	}

	cout << fixed << setprecision(15) << ans;
	
	return 0;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main(int argc, char *argv[]) {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    int N; cin >> N;
    vector<int> A(N+1), B(N);
    rep(i, N+1) cin >> A[i];
    rep(i, N) cin >> B[i];

    ll ans = 0;
    rep(i, N) rep(j, 2) {
        int tmp = min(A[i+j], B[i]);
        ans += tmp;
        A[i+j] -= tmp;
        B[i] -= tmp;
        if (B[i] <= 0) break;
    }

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

Measured memory_bytes: 1024
#include<iostream>
#include<set>
using namespace std;
int main()
{
    //set<int>a;
    int n;
    cin>>n;
    int a[n];
    for(int i=0; i<n; i++){
        cin>>a[i];
    }
    int m;
    cin>>m;
    set<int>b;
    for(int i=0; i<m; i++){
        int x;
        cin>>x;
        b.insert(x);
    }
    for(int i=0; i<n; i++){
        if(b.find(a[i])==b.end())
            cout<<a[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 13248
#include<map>
#include<queue>
#include<cmath>
#include<ctime>
#include<stack>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
inline int read(){
	int ans=0,fh=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-') fh=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9')
		ans=ans*10+ch-'0',ch=getchar();
	return ans*fh;
}
const int maxn=1e5+100;
int n,k,h[maxn],f[maxn];
int main(){
//	freopen(".in","r",stdin);
	n=read(),k=read();
	for(int i=1;i<=n;i++) h[i]=read();
	for(int i=2;i<=n;i++){
		f[i]=0x7fffffff;
		for(int j=i-1;j>=max(i-k,1);j--)
			f[i]=min(f[i],f[j]+abs(h[i]-h[j]));
	}
	printf("%d\n",f[n]);
	return 0;
}








Measured memory_bytes: 896
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int n,a,b,c,d,zhe,fu;
int main(){
	scanf("%d%d%d%d%d",&n,&a,&b,&c,&d);int tmp=a;
	for(int i=2;i<=n;i++){
		if(abs(tmp+d-b)<=abs(tmp-d-b))tmp+=d,zhe++;
		else tmp-=d,fu++;
	}
	int cha=((d-c)==0)?(tmp-b!=0?0x3f3f3f3f:0):abs(tmp-b)/(d-c)+(abs(tmp-b)%(d-c)!=0);
	if(tmp>=b)printf("%s\n",cha<=zhe?"YES":"NO");
	else printf("%s\n",cha<=fu?"YES":"NO");
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main(){
  long N,M;cin>>N>>M;
  vector<pair<long,long>>facts;
  long p=2;
  while(M>1){
    if(M%p==0){
      long t=0;
      while(M%p==0){t++;M/=p;}
      facts.push_back(pair<long,long>(p,t));
    }
    p++;
  }
  COMinit(); long long ans=1;
  for(auto f:facts){
    ans=(ans*COM(f.second+N-1,N-1))%MOD;
  }
  cout<<ans%MOD;
}



Measured memory_bytes: 12160
import java.util.Scanner;

public class Main{
    public static void main(String args[]){
        Scanner input = new Scanner(System.in);
        int a = input.nextInt();
        int count = 0;
        for(int i = 0; i <a; i++ ){
            if(isPrime(input.nextInt())){
                count++;
            }//if
        }//for
        System.out.println(count);
    }//main
    
     private static boolean isPrime(int a) {
        if(a < 2) {
            return false;
        }//if 
        if(a == 2) {
            return true;
        }//if
        if(a % 2 == 0) {
            return false;
        }//if
        
        double sqrt = Math.sqrt(a);
        for (int i = 3; i <= sqrt; i += 2) {
            if (a % i == 0) {
                return false;
            }//if
        }//for
        return true;
    }//isPrime
}//main


Measured memory_bytes: 41104
#include<iostream>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include <algorithm>
#include <set>
#include<math.h>
#include<cmath>
#include<vector>
#include<map>
#include<random>
#include<sstream>
using namespace std;

int main(){
    int n;cin >> n ;
    int t,h,o;
    t = n/100;
    h = n%100/10;
    o = n%10;
    //cout << t << h <<  o << endl;
    if(t == 1)t = 9;
    else if(t==9)t = 1;

    if(h == 1)h = 9;
    else if(h==9)h = 1;
 
    if(o == 1)o = 9;
    else if(o==9)o = 1;
    cout << t*100 + h*10 + o << endl;
    

}


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-6;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

const int64 mod = 1e9+7;

int main(void){
	int32 n, m, p;
	while(cin >> n >> m >> p && (n || m || p)){
		vector<int32> x(n);
		int32 sum = 0;
		REP(i, n){
			cin >> x[i];
			sum += x[i];
		}
		int32 res = 0;
		if(x[m-1] != 0){
			sum = (sum*100-sum*p);
			while(res*x[m-1] <= sum) res++;
			res--;
		}
		else res = 0;
		cout << res << endl;
	}
}


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

int main() {
	int n, m;
	scanf("%d %d", &n, &m);
	vector<int> h(n);
	for(int &x : h) scanf("%d", &x);
	vector<vector<int>> g(n);
	for(int i = 0; i < m; i++) {
		int a, b;
		scanf("%d %d", &a, &b);
		a--, b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	int ans = 0;
	for(int i = 0; i < n; i++) {
		bool good = true;
		for(int v : g[i]) {
			if(h[v] >= h[i]) {
				good = false;
			}
		}
		ans += good;
	}
	printf("%d\n", ans);
}


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

int main(){
    int H,N;
    cin >> H >> N;
    vector<int> A(N);
    int sum = 0;
    for(int i=0;i<N;i++){
        cin >> A.at(i);
        sum += A.at(i);
    }
    if(sum>=H){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

    // int max = 0;
    // int tmp;
    // int score;
    // for(int j=1;j<N;j++){
    //     tmp = 
    // }
}


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

#define rep(X,N) for(ll X = 0LL; X < (N); X++)
#define PI (acos(-1.0))
#define MODN 1000000007
#define MODN2 998244353
#define ALL(V) (V).begin(),(V).end()
#define INT_MAX_HALF (INT_MAX / 2)
#define EPS (1e-10)

using namespace std;
typedef long long ll;

int main(){

    string s;
    cin >> s;

    int size = s.size();

    if(size == 1){
        cout << 1 << endl;
    }else if(size == 2){
        if(s[0] == s[1]){
            cout << 1 << endl;
        }else{
            cout << 2 << endl;
        }
    }else{

        string prevs = s.substr(0, 1);
        int count = 0;
        int i = 1;

        while(i < size){
            if(i == size - 2){
                if(prevs.size() == 1){
                    if(s[i - 1] != s[i] && s[i] != s[i + 1]){
                        count = count + 2;
                        break;
                    }else{
                        count++;
                        break;
                    }
                }else{
                    if(s[i] == s[i + 1]){
                        count++;
                        break;
                    }else{
                        count = count + 2;
                        break;
                    }
                }
            }else{

                for(int j = 1; i + j - 1 < size; j++){
                    string tmps = s.substr(i, j);

                    if(prevs != tmps){
                        count++;
                        prevs = tmps;

                        i += j;
                        break;
                    }
                }
            }
        }
        cout << count + 1 << endl;
    }

    return 0;
}


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

#define PI 3.14159265359
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
ll gcd(ll x,ll y){
    if(x%y==0)return y;
    return gcd(y,x%y);
}
ll LCM(int a, int b){
    return a*b/gcd(a,b);
}

int main(void)
{
    int n;
    cin>>n;
    vector<ll> a(n);
    rep(i,0,n){
        cin>>a[i];
    }
    if(find(a.begin(),a.end(),0)!=a.end()) {
        cout<<0<<endl;
        return 0;
    }

    ll sum=1;
    rep(i,0,n){
        if(a[i] <= 1000000000000000000/sum){
            sum*=a[i];
        }else{
            cout<<-1<<endl;
            return 0;
        }
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 3976
#include <iostream>
#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#include <algorithm>
#include <bits/stdc++.h>
#define MOD 1000000000000000000
#define ll long long
#define mm(arr) memset(arr, 1, sizeof(arr))
#define scanArray(a,n) for(ll i = 0; i < n; i++){cin >> a[i];}
using namespace std;
void prime(ll n1);
int main(){
    FAST
    ll a,b; cin >> a >> b;
    ll n1 = __gcd(a,b);
    prime(n1);
    return 0;
}
void prime(ll n1){
    map<ll,ll>found;
    ll cnt=0;
    for(ll i=2; i*i<=n1; i++){
        while(n1%i == 0){
            n1/=i;
            if(found[i]>0){
                continue;
            }
            found[i]++;
            cnt++;
        }
    }
    if(n1!=1){
        cout << cnt+2 << endl;
    }
    else{
        cout << cnt+1 << endl;
    }
}


Measured memory_bytes: 3608
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
## dp ##
def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]
## math ##
def to_bin(x: int) -> str: return format(x,'b') # rev => int(res, 2)
def to_oct(x: int) -> str: return format(x,'o') # rev => int(res, 8)
def to_hex(x: int) -> str: return format(x,'x') # rev => int(res, 16)
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(n=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(n+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, n+1, i): is_prime[j] = False
    return [i for i in range(n+1) if is_prime[i]]
def prime_factor(n):
    """Return a list of prime factorization numbers of n"""
    res = []
    for i in range(2,int(n**0.5)+1):
        while n%i==0: res.append(i); n //= i
    if n != 1: res.append(n)
    return res
## const ##
MOD=10**9+7
## libs ##
import itertools as it
import functools as ft
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left
from math import cos, radians
#======================================================#
def main():
    a, b, h, m = MII()
    hd = h*30 + 30*(m/60)
    md = 6*m
    d = max(hd, md) - min(hd, md)
    if d > 180:
        d = 360 - d
    cc = a**2 + b**2 - 2*a*b*cos(radians(d))
    print(cc**(1/2))

if __name__ == '__main__':
    main()

Measured memory_bytes: 9932
h, w = map(int, input().split())
a = [list(input()) for _ in range(h)]
d = (-1, 0), (1, 0), (0, -1), (0, 1)
p = [(i, j) for i in range(h) for j in range(w) if a[i][j] == '#']

def f():
    for i, j in p:
        for di, dj in d:
            di += i
            dj += j
            if 0 <= di < h and 0 <= dj < w and a[di][dj] == '.':
                a[di][dj] = '#'
                yield di, dj

n = h * w - len(p)
r = 0
while n:
    r += 1
    p = list(f())
    n -= len(p)
print(r)


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

typedef long long int ll;
ll n;

bool is753(ll x) {
  bool has3 = false, has5 = false, has7 = false;
  while(x > 0 && !(has3 && has5 && has7)) {
    int r = x % 10;
    x /= 10;

    has3 |= r == 3;
    has5 |= r == 5;
    has7 |= r == 7;
  }
  return has3 && has5 && has7;
}

int dfs(ll x) {
  if(x > n) return 0;

  int ret = 0;
  if(is753(x)) ++ret;

  ret += dfs(10 * x + 3);
  ret += dfs(10 * x + 5);
  ret += dfs(10 * x + 7);

  return ret;
}

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

  std::cout << dfs(0) << std::endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
const int DN=105;
int n,f,a[DN],cnt;
int main()
{
    cin>>n>>f;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    sort(a+1,a+n+1);
    for(int i=1;i<=n;i++)
        if(a[i]<=f)
        {
            f-=a[i];
            cnt++;
            if(f!=0&&i==n)
                cnt--;
        }
    cout<<cnt;
}


Measured memory_bytes: 256
X,Y=map(int,input().split())
list_1=[1,3,5,7,8,10,12]
list_2=[4,6,9,11]
list_3=[2]
if list_1.count(X)==list_1.count(Y)==1 or list_2.count(X)==list_2.count(Y)==1:
    print ('Yes')
else:
    print ('No')

Measured memory_bytes: 2940
n=int(input())
a=list(map(int, input().split()))

count=0
right=0
m=0
for left in range(n):
    while right<n and m^a[right]==m+a[right]:
        m+=a[right]
        right+=1
    count+=right-left
    m-=a[left]
print(count)

Measured memory_bytes: 25916
# A, A?C
# AtCoder 社は、毎週土曜日にコンテストを開催しています。
# コンテストには ABC と ARC の2つの種類があり、毎週どちらか一方が開催されます。
# ABC が開催された次の週には ARC が開催され、ARC が行われた次の週には ABC が開催されます。
# 先週開催されたコンテストを表す文字列Sが与えられるので、今週開催されるコンテストを表す文字列を出力してください。

# Sは'またはABC''ARC'

S = input()

# 今週開催されるコンテストを表す文字列を出力せよ。

if S == 'ABC':
    print('ARC')
else:
    print('ABC')

Measured memory_bytes: 9040
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
using namespace std; using ll = long long; using ld = long double;  using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
using vs = vector<string>; using tll = tuple<ll, ll, ll>; using vtll = vector<tll>;
const ld PI = 3.1415926535897932;
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define co(i) cout << i << endl;
#define co2(i,j) cout << i << " " << j << endl;
#define co3(i) cout << i << " ";
#define po(i) cout << i.first << " " << i.second << endl;
void in() {}
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop, bitSearch, bitList, nod, digitDP, treeDP//
//gcdlcm, isPrime, eratos, primeFactorize, Npow, combination, divisor, modinv, doubling//
//dfs, bfs, dijkstra, WarshallFloyd, BellmanFord, UnionFind, Kruskal, RMQ, LCA//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R, Q;
ll MOD = 1000000007, INF = 1LL << 60, ans = 0, z = 0, o = 1;
vll flag, D; vll path;
//***********//
int main() {
	ll A, B, C, D;
	cin >> A >> B >> C >> D;
	ll X = C - A, Y = D - B;
	MOD = 998244353;
	vector<vll> dp(X + 2,vll(Y+2,vl(2,0)));
	//i番目まで追加出来てて、そのうちX方向の追加が〇回
	dp[0][0][1] = 1;
	for (i = 0; i <= X; i++) {
		for (j = 0; j <= Y; j++) {
			(dp[i][j + 1][1] += dp[i][j][0] + dp[i][j][1] * (i+A)) %= MOD;
			(dp[i + 1][j][0] += dp[i][j][0] * (j+B) + dp[i][j][1] * (j+B)) %= MOD;
		}
	}
	co((dp[X][Y][0]+dp[X][Y][1]) % MOD);
}

Measured memory_bytes: 496076
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <cassert>
#include <cstring>
#include <queue>
#include <cstdio>
#include <cmath>
#include <sstream>
#include <bitset>
#include <ctime>
 
using namespace std;
 
typedef long long Long;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int, int> PII;


int main(int argc, char *argv[]) {
	
	int N;
	cin >> N;
	int mi = 100000000;
	for (int i = 1; i < N; ++i) {
		int A = i;
		int B = N - A;
		stringstream st;
		st << A << B;
		int s = 0;
		for (char c : st.str()) {
			s += c - '0';
		}
		mi = min(mi, s);
	}
	cout << mi << endl;
	
}


Measured memory_bytes: 256