akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define MMP(a, b, c) make_pair(make_pair(a, b), c)
#define MAX 1000000000
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define PI 3.14159265359

int main(){
    iostream::sync_with_stdio(false);
    
	int N;
	cin >> N;
	string S;
	cin >> S;
	int ans = 0;
	for(int i=0; i<N-1; i++){
		if(S[i] != S[i+1]){
			ans++;
			i++;
		}
	}
	cout << ans << endl;
    
    return 0;
}



Measured memory_bytes: 3364
fn main() {
    let s = read::<String>();
    let mut v: Vec<char> = Vec::new();
    for (i, c) in s.char_indices() {
        if i == 3 {
            v.push('8');
        } else {
            v.push(c);
        }
    }

    println!("{}", v.into_iter().collect::<String>());
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().parse().ok().unwrap()
}

Measured memory_bytes: 4352
def g(x):
  S=format(x,"22b")
  cnt=0
  for i in range(20):
    if S[-1-i]=="1":
      cnt=cnt+1
  return x%cnt

n=int(input())
X=input()
a=0
for i in range(n):
  if X[i]=="1":
    a=a+1
#最初に割るのは a-1 or a+1 -> a==0,1 に注意
if a==0:
  for i in range(n):
    print(1)
  exit()
if a==1:
  if X[-1]=="1":
    for i in range(n-1):
      print(2)
    print(0)
    exit()
  else:
    for i in range(n-1):
      if X[i]=="1":
        print(0)
      else:
        print(1)
    print(2)
    exit()
D=[0]*n
E=[0]*n
D[0]=1%(a-1)
E[0]=1%(a+1)
b=int(X[-1])%(a-1)
c=int(X[-1])%(a+1)
for i in range(n-1):
  D[i+1]=(D[i]*2)%(a-1)
  E[i+1]=(E[i]*2)%(a+1)
  if X[-2-i]=="1":
    b=(b+D[i+1])%(a-1)
    c=(c+E[i+1])%(a+1)
for i in range(n):
  if X[i]=="1":
    x=(b+a-1-D[-1-i])%(a-1)
    ans=1
    while x!=0:
      x=g(x)
      ans=ans+1
    print(ans)
  else:
    x=(c+E[-1-i])%(a+1)
    ans=1
    while x!=0:
      x=g(x)
      ans=ans+1
    print(ans)

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

int main(){
    
    long long n; cin >> n;
    long long a = 1LL, b = 1LL;
    //cout << floor(3) << endl;
    for(long long i = 0; i < n; i++){
        long long A, B; cin >> A >> B;
        long long n = max((a + A - 1) / A, (b + B - 1) / B);
        a = n*A;
        b = n*B;
        //cout << n << " " << a << " " << b << endl;
    }

    cout << a + b << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

template <typename T> inline void voutput(T &v){
    rep(i, v.size()){
        if (i) cout << " " << v[i];
        else cout << v[i];
    }
    cout << endl;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int N;
    int K;
    cin >> N >> K;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    sort(all(A));
    reverse(all(A));
    ll sum = 0;
    rep(i, N) sum += A[i];
    vector<int> dp(K, 0);
    dp[0] = 1;
    int ret = 0;
    
    rep(i, N){
        bool need = false;
        rep(j, K){
            if(dp[j] && sum + j >= K) need = true;
        }
        if(!need) ret++;
        sum -= A[i];
        for(int j = K - 1; j >= A[i]; j--){
            dp[j] |= dp[j - A[i]];
        }
//        voutput(dp);
    }
    output(ret);
    
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#define LEN 100
#define NIL -1
using namespace std;

int INFTY = 2000;
int w[LEN][LEN];
int color[LEN];
int n;
int WHITE = 0;
int BLACK = 1;
 
int prim(int x)
{
    int res = 0;
    int cnt = 1;
    color[x] = BLACK;
    while (cnt++ != n) {
        int minCost = INFTY;
        int pos = 0;
        for (int i = 0; i < n; i++) {
            if (color[i] != BLACK) continue;
            for (int j = 0; j < n; j++) {
                if (color[j] != WHITE) continue;
                if (w[i][j] < minCost) {
                    pos = j;
                    minCost = w[i][j];
                }
            }
        }
        res += minCost;
        color[pos] = BLACK;
    }
    return res;
}
 
int main()
{
    cin >> n;
    int num;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            cin >> num;
            if (num == NIL) w[i][j] = INFTY;
            else w[i][j] = num;
        }
    }
    cout << prim(0) << endl;
    return 0;
}



Measured memory_bytes: 3104
package main

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

var sc = bufio.NewScanner(os.Stdin)

var border = int64(math.Pow10(18))

func Nextint64() int64 {
	sc.Scan()
	i, e := strconv.ParseInt(sc.Text(), 10, 64)
	if e != nil {
		panic(e)
	}
	return i
}

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

func main() {
	sc.Split(bufio.ScanWords)
	n := NextInt()
	var ans int64
	var alist = make([]int64, n)
	ans = 1
	for i := 0; i < n; i++ {
		a := Nextint64()
		if a == int64(0) {
			ans = 0
		}
		alist[i] = a
	}
	if ans != 0 {
		for _, x := range alist {
			if ans > border/x {
				ans = -1
				break
			}
			ans *= x
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 5852
h,n = gets.to_s.split.map{ |v| v.to_i }

# dp[与えたダメージ] := 使った魔力の最小値
# dp[0] := 0, dp[i] := inf
# dp[i] chmin= dp[i - a] + b

dp = Array.new(h+1, 1<<60)
dp[0] = 0

n.times do
  a,b = gets.to_s.split.map{ |v| v.to_i }
  1.upto(h) do |i|
    dp[i] = [
      dp[i],
      dp[[i - a, 0].max] + b
    ].min
  end
end

pp dp[-1]

Measured memory_bytes: 14576
N = int(input())
A = list(map(int, input().split()))
A.sort()
def divisors(n):
    div = set()
    A = 1
    while A*A <= n:
        if n%A == 0:
            if A*A == n:
                div.add(A)
            else:
                B = n//A
                div.add(A)
                div.add(B)
        A += 1
    return div
div = list(divisors(A[0]) | divisors(A[1]))
div.sort(reverse=True)
for x in div:
    count = 0
    for a in A:
        if a%x != 0:
            count += 1
        if count > 1:
            break
    if count <= 1:
        print(x)
        break

Measured memory_bytes: 14428
#include <bits/stdc++.h>
using i64 = long long;

std::vector<std::vector<int>> g, d;
std::vector<int> ls;

void dfs(int v, int p, int t) {
    if (g[v].size() == 1) ls.push_back(v);
    for (int c : g[v]) {
        if (c == p) continue;
        d[t][c] = d[t][v] + 1;
        dfs(c, v, t);
    }
}

int main() {
    int n, s, t;
    std::cin >> n >> s >> t;
    --s; --t;
    g.resize(n); d.resize(2, std::vector<int>(n));
    for (int i = 1; i < n; i++) {
        int a, b;
        std::cin >> a >> b;
        --a; --b;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    dfs(s, -1, 0);
    dfs(t, -1, 1);

    int ret = 0, par = d[0][t] % 2;
    for (int v : ls) {
        if (d[0][v] >= d[1][v]) continue;
        if ((d[1][v] - d[0][v]) % 2 == par) v = g[v].front();
        ret = std::max(ret, d[1][v]);
    }

    std::cout << ret << std::endl;

    return 0;
}


Measured memory_bytes: 11896
import java.util.*;
public class Main{
  static Scanner sc = new Scanner(System.in);
  int [] owned_stones;
	public static void main(String [] args){
    while(true){
      int candidates = sc.nextInt();
      int stones = sc.nextInt();
      int ans;
      if(candidates == 0 && stones == 0){
        break;
      }
      ans = solve(candidates, stones);
      System.out.println(ans);
    }
	}

  static int solve(int candidates, int stones){
    int current_stones = stones;
    int[] owned_stones = new int[candidates];
    int i = 0;
    int candidates_num;
    while(true){
      candidates_num = i % candidates;
      if(current_stones > 0){
        current_stones--;
        owned_stones[candidates_num] += 1;
        if(current_stones == 0){
          if(owned_stones[candidates_num] == stones){
            break;
          }
        }
      }else{
        current_stones = owned_stones[candidates_num];
        owned_stones[candidates_num] = 0;
      }
      i++;
    }
    return candidates_num;
  }
}

Measured memory_bytes: 20180
import std.stdio, std.conv, std.string, std.array, std.math, std.regex, std.range, std.ascii, std.numeric, std.random;
import std.typecons, std.functional, std.traits,std.concurrency;
import std.algorithm, std.container;
import core.bitop, core.time, core.memory;
import std.bitmanip;
import std.regex;

enum INF = long.max/3;
enum MOD = 10L^^9+7;

//辞書順順列はiota(1,N),nextPermituionを使う


void end(T)(T v)
if(isIntegral!T||isSomeString!T||isSomeChar!T)
{
    import core.stdc.stdlib;
    writeln(v);
    exit(0);
}

T[] scanArray(T = long)()
{
    static char[] scanBuf;
    readln(scanBuf);
    return scanBuf.split.to!(T[]);
}

dchar scanChar()
{
    int c = ' ';
    while (isWhite(c) && c != -1)
    {
        c = getchar;
    }
    return cast(dchar)c;
}

T scanElem(T = long)()
{
    import core.stdc.stdlib;
    static auto scanBuf = appender!(char[])([]);

    scanBuf.clear;

    int c = ' ';
    while (isWhite(c) && c != -1)
    {
        c = getchar;
    }
    while (!isWhite(c) && c != -1)
    {
        scanBuf ~= cast(char) c;
        c = getchar;
    }
    return scanBuf.data.to!T;
}

dchar[] scanString(){
    return scanElem!(dchar[]);
}


void main()
{
  max(0, scanElem-scanElem).writeln;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
L_list = [0]*m
R_list = [0]*m
for i in range(m):
    L, R = map(int, input().split())
    L_list[i] = L
    R_list[i] = R
LR_intersection = min(R_list) - max(L_list)
if LR_intersection >= 0:
    print(LR_intersection+1)
else:
    print(0)

Measured memory_bytes: 45400
#include <stdio.h>

int main(void){
    int a,b;
    do{
        scanf("%d %d",&a,&b);
        if(a== 0 && b == 0){
            break;
        }else if( a > b){
            int tmp = a;
            a = b;
            b = tmp;
        }
        printf("%d %d\n", a,b);
    }while(a != 0 || b != 0);
    return 0;
}


Measured memory_bytes: 1996
// J'aime
// Chemise Blanche

#include <bits/stdc++.h>
using namespace std;

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr << __LINE__ << " > " << #x << " = " << (x) << endl

void MAIN() {
  int n; cin >> n;
  vector<int> a(n);
  for (auto &i : a) cin >> i;
  sort(all(a));
  int ans = 0;
  for (int i = 0; i < n - 2; i++)
  for (int j = i + 1; j < n - 1; j++)
  for (int k = j + 1; k < n; k++) {
    if (a[i] != a[j] && a[j] != a[k] && a[k] != a[i]) {
      if (a[k] < a[i] + a[j]) {
        ans++;
      }
    }
  }
  cout << ans << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0; i < (ll)(n); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1LL << 60;
int main(){
    int n;
    string s;
    cin >> n >> s;
    vector<int> v(n),e(n),w(n);
    rep(i,n){
        if(s[i]=='E'){
            if(!i) e[i]=1;
            else e[i] = e[i-1]+1;
        }else{
            if(!i) e[i]=0;
            else e[i] = e[i-1];
        }
    }
    for(int i=n-1; i>=0; i--){
        if(s[i]=='W'){
            if(i==n-1) w[i]=1;
            else w[i] = w[i+1]+1;
        }else{
            if(i==n-1) w[i]=0;
            else w[i] = w[i+1];
        }
    }
    rep(i,n){
        if(i!=0) v[i]+=e[i-1];
        if(i!=n-1) v[i]+=w[i+1];
    }
    int mx = -1;
    int midx = -1;
    // rep(i,n) cout << v[i] << " ";
    // cout << endl;
    rep(i,n) if(v[i]>mx){
        mx = v[i];
        midx = i;
    }
    cout << n-1-mx << endl;
    return 0;
}

Measured memory_bytes: 4228
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<cmath>
#include<cstring>
#include<set>
#include<climits>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define all(a) a.begin(),a.end()
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define size(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*pi*/double pi=acos(-1);
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
/*Fibonacci数列*/ll fib(ll x){ll i,fibo[x+10];fibo[0]=1;fibo[1]=1;fibo[2]=1;rep(i,3,x+1)fibo[i]=fibo[i-1]+fibo[i-2];return fibo[x];}
/*桁数*/ll dig(ll n){ll d=0,i=0;while(n/10>0){i++;d++;}return d;}
llfor;ll ans=0;////////////////////////////////////////////////////////////
int main(){
 char t[20];
 sc(t);
 ll len=strlen(t);
 rep(i,0,len){
  if(i>0&&t[i]=='B'){
   rep(j,1,i+1){
   if(t[i-j]!='B'){
    t[i-j]='B';break;
    }
   }
  }
 }
 rep(i,0,len){
  if(t[i]!='B')cout<<t[i];
 }
 return 0; }



Measured memory_bytes: 3640
import java.io.InputStreamReader
import java.io.BufferedReader

fun main(args: Array<String>) {
  val mod = 1000000007
  val br = BufferedReader(InputStreamReader(System.`in`))

  val(n, m) = br.readLine().split(" ").map { it.toInt() }
  val isBroken = (1..m).map { br.readLine().toInt() }.toSet()

  val dp = IntArray(n+2)
  dp[0] = 1
  for(i in 0..n-1) {
    if(isBroken.contains(i))
      continue

    dp[i+1] = (dp[i+1] + dp[i]) % mod
    dp[i+2] = (dp[i+2] + dp[i]) % mod
  }

  val ans = dp[n]
  println(ans)
}

Measured memory_bytes: 46392
import sys
input = sys.stdin.readline


N = int(input())
S = list(input().rstrip())

one = set()
two = set()
thi = set()
for s in S:
    for t in two:
        thi.add(t+s)
    for o in one:
        two.add(o+s)
    one.add(s)

print(len(thi))

Measured memory_bytes: 9252
x,y=map(int,input().split())
l=[1,3,5,7,8,10,12]
m=[4,6,9,11]
n=[2]
if x in l:
    if y in l:
        print("Yes")
        import sys
        sys.exit()
if x in m:
    if y in m:
        print("Yes")
        import sys
        sys.exit()
print("No")

Measured memory_bytes: 3060
import math


def main():
    t = []
    for i in range(5):
        t.append(int(input()))

    max_wait = 0
    max_wait_order = 0
    for i in range(len(t)):
        if t[i] % 10 != 0 and 10 - (t[i] % 10) >= max_wait:
            max_wait = 10 - t[i] % 10
            max_wait_order = i

    time = 0
    for i in range(len(t)):
        if i == max_wait_order:
            continue
        else:
            time += math.ceil(t[i] / 10) * 10
    time += t[max_wait_order]

    print(time)


if __name__ == '__main__':
    main()


Measured memory_bytes: 61968
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

void solve()
{
	vector<int> wVec(10);
	vector<int> kVec(10);
	for(int i = 0; i < 10; ++i)
	{
		cin >> wVec[i];
	}
	for(int i = 0; i < 10; ++i)
	{
		cin >> kVec[i];
	}
	sort(wVec.begin(), wVec.end());
	sort(kVec.begin(), kVec.end());
	cout << wVec[wVec.size() - 1] + wVec[wVec.size() - 2] + wVec[wVec.size() - 3] << " " << kVec[kVec.size() - 1] + kVec[kVec.size() - 2] + kVec[kVec.size() - 3] << endl;
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1212
//author:emre yazicioglu

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
#define fori(a,b,c) for(ll a = b;a < ll(c); a++)
#define ford(a,b,c) for(ll a = b;a >= ll(c); a--)
#define fi p[i].first
#define se p[i].second.first
#define th p[i].second.second

const int N = 1e5 + 7;
ll n,s,w[N],v[N],dp[105][N];

ll ks(ll cur, ll rem){
	if(cur == n + 1)
		return 0;
	if(dp[cur][rem] != -1)
		return dp[cur][rem];
	dp[cur][rem] = 0;
	dp[cur][rem] = ks(cur + 1, rem);
	if(rem >= w[cur])
		dp[cur][rem] = max(dp[cur][rem], ks(cur + 1, rem - w[cur]) + v[cur]);
	return dp[cur][rem];
}

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

	// freopen("../in.txt","r",stdin);
	// freopen("../out.txt","w",stdout);
	
	memset(dp, -1, sizeof dp);
	cin >> n >> s;
	fori(i,1,n + 1)
		cin >> w[i] >> v[i];
	cout << ks(1, s);
	
}

Measured memory_bytes: 82304
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <istream>
#include <iterator>
#include <sstream>
#include <list>
#include <map>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iomanip>
#define BR "\n"
#define REP(i,n) for(int (i)=0;(i)<(n);++(i))
#define ALL(cont) begin(cont),end(cont)
#define AS_MOD(a,b) ((((a) % (b) ) + (b)) % (b))
#define FEACH(it,cont) for(auto (it) = begin(cont); it!=end(cont);++it)
#define FEACHR(it,cont) for(auto (it) = rbegin(cont); it!=rend(cont);++it)
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define getll() ([](){ll s;scanf("%lld", &s);return s;})()
#define getld() ([](){ld s;scanf("%Lf", &s);return s;})()
#define prl(P) printf("%lld", P)
#define prd(P) printf("%.10Lf", P)
#define pr(P) printf(P)
#define MAX(V, T) V=max(V,T)

#define DumpArray(cont,from,to) for(int __i=from;__i<to;++__i) {cout<<"(" <<__i<<": " << cont[__i]<<")";} cout<<endl;

using namespace std;
typedef long long ll;
typedef long double ld;
int N;
vector<int> P;
int main() {
    cin >> N;
    P.resize(N);
    REP(i,N){
        cin >> P[i];
    }
    int ans=0;
    for(int i=1;i<N-1;++i){
        set<int> C;
        C.insert(P[i-1]);
        C.insert(P[i]);
        C.insert(P[i+1]);
        if (P[i]!=*C.begin() && P[i]!=*C.rbegin()){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		int p=sc.nextInt();
		
		int x=a*3;
		int ans=(p+x)/2;
		System.out.println(ans);
	}
}


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

int main(){
  int n,x,i,cur=0,ans=1;
  cin >> n >> x ;
  
  while(cur<=x && ans<=n){
    cin >> i;
    cur+=i;
    if(cur>x) break;
    ans++;
  }
  cout << ans;
}

Measured memory_bytes: 256
// ITP1_4_A:   A / B Problem
#include <stdio.h>
#include <stdlib.h>

int main()
{
	int a, b;

	scanf("%d%d", &a, &b);
	printf("%d %d %lf\n", a/b, a%b, (double)a/b);
	return 0;
}



Measured memory_bytes: 2048
temp = input().split(" ")

a = int(temp[0])
b = int(temp[1])
c = int(temp[2])
k = int(temp[3])

if a > k:
    print(k)
else:
    if a + b > k:
        print(a)
    else:
        m = k - a - b
        print(a - m)

Measured memory_bytes: 9192
while True:
	a, op, b = input().split()
	a = int(a)
	b = int(b)
	if op == "+":
		print(a + b)
	elif op == "-":
		print(a - b)
	elif op == "*":
		print(a * b)
	elif op == "/":
		print(a // b)
	elif op == "?":
		break

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

int main() {
    ll L, R;
    cin >> L >> R;
    ll ans = 2019;
    ll mod = 2019;
    if ((L % mod == 0 || R % mod == 0)
    || (L / mod != R / mod)) {
        ans = 0;
    } else {
        for (int i = L; i < R; ++i) {
            for (int j = L + 1; j <= R; ++j) {
                ll preans = ((i % mod) * (j % mod)) % mod;
                ans = min(ans, preans);
            }
        }
    }
    cout << ans << endl;
}


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

using namespace std;

typedef long long lli;
typedef double lld;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<double> vdl;
typedef vector<vector<lli>> mat;
typedef vector<vdl> mad;
typedef unordered_map<lli,unordered_map<lli,lli>> graph;
typedef complex<double> cmp;
typedef vector<cmp> vcl;

lli n,k;
vll a;


int main(){
  cin >> n >> k;
  a = vll(n);
  for(lli i = 0;i < n;i++) cin >> a[i];
  if((n-1)%(k-1)) cout << (n-1)/(k-1)+1 << endl;
  else cout << (n-1)/(k-1) << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
//#include <string>
//#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
#define MOD 1000000007
//#define MAX 100100
//#define NIL -1

int main() {
    int n;
    cin >> n;
    vector<LL> a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    LL ans=1;
    vector<LL> rgb(3, 0);
    for(int i=0; i<n; i++){
        LL tmp=0;
        for(int j=0; j<3; j++){
            if(a[i]==rgb[j]){
                tmp++;
            }
        }
        ans=(ans*tmp)%MOD;
        for(int j=0; j<3; j++){
            if(a[i]==rgb[j]){
                rgb[j]++;
                break;
            }
        }
    }

    //for(int i=0; i<3; i++){
    //    cout << rgb[i] << endl;
    //}

    cout << ans << endl; 

    return 0;
}

Measured memory_bytes: 1024
import java.util.*;
import static java.lang.System.*;
import java.math.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		String s = sc.next();
		if(a >= 3200)
			out.println(s);
		else
			out.println("red");
	}
}

Measured memory_bytes: 21844
/*author: hyperion_1724
  date: 
*/

//Optional FAST

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")

//Required Libraries

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define trav(x,A) for(auto &x:A)
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef vector<int> veci;
typedef vector<long long> vecl;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);

//Required Functions

ll power(ll x,ll y) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2) % MOD; 
    p = (p * p) % MOD; 
  
    return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work

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

    READV(A1);
    READV(A2);
    READV(A3);
    if (A1+A2+A3>=22)
    {
        cout<<"bust"<<endl;
    }
    else
    {
        cout<<"win"<<endl;
    }
    
    

    return 0;
}

Measured memory_bytes: 256
n = int(input())
print(0)
s = input()
if s == "Vacant":
    exit()
elif s == "Male":
    print(n-1)
    s = input()
    if s == "Vacant":
        exit()
    else:
        l = 0
        r = n-1
        while True:
            m = (l+r)//2
            print(m)
            s = input()
            if s == "Vacant":
                exit()
            if m % 2 == 0 and s == "Male":
                l = m
            elif m % 2 == 1 and s == "Female":
                l = m
            else:
                r = m
elif s == "Female":
    print(n-1)
    s = input()
    if s == "Vacant":
        exit()
    else:
        l = 0
        r = n-1
        while True:
            m = (l+r)//2
            print(m)
            s = input()
            if s == "Vacant":
                exit()
            if m % 2 == 0 and s == "Male":
                r = m
            elif m % 2 == 1 and s == "Female":
                r = m
            else:
                l = m


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

typedef long long ll;

const int INF = 100000000;

int main() {
    int N, M;
    int k;
    int ans = 0;
    cin >> N >> M;
    vector<vector<int>>s(M);
    vector<int>p(M);

    for (int i = 0; i < M; i++) {
        cin >> k;
        vector<int>v(k);
        for (int j = 0; j < k; j++) {
            cin >> v[j];
        }
        s[i] = v;
    }

    for (int i = 0; i < M; i++) {
        cin >> p[i];
    }

    for (int bits = 0; bits < (1<<N); bits++) {
        bool ok = true;

        vector<int>v;
        for (int i = 0; i < N; i++) {
            if (bits & (1<<i)) {
                v.push_back(i+1);
            }
        }
        for (int i = 0; i < M; i++) {
            int sum = 0;
            for (int j = 0; j < s[i].size(); j++) {
                for (int k = 0; k < v.size(); k++) {
                    if (s[i][j] == v[k]) {
                        sum++;
                    }
                }
            }
            if (sum % 2 != p[i]) {
                ok = false;
            }
        }
        if (ok) {
            ans++;
        }
    }
    cout << ans << endl;
}


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

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

	string s;
	cin >> s;
	int N = s.length() / 2 - 1;
	for(;;) {
		int t = N;
		for (int i = 0; i < N; i++) {
			if (s[i] != s[i + N]) {
				N--;
				break;
			}
		}
		if (t == N) {
			cout << 2 * N;
			return 0;
		}
	}
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#define PI 3.1415926535
int dim;

void Koch(double x1, double y1, double x2, double y2, int dim){
  double x3=0, y3=0, x4=0, y4=0, x5=0, y5=0;
  double s , c;
    
  if(dim != 0){
    s = sin(PI/3);
    c = cos(PI/3);
  
    x3 = ( 2*x1 +   x2 ) / 3;
    y3 = ( 2*y1 +   y2 ) / 3;
    x5 = (   x1 + 2*x2 ) / 3;
    y5 = (   y1 + 2*y2 ) / 3;
    x4 = x3 + (x5-x3)*c + (y5-y3)*s;
    y4 = y3 - (x5-x3)*s + (y5-y3)*c;
    Koch( x1, y1, x3, y3, dim-1 );
    printf("%1.8f %1.8f\n",x3,fabs(y3));
    Koch( x3, y3, x4, y4, dim-1 );
    printf("%1.8f %1.8f\n",x4,fabs(y4));
    Koch( x4, y4, x5, y5, dim-1 );
    printf("%1.8f %1.8f\n",x5,fabs(y5));
    Koch( x5, y5, x2, y2, dim-1 );
  }
  return;
} 
int main(){
  int i;
  double x1=0,y1=0,x2=100,y2=0;
    
  scanf("%d",&dim);
  
  printf("%1.8f %1.8f\n",x1,y1);
    
  if(0<=dim || dim<=6){
    Koch(x1,y1,x2,y2,dim);
  }
    
  printf("%1.8f %1.8f\n",x2,y2);
    
  return 0;
}
  
  
 

Measured memory_bytes: 640
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
using ll = long long;
using ull = unsigned long long;
using vl = vector<ll>;
using vi = vector<int>;
using vchar = vector<char>;
using vstr = vector<string>;
using pll =  pair<ll,ll>;
 
const ll mod = 1000000007;
const ll inf = 1000000000000000;
 
#define pi acos(-1)
#define pb push_back
#define test int TEST;cin>>TEST;while(TEST--)
#define vsort(xx) sort(xx.begin(),xx.end())
#define vrevsort(xx) sort(xx.rbegin(),xx.rend())
 
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    long n,m;cin>>m>>n;
  ll sum=0;
  int ele;
  while(n--) {cin>>ele;sum+=ele;}
  (m - sum >=0)?cout<<m-sum:cout<<-1;
   
    return 0;
}
 
 

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

int main() {
  int N, K;
  
  cin >> N >> K;
  
  int H[N];
  long long T;
  
  for (int i=0; i<N; i++){
    cin >> H[i];
  }
  
  sort (H, H+N);
  
  T=0;
  
  for (int i=0; i<N-K; i++){
    T += H[i];
  }
  
  cout << T << endl;

}





Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
template <class T> int size(const T &x) { return x.size(); }
#define rep(i,a,b) for (__typeof(a) i=(a); i<(b); ++i)
#define iter(it,c) for (__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++it)
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long long ll;
const int INF = 2147483647;

int main() {
    int n, k;
    cin >> n >> k;
    if (!(2 <= k && k <= 2*n-2)) {
        cout << "No" << endl;
        return 0;
    }

    cout << "Yes" << endl;

    list<int> bel, abo;
    rep(i,1,2*n) {
        if (i == k) continue;
        if (i <= n) {
            bel.push_back(i);
        } else {
            abo.push_back(i);
        }
    }

    if (size(bel) > size(abo)) {
        abo.push_front(bel.back());
        bel.pop_back();
    }
    if (size(bel) < size(abo)) {
        bel.push_back(abo.front());
        abo.pop_front();
    }

    if (bel.back() > k) {
        bel.push_back(bel.front());
        bel.pop_front();
    }
    if (abo.front() < k) {
        abo.push_front(abo.back());
        abo.pop_back();
    }

    iter(it,bel) {
        cout << *it << endl;
    }
    // cout << endl;

    cout << k << endl;
    // cout << endl;

    iter(it,abo) {
        cout << *it << endl;
    }

    return 0;
}



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

int main() {
  int N;
  cin >> N;
  int P[N];
  for (int i = 0; i < N; i++) cin >> P[i];
  int n = 0, min_p = 2147483647;
  for (int i = 0; i < N; i++) {
    if (P[i] <= min_p) {
      min_p = P[i];
      n++;
    }
  }
  cout << n << endl;
  return 0;
}

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

#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define rep0(i,n) rep(i,0,n)
#define rep1(i,n) rep(i,1,n+1)
#define repR(i,s,n) for(ll i = (n-1); i >= (s); i--)
#define repR0(i,n) repR(i,0,n)
#define repR1(i,n) repR(i,1,n+1)

#define BR "\n"
#define SP " "
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << SP; } cout << BR;
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << BR;
#define fcout cout << fixed << setprecision(18)

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

int a[100];
int cells[100][100]; // r * c

int main() {
  ll N, A, B;
  cin >> N >> A >> B;

  vector<ll> X(N);
  rep0(i, N) cin >> X[i];

  ll ans = 0;
  rep(i, 1, N) {
    ll temp = (X[i] - X[i - 1]) * A;
    ans += min(temp, B);
  }

  cout << ans << BR;
  return 0;
}

Measured memory_bytes: 1024
import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int N = sc.nextInt();
   int M = sc.nextInt();
   int[] p =new int[M];
   String[] s =new String[M];
   for(int i=0;i<M;i++) 
   {
     p[i] = sc.nextInt();
     s[i] = sc.next();
   }
   boolean[] ac = new boolean[100010]; 
   int[] wacnt = new int[100010];
   int ans =0;
   int wa =0;
   for(int i=0;i<M;i++)
   {
     if(s[i].equals("WA"))
     {
       if(!ac[p[i]])
       {
         wacnt[p[i]]++;
       }
     }
     else if(s[i].equals("AC"))
     {
       if(!ac[p[i]])
       {
         ans++;
         wa+= wacnt[p[i]];
         ac[p[i]]=true;
       }
     }
   }
   System.out.println(ans+ " " + wa);
 }
}

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

int digit(int x){
    int count = 0;
    while(x>0){
        x /= 10;
        count++;
    }
    return count;
}

int main(){
int N; cin >> N;
int ans = 0;
for(int i = 1; i<= N; i++){
    if(digit(i) % 2 != 0){
        ans++;
    }
}
    cout << ans <<endl;

}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!(
    k: usize
    );
    let mut v:Vec<usize> = vec![1, 2, 3, 4, 5, 6, 7, 8, 9];
    let (mut s, mut f) = (0, 9);
    while v.len() <= k {
        let mut c = 0;
        for k in s..f {
            let j = v[k];
            let t = j % 10;
            match t {
                0 => {
                    v.push(j * 10 + t);
                    v.push(j * 10 + t + 1);
                    c += 2;
                }
                9 => {
                    v.push(j * 10 + t - 1);
                    v.push(j * 10 + t);
                    c += 2;
                }
                _ => {
                    v.push(j * 10 + t - 1);
                    v.push(j * 10 + t);
                    v.push(j * 10 + t + 1);
                    c += 3;
                }
            }
        }
        f += c;
        s = f - c;
    }
    println!("{}", v[k - 1]);
}


Measured memory_bytes: 6396
#include<bits/stdc++.h>
using namespace std;
vector<pair<int, int>> vp;
double clac(int i, int j) {
  double dx = abs(vp[i].first - vp[j].first);
  double dy = abs(vp[i].second - vp[j].second);
  return sqrt(dx * dx + dy * dy);
}
void dfs(int u, double dist, vector<bool> vis, vector<double>& ans) {
  vis[u] = true;
  bool f = true;
  for (int v = 0; v < vp.size(); v++) {
    if (vis[v]) continue;
    f &= false;
    dfs(v, dist + clac(u, v), vis, ans);
  }
  if (f) ans.push_back(dist);
}
int main() {
  int N;
  cin >> N;
  vp.resize(N);
  for (auto& p : vp) cin >> p.first >> p.second;
  
  vector<double> ans;
  vector<bool> vis(N);
  for (int i = 0; i < N; i++) {
    dfs(i, 0, vis, ans);
  }
  
  double sum = 0;
  for (auto& x : ans) sum += x;
  cout << fixed << setprecision(12) << sum / ans.size() << endl;
}


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

int main() {
  int x1, x2, x3, x4, y1, y2, y3, y4;
  cin >> x1 >> y1 >> x2 >> y2;
  cout << y1-y2+x2 << ' ' << x2-x1+y2 << ' ' << y1-y2+x1 << ' '<< x2-x1+y1;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
using ll=long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int>a(n);
	ll sum = 0;
	rep(i, n) {
		cin >> a[i];
		sum += a[i] - 1;
	}
	cout << sum << endl;
}

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

using namespace std;

int main(){
    int p, q, r;
    cin >> p >> q >> r;

    int abc, bca, cab, ans;
    abc = p + q;
    bca = q + r;
    cab = r + p;
    ans = min({abc, bca, cab});

    cout << ans << endl;
    return 0;

}


Measured memory_bytes: 256
s = input()

alphaList = []

for alpha in s:

    isExist = False

    for a in alphaList:
        if a == alpha :
            isExist = True
    
    if isExist == False:
        alphaList.append(alpha)

print( 'Yes' if(len(alphaList)==2) else 'No'  )

Measured memory_bytes: 2940
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int cnt[13] = {};
    cnt[0]++;
    rep(i, N) {
        int x; cin >> x;
        x = min(x, 24 - x);
        cnt[x]++;
    }
    rep(i, 13) {
        if(cnt[i] > 2) {
            cout << 0 << endl;
            return 0;
        }
    }
    int ans = 0;
    rep(bit, (1 << 13)) {
        vector<int> v;
        rep(i, 13) {
            if(cnt[i] == 2) {
                v.push_back(i);
                v.push_back(24 - i);
            } else if(cnt[i] == 1){
                if(bit & (1 << i)) v.push_back(i);
                else v.push_back(24 - i);
            }
        }
        sort(v.begin(), v.end());
        int tmp = 24;
        rep(i, v.size()) {
            int d1 = v[i];
            int d2 = v[(i + 1) % v.size()];
            int d = abs(d2 - d1);
            tmp = min(tmp, min(d, 24 - d));
            //cout << d1 << " " << d2 << " " << d << " " << min(d, 24 - d) << endl;
        }
        ans = max(ans, tmp);
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <mylib.h>
using namespace std;
//cin.sync_with_stdio(false);

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define FOR_EQ(i,a,b) for(int i = (a); i <= (b); ++i)
#define FOR_RE(i,a,b) for(int i = (a); i > (b); --i)
#define rep(i,n) FOR(i,0,n)
#define rep_eq(i,n) FOR_EQ(i,0,n)
#define rep_re(i,n) FOR_RE(i,n,0)
//1個上から時計周り
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
//上右下左
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};
static const int NIL = -1;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> Vector;
typedef vector<Vector>	DVector;
int n;

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int k, s;
    cin >> k >> s;
    
    int cnt = 0;
    rep_eq(x, k){
        rep_eq(y, k){
            int z = s - x - y;
            if(0 <= z && z <= k)  cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;


int main(){
    
   string s;
   cin >> s;
   ll flg = 0;
   for(ll i = 2; i + 1 < s.size(); i++){
       ll f = 1;
       if(s[0] != 'A')f = 0;
       if(s[i] != 'C')f = 0;
       for(ll j = 1; j < s.size(); j++){
           if(i == j)continue;
           if('A' <= s[j] && s[j] <= 'Z')f = 0;
       }
       if(f)flg = 1;
   }
   if(flg)cout << "AC" << endl;
   else cout << "WA" << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define rush() int T;scanf("%d",&T);while(T--)
#define mm(a,b) memset(a,b,sizeof(a))
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define sc(a) scanf("%d",&a)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define pf(a) printf("%d\n",a)
#define pf2(a,b) printf("%d %d\n",a,b)
#define p_f(a) printf("%d ",a)
#define pyn(a) if(a)puts("Yes");else puts("No");
#define fi first
#define se second
#define db double
#define ll long long
using namespace std;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
const db eps=1e-9;
int n,x,a[10];
bool flag;
int main()
{
    rep(i,1,9)sc(a[i]);
    sc(n);
    rep(i,1,n){
        sc(x);
        rep(i,1,9)if(a[i]==x)a[i]=0;
    }
    for(int i=1;i<=7;i+=3)if(a[i]+a[i+1]+a[i+2]==0)return cout<<"Yes",0;
    for(int i=1;i<=3;i++)if(a[i]+a[i+3]+a[i+6]==0)return cout<<"Yes",0;
    if(a[1]+a[5]+a[9]==0||a[3]+a[5]+a[7]==0)return cout<<"Yes",0;
    cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
#define ll long long
#define ld long double
using namespace std;

int main() {
	string S, T;
	cin >> S >> T;
	cout << T+S << endl;
	return 0;
}

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

using namespace std;


 
int main() {
    int k, n, t;
    cin >> k >> n;
    vector<int> a;
    vector<int> b;
    for (int i = 0; i < n; i++){
        cin >> t;
        a.push_back(t);
    }
    for (int i = 0; i < n; i++){
        if (i == 0)
            b.push_back(a.at(i));
        else
            b.push_back(a.at(i) - a.at(i - 1));
    }
    b.at(0) = k - a.at(n - 1) + a.at(0);
    cout << k - *max_element(b.begin(), b.end()) << endl;
}


Measured memory_bytes: 2548
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 9999999999;
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> inline T powerM(T a,T b){if (b==0) return 1;
  T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }


int n,m;
Graph G;
vector<int> dp(100100, -1);// 頂点iからの最大パス長

int rec(int v){
  if (dp.at(v) != -1) return dp.at(v);

  int res = 0;
  for (auto nv : G.at(v)){
    chmax(res, rec(nv) + 1);
  }
  dp.at(v) = res;
  return res;
}

int main() {
  cin >>n >>m;
  G.assign(n, vector<int>());
  rep(i, m){
    int a,b; cin >>a >>b;
    a--; b--;
    G.at(a).push_back(b);
  }
  int res = 0;
  for (int v=0; v<n; v++) chmax(res, rec(v));
  cout <<res <<endl;
}

Measured memory_bytes: 8192
#include "bits/stdc++.h"
using namespace std;
//#include "atcoder/all"
namespace atcoder{}
using namespace atcoder;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)n; ++i)
#define RREP(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define RFOR(i, s, n) for (int i = (int)n - 1; i >= s; --i)
#define ALL(a) a.begin(), a.end()
#define IN(a, x, b) (a <= x && x < b)
template<class T>istream&operator >>(istream&is,vector<T>&vec){for(T&x:vec)is>>x;return is;}
template<class T>inline void out(T t){cout << t << "\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout << t << " ";out(ts...);}
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;}
constexpr int INF = 1e18;

signed main(){
	int N, X, M;
	cin >> N >> X >> M;
	vector<int>to(M);
	vector<int>val(M);
	REP(i, M) {
		to[i] = i * i % M;
		val[i] = i;
	}
	vector<vector<int>>dp(60, vector<int>(M));
	vector<vector<int>>cost(60, vector<int>(M));
	REP(i, M) {
		dp[0][i] = to[i];
		cost[0][i] = val[i];
	}
	REP(i, 59) {
		REP(j, M) {
			dp[i + 1][j] = dp[i][dp[i][j]];
			cost[i + 1][j] = cost[i][j] + cost[i][dp[i][j]];
		}
	}
	int ans = 0;
	int pos = X;
	REP(i, 60) {
		if((N & (1ll << i)) == 0) continue;
		ans += cost[i][pos];
		pos = dp[i][pos];
	}
	out(ans);

}

Measured memory_bytes: 99472
#define _USE_MATH_DEFINES 
#include <iomanip> 
#include <cmath>  
#include<iostream>
#include <fstream>
#include<vector>
#include<algorithm>
#include<bitset>
#include<map>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define repi(i,a,b) for(ll i = (ll)(a) ; i < (ll)(b) ; i++)
#define repd(i,a,b) for(ll i = (ll)(a) ; i > (ll)(b) ; i--)
#define rd(x) cin >> x
#define wr(x)  cout << x
#define wrln(x) cout << x << endl

int N, sum, sumMin, r;
string S;

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

	repi(i, 0, N) {
		if (S[i] == '(') sum++;
		else sum--;
		sumMin = min(sumMin, sum);
	}
	r = abs(sumMin) + sum;

	repi(i, 0, abs(sumMin)) wr('(');
	wr(S);
	repi(i, 0, r) wr(')');
	cout << endl;

	return 0;
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    string s;cin >>s;
    ll k;cin >>k;
    map<string,int>mp;
    ll n=s.size();
    for (int i = 0; i <n; ++i) {
        for (int j = 1; j <=k; ++j) {
            string sub=s.substr(i,j);
            mp[sub]++;
        }
    }
    ll num=0;
    string ans;
    for(auto p:mp){
        num++;
        if(num==k){
            ans=p.first;
        }
    }
    cout <<ans <<endl;
    return 0;
}

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

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	string a, b;
	cin >> a >> b;
	string s, t;
	for(int i = 0; i < stoi(b); i++) {
		s += a;
	}
	for(int i = 0; i < stoi(a); i++) {
		t += b;
	}
	
	cout << min(s, t) << endl;
}


Measured memory_bytes: 256
use std::io::stdin;
use std::str::FromStr;
#[allow(dead_code, unused_mut)]
fn read<T: FromStr>() -> T {
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    s.trim().parse().ok().expect("1")
}
#[allow(dead_code, unused_mut)]
fn read_vec<T: FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().expect("2"))
        .collect()
}
#[allow(dead_code, unused_mut)]
fn read_two<T: FromStr>() -> (T, T) {
    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();
    let mut x = s.split_whitespace().map(|x| x.parse().ok().unwrap());
    (x.next().unwrap(), x.next().unwrap())
}
#[allow(dead_code, unused_mut)]
fn read_three<T: FromStr>() -> (T, T, T) {
    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();
    let mut x = s.split_whitespace().map(|x| x.parse().ok().unwrap());
    (x.next().unwrap(), x.next().unwrap(), x.next().unwrap())
}
#[allow(dead_code)]
fn remove_whitespace(s: &str) -> String {
    s.chars().filter(|c| !c.is_whitespace()).collect()
}
#[allow(unused_imports)]
use std::io::{stdout, Write};
fn main() {
    let n: usize = read();
    let v: Vec<usize> = read_vec();
    let mut count = 0;
    for i in 0..n {
        if i == v[v[i] - 1] - 1 {
            count += 1;
        }
    }
    println!("{}", count / 2);
}


Measured memory_bytes: 6396