akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef pair< int , int > Pi;

int main(){
  int n, m, h, k, s[1000];
  Pi ab[100000], c[100000], d[100000];
  int ans[1000], pos[1000];

  while(scanf("%d %d %d %d", &n, &m, &h, &k), n){
    for(int i = 0; i < n; i++){
      scanf("%d", &s[i]);
      ans[i] = i;
    }
    for(int i = 0; i < m; i++){
      scanf("%d %d", &ab[i].second, &ab[i].first);
    }
    sort( ab, ab + m);
  
    int base = 0;
    for(int i = 0; i < m; i++){
      swap(ans[ab[i].second - 1], ans[ab[i].second]);
      d[i] = Pi( ans[ab[i].second - 1], ans[ab[i].second]);
    }
    for(int i = 0; i < n; i++){
      if(ans[i] < k) base += s[i];
      pos[ans[i]] = i;
    }

    int ret = base;

    for(int i = 0; i < m; i++){
      int res = base;
      
      if(d[i].first < k){
        res -= s[pos[d[i].first]];
        res += s[pos[d[i].second]];
      }
      if(d[i].second < k){
      res += s[pos[d[i].first]];
      res -= s[pos[d[i].second]];
      }
      ret = min( res, ret);
    }
    
    cout << ret << endl;
  }  
}

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

int main(){
	string s; cin >> s;
	bool po = 0, yo = 0;
	for(char c : s){
		if(c == 'C') po = 1;
		else if(c == 'F' && po) yo = 1;
	}
	cout << (po && yo ? "Yes\n" : "No\n");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <queue>
#include <math.h>
#include <assert.h>
#include <set>
#include <map>
#include <bitset>
#include <ctime>
#include <time.h>
#include <algorithm>
#include <cstdio>
#include <fstream>
#include <stack>
#include <ctype.h>
#include <numeric>
#include <sstream>
#include <unistd.h>
#include <unordered_map>
#include <limits>
const int oo = 1 << 30;
using namespace std;


int main(){
    // freopen("/Users/deepsajeda/Documents/FIRST/in", "r", stdin);
    // freopen("/Users/deepsajeda/Documents/FIRST/out", "w", stdout);

    int n;
    scanf("%d", &n);
    vector<int> arr(n);
    for(int i = 0; i < n; ++i){
        scanf("%d", &arr[i]);
    }
    vector<int> dp(n + 1, oo);
    dp[0] = 0;
    for(int i = 1; i < n; ++i){
        dp[i] = min(dp[i], dp[i - 1] + abs(arr[i] - arr[i - 1]));
        if(i >= 2)dp[i] = min(dp[i], dp[i - 2] + abs(arr[i] - arr[i - 2]));
    }
    printf("%d\n", dp[n - 1]);
}
//printf("%.5f\n", clock() / (float)CLOCKS_PER_SEC); time in seconds


Measured memory_bytes: 1024
#include <iostream>
#include <set>
#include <string>

int main() {
  std::string N;

  std::cin >> N;
  std::set<char> tmp;
  std::set<char> tmp2;

  std::size_t n = N.length();
  for (int i = 0; i < n; i++) {
    if (i < 3) {
      tmp.insert(N[i]);
    }
    if (i >= 1) {
      tmp2.insert(N[i]);
    }
  }

  if (tmp.size() < 2 || tmp2.size() < 2) {
    std::cout << "Yes" << std::endl;
  } else {
    std::cout << "No" << std::endl;
  }
  return 0;
}

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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second

const int N=1000000;

typedef pair<int,int> pi;

//?????£??????????????±
int field[1000][1000]={0};
//??????(??°????????§?¨?)
pi im[N+1];
//?´???°????????????
bool prime[N+1];

int n,m;

//?????§???
int dp[N+1];
//????????¨???????????????????????????????´???°
int last[N+1];

bool inline in(int x, int y)
{
    return (0<=x&&x<1000 && 0<=y&&y<1000);
}

int dfs(int v)
{
    if(dp[v]>=0) return dp[v];

    int ret=0;
    int x=im[v].se;
    int y=im[v].fi;

    int t[3];
    memset(t,-1,sizeof(t));

    rep(i,3)
    {
        if(in(y+1,x+i-1) && field[y+1][x+i-1]<=m)
            t[i]=dfs(field[y+1][x+i-1]);
    }

    ret=max({0,t[0],t[1],t[2]});
    rep(i,3)
    {
        if(ret==t[i]) last[v]=max(last[v],last[field[y+1][x+i-1]]);
    }

    if(prime[v])
    {
        ++ret;
        if(ret==1) last[v]=v;
    }

    return dp[v]=ret;
}

int main()
{
    //?´???°??¨??????
    fill(prime,prime+N+1,true);
    prime[0]=prime[1]=false;
    for(int i=2; i<=N; ++i)
    {
        if(prime[i]) for(int j=2; i*j<=N; ++j) prime[i*j]=false;
    }

    //?????£???????????????
    int h=0,w=0;
    int dir=0;
    int dh[4]={0,1,0,-1}, dw[4]={1,0,-1,0};
    for(int i=N; i>0; --i)
    {
        field[h][w]=i;
        im[i]=pi(h,w);
        h+=dh[dir];
        w+=dw[dir];
        if(!in(h,w) || field[h][w]>0)
        {
            h-=dh[dir];
            w-=dw[dir];
            dir=(dir+1)%4;
            h+=dh[dir];
            w+=dw[dir];
        }
    }

    while(scanf(" %d %d", &m, &n),m|n)
    {
        memset(dp,-1,sizeof(dp));
        memset(last,0,sizeof(last));
        int ans=dfs(n);
        printf("%d %d\n", ans, last[n]);
    }
    return 0;
}

Measured memory_bytes: 23856
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
#include <atcoder/all> 
using namespace atcoder;
/*
注意!! #include <atcoder/all>
*/
using namespace std;

int main() {
	int n, q;
	cin >> n >> q;
	dsu unionfind(n);
	for (int i = 0; i < q; i++) {
		int t, u, v;
		cin >> t >> u >> v;
		if (t == 0) {
			unionfind.merge(u, v);
		}
		else {
			if (unionfind.same(u, v)) {
				cout << "1" << endl;
			}
			else {
				cout << "0" << endl;
			}
		}

	}
}


Measured memory_bytes: 3908
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
typedef long long ll;
typedef unsigned int uint;
using namespace std;
ll n, a, b, h[1000005];

ll binary_search(ll s, ll g) {
    ll k = (g + s) / 2;
    ll t1 = 0, t2 = 0;
    for (int i = 0; i < n; i++) {
        if (h[i] > b * k) {
            t1 += (h[i] - b * k + a - 1) / a;
        }
        if (h[i] > b * (k - 1)) {
            t2 += (h[i] - b * (k - 1) + a - 1) / a;
        }
    }

    ll ret;
    if (t1 > k) { // kで倒せない
        ret = binary_search(k, g);
    } else { // kで倒せる
        if (t2 > k-1) { // k-1で倒せない
            ret = k;
        } else {
            ret = ret = binary_search(s, k);
        }
    }

    return ret;
}

int main() {
    cin.sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> a >> b;
    a -= b;
    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }

    cout << binary_search(0, 1000000000) << "\n";
    return 0;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
using namespace std;
#define INF 110000000000
#define MAX 100000
typedef long long ll;
typedef pair<ll,ll> P;
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/

int main(){
    int N,ans=0;
    string S;
    cin>>N>>S;
    S.push_back('0');
    for(int i=0;i<N;i++){
        if(S[i]==S[i+1]) continue;
        else ans++;
    }
    cout<<ans<<endl;
}


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

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

int main()
{
  string s, s2 = "CODEFESTIVAL2016";
  cin >> s;
  int cnt = 0;
  rep(i, s.length())
    {
      if(s[i] != s2[i])
	{
	  cnt++;
	}
    }
  cout << cnt << endl;
  
  return 0;
}


Measured memory_bytes: 256
import math
import fractions
import itertools
import copy
import collections
from operator import itemgetter
#以下てんぷら
def j(q):
    if q==1: print("Yes")
    elif q == 0:print("No")
    exit(0)


"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def printrow(a):
    for i in range(len(a)):
        print(a[i])
def combinations(n,r):
    if n<r:return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def permutations(n,r):
    if n<r:return 0
    return math.factorial(n) // math.factorial(n - r)
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)


#n = ip()                                     #入力整数1つ
r,g,b,n= (int(i) for i in input().split())       #入力整数横2つ以上
#a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#a=[input() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
s = 0
for i in range(n//r+1):
    for k in range(n//g+1):
        left = n-(r*i+k*g)
        if left%b == 0 and left>=0:s+=1
print(s)


Measured memory_bytes: 66408
#include<stdio.h>

int main()
{
  int a, b, c, t, i;

  scanf("%d %d %d", &a, &b, &c);

  for(i = 0; i < 2; i ++){
    if(b > c){
      t = c;
      c = b;
      b = t;
    }
    
    if(a > b){
      t = b;
      b = a;
      a = t;
    }
  }

  printf("%d %d %d\n", a, b, c);

  return 0;
}

Measured memory_bytes: 596
N = input()
K = int(input())
L = len(N)

dp = [[[0 for j in range(L + 10)] for i in range(L + 10)] for _ in range(2)]
dp[0][0][0] = 1

for i in range(L):
    Ni = int(N[i])
    for j in range(L):
        if Ni == 0:
            dp[0][i + 1][j + 0] += dp[0][i][j + 0] * 1
            dp[0][i + 1][j + 1] += dp[0][i][j + 0] * 0
            dp[1][i + 1][j + 0] += dp[0][i][j + 0] * 0 + dp[1][i][j + 0] * 1
            dp[1][i + 1][j + 1] += dp[0][i][j + 0] * 0 + dp[1][i][j + 0] * 9
        else:
            dp[0][i + 1][j + 0] += dp[0][i][j + 0] * 0
            dp[0][i + 1][j + 1] += dp[0][i][j + 0] * 1
            dp[1][i + 1][j + 0] += dp[0][i][j + 0] * 1 + dp[1][i][j + 0] * 1
            dp[1][i + 1][j + 1] += dp[0][i][j + 0] * (Ni - 1) + dp[1][i][j + 0] * 9
#print(dp[0])
#print(dp[1])

print(dp[0][L][K] + dp[1][L][K])

Measured memory_bytes: 43504
a = [list(map(int, list(input().split()))) for i in range(3)]
n = int(input())
b = [int(input()) for i in range(n)]

for i in range(n):
    for j in range(3):
        for k in range(3):
            if a[j][k] == b[i]:
                a[j][k] = True

for i in range(3):
    cnt = 0
    for j in range(3):
        if a[i][j] == True:
            cnt += 1
        if cnt == 3:
            print("Yes")
            exit()

for i in range(3):
    cnt = 0
    for j in range(3):
        if a[j][i] == True:
            cnt += 1
        if cnt == 3:
            print("Yes")
            exit()

if a[0][0] == True and a[1][1] == True and a[2][2] == True:
    print("Yes")
    exit()

if a[2][0] == True and a[1][1] == True and a[0][2] == True:
    print("Yes")
    exit()

print("No")

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

s_list = list(s)

ans = 'Yes'

if n % 2 == 1:
    ans = 'No'
else:
    char_first_t = 0
    char_second_t = (n//2)
    for i in range(n//2):
        f = s_list[char_first_t]
        sec = s_list[char_second_t]
        if f != sec:
            ans = 'No'
        char_first_t += 1
        char_second_t += 1
        
print(ans)

Measured memory_bytes: 3060
#include <stdio.h>
#include <stdint.h>
#include <math.h>

int main()
{
  int64_t a, b, n;
  int64_t t;
  scanf("%ld %ld %ld",&a, &b, &n);

  if (n >= b) {
    t = b - 1;
  } else {
    t = n;
  }

  printf("%ld\n", (int64_t)(floor(a*t/b) - a*floor(t/b)));
  return 0;
}



Measured memory_bytes: 1732
<?php                                                                                                                                                          
                                                                                                                                                               
function fget_array()                                                                                                                                          
{                                                                                                                                                              
    return explode(' ', trim(fgets(STDIN)));                                                                                                                   
}                                                                                                                                                              
                                                                                                                                                               
list($num) = fget_array();                                                                                                                                     
$places = fget_array();                                                                                                                                        
sort($places);                                                                                                                                                 
$places = array_values($places);                                                                                                                               
$result = $places[0];                                                                                                                                          
for ($i = 1; $i < $num; $i++) {                                                                                                                                
    $result = ($result + $places[$i]) / 2;                                                                                                                     
}                                                                                                                                                              
echo $result.PHP_EOL;                                                                                                                                          
?> 

Measured memory_bytes: 4604
#%%
from bisect import bisect_left

n = int(input())
l = list(map(int, input().split()))
l.sort()

ans = 0
for i in range(n):
    for j in range(i+1, n):
        tmp = l[i] + l[j]
        back = bisect_left(l, tmp)
        ans += (back-1) - j
        #print(i, j, back)

print(ans)

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


using namespace std;

#define ll long long

int main(){
    ll n;
    cin>>n;
    if(n%2==1){
        cout<<"0";
        return 0;
    }
    ll ans=0;
    ll p=1;
    ll c=10;
    while(c<=n){
        ans+=(n/c);
        c*=5;
    }
    cout<<ans;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#define mod 998244353ll
int k,n;
long long inv[100005],fac[100005];
long long fp(long long x,int y){return (y&1?x:1ll)*(y/2?fp(x*x%mod,y/2):1ll)%mod;}
void pre(int n){inv[0]=fac[0]=1;for (int i=1;i<=n;i++) fac[i]=fac[i-1]*i%mod,inv[i]=fp(fac[i],mod-2);}
long long c(int x,int y){return y>x?0:fac[x]*inv[y]%mod*inv[x-y]%mod;}
int main()
{
	scanf("%d%d",&k,&n);
	pre(10000);
	for (int i=2;i<=2*k;i++)
	{
		int tot=0;long long ans=0;
		for (int j=1;i-j>=j;j++) tot=tot+(j<=k&&i-j<=k);
		for (int j=0;j<=std::min(tot,n/2);j++) ans=(ans+1ll*(1-(j&1)*2)*c(tot,j)%mod*c(n-2*j+k-1,k-1)%mod)%mod;
		printf("%lld\n",(ans+mod)%mod);
	}
	return 0;
}

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

using ll=long long;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DBG(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl

using pii=pair<int,int>;
using vi=vector<int>;
using ld=long double;

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

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

int read(){
	int i;
	scanf("%lld",&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(int x,int suc=1){
	printf("%lld",x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341919];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341919];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(a>b)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

const int mod=1000000007;
template<class T,class U>
void add(T& a,U b){
	a=((ll)a+b)%mod;
}

template<class T,class U>
void sub(T& a,U b){
	a=((ll)a-b%mod+mod)%mod;
}

template<class T,class U>
void mult(T& a,U b){
	a=((ll)a*b)%mod;
}

ll modPow(ll a,ll p){
	ll s=1;
	REP(i,30){
		if((p>>i)&1)
			mult(s,a);
		mult(a,a);
	}
	return s;
}

ll modInv(ll a){
	return modPow(a,mod-2);
}

signed main(){
	int n=read(),m=read();
	string s=readString();
	int len=s.size();
	vi c(len,0);
	REP(i,len)if(s[i]=='1')
		c[i]++;
	FOR(i,1,len)
		c[i]+=c[i-1];
	vi cur(n+1,0),nx(n+1,0);
	vi qs(n);
	REP(i,n)
		qs[i]=i;
	REP(i,m){
		int l=read()-1,r=read()-1;
		chmax(qs[l],r);
	}
	int rMax=0;
	cur[0]=1;
	REP(i,n){
		chmax(rMax,qs[i]);
		fill(ALL(nx),0);
		REP(x,n+1)if(cur[x]){
			int p=c[rMax]-x;
			int q=(rMax+1-c[rMax])-(i-x);
			if(p>0){
				add(nx[x+1],cur[x]);
			}
			if(q>0){
				add(nx[x],cur[x]);
			}
		}
		swap(nx,cur);
	}
	cout<<cur[c[n-1]]<<endl;
}


Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include <queue>
using namespace std;
int main() {
	int N, Q;
	cin >> N;
	vector<int> A(N);
	long long int sum = 0;
	vector<int> num(100010,0);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		sum += A[i];
		num[A[i]]++;
	}
	cin >> Q;
	vector<int> B(Q), C(Q);
	for (int i = 0; i < Q; i++) {
		cin >> B[i] >> C[i];
	}
	for (int i = 0; i < Q; i++) {
		sum += ( C[i]-B[i]) * num[B[i]];
		num[C[i]] += num[B[i]];
		num[B[i]] = 0;
		cout << sum << endl;
	}
}

Measured memory_bytes: 4792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll v[4];
ll n;
int main() {
  cin >> v[0] >> v[1] >> v[2] >> v[3];
  cin >> n;
  n *= 4;
  vector<vector<ll>> pp;
  pp.push_back({v[0] * 8, 1, v[0]});
  pp.push_back({v[1] * 4, 2, v[1]});
  pp.push_back({v[2] * 2, 4, v[2]});
  pp.push_back({v[3] * 1, 8, v[3]});

  sort(pp.begin(), pp.end());
  ll ret = 0;
  for (int i = 0; i < 1; ++i) {
    ret += n / (pp[i][1]) * pp[i][2];
    n %= pp[i][1];
  }
  ll r2 = INT_MAX;
  for (int i = 0; i <= 8; ++i)
    for (int j = 0; j <= 4; j++)
      for (int k = 0; k <= 2; ++k)
        for (int m = 0; m <= 1; ++m) {
          if (i + j * 2 + k * 4 + m * 8 == n) {
            if (i * v[0] + j * v[1] + k * v[2] + m * v[3] < r2) {
              r2 = i * v[0] + j * v[1] + k * v[2] + m * v[3];
            }
          }
        }
  cout << ret + r2 << endl;
}

Measured memory_bytes: 256
use proconio::input;

fn divisors(n: usize) -> Vec<usize> {
    let mut d = vec![];
    for i in 1.. {
        if i * i > n {
            break;
        }
        if n % i == 0 {
            d.push(i);
            if i != n / i {
                d.push(n / i);
            }
        }
    }
    // d.sort();
    d
}

fn main() {
    input! {
        n: usize,
        m: usize,
    };

    let d = divisors(m);
    let mut ans = 1;
    for &d_i in d.iter() {
        if n * d_i <= m {
            ans = std::cmp::max(ans, d_i);
        }
    }
    println!("{}", ans);
}


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

int main() {
  long long n, a, b;
  cin>>n>>a>>b;
  if (a % 2 == b % 2) {
    cout<<(b - a) / 2<<endl;
  } else {
    long long cnt1 = n - b + 1 + (n - (a + n - b + 1)) / 2;
    long long cnt2 = a + (b - a - 1) / 2;
    cout<<min(cnt1, cnt2)<<endl;
  }
}

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

const int MAXN=110;
int pp[MAXN]={0};
int main(){
	int n;
	while(cin>>n){
		for(int i=0;i<n;i++) cin>>pp[i];
		int temp=0;
		for(int i=0;i<n-1;i++){
			for(int j=0;j<n-i-1;j++){
				if(pp[j]>pp[j+1]){
					int t=pp[j];
					pp[j]=pp[j+1];
					pp[j+1]=t;
					temp++;	
				}
			}
		}
		for(int i=0;i<n;i++){
			if(i<n-1){
				cout<<pp[i]<<" ";
			}else{
				cout<<pp[i]<<endl;
			}
		}
		cout<<temp<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 3104
while 1:
	n=input()
	if n==0:break
	b=map(int,raw_input().split())
	count=0
	while count<10001:
		if b[0]==1:
			for i in range(len(b)-1):
				if b[i+1]-b[i]!=1:
					break
			else:
				print count
				break
		for i in range(len(b)):
			b[i]-=1
		b.append(len(b))
		while b.count(0)>0:
			del b[b.index(0)]
		count+=1
	else:
		print -1

Measured memory_bytes: 4304
#include <stdio.h>
#include <math.h>
int main(void){
	int n,h,m; float r,s,l;
	scanf("%d",&n);
	while(n--){
		scanf("%d:%d",&h,&m);
		s = 30 * h + m / 2.0;
		l = 6 * m;
		r = fabs(s - l);
		if(r > 180) r = 360 - r;
		printf("%s\n",r<30?"alert":90<=r&&r<=180?"safe":"warning");
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;

int main(){
    string s;
    cin >> s;
    bool ans = true;
    ans &= (s[0] == 'A');
    int count = 0;
    for(int i = 2; i <= s.size()-2; i++){
        if(s[i] == 'C'){
            count++;
        }
    }
    ans &= (count == 1);
    bool isLower = true;
    for(int i = 0; i < s.size(); i++){
        if((s[i] >= 'a' && s[i] <= 'z') || s[i] == 'A' || s[i] == 'C'){
            continue;
        } else {
            isLower = false;
        }
    }
    ans &= isLower;
    if(ans){
        cout << "AC" << endl;
    } else {
        cout << "WA" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import numpy as np
N,P = map(int,input().split(' '))
#N=3
#P=24


def primes(n):
	f = [True]*(n+1)
	f[0] = False
	f[1] = False
	m = int(n**0.5+1)
	for i in range(2,m):
		if f[i]:
			for j in range(i*i,n+1, i):
				f[j] = False
	return f


if N == 1:
	print(P)
	exit()

thres = int(np.log2(P))+1
if N > thres:
	print(1)
	exit()

s = 1/N
sP=int(P**s)+1
f = primes(sP)
prime = [x for x in range(1,sP+1) if f[x]]

ans = 1
	
for p in prime:
	q = p**N
	if P < q:
		break
	if P % q == 0:
		ans*=p
		q*= p**N
		while(P % q == 0):
			ans*=p
			q*=p**N

print(ans)





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

// #include <boost/algorithm/string/join.hpp>
// using boost::algorithm::join;
//
// #include "boost/multi_array.hpp"
// boost::multi_array<int, 3> dp;
// dp.resize(boost::extents[10][9][8]);
//
// #include <boost/multiprecision/cpp_dec_float.hpp>  // quite slowly
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision; // mp::log10
// using bigint = boost::multiprecision::cpp_int;
// using rational = mp::cpp_rational;  // double d = static_cast<double>(r);

typedef long long ll;
typedef unsigned long long ull;
//typedef long double ld;

typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef set<int> si;
typedef set<ll> sll;
typedef vector<int> vi;
typedef vector<pair<int, int > > vii;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<vll> vvll;

//constexpr ll MOD = 1e9+7;
template<typename T>constexpr auto inf=numeric_limits<T>::max()/4;
constexpr int INF=inf<int>;
constexpr ll LINF=inf<ll>;

#define Sort(x) sort(begin(x),end(x))
#define Reverse(x) reverse(begin(x),end(x))
#define ABS(a,b) ((a)<(b)?(b)-(a):(a)-(b))
#define nbit(n) (1ull<<(n))
#define _ol3(_1,_2,_3,name,...)name
#define _rep(i,n)_repi(i,0,n)
#define _repi(i,a,b)for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...) _ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,v) REP(i,(v).size())

// sort(begin(x), end(x), greater<ll>());
// lower_bound(a.begin(), a.end(), val): a[i] ≥ valである最左の位置
// upper_bound(a.begin(), a.end(), val): a[i] > valである最左の位置

// Returns minimum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmin(T& a, T b) {
  if (a > b) {
    a = b;
  }
  return a;
}

// Returns maximum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmax(T& a, T b) {
  if (a < b) {
    a = b;
  }
  return a;
}

template <typename T>
void dumpContents(const T& v, const string& msg)
{
  cerr << "### " << msg << " ###\n";
  for (const auto& x : v) {
    cerr << x << " ";
  }
  cerr << endl;
}

struct before_main_function {
  before_main_function() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<setprecision(20)<<fixed;
#define endl "\n"
  }
} before_main_function;

// ========== end of template ==========

int main(int argc, char** argv) {
  ll N;
  cin >> N;

  if (N==0) {
    cout << 0 << endl;
    return 0;
  }

  vi ret;
  while (N!=0) {
    int r = N%(-2);
    N /= -2;
    if (r<0) {
      r = 1;
      N++;
    }
    ret.emplace_back(r);
  }
  Reverse(ret);
  for (auto x : ret) {
    cout << x;
  }
  cout << endl;

  return 0;
}

/* vim: set expandtab shiftwidth=2 softtabstop=2 : */


Measured memory_bytes: 256
n, m = map(int, input().split())
ab = [(lambda x, y:(x, y))(*map(int, input().split())) for _ in range(m)]
d = {}
for x in ab:
  if x[0] in d.keys():
    d[x[0]].append(x[1])
  else:
    d[x[0]] = [x[1]]
moyo = []
for z in d[1]:
  if z in d.keys():
    moyo += d[z]
for z in moyo:
  if z == n:
    exit(print('POSSIBLE'))
print('IMPOSSIBLE')

Measured memory_bytes: 47880
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
#include<numeric>
using namespace std;
using ll = long long;
int main(){
  string s;
  cin >> s;
  int n = s.length();
  int cs = 0, ct = 0;
  int ans = 0;
  for(int i = 0; i < n; i++) {
    if(s[i] == '0'){
      if(ct > 0){
        ct--;
        ans += 2;
      }else{
        cs++;
      }
    }else{
      if(cs > 0){
        cs--;
        ans += 2;
      }else{
        ct++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <list>
#include <string>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <iomanip> // setprecisionを使用するのに必要 cout << fixed << setprecision(15) << p でpを小数点以下15桁表示
using namespace std;
#define REPD(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) REPD(i, 0, n)
typedef long long ll;
#define fin(ans) cout << (ans) << '\n'
/*

*/
int main()
{
    string S;
    cin >> S;
    fin(S[0]+S[1]+S[2]-'0'*3);
    return 0;
}

Measured memory_bytes: 888
// I - Coins
#include <bits/stdc++.h>
using namespace std;
using dl = double;

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

	vector<dl> P(N+1); for(int i=1; i<=N; i++) cin>>P[i];

	int C = (N+1)/2;//ceil
	vector<dl> dp(N+2);
	dp[1] = 1.;
	for(int lv=1; lv<=N; lv++){
		dl f = P[lv], b = 1.-f;
		int e = max(1, lv-C+2);
		for(int i=lv+1; i>=e; i--) dp[i] = b*dp[i] + f*dp[i-1];
	}

	dl a = 0; for(int i=N+1; i>C; i--) a += dp[i];
	printf("%.10g\n",a);
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  long long k;cin>>k;
  if(k == 0){
    cout << 2 << endl;
    cout << "0 1" << endl;
  }else if(k == 1){
    cout << 2 << endl;
    cout << "0 2" << endl;
  }else if(k < 51){
    cout << k << endl;
    for(int i = 1; k >= i; i++){
      cout << i;
      if(i != k)cout << " ";
    }
    cout << endl;
    return 0;
  }else{
    long long syoki = k/50;
    long long wari = 50- (k % 50);
    cout << 50 << endl;
    for(int i = 1; 50 >= i; i++){
      long long kekka = syoki+i;
      if(wari != 0){
        kekka += (wari >= i ? -1:-0);
      }
      cout << kekka;
      if(i != k)cout << " ";
    }
    cout << endl;
    
  }
}

Measured memory_bytes: 256
using System;

namespace A___Takahashi_Calendar
{
    class Program
    {
        static void Main (string[] args)
        {
            var input = Console.ReadLine ().Split (' ');
            var m = int.Parse (input[0]);
            var d = int.Parse (input[1]);
            var month = 4;
            var day = 21;
            var count = 0;
            while (month <= m && day <= d)
            {
                if (day < d)
                    day++;

                else
                {
                    month++;
                    day = 22;
                }
                if (day / 10 >= 2 && day % 10 >= 2 && (day / 10) * (day % 10) == month)
                {
                    count++;
                }
            }
            Console.WriteLine (count);
        }
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
//#include <ext/hash_map>
#include <tr1/unordered_map>
#include <set>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using namespace tr1;
//using namespace __gnu_cxx;

#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define DEB 0

/*
real	0m2.093s  --> 
real	0m2.000s
*/
const int dx[] = {1,0,-1,0}; //r,d,l,u
const int dy[] = {0,1,0,-1};

int w,h,sx,sy,home,last;
int field[16][16];
int num[16][16];
int hS[25],hx[25],hy[25],edge[25][4][25]; //[src][dir][dest]
//hash_map<int,int> hii;
unordered_map<int,int> hii;


inline bool isnotgoal(int s){
  return (((last&s)) == last);
}
inline bool isnot(int s){
  rep(i,home)if( !(s&(1<<i)) ){
    if( (hS[i]&s)==hS[i] ) return true;
  }
  return false;
}
inline bool inside(int x, int y){
  return (x<0 || y<0 || x>=w || y>=h);
}

int dfs(int S){
  int src = S&((1<<5)-1);
  int x = hx[src];
  int y = hy[src];
  int s = S>>5;

  if( (1<<home)-1 == s ){ //ツ静「ツ妥篠づ可姪淞づェツづゥ
    return 1;
  }
  if( isnotgoal(s) ){ //ツ仰ウツ嘉ッツづ可姪淞づゥツつスツづ淞づ個嘉づーツ湘氾ッツつオツつスツつゥツづつ、ツつゥ
    return 0;
  }
  //hash_map<int,int>::iterator it = hii.find(S);
  unordered_map<int,int>::iterator it = hii.find(S);
  if( it!=hii.end() && it->first==S ){ //ツ探ツ催オツ催渉づ敖づ個湘ウツ妥板つゥツづつ、ツつゥ
    return it->second;
  }

  // ツプツδ個ゼツδ督トツつェツ置ツつッツづ按つ「ツ嘉づ個有ツ鳴ウ
  if( s>0 && ((s&(s-1))!=0) && isnot(s&~(1<<src)) ){
    return 0;
  }
  
  int ret = 0;
  rep(k,4){
    for(int j=0; edge[src][k][j]!=-1; j++){
      int dest = edge[src][k][j];
      int nx = hx[dest];
      int ny = hy[dest];
      if( field[ny][nx]==1 ){
	field[ny][nx] = 0;
	ret += dfs(((s|(1<<dest))<<5)|dest);
	field[ny][nx] = 1;
	break;
      }
    }
  }
  hii.insert(make_pair(S,ret));
  return ret;
}

int main(){

  while(scanf("%d%d",&w,&h),w|h){
    hii.clear();
    memset(num,-1,sizeof(num));
    memset(edge,-1,sizeof(edge));
    memset(hS,0,sizeof(hS));
    home = last = 0;
    rep(i,h){
      rep(j,w){
	scanf("%d",&field[i][j]);
	if( field[i][j]==2 ){
	  sx=j; sy=i;
	}
	if( field[i][j]==1 ){
	  hx[home]=j; hy[home]=i;
	  num[i][j] = home;
	  home++;
	}
      }
    }
    hx[home] = sx;
    hy[home] = sy;

    // other homes
    rep(i,home){
      rep(k,4){
	int sz = 0;
	for(int j=1; j<20; j++){
	  int tx = hx[i] + dx[k]*j;
	  int ty = hy[i] + dy[k]*j;
	  if( inside(tx,ty) ) break;
	  if( field[ty][tx]==1 ){
	    hS[i] |= (1<<num[ty][tx]);
	    edge[i][k][sz++] = num[ty][tx];
	  }
	}
      }
    }

    //last homes
    rep(k,4){
      int sz = 0;
      for(int i=1; i<20; i++){
	int tx = sx + dx[k]*i;
	int ty = sy + dy[k]*i;
	if( inside(tx,ty) )break;
	if( field[ty][tx]==1 ){
	  last |= (1<<num[ty][tx]);
	  edge[home][k][sz++] = num[ty][tx];
	}
      }
    }
    printf("%d\n",dfs(home));
  }
  

  return 0;
}

Measured memory_bytes: 18000
a,b,c,d= map(int,input().split())
k=b+1-a
n=(b//d)-((a-1)//d)
m=(b//c)-((a-1)//c)
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a
def lcm(a,b):
     return a*b//gcd(a,b)
l=(b//(lcm(c,d)))-((a-1)//(lcm(c,d)))
print(k+l-n-m)

Measured memory_bytes: 38256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<cmath>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define FOR(i, j, limit) for(int i=j; i< limit; ++i)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ECHO(x) cout<<x<<endl;
#define LL long long
int INF = 2147483647;
LL LINF = 9223372036854775807;
LL MOD = 1000000007;
typedef pair<int, int>P;
typedef pair<LL, LL>PL;
typedef vector<int> vi;
typedef vector<LL> vl;


int main(){
  int n;
  string s;
  cin>>n>>s;
  int r=0;
  REP(i, n){
    if(s[i]=='R')++r;
  }
  if(r>=(n+2)/2 ) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;


  return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();

		List<Integer> list = new ArrayList<>();

		for (int i = 0; i < n; i++) {
			int buf = sc.nextInt();
			list.add(buf);
		}

		boolean boo = true;
		int result = 0;

		while(boo) {
			for (int cnt = 0; cnt < list.size(); cnt++) {
				if (list.get(cnt) % 2 != 0) {
					boo = false;
					break;
				}
				list.set(cnt, list.get(cnt)/2);
			}
			if(boo) {
				result += 1;
			}
		}
		System.out.println(result);
	}
}

Measured memory_bytes: 36168
#include <iostream>
using namespace std;
int main(){
  int n;
  while( cin >> n,n ){
    for(int i = 0 ; i < n ; i++){
      double a,b,c;
      cin >> a >> b >> c;
      if(a == 100 || b == 100 || c == 100)cout << "A" <<endl;
      else if((a+b)/2 >= 90)cout << "A" <<endl;
      else if((a+b+c)/3 >= 80)cout << "A" <<endl;
      else if((a+b+c)/3 >= 70)cout << "B" <<endl;
      else if((a+b+c)/3 >= 50 && (a >= 80 || b>=80))cout << "B" <<endl;
      else cout << "C" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1224
#include<iostream>
#include <algorithm>
#include<string>
#include <numeric>
#include<math.h>
#include <bits/stdc++.h>
using namespace std;

int main(void) {
    int a,b,c,d;
    cin >>a>>b>>c>>d;


    if(a>b)cout<<b*c+(a-b)*d<<endl;
    else cout<<a*c<<endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 2147483600

int main(){
  long s,c;
  cin>>s>>c;
  long res = min(s,c/2);
  s -= res;
  c -= res*2;

  res += c/4;

  cout<<res<<endl;

  return 0;
}


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

const int MOD = 1000000007;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define copy(from, to) copy(from.begin(), from.end(), back_inserter(to))
#define sort(a) sort(a.begin(), a.end())
#define reverse(s) reverse(s.begin(), s.end())
#define p(s) cout << (s) << endl

typedef long long ll;
using namespace std;

template<class T>
void load(vector<T> &v, int n) {
  for (int i = 0; i < n; ++i) {
    T t;
    cin >> t;
    v.push_back(t);
  }
}

template<class T>
T max(vector<T> &v) {
  return *max_element(v.begin(), v.end());
}

template<class T>
T min(vector<T> &v) {
  return *min_element(v.begin(), v.end());
}

void py(bool isUpper = false) {
  if (isUpper) {
    p("YES");
  } else {
    p("Yes");
  }
}

void pn(bool isUpper = false) {
  if (isUpper) {
    p("NO");
  } else {
    p("No");
  }
}

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

  vector<int> w;
  load(w, n);

  vector<int> x;
  int sum = accumulate(w.begin(), w.end(), 0);

  for (int i = 1; i < n; ++i) {
    int s1 = 0;
    for (int j = 0; j < i; ++j) {
      s1 += w[j];
    }
    int s2 = sum - s1;
    x.push_back(abs(s1 - s2));
  }
  p(min(x));
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<array>
#include<algorithm>
#include<deque>
#include<vector>

int main(void) {
	using namespace std;
	int result = 0;
	int N;
	array<int, 10>arr = {};
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> arr[i];
	}
	sort(arr.rbegin(), arr.rend());
	arr[0] = arr[0] / 2;
	for (int i = 0; i < N; i++) {
		result += arr[i];
	}
	cout << result << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(25) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 998244353
#define MAX 10000000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli A,B,C,D,E,F,L,N,M,K,X,Y,Z,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> N;
  Vec(P,lli,N,0);
  rep(i,0,N)cin >> P[i];
  map<lli,lli>mp1;
  map<lli,lli>mp2;
  rep(i,0,N){
    mp1[P[i]+i+1]++;
    if(i+1-P[i]>0)mp2[i+1-P[i]]++;
  }
  for(auto v:mp2){
    if(mp1.find(v.first)==mp1.end())continue;
    sum+=v.second*mp1[v.first];
  }
  Out(sum);
}

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

int main() {
  string S;
  cin >> S;
  if (S.at(0) == S.at(1) || S.at(1) == S.at(2) || S.at(2) == S.at(3)) {
    cout << "Bad" << endl;
  } else {
    cout << "Good" << endl;
  }
}

Measured memory_bytes: 3632
//#pragma GCC optimize ('O3')
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
#define mp make_pair
#define f first
#define s second
#define pb push_back

const int N = 1e5 + 5;
const int M = 5e5 + 5;
const int OO = 1e9;
const int mod = 1e9 + 7;

string s;

void init() {}

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> s;

    if(s=="RRR") cout << 3;
    else if(s=="RRS" || s=="SRR") cout << 2;
    else if(s[0]=='R' || s[1]=='R' || s[2]=='R') cout << 1;
    else cout << 0;
    cout << '\n';

    return 0;
}

Measured memory_bytes: 3644
n, k = map(int, input().split())
P = list(map(lambda x: int(x)-1, input().split()))
C = list(map(int, input().split()))
ans = -10**18
for i in range(n):  # 開始点を全通り
  x = i
  sc = []
  tot = 0
  while True:
    x = P[x]
    sc.append(C[x])
    tot += C[x]
    if x == i: break  # 開始点に戻ってきて循環に入った
  #print(i, sc, tot)
  l = len(sc)
  cum = 0
  for j in range(l):  # 何ステップ進むとよいか
    cum += sc[j]
    if j+1 > k: break  # k=1は最初の1周のみ
    val = cum  # 循環ループ考慮するスコア
    if tot > 0:
      cyc = (k-(j+1)) // l  # 残りステップで循環できる数
      val += tot * cyc
    ans = max(ans, val)
    #print(j, cum, cyc, val)
print(ans)

Measured memory_bytes: 80960
import sys
input = sys.stdin.readline
n = int(input())
A = list(map(int,input().split()))

m = sum(A) / n
ans = -1
mi = float("inf")
for i in range(n):
    if abs(m - A[i]) < mi:
        ans = i
        mi = abs(m - A[i])
print(ans)

Measured memory_bytes: 38384
#include<stdio.h>
int koyakusu(int a,int b)
{
  int r=1;
  while(r!=0){
    r=a%b;
    a=b;
    b=r;
  }
  
  return a;
}
int main(void)
{
  int x,y,z;
  int num=0;
  int n;
  
  scanf("%d", &n);
  
  for(x=1;x<=n;x++){
    for(y=1;y<=n;y++){
      for(z=1;z<=n;z++){
        num+=koyakusu(koyakusu(x,y),z);
      }
    }
  }
  printf("%d", num);
  
  return 0;
}


Measured memory_bytes: 1732
#include<cstdio>
#include<algorithm>
#include<vector>
#define N_ 201000
using namespace std;
vector<int>E[N_], G[3], V[2];
int T[N_], n, Col[N_], chk[N_], Res[N_];
void DFS(int a, int pp) {
	Col[a] = !Col[pp];
	V[Col[a]].push_back(a);
	for(auto &x : E[a]) {
		if (x == pp)continue;
		DFS(x, a);
	}
}
int main() {
	int i, a, b;
	scanf("%d", &n);
	for (i = 1; i <= n; i++) {
		G[i % 3].push_back(i);
	}
	for (i = 1; i < n; i++) {
		scanf("%d%d", &a, &b);
		E[a].push_back(b);
		E[b].push_back(a);
	}
	DFS(1, 0);
	int pv = 0;
	if (V[pv].size() > V[!pv].size())pv = !pv;
	if (V[pv].size() <= G[0].size()) {
		int pp = 0;
		for (auto &x : V[pv]) {
			Res[x] = G[0][pp];
			chk[G[0][pp]] = 1;
			pp++;
		}
	}
	else {
		int pp = 0, pp2 = 0;
		for (auto &x : V[pv]) {
			if (pp < G[1].size()) {
				Res[x] = G[1][pp];
				chk[G[1][pp]] = 1;
				pp++;
			}
			else {
				Res[x] = G[0][pp2];
				chk[G[0][pp2]] = 1;
				pp2++;
			}
		}
	}
	vector<int>TP;
	for (i = 1; i <= n; i++)if (!chk[i])TP.push_back(i);
	for (i = 0; i < V[!pv].size(); i++) {
		Res[V[!pv][i]] = TP[i];
	}
	for (i = 1; i <= n; i++)printf("%d ", Res[i]);
}

Measured memory_bytes: 22168
D, G = map(int, input().split())
G //= 100
problems = []
for i in range(D):
    b = i + 1
    p, c = map(int, input().split())
    c //= 100
    problems.append((b, p, c))  # 基本点, 問題数, ボーナス

nsolved = {0: 0}  # 総合点 → 必要問題数

for b, p, c in problems:
    nsolved2 = {}
    for k in nsolved:
        for n in range(p + 1):
            s = b * n + (0 if n < p else c)  # n問解いたときの総合点
            g = min(k + s, G)                # 総合点
            if g not in nsolved2:
                nsolved2[g] = nsolved[k] + n
            else:
                nsolved2[g] = min(nsolved2[g], nsolved[k] + n)
    nsolved = nsolved2

print(nsolved[G])


Measured memory_bytes: 67548
#include<bits/stdc++.h>
using namespace std;
bitset<5000000>s;
int main(){
    int n,x,sum=0;
    scanf("%d",&n);
    s[0]=1;
    for(int i=0;i<n;i++)
        scanf("%d",&x),s|=s<<x,sum+=x;
    for(int i=(sum+1)>>1;;i++)
    if(s[i]){
            printf("%d",i);
            return 0;
    }
    return 0;
}


Measured memory_bytes: 2048
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    s = S()
    w = II()
    print(s[::w])
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 38512
#include<bits/stdc++.h>
using namespace std;
int main()
{
   string n,m;
   cin>>n>>m;
   int k=0;
   for(int i=0;i<n.size();i++)
   {
       if(n[i]!=m[i])
       {
           k++;
       }
   }
   cout<<k<<"\n";

}


Measured memory_bytes: 3852
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<long long ,long long>pll;

ll gcd(ll a, ll b) {return (!b ? a : gcd(b, a % b));}
ll lcm(ll a, ll b) {return ((a*b)/gcd(a,b));}
bool cmp(int a,int b){return a>b;}

const ll mod = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;
const ld pi = 3.141592653589793;

long long modpow(long long n, long long k, long long mod)
{
if (k == 0) return 1;
long long r = modpow(n * n % mod, k >> 1, mod);
if (k & 1) r = r * n % mod;
return r;
}

void solve(){
    int n,k;
    cin >> n >> k;
    vector<vector<int>>adj(n+1);
    int maxi = (n-1)*(n-2)/2;
    for(int i = 2;i<=n;i++){
        adj[1].push_back(i);
    }
    if(k>maxi){
        cout << -1;
        return;
    }
    int cnt = 0;bool ok = 0;
    for(int i = 2;i<=n;i++){
        for(int j = i+1;j<=n;j++){
            if(cnt==maxi-k){ok = 1;break;}
            adj[i].push_back(j);
            cnt++;
        }
        if(ok) break;
    }
    int siz = 0;
    for(int i = 1;i<=n;i++) siz += adj[i].size();
    cout << siz <<endl;
    for(int i = 1;i<=n;i++){
        for(int j = 0;j<adj[i].size();j++){
            cout << i <<' ' << adj[i][j] <<endl;
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    solve();
    return 0;
}

Measured memory_bytes: 3592
#include <stdio.h>

int n, A[2000];

int plus(int i, int m){
  int ans;
  if(m==0) return 1;
  if(i>=n) return 0;
  ans = plus(i+1, m) || plus(i+1, m-A[i]);
  return ans;
}

int main(){
  int i, j, q, m;

  scanf("%d", &n);
  for(i=0; i<n; i++) scanf("%d", &A[i]);

  scanf("%d", &q);
  for(j=0; j<q; j++){
    scanf("%d", &m);
    if(plus(0, m)) printf("yes\n");
    else printf("no\n");
  }
  
  return 0;
}



Measured memory_bytes: 2108
H,W = map(int, input().split())
N = int(input())
a = list(map(int, input().split()))

C = [[0 for _ in range(W)] for _ in range(H)]

h = 0
w = 0
total = 0
flag = 1
for i in range(len(a)):
    while a[i] > 0:
        C[h][w] = i + 1
        a[i] -= 1
        if flag == 1:
            if w != W - 1:
                w += 1
            else:
                h += 1
                flag = -1
        else:
            if w != 0:
                w -= 1
            else:
                h += 1
                flag = 1

for i in range(H):
    print(*C[i])



Measured memory_bytes: 3920
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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


fn main() {
    input!{
        a: usize,
        b: usize,
        c: usize,
    }
    let mut ans = 3;
    if a == b && b  == c {
        println!("1");
    } else if a == b || b == c || a == c {
        println!("2");
    }else{
        println!("3");
    }
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main(){
    int a,b,c;
	cin >> a >> b >> c;
	if (a + b >= c){
		cout<<(c-a >= 0 ? c-a : 0 )<<endl;
	}else{
		cout<<"NA"<<endl;
	}
}



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

int main()
{
    int n, l;
    cin >> n >> l;
    int min = 1000;
    int sum = 0;
    rep(i, n)
    {
        if (min > abs(l + i))
            min = abs(l + i);
        sum += l + i;
    }
    if (l + n > 0)
        cout << sum - min << endl;
    else
        cout << sum + min << endl;
    return 0;
}


Measured memory_bytes: 256