akhauriyash/Code-Regression huggingface dataset:
#pragma GCC diagnostic ignored "-Wunused-result"

#include <stdio.h>
#include <string.h>

#define MAX_LEN 11 // 10 chars + 1 '\0'
#define MAX_WORDS 100

static char W[MAX_WORDS][MAX_LEN];

// return 1 : found
// return 0 : not found
static inline int search(const char* searh_word, int num_word) {
  for (int i=0; i<num_word; i++) {
    if (strcmp(W[i],searh_word)==0) {
      // printf("found\n");
      return 1;
    }
  }
  // printf("not found\n");
  return 0;
}

int main(void) {
  int N; // 2<=N<=100
  char last_char = 0;
  int last;
  
  scanf("%d", &N);

  for (int i=0; i<N; i++) {
    char tmp_last_char;
    scanf("%s",W[i]);
    if (i==0) last_char = W[i][0];
    // printf("%s:%c\n",W[i],tmp_last_char);
    if ((W[i][0] != last_char) || (search(W[i], i)==1)) {
      printf("No\n");
      goto end;
    }
    last = strlen(W[i])-1;
    last_char = W[i][last];
  }
  printf("Yes\n");

 end:
  return 0;

}


Measured memory_bytes: 128
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<queue>
using namespace std;
typedef long long LL;
const int maxn = 100000+5;
const LL mod = 1000000007;
int main() {
    int a,b,c;
    cin>>a>>b>>c;
    if (a==b&&b==c) {
        puts("1");
    }
    else if (a==b||a==c||b==c) {
        puts("2");
    }
    else {
        puts("3");
    }
    return 0;
}

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

int main(void){
  int heap[251];
  int h;
  cin >> h;
  for (int i=1;i<=h;++i)
    cin >> heap[i];
  for (int i=1;i<=h;++i){
    cout << "node " << i << ": key = " << heap[i] << ", ";
    if (i!=1)  cout << "parent key = " << heap[i/2] << ", ";
    if (2*i <= h) cout << "left key = " << heap[2*i] << ", ";
    if (2*i+1 <= h) cout << "right key = " << heap[2*i+1] << ", ";
    cout << endl;
  }
}



Measured memory_bytes: 3092
#include <stdio.h>

int main(void){
    int saikoro[6];
    int q,i;
    int top,front;
    int result;
    
    
    for(i=0; i<6; i++){
        scanf("%d",&saikoro[i]);
    }
    scanf("%d",&q);
    for(i=0; i<q; i++){
        scanf("%d %d",&top,&front);
        result = dice(saikoro,top,front);
        printf("%d\n",result);
    }
    
    
    return 0;
}
int dice(int saikoro[6], int top, int front){
    
    if(top == saikoro[0]){
        if( front == saikoro[1]) return saikoro[2];
        if( front == saikoro[2]) return saikoro[4];
        if( front == saikoro[3]) return saikoro[1];
        if( front == saikoro[4]) return saikoro[3];
    }
    if(top == saikoro[1]){
        if( front == saikoro[0]) return saikoro[3];
        if( front == saikoro[2]) return saikoro[0];
        if( front == saikoro[3]) return saikoro[5];
        if( front == saikoro[5]) return saikoro[2];
    }
    if(top == saikoro[2]){
        if( front == saikoro[0]) return saikoro[1];
        if( front == saikoro[1]) return saikoro[5];
        if( front == saikoro[4]) return saikoro[0];
        if( front == saikoro[5]) return saikoro[4];
    }
    if(top == saikoro[3]){
        if( front == saikoro[0]) return saikoro[4];
        if( front == saikoro[1]) return saikoro[0];
        if( front == saikoro[4]) return saikoro[5];
        if( front == saikoro[5]) return saikoro[1];
    }
    if(top == saikoro[4]){
        if( front == saikoro[0]) return saikoro[2];
        if( front == saikoro[2]) return saikoro[5];
        if( front == saikoro[3]) return saikoro[0];
        if( front == saikoro[5]) return saikoro[3];
    }
    if(top == saikoro[5]){
        if( front == saikoro[1]) return saikoro[3];
        if( front == saikoro[2]) return saikoro[1];
        if( front == saikoro[3]) return saikoro[4];
        if( front == saikoro[4]) return saikoro[2];
    }
    return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const int MOD = 1000000007;

vector<vector<int> > c;
int counter[200000];
bool used[200000];

void walk(int i) {
    used[i] = true;
    for(int j : c[i]) {
        if(used[j]) continue;
        counter[j] += counter[i];
        walk(j);
    }
}

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

    rep(i, n) {
        vector<int> v;
        c.pb(v);
    }

    rep(i, n - 1) {
        int a, b;
        cin >> a >> b;
        c[a - 1].pb(b - 1);
        c[b - 1].pb(a - 1);
    }

    rep(i, n) {
        counter[i] = 0;
        used[i] = false;
    }
    rep(i, q) {
        int p, x;
        cin >> p >> x;
        counter[p - 1] += x;
    }
    walk(0);

    rep(i, n) {
        if(i != 0) cout << " ";
        cout << counter[i];
    }
    cout << endl;

    return 0;
}



Measured memory_bytes: 21996
#include <stdio.h>

#define LENGTH 5

int main(void) {
    char a[LENGTH];

    scanf("%s", a);
    
    if((a[0] == a[1]) && (a[2] == a[3]) && (a[1] != a[2])){
        printf("Yes\n");
    }else if((a[1] == a[2]) && (a[0] == a[3]) && (a[0] != a[1])){
        printf("Yes\n");
    }else if((a[0] == a[2]) && (a[1] == a[3]) && (a[0] != a[1])){
        printf("Yes\n");
    }else{
        printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 128
n,m = map(int,input().split())
a = [list(input()) for _ in range(n)]
b = [list(input()) for _ in range(m)]
r = any([r[j:j+m] for r in a[i:i+m]]==b for i in range(n-m+1) for j in range(n-m+1))
print("Yes" if r == True else "No")

Measured memory_bytes: 3060
#include <fstream>
#include <iostream>
#include <cmath>
#include <vector>
#include <queue>
#include <utility>
#include <algorithm>
using namespace std;

int main() {
  // ifstream cin("../test.txt");
  int w[10];
  int k[10];
  for (int i = 0; i < 10; i++)
    cin >> w[i];
  for (int i = 0; i < 10; i++)
    cin >> k[i];

  sort(w, w + 10);
  sort(k, k + 10);

  int sum_w = w[7] + w[8] + w[9];
  int sum_k = k[7] + k[8] + k[9];

  cout << sum_w << " " << sum_k << endl;;
}

Measured memory_bytes: 1180
#include <iostream>
#include <string>
#include <vector>
#include <set>
using namespace std;

int greedy(int A, int B, int C, vector<int> &L)
{
  int m = 10000;
  int N = L.size();
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < N; ++j) {
      if (i == j) continue;
      for (int k = 0; k < N; ++k) {
        if (i == k || j == k) continue;
        m = min(m, abs(A - L[i]) + abs(B - L[j]) + abs(C - L[k]));
      }
    }
  }

  return m;
}

int search(int A, int B, int C, vector<int> &L, int upper=10000)
{
  upper = min(upper, greedy(A, B, C, L));
  if (L.size() == 3 || upper <= 10) return upper;

  for (int i = 0; i < L.size(); ++i) {
    for (int j = i + 1; j < L.size(); ++j) {
      vector<int> LL = L;
      LL[i] += LL[j];
      LL.erase(LL.begin() + j);
      upper = min(upper, 10 + search(A, B, C, LL, upper - 10));
    }
  }

  return upper;
}

int main()
{
  int N, A, B, C;
  cin >> N >> A >> B >> C;
  
  vector<int> L;
  for (int i = 0; i < N; ++i) {
    int len; cin >> len;
    L.push_back(len);
  }

  vector<int> G;
  for (int i = 0; i < N; ++i) {
    G.push_back(i);
  }

  cout << search(A, B, C, L) << endl;

  return 0;
}


Measured memory_bytes: 256
N = int(input())
H = [int(x) for x in input().split()]
count = 0
LC = [] #LCはそれぞれ左から数えた時の条件を満たさなくなるまでの長さ
pt = 0
for i in range(N):
    if i != N-1 and H[i] >= H[i+1]:
        count += 1
    else:
        LC.append(count)
        count = 0
print(max(LC))

Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
#define INF 2147483647
#define INFF 9223372036854775807
#define ll long long
#define REP(i,n) for(long long i=0;i<n;i++)
#define REPP(i,m,n) for(long long i=m;i<n;i++)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int N , Q;
int a[200010] , b[200010];
int p[200010],x[200010];
vector<int> V[200010],num(200010),ans(200010);
bool flag[200010];
int root = 1,cnt[200100] = {};

void solve(int &i,int &pred){
  	cnt[i] += cnt[pred];
    REP(j,V[i].size()){
        if(V[i][j] != pred)solve((int&)V[i][j],(int&)i);
    }
}

int main() {
    cin.tie(0);    
	ios::sync_with_stdio(false);
    cin >> N >> Q;
    REP(i,N-1){
        cin >> a[i] >> b[i];
        V[a[i]].pb(b[i]);
      	V[b[i]].pb(a[i]);
        flag[b[i]] == false;
    }
    REPP(i,1,N+1){
        if(flag[i] == true){
            root = i;
            break;
        }
    }
    REP(i,Q){
        cin >> p[i] >> x[i];
        cnt[p[i]] += x[i];
    }
  	int m = 0;
    solve((int&)root,(int&)m);
    REPP(i,1,N+1){
        cout << cnt[i] << ' ';
    }
    cout << endl;
}

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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF 9223372036854775807

bool ans;
string s;

signed main() {
    cin >> s;
    rep(i,s.size()-8) cout << s[i];
    cout << endl;
}












Measured memory_bytes: 256
fn main() {
    let mut input1 = String::new();
    std::io::stdin().read_line(&mut input1).unwrap();
    let mut input2 = String::new();
    std::io::stdin().read_line(&mut input2).unwrap();
    println!("{}", input1.chars().zip(input2.chars()).filter(|(a, b)| a != b).count());
}

Measured memory_bytes: 2476
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int a[100005],b[100005];
struct info{
	int v,po,t;
	bool operator <(const info b)const{
		return v<b.v;
	}
}c[200005];
int tp[100005],cnt[4];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d%d",&a[i],&b[i]),c[2*i-1]=(info){a[i],i,1},c[2*i]=(info){b[i],i,2};
	sort(c+1,c+2*n+1);
	for(int i=1;i<=n;i++)tp[c[i].po]|=c[i].t;
	for(int i=1;i<=n;i++)cnt[tp[i]]++;
	long long res=0;
	for(int i=1;i<=n;i++)res+=c[i].v;
	if(cnt[0]||!cnt[1]||!cnt[2])printf("%lld\n",res);
	else if(c[n+1].po!=c[n].po)printf("%lld\n",res+c[n+1].v-c[n].v);
		 else printf("%lld\n",res+min(c[n+1].v-c[n-1].v,c[n+2].v-c[n].v));
}

Measured memory_bytes: 3712
import math
X = int(input())

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True

for i in range(10**7):
    if i < X:
        continue
    elif is_prime(i) is True:
        print(i)
        exit()


Measured memory_bytes: 63652
#include <algorithm>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

int main(void) {
  int64_t N, M, V, P;
  cin >> N >> M >> V >> P;
  vector<int64_t> A(N);
  rep(i, N) { cin >> A[i]; }
  sort(A.begin(), A.end(), greater<int>());

  int left = 0;
  int right = N;
  while (left + 1 < right) {
    int mid = left + (right - left) / 2;
    if ((A[mid] + M) < A[P - 1]) {
      right = mid;
      continue;
    }
    int64_t score = 0;
    score += M * (1 + (P - 1) + (N - mid - 1));
    for (int j = P - 1; j < mid; ++j) {
      if (A[j] < (A[mid] + M)) {
        score += (A[mid] + M - A[j]);
      }
    }
    if (M * V <= score) {
      left = mid;
    } else {
      right = mid;
    }
  }
  int answer = right;
  cout << answer << endl;
  return 0;
}

Measured memory_bytes: 1024
# 入力
N, M = map(int, input().split())
X, Y, Z = (
    zip(*(map(int, input().split()) for _ in range(M))) if M else
    ((), (), ())
)


# UnionFind木で連結成分の個数を数える
class UnionFindTree:
    def __init__(self, n):
        self.p = [i for i in range(n + 1)]
        self.r = [0 for _ in range(n + 1)]

    def find(self, x):
        if self.p[x] != x:
            self.p[x] = self.find(self.p[x])
        return self.p[x]

    def union(self, x, y):
        px = self.find(x)
        py = self.find(y)
        if px != py:
            if self.r[px] < self.r[py]:
                self.p[px] = py
            else:
                self.p[py] = px
                if self.r[px] == self.r[py]:
                    self.r[px] += 1

    def same(self, x, y):
        return self.find(x) == self.find(y)


uft = UnionFindTree(N)
for x, y in zip(X, Y):
    uft.union(x, y)
ans = len({uft.find(i) for i in range(1, N + 1)})

# 出力
print(ans)


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

#define fi first
#define se second
#define pb push_back
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define FOR(i, a, b) for (int i = a; i <= (b); i++)
#define ROF(i, a, b) for (int i = a; i >= (b); i--)

using pii = pair<int, int>; using vpii = vector<pii>;
using vi = vector<int>; using vvi = vector<vi>;
using ll = long long;
using pll = pair<ll, ll>; using vpll = vector<pll>;
using vll = vector<ll>; using vvll = vector<vll>;

int main() {
    int n; cin >> n;
    string s; cin >> s;
    vi c(n + 1);
    vvi ps(n + 1, vi(4));
    FOR(i, 0, n - 1) {
        if (s[i] == 'R') c[i + 1] = 1;
        else if (s[i] == 'G') c[i + 1] = 2;
        else c[i + 1] = 3;
        ps[i + 1][c[i + 1]]++;
        FOR(j, 1, 3)
            ps[i + 1][j] += ps[i][j];
    }
    vvi ss(n + 2, vi(4));
    ROF(i, n, 1) {
        ss[i][c[i]]++;
        FOR(j, 1, 3)
            ss[i][j] += ss[i + 1][j];
    }
    ll ans = 0;
    FOR(i, 1, n) {
        FOR(j, 1, 3) FOR(k, 1, 3) {
            if (c[i] ^ j ^ k ^ 1 ^ 2 ^ 3) continue;
            ans += ps[i - 1][j] * ss[i + 1][k];
        }
        for (int j = 1; i - j > 0 && i + j <= n; j++)
            if ((c[i] ^ c[i - j] ^ c[i + j] ^ 1 ^ 2 ^ 3) == 0)
                ans--;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3932
#ABC073C
N=int(input())
A=[int(input()) for i in range(N)]
A_sorted=sorted(A)
count=1
ans=0
for i in range(N-1):
    if A_sorted[i]==A_sorted[i+1]:
        count+=1
    else:
        ans+=count%2
        count=1
ans+=count%2
print(ans)


Measured memory_bytes: 8276
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define sqr(x) ((x)*(x))
#define mp make_pair
#define uint unsigned
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read(){
	int x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(int a){
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(int a){
    if(a<0){
    	a=-a; putchar('-');
	}
	write(a); puts("");
}
const int N=2005,mod=1000000007;
int n,k,c[N*N],dp[N][N];
inline void add(int &a,ll b){
	a=(a+b)%mod;
}
inline int ksm(ll a,int b){
	int ans=1;
	for(;b;b>>=1){
		if(b&1)ans=ans*a%mod;
		a=a*a%mod;
	}
	return ans;
}
int main(){
	n=read(); k=read();
	if(k==1){puts("1"); return 0;}
	c[k-2]=1; for(int i=k-1;i<=n*k;i++)c[i]=(ll)c[i-1]*i%mod*ksm(i-(k-2),mod-2)%mod;
	dp[0][0]=1;
	for(int i=0;i<=n;i++){
		for(int j=i;j<=n;j++){
			add(dp[i+1][j],(ll)dp[i][j]*c[n*k-i*(k-1)-j-1]);
			add(dp[i][j+1],dp[i][j]);
			//cout<<i<<" "<<j<<" "<<dp[i][j]<<endl;
		}
	}
	ll ans=dp[n][n];
	for(int i=1;i<=n;i++)ans=ans*i%mod;
	cout<<ans<<endl;
}
/*
5*4*3=4*3*2
*/

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

using namespace std;
using i64 = int64_t;

int main(){
    int N;
    cin >> N;
    map<char, i64> m;
    for(int i=0;i<N;i++){
        string s;
        cin >> s;
        m[s[0]]++;
    }
    i64 ans = 0;
    ans += m['M'] * m['A'] * m['R'];
    ans += m['M'] * m['A'] * m['C'];
    ans += m['M'] * m['A'] * m['H'];
    ans += m['C'] * m['A'] * m['R'];
    ans += m['H'] * m['A'] * m['R'];
    ans += m['M'] * m['C'] * m['R'];
    ans += m['M'] * m['H'] * m['R'];
    ans += m['C'] * m['A'] * m['H'];
    ans += m['H'] * m['C'] * m['R'];
    ans += m['M'] * m['C'] * m['H'];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3548
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e9;
const ll MOD = 1e9 + 7;


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

    using P = pair<ll, ll>;
    vector<P> v(n);

    int pn = 0, nn = 0;

    int neg_num = 0;
    int zero = 0;
    rep(i, n){
        cin >> v[i].first;
        if(v[i].first != 0) v[i].second = v[i].first / abs(v[i].first);
        else zero++;
        v[i].first = abs(v[i].first);
        if(v[i].second < 0) neg_num++;

        if(v[i].second < 0) nn++;
        else pn++;
    }


    sort(rall(v));

    int sgn = 1;
    int pos = -1, neg = -1;
    rep(i, k){
        sgn *= v[i].second;
        if(v[i].second > 0) pos = i;
        else neg = i;
    }


    if((n == k && sgn < 0) || (k%2 == 1 && neg_num == n)){
        ll ans = 1;
        rep(i, k){
            ans *= v[n-i-1].first;
            ans %= MOD;
        }
        cout << MOD - ans << endl;
        return 0;
    }

    if(sgn > 0){
        ll ans = 1;
        rep(i, k){
            ans *= v[i].first;
            ans %= MOD;
        }
        cout << ans << endl;
        return 0;
    }

    ll A = (pos != -1) ? v[pos].first : -1;
    ll B = (neg != -1) ? v[neg].first : -1;
    ll x = 1, y = 1;
    rep(i, k){
        if(i != pos) x *= v[i].first, x %= MOD;
        if(i != neg) y *= v[i].first, y %= MOD;
    }

    bool flag_x = false, flag_y = false;
    for(int i=k; i<n; i++){
        if(pos != -1 && !flag_x && v[i].second < 0){
            flag_x = true;
            x *= v[i].first;
            x %= MOD;
            B *= v[i].first;
        }
        if(neg != -1 && !flag_y && v[i].second > 0){
            flag_y = true;
            y *= v[i].first;
            y %= MOD;
            A *= v[i].first;
        }
    }


    if(!flag_x) x = -1;
    if(!flag_y) y = -1;

    ll ans = (A > B) ? y : x;
    if(x == -1) ans = y;
    if(y == -1) ans = x;
    
    ll z = (zero > 0) ? 0 : -1;

    cout << max(ans, z) << endl;
}

Measured memory_bytes: 6372
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define endl '\n'
#define D(x) cerr << #x << " = " << (x) << '\n'
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
typedef long long ll;



int main()
{
  int k;
  cin >> k;
  while(k--)  
    cout << "ACL";
  cout << endl;
  return 0;
}


Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(a==b&&b!=c) cout << "Yes" << endl;
  else if(a==c&&a!=b) cout << "Yes" << endl;
  else if(b==c&&b!=a) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
import sys
import math
from fractions import gcd
# import queue
# from collections import Counter
# from itertools import accumulate
# from functools import reduce

def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""
# 標準入力取得
## 文字列
 =  sys.stdin.readline().rstrip()
 =  list(sys.stdin.readline().rstrip())

## 数値
 =  int(sys.stdin.readline())
 =  map(int, sys.stdin.readline().split())
 =  list(map(int, sys.stdin.readline().split()))
 =  [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""


S =  sys.stdin.readline().rstrip()

if "a" in S and "b" in S and "c" in S:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 63980
#include <bits/stdc++.h>
#define LL long long
using namespace std;
int main() {
    ios::sync_with_stdio(false),cin.tie(0);
    int a,p;
    cin >> a >> p;
    a = 3 * a + p;
    cout << a / 2 << endl;
    return 0;
}


Measured memory_bytes: 256
n, x = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
a.sort!
ans = 0
i = 0
tmp = a[0].to_i
while tmp <= x && i < n do
  if i == n-1
    if a[i] == x
      ans += 1
    end
  else
    x -= tmp
    ans += 1
    tmp = a[i+1].to_i
  end
  i +=1
end
puts ans


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int ans_hypo(std::vector<pair<char,bool>> A,std::vector<pair<char,bool>> B){
	int ans = 0;
	for (int i = 0; i < (int)A.size(); ++i)
	{
		if(A[i].second && B[i].second) ans++;
	}
	return ans;
}

int main() {
	int n; cin >> n;
	string s; cin >> s;
	std::vector<pair<char,bool>> abcL(26);/////
	std::vector<pair<char,bool>> abcR(26);/////
	string ABC = "abcdefghijklmnopqrstuvwxyz";
	for (int i = 0; i < 26; ++i) abcL[i] = make_pair(ABC[i],false);////set
	for (int i = 0; i < 26; ++i) abcR[i] = make_pair(ABC[i],false);////set

	int ANS = 0;

	for (int i = 1; i < n; ++i)
	{
		string L = s.substr(0,i);
		string R = s.substr(i);
		for (int j = 0; j < i; ++j)
		{
			for (int k = 0; k < 26; ++k)
			{
				if(L[j]==abcL[k].first) abcL[k].second = true;
			}
		}

		for (int j = 0; j < (int)R.size(); ++j)
		{
			for (int k = 0; k < 26; ++k)
			{
				if(R[j]==abcR[k].first) abcR[k].second = true;
			}
		}

		ANS = max(ANS, ans_hypo(abcL,abcR));
        
        for (int i = 0; i < 26; ++i)
        {
        	abcL[i].second = false;
        	abcR[i].second = false;
        }

	}

	cout << ANS << endl;



}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P; 
const int inf = 1<<21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, r;
    cin >> n >> r;
    if (n>=10){
        cout << r << endl;
    }else{
        cout << r+100*(10-n) << endl;
    }

    return 0;
}

Measured memory_bytes: 256
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

/*  Macros from Endagorion */
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;


int main(){
        
    ios_base::sync_with_stdio(0);
    
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    int n,m;
    cin>>n>>m;
    int l = INT_MIN, r=INT_MAX;
    for(int j=1;j<=m;j++){
        int x,y;
        cin>>x>>y;
        l = max(l, x);
        r = min(r, y);
    }

    if(l<=r)    cout<<r-l+1<<endl;
    else        cout<<0<<endl;
    return 0;
}



Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define MOD 1000000007
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <bitset>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <string>
#include <functional>
#include <algorithm>
#include <iterator>
#include <cstdio>
#include <utility>
#include <unordered_map>
#include <cmath>
#include <chrono>
#include <random>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

typedef pair<ll, ll> P;
struct edge { ll to, cost; };

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define RFOR(i,a,b) for(ll i=(a);i>(b);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,n-1,-1)

inline ll madd(ll a, ll b) {
	a %= MOD;b %= MOD;
	return (a + b) % MOD;
}
inline ll msub(ll a, ll b) {
	a %= MOD;b %= MOD;
	a += MOD;
	return (a - b) % MOD;
}
inline ll mmul(ll a, ll b) {
	a %= MOD;b %= MOD;
	return (a*b) % MOD;
}
inline ll mpow(ll a, ll r) {
	long long res = 1;
	while (r > 0) {
		if (r & 1) res = res * a % MOD;
		a = a * a % MOD;
		r >>= 1;
	}
	return res;
}
inline ll minv(ll a) {
	a %= MOD;
	ll b = MOD, u = 0, v = 1;
	while (a) {
		ll t = b / a;
		b -= t * a; swap(a, b);
		u -= t * v; swap(u, v);
	}
	if (u < 0) u += MOD;
	return u;
}
inline ll mdiv(ll a, ll b) {
	a %= MOD;
	a *= minv(b);
	return a%MOD;
}

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) { }
	bool unite(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool same(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

/*
ll fact[100001], fact_inv[100001];
void calc_fact{
	fact[0]=1;
	REP(i,100000){
		fact[i+1]=mmul(fact[i],i+1);
		fact_inv[i+1]=minv(fact[i+1]);
	}
}
ll combi(int a, int b) {
	return mmul(fact[a], mmul(fact_inv[b], fact_inv[a - b]));
}
*/

int res[301][301];
int main(void) {
	int h, w, k, now=0;
	cin >> h >> w >> k;
	string s;
	REP(i, h) {
		cin >> s;
		bool isok = false;
		bool skip_once = true;
		REP(j, w) {
			if (s[j] == '#') {
				isok = true;
				now++;
				break;
			}
		}
		if (isok) {
			REP(j, w) {
				if (s[j] == '#') {
					if (!skip_once) now++;
					else skip_once = false;
				}
				res[i][j] = now;
			}
		}
	}
	FOR(i, 1, h) {
		REP(j, w) {
			if (res[i][j] == 0 && res[i - 1][j] != 0) res[i][j] = res[i - 1][j];
		}
	}
	RFOR(i, h-2, -1) {
		REP(j, w) {
			if (res[i][j] == 0 && res[i + 1][j] != 0) res[i][j] = res[i + 1][j];
		}
	}
	REP(i, h) {
		REP(j, w) {
			cout << res[i][j]<< " ";
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define all(v) (v).begin(), (v).end()
#define lp(i, n) for (int i = 0; i < (n) ; ++i)
#define sz(v) (ll)(v).size()
#define int long long
#define mod 1000000007

void solve() {
        int n; cin >> n; cout << (n + 1)/ 2<< "\n";
}

int32_t main(){
ios::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
        int t = 1;
        //cin >> t;
        while ( t-- ) {
                solve();
        }
return 0;
}


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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

template <typename T> T id(T b) {return b;};
template <class It> bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It> bool any(It f,It l){return std::any_of(f,l,id<bool>);}
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }

const int MAX_N = 50;
int n;
int v[MAX_N];

int main()
{
  cin >> n;
  forn(i,n) cin >> v[i];

  sort(v,v+n);

  double res = (v[0]+v[1])/2.0;
  for (int i = 2; i < n; i++) {
    res = (res + v[i])/2.0;
  }

  printf("%.10f\n",res);

  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python

N=int(input())
Num=[0]*4
A=N//1000
B=N//100%10
C=N//10%10
D=N%10

'''
for i in range(0, len(Num)):
    print(Num[i])
'''

Num.sort()
mul=[-1,1]

def ope(sym):
    if(sym==-1):
        return "-" 
    elif(sym==1):
        return "+"

def cal():
    for j in mul:
        for k in mul:
            for m in mul:
                if( A + B*j + C*k + D*m == 7 ):
                    # print("j, k, m", j, k, m)
                    print(str(A)+ope(j)+str(B)+ope(k)+str(C)+ope(m)+str(D)+"=7")
                    return

cal()

Measured memory_bytes: 3064
import java.util.Scanner;

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

    long N = scanner.nextLong();
    long min = 1_000_000_000_000_000L;
    for (int i = 0; i < 5; i++) {
      long a = scanner.nextLong();
      min = Math.min(a, min);
    }
    System.out.println((N - 1) / min + 5);
  }
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int a,b,c,d,e; cin >> a >> b >> c >> d >> e;
    int k; cin >> k;
    if(e-a>k)
    {
        cout << ":(" << endl;
    }
    else
    {
        cout << "Yay!" << endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	double x1, y1, x2, y2;

	scanf("%lf%lf%lf%lf", &x1, &y1, &x2, &y2);
	printf("%.8lf\n", hypot(x1 - x2, y1 - y2));

	return 0;
}


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

int mod = 1'000'000'007;

long long modpow(long long x, long long y){
    if (y == 0) return 1;
    if (y % 2) return x * modpow(x, y - 1) % mod;
    return modpow(x, y / 2) * modpow(x, y / 2) % mod;
}

long long getCmb(long long x, long long y){
    y = min(y, x - y);
    long long fac = 1;
    long long div = 1;
    for (int i = 0; i < y; i++){
        fac *= x - i;
        fac %= mod;
        div *= i + 1;
        div %= mod;
    }
    return fac * modpow(div, mod - 2) % mod;
}

int main(){
    vector<long long> inv(200'000, 0);
    inv[1] = 1;
    for (int i = 2; i < 200'000; i++){
        inv[i] = (mod - inv[mod % i]) * (mod / i) % mod;
    }
    int h, w, a, b;
    cin >> h >> w >> a >> b;
    long long ans = getCmb(h + w - 2, h - 1);
    long long x, y;
    for (int i = 0; i < b; i++){
        if (i == 0){
            x = getCmb(h - a - 1, 0);
            y = getCmb(w + a - 2, a - 1);
            ans += mod - (x * y) % mod;
            ans %= mod;
        }
        else {
            x *= h - a - 1 + i;
            x %= mod;
            x *= inv[i];
            x %= mod;
            y *= w - i;
            y %= mod;
            y *= inv[w + a - 1 - i];
            y %= mod;
            ans += mod - (x * y) % mod;
            ans %= mod;
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
const int N=1e6+5;
typedef long long ll;
char s[N];
int n,a[N];
ll f(int x)
{
    ll ans=0;
    while(x)
    {
        x/=2;ans+=x;
    }
    return ans;
}
ll C(int n,int m)
{
    return f(n)-f(n-m)-f(m);
}
int main()
{
    scanf("%d%s",&n,s+1);
    for(int i=1;i<=n;i++) a[i]=s[i]-'0'-1;
    int ans=0;
    for(int i=1;i<=n;i++)
        if(a[i]&1)
        if(C(n-1,i-1)==0) ans^=1;
    if(ans) printf("1\n");
    else
    {
        ans=0;
        for(int i=1;i<=n;i++)
        {
            if(a[i]==1) {printf("0\n");return 0;}
            if(a[i]==2&&C(n-1,i-1)==0) ans^=1;
        }
        if(ans) printf("2\n");
        else printf("0\n");
    }
}


Measured memory_bytes: 5120
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n = read::<usize>();
    solve(n);
}

fn solve(n: usize) {
    if n.count_ones() == 1 {
        println!("No");
        return;
    }
    let max_bit = n.next_power_of_two() / 2;
    let mut anss: Vec<(usize, usize)> = vec![];
    for i in 1..max_bit - 1 {
        anss.push((i, i + 1));
    }
    for i in 1..max_bit - 1 {
        let prev = if i == 1 { n + 1 } else { n + (i ^ 1) };
        let next = n + ((i + 1) ^ 1);
        anss.push((prev, next));
    }
    anss.push((1, max_bit));
    anss.push((1, max_bit + 1));
    anss.push((n + 1, n + max_bit));
    anss.push((n + 1, n + 1 + max_bit));
    anss.push((max_bit, n + 1 + max_bit));
    for i in (max_bit + 2)..n + 1 {
        let prev = max_bit ^ (i % 2) ^ (i % 4 / 2);
        anss.push((prev, i));
        let next = (i - max_bit) / 2 * 2;
        anss.push((next, i + n));
    }
    println!("Yes");
    for ans in anss.iter() {
        println!("{} {}", ans.0, ans.1);
    }
}

Measured memory_bytes: 11896
#include <iostream>
#include <string>
#include <vector>


int main(){
    int n, a, b;
    std::vector<int> vec{};
    std::cin >> n >> a >> b;
    
    int answer = 0;
    
    for(int i = 1; i <= n; i++){
        int check_num = i;
        int k_count = 0;
        while(check_num > 0){
            k_count += check_num % 10;
            check_num = check_num / 10;
        }
        if(k_count >= a && k_count <= b){
            answer += i;
        }
    }
    
    std::cout << answer;
}


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


using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;++i)
#define REP(i,s,n) for(int i=(s);i<(n);++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define REPR(i,s,n) for(int i=(s);i>=(n);--(i))
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define DOUBLE fixed << setprecision(10)
#define fi first
#define se second
const double pi = acos(-1.0);
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef deque<ll> dll;
typedef pair<ll, ll> P;
typedef vector<P> vP;
const ll mod = 1e9 + 7;
ll dx[4] = { 1,0,-1,0 };
ll dy[4] = { 0,1,0,-1 };
template <typename T>
bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
};
template <typename T>
bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
};
void Pvll(vll v) {
	cout << "------------------------------------------------\n";
	rep(i, v.size()) cout << v[i] << " ";
	cout << endl;
	cout << "------------------------------------------------\n";
}
void Pvvll(vvll v) {
	cout << "------------------------------------------------\n";
	rep(i, v.size()) {
		rep(j, v[i].size()) {
			cout << v[i][j] << " ";
		}
		cout << endl;
	}
	cout << "------------------------------------------------\n";
}

void Ps(string s) {
	cout << "------------------------------------------------\n";
	rep(i, s.size()) cout << s[i] << " ";
	cout << endl;
	cout << "------------------------------------------------\n";
}

void Pvs(vs s) {
	cout << "------------------------------------------------\n";
	rep(i, s.size()) {
		rep(j, s[i].size()) {
			cout << s[i][j] << " ";
		}
		cout << endl;
	}
	cout << "------------------------------------------------\n";
}

void Yes(bool x) {
	if (x) cout << "Yes\n";
	else cout << "No\n";
}

void YES(bool x) {
	if (x) cout << "YES\n";
	else cout << "NO\n";
}

void yes(bool x) {
	if (x) cout << "yes\n";
	else cout << "no\n";
}

void Yay(bool x) {
	if (x) cout << "Yay!\n";
	else cout << ":(\n";
}


ll  n, m, r, l, k, h, w, ans = 0, ret = M;
bool flag = false, flag2 = false, flag3 = false;
string s,t;

void INIT() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << DOUBLE;
}

int main() {
	INIT();


	cin >> n;
	cout << 3 * n * n << endl;

	return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define vec vector
#define fi first
#define se second
#define eb emplace_back
#define ef emplace_front
#define pof pop_front()
#define pob pop_back()
#define Rep(i,n) for(li i=0,nn=(li)(n);i!=nn;++i)
#define Rep1(i,n) for(li i=1,nn=(li)(n)+1;i!=nn;++i)
#define Size(v) (li)(v.size())
#define SortA(v) sort(v.begin(),v.end())
#define SortD(v) sort(v.rbegin(),v.rend())
#define All(a) (a).begin(),(a).end()
#define Input(a) for(li ii=0,nn=(li)(a.size());ii!=nn;++ii){cin>>(a).at(ii);}
#define Input2(a,b) for(li ii=0,nn=(li)(a.size());ii!=nn;++ii){cin>>(a).at(ii)>>(b).at(ii);}
#define mp make_pair
using li = int64_t;
using intl = int64_t;
using vi = vec<li>;
using vb = vec<bool>;
using vvi = vec<vi>;
using qi = deque<li>;
using pi = pair<li,li>;
using vpi = vec<pi>;
using si = set<li>;
using vsi = vec<si>;
using mii = map<li,li>;
using vmii = vec<mii>;
vec<li> dx = {0, 1, 0, -1, 1, 1, -1, -1};
vec<li> dy = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr li INF = 9223372036854775807;

void Yes(li b){
  if(b)cout<<"Yes";
  else cout<<"No";
}
void yes(li b){
  if(b)cout<<"yes";
  else cout<<"no";
}

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

  int N;
  cin >>N;

  deque<li> A;
  li a;
  Rep(i,N){
    cin >>a;
    if(A.empty() || a!=A.back())A.eb(a);
  }
  
  N = A.size();
  
  if(N ==1){cout <<1000;return 0;}

  li money =1000;
  li stock =0;
  li last;

  if(A[0]<A[1]){
  	stock += money/A[0];
  	money -= A[0]*stock;
  }
  
  
  Rep1(i,N-2){
  	if(A[i-1]>A[i]&&A[i+1]>A[i]){
  	stock += money/A[i];
  	money -= A[i]*stock;
  	}
  	if(A[i-1]<A[i]&&A[i+1]<A[i]){
  	money += A[i]*stock;
  	stock =0;
  	last = A[i];
  	}
    //cout <<money<<endl;
  }
 
  
  if(A[N-2]<A[N-1]){
  	money += A[N-1]*stock;
  	stock =0;
  }

  if(!stock){
  	money += stock *last;
  }

  cout <<money;

}

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

int main(){
    int N;
    int64_t K;
    cin >> N >> K;
    vector<int> A(N);
    for(int i=0; i<N; i++) cin >> A.at(i);
    vector<bool> new_flag(N, true);
    int current_town = 0;
    int pre_town = 0;
    vector<int> town_order(N);
    int count = 0;
    town_order.at(0) = 0;
    while(true){
        pre_town = current_town;
        current_town = A.at(current_town) - 1;
        if(!(new_flag.at(current_town))) break;
        new_flag.at(current_town) = false;
        count++;
        town_order.at(current_town) = count;
    
    }
    int to_close_length = town_order.at(current_town);
    int close_length = town_order.at(pre_town) - town_order.at(current_town) + 1;

    if(K<=to_close_length){
        current_town = 0;
        for(int i=0; i<K; i++) current_town = A.at(current_town) - 1;
    }
    else{
        K -= to_close_length;
        K %= close_length;
        for(int i=0; i<K; i++) current_town = A.at(current_town) - 1;
    }

    cout << current_town + 1 << endl;
}

Measured memory_bytes: 4844
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
      int A, B, C, D;
      cin >> A >> B >> C >> D;
     
      if ((A + B) < (C + D))
        cout << "Right" << endl;
      
      else if ((A + B) > (C + D))
        cout << "Left" << endl;
      
      else
        cout << "Balanced" << endl; 
      
    }

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

using namespace std;
using ll = long long;

vector<int> prime;

void fact() {
    vector<int> a(1e4 + 10);
    for(int i = 2; i < 1e4 + 10; i++) {
        if(a[i])continue;
        prime.emplace_back(i);
        for(int j = i; j < 1e4 + 10; j += i)a[j] = 1;
    }
}

int main()
{
    int n; cin >> n;
    int cnt = 0;
    fact();
    for(int i = 0; i < n; i++) {
        int t;cin >> t;
        bool res = true;
        for(auto j : prime)if(t % j == 0 && t != j)res = false;
        if(res)cnt++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 3208
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main() {
	int n, k;
	cin >> n >> k;
	vector<ll> a(n);
	rep(i, n) cin >> a[i];
	ll ans = 1LL << 60;
	for(int bit = 1; bit < (1 << n); bit++) {
		// bitが1の建物が見えるようにする（0の建物は高さを増やさないが、見えても良い）
		int cnt = 0;
		rep(i, n) {
			if(bit & 1 << i) cnt++;
		}
		if(cnt < k) continue;	// 見える建物がk未満の組み合わせは飛ばす
		vector<ll> b = a;
		ll sum = 0;
		rep(i, n) {
			if(!(bit & 1 << i)) continue;
			// bitが1の建物について
			ll high = 0;	// high: i未満の建物の中で最大の高さ
			rep(j, i) {
				high = max(high, b[j]);
			}
			// i番目の建物が見えるように、b[i] <= highならhigh+1-b[i]だけ高さを増やす。
			if(b[i] <= high){
				sum += high + 1 - b[i];
				b[i] = high + 1;
			}
		}
		ans = min(ans, sum);
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, l, r) for (int i = l; i <= (int)(r); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define all(v) v.begin(), v.end()
#define MOD (int) (1e9+7)
#define INF (int) 1e9
#define LLINF (ll) 1e18

int main(){
    int n;
    cin >> n;
    int l[n];
    rep(i, n) cin >> l[i];

    sort(l, l+n);

    int ans = 0;
    rep(i, n) rep(j, n)rep(k, n){
        if(!(i<j && j < k)) continue;
        if(l[i]==l[j] || l[k]==l[j] || l[i]==l[k]) continue;
        // if(l[i] +l[j] > l[k] && abs(l[i]-l[j]) < l[k]) ans++;
        if(l[i] +l[j] > l[k]) ans++;
    }
    cout << ans << endl;
    // printf("%d\n", N);
    return 0;
}

Measured memory_bytes: 3632
#https://atcoder.jp/contests/abc152/tasks/abc152_c

n=int(input())
p=list(map(int,input().split()))
count=1
min_num=p[0]
for i in range(1,n):
    min_num=min(p[i-1],min_num)
    if p[i]<=min_num:
        count+=1
print(count)

Measured memory_bytes: 75472
import java.util.Arrays;
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int M = scan.nextInt();
		int X = scan.nextInt();
		int Y = scan.nextInt();
		int[]x = new int[N];
		int[]y = new int[M];
		for(int i = 0; i < N; i++) {
			x[i] = scan.nextInt();
		}
		for(int i = 0; i < M; i++) {
			y[i] = scan.nextInt();
		}
		scan.close();
		Arrays.sort(x);
		Arrays.sort(y);
		if(x[N - 1] < y[0]) {
			int k = y[0];
			if(k > X && k <= Y) {
				System.out.println("No War");
			}else {
				System.out.println("War");
			}
		}else {
			System.out.println("War");
		}
	}
}


Measured memory_bytes: 25044
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cassert>
using namespace std;

#define REP(i,n) for (int i = 0; i < n; i++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long ll;

int main ()
{
    ll A,B,C,X,Y;
    cin >> A >> B >> C >> X >> Y;

    ll ans = 1e18;
    for (ll i = 0; i <= X; i++) {
        ll sum = A * i;
        ll Xt = X - i;
        sum += C * 2 * Xt;
        ll Yt = max(0LL, Y - Xt);
        sum += min(C * 2LL * Yt, Yt * B);
        ans = min(ans, sum);
    }

    cout << ans << endl;

    return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

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

// const int dx[8] = {1, 1, 0,-1,-1,-1, 0, 1};
// const int dy[8] = {0, 1, 1, 1, 0,-1,-1,-1};

#define SUM(vec) accumulate(all(vec),0LL) // 配列の中身を全部足す
template<typename T>void print(T&& x){cout<<x<<endl;}// 改行付き出力
ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int ctoi(char c){return c-'0';}


// TODO: write
int main() {
  int h,w;cin>>h>>w;
  vector<vector<string>> s(h,vector<string>(w));
  rep(i,h)rep(j,w)cin>>s[i][j];
  rep(i,h)rep(j,w)if(s[i][j] == "snuke"){
    cout<<char('A'+j)<<i+1<<endl;
  }
  
  return 0;
}



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

using std::cin;
using std::cout;
using std::endl;

using std::string;

int main(){
    string s;
    string t = "AKIHABARA";

    cin >> s;

    bool ans = true;

    size_t it = 0;
    for(char c : t){
        if(s[it] == c){
            it++;
            continue;
        }
        if(c == 'A'){
            continue;
        }
        ans = false;
        break;
    }

    if(it != s.length()){
        ans = false;
    }

    cout << (ans ? "YES" : "NO") << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 5005;
int n, h[N], p[N], t[N];
LL dp[N];
int cmp(int x, int y) { return h[x] + p[x] < h[y] + p[y]; }
int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        scanf("%d%d", &h[i], &p[i]);
        t[i] = i;
    }
    sort(t + 1, t + 1 + n, cmp);
    memset(dp, 0x3f, sizeof(dp));
    dp[0] = 0;
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        int now = t[i];
        for (int j = i; j >= 0; j--) {
            if (dp[j - 1] <= h[now]) {
                dp[j] = min(dp[j - 1] + p[now], dp[j]);
                ans = max(ans, j);
            }
        }
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 384
#include <vector>
#include <iostream>
#include <cstdlib>
#include <string>

static const int INF = 1001001001;

using namespace std;

int main()
{
	long long x, count;
	cin >> x;
	count = (x / 11) * 2;
	if (x % 11 > 0 && x % 11 <= 6) {
		count += 1;
	} else if (x % 11 > 6) {
		count += 2;
	}
	cout << count << endl;
	return 0;
}


Measured memory_bytes: 256
s = s0 = input()
d = {chr(c) for c in range(97, 123)}
for c in s:
    d.remove(c)
if d:
    s += min(d)
else:
    for c in reversed(s):
        s = s[:-1]
        if d and any(c < e for e in d):
            s += min(e for e in d if c < e)
            break
        d.add(c)
print(s if s else -1)
if s:
    assert s0 < s


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

int main() {
  int n,count,max;
  cin>>n;
  vector<int> a(n);
  count=max=0;
  for(int i=0;i<n;i++){
    cin>>a.at(i);

    if(a.at(i)>=max){
      count++;
      max=a.at(i);
    }
  }
  cout<<count<<endl;
}

Measured memory_bytes: 256