akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>

int main() {
	long long N, K, S;
	std::cin >> N >> K >> S;
	//std::vector<long long> A(N);
	if (S == (long long)1e9) {
		for (long long i = 0; i < N; i++) {
			/*if (i < K) {
				A[i] = S;
			}
			else {
				A[i] = 1;
			}*/
			if (i < K) {
				std::cout << S;
			}
			else {
				std::cout << 1;
			}
			if (i != N - 1) {
				std::cout << " ";
			}
			else {
				std::cout << std::endl;
			}
		}
		return 0;
	}
	for (long long i = 0; i < N; i++) {
		if (i < K) {
			std::cout << S;
		}
		else {
			std::cout << S + 1;
		}
		if (i != N - 1) {
			std::cout << " ";
		}
		else {
			std::cout << std::endl;
		}
	}
	return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
int dy[4] = { 1, 0, -1, 0 }, dx[4] = { 0, 1, 0, -1 };
const ll MOD = 1e9 + 7;
const ll INF = 1e9;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, k;
    cin >> n >> k;
    cout << n + 1- k << endl;
    return 0;
}

Measured memory_bytes: 256
s = input()
li = list(s)
#new_li = [False for _ in range((len(li)+1))]
#print(new_li) [False, False, False, False]
tmp = [] #<,>
last_str = ''
memo = []
for i,l in enumerate(li):
    if i == 0:
        tmp.append(l)
        last_str = l
        continue
    if l != last_str:
        memo.append(tmp)
        tmp = [l]
        last_str = l
    else:
        tmp.append(l)
if len(tmp)>0:
    memo.append(tmp)
#print(memo) [['<'], ['>', '>']]
all_count = 0
muki = memo[0][0]
last_len = 0
for mi,m in enumerate(memo):
    all_count += (1+len(m))*len(m)//2
    #print(m,all_count,muki,last_len)
    if muki == '<' and m[0] == '>':
        #print(min(last_len,len(m)))
        all_count -= (min(last_len,len(m)))
    muki = m[0]
    last_len = len(m)
print(all_count)



Measured memory_bytes: 35228
#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;

int main(){
    int k;
    cin>>k;
    vector<ll> a;
    for(int i=1;i<=9;i++) a.push_back(i);

    while(1){
        if(k<=a.size()){
            cout<<a[k-1]<<endl;
            return 0;
        }
        k-=a.size();
        vector<ll> v;
        swap(v,a);
        for(ll x: v){
            for(int i=-1;i<=1;i++){
                int d=x%10+i;
                if(d<0||d>9) continue;
                a.push_back(x*10+d);
            }
        }
    }
}

Measured memory_bytes: 1712
from collections import Counter

N = input()
src = map(int, raw_input().split())
MOD = 10**9+7

counter = Counter(src)
dup = counter.most_common(1)[0][0]
a = src.index(dup)
b = a+1 + src[a+1:].index(dup)
arr = src[:a] + src[b+1:]
n2 = len(arr)

def mul(a,b):
  return (a*b) % MOD

def pow(a,n):
  ans = 1
  mag = a
  for b in reversed(str(bin(n))):
    if b == 'b': break
    if b == '1':
      ans = mul(ans, mag)
    mag = mul(mag, mag)
  return ans

def inv(a):
  return pow(a, MOD-2)

fac = [1]
fac_inv = [1]
for n in range (1,N+2):
  f = mul(fac[n-1], n)
  fac.append(f)
  fac_inv.append(inv(f))

def ncr(n,r):
  return mul(mul(fac[n], fac_inv[n-r]), fac_inv[r])

for i in range(N+1):
    ans = ncr(N+1, i+1)
    if i <= n2:
        ans = (ans - ncr(n2, i)) % MOD
    print ans


Measured memory_bytes: 24636
#include <bits/stdc++.h>
using namespace std;using ll=long long;using uint=unsigned int;using pii=pair<int,int>;using pll=pair<ll,ll>;using ull = unsigned long long;using ld=long double;template<typename T>void _(const char*s,T h){cerr<<s<<" = "<<h<<"\n";}template<typename T,typename...Ts>void _(const char*s,T h,Ts...t){int b=0;while(((b+=*s=='(')-=*s==')')!=0||*s!=',')cerr<<*s++;cerr<<" = "<<h<<",";_(s+1,t...);}// break continue pop_back 998244353
#define int ll
// #define pii pll
#define f first
#define s second
#define pb emplace_back
#define forn(i,n) for(int i=0;i<(n);++i)
#define sz(a)((int)(a).size())
#define sqr(x) ((x)*(x))
struct init{init(){cin.tie(0);iostream::sync_with_stdio(0);cout<<fixed<<setprecision(10);cerr<<fixed<<setprecision(5);}~init(){
#ifdef LOCAL
#define dbg(...) _(#__VA_ARGS__,__VA_ARGS__)
cerr<<"Time elapsed: "<<(double)clock()/CLOCKS_PER_SEC<<"s.\n";
#else
#define dbg(...) 
#endif
}}init;template<typename T,typename U>void upx(T&x,U y){if(x<y)x=y;}template<typename T,typename U>void upn(T&x,U y){if(x>y)x=y;}mt19937 rng(12);const int D=4,dx[]={+1,0,-1,0},dy[]={0,+1,0,-1};
const int N=3e5+5,M=998244353;
int ans=1;
int c[8];
void f(int x){
    int a=7;
    int o=a^(1<<x);
    if(c[o]){
        (ans*=c[o])%=M;
        --c[o];
    }else{
        int y=(x+1)%3;
        if(c[1<<y]){
            (ans*=c[1<<y])%=M;
            c[1<<y]--;
            c[(1<<y)+(1<<x)]++;
        }else{
            (y+=1)%=3;
            if(c[1<<y]){
                (ans*=c[1<<y])%=M;
                c[1<<y]--;
                c[(1<<y)+(1<<x)]++;
            }else{
                c[1<<x]++;
            }
        }
    }
}
int32_t main(){
    int n;
    string s;
    cin>>n>>s;
    for(char i:s){
        if(i=='R'){
            f(0);
        }else if(i=='G'){
            f(1);
        }else{
            f(2);
        }
    }
    forn(i,n)(ans*=(i+1))%=M;
    cout<<ans<<'\n';

    return 0;
}

Measured memory_bytes: 720
s = input().split(" ");
k = int(s[0]);
x = int(s[1]);

sita = x - (k - 1);
ue = x + k - 1;

if sita < -1000000 :
	sita = -1000000;
if ue > 1000000 :
	ue = 1000000;
	

print(sita,end="");
for i in range(sita+1,ue+1) :
	print(" ",i,end="");

Measured memory_bytes: 3064
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		int n = sc.nextInt();
		int[] A = inpNum(n);

		Arrays.sort(A);
		third_p(A);

	}

	private static void third_p(int[] a) {
		int limit = Math.min(a.length, 4);
		List<Integer> conv_num = new ArrayList<Integer>();

		for (int i = 0; i < limit; i++) {
			for (int j = 0; j < limit; j++) {
				if (i == j) {
					continue;
				}

				conv_num.add(a[i] * (int)Math.pow(10, Integer.toString(a[j]).length()) + a[j]);
			}
		}
		Collections.sort(conv_num);
		System.out.println(conv_num.get(2));

	}

	private static int[] inpNum(int n) {
		int[] nums = new int[n];

		for (int i = 0; i < n; i++) {
			nums[i] = sc.nextInt();
		}
		return nums;
	}

}



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

int main()
{
  int N, K;
  cin >> N >> K;
  vector<int> A(N, 0);
  for (int i = 0; i < K; i++)
  {
    int d;
    cin >> d;
    for (int j = 0; j < d; j++)
    {
      int tmpA;
      cin >> tmpA;
      A.at(tmpA-1)++;
    }
  }
  int ans = 0;
  for (int i = 0; i < N; i++)
  {
    if (A.at(i) == 0) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3628
#include <stdio.h>
int main()
{
    int H,W,N,row,col,total_1,total_2;
    scanf("%d%d%d",&H,&W,&N);
    for(row=1; row<=H; row++)
    {
        if(row*W>=N)
        {
            total_1=row;
            break;
        }
    }
    for(col=1; col<=W; col++)
    {
        if(col*H>=N)
        {
            total_2=col;
            break;
        }
    }
    if(total_1<=total_2)
    {
        printf("%d\n",total_1);
    }
    else
    {
        printf("%d\n",total_2);
    }
    return 0;
}


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

int main(){
	int n;
	while(cin >> n){
		while(n > 39){
			n -= 39;
		}
		if(n >= 10){
			printf("3C%d\n", n);
		}else{
			printf("3C0%d\n", n);
		}

	}
}

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

int main()
{
	int N;
	cin >> N;
	vector<int> a(N);
	for (int i = 0; i < N; i++) {
		cin >> a[i]; a[i]--;
	}
	vector<int> used(N);
	int tmp = 0, cnt = 0;
	while (tmp != 1 && used[tmp] == 0) {
		used[tmp] = 1;
		tmp = a[tmp];
		cnt++;
	}
	cout << (tmp == 1 ? cnt : -1) << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define meow(args...) fprintf(stderr, args)
typedef unsigned u32;
typedef long long s64;
typedef unsigned long long u64;
template<class T1, class T2> inline bool cmin(T1 &a, const T2 &b) {return b<a?(a=b, true):false;}
template<class T1, class T2> inline bool cmax(T1 &a, const T2 &b) {return a<b?(a=b, true):false;}
template<class Type> Type read() {
	Type a;
	bool b;
	unsigned char c;
	while(c=getchar()-48, (c>9)&(c!=253));
	for(a=(b=c==253)?0:c; (c=getchar()-48)<=9; a=a*10+c);
	return b?-a:a;
}
int (*rd)()=read<int>;
const u32 P=1e9+7;
inline u32 &inc(u32 &a, u32 b) {return (a+=b)<P?a:(a-=P);}
inline u32 &dec(u32 &a, u32 b) {return (a-=b)&0x80000000?(a+=P):a;}
inline u32 sum(u32 a, u32 b) {return (a+=b)<P?a:a-P;}
inline u32 dif(u32 a, u32 b) {return (a-=b)&0x80000000?a+P:a;}
u64 power(u64 a, int b) {
	u64 ans=1;
	for(; b; a=a*a%P, b/=2) if(b&1) ans=ans*a%P;
	return ans;
}
const int N=2e5+1;
int n, a[N], b[N], cnt[N], rank[N];
u32 bit[N], p[N], invp[N], q[N], invq[N], x[N];
u32 query(int x) {
	u32 ans=0;
	for(; x; x&=x-1) inc(ans, bit[x]);
	return ans;
}
void add(int x, u32 v) {
	for(; x<=n; x+=x&-x) inc(bit[x], v);
}
void clear(int x) {
	for(; x<=n; x+=x&-x) bit[x]=0;
}
int main() {
	n=rd();
	for(int i=1; i<=n; ++i) ++cnt[a[i]=rd()];
	for(int i=1; i<=n; ++i) cnt[i]+=cnt[i-1];
	for(int i=n; i>=1; --i) rank[cnt[a[i]]]=i, b[cnt[a[i]]--]=a[i];
	memset(cnt+1, 0, n*sizeof(int));
	p[0]=q[0]=1;
	for(int i=1; i<=n; ++i) p[i]=p[i-1]*(b[i]-i+1llu)%P;
	if(p[n]==0) puts("0"), exit(0);
	for(int i=1; i<=n; ++i) x[i]=std::max(b[i]-i, 1), q[i]=(u64)q[i-1]*x[i]%P;
	invp[n]=power(p[n], P-2), invq[n]=power(q[n], P-2);
	for(int i=n; i>=1; --i) invp[i-1]=invp[i]*(b[i]-i+1llu)%P;
	for(int i=n; i>=1; --i) invq[i-1]=(u64)invq[i]*x[i]%P;
	u64 invcnt=0;
	for(int i=1; i<=n; ++i) {
		for(int j=a[i]+1; j<=n; j+=j&-j) invcnt+=bit[j];
		for(int j=a[i]; j; j&=j-1) ++bit[j];
	}
	u32 ans=invcnt*2%P;
	memset(bit+1, 0, n*sizeof(int));
	for(int i=1, j=0; i<=n; ++i) {
		if(b[i-1]==i-1) {
			while(j<i-1) clear(rank[++j]);
		} else {
			ans=(ans+(2llu*query(rank[i]-1)+P-query(n))*q[i-1]%P*invp[i])%P;
		}
		add(rank[i], (b[i]-i+1llu)*p[i-1]%P*invq[i-1]%P);
	}
	ans=(ans+(ans&1?P:0llu))/2*p[n]%P;
	printf("%u\n", ans);
	return 0;
}


Measured memory_bytes: 8064
import java.util.Scanner;
public class Main{
	public static void main(String[]args) {
		Scanner sc = new Scanner(System.in);
		String a = sc.next().toUpperCase();
		String b = sc.next().toUpperCase();
		String c = sc.next().toUpperCase();

		String ans = "";

		ans += a.substring(0,1);
		ans += b.substring(0,1);
		ans += c.substring(0,1);
		System.out.println(ans);
	}
}

Measured memory_bytes: 39304
S = input()
l = sorted(list(set(S)))

ans = ""
for i in range(len(l)):
  if ord(l[i]) !=  97 + i:
    ans = chr(97+i)
    break
  elif i == 25 and l[i] == "z":
    ans = "None"

if ans != "":
 print(ans)
else:
  print(chr(ord(l[-1])+1))

Measured memory_bytes: 3188
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func main() {
	n := nextLine()
	ans := ""
	for _, v := range n {
		if "1" == string(v) {
			ans = ans + "9"
		} else {
			ans = ans + "1"
		}

	}
	fmt.Println(ans)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);

    double L;
    cin >> L;
    cout << pow(L / 3.0, 3.0) << endl;
}

Measured memory_bytes: 384
n,m=map(int,input().split())
ans=[0]*2
l=[]
for i in range(n):
    a,b=map(int,input().split())
    l.append((a,b))
l.sort()
for i,j in l:
    if ans[1]+j<=m:
        ans[0]+=i*j
        ans[1]+=j
    else:
        ans[0]+=i*(m-ans[1])
        break
print(ans[0])


Measured memory_bytes: 54160
A=list(input()+"e")[::-1]
B=list(input()+"e")[::-1]
C=list(input()+"e")[::-1]
a,b,c = 0,0,0
p="a"
while p!="e":
    if p=="a":
        p=A.pop()
    elif p=="b":
        p=B.pop()
    else:
        p=C.pop()
if not A:
    print("A")
elif not B:
    print("B")
else:
    print("C")

Measured memory_bytes: 3064
#if 0
??????????????????????????£?????????????????????
??????????????£????????¨????????£???????????§??????
???????????°?´??????§?????£??????????????¨?????£???????????????????????°????????????????????§??????????????????
??????????????????????????????????????¨????????§?????°??????????????????????????¨??????????????????
????????????????????§?????????????????????c??¨i??????????????????????????????
????????????????????§???????????¨??§?????????????????????????????????????????¨????????????????????£????????????????????????
?????????malloc????????£??????????????§?????????????????????4???????????¨???????????¨??????????????????????????????
????????§???c??????????????§malloc??????????????¨?????????????????????????????¨???????????£????????????NEW????????????????????????????????????
???????????§??????bus error????????????google??§???std::vector<info>???????????????????????????segment error 11?????????????????????
????????¢??????????????§????????????????????????c??¨i????????????????????£??????????????¨????°???\?????????
????????????????????????????????£???????????£?????????AC??§?????????????????£?????§?????????
std::vector<???>??¨new,delete????°????????????????????????????????????????
#endif
#include <iostream>
#include <vector>
using namespace std;
struct info{
  int value;
  int weight;
};
int search_value(int i,info *item,int bag_weight);
int V[10002][102];
int main(){
  int N,W;
  int c;
  int V[10002][102];
  cin >> N >> W;
  std::vector<info> item(102);
  for(int i = 1; i <= N; i ++){
    cin >> item[i].value;
    cin >> item[i].weight;
  }
  for(int c = 0; c <= W; c++){
    for(int i = 0; i < N; i++){
      if(i <= 0 || c <= 0)
	V[c][i] = 0;
      if(c - item[i+1].weight < 0)
	V[c][i+1] = V[c][i];
      else{
	if(item[i+1].value + V[c-item[i+1].weight][i] > V[c][i] )
	  V[c][i+1] = item[i+1].value + V[c-item[i+1].weight][i];
	else
	  V[c][i+1] =  V[c][i];}
    }
  }
  cout << V[W][N] <<endl;
  return 0;
}

Measured memory_bytes: 7076
#include<stdio.h>
#include<iostream>
#include<vector>
#include <bits/stdc++.h>
#include <queue>
#include <algorithm>
#include <string>

using namespace std;
typedef long long ll;

#define rep(i,n) for(ll i=0; i<(ll)(n); i++)

int main(){
  ll k; cin>>k;
  string s; cin>>s;
  // vector<ll> a(n);
  // rep(i,n){
  //   cin>>a[i];
  // }
  
  if(s.length()<=k){
    cout<<s;
  }else{
    string ans=s.substr(0,k);
    ans+="...";
     cout<<ans;
  }

 

    
  
  
  return 0;
}

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

using namespace std;
int main() {
  unsigned long long x;
  cin >> x;

  unsigned long long a = 100;
  for (int i = 1;;i++) {
    a = floor(a * 1.01);
    if (a >= x) {
      cout << i;
      return 0;
    }
  }
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
int a[5],ans;
inline int read()
{
	int num=0,flag=1;
	char c=getchar();
	for (;c<'0'||c>'9';c=getchar())
	if (c=='-') flag=-1;
	for (;c>='0'&&c<='9';c=getchar())
	num=(num<<3)+(num<<1)+c-48;
	return num*flag;
}
int main()
{
	for (int i=1;i<=3;++i)
	a[i]=read();
	sort(a+1,a+4);
	ans=a[3]-a[1];
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
// 今日はお盆前の最終出社日です
// いい加減寝ろ

#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};
vector< ll > divisor(ll n) {
  vector< ll > ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

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

    ll a,b,c,d,maxi=0,f=0,mini=INF,sum=0;
    ll n;
    cin>>n;
    vector<ll> v(n);
    rep(i,n)cin>>v[i];
    sort(all(v));
    vector<ll> w=divisor(v[0]);
    vector<ll> x=divisor(v[1]);
    set<ll> s;
    rep(i,w.size()) s.insert(w[i]);
    rep(i,x.size()) s.insert(x[i]);
    map<ll,ll> m;
    rep(i,n){
        for(auto itr=s.begin();itr!=s.end();++itr){
            if(v[i]%*itr==0) m[*itr]++;
        }
    }
    for(auto itr=s.rbegin();itr!=s.rend();++itr){
        //cout<<*itr<<endl;
        if(m[*itr]>=n-1) {
            cout<<*itr<<endl;
            return 0;
        }
    }
    return 0;
}


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

int main(){
  
  int n;
  cin >> n;
  
  vector<int>a(n);
  
  for(int i=0; i<n; i++)cin >> a[i];
  
  int count = 0;
  bool flag = true;
  while(flag){
    for(int i = 0; i<n; i++){
      if(a[i] % 2 == 0){
        a[i] /= 2;
        if(flag == true && i == n-1)count += 1;
      }
      else flag =false;
    }
  }
  
  cout << count << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

ll A[20][20];
ll dp[1<<20];
ll dp2[1<<20];

string print(ll S){
  string ret = "";
  while(S>0){
    if(S%2==0) ret += "0";
    else ret += "1";
    S/=2;
  }
  reverse(ALLOF(ret));
  return ret;
}

int main(){
  int N;
  cin >> N;
  rep(i,N){
    rep(j,N){
      cin >> A[i][j];
    }
  }
  
  for(ll S=0; S<(1<<N); S++){
    vector<int> v;
    ll tmp = S, i = 0;
    while(tmp>0){
      if(tmp%2==1) v.push_back(i);
      tmp/=2;
      i++;
    }
    ll sum = 0;
    rep(j,v.size()){
      REP(k,j+1,v.size()){
        sum += A[v[j]][v[k]];
      }
    }
    dp2[S] = sum;
  }
  
  for(ll S=0; S<(1<<N); S++){
    for(ll T=S; T>0; T=(T-1)&S){
      dp[S] = max(dp[S], dp[S^T] + dp2[T]);
      //cout << print(S) << "\t" << print(T) << "\t" << print(S^T) << "\t" << dp[S^T]+sum << endl;
    }
  }

  cout << dp[(1<<N)-1] << endl;
  
  return 0;
}


Measured memory_bytes: 2816
N=int(input())
x,y=0,0
for i in range(N):
  p=0
  T,A=map(int,input().split())
  if i==0:
    x,y=T,A
    continue
  if x<=T and y<=A:
    x,y=T,A
  elif x<=T and A<y:
    if y%A!=0:
      p=1
    x=T*(y//A+p)
    y=A*(y//A+p)
  elif T<x and y<=T:
    if x%T!=0:
      p=1
    y=A*(x//T+p)
    x=T*(x//T+p)
  else:
    if (x//T+1)<=(y//A+1):
      if y%A!=0:
        p=1
      x=T*(y//A+p)
      y=A*(y//A+p)
    else:
      if x%T!=0:
        p=1
      y=A*(x//T+p)
      x=T*(x//T+p)
print(x+y)

Measured memory_bytes: 9260
#include <iostream>

using namespace std;

unsigned long long t[21] = {0, 1, 2, 6, 24, 120,720, 5040, 40320, 362880, 3628800, 39916800, 479001600, 6227020800, 87178291200, 1307674368000, 20922789888000, 355687428096000, 6402373705728000, 121645100408832000, 2432902008176640000};
int main(void){
    int n;
    cin >> n;
    cout << t[n] << endl;
    return 0;
}

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

int main() {
	int a, b;
	cin >> a >> b;
	if (a < 6) {
		cout << 0 << endl;
	}
	else if (a < 13) {
		cout << b / 2 << endl;
	}
	else {
		cout << b << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
const int INF=0x7fffffff;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define range(a) a.begin(), a.end()
const int N=200020;
int n, a[N];
ll tot, b[N];
int main(){
//	freopen("test.in", "r", stdin);
//	freopen("test.out", "w", stdout); 
	scanf("%d", &n);
	int i;
	for(i=1;i<=n;i++){
		scanf("%d",&a[i]);
		b[a[i]]++;
	}
		
	for(i=1;i<=n;i++)
	{
		if(b[i]==2) tot++;
		else if(b[i]>2) tot+=b[i]*(b[i]-1)/2;	
	}
	
	for(i=1;i<=n;i++)
		printf("%lld\n", tot-(b[a[i]]-1));
	return 0;
}

Measured memory_bytes: 3968
#include <iostream>
#include <string>
#include <map>
#include <algorithm>
#include <math.h>
#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)
using namespace std;
typedef long long ll;
static const ll MOD = 1e9 + 7;

int main() {
	ll n; cin >> n;
	ll w[101] = {};
	ll S[101] = {};
	repe(i, 1, n) {
		cin >> w[i];
		w[i] += w[i - 1];
	}

	ll a = 1e10;
	rep(T, 1, n) {
		ll x = w[T] - w[0];
		ll y = w[n] - w[T];
		a = min(a,abs(x-y));
	}
	cout << a << endl;


	return 0;
}

Measured memory_bytes: 256
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>

auto& in = std::cin;
auto& out = std::cout;

int32_t a, b, c, d;

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> a >> b >> c >> d;
	if (a<c) {}
	else { std::swap(a, c); std::swap(b, d); }

	out << std::max(0, std::min(d,b) - c) << endl;;


	return 0;
}
#endif

Measured memory_bytes: 888
// JAI SHREE RAM
#pragma GCC optimize("O3")
typedef long long int ll;
typedef unsigned long long int ull;
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FOR(i,n) for(int i=0;i<n;i++)
#define MOD 1000000007
#define sz(a) int((a).size())
#define forn(i, n) for (int i = 0; i < (n); ++i)
#define fore(i, l, r) for (int i = int(l); i < int(r); ++i)
#define loop for(int i=0;i<n;i++)
#define max3(a,b,c) max(a,max(b,c))
#define max4(a,b,c,d) max3(a,max(b,c),d)
#define max5(a,b,c,d,e) max4(a,max(b,c),d,e)
#define min3(a,b,c) min(a,min(b,c))
#define min4(a,b,c,d) min3(a,min(b,c),d)
#define min5(a,b,c,d,e) min4(a,min(b,c),d,e)
#define sec second
#define fir first
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repe(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
// #define all(a) (a).begin(),(a).end()
#define vec vector<int>
#define M_PI           3.14159265358979323846  /* pi */
#define pb push_back
#define pii pair<int,int>
#include<bits/stdc++.h>
#include<cmath>
using namespace std;
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	fast
	int a,b,c,k,ans=0;
	cin>>a>>b>>c>>k;
	
		if(k>=a)
		{
			ans+=a;
			k=k-a;
		}
		else
		{
			ans=k;
			cout<<ans<<endl;
			return 0;
		}

		if(k>=b)
			k-=b;
		else
		{
			cout<<ans<<endl;
			return 0;
		}
		
		ans-=k;
	
		cout<<ans<<endl;

	return 0;
}


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

int main() {
    string S, T, subS;
    int count = 0;
    int min = 10000;
    cin >> S >> T;
    
    for (int i = 0; i < S.size() - T.size() + 1; i++) {
        count = 0;
        subS = S.substr(i, T.size());

        for(int j = 0; j < T.size(); j++) {
            if (subS.at(j) - T.at(j) != 0)
                count++;
        }
        if(count < min) 
            min = count;
    }

    cout << min << endl;

    return 0;
}

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main()
{
    string s;
    cin >> s;
    rep(i, s.size())
    {
        if (i % 2 == 0)
            cout << s[i];
    }
    cout << endl;
    return 0;
}

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

#define ASC(vec) vec.begin(), vec.end()    // 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend() // 降順ソート 例：sort(DESC(vec));
#define rep(i, n) for (int i = 0; i < (n); i++)
#define Rep(i, n) for (int i = 1; i < n; i++)
#define REP(i, vec) for (auto i = vec.begin(); i != vec.end(); ++i)

const int       mod = 1000000007;
const int       inf = (1 << 21);
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;
using vll = vector<pair<ll, ll>>;

template<class T>
inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T>
inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T>
T GCD(T a, T b) { if (b == 0) return a; else return GCD(b, a % b); }
template<class T>
T LCM(T a, T b) { return a / GCD(a, b) * b; }
template<class T>
inline T upper(T a, T b) { return (a + (b - 1)) / b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };

// ──────────────────────────────────────────────────────────────────

int n, m;
vector<vector<int>> g;
int ans = 0;

void dfs(int v, map<int, bool> mp, int p = -1) {
	mp[v] = true;

	if (mp.size() == n) ans++;

	for (int nv : g[v]) {
		if (nv == p) continue;
		/*
		if (nv == 0 && p != -1 && mp.size() == n) {
			ans++;
		}
		*/
		if (mp.count(nv) == true) continue;

		
		dfs(nv, mp, v);
	}
}

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

	g.resize(n);
	for (int i = 0; i < m; ++i) {
		int a, b;
		cin >> a >> b;

		a--, b--;

		g[a].push_back(b);
		g[b].push_back(a);
	}

	map<int, bool> mp;
	dfs(0, mp);

	cout << ans << endl;
}

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

ll sumb, sumesq, sumdir;
multiset<ll> esq, dir;

void add(ll val){
    if(esq.empty() and dir.empty()){
        sumdir += val;
        dir.insert(val);
    }
    else if(esq.empty()){
        if(sumdir >= val){
            sumesq += val;
            esq.insert(val);
        }
        else{
            sumesq = sumdir;
            sumdir = val;
            dir.clear();
            esq.insert(sumesq);
            dir.insert(sumdir);
        }
    }
    else{
        ll valesq = *(--esq.end()), valdir = *dir.begin();
        if(val >= valesq){ // go to right
            sumdir += val;
            dir.insert(val);
        }
        else{ // go to left
            sumesq += val;
            esq.insert(val);
        }
        while(dir.size() > esq.size()){
            valdir = *dir.begin();
            dir.erase(dir.begin());
            sumdir -= valdir;
            esq.insert(valdir);
            sumesq += valdir;
        }
        while(esq.size() > dir.size()){
            valesq = *(--esq.end());
            esq.erase(--esq.end());
            sumesq -= valesq;
            dir.insert(valesq);
            sumdir += valesq;
        }
    }
}

ll median(){
    if(esq.size() == dir.size()){
        auto it = --esq.end();
        return *it;
    }
    else if(esq.size() > dir.size()){
        auto it = --esq.end();
        return *it;
    }
    else{
        auto it = dir.begin();
        return *it;
    }
}

int main(){

    ll q; cin >> q;
    while(q--){
        ll op; cin >> op;
        if(op == 1){
            ll a, b; cin >> a >> b;
            add(a);
            sumb += b;
        }
        else{
            ll med = median();
            ll res = med*esq.size()-sumesq + sumdir-med*dir.size() + sumb;
            cout << med << " " << res << endl;
            // cout << "ESQ: ";
            // for(ll val : esq)
            //     cout << val << " ";
            // cout << endl;
            // cout << "DIR: ";
            // for(ll val : dir)
            //     cout << val << " ";
            // cout << endl << endl;
        }
    }
	return 0;
}


Measured memory_bytes: 9600
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cmath>
#include <cassert>
using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> a(N+1);
    for(int i=1; i<=N; i++)
        cin >> a[i];

    vector<int> b(N+1);
    for(int i=N; i>=1; i--){
        int sm = 0;
        for(int j=2*i; j<=N; j+=i){
            sm ^= b[j];
        }
        b[i] = a[i] ^ sm;
    }

    vector<int> ans;
    for(int i=1; i<=N; i++)
        if(b[i])
            ans.push_back(i);

    cout << ans.size() << endl;
    for(int x : ans)
        cout << x << " ";
    cout << endl;

    return 0;
}

Measured memory_bytes: 3064
// ===================================
//   author: M_sea
//   website: http://m-sea-blog.com/
// ===================================
#include <bits/stdc++.h>
#define re register
using namespace std;

inline int read() {
    int X=0,w=1; char c=getchar();
    while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
    while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
    return X*w;
}

const int N=200000+10;

int a[N];

int main() {
    int n=read(),mn=2e9,ans=0;
    for (re int i=1;i<=n;++i) a[i]=read();
    for (re int i=1;i<=n;++i) {
        if (a[i]<mn) ++ans,mn=a[i];
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 1024
class Array
  def diff; (size-1).times.map { |i| self[i + 1] - self[i] }.to_a end
end
INF = 0xffffffffffffffff
# mod = 998244353
# mod = 10 ** 9 + 9
mod = 10 ** 9 + 7
PI = Math::PI
dx = [ 1,  0, -1,  0,  1,  1, -1, -1]
dy = [ 0,  1,  0, -1,  1, -1,  1, -1]
eight = [0, 1, 1, 0, -1, -1, 1, -1, 0]
def max(a,b);       a > b ? a : b                              end
def min(a,b);       a < b ?  a : b                             end
def swap(a,b);      a, b = b, a                                end
def gi;             gets.to_s.to_i                             end
def gf;             gets.to_s.to_f                             end
def gs;             gets.to_s.chomp                            end
def gmi(n=nil); n.nil? ? gets.to_s.split.map{|t|t.to_i} : n.times.map{ gets.to_s.to_i } end
def gmf(n=nil); n.nil? ? gets.to_s.split.map{|t|t.to_f} : n.times.map{ gets.to_s.to_f } end
def gms(n=nil); n.nil? ? gets.to_s.split : n.times.map{ gets.to_s.chomp } end
def ga2i(h);        h.times.map{ gets.to_s.split.map{|t|t.to_i} }      end
def gm(h);        Array.new(h){ gets.to_s.split.map{|t|t.to_i} }      end
def yn(f); puts f ? "Yes" : "No" end
#def YN(f); puts f ? "YES" : "NO" end
def yes(f=nil); f.nil? ? (puts "Yes"; exit) : (puts f ? "Yes" : "No") end
def no(f=nil); f.nil? ? (puts "No"; exit) : (puts f ? "Yes" : "No") end
def yay(f=nil); f.nil? ? (puts "Yay!"; exit) : (puts f ? "Yay!" : ":(") end

def an(n,d=0) Array.new(n,d)end
def an2(n,m,d=0) Array.new(n){an(m,d)}end
def an3(n,m,l,d=0) Array.new(n){an2(m,l,d)}end
def zeros(n); an2(n,n) end
def eye(n); an2(n,n).each_with_index{|e,i|e[i]=1} end # 単位行列 identity matrix
# n = gets.to_s.to_i
# a = gets.to_s.split.map{|t|t.to_i}
# s = gets.to_s.chomp
# m = Array.new(n){ gets.split.map{|t|t.to_i} }

n = gets.to_s.to_i
# s = gets.to_s.chomp
# a = gets.to_s.split.map{|i|i.to_i}

ans = 0
1.upto(n) do |i|
  
  next if i % 3 == 0 || i % 5 == 0
  ans += i
end

puts ans






Measured memory_bytes: 14316
#include <algorithm>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;

int main() {
  ll H, W;
  int N;
  cin >> H >> W >> N;
  set<pair<int, int>> points, events;
  for (int i = 0; i < N; i++) {
    int y, x;
    cin >> y >> x;
    points.insert(make_pair(y, x));
    for (int dy = -2; dy <= 0; dy++) {
      for (int dx = -2; dx <= 0; dx++) {
        events.insert(make_pair(y + dy, x + dx));
      }
    }
  }
  vector<ll> res(10);
  for (auto evt : events) {
    int sy = evt.first, sx = evt.second;
    bool contains = true;
    int cnt = 0;
    for (int dy = 0; dy <= 2; dy++) {
      for (int dx = 0; dx <= 2; dx++) {
        int y = sy + dy, x = sx + dx;
        if (y < 1 || y > H || x < 1 || x > W) {
          contains = false;
          break;
        }
        cnt += points.count(make_pair(y, x));
      }
    }
    if (contains) {
      ++res[cnt];
    }
  }
  res[0] = (H - 2) * (W - 2);
  for (int i = 1; i < 10; i++) {
    res[0] -= res[i];
  }
  for (ll x : res) {
    cout << x << endl;
  }
  return 0;
}


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

int main() {
	int A[5], B[5];
	cin >> A[0] >> A[1] >> A[2] >> A[3] >> A[4];
	int ans = 0;
	for (int i = 0; i < 5; i++) {
		B[i] = (A[i] + 9) / 10 * 10;
		ans += B[i];
	}
	int dif = 0;
	for (int i = 0; i < 5; i++) dif = max(dif, B[i] - A[i]);
	cout << ans - dif << endl;
}

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

int main()
{
  int n, m, ans = 0;
  cin >> n >> m;
  vector<int> v(n + 1, 0);
  for (int i = 0; i < m; i++)
  {
    int l, r;
    cin >> l >> r;
    l--, r--;
    v.at(l)++;
    v.at(r + 1)--;
  }
  for (int i = 1; i <= n; i++)
  {
    v.at(i) += v.at(i - 1);
  }
  for (int i = 0; i < n; i++)
  {
    if (v[i] == m)
      ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3748
#include<stdio.h>

struct tag_suki{
  int food[30];
};

int main()
{
  int n,m;
  int k[30];
  struct tag_suki a[30];
  int i,j;
  int cnt = 0;

  scanf("%d %d",&n,&m);

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

  int c[m]; //kobetu
  for(i=0;i<m;i++){
    c[i]=0;
  }

  for(i=0;i<n;i++){
    for(j=0;j<k[i];j++){
      c[a[i].food[j]-1] += 1;
    }
  }

  for(i=0;i<m;i++){
    if(c[i]==n) cnt++;
  }

  printf("%d",cnt);
  return 0;
}


Measured memory_bytes: 128
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define ll long long

bool bo[233];

inline bool read()
{
	char ch=getchar();
	while (ch!='Y'&&ch!='N') ch=getchar();
	return (ch=='Y');
}

int main()
{
	ll tot=0;
	for (ll i=1;i<=10000000000LL;i*=10)
	{
		cout<<"? "<<i<<endl;
		bo[++tot]=read();
	}
	if (bo[tot]==1)
	{
		for (ll s=10;;s*=10)
		{
			cout<<"? "<<s-1<<endl;
			if (read()) { cout<<"! "<<s/10;return 0; }
		}
	}
	for (ll i=0;i<tot;i++) if (!bo[i+1])
	{
		ll l=1,r=1,ans;
		for (ll j=1;j<=i;j++) r*=10;
		l=r/10;
		while (l<r)
		{
			ll mid=(l+r)>>1;
			cout<<"? "<<mid*10<<endl;
			if (read()) r=mid;
			else l=mid+1;
		}
		cout<<"! "<<l;
		return 0;
	}
	return 0;
}

Measured memory_bytes: 596
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>

using namespace std;

typedef long long ll;
const ll mod=1e9+7;
const ll MAXN=1e5+10;
const ll INF=0x7fffffff;

int a[MAXN],n;

void swp(int x,int y){
	int t=a[x];
	a[x]=a[y];
	a[y]=t;
}
//
//void print(){
//	for(int i=1;i<=n;i++){
//		cout<<a[i]<<" ";
//	}
//	cout<<endl;
//} 

int main()//所有的循环已改正 
{
	cin>>n;
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	int ans=0;
	for(int i=1;i<=n;i++){
		if(a[i]==i){
			swp(i,i+1);
			ans++;
//			print();
		}
	}
	cout<<ans<<endl;
	return 0;
}	 


Measured memory_bytes: 640
N = int(input())
p = [int(x) for x in input().split(' ')]

num = 0
res = 0
for i in range(N):
    if p[i] == i + 1:
        num += 1
    else:
        res += (num + 1) // 2
        num = 0

res += (num + 1) // 2
print(res)


Measured memory_bytes: 13880
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <iomanip>
using namespace std;
using i64 = int64_t;
#define rep(i, j, n) for(int i = (j); i < (n); ++i)
#define rrep(i, j, n) for(int i = (n) - 1; (j) <= i; --i)
constexpr i64 MOD = 1000000007;
constexpr i64 INF = 1LL << 60;

int main() {
	string s, t; cin >> s >> t;

	int ans = 0;
	rep(i, 0, s.size()) {
		if (s[i] != t[i]) ++ans;
	}
	cout << ans;
	return 0;
}

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

int main()
{
	int a, b;
	cin >> a >> b;
	
	if (a == b)
	{
		for (int i = 0; i < a; ++i)
		{
			cout << a;
		}
		cout << endl;
	}
	else if (a > b)
	{
		for (int i = 0; i < a; ++i)
		{
			cout << b;
		}
		cout << endl;
	}
	else if (b > a)
	{
		for (int i = 0; i < b; ++i)
		{
			cout << a;
		}
		cout << endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
import math


def solve():
    abcde = [int(input()) for _ in range(5)]
    if any([str(i)[-1] != "0" for i in abcde]):
        last = min([i for i in abcde if not str(i)[-1] == "0"], key=lambda x: abs(int(str(x)[-1])))
    else:
        last = min(abcde)
    hoge = sum([math.ceil(i / 10) * 10 for i in abcde]) - (math.ceil(last / 10) * 10)
    print(hoge + last)


if __name__ == "__main__":
    solve()


Measured memory_bytes: 3060
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
import math
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
from collections import deque
inf = 10 ** 18
mod = 10 ** 9 + 7
a,b = input().split()
bpre = []
for c in b:
    if c != '.':
        bpre.append(c)
a100 = int(a)
b100 = int(''.join(bpre))
ans = str(a100*b100)
if len(ans) > 2:
    print(ans[:-2])
else:
    print(0)


Measured memory_bytes: 65492
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  for(int n=0;n<10000;n++){
    int za=n*8/100;
    int zb=n*10/100;
    if(a==za&&b==zb){
      cout<<n<<endl;
      return 0;
    }
  }
  cout<<-1<<endl;
  return 0;
}


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

typedef string::const_iterator State;
#define inRange(x,a,b) (a <= x && x <= b)

int p, q, r;

int NOT(int a){
    return 2-a;
}
int AND(int a, int b){
    if(a == 2 & b == 2)     return 2;
    if(a >= 1 && b >= 1)    return 1;
    return 0;
}
int OR(int a, int b){
    if(a == 2 || b == 2)    return 2;
    if(a == 1 || b == 1)    return 1;
    return 0;
}

int formula(State &begin){
    if(inRange(*begin, '0', '2')){
        int ret = (*begin)-'0';
        begin++;
        return ret;
    }
    if(inRange(*begin, 'P', 'R')){
        char c = *(begin);
        begin++;
        if(c == 'P')    return p;
        if(c == 'Q')    return q;
        if(c == 'R')    return r;
    }
    if(*begin == '-'){
        begin++;
        return NOT(formula(begin));
    }
    if(*begin == '('){
        begin++;
        int ret = formula(begin);
        while(true){
            if(*begin == '*'){
                begin++;
                ret = AND(ret, formula(begin));
            }else if(*begin == '+'){
                begin++;
                ret = OR(ret, formula(begin));
            }else{
                break;
            }
        }
        begin++;    // ')'
        return ret;
    }
}

int main(){
    string s;
    while(cin >> s, s != "."){
        int ans = 0;
        for(int i = 0; i < 3; i++){
            for(int j = 0; j < 3; j++){
                for(int k = 0; k < 3; k++){
                    p = i, q = j, r = k;
                    State begin = s.begin();
                    if(formula(begin) == 2) ans++;
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}


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

using namespace std;

int main(){
        char moji;
        string s,t;
        int len,j,flg;
        flg=0;
        j=0;
        cin>>s>>t;
        len=s.size();

        for(int i=0; i<len; i++) {
                while(t[j]==s[(i+j)%len]) {
                        j++;
                        if(j==len) {
                                flg=1;
                                break;
                        }
                }
                j=0;
        }

        if(flg) {
                cout<<"Yes"<<endl;
        }else{
                cout<<"No"<<endl;
        }

}


Measured memory_bytes: 256
n, k = map(int, input().split())
L = [[0, 0] for _  in range(n)]
for i in range(n):
    a, b = map(int, input().split())
    L[i][0] = a
    L[i][1] = b
L.sort()
temp = 0
for i in range(n):
    temp += L[i][1]
    if temp >= k:
        print(L[i][0])
        exit()


Measured memory_bytes: 54304
#include<iostream>
#include<algorithm>

using namespace std;

int p[101] = {};
int q[101] = {};

int main(){
    int X, N = 0;
    cin >> X >> N;
  	if(N == 0){
      cout << X << endl;
      return 0;
    }
    int flag = 1;
    for(int i = 0; i < N; i++){
        cin >> p[i];
        if(p[i] == X){
            flag = 0;
        }
    }
    if(flag){
        cout << X << endl;
        return 0;
    }
    int result = 0;
    for(int i = 0; i < 100; i++){
        flag = 1;
        for(int j = 0; j < N; j++){
            if(p[j] == X - i){
                flag = 0;
                break;
            }
        }
        if(flag){
            cout << X - i << endl;
            return 0;
        }
        flag = 1;
        for(int j = 0; j < N; j++){
            if(p[j] == X + i){
                flag = 0;
                break;
            }
        }
        if(flag){
            cout << X + i << endl;
            return 0;
        }
    }
    return 0;
}

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

int c[100];
bool d[100];
int main() {
	int n, m; scanf("%d%d", &n, &m);
	memset(c, -1, sizeof(c));
	rep(i, m) {
		int a, b; scanf("%d%d", &a, &b); a--; b--;
		for (int j = a; j <= b; j++)c[j] = max(c[j], b);
	}
	int res = 0;
	rep(i, n) {
		if (!d[i]) {
			if (c[i] == -1) {
				puts("Impossible"); return 0;
			}
			res++;
			for (int j = i; j <= c[i]; j++)d[j] = true;
		}
	}
	printf("%d\n", res);
}

Measured memory_bytes: 3224
#include <bits/stdc++.h>
#define range(i, l, r) for(long long int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (long long int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

template <typename S, typename T>
ostream& operator <<(ostream& os, pair<S, T> p) {
    os << "(";
    os << p.first << ", " << p.second;
    return os << ")";
}

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    if (v.size() == 0) return os << "]";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    lint A1, A2, A3; cin >> A1 >> A2 >> A3;
    cout << (A1 + A2 + A3 >= 22 ? "bust" : "win") << "\n";
}

Measured memory_bytes: 256
# ABC167 C

def main():
    n, m, x = map(int, input().split())
    List = []
    
    for _ in range(n):
        tmp = list(map(int, input().split()))
        List.append(tmp)

    minCost = 10**20

    for i in range(1, 2**n):
        #inBit = bin(i)[2:][::-1]
        inBit = ''.join(['{:0', str(n), 'b}']).format(i)[::-1]
        knowledge = [0 for _ in range(m)]
        cost = 0

        for bit in range(len(inBit)):
            if inBit[bit] == '1':
                cost += List[bit][0]
                for j in range(m):
                    knowledge[j] += List[bit][j+1]
        
        requirement = [a >= b for (a, b) in zip(knowledge, [x for _ in range(m)])]
        
        if False not in requirement and cost < minCost:
            minCost = cost
    
    if minCost == 10**20:
        print(-1)
    else:
        print(minCost)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9256
#include <bits/stdc++.h>
using namespace std;
int main() {
	string s;
	cin>> s;
	int f1 = -1, f2 = -1;
	for (register int i = 0; i < s.size(); ++i) if (s[i] == 'C') {
		f1 = i;
		break;
	}
	for (register int i = f1; i < s.size(); ++i) if (s[i] == 'F') {
		f2 = i;
		break;
	}
	if (f1 != -1 && f2 != -1 && f1 < f2) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
def gcd(a, b)
        while a % b != 0
                work = b
                b = a % b
                a = work
        end
        b
end

n = gets.chomp.to_i
a = gets.chomp.split(' ').map{|i| i.to_i}
lcm = a[0]
a.each do |i|
        lcm = lcm * i / gcd(lcm, i)
end
lcm -= 1
f = 0
a.each do |i|
        f += lcm % i
end
puts f


Measured memory_bytes: 20732
#include<bits/stdc++.h>
using namespace std;
int N, R;
bool fie[55][55];
int dx[]={0,1,0};
int dy[]={-1,0,1};
bool used[55][55];
typedef complex<double> P;
const double EPS = 1e-8;
bool check(int x,int y,int d){
  if( 0 <= x && x <= 44 && 0 <= y && y <= 44 ){
    if(!used[x][y]){
      if( d == 0 ) return !fie[x-1][y] || !fie[x][y];
      else if( d == 1 ) return !fie[x-1][y];
      else return true;
    }
  }
  return false;
}

double solve( P p,const vector<P>& ep ){
  double x = abs(p.real()-22);
  if( (int)x > R ) return -R;
  P v = P(22, p.imag() - sqrt(R*R - x*x) );  
  for(int i=0;i<(int)ep.size();i++){
    if( (double)R - EPS > abs( ep[i] - v ) ) return -R;
    if( ep[i].real() == 22 && ep[i].imag() < v.imag() ) return -R;
  }
  return v.imag();
}

int main(){
  int cnt = 0;
  while( cin >> R >> N && (N|R) ){
    cnt++;
    double ra = R;
    memset(fie,0,sizeof(fie));
    for(int i=0;i<N;i++){
      int xr,xl,h;
      cin >> xr >> xl >> h;
      xr+=22; xl+=22;
      for(int j=xr;j<xl;j++)
	for(int l=0;l<h;l++)
	  fie[j][l] = true;      
    }
    
    memset(used,0,sizeof(used));
    vector<P> ep;
    int x=1,y=0;
    while( !(x == 44 && y == 0) ){
      used[x][y] = true;
      ep.push_back( P( x, y ) );
      for(int i=0;i<3;i++){
	int nx = x+dx[i], ny = y+dy[i];
	if( check(nx,ny,i) ){	  
	  x = nx; y = ny;
	  break;
	}       
      }
    }

    double res = -ra;
    for(int i=0;i<(int)ep.size();i++){
      res = max( res, solve(ep[i],ep) );      
    }
    printf("%.4lf\n", res + R );
  }
}

Measured memory_bytes: 1284