akhauriyash/Code-Regression huggingface dataset:
use std::io::*;//Not mine.
use std::str::FromStr;
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}
fn main(){
    let n = read();
    let mut minimum = 1000000;
    let mut k:Vec<i32> = (0..n).map(|_| read()).collect();
    for (i, &l) in k.iter().enumerate() {
        let mut cnt = 0;
        let mut ll = l;
        while(ll % 2 == 0){
            ll /= 2;
            cnt += 1;
        }
        minimum = std::cmp::min(cnt,minimum);
    }
    println!("{}",minimum);
}


Measured memory_bytes: 4352
import sys


input = sys.stdin.readline
n, p = map(int, input().split())
if n == 1:
    ans = p
elif n > 10**6:
    ans = 1
else:
    ans = 1
    for i in range(2, 10**6+1):
        check = i**n
        if check > p:
            break
        elif p % check == 0:
            ans = i
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF INT_MAX/3
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define CLR(a) memset(a,0,sizeof(a))

typedef long long int ll;

using namespace std;

int main(){
    while(true){
	int n;
	cin >> n;
	vector< vector<char> > map(n,vector<char>(n,'.'));
	REP(i,n){
	    REP(j,n){
		cin >> map[i][j];
	    }
	}
	if(n == 0) break;
	bool flg = true;
	int high,low,middle;
	high = n+1;
	low = 0;
	middle = (high+low)/2;

	while(high-low>1){
	    REP(j,n-middle+1){
		REP(k,n-middle+1){
		    flg = true;
		    REP(l,middle){
			REP(m,middle){
			    if(map[j+l][k+m] == '*'){
				flg = false;
				k = k + m;
				if(k >= n-middle+1) break;
				break;
			    }
			}
			if(!flg) break;
		    }
		    if(flg){
			break;
		    }
		}
		if(flg) break;
	    }
	    if(flg){
		low = middle;
	    }else{
		high = middle;
	    }
	    middle = (high+low)/2;
	}
	cout << middle << endl;
    }
    return 0;
}

Measured memory_bytes: 2128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll> 
#define P pair<ll,ll>
#define ALL(a) (a).begin(),(a).end()
#define YESNO(i) if((i)) puts("YES");else puts("NO");
#define YesNo(i) if((i)) puts("Yes");else puts("No");
#define yesno(i) if((i)) puts("yes");else puts("no");
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll a,b;cin>>a>>b;
  if((a*b)%2==0) puts("Even");else puts("Odd");
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define ll long long

int main(){
	int h,n;
	cin>>h>>n;
	int sum=0;
	for(int i=0;i<n;i++){
		int t;
		cin>>t;
		sum+=t;
		if(sum>=h) {
			cout<<"Yes";
			return 0;
		}
	}	
	cout<<"No";
	return 0;
}

Measured memory_bytes: 3092
import java.util.Scanner;

public class Main {

	void main() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int [n];
		
		for(int i = 0; i <a.length; i++) {
			a[i] = sc.nextInt();
		}
		System.out.print(a[a.length-1]);
		for(int i = a.length-2; i >=0; i--) {
			System.out.print(" " + a[i]);
		}
		System.out.println();
	}
	
	public static void main(String[] args) {
		new Main(). main();
	}

}



Measured memory_bytes: 26532
#include <bits/stdc++.h>
using namespace std;
int sum(int N){
int sum = 0;
while(N > 0){
sum += N%10;
N /=10;}
return sum;}
int main() {
int  N, A, B;
int total = 0;
cin >> N >> A >> B;
for(int i = 0; i <= N; i++){
if(sum(i) >= A && sum(i) <= B){
total += i;}}
cout << total << endl;}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <math.h>

#define Ft(x)			((x) * (x))

#define R	(0)
#define G	(1)
#define B	(2)

typedef struct {
	int color[3];
	char c_name[8];
} INDEX;

int main(void)
{
	INDEX table[8];
	int in[3];
	int i, j;
	int tmp;
	double dk;
	char flag;
	
	strcpy(table[0].c_name, "black");
	strcpy(table[1].c_name, "blue");
	strcpy(table[2].c_name, "lime");
	strcpy(table[3].c_name, "aqua");
	strcpy(table[4].c_name, "red");
	strcpy(table[5].c_name, "fuchsia");
	strcpy(table[6].c_name, "yellow");
	strcpy(table[7].c_name, "white");
	
	for (i = 0; i <= 7; i++){
		for (j = 0; j < 3; j++){
			table[i].color[2 - j] = (i & (1 << j)) ? 0xFF : 0;
		}
	}
	
	while (1){
		scanf(" %c", &flag);
		if (flag == '0'){
			break;
		}
		
		scanf("%2x%2x%2x", &in[R], &in[G], &in[B]);
		
		dk = sqrt(Ft(in[R] - table[0].color[R]) + Ft(in[G] - table[0].color[G]) + Ft(in[B] - table[0].color[B]));
		tmp = 0;
		
		for (i = 1; i < 8; i++){
			if (dk > sqrt(Ft(in[R] - table[i].color[R]) + Ft(in[G] - table[i].color[G]) + Ft(in[B] - table[i].color[B]))){
				dk = sqrt(Ft(in[R] - table[i].color[R]) + Ft(in[G] - table[i].color[G]) + Ft(in[B] - table[i].color[B]));
				tmp = i;
			}
		}
		
		printf("%s\n", table[tmp].c_name);
	}
	
	return (0);
}

Measured memory_bytes: 0
#include <iostream>
#include <cstring>
#include <vector>
#include <string>

using namespace std;

vector<int>res;
int main(int argc, char *argv[]) {
    int n,k,tmp;
    int ans = 1;
    cin>>n>>k;
    for(int i = 0 ; i < n ; ++i){
        cin>>tmp;
        res.push_back(tmp);
    }
    int mins = res[0];
    int maxs = 0;
    for(int i = 1 ; i < n ; ++i){
        if(maxs==res[i]-mins){
            ans++;
        }
        if(maxs<res[i]-mins){
            maxs = res[i]-mins;
            ans = 1;
        }
        mins = min(res[i],mins);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 892
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <stack>

using namespace std;

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


Measured memory_bytes: 256
map{/ /?vec($$I,$`-1,8)=$'+49:$I--for<>;$i=$f=0;$t=$_;$i--,/2/&&(~$t&$$i)=~/[^\0]/&&$f++for/./g;$\+=$-=!$f*y/2//-$\}glob'{1,2}'x<>;print

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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" ";
#define LOGE if(DEBUG)cout<<endl;

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

void func(long long N, long long M, std::vector<long long> a, std::vector<long long> b){

    vector<pair<lli,lli>> v;
    REP(i,0,M){
        v.push_back({b[i],a[i]});
    }
    sort(v.begin(),v.end());

    set<lli> t;

    lli now=-INF;
    lli ans=0;
    REP(i,0,M){
        if(now<=v[i].second){
            now=v[i].first;
            ans++;
        }
    }
    cout<<ans<<endl;

}

int main(){
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> a(M);
    std::vector<long long> b(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&a[i]);
        scanf("%lld",&b[i]);
    }
    func(N, M, std::move(a), std::move(b));
    return 0;
}


Measured memory_bytes: 3956
X = int(input())
happy = 0

while X > 0:
    if X - 500 >= 0:
        happy += 1000 * (X // 500)
        X -= 500 * (X // 500)
    elif X - 5 >= 0:
        happy += 5 * (X // 5)
        X -= 5 * (X // 5)
    elif X - 1 >= 0:
        X -= 1

print(happy)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound

ll modpow(ll a,ll n,ll mod){
  ll res=1;
  while(n){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a,ll mod){
  return modpow(a,mod-2,mod);
}

int main(){
  ll N;
  cin>>N;
  VL A(N);
  rep(i,N) cin>>A[i];
  VL B(N);
  rep(i,N) B[i]=A[i];
  vector<map<ll,int>> P(N);
  ll mod=1e9+7;
  VI PP;
  PP.pb(2);
  rep(i,1000){
    int F=1;
    rep(j,PP.size()){
      if((i+3)%PP[j]==0){
        F=0;
        break;
      }
    }
    if(F) PP.pb(i+3);
  }
  rep(i,N){
    rep(q,20){
      rep(j,PP.size()){
        if(A[i]%PP[j]==0){
          A[i]/=PP[j];
          P[i][PP[j]]++;
          break;
        }
      }
    }
    if(A[i]>1) P[i][A[i]]++;
  }
  map<ll,int> M;
  rep(i,N){
    auto itr=P[i].begin();
    rep(j,P[i].size()){
      M[itr->first]=max(M[itr->first],itr->second);
      itr++;
    }
  }
  ll pro=1;
  auto itr=M.begin();
  rep(i,M.size()){
    ll Y=itr->first;
    ll Z=itr->second;
    pro=pro*modpow(Y,Z,mod)%mod;
    itr++;
  }
  ll ans=0;
  rep(i,N){
    ll tmp=pro*modinv(B[i],mod)%mod;
    ans=(ans+tmp)%mod;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3968
import sys
import math
import heapq
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def FLIST(n):
    res = [1]
    for i in range(1, n+1): res.append(res[i-1]*i%DVSR)
    return res

N = II()
res = 0
for i in range(1, N+1):
    n = N//i
    res += i*n*(n+1)//2

print(res)


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

int main()
{
    int n; cin >> n;
    for (int i = 1; i <= n; i++) {
        int x = i;
        if (i % 3 == 0) {
            printf(" %d", i);
            continue;
        }
        while (x > 0) {
            if (x % 10 == 3) {
                printf(" %d", i);
                break;
            }
            x /= 10;
        }
    }
    putchar('\n');
}



Measured memory_bytes: 3236
#include <stdio.h>

int main(void) {
	int H= 1,W = 1;
	int i=0,j=0;
	

	while(H != 0 && W != 0){
			scanf("%d",&H);
			scanf("%d",&W);
			if(H == 0 && W == 0){
				break;
			}

		for(i=0;i<H;i++){
			for(j=0;j<W;j++){
				printf("#");		
			}
			printf("\n");
		}
		printf("\n");
	}
	

	return 0;
}

Measured memory_bytes: 572
#include <iostream>

using namespace std;
int main() {
	long long a, b, k,tmp,t=0;
	cin >> a >> b >> k;

	if (a >= k) {
		a = a - k;
		cout << a << " " << b;
	}
	else if (a + b >= k) {
		b = b - (k-a);
		a = 0;
		cout << a << " " << b;
	}
	else {
		a = 0;
		b = 0;
		cout << a << " " << b;
	}
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-


# 最大公約数
def gcd(a, b):
  while b != 0:
    a, b = b, a % b

  return a


# 素因数分解
def factorization(n):
  arr = []
  temp = n

  for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
    if temp % i == 0:
      cnt = 0
      while temp % i == 0:
        cnt += 1
        temp //= i
      arr.append([i, cnt])

  if temp != 1:
    arr.append([temp, 1])

  if arr == []:
    arr.append([n, 1])

  return arr


def main():
  a, b = map(int, input().split())
  g = gcd(a, b)
  fs = [v for v, _ in factorization(g) if v != 1]
  print(len(fs) + 1)


if __name__ == '__main__':
  main()


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

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

Measured memory_bytes: 640
#include <iostream>
#define MAXN 100
using namespace std;
int main(){
	int N, M;
	char map[MAXN][MAXN+1];
	int ans[MAXN][MAXN];
	cin >> N >> M;
	for(int i=0; i<N; i++)
		cin >> map[i];
	ans[0][0] = (map[0][0] == '#');
	for(int i=1; i<N; i++)
		ans[i][0] = ans[i-1][0] + (map[i][0] != map[i-1][0]);
	for(int i=1; i<M; i++)
		ans[0][i] = ans[0][i-1] + (map[0][i] != map[0][i-1]);
	for(int i=1; i<N; i++)
		for(int j=1; j<M; j++)
			ans[i][j] = min(ans[i-1][j] + (map[i-1][j] != map[i][j]),
					ans[i][j-1] + (map[i][j-1] != map[i][j]));
	cout << (ans[N-1][M-1]+1) / 2 << endl;
}



Measured memory_bytes: 256
#include <queue>
#include <cstdio>
#include <iostream>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <stack>
using namespace std;
typedef long long int ll;

#define EPS (1e-9)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i,n) for(int i=0;i<n;i++)

int gcd(int a, int b) {
if (b == 0) return a;
return gcd(b, a % b);
}

int N, A, B;

int main() {
	cin >> N;
	if (N == 1) {
		cout << "Hello World" << endl;
	}
	else {
		cin >> A >> B;
		cout << A + B << endl;
	}
}

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

using namespace std;

typedef long long ll;
#define int ll
typedef long double ld;

typedef pair<int,int> pii;
#define x first
#define y second

int solve(string n,int k)
{
    if(k==0)
        return 1;
    reverse(n.begin(),n.end());
    while(!n.empty()&&n.back()=='0')
        n.pop_back();
    reverse(n.begin(),n.end());
    int s=n.size();
    if(s<k)
        return 0;
    int ans1;
    if(k==1)
        ans1=(s-1)*9;
    else if(k==2)
        ans1=(s-1)*(s-2)/2*9*9;
    else if(k==3)
        ans1=(s-1)*(s-2)*(s-3)/6*9*9*9;
    int ans2=solve(string(s-1,'9'),k-1)*(n[0]-'0'-1);
    int ans3=solve(n.substr(1),k-1);
    return ans1+ans2+ans3;
}

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

    string n;
    int k;
    cin>>n>>k;
    cout<<solve(n,k);
}


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

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	set<int> st;
	st.insert(a);
	st.insert(b);
	st.insert(c);
	
	cout << st.size() << endl;
	return 0;
}

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

int main(){
  int K, S;
  cin >> K >> S;
  int answer;
  for (int x=0; x<=K; x++){
    for (int y=0; y<=K; y++){
      int z = S-x-y;
      if (0 <= z && z <= K){
        answer++;
      }
    }
  }
  cout << answer << endl;
  return 0;  
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,m,l,i,j,a[101][101],b[101][101],k=0;
  long long c[101][101];

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

  for(i=0;i<m;i++){
    for(j=0;j<l;j++){
      scanf("%d",&b[i][j]);
    }
  }

 for(i=0;i<n;i++){
    for(j=0;j<l;j++){
      c[i][j]+=0;
    }
 }


  for(i=0;i<n;i++){
    for(j=0;j<l;j++){
      for(k=0;k<m;k++){

      c[i][j]+=a[i][k]*b[k][j];
    }
  }
  }
 for(i=0;i<n;i++){
    for(j=0;j<l;j++){
      if(j<l-1)  printf("%ld ",c[i][j]);
      else printf("%ld",c[i][j]);
    }
    printf("\n");
 }


 return 0;
}

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

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

    string s; cin >> s;

    if(s.size() < 4)
    {
        cout << "No" << endl; return 0;
    }

    if(s[0] != 'Y' || s[1] != 'A' || s[2] != 'K' || s[3] != 'I')
    {
        cout << "No" << endl; return 0;
    }

    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.math.BigDecimal;
import java.util.*;

public class Main {


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

        double ans = 0;
        double n = sc.nextDouble();
        double k = sc.nextDouble();

        for(int i = 1; i <= n; i++){
            double temp = 1 / n;

            int now = i;
            while(now < k){
                now *= 2;
                temp /= 2;
            }
            ans += temp;
        }

        System.out.println(ans);
        return;
    }
}


Measured memory_bytes: 22612
temp = input().split()
n,total = int(temp[0]), int(temp[1])

find = False
for a in range(n+1):
    for b in range(n+1):
        c = (-a) + (-b) + n
        if c >= 0 and a*10000 + b*5000 + c*1000 == total:
            print('{} {} {}'.format(a,b,c))
            find = True
            break
    else:
        continue
    break

if not find:
    print('{} {} {}'.format(-1,-1,-1))


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

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n,m;
	cin>>n>>m;
	vector<int> odd,even,b;
	for(int i=1,a;i<=m;i++){
		cin>>a;
		if(a&1)
			odd.emplace_back(a);
		else
			even.emplace_back(a);
	}
	if(odd.size()>2){
		cout<<"Impossible"<<endl;
		return 0;
	}
	if(odd.size()>=1)
		b.emplace_back(odd[0]);
	for(int it:even)
		b.emplace_back(it);
	if(odd.size()>=2)
		b.emplace_back(odd[1]);
	for(int it:b)
		cout<<it<<' ';
	cout<<endl;
	if(b.size()==1&&b[0]==1){
		cout<<1<<endl<<1<<endl;
	}
	else if(b.size()==1){
		cout<<2<<endl;
		cout<<1<<' '<<b[0]-1<<endl;
	}
	else{
		b[0]++;
		if((--b.back())==0)
			b.pop_back();
		cout<<b.size()<<endl;
		for(int it:b)
			cout<<it<<' ';
		cout<<endl;
	}
	
}


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

int main() {
  double a, b;
  cin >> a >> b;
  cout << 2 * (b - (a / 2)) << endl;
  return 0;
}


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

string toString(int n){
	string str;
	stringstream ss;
	ss << n;
	ss >> str;
	return str;
}

string toNegativeBase(int n, int negBase){
	if (n == 0)
		return "0";

	string converted = "";
	while (n != 0){
		int remainder = n % negBase;
		n /= negBase;
		if (remainder < 0){
			remainder += (-negBase);
			n += 1;
		}
		converted = toString(remainder) + converted;
	}
	return converted;
}
int main()
{	
	int n;
	cin>>n;
	cout << toNegativeBase(n, -2);
	return 0;
}


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

   typedef long long ll;
   typedef pair<ll, ll> Pii;
   typedef vector<ll> Vi;
   typedef vector<Vi> VVi;

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define RSORT(x) sort((x).rbegin(), (x).rend())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
   template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
   ll pow(ll a, ll b){if (b == 0) return 1; else if (b % 2 == 0) return pow(a * a, b / 2); else return pow(a * a, b / 2) * a;}
   ll pow(ll a, ll b, ll m){if (b == 0) return 1; else if (a == 0) return 0; else if (b % 2 == 0) return (pow((a * a) % m, b / 2, m) % m); else return (pow((a * a) % m, b / 2, m) * a) % m;}
   ll residue(ll a, ll m){return ((a % m) + m) % m;};

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

bool in_helix(const char& c){
  if(c == 'A' || c == 'T' || c == 'G' || c == 'C') return true;
  return false;
}
int main(){
  string s; cin >> s;
  ll ans = 0, right = 0;
  for(ll left = 0; left < s.size(); left++){
    if(left > right) right = left;
    while(right < s.size()){
      if(!in_helix(s[right])) break;
      right++;
    }
    chmax(ans, right - left);
  }
  cout << ans << endl;
}


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

using namespace std;
typedef pair<int,int> ii;
vector<vector<int>> adj;
set<ii> edges;
vector<bool> vis;
vector<vector<int>> child;
vector<int> outdeg;
void dfs(int u,int e){
	vis[u] = true;
	for(auto v:adj[u])
	if(v!=e){
		if(!vis[v]){
			child[u].push_back(v);
			outdeg[u]++;
			dfs(v,u);
		}
		else{
			if(edges.count({u,v})==0&&edges.count({v,u})==0)
			{
				edges.insert({u,v});
				outdeg[u]++;
			}
		}
	}
}
void assdir(int u,int e){
	for(auto v:child[u])
	{
		assdir(v,u);
	}
	if(e!=-1)
	{
		if(outdeg[u]&1){
			outdeg[u]+=1;
			outdeg[e]-=1;
			edges.insert({u,e});
		}
		else edges.insert({e,u});
	}
}
int main(int argc, char *argv[]) {
	int n,m;
	cin>>n>>m;
	child.resize(n+1);
	if(m%2==1) return (cout<<-1),0;
	adj.resize(n+1);
	vis.resize(n+1);
	outdeg.resize(n+1);
	for(int i=0;i<m;i++){
		int u,v;
		cin>>u>>v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	dfs(1,-1);
	assdir(1, -1);
//	for(int i=1;i<=n;i++) assert(outdeg[i]%2==0);
	for(auto e:edges) cout<<e.first<<' '<<e.second<<endl;
}

Measured memory_bytes: 29952
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }


string str;

int main() {
    int res = 0;
    while (cin >> str) {
        for (int i = 0; i < str.size(); ++i) if (!(str[i] >= '0' && str[i] <= '9')) str[i] = ' ';
        istringstream sin(str);
    
        int a;
        while (sin >> a) res += a;
    }
    cout << res << endl;
    
    return 0;
}


Measured memory_bytes: 1216
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr ll MOD = 1e9 + 7;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
template <std::uint_fast64_t Modulus> class modint {
    using u64 = std::uint_fast64_t;

  public:
    u64 a;
    constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
    constexpr u64 &value() noexcept { return a; }
    constexpr const u64 &value() const noexcept { return a; }
    constexpr modint operator+(const modint rhs) const noexcept {
        return modint(*this) += rhs;
    }
    constexpr modint operator-(const modint rhs) const noexcept {
        return modint(*this) -= rhs;
    }
    constexpr modint operator*(const modint rhs) const noexcept {
        return modint(*this) *= rhs;
    }
    constexpr modint operator/(const modint rhs) const noexcept {
        return modint(*this) /= rhs;
    }
    constexpr modint operator^(const u64 rhs) const noexcept {
        return modint(*this) ^= rhs;
    }
    constexpr modint &operator+=(const modint rhs) noexcept {
        a += rhs.a;
        if (a >= Modulus) {
            a -= Modulus;
        }
        return *this;
    }
    constexpr modint &operator-=(const modint rhs) noexcept {
        if (a < rhs.a) {
            a += Modulus;
        }
        a -= rhs.a;
        return *this;
    }
    constexpr modint &operator*=(const modint rhs) noexcept {
        a = a * rhs.a % Modulus;
        return *this;
    }
    constexpr modint &operator/=(modint rhs) noexcept {
        u64 exp = Modulus - 2;
        while (exp) {
            if (exp % 2) {
                *this *= rhs;
            }
            rhs *= rhs;
            exp /= 2;
        }
        return *this;
    }
    constexpr modint &operator^=(u64 exp) {
        modint rhs = modint(*this);
        a = 1;
        while (exp) {
            if (exp % 2) {
                *this *= rhs;
            }
            rhs *= rhs;
            exp /= 2;
        }
        return *this;
    }
};
using mint = modint<MOD>;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    mint res = 0;
    for (int k = 60; k >= 0; k--) {
        mint b = mint(1LL << k);
        mint c0 = 0, c1 = 0, sum = 0;
        for (int i = 0; i < n; i++) {
            if ((a[i] >> k) & 1LL) {
                sum += c0;
                c1 += 1;
            } else {
                sum += c1;
                c0 += 1;
            }
        }
        res += sum * b;
    }
    cout << res.a << endl;
}

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

int main() 
{   
  
char s[3000];
char t[3000];
 

scanf("%s",s);

scanf("%s",t);
long long int a=strlen(s);
long long int b=strlen(t);
long long int l[a+1][b+1];

    for(long long int i = 0; i <=a; i++){
   
for(long long int j = 0; j <=b; j++){
   if (i == 0 || j == 0) 
         l[i][j] = 0; 
         else
if(s[i-1]==t[j-1])
   l[i][j] = l[i-1][j-1] + 1; 
       else
         l[i][j] = max(l[i-1][j], l[i][j-1]);




}
}
long long int size=l[a][b];
char lcs[size];
lcs[size] = '\0';
long long int i=a;
long long int j=b;
while (i > 0 && j > 0) 
   { 
      
      if (s[i-1] == t[j-1]) 
      { 
          lcs[size-1] = s[i-1];  
          i--; j--;size--;    
      } 
  
      
      
      else if (l[i-1][j] > l[i][j-1]) 
         i--; 
      else
         j--; 
   } 

 
   printf("%s", lcs);


}

  
 


Measured memory_bytes: 70656
#include <bits/stdc++.h>
using namespace std;
int main(){
	int x;
	cin>>x;
	vector<bool> expo(x+1);
	expo[1]=1;
	for(int i=2;i<=x;i++){
		int v=i*i;
		while(v<=x){
			expo[v]=1;
			v*=i;
		}
	}
	for(int a=x;a>=1;a--) if(expo[a]==true){
			cout<<a<<endl;
			return 0;
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int M,D;
int main()
{
	cin>>M>>D;
	if(D<10)cout<<0<<endl;
	else 
	{   int sum=0;
		for(int j=1;j<=M;j++)
		for(int i=20;i<=D;i++)
		{ //cout<<1;
		if(i%10>=2){
		
		  if((i%10)*(i/10)==j)
		  {sum++;
		   //cout<<j<<" "<<i<<endl;
          }		
		}}
		 cout<<sum<<endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
 
#define ll long long int
#define debug cout<<"debug";
#define mp make_pair 
#define pb push_back
#define ff first
#define ss second
#define fast  ios_base::sync_with_stdio(false);cin.tie(0);
#define MOD 998244353
#define ll_MAX 19223372036859
#define endl "\n"
inline ll absdiff(ll a,ll b){ return (a>b)?a-b:b-a;}
ll fast_expo(ll x,ll p){if(p==0) return 1;
else if(p%2==0){ ll t=fast_expo(x,p/2)%MOD;return (t*t)%MOD;} else return (x*(fast_expo(x,p-1))%MOD)%MOD;}
ll gcd(ll a,ll b){if(a==0||b==0) return a+b;  else return gcd(b%a,a); }

int main(){
    ll n;cin>>n;
    ll arr[n];
    for(auto& i:arr) cin>>i;

    ll dp[n];
    dp[0]=0;dp[1]=absdiff(arr[0],arr[1]);

    for(ll i=2;i<n;++i){
        dp[i]=min(dp[i-1]+absdiff(arr[i],arr[i-1]),dp[i-2]+absdiff(arr[i],arr[i-2]));
    }

    cout<<dp[n-1];
    return 0;   
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#ifdef DEBUG
#define debug(x) cerr << #x << " " << x << '\n'
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using pii = pair<int,int>;
const int INF = 0x3f3f3f3f, N = 2e5 + 5;

int main()
{
 	ios::sync_with_stdio(false);
 	cin.tie(0);
 	int n;
 	cin >> n;
 	for(int a=1;a<=9;a++)
 	{
 		for(int b=1;b<=9;b++)
 		{
 			if(a*b==n) return printf("Yes\n"), 0;
 		}
 	}
 	printf("No\n");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int h[200005];
int a[200005];
int main(){
    int k,n;
    cin>>k>>n;
    for(int i=0;i<n;i++)
        cin>>h[i];
    for(int i=0;i<n-1;i++)
        a[i]=h[i+1]-h[i];
    if(h[0]==0)
        a[n-1]=k-h[n-1];
    else
        a[n-1]=k-h[n-1]+h[0];
    long long sum=0;
    int m=0;
    for(int i=0;i<n;i++){
        sum+=a[i];
        m=max(m,a[i]);
    }
    sum-=m;
    cout<<sum;
}


Measured memory_bytes: 1792
fun main(args: Array<String>) {
    readLine()!!
    val guzaiValue = readLine()!!.split(" ").map { it.toDouble() }
    print(abc138c(guzaiValue))
}

fun abc138c(value: List<Double>):Double{
    var list = value.sorted().toMutableList()

    while( list.size >= 2){
        list.add((list[0] + list[1]) / 2)
        list = list.drop(2).toMutableList()
        list = list.sorted().toMutableList()
    }

    return list.first()
}

Measured memory_bytes: 36072
/**
 * Title:
 * Url:
 */
#include<bits/stdc++.h>

using namespace std;

#define ll long long

int main() {

    int s[32] = {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};
    int k; cin >> k;
    cout << s[k-1] << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define LIMIT(d_in, d_min, d_max) max(d_min, min(d_max, d_in))
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

struct SegmentTree
{
private:
	int mode;
	int invalid;
	int node_size;
	int leaf_size;
	vector<lint> node;

	lint Execute(int left, int right)
	{
		switch (mode)
		{
		case 0:
			return min(left, right);
		case 1:
			return max(left, right);
		case 2:
			return (left + right) % invalid;
		case 3:
			return left * right % invalid;
		default:
			return 0;
		}
	}

	lint Untarget()
	{
		switch (mode)
		{
		case 0:
			return INF64;
		case 1:
			return -INF64;
		case 2:
			return 0;
		case 3:
			return 1;
		default:
			return 0;
		}
	}

public:
	SegmentTree(vector<lint> data, int set_mode, lint set_inv = 1000000007)
	{
		int N = data.size();
		mode = set_mode;
		invalid = set_inv;

		leaf_size = 1;
		while (leaf_size < N)
			leaf_size *= 2;
		node_size = leaf_size - 1;
		node.resize(node_size + leaf_size, Untarget());

		for (int i = 0; i < N; i++)
			node[node_size + i] = data[i];

		for (int i = node_size - 1; 0 <= i; i--)
			node[i] = Execute(node[2 * i + 1], node[2 * i + 2]);
	}

	bool Update(int pos, lint to)
	{
		pos += node_size;

		node[pos] = to;
		for (; 0 < pos;)
		{
			pos = (pos - 1) / 2;
			node[pos] = Execute(node[2 * pos + 1], node[2 * pos + 2]);
		}

		return true;
	}

	lint Query(int t_left, int t_right, int current = 0, int c_left = 0, int c_right = -1)
	{

		if (c_right < 0)
			c_right = leaf_size - 1;

		if (c_right < t_left || t_right < c_left)
			return Untarget();

		if (t_left <= c_left && c_right <= t_right)
			return node[current];

		int v_left = Query(t_left, t_right, 2 * current + 1, c_left, (c_left + c_right) / 2);
		int v_right = Query(t_left, t_right, 2 * current + 2, (c_left + c_right) / 2 + 1, c_right);

		return Execute(v_left, v_right);
	}
};

void execute()
{
	int N, Q;
	string input;
	cin >> N >> input >> Q;

	vector<SegmentTree> tree(26, SegmentTree(vector<lint>(N), 2));

	for (int i = 0; i < N; i++)
	{
		tree[input[i] - 'a'].Update(i, 1);
	}

	for (int i = 0; i < Q; i++)
	{
		int ope, right, left, set;
		char to;
		cin >> ope;
		if (ope == 1)
		{
			cin >> set >> to;
			set--;
			if (input[set] != to)
			{
				tree[input[set] - 'a'].Update(set, 0);
				tree[to - 'a'].Update(set, 1);
				input[set] = to;
			}
		}
		else
		{
			cin >> right >> left;
			right--;
			left--;
			int ans = 0;
			for (int j = 0; j < 26; j++)
			{
				if (0 < tree[j].Query(right, left))
					ans++;
			}
			cout << ans << endl;
		}
	}

	return;
}

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

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 226076
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

const int MOD = 1e9+7;

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    map<int, int> M;
    for(int i = 0; i < N; i++){
        cin >> A[i];
        M[A[i]]++;
    }

    int ans = 0;
    bool F = true;
    if(N % 2 == 1){
        if(M[0] == 1){
            for(auto p : M){
                if(p.first != 0 && p.second != 2){
                    F = false;
                    break;
                }
            }
        }else{
            F = false;
        }
    }else{
        for(auto p : M){
            if(p.second != 2){
                F = false;
                break;
            }
        }
    }

    if(F == true){
        ans = 1;
        for(int i = 1; i <= N/2; i++){
            ans *= 2;
            ans %= MOD;
        }
        cout << ans << endl;
    }else{
        cout << ans << endl;
    }


    return 0;
}

Measured memory_bytes: 3584
import sys

s = input()

a = 0
num_a = 0
b = 0
num_b = 0
for i in range(len(s)):
    if a == 0 and b == 0:
        a = s[i]
        num_a += 1
    elif s[i] == a:
        num_a += 1
    elif s[i] != a and b == 0:
        b = s[i]
        num_b += 1
    elif s[i] == b:
        num_b += 1
    else:
        print('No')
        sys.exit()

if num_a == num_b:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define che
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define PB push_back
#define MP make_pair
#define fi first
#define se second
using namespace std;
typedef long long LL;
const int M=(1<<18) +10,N= 45 ;
const LL MOD = 1e9 +7;

int n,ns, nt=0;
char s[N], t[N], a[N];
LL ans= 0,f[N][N];

template<typename T>
void upsum(T &a, T b){ a=a+b;}

int main(){
	scanf("%d%s", &n,a); 
	
	for (int S=0; S< 1<<n; ++S){
		ns=0 , nt=0;
		for (int j=0; j<n; j++)
			if ( S&1<<j) s[ns++] = a[j];
				else t[nt++] = a[j];
		s[ns] = t[nt] = '\0';
		for (int i=0; i<=ns; ++i)
			for (int j=0;j<=nt; ++j) f[i][j] = 0;
		f[0][0]  =1;
		for (int i=0; i<=ns; i++)
			for (int j=0; j<=nt; j++){
				if ( a[2*n-1-i-j] == s[i] ) upsum(f[i+1][j], f[i][j]);
				if ( a[2*n-1-i-j] == t[j] ) upsum(f[i][j+1], f[i][j]);
			}
		upsum(ans, f[ns][nt]);
		
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 384
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
        int count = 1;
        boolean ans = true;
        String front[] = new String[100];
        String back[] = new String[100];
      	String tmp,tmp2;
      
        
        List<String> list = new ArrayList<String>();
        tmp = sc.next();
        list.add(tmp);
        while(count < n){
          tmp2 = sc.next();
          list.add(tmp2);
          front = tmp.split("");
          back =  tmp2.split("");
          if(!back[0].equals(front[front.length - 1])){
            System.out.println("No");
            return;
          }
          
          ans = (list.size() == new HashSet<>(list).size());
          if(ans == false){
            System.out.println("No");
            return;
          }
          
          tmp = tmp2;
          count++;
        }
        
        
        
        System.out.println("Yes");
    }
}

Measured memory_bytes: 38588
n = int(input())
s = input()

w = [0]*(n+1)
e = [0]*(n+1)

# e,wの累積和を記録
for i, d in enumerate(s):
    if d == "W":
        w[i+1] = w[i] + 1
        e[i+1] = e[i]
    else:
        e[i+1] = e[i] + 1
        w[i+1] = w[i]

mnum = n
for i, d in enumerate(s):
    mnum = min(mnum, w[i] + e[n] - e[i+1])

print(mnum)

Measured memory_bytes: 17656
N = int(input())
C = str(0)
AC = 0
WA = 0
TLE = 0
RE = 0
for i in range(N):
    C += str(input())
AC = C.count("AC")
WA = C.count("WA")
TLE = C.count("TLE")
RE = C.count("RE")
print('AC x ',AC)
print('WA x ',WA)
print('TLE x ',TLE)
print('RE x ',RE)

Measured memory_bytes: 9332
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define P pair<ll, ll>
using ll = long long;
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl
#define coel cout << endl
#define pb push_back
#define sz(v) ((ll)(v).size())
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define pp pair<ll, pair<ll, ll>> 
#define fi first
#define se second

void print(Vl vec){
    rep(i, 0, sz(vec)){
        if(i) cout << " ";
        cout << vec[i];
    }
    coel;
}

////////////////////////////////////////////////////////

Vl v;

void bf(){
    v.push_back(1);
    ll r = 6;
    while(1){
        if(r > 100000) break;
        v.push_back(r);
        r *= 6;
    }
    r = 9;
    while(1){
        if(r > 100000) break;
        v.push_back(r);
        r *= 9;
    }
}

int main() {
    bf();
    sort(ALL(v), greater<ll>());

    ll n; cin >> n;
    Vl dp(n+1, INF);
    dp[0] = 0;

    rep(i, 1, n+1){
        rep(j, 0, sz(v)){
            if(i-v[j]>=0) chmin(dp[i], dp[i-v[j]]+1);
        }
    }

    co(dp[n]);

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
  
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

const ll mod = 1e9+7;

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

   int n; cin >> n;
   vector<pair<int, int>> c(2*n);
   for(int i=0; i<2*n; ++i){
       int x; cin >> x;
       if(i < n) c[i] = make_pair(x, 1);
       else c[i] = make_pair(x, 2);
   }
   sort(c.begin(), c.end());

    ll a = 0, b = 0;
    int m;
    if(c[0].second == 1){ m = 1; a = 1; }
    else { m = 2; b = 1; }

    ll ans = 1;
    for(int i=1; i<2*n; ++i){
        if(c[i].second == 1){
            if(b > 0) { ans *= b; ans %= mod; --b; }
            else ++a;
        }
        else if(c[i].second == 2){
            if(a > 0) { ans *= a; ans %= mod; --a; }
            else ++b;
        }
    }

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

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

using namespace std;

int main(){
	// int n;
	// cin>>n;
	int a[5];
	for(int i=0;i<5;i++){
		cin>>a[i];
	}
	sort(a,a+5);
	int k;
	cin>>k;
	cout<<((a[4]-a[0]<=k)?"Yay!":":(");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define dum(x) cout<<#x<<'='<<x<<endl
#define ll long long
using namespace std;

int main() {
  ll n, m;
  cin >> n >> m;
  ll ans = 0;
  ll re = m - n * 2;
  if (re >= 0) {
    ans += n;
    ans += re / 4;
    cout << ans << endl;
    return 0;
  } else {
    ans += m / 2;
    cout << ans << endl;
    return 0;
  }

}

Measured memory_bytes: 256
x = int(input())
if 400 <= x < 600:
  print(8)
elif 600 <= x < 800:
  print(7)
elif 800 <= x < 1000:
  print(6)
elif 1000 <= x < 1200:
  print(5)
elif 1200 <= x < 1400:
  print(4)
elif 1400 <= x < 1600:
  print(3)
elif 1600 <= x < 1800:
  print(2)
elif 1800 <= x < 2000:
  print(1)



Measured memory_bytes: 9188
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define reps(i,n) for (int i=1;i<=(n);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rreps(i,n) for (int i=(n);i>0;i--)
#define all(v) (v).begin(),(v).end()
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>
template<class T> inline bool chmin(T &a, T b) {if (a>b) {a = b; return 1;} return 0;};
template<class T> inline bool chmax(T &a, T b) {if (a<b) {a = b; return 1;} return 0;};
typedef long long int ll;
const long long INF = 1LL << 60;


int main(){
  int N; cin >> N;
  ll A[N]; rep(i,N) cin >> A[i];

  ll ans = 0;
  rep(i,N){
    if (i==0) continue;

    if (A[i-1]>A[i]) {
      ll h = A[i-1] - A[i];
      A[i] = A[i-1];
      ans += h;
    }
  }
  cout << ans << endl;


  // cout << fixed << setprecision(10);
  
  return 0;
}

Measured memory_bytes: 5196
N = int(input())
p = list(map(int,input().split()))
ps = sorted(p)

cnt = 0
idx = []
for i in range(N):
    if p[i] != ps[i]:
        cnt += 1
        idx.append(i)

if cnt == 2:
    i,j = idx[0],idx[1]
    p[i],p[j] = p[j],p[i]
    if p == ps:
        print('YES')
    else:
        print('NO')
elif cnt == 0:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3064
# problem C

input_d3 = list(map(int, input().split()))

N = input_d3[0]
K = input_d3[1]

if K > N:
    M = abs(K - N)
    print(min(N,M))
else:
    amari = N % K
    if amari == 0:
        print(0)
    else:
        M = abs(K - amari)
        print(min(M,amari))

Measured memory_bytes: 3060
M = input().split()
i = 0
a = ''
b = ''
c = [0,0]
for i in range(int(M[0])):
    a += str(M[1])
for i in range(int(M[1])):
    b += str(M[0])
c[0] = int(a)
c[1] = int(b)  
c.sort()
print(str(c[1]))

Measured memory_bytes: 3064
/*input
1 2 3 4
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}

int main(){
	IOS;
	int a,b,c,n;
	cin>>a>>b>>c>>n;
	int ans=0;
	for(int i=0;i<=n;i+=a) for(int j=0;i+j<=n;j+=b){
		int tmp=n-i-j;
		if(tmp%c) continue;
		ans++;
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>
#define pb push_back 
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define INF (1<<30)
#define MOD 1000000007
using ll = long long;
using namespace std;

int main() {
    ll k;
    cin >> k;
    ll n = 50, num[50] = {};
    for (ll i = 0; i < n; i++)num[i] = i + (k/n);
    k = k - ((k / n) * n);
    for (ll i = 0; i < k; i++) {
        for (ll j = 0; j < n; j++) {
            if (i == j)num[j] += n;
            else num[j] -= 1;
        }
    }
    cout << n << endl;
    for (ll i = 0; i < n; i++) {
        cout << num[i] << ' ';
    }
    return 0;
}


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

using namespace std;

int alphabet[26];

typedef long long ll;

const int mod = 1e9 + 7;

int main(){
int N; cin >> N;
  for(int i = 0; i < 26; i++){ alphabet[i] = 1;}
  string S; cin >> S;
  
  for(int i = 0; i < N; i++){
    int c = S[i] - 'a'; alphabet[c]++;}
  
  ll sum = 1;
  for(int i = 0; i < 26; i++){
    sum *= alphabet[i] ; sum = sum % mod;}
  cout << sum - 1 << endl; return 0;}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <queue>
using namespace std;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
#define MAX_N 100100
#define MOD 1000000007
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

void  base_num(ll data,ll base){
    if(data==0) return;
    ll next=abs(data)%abs(base);
    if(data<0) next=(abs(base)-next)%abs(base);
    base_num((data-next)/base,base);
    cout << next;
}

int main(){
    ll n,m;
    cin >> n >> m;
    vector<ll> g[n];
    for (ll i=0;i<m;i++){
        ll a,b;
        cin >> a >> b;
        a--;
        b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    queue<ll> que;
    que.push(0);
    ll visited[n],c=0;
    ll ans[n];
    fill(visited,visited+n,-1);
    visited[0]=0;
    while(!que.empty()){
        ll p=que.front();
        que.pop();
        for (ll i=0;i<g[p].size();i++){
            if (visited[g[p][i]]==-1){
                visited[g[p][i]]=c+1;
                que.push(g[p][i]);
                ans[g[p][i]]=p+1;
            }
        }
        c++;
    }
    bool flag=true;
    for (ll i=0;i<n;i++){
        if (visited[i]==-1){
            flag=false;
        }
    }
    if (flag){
        cout << "Yes" << endl;
        for (ll i=1;i<n;i++){
            cout << ans[i] << endl;
        }
    }else{
        cout << "No" << endl;
    }
    return 0;
}
 
 


Measured memory_bytes: 13360