akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <map>

typedef long long ll;
#define rep(i, a, n) for(int i = a; i<n; i++)
#define ALL(a) begin(a), end(a)
#define mii map<int, int>
#define msi map<string, int>
#define vi vector<int>
#define vl vector<ll>
#define MOD 1000000007
#define INF 1e9
#define showVector(v) rep(i,0,v.size()){p(v[i]);p(" ")} pl("")
#define p(s) std::cout << s ;
#define pl(s)  std::cout << s << endl;
using namespace std;

// 素数判定 O(√n)
bool is_prime(int n){
    for(int i = 2; i * i <= n; i++){
        if(n % i == 0) return false;
    }
    return true;
}

// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

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

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

//想定解答との絶対誤差または相対誤差が 10−6以下の場合+1以上だしておく。適当に15とかでもおｋ．
//cout << fixed << setprecision(15);

int main() {
    int N;
    cin >> N;
    vl a(N);
    bool odd = false;
    rep(i, 0, N) {
        ll a;
        cin >> a;
        if (a % 2 == 0) continue;
        odd = true;
    }
    if (odd) {
        cout << "first" << endl;
    } else {
        cout << "second" << endl;
    }
    return 0;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<queue>
using namespace std;
int n,m;
bool map[15][10005];
int make_ans(){
	int ans=0;
	for(int i=1;i<=m;i++){
		int sum1=0,sum2=0;
		for(int j=1;j<=n;j++)
			if(map[j][i])
				sum1++;
			else
				sum2++;
		ans+=max(sum1,sum2);
	}
	return ans;
}
void fanzhuan(int x){
	for(int i=1;i<=m;i++)
		map[x][i]=!map[x][i];
}
int dfs(int x){
	if(x>n)
		return make_ans();
	int ans=0;
	fanzhuan(x);
	ans=max(ans,dfs(x+1));
	fanzhuan(x);
	ans=max(ans,dfs(x+1));
	return ans;
}
int main()
{
	scanf("%d%d",&n,&m);
	while(n||m){
		for(int i=1;i<=n;i++)
			for(int j=1;j<=m;j++){
				int a;
				scanf("%d",&a);
				map[i][j]=(a==1);
			}
		printf("%d\n",dfs(1));
		scanf("%d%d",&n,&m);
	}
}

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

using namespace std;

int main() {
  int w, n;
  cin >> w >> n;
  vector<int> k(w);
  for (int i = 0; i < w; ++i) k[i] = i;
  for (int i = 0; i < n; ++i) {
    int a, b;
    cin >> a;
    cin.ignore();
    cin >> b;
    swap(k[a - 1], k[b - 1]);
  }
  for (int i : k) cout << i + 1 << endl;
}

Measured memory_bytes: 1192
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int K = scanner.nextInt();
        double ans = 0;
        for (int i = 1; i <= N; i++) {
            double p = (double) 1 / N;
            int j = i;
            while (j < K) {
                p /= 2;
                j *= 2;
            }
            ans += p;
        }
        System.out.println(ans);
    }

}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[100005];
ll ans[100005];
int main(void){
	int n; cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	ll k=0;
	for(int i=0;i<n;i++){
		k=(a[i]-k/2)*2;
	}
	ans[0]=k/2;
	cout<<ans[0];
	for(int i=1;i<n;i++){
		ans[i]=(a[i-1]-(ans[i-1])/2)*2;
		cout<<" "<<ans[i];
	}
	cout<<endl;
	
}


Measured memory_bytes: 2816
//C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

//ここまで標準include
//以下プログラム

using namespace std;

int main() {
	int X;
	cin >> X;
	int result = 1;
	for (int i = 2; i <= sqrt(1000); i++) {
		for (int j = 2; pow(i, j) <= 1000; j++) {
			if (pow(i, j) <= X) {
				result = max(result, (int)pow(i, j));
			}
			else {
				break;
			}
		}
	}
	cout << result << endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<numeric>
#include<vector>
#include<string>

typedef long long ll;
#define REP(i,n) for(int (i)=0;(i) < (n);(i)++)
using namespace std;


int main(){
  int H,W;
  while(true){
  cin >> H >> W;
    if((H != 0) || (W != 0)){
      REP(i,H){
        REP(j,W){
            cout << "#";
          }
        cout << endl;
    }
    cout << endl;
    }
    else break;
  }

  return 0;

}


Measured memory_bytes: 3072
package main

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

const (
	initialBufSize = 64 * 1024
	maxBufSize     = 10000000
)

var (
	scanner = bufio.NewScanner(os.Stdin)
)

func main() {
	scanner.Split(bufio.ScanWords)
	n, k := scanInt(), scanInt()
	p := scanFloat64s(n)

	cal := func(n float64) float64 {
		return (n + 1) / 2
	}

	cum := make([]float64, n+1)
	for i := 0; i < n; i++ {
		cum[i+1] = cum[i] + cal(p[i])
	}

	high := 0.
	for i := k; i <= n; i++ {
		if exp := cum[i] - cum[i-k]; exp > high {
			high = exp
		}
	}

	fmt.Println(high)
}

func scanInt() int {
	i, _ := strconv.Atoi(scanText())
	return i
}

func scanInts(size int) []int {
	ints := make([]int, size)
	for i := 0; i < size; i++ {
		ints[i] = scanInt()
	}
	return ints
}

func scanFloat64() float64 {
	f, _ := strconv.ParseFloat(scanText(), 64)
	return f
}

func scanFloat64s(size int) []float64 {
	f := make([]float64, size)
	for i := 0; i < size; i++ {
		f[i] = scanFloat64()
	}
	return f
}

func scanText() string {
	scanner.Scan()
	return scanner.Text()
}

func abs(n int) int {
	return int(math.Abs(float64(n)))
}

func pow(x, y int) int {
	return int(math.Pow(float64(x), float64(y)))
}


Measured memory_bytes: 4736
def f(a):
    if(a%2==0):
        return (int(a/2))
    else:
        return (3*a+1)

s = int(input())
m = 1
flag = False
a = []
#a_1
a.append(s)
while(1):
    a.append(f(a[-1]))
    for i in range(len(a)-1):
        if(a[m]==a[i]):
            flag = True
            break
    m = m+1
    if(flag):
        break
print(m)

Measured memory_bytes: 3064
#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
#%%code
def resolve():
    W,H,N=pin()
    ans=[0,W,0,H]#ans[[xの範囲][yの範囲]]
    for n in range(N):
        x,y,a=pin()
        if a==1:
            ans[0]=max(ans[0],x)
        elif a==2:
            ans[1]=min(ans[1],x)
        elif a==3:
            ans[2]=max(ans[2],y)
        else:
            ans[3]=min(ans[3],y)
    t=((ans[1]-ans[0])*(ans[3]-ans[2]))
    if ans[1]-ans[0]<0 or ans[3]-ans[2]<0:t=0
    print(t)    
#%%submit!
resolve()

Measured memory_bytes: 38428
#define _USE_MATH_DEFINES
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>


#ifdef _DEBUG
#define typeof(X) std::identity<decltype(X)>::type //C++0x (for vs2010)
#else
#define typeof(X) __typeof__(X) // for gcc
#endif

#define sz(a)  int((a).size())
#define FOREACH(it, c) for (typeof((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define FOR(i,count) for (int i = 0; i < (count); i++)

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

using namespace std;
static const double EPS = 1e-6;
typedef long long ll;
const int MODULO = 1000000007;
const int INF = 100000000; //1e8

typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
typedef complex<double> Cd;

string s;

string ts = "IVXLCDM";
int ti[] = {1,5,10,50,100,500,1000};

int main(){
	while(cin>>s){
		int ans = 0;
		for (int i = 0; s[i]; i++){
			int pos = ts.find(s[i]);
			int npos = ts.find(s[i+1]);
			if(npos > pos) ans -= ti[pos];
			else ans += ti[pos];
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
const double EPS = 1e-10;
const double g = 9.8;	//??????????????? 
const int MAX_N = 55; 

//?????\ 
int N;
double V, X, Y;
double L[MAX_N], R[MAX_N], B[MAX_N], T[MAX_N];

//????????\vy??????????????´???????°????t?§????????????? 
double calc(double vy, double t){
	return vy * t - g * t * t / 2;
}

//a??????lb???ub????????? 
int cmp(double lb, double ub, double a){
	return a < lb + EPS ? -1 : a > ub - EPS ? 1 : 0;
}


bool check(double qx, double qy)
{
    //??????????????¨x?????????y????????????????????????vx???vy????????????(qx, qy)?????¶??´???t
    //????§£??????????¨????vx^2 + vy ^2 = V^2, vx * t = 1x, vy * t - 1/2 g t^2 = qy
    double a = g * g / 4, b = g * qy - V * V, c = qx * qx + qy * qy;
    double D = b * b - 4 * a * c;
    if (D < 0 && D > -EPS)
        D = 0;
    if (D < 0)
        return false;
    for (int d = -1; d <= 1; d += 2){       //????????????????¨?????????????????§£?????????
        double t2 = (-b + d * sqrt(D)) / (2 * a);
        if (t2 <= 0)
            continue;
        double t = sqrt(t2);
        double vx = qx / t, vy = (qy + g * t * t / 2) / t;

        //??????????????????????????£??????
        double yt = calc(vy, X / vx);
        if (yt < Y - EPS)
            continue;

        bool ok = true;
        for (int i = 0; i < N; i++){
            if (L[i] >= X)
                continue;
            //????????¨?????£???????????????????????´?????????????¢????
            if (R[i] == X && Y <= T[i] && B[i] <= yt)
                ok = false;
            //????????¨?£???°????????£??????????????????????????°????¢????
            int yL = cmp(B[i], T[i], calc(vy, L[i] / vx));   //?????§???????????????
            int yR = cmp(B[i], T[i], calc(vy, R[i] / vx));   //?????§???????????????
            int xH = cmp(L[i], R[i], vx * (vy / g));      //????????????????????????
            int yH = cmp(B[i], T[i], calc(vy, vy / g));
            if (xH == 0 && yH >= 0 && yL < 0)
                ok = false;
            if (yL * yR <= 0)
                ok = false;
        }
        if (ok)
            return true;
    }
    return false;
}

 
void solve(){
	//???????????\??????????¢???? 
 	for(int i = 0; i < N; i++){
 		R[i] = min(R[i], X);
	}
	bool ok = check(X, Y);			//??´??\?????????????????? 
	for(int i = 0; i < N; i++){
	 	ok |= check(L[i], T[i]);	//?????????????§?????????? 
	 	ok |= check(R[i], T[i]);	//?????????????§?????????? 
	}
	puts(ok ? "Yes" : "No");
}
 
int main(){
 	while(scanf("%d%lf%lf%lf",&N,&V,&X,&Y)!=EOF){
 		for(int i = 0; i < N; i++)
 			scanf("%lf%lf%lf%lf",&L[i],&B[i],&R[i],&T[i]);	
		solve();
	}
 	return 0;
}

Measured memory_bytes: 2756
#include<bits/stdc++.h>
using namespace std;
signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);

  int p, q, r;
  cin >> p >> q >> r;

  int sum[2];
  sum[0] = p;
  sum[1] = q;
  sum[2] = r;

  sort( sum, sum + 3 );

  cout << sum[0] + sum[1] << '\n';

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int n;
	int a[100];
	int b[100];
	int sum;
	int i;
	cin>>n;
	for(i=0;i<n-1;i++)	cin>>b[i];
	a[0]=b[0];
	a[n-1]=b[n-2];
	for(i=1;i<n-1;i++){
		a[i]=min(b[i-1],b[i]);
	}
	sum=0;
	for(i=0;i<n;i++)	sum+=a[i];
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int n;
  ll c;
  cin>>n>>c;
  P a[n];
  rep(i,0,n){
    ll x;
    ll v;
    cin>>x>>v;
    a[i]=P(x,v);
  }
  ll vsum[n+1];
  ll xsum[n+1];
  vsum[0]=0;
  xsum[0]=0;
  rep(i,0,n){
    vsum[i+1]=vsum[i]+a[i].second;
  }
  rep(i,0,n){
    xsum[i+1]=vsum[i+1]-a[i].first;
  }
  rep(i,0,n){
    xsum[i+1]=max(xsum[i+1],xsum[i]);
  }
  
  ll vsum2[n+1];
  ll xsum2[n+1];
  vsum2[0]=0;
  xsum2[0]=0;
  rep(i,0,n){
    vsum2[i+1]=vsum2[i]+a[n-1-i].second;
  }
  rep(i,0,n){
    xsum2[i+1]=vsum2[i+1]-(c-a[n-1-i].first);
  }
  rep(i,0,n){
    xsum2[i+1]=max(xsum2[i+1],xsum2[i]);
  }
  
  ll ans=0;
  rep(i,0,n){
    ans=max(ans,vsum2[i+1]-(c-a[n-1-i].first)+max((ll)0,xsum[n-1-i]-(c-a[n-1-i].first)));
  }
  rep(i,0,n){
    ans=max(ans,vsum[i+1]-a[i].first+max((ll)0,xsum2[n-1-i]-a[i].first));
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 4992
import collections

n, q = map(int, input().split())
nxts = collections.defaultdict(list)
score = [0] * n 
for _ in range(n - 1):
    a, b = map(int, input().split())
    nxts[a - 1].append(b - 1)
    nxts[b - 1].append(a - 1)
for i in range(q):
    p, x = map(int, input().split())
    score[p - 1] += x


stack = [(0, -1)]
while stack:
    node, parent = stack.pop()
    for nxt in nxts[node]:
        if nxt != parent:
            score[nxt] += score[node]
            stack.append((nxt, node))

ans = ' '.join(map(str, score))
print(ans)


Measured memory_bytes: 82584
#include<bits/stdc++.h>
using namespace std;
long int dp[11][11][11];
long int n,m,q;
long int ans=0;
void fun(long int ind,long int val,long int sum,vector<int> a)
{
    if(ind==n)
    {
        ans=max(ans,sum);
        return ;
    }
    if(val>m)
    return ;
    vector<int> b=a;
    for(long int i=val;i<=m;i++)
    {
        long int ss=sum;
         b.push_back(i);
         for(long int j=0;j<ind;j++)
         {
            ss+=dp[ind][j][i-b[j]];
         }
         fun(ind+1,i,ss,b);
         b.pop_back();
    }
}
int main()
{
  cin>>n>>m>>q;
  long int a,b,c,d;
  for(long int i=0;i<=10;i++)
  for(long int j=0;j<=10;j++)
  for(long int k=0;k<=10;k++)
  dp[i][j][k]=0;
  for(long int i=0;i<q;i++)
  {
      cin>>a>>b>>c>>d;
      dp[b-1][a-1][c]=d;
  }
  vector<int> aa;
  for(long int i=1;i<=m;i++)
  {
      aa.push_back(i);
      fun(1,i,0,aa);
      aa.pop_back();
  }
  cout<<ans;
}


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

long long MOD=1000000007LL;

long long fac[111111],finv[111111],inv[111111];
 
void COMinit(){
	fac[0]=fac[1]=1;
	finv[0]=finv[1]=1;
	inv[1]=1;
	for(int i=2;i<111111;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 long N,K;
	cin >> N >> K;
	
	COMinit();
	
	for(int k=1;k<=K;k++){
		cout << (COM(N-K+1,k)*COM(K-1,K-k))%MOD << endl;
	}
	return 0;
}

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

int main() {
  char c;
  cin >> c;

  if (c=='a'||c=='e'||c=='i'||c=='o'||c=='u') {
    cout << "vowel" << endl;
  }

  else {
    cout << "consonant" << endl;
  }

}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define MX 200005

using namespace std;

typedef long long ll;

int fst[MX], nxt[MX], v[MX], lnum;
int fa[MX], vis[MX], dep[MX], siz[MX];
int n, m, S, T;

void addeg(int nu, int nv)
{
	nxt[++lnum] = fst[nu];
	fst[nu] = lnum;
	v[lnum] = nv;
}

void input()
{
	int a, b;
	scanf("%d%d", &n, &m);
	for(int i=1; i<=m; i++)
	{
		scanf("%d%d", &a, &b);
		addeg(a, b);
		addeg(b, a);
	}
}

ll ans = 0;

int dfs(int x, int f, int d)
{
	vis[x] = 1;
	dep[x] = d;
	fa[x] = f;
	int s = d;
	for(int i=fst[x]; i; i=nxt[i])
		if(v[i] != f)
		{
			if(!vis[v[i]]) s += dfs(v[i], x, -d);
			else if(!S) S = v[i], T = x;
		}
	if(x != 1) ans += abs(s);
	siz[x] = s;
	return s;
}

void fail()
{
	printf("-1\n");
	exit(0);
}

int main()
{
	input();
	int ret = dfs(1, 0, 1);
	if(abs(ret) & 1) fail();
	else if(ret && !S && !T) fail();
	else if(!ret && !S && !T) printf("%lld\n", ans);
	else
	{
		if(dep[S] == dep[T])
		{
			int p = T;
			ans += abs(ret/2);
			while(p != S) ans -= abs(siz[p]), p = fa[p];
			while(p != 1) ans -= abs(siz[p]), p = fa[p];
			p = T;
			while(p != S) ans += abs(siz[p]-ret/2), p = fa[p];
			while(p != 1) ans += abs(siz[p]-ret), p = fa[p];
			printf("%lld\n", ans);
		}
		else
		{
			if(ret) fail();
			static int tmp[MX], cnt;
			int p = T, x = 0;
			while(p != S) tmp[++cnt] = siz[p], ans -= abs(siz[p]), p = fa[p];
			tmp[++cnt] = 0;
			nth_element(tmp+1, tmp+(cnt+1)/2, tmp+cnt+1);
			x = tmp[(cnt+1)/2];
			p = T;
			ans += abs(x);
			while(p != S) ans += abs(siz[p]-x), p = fa[p];
			printf("%lld\n", ans);
		}
	}
	return 0;
}

Measured memory_bytes: 11776
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

typedef long long ll;

int main(int argc, char const *argv[])
{
    string s;
    cin >> s;
    int rb;
    ll ans = 0, r = 0, b = 0;
    for (int i = 0; i < s.size(); ++i) {
        if (s[i]-'0') b++;
        else r++;
    }

    ans += 2 * min(r,b);

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

Measured memory_bytes: 636
#include<bits/stdc++.h>
#include<string>
#include<cmath>

using namespace std;

#define ll long long int
#define ld long double
#define pb push_back
#define all(v) v.begin(),v.end()
#define sz(x) ((int)(x).size())
#define fi first
#define se second
#define deb(x) cout<< #x << '=' << x <<endl
#define MOD 1000000007
const int N = 2005;
int s;
int dp[N];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>s;
    dp[0] = 1;
    dp[1] = 0;
    dp[2] = 0;
    for(int i = 3; i <= s; i++){
        for(int j = 3; j <= i; j++){
            dp[i] += dp[i - j];
            dp[i] %= MOD;
        }
    }    
    cout<<dp[s]<<"\n";
}

Measured memory_bytes: 3652
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<string>
#define int long long
#define maxn 200010
#define inf 2147483647
#define mod 998244353
#define eps 1e-8
using namespace std; 
inline int read(){
    int x=0,f=1; char ch=getchar();
    while(!isdigit(ch)) {if(ch=='-')f=-1;ch=getchar();}
    while(isdigit(ch)) {x=x*10+ch-48;ch=getchar();}
    return x*f;
}
string s;
signed main(){
	cin>>s;
	int len=s.size();
	for(int i=0;i<len;i++)
	if(s[i]=='C')
	for(int j=i+1;j<len;j++)
	if(s[j]=='F') return puts("Yes"),0;
	puts("No");
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int room[10]={0,0,0,0,0,0,0,0,0,0};
	int b[500], f[500], r[500], v[500];
	int n, i, j, k, m;
	scanf("%d\n", &n);
	for (i=1; i<=n; i++)
	{
		scanf("%d%d%d%d\n", &b[i-1], &f[i-1], &r[i-1], &v[i-1]);
	}
	for (i=1; i<=4; i++)
	{
		for (j=1; j<=3; j++)
		{
			for (k=1; k<=n; k++)
			{
				if (i==b[k-1] && j==f[k-1])
				{
					room[r[k-1]-1]+=v[k-1];
				}
			}
			for (m=1; m<=10; m++)
			{
				printf(" %d", room[m-1]);
			}
			printf("\n");
			for (m=1; m<=10; m++)
			{
				room[m-1]=0;
			}
		}
		if (i==4) break;
		printf("####################\n");
	}
	return 0;
}

Measured memory_bytes: 624
//
//  main.cpp
//  AC
//
//  Created by makinofuya on 2019/07/08.
//  Copyright © 2019 makinofuya. All rights reserved.
//
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <math.h>

typedef long long ll;
using namespace std;
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define out(s) cout << s << endl


int main(){
    vector<int>x(3);
    rep(i,3)cin >> x[i];
    int k;cin >> k;
    int max=0,max_index=-1;
    for(int i=0;i<3;i++){
        if(max<x[i]){
            max=x[i];
            max_index=i;
        }
    }
    for(int i=0;i<k;i++){
        x[max_index]*=2;
    }
    int ans=0;
    for(int a:x)ans+=a;
    cout << ans <<endl;
    return 0;
}


Measured memory_bytes: 256
n=int(input())
s=input()
max=0

for i in range(1,len(s)):
    count=set()
    x=s[0:i]
    y=s[i::]
    #print(x)
    #print(y)
    for j in range(len(x)):
        if x[j] in y:
            count.add(x[j])
    if max<len(count):
        max=len(count)

print(max)


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

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef size_t st;

// #define OJ
#define pb push_back
#define F first
#define S second
#define N '\n'

#define WLL(t) while(t--)
#define FOR(i,a,b) for(int i = a; i < b; i++)
#define STF(i, a, b) for(size_t i = a; i < b; i++)
#define RFOR(i, a, b) for(int i = a; i >= b; i--)
#define SRF(i, a, b) for(size_t i = a;i >= b;i--)

#define ALL(v) v.begin(),v.end()
#define FPRECISE(x) cout<<fixed<<setprecision(x)
#define PRECISE(x) cout<<setprecision(x)
#define BOOL cout<<boolalpha
#define FASTIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define READ freopen("input.txt", "r", stdin)
#define WRITE freopen("output.txt", "w", stdout)
#define MOD 1000000007

#define TO(v, type) static_cast<type>(v)
int main()
{
#ifdef OJ
	READ;
	WRITE;
#endif
	FASTIO;
	int n;
	cin >> n;
	while (n--) {
		cout << "ACL";
	}
	cout << N;
	return 0;
}


Measured memory_bytes: 3644
k = 72
kk = k // 4
KK = 1<<k
nu = lambda L: int("".join([hex(KK+a)[3:] for a in L[::-1]]), 16)
st = lambda n: hex(n)[2:]
li = lambda s, l, r: [int(a, 16) % P if len(a) else 0 for a in [s[-(i+1)*kk:-i*kk] for i in range(l, r)]]

def grow(d, v, h):
    h += [0] * d
    f = [(-1 if (i+d) % 2 else 1) * fainv[i] * fainv[d-i] % P * h[i] % P for i in range(d+1)]
    nuf = nu(f)
    a = d * inv[v] % P
    t = [1] * (3*d+3)
    for i in range(1, 3*d+3): t[i] = t[i-1] * (a - d + i - 1) % P
    ti = [1] * (3*d+3)
    ti[-1] = pow(t[-1], P-2, P)
    for i in range(1, 3*d+3)[::-1]: ti[i-1] = ti[i] * (a - d + i - 1) % P
    iv = [1] * (3*d+3)
    for i in range(1, 3*d+3):
        iv[i] = ti[i] * t[i-1] % P

    ###
    g = [inv[i] for i in range(1, 2*d+2)]
    fg = li(st(nuf * nu(g)), d, d * 2 + 1)
    for i in range(d):
        h[i+d+1] = fg[i] * fa[d+i+1] % P * fainv[i] % P

    ###
    g = [iv[i] for i in range(1, 2*d+2)]
    fg = li(st(nuf * nu(g)), d, d * 2 + 1)
    for i in range(d+1):
        h[i] = h[i] * (fg[i] * t[d+i+1] % P * ti[i] % P) % P

    ###
    g = [iv[i] for i in range(d+2, 3*d+3)]
    fg = li(st(nuf * nu(g)), d, d * 2 + 1)
    for i in range(d):
        h[i+d+1] = h[i+d+1] * (fg[i] * t[2*d+i+2] % P * ti[d+i+1] % P) % P

    return h

# Create a table of the factorial of the first v+2 multiples of v, i.e., [0!, v!, 2v!, ..., (v(v+1))!]
def create_table(v):
    s = 1
    X = [1, v+1]
    while s < v:
        X = grow(s, v, X)
        s *= 2

    table = [1]
    for x in X:
        table.append(table[-1] * x % P)
    return table

def fact(i, table):
    a = table[i//v]
    for j in range(i//v*v+1, i+1):
        a = a * j % P
    return a

H, W, K = map(int, input().split())
N = H + W
P = 10**9+7

v = 1 << (N.bit_length() + 1) // 2
fa = [1] * (2*v+2)
fainv = [1] * (2*v+2)
for i in range(2*v+1):
    fa[i+1] = fa[i] * (i+1) % P
fainv[-1] = pow(fa[-1], P-2, P)
for i in range(2*v+1)[::-1]:
    fainv[i] = fainv[i+1] * (i+1) % P
inv = [0] * (2*v+2)
for i in range(1, 2*v+2):
    inv[i] = fainv[i] * fa[i-1] % P

T = create_table(v)

print((K*(K+3)//2 + K*(K+1)*(K-1)//3*H*W*pow(N * (N-1), P-2, P)) * fact(N, T) * pow(fact(N-K, T), P-2, P) % P)

Measured memory_bytes: 10168
#pragma region
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = n; i > 0; i--)
#define repc(i, m, n) for (int i = m; i < n; i++)
#define reprc(i, m, n) for (int i = m; i > n; i--)
#define all(v) v.begin(), v.end()
#define INF 1e9
#define EPS 1e-10
using namespace std;
typedef long long ll;
#pragma endregion

int main()
{
    string S,T;
    cin >> S >> T;

    rep(i, S.size()){
        if(S[i] != T[i]){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
}

Measured memory_bytes: 3620
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <random>
#include <set>
#include <stack>
#include <time.h>

//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define SORTR(x) sort(x.begin(),x.end(),greater<int>())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple

using namespace std;
using ll = long long;
typedef std::pair<int,int> pii;
typedef std::pair<int,double> pid;
typedef std::vector<int> vi;
typedef std::vector<pii> vii;

#define PI 3.14159265358979323846264338327950L
const int mod = 1000000007;


void solve(){
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    
    
    ll money = 1000;
    ll stock = 0;

    for(int i = 0; i < n-1;i++){
        if (a[i] < a[i+1]){
            stock = money/a[i];
            money = money%a[i];
            money += stock*a[i+1];
            stock = 0;
        }
        else continue;
    }
    
    cout << money;
    
    
}


int main(){
    int T;
    T = 1;
    //cin >> T;
    while(T--){
        solve();
        cout << endl;
    }
}





































Measured memory_bytes: 3624
#include <iostream>
#include <numeric>
#include <vector>
using namespace std;

int main(){
	int n;
	string s;
	cin>>n>>s;
	vector<long long> td,yd;
	for(int i=0; i<n; i++){
		td.assign(8,0);
		if(!i){
			if(s[i]=='J')td[1] = td[3] = td[5] = td[7] = 1;
			else if(s[i]=='O') td[3] = td[7] = 1;
			else if(s[i]=='I') td[5] = td[7] = 1;
		}else if(s[i]=='J'){
			td[1] += yd[1] + yd[3] + yd[5] + yd[7];
			td[3] += td[1] + yd[2] + yd[6];
			td[5] += td[1] + yd[4] + yd[6];
			td[7] += td[3] + yd[4];
		}else if(s[i]=='O'){
			td[2] += yd[2] + yd[3] + yd[6] + yd[7];
			td[3] += td[2] + yd[1] + yd[5];
			td[6] += td[2] + yd[4] + yd[5];
			td[7] += td[3] + yd[4];
		}else if(s[i]=='I'){
			td[4] += yd[4] + yd[5] + yd[6] + yd[7];
			td[5] += td[4] + yd[1] + yd[3];
			td[6] += td[4] + yd[2] + yd[3];
			td[7] += td[5] + yd[2];
		}
		for(auto &e : td) e %= 10007;
		yd = td;
	}
	cout<<accumulate(td.begin(),td.end(),0)%10007<<endl;
}

Measured memory_bytes: 3180
package main

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

func main() {
  sc := bufio.NewScanner(os.Stdin)
  sc.Split(bufio.ScanWords)

  sc.Scan()
  n, _ := strconv.Atoi(sc.Text())
  sc.Scan()
  a, _ := strconv.Atoi(sc.Text())
  sc.Scan()
  b, _ := strconv.Atoi(sc.Text())

  if n * a < b {
    b = n * a
  }

  fmt.Println(b)
}



Measured memory_bytes: 640
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2, log
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *

N = INT()
CSF = [LIST() for _ in range(N-1)]

for i in range(N-1):
	t = 0
	for C, S, F in CSF[i:]:
		if t < S:
			t = S
		else:
			t = F * ceil(t/F)
		t += C
	print(t)
print(0)


Measured memory_bytes: 5200
#include <bits/stdc++.h>
#include <math.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++)

const int MOD = 1000000007;
const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

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

typedef long long ll;

#define MAX_N 10000

struct Edge {
    int to;
    int weight;
    Edge(int t, int w)
        : to(t)
        , weight(w)
    {
    }
};
using Graph = vector<vector<int>>;
using Graph_e = vector<vector<Edge>>;

vector<int> dx = { 1, 0, -1, 0 };
vector<int> dy = { 0, 1, 0, -1 };
typedef pair<int, int> P;

template <typename T>
T GCD(T x, T y)
{
    return (y ? GCD<T>(y, x % y) : x);
}

struct UnionFind {
    vector<int> par; // 親ノード
    vector<int> rank;

    UnionFind(int n = 1)
    {
        init(n);
    }

    void init(int n = 1)
    {
        par.resize(n);
        rank.resize(n);
        for (int i = 0; i < n; i++) {
            par[i] = i;
            rank[i] = 0;
        }
    }

    int root(int x)
    {
        if (par[x] == x) {
            return x;
        } else {
            int r = root(par[x]);
            return par[x] = r; // 辺の縮約（一度根をたどったら辺を直接根に向かって貼り直す）
        }
    }

    bool issame(int x, int y)
    {
        return root(x) == root(y);
    }

    bool merge(int x, int y)
    {
        x = root(x);
        y = root(y);
        if (x == y)
            return false;
        if (rank[x] < rank[y])
            swap(x, y);
        if (rank[x] == rank[y])
            ++rank[x];
        par[y] = x; // xよりyのほうが高さが小さい木
        return true;
    }
};

// railwayとroadそれぞれについてunion-find treeを用意し，どちらでもis-sameなcityの数を求める
int main()
{
    int N;
    cin >> N;
    vector<int> a(N);
    rep(i, N) cin >> a.at(i);

    int start = -1;
    rep(i, N)
    {
        if (a.at(i) == 1) {
            start = i + 1;
            break;
        }
    }
    if (start == -1) {
        cout << "-1" << endl;
        return 0;
    }

    int next = 2;
    while (start < N) {
        if (a.at(start) == next)
            next++;
        start++;
    }

    int ans = N - (next - 1);

    cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 1e5 + 10;

ll h[MAXN];

int main() {
	ios::sync_with_stdio(false);
	ll n;
	while(cin >> n) {
		for(int i = 0; i < n; i++) {
			cin >> h[i];
		}
		ll ans = 0;
		for(int i = 0; i < n; i++) {
			ll countN = 0;
			while(h[i] >= h[i + 1] && i + 1 < n) {
				countN++;
				i++;
			}
			ans = max(ans, countN);
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1024
h,w=map(int,input().split())
a=[]
for i in range(h):
  aa=list(input())
  if "#" not in aa:
    continue
  else:
    a.append(aa)
aa=[]
for i in range(w):
  c=0
  for j in range(len(a)):
    if a[j][i]=="#":
      c+=1
  if c==0:
    aa.append(i)
aa.reverse()
for i in aa:
  for j in range(len(a)):
    del a[j][i]
for i in range(len(a)):
  print("".join(a[i]))


Measured memory_bytes: 3188
N,K = map(int, input().split())
A = [int(i) for i in input().split()]

# dp[i][j]: fの最大値
# i: 決定した桁数
# j: K以下確定フラグ
dp = [[-float("inf")] * 2 for _ in range(61)]

# 初期条件
dp[0][0] = 0

for i in range(60):
    for j in range(2):
        if dp[i][j] < 0:
            continue

        one = 0
        for a in A:
            if (a >> (59 - i)) & 1:
                one += 1
        zero = N - one

        # 0にする
        dp[i+1][j | ((K >> (59 - i)) & 1)] = max(dp[i+1][j | ((K >> (59 - i)) & 1)], dp[i][j] + one * (1 << (59 - i)))

        # 1にする
        if j or (K >> (59 - i)) & 1:
            dp[i+1][j] = max(dp[i+1][j], dp[i][j] + zero * (1 << (59 - i)))

print(max(dp[60]))

Measured memory_bytes: 14708
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		for(int i=0;i<n;i++){
			int a=sc.nextInt();
			if(a%2==0&&a%3!=0&&a%5!=0){
				System.out.println("DENIED");
				return;
			}
		}
		System.out.println("APPROVED");
	}
}

Measured memory_bytes: 35520
N, M = map(int,input().split())
A = list(map(int, input().split()))
cost = [2,5,5,4,5,6,3,7,6]

dp = [-1 for _ in [0]*(N+10)]
dp[0] = 0

for i in range(N+1):
    for a in A:
        if i-cost[a-1] < 0 or dp[i-cost[a-1]] < 0:
            continue
        if dp[i-cost[a-1]]*10 + a > dp[i]:
            dp[i] = dp[i-cost[a-1]]*10 + a
print(dp[N])

Measured memory_bytes: 51420
import numpy as np

def ceil(a):
    return int(np.ceil(a))

def sol2():
    A,B,C,D,E,F = map(int, input().split(' '))
    na, nb, nc, nd = ceil(F/A/100),ceil(F/B/100),ceil(E*F/C/100),ceil(E*F/D/100) 
    sug = np.arange(0,nc).reshape(1,1,nc,1)*C+np.arange(0,nd).reshape(1,1,1,nd)*D
    wat = np.arange(0,na).reshape(na,1,1,1)*A*100+np.arange(0,nb).reshape(1,nb,1,1)*B*100
    sug2=np.unique(sug[sug<=F*F/100])
    wat2=np.unique(wat[wat<=F])
    
    if len(wat2)==1:
        print(0,0)
        return
    elif E==0:
        print(wat2[1],0)
        return
    
    tot =  wat2[1:].reshape(len(wat2[1:]),1) + sug2
    e2 = E/(100+E)
    dense = (sug2/tot)[tot<=F]
    
    maxi = np.argmax(dense[dense<=e2])
    stot = tot[tot<=F][dense<=e2]
    ssug = (sug2 + tot*0)[tot<=F][dense<=e2]
    
    if dense[maxi] ==0:
        print(wat2[1],0)
    else:
        print(int(stot[maxi]),int(ssug[maxi]))
sol2()

Measured memory_bytes: 25128
#include<stdio.h>

int main(){
char ch;
char p[101]={};
int sum;
int w,b,a;
sum=0;ch=NULL;w=0;b=0;a=0;
//scanf("%s",p);printf("%c",(p[1]));
while(scanf("%s",p)!=EOF)
{
for(int i=0;i<101;i++){

	ch=p[i];
 if(ch=='I')w=1;
else if(ch=='V')w=5;
else if(ch=='X')w=10;
else if(ch=='L')w=50;
else if(ch=='C')w=100;
else if(ch=='D')w=500;
else if(ch=='M')w=1000;
switch(w){
case 1:
a=1;break;
case 5:
	if(b==1){a=3;break;}
else  if(b!=1)a=5;break;
case 10:
if(b==1){a=8;break;}
else  if(b!=1)a=10;break;
case 50:
if(b==10){a=30;break;}
else  if(b!=10)a=50;break;
case 100:
if(b==10){a=80;break;}
else  if(b!=10)a=100;break;
case 500:
if(b==100){a=300;break;}
else  if(b!=100)a=500;break;
case 1000:
if(b==100){a=800;break;}
else  if(b!=100)a=1000;break;
}

sum+=a;b=a;
ch='\0';w=0;a=0;
}
printf( "%d\n",sum);
sum=0;ch='\0';w=0;b=0;a=0;
for(int i=0;i<101;i++)
	p[i]='\0';


}

return 0;
}

Measured memory_bytes: 968
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};
fn main() {
    input! {//
        n:i64,
    }
    // n* (n+1) / 2
    let mut x = 0;
    let mut left = 0;
    for i in 1..=n {
        if i * (i + 1) / 2 >= n {
            x = i;
            left = (i * (i + 1) / 2) - n;
            break;
        }
    }
    dbg!(x, left);
    for i in 1..=x {
        if i != left {
            println!("{}", i);
        }
    }
}


Measured memory_bytes: 2168
n, x, m = map(int, input().split())
dp = [x]
s = set([x])
for i in range(1000000):
    if ((dp[-1] ** 2) % m) in s:
        dp.append((dp[-1] ** 2) % m)
        break
    s.add((dp[-1] ** 2) % m)
    dp.append((dp[-1] ** 2) % m)
ind = dp.index(dp[-1])
del dp[-1]
print(sum(dp[:ind]) + sum(dp[ind:]) * ((n - ind) // (len(dp) - ind)) + sum(dp[ind:ind + ((n - ind) % (len(dp) - ind))]))

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

#define int long long
#define ci(m)     for(int i=0;i<m;i++)
#define cj(m)     for(int j=0;j<m;j++)
#define ck(m)     for(int k=0;k<m;k++)
#define gcd            __gcd
#define endl           "\n"
#define pb             emplace_back
#define setbits(x)     __builtin_popcountll(x)
#define zrobits(x)     __builtin_ctzll(x)
#define mod            1000000007
#define mod2           998244353
#define maxe           *max_element
#define mine           *min_element
#define inf            1e18
#define deci(x, y)      fixed<<setprecision(y)<<x
#define w(t)           int t; cin>>t; while(t--)
#define nitin          ios_base::sync_with_stdio(false); cin.tie(NULL)
#define PI             3.141592653589793238
using namespace std;
int n,m;
int cost[1001];
int which[1001];
int dp[1001][1<<13];
int32_t main() {
    nitin;
    cin>>n>>m;
    ci(m)
    {
        cin>>cost[i];
        int p;
        cin>>p;
        cj(p)
        {
            int q;
            cin>>q;
            --q;
            which[i]|=(1<<q);
        }
    }
    for(int i=0;i<m;i++)
    {
        dp[i][0]=0;
        for(int j=1;j<(1<<12);j++)
        {
            if((j|which[i])==which[i])
                dp[i][j]=cost[i];
            else
                dp[i][j]=inf;
        }
        for(int j=1;j<(1<<12) && i>0;j++)
        {
            dp[i][j]=min(dp[i-1][j],dp[i][j]);
            dp[i][j]=min(dp[i-1][j],dp[i-1][j&(~which[i])]+cost[i]);
        }
    }
    if(dp[m-1][(1<<n)-1]==inf)
        cout<<-1<<endl;
    else
        cout<<dp[m-1][(1<<n)-1]<<endl;
    return 0;
}

Measured memory_bytes: 39624
#!/usr/bin/env python3
import sys, math, fractions, itertools


def solve(A: str, B: str):
    l = max(len(A), len(B))
    A = A.zfill(l)
    B = B.zfill(l)
    if (A > B):
        print('GREATER')
    elif (B > A):
        print('LESS')
    else:
        print('EQUAL')
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = next(tokens)  # type: int
    B = next(tokens)  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()


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

#define ll long long
#define ld long double

int n;
map<string, int> song;

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

    cin >> n;
    string last = "";
    for(int i=0;i<n;i++) {
        string s;
        cin >> s;
        int x;
        cin >> x;
        if(last != "") song[s] = x + song[last];
        else song[s] = x;
        last = s;
    }
    string sleep;
    cin >> sleep;

    /*for(auto x : song) {
        cout << x.first << " " << x.second << '\n';
    }*/

    cout << song[last] - song[sleep] << '\n';
    return 0;
}



Measured memory_bytes: 256
N = int(input())
XL = []
for i in range(N):
    x,l = map(int,input().split())
    XL.append((x-l,x+l-1))

XL.sort(key=lambda x: x[1])

ans = 0
t = -10**10
for i in range(N):
    if t < XL[i][0]:
        ans += 1
        t = XL[i][1]
print(ans)

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

int main(){
    string s;
    cin >> s;
    int one = 0,zero = 0;
    for(int i = 0; i < s.size(); i++){
        if(s[i] == '0'){
            zero++;
        }else{
            one++;
        }
    }
    cout << min(one,zero)*2 << endl;
}


Measured memory_bytes: 512
import java.io.PrintWriter
import kotlin.math.min

fun main() {
    val pw = PrintWriter(System.out)

    var (n, a, b, c) = readInputLine().split(" ").map { it.toInt() }

    val query = Array(n) { readInputLine() }

    val builder = StringBuilder()

    builder.append("Yes\n")
//    pw.println("Yes")

    for (i in 0 until n) {
        when(query[i]) {
            "AB" -> {
                if (a == 0 && b == 0) {
                    println("No")
                    return
                }
                if (a < b || (a == 1 && b == 1 && query[min(i + 1, n - 1)] == "AC")) {
//                    pw.println("A")
                    builder.append("A\n")
                    a++
                    b--
                } else {
//                    pw.println("B")
                    builder.append("B\n")
                    a--
                    b++
                }
            }
            "AC" -> {
                if (a == 0 && c == 0) {
                    println("No")
                    return
                }
                if (a < c || (a == 1 && c == 1 && query[min(i + 1, n - 1)] == "AB")) {
//                    pw.println("A")
                    builder.append("A\n")
                    a++
                    c--
                } else {
//                    pw.println("C")
                    builder.append("C\n")
                    a--
                    c++
                }
            }
            "BC" -> {
                if (b == 0 && c == 0) {
                    println("No")
                    return
                }
                if (b < c || (b == 1 && c == 1 && query[min(i + 1, n - 1)] == "AB")) {
//                    pw.println("B")
                    builder.append("B\n")
                    b++
                    c--
                } else {
//                    pw.println("C")
                    builder.append("C\n")
                    b--
                    c++
                }
            }
        }
    }

    println(builder.toString())

//    pw.flush()
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 60852
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include <functional>
#include <set>
#include <map>
#include <queue>
#include <math.h>
#include <stack>

using namespace std;

long long int cou(long long int a, long long int b) {
	if (a > b) {
		return b;
	}
	else {
		return cou(a, b / a) + b % a;
	}
}
int main() {
	long long int n, s;

	cin >> n;
	cin >> s;
	if (s == n) {
		cout << n + 1;
		return 0;
	}
	if (s > n) {
		cout << "-1";
		return 0;
	}
	int y = sqrt(n);
	for (int i = 2; i < y + 1; i++) {
		if (cou(i, n) == s) {
			cout << i;
			return 0;
		}
	}

	for (int i = y; i > 0; i--) {
		if ((n - s) % i != 0)continue;
		long long int a = (n - s) / i + 1;
		if (cou(a, n) == s) {
			cout << a;
			return 0;
		}
	}
	cout << "-1";
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<set>
#include<queue>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<stack>
#include<unordered_map>
#include<bitset>
using namespace std;
#define MOD 1000000007
#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);i++)
#define REP(i,n) rep(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
typedef vector<ll> Array;
typedef vector<Array> Matrix;

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

	ll n;
	cin >> n;
	Array a(n + 1);
	REP(i, n + 1)cin >> a[i];
	Array b(n);
	ll ans = 0;
	REP(i, n) {
		cin >> b[i];
		ans += min(a[i], b[i]);
		b[i] -= min(a[i], b[i]);
		ans += min(a[i + 1], b[i]);
		a[i + 1] -= min(a[i + 1], b[i]);
	}
	cout << ans << endl;


	return 0;
}

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

#define debug(...) fprintf(stderr, __VA_ARGS__)

#ifndef AT_HOME
#define getchar() IO::myGetchar()
#define putchar(x) IO::myPutchar(x)
#endif

namespace IO {
	static const int IN_BUF = 1 << 23, OUT_BUF = 1 << 23;

	inline char myGetchar() {
		static char buf[IN_BUF], *ps = buf, *pt = buf;
		if (ps == pt) {
			ps = buf, pt = buf + fread(buf, 1, IN_BUF, stdin);
		}
		return ps == pt ? EOF : *ps++;
	}

	template<typename T>
	inline bool read(T &x) {
		bool op = 0;
		char ch = getchar();
		x = 0;
		for (; !isdigit(ch) && ch != EOF; ch = getchar()) {
			op ^= (ch == '-');
		}
		if (ch == EOF) {
			return false;
		}
		for (; isdigit(ch); ch = getchar()) {
			x = x * 10 + (ch ^ '0');
		}
		if (op) {
			x = -x;
		}
		return true;
	}

	inline int readStr(char *s) {
		int n = 0;
		char ch = getchar();
		for (; isspace(ch) && ch != EOF; ch = getchar())
			;
		for (; !isspace(ch) && ch != EOF; ch = getchar()) {
			s[n++] = ch;
		}
		s[n] = '\0';
		return n;
	}

	inline void myPutchar(char x) {
		static char pbuf[OUT_BUF], *pp = pbuf;
		struct _flusher {
			~_flusher() {
				fwrite(pbuf, 1, pp - pbuf, stdout);
			}
		};
		static _flusher outputFlusher;
		if (pp == pbuf + OUT_BUF) {
			fwrite(pbuf, 1, OUT_BUF, stdout);
			pp = pbuf;
		}
		*pp++ = x;
	}

	template<typename T>
	inline void print_(T x) {
		if (x == 0) {
			putchar('0');
			return;
		}
		static int num[40];
		if (x < 0) {
			putchar('-');
			x = -x;
		}
		for (*num = 0; x; x /= 10) {
			num[++*num] = x % 10;
		}
		while (*num){
			putchar(num[*num] ^ '0');
			--*num;
		}
	}

	template<typename T>
	inline void print(T x, char ch = '\n') {
		print_(x);
		putchar(ch);
	}

	inline void printStr_(const char *s, int n = -1) {
		if (n == -1) {
			n = strlen(s);
		}
		for (int i = 0; i < n; ++i) {
			putchar(s[i]);
		}
	}

	inline void printStr(const char *s, int n = -1, char ch = '\n') {
		printStr_(s, n);
		putchar(ch);
	}
}
using namespace IO;

const long long INF = 0x3f3f3f3f3f3f3f3fll;

long long n, A, B, C, D;

std::map<long long, long long> f;

long long calc(long long n, int v) {
	long long dn = n - n / v;
	long long t = v == 2 ? A : (v == 3 ? B : C);
	if (dn > INF / D) {
		return t;
	} else {
		return std::min(t, dn * D);
	}
}

long long DP(long long n) {
	if (n == 0) {
		return 0;
	}
	if (n == 1) {
		return D;
	}
	if (f.count(n)) {
		return f[n];
	}
	long long ans = INF;
	for (int v : {2, 3, 5}) {
		int d = n % v;
		ans = std::min(ans, DP((n - d) / v) + D * d + calc(n - d, v));
		d = (v - d) % v;
		ans = std::min(ans, DP((n + d) / v) + D * d + calc(n + d, v));
	}
	return f[n] = ans;
}

void solve() {
	read(n), read(A), read(B), read(C), read(D);
	f.clear();
	print(DP(n));
}

int main() {
	int T = 1;
	read(T);
	while (T--) {
		solve();
	}
}


Measured memory_bytes: 4336
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

int main(){
	string s;
	cin >> s;
	int first, last;
	for(int i=0; i<s.size(); i++){
		if(s[i] == 'A'){
			first = i;
			break;
		}
	}
	for(int i=s.size()-1; i>=0; i--){
		if(s[i] == 'Z'){
			last = i;
			break;
		}
	}
	cout << last-first+1 << '\n';
	return 0;
}

Measured memory_bytes: 640
s=input()
l=len(s)
i,j=0,-1
first,last=0,0
while True:
    if s[i]=="A":
        first=i
        break
    else:
        i+=1
while True:
    if s[j]=="Z":
        last=l+j
        break
    else:
        j-=1
print(last-first+1)


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

#define ll long long
const int N = 1e5 + 5, mod = 1e9 + 7;

int main(){
    int n, tmp, ans = 0;
    vector<int> V;
    cin>>n;
    for(int i = 0; i < n + n; i++){
        cin>>tmp;
        V.push_back(tmp);
    }
    sort(V.begin(), V.end());
    for(int i = 0; i < n + n; i += 2)  ans += V[i];
    cout<<ans;
}


Measured memory_bytes: 256