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

#define N_MAX 100000

int partition(int A[], int start, int end) {
	int tmp, j = 0, x = A[end];
	for (int i = start; i < end; i++) {
		if (A[i] <= x) {
			tmp = A[j];
			A[j] = A[i];
			A[i] = tmp;
			j++;
		}
	}
	tmp = A[end];
	A[end] = A[j];
	A[j] = tmp;

	return j;
}

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

	int j = partition(A, 0, n - 1);
	for (int i = 0; i < n; i++) {
		if (i != 0)	printf(" ");
		if (i == j) {
			printf("[%d]", A[i]);
		}
		else {
			printf("%d", A[i]);
		}
	}
	printf("\n");

	return 0;
}

Measured memory_bytes: 2968
from collections import Counter

n = int(input())
s = str(input())
s_count = Counter(list(s))

ans = 1
count = 0

for i, j in s_count.items():
    count += 1
    ans *= j

if count < 3:
    ans = 0
    

for i in range(n):
    k = 1

    while i + 2 * k < n:
        l = [s[i], s[i+k], s[i+2*k]]
        if l.count('R') == 1 and l.count('G') == 1 and l.count('B') == 1:
            ans -= 1
        
        k += 1
    
print(ans)

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

int main(){
    int N;string S;cin>>N>>S;
    char now=S.at(0);
    int count=1;
    rep(i,N){
        if(S.at(i)==now)continue;
        else{
            count++;
            now=S.at(i);
        }
    }
    cout<<count<<endl;
    return 0;
}

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

#define fr                first
#define se                second
#define int               long long
#define pb                push_back
#define mp                make_pair
#define pii               pair<int,int>
#define vi                vector<int>
#define mi                map<int,int>
#define pq                priority_queue<int>
#define set_bits(x)       __builtin_popcountll(x)
#define mode               1000000007
#define inf               1e18                        //Defining infinity the overflow of int
#define ps(x,y)           fixed<<setprecision(y)<<x   //for defining the precision of the decimal upto y places. 
#define zrosetbits(x)     __builtin_ctzll(x)         //it will give no of 0's before the first 1 from the right.
#define mk(a,n,type)      type *a=new type[n];
#define test(t)           int t; cin>>t; while(t--)


//**********************************************************************************************************
struct custom_hash {
  static uint64_t splitmix64(uint64_t x) {
    // http://xorshift.di.unimi.it/splitmix64.c
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }

  size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
  }
};

#define safemap               unordered_map<int,int,custom_hash>

//*********************************************************************************************************


void io()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin.tie(0);


}


int32_t main()
{
  io();
  clock_t begin = clock();

  int te = 1;

  // test(t)
  // {
  int a, b, c, k;
  cin >> a >> b >> c >> k ;

  int flag = 0;


  for (int i = 0; i < k; i++)
  {
    int op1 = 0;
    int op2 = 0;

    if (a < b and b < c)
    {
      flag = 1;
      break;
    }

    if (op2 != 1 and c <= b)
    {
      c *= 2;
      op1 = 1;
    }

    if (op1 != 1 and b <= a)
    {
      b *= 2;
      op2 = 1;
    }

    if (a < b and b < c)
    {
      flag = 1;
      break;
    }

  }

  if (flag == 0)
    cout << "No\n";
  else
    cout << "Yes\n";


  // cout << "\n";
  te++;
// double c_time = (double) (clock() - begin) / CLOCKS_PER_SEC;
// cout << ps(c_time, 4) << " seconds\n";
  // }

  return 0;
}


Measured memory_bytes: 3648
def solve(N):
    def rec(k = 0, tight = True, flags = {3: False, 5: False, 7: False}, S = []):
        if k == len(N):
            return sum(flags.values()) == 3
        res = 0
        for key in [0, 3, 5, 7]:
            if not tight or key <= int(N[k]):
                flags_temp = flags.copy()
                if key != 0:
                    flags_temp[key] = True
                else:
                    if sum(S) > 0:
                        continue
                res += rec(k + 1, tight and key == int(N[k]), flags_temp, S + [key])
        return res
    return rec()

print(solve(input()))

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

int main(){
  int N;
  cin >> N;
  vector<int> h(110);
  for(int i=1;i<=N;i++){cin >> h[i];}
  int a=0; int m=101; int M=0;
  int count=0;
  for(int i=1;i<=N;i++){M=max(M,h[i]);}
  for(int i=1;i<=M;i++){
    a=0; int j=1;
    while(h[j]<i && j<=N){j++;}
    for(j;j<=N;j++){
      if(h[j]<i){
        a++;
        while(h[j]<i && j<=N){j++;}
        if(j==N+1){a--;}
      }
    }
    count+=1+a;
  }
  cout << count << endl;
}

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

int main() {
    int X;
    cin >> X;
    int found = 0;
    
    if (X != 2) {
        while (found == 0) {
            for (int i = 2; i <= X; i++) {
                if (X % i == 0) {
                    if (i == X) {
                        found = 1;
                        X--;
                    }
                    break;
                }
            }
            X++;
        }
    }
    cout << X << endl;
}


Measured memory_bytes: 256
// warm heart, wagging tail,and a smile just for you!
//
//                            ▒█████▒▒
//                             ██████████▒
//                             ▒████████████▒
//                            ██████████████████
//                           ████████████████████▒
//                          ▒██████████████████████▒
//                          ▒███████████████████████
//                      ▒████▒▒▒▒▒▒█████████████████▒
//                    ███▒▒▒▒▒▒██████████████████████▒▒▒
//                  ▒██▒▒███████████████████████▒▒▒▒▒██████
//                 ▒█████████████████████████▒▒▒▒▒▒█████████▒
//                 ▒█████████████████████▒▒▒▒▒▒██████████████
//                  ▒████         ████▒▒▒▒▒████         ████▒
//              ▒█████▒    ████    ▒▒▒▒███████    ████    ██████▒
//            ▒██▒▒▒▒▒    ██████    █████████    ██████    ██▒▒▒██▒
//           █████████   ████████   █████████   ████████   ▒▒▒▒█████
//          ▒█████████    ██████    ████████▒    ██████    █████████
//          ▒██████████    ████    █████▒▒▒▒▒▒    ████    ██████████
//           ████████████        ▒▒▒▒▒▒▒████████        ███████████▒
//       ▒██████████▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒███████████████████████████████████▒
//     ███▒▒▒▒▒▒▒▒▒▒▒▒█████████████████████████████████████████▒▒████████▒
//   ▒▒▒▒▒▒▒▒▒██████████████                         ███████▒▒▒▒███████████
//   █████████████████████████                     ███████▒▒▒██████████████▒
//   █████████████████████████████             ███████▒▒▒██████████████████▒
//   ██████████████████████████████████████████████████████████████████████
//    ██████████████████████████████████████████████████████████████████▒
//      ▒█████████████████▒▒▒▒▒▒▒██████████████████████████████████▒▒▒
//
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  int n,p;
  cin >> n >> p;

  int sum = 0;
  vector<int> b(n),w(n);
  REP(i,n) cin >> w[i] >> b[i], sum -= p*b[i];
  
  vec a(n); REP(i,n) a[i] = i;

  auto comp = [&](int x,int y){
    return (100-p)*w[x]+p*b[x] > (100-p)*w[y]+p*b[y];
  };

  sort(a.begin(),a.end(),comp);

  if(sum>=0) cout << 0 << endl;
  else REP(i,n){
    sum += (100-p)*w[a[i]]+p*b[a[i]];
    if(sum >= 0){
      cout << i+1 << endl;
      return 0;
    }
  }

  return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll dp[1120005];
ll a[112005];
ll b[211005];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll h,n;
    cin>>h>>n;
    ll ans=999999999;
    for(int i=1;i<=n;i++)
        cin>>a[i]>>b[i];
    for(int i=1;i<=210004;i++)
      dp[i]=999999999;
    for(int i=1;i<=n;i++)
    {

        for(int j=a[i];j<=30000;j++)
        {

            dp[j]=min(dp[j],dp[j-a[i]]+b[i]);
        }
    }
    for(int i=h;i<=30000;i++)
    {

        ans=min(ans,dp[i]);
    }


    cout<<ans<<'\n';


}












Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <utility>

#include <cassert>
#include <cmath>
#include <cstdio>

using namespace std;

#define fi first
#define se second
#define mkp make_pair
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

int d_in[100100];
int p[100100];

int main() {
	int N, M;
	cin >> N >> M;
	vector<vector<int>> G(N);
	rep(i,N-1+M) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		G[a].push_back(b);
		d_in[b]++;
	}
	int r = -1;
	rep(i,N) {
		if(d_in[i] == 0)
			r = i;
	}
	queue<int> q;
	q.push(r);
	while(q.size()) {
		int n = q.front(); q.pop();
		for(int i = 0; i < G[n].size(); i++) {
			d_in[G[n][i]]--;
			if(d_in[G[n][i]] == 0) {
				q.push(G[n][i]);
			}
			p[G[n][i]] = n+1;
		}
	}
	rep(i,N) {
		cout << p[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 7168
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop
from itertools import permutations, accumulate
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
#from fractions import gcd
#from math import gcd
import sys
def I(): return int(input())  # '123' -> 123
def Is(): return map(int, input().split())  # '123 456' -> 123, 456
def LI(): return list(map(int, input().split()))  # '123 456' -> [123, 456]
def TI(): return tuple(map(int, input().split()))  # '123 456' -> (123, 456)
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()  # 'aa bb' -> 'aa','bb' or ['aa','bb']
def LS(): return list(input())  # 'abc123' -> ['a','b','c','1','2','3']
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(1000000)
MOD = 1000000007
INF = float('inf')

n = I()
s, t = Ss()
ans = ""
for i in range(n):
    ans += s[i]
    ans += t[i]
print(ans)

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

#if __has_include(<local.h>)
#include <local.h>
#endif

using namespace std;

typedef long long int LL;
typedef long long int LLint;

//Faster Program
#define endl "\n"

//Faster Coding
#define ED return
#define GET(a) int a;cin >> a
#define DGET(a) double a;cin >> a
#define SGET(a) string a;cin >> a
#define CGET(a) char a;cin >> a
#define PRINT(a) cout << a << "\n"
#define ANS(a,b) int a;cin >> a;cout << b << "\n"
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define SORT(vec) sort(vec.begin(),vec.end())
#define REV(vec) reverse(vec.begin(),vec.end())
#define ALL(x) (x).begin(),(x).end()

//As Function
#define UP(a,b) ((a+(b-1))/b)
#define IPOW(x,y) LL(pow(x,y))

//Debug
#ifdef LOCAL_H
#define TEST cout << "OK\n"
#define DEBUG(a) a
#else
#define TEST
#define DEBUG(a)
#endif

#ifdef LOCAL_H
[[maybe_unused]]
#endif
const double PI = M_PI;
#ifdef LOCAL_H
[[maybe_unused]]
#endif
const int INF = int(999999999);
#ifdef LOCAL_H
[[maybe_unused]]
#endif
const LL LL_INF = LL(999999999999999999);
#ifdef LOCAL_H
[[maybe_unused]]
#endif
const long long MOD = int(1000000007);

//Settings
#ifdef LOCAL_H
const bool DO_BENCHMARK = true;
#endif
const int DOUBLE_ACCURACY = 15;
const int RUN_SOLVE = 1;

#ifndef LOCAL_H
const bool DO_BENCHMARK = false;
#endif

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(DOUBLE_ACCURACY);
    for(int do_solve_time = 0;do_solve_time < RUN_SOLVE;do_solve_time++){
        void solve();
        if(DO_BENCHMARK){
            clock_t clock_start = clock();
            solve();
            clock_t clock_end = clock();
            const double time = static_cast<double>(clock_end-clock_start)/CLOCKS_PER_SEC*1000.0;
            cout << "\n------------------------------------\n" << time << "[ms]\n";
        }
        else solve();
    }
}

/************************************************************************************************************************************************/
void solve(){
    LL N;
    cin >> N;
    vector<int> vec (N);
    for(int i = 0;i < N;i++){
        cin >> vec[i];
    }
    vector<bitset<37>> bs;
    for(int i = 0;i < N;i++){
        bs.push_back(bitset<37>(vec[i]));
    }

    vector<bool> flip (37,false);
    bitset<37> xor_check("0");
    for(int i = 1;i < N;i++){
        xor_check ^= bs[i];
    }
    for(int i = 0;i < 37;i++){
        if(bs[0][i] != xor_check[i]){
            flip[i] = true;
        }
    }

    for(int i = 0;i < N;i++){
        for(int j = 0;j < 37;j++){
            if(flip[j]){
                bs[i][j] = !bs[i][j];
            }
        }
        cout << bs[i].to_ulong() << endl;
    }

}



Measured memory_bytes: 6008
#include <iostream>
#include <queue>
#include <cstdlib>
#define MAX 10001
using namespace std;
typedef long long lld;
int main(void) {
    priority_queue<lld> que;
    lld n, m, x[MAX], y[MAX], z[MAX], ans=0, sum;
    cin >> n >> m;
    for(int i=0; i<n; i++)
        cin >> x[i] >> y[i] >> z[i];
    
    int sx[8] = {-1, -1, -1, -1, 1, 1, 1, 1};
    int sy[8] = {-1, -1, 1, 1, -1, -1, 1, 1};
    int sz[8] = {-1, 1, -1, 1, -1, 1, -1, 1};
    
    
    for(int i=0; i<8; i++) {
        priority_queue<lld> empty;
        swap(que, empty);
        sum = 0;
        for(int j=0; j<n; j++)
            que.push(sx[i]*x[j] + sy[i]*y[j] + sz[i]*z[j]);
        
        for(int j=0; j<m; j++) {
            sum += que.top();
            que.pop();
        }
        ans = ans>sum ? ans : sum;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include<string>
using namespace std;
struct Node
{
    int key;
    Node *right, *left, *parent;
};
Node *root;
void insert(int k)
{
    Node *y = NULL;
    Node *x = root;//
    Node *z;
    z = (Node *)malloc(sizeof(Node));
    z->key = k;
    z->left = NULL;
    z->right = NULL;
    while (x)
    {
        y = x;//????????¶??????
        if (z->key<x -> key)
            x = x->left;//?§???¨????????????
        else
            x = x->right;//?§???¨????????????
    }
    z->parent = y;
    if (y == NULL)//??????????????¶
        root = z;
    else
        if (z->key<y->key)
            y->left = z;//?°?z??????y???????????????
        else
            y->right = z;//?°?z??????y???????????????
}
void inorder(Node *u)//????????????
{
    if (u == NULL)
        return;
    inorder(u->left);
    cout << " " << u->key;
    inorder(u->right);
}
void preorder(Node *u)//????????????
{
    if (u == NULL)
        return;
    cout << " " << u->key;
    preorder(u->left);
    preorder(u->right);
}
int main()
{
    int n;
    cin >> n;
    string com;
    for (int i = 0; i<n; i++)
    {
        cin >> com;
        if (com == "insert")
        {
            int x;
            cin >> x;
            insert(x);
        }
        else if (com == "print")
        {
            inorder(root);
            cout << endl;
            preorder(root);
            cout << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 26512
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define FORE(v, a, b) for(int v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(int v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define LLI long long int
#define fst first
#define snd second

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(x)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> istream& operator>>(istream &is, pair<T,U> &p){is >> p.first >> p.second; return is;}

template <typename T, typename U> T& chmin(T &a, const U &b){return a = (a<=b?a:b);}
template <typename T, typename U> T& chmax(T &a, const U &b){return a = (a>=b?a:b);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

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

  int N;
  while(cin >> N){
    vector<int> b(N); cin >> b;

    vector<int> ans;
    while(not b.empty()){
      bool no_ans = true;
      REV(i,b.size()-1,0){
	if(i+1 == b[i]){
	  ans.push_back(b[i]);
	  b.erase(b.begin()+i);
	  no_ans = false;
	  break;
	}
      }
      if(no_ans) break;
    }

    reverse(ALL(ans));

    if(ans.size()==N)
      join(cout, ALL(ans), "\n");
    else
      cout << -1 << endl;
  }
  
  return 0;
}


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

using namespace std;
constexpr int64_t MOD =   998'244'353;

int main(void) {
    int N;
    cin >> N;
    vector<int> D(N);
    vector<int> num(N);
    for(int i=0; i<N; i++) {
        cin >> D[i];
        num[D[i]]++;
    }

    int64_t ans = 1;
    if(D[0] != 0 || num[0] != 1) {
        ans = 0;
    } else {
        for(int i=0; i<N; i++) {
            for(int j=0; j<num[i+1]; j++) {
                ans = (ans*num[i]) % MOD;
            }
        }
    }

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

Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

int main()
{
    char n[10];
    scanf("%s", n);
    int lenn = strlen(n);
    int sum = 0;
    for (int i=0; i<lenn; i++)
    {
        sum += n[i] - '0';
    }
    if (atoi(n) % sum == 0) printf("Yes\n");
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

#define MAX 1000000

int isPrime[MAX];

int main() {
	int num;
	int i, j;
	int count;

	// ??????????????????
	isPrime[0] = isPrime[1] = 0;
	for (i = 2; i < MAX; i++) {
		isPrime[i] = 1;
	}

	// ??¨??????????????????????????????
	for (i = 2; i * i < MAX; i++) {
		if (isPrime[i]) {
			// i????????°????´???°?????????????????§????????°?????´
			for (j = 2 * i; j < MAX; j += i) {
				isPrime[j] = 0;
			}
		}
	}

	while (scanf("%d", &num) != EOF) {
		count = 0;
		while (num) {
			count += isPrime[num--];
		}
		printf("%d\n", count);
	}

	return 0;
}

Measured memory_bytes: 4500
#include<iostream>
#include<map>
#include<string>
#include<vector>
using namespace std;
int inf = 10000000;

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

  vector< vector<bool> > dp(n, vector<bool> (2000*20+1, false));
  dp[0][ a[0] ] = true;
  for(int i=0; i<n-1; i++){
    dp[i+1][a[i+1]] = true;
    for(int j=0; j<dp[i].size(); j++){
      if( dp[i][j] ){
        dp[i+1][j] = true;
        if( j + a[i+1] < dp[i].size()-1 ) dp[i+1][j + a[i+1]] = true;
        // if( j - a[i+1] > 0) dp[i+1][j - a[i+1]] = true;
      }
    }
  }


  int q; cin >> q;
  for(int i=0; i<q; i++){
    int m;
    cin >> m;
    cout << ( dp[n-1][m] ? "yes" : "no" ) << endl;
  }

  // for(int i=0; i<dp[n-1].size(); i++) if( dp[n-1][i] ) cerr << i << endl;

  return 0;
}

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

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

    int index = 1;
    while (true) {
        int num;
        cin >> num;
        if (num == 0)
            break;
        cout << "Case " << index << ": " << num << endl;
        index++;
    }
    return 0;
}


Measured memory_bytes: 3020
import java.util.Scanner;
public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h,w;
        while(true){
            h = sc.nextInt();
            w = sc.nextInt();
            if(h==0) break;
            for(int i=0;i<h;i++){
                for(int l=0;l<w;l++){
                    System.out.print("#");
                }
                System.out.print("\n");
            }
            System.out.print("\n");
        }
        sc.close();
    }
}


Measured memory_bytes: 36924
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <stdio.h>

using namespace std;

//typedefリスト
typedef vector<long long int> vint;
typedef vector<string> vstr;
typedef long long int llint;



int main(void) {
	string s1, s2, s3;
	char as1, as2, as3;
	cin >> s1 >> s2 >> s3;
	as1 = 'A' + (s1[0] - 'a');
	as2 = 'A' + (s2[0] - 'a');
	as3 = 'A' + (s3[0] - 'a');
	cout << as1 << as2 << as3 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t,n,i,j,weight,w,v;
    cin>>n>>weight;
    vector<vector<ll>> dp(n+1,vector<ll> (weight+1));
    for(i=0;i<n+1;i++)
    {
        dp[i][0]=0;
    }
    for(i=0;i<weight+1;i++)
    {
        dp[0][i]=0;
    }
    for(i=1;i<n+1;i++)
    {
        cin>>w>>v;
        for(j=1;j<weight+1;j++)
        {
          if(j>=w)
          {
              dp[i][j]=max(dp[i-1][j],dp[i-1][j-w]+v);
          }
          else
          {
              dp[i][j]=dp[i-1][j];
          }
        }
    }
    cout<<dp[n][weight];
}















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

int main()
{

    int a;
    cin >> a;
    string s;
    cin >> s;

    if(a >= 3200){
        cout << s << endl;
    } else if (a < 3200)
    {
        cout << "red" << endl;
    }

}


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

long long gcd(long  long a, long long b) {
  if (b == 0) {
    return a;
  }
  return gcd(b, a % b);
}
int main() {
  long long a, b;
  cin>>a>>b;
  cout<<a  * b / gcd(a, b)<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<list>
#include<set>
using namespace std;
int gcd(int a, int b) {
	int c = a % b;
	while (c != 0) {
		a = b;
		b = c;
		c = a % b;
	}
	return b;
}
struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};
typedef long long ll;

const ll M = 1000000007;

vector<ll> fac(300001); //n!(mod M)
vector<ll> ifac(300001); //k!^{M-2} (mod M)

ll mpow(ll x, ll n) {
	ll ans = 1;
	while (n != 0) {
		if (n & 1) ans = ans * x % M;
		x = x * x % M;
		n = n >> 1;
	}
	return ans;
}

ll comb(ll a, ll b) {
	if (a == 0 && b == 0)return 1;
	if (a < b || a < 0)return 0;
	ll tmp = ifac[a - b] * ifac[b] % M;
	return tmp * fac[a] % M;
}
int main() {
	ll n, m, i, j, k, ans=0;
	cin >> n >> m>>k;
	fac[0] = 1;
	ifac[0] = 1;
	for (ll i = 0; i < 300000; i++) {
		fac[i + 1] = fac[i] * (i + 1) % M; // n!(mod M)
		ifac[i + 1] = ifac[i] * mpow(i + 1, M - 2) % M; // k!^{M-2} (mod M) ←累乗にmpowを採用
	}
	for (i = 1; i <= n; i++)
		for (j = 1; j <= m; j++)
			ans = (ans+(m - j)*(m - j + 1) / 2 % M*n%M + (n - i)*(n - i + 1) / 2 % M+(i-1)*i/2%M*(m-j)%M+(n-i)*(n-i+1)/2%M*(m-j)%M) % M;
	ans = ans * comb(n*m - 2, k - 2)%M;
	cout << ans << endl;
}

Measured memory_bytes: 4992
#include <iostream>
#include <vector>

void sort(std::vector<int> &a){
  for (std::size_t i = 1; i < a.size(); i++) {
    int v = a[i];
    int j = i - 1;
    while (j >= 0 && a[j] > v) {
      a[j + 1] = a[j];
      j--;
    }
    a[j + 1] = v;
  }
}

int main() {
  std::vector<int> a;
  for (int i = 0; i < 3; i++) {
    int x;
    std::cin >> x;
    a.push_back(x);
  }

  sort(a);

  for (std::size_t i = 0; i < a.size(); i++) {
    std::cout << a[i];
    if (i < a.size() - 1) {
      std::cout << " ";
    }
  }
  std::cout << std::endl;
}



Measured memory_bytes: 3136
n=int(input())
arr=[]
for i in range(n):
	s,p=map(str,input().split())
	p=int(p)
	arr.append([s,p,i+1])
# arr=sorted(arr,key=lambda item:item[0])
arr=sorted(arr,key=lambda item:item[1],reverse=True)
arr=sorted(arr,key=lambda item:item[0])
# print(arr)
for i in range(len(arr)):
	print(arr[i][2])

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

//int dp[105][4][2];

int main() {
  int x;
  cin >> x;
  
  if( x >= 30 )cout << "Yes" << endl;
  else cout << "No" << endl;
  
  //cout << ans << endl;
  
  return 0;
  
}


Measured memory_bytes: 3584
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int INF=0x7fffffff,MAXN=2005;
int n,a[MAXN<<1],f[MAXN][MAXN],Sum[MAXN<<1][MAXN<<1];
int Get(int x,int B,int W){return (Sum[x][B]-Sum[x-1][B]+Sum[x][W])-(Sum[x][n]+Sum[x-1][W]-Sum[x-1][n]);}
int main(){
    scanf("%d",&n);
    for(int i=1;i<=(n<<1);++i){
    	char ch[10];scanf("%s%d",ch,&a[i]),a[i]+=(ch[0]=='B')*n;
        for(int j=1;j<i;++j) Sum[a[j]][a[i]]=1;
    }
    for(int i=1;i<=(n<<1);++i) for(int j=1;j<=(n<<1);++j) Sum[i][j]+=Sum[i-1][j]+Sum[i][j-1]-Sum[i-1][j-1];
    memset(f,63,sizeof(f));f[0][0]=0;
    for(int i=0;i<=n;++i) for(int j=0;j<=n;++j) if(i||j)
	f[i][j]=min(i?f[i-1][j]+Get(i,i,j+n):INF,j?f[i][j-1]+Get(j+n,i,j+n):INF);
    printf("%d\n",f[n][n]);
    return 0;
}

Measured memory_bytes: 78720
#include <iostream>

using namespace std;

int main()
{
    for(;;) {
        int n, m, p;
        cin >> n >> m >> p;
        if ( n == 0 && m == 0 && p == 0 )
            break;
        
        int total = 0, prizewinners;
        for( int i=0; i<n; ++i ) {
            int x;
            cin >> x;

            if ( i == m - 1 ) {
                prizewinners = x;
            }
            total += x;
        }

        if ( prizewinners != 0 ) {
            int const g = total * 100 - ( total * p );
            cout << ( g / prizewinners ) << endl;
        } else {
            cout << 0 << endl;
        }
    }
}

Measured memory_bytes: 1156
#include <iostream>

using namespace std;

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

    tk = a / d + ((a % d) ? 1 : 0);
    ao = c / b + ((c % b) ? 1 : 0);

    if(tk >= ao){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

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

int main() {
  
  int n;
  cin >> n;
  
  vector<int> h(n);
  REP(i,n) {
    cin >> h[i];
  }
  
  int count = 0;
  REP(i,n) { 
    if (h[i] > 0) {
      REP(j,n-i) {
        if (h[i+j] > 0) h[i+j]--;
        else break;
      }
      count++;
      if (h[i] > 0) i--;
    }
  }
  
  cout << count << endl;
}

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

void solve(){
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll a1=a*c, b1=b*c;
	a1= max(a1, b*d);
	b1 = max(b1,a*d);
	ll ans = max(a1,b1);
	cout<<ans<<"\n";
	
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    // ll t; cin>>t;
    // while(t--)
        solve();
    return 0;
}



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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
//#define int long long int
const int MOD = 1000000007;
const ll LINF = (ll)1e18 - 1;
const int INF = 1e9 - 1;
const double EPS = 0.000000001;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

void print(const vector<int> &v) {
  for(auto x : v) {
    cout << x << " ";
  }
  cout << endl;
}

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<vector<P>> link(n);
  rep(i, m) {
    int l, r, d;
    cin >> l >> r >> d;
    l--; r--;
    link[l].emplace_back(r, d);
    link[r].emplace_back(l, -d);
  }
  VL ans(n, LINF);
  rep(i, n) {
    if(ans[i] == LINF) {
      queue<int> q;
      ans[i] = 0;
      q.push(i);
      while(!q.empty()) {
        int j = q.front();
        q.pop();
        for(auto k : link[j]) {
          if(ans[k.first] == LINF) {
            ans[k.first] = ans[j] + k.second;
            q.push(k.first);
          }
          else if(ans[k.first] != ans[j] + k.second) {
            out("No");
            return 0;
          }
        }
      }
    }
  }
  out("Yes");
  return 0;
}


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

#define maxn 100000008
#define pp push_back
#define pf push_front
#define mp make_pair
#define fs first
#define sc second

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

int main(int argc, char *argv[])
{
	string o, e;
	cin >> o >> e;
	for (int i = 0; i < min(o.length(), e.length()); ++i) {
		printf("%c%c", o[i], e[i]);
	}
	if(o.length() > e.length()){
		printf("%c", o[o.length() - 1]);
	}
	return 0;
}


Measured memory_bytes: 256
let split str delim =
  let open String in
  let rec doit s acc =
    match
      try Some (rindex s delim) with _ -> None
    with
    | None -> s :: acc
    | Some i -> doit (sub s 0 i) (sub s (i + 1) (length s - i - 1) :: acc) in
  doit str []

let find_set s x =
  let rec doit x =
    if x <> fst s.(x) then s.(x) <- (doit (fst s.(x)), snd s.(x));
    fst s.(x) in
  doit x

let unite s x y =
  let (a, b) = (find_set s x, find_set s y) in
  if snd s.(a) > snd s.(b) then s.(b) <- (a, snd s.(b))
  else begin
    s.(a) <- (b, snd s.(a));
    if snd s.(a) = snd s.(b) then s.(b) <- (fst s.(b), snd s.(b) + 1)
  end

let same_p s x y = find_set s x = find_set s y

let solve n q =
  let s = Array.init n (fun i -> (i, 0)) in
  let rec doit i =
    if i < q then begin
      begin match List.map int_of_string (split (read_line ()) ' ') with
      | 0 :: x :: y :: _ -> unite s x y
      | 1 :: x :: y :: _ -> print_endline (if same_p s x y then "1" else "0")
      | _ -> ()
      end;
      doit (i + 1)
    end in
  doit 0

let () =
  match List.map int_of_string (split (read_line ()) ' ') with
  | [n; q] -> solve n q
  | _ -> ()

Measured memory_bytes: 6712
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void debug(String str) {
        boolean debug = false;
        if (debug == false) {
            return;
        }
        System.out.println(str);
    }

    public static class Edge {
        int u;
        int v;
        int w;

        public Edge(int u, int v, int w) {
            this.u = u;
            this.v = v;
            this.w = w;

        }
    }
    public static class Node {
        List<Edge> edge = new LinkedList<>();
    }

    public static void main(String[] args) {

        int N;
        Node[] node;
        try (Scanner sc = new Scanner(System.in)) {
            N = sc.nextInt();
            node = new Node[N];
            for (int i = 0; i < N; i++) {
                node[i] = new Node();
            }
            for (int i = 0; i < N - 1; i++) {
                int u = sc.nextInt();
                int v = sc.nextInt();
                int w = sc.nextInt();
                Edge e = new Edge(u, v, w);
                node[u-1].edge.add(e);
                node[v-1].edge.add(e);
            }
        }
        int[] distans = new int[N];
        HashSet<Edge> visited = new HashSet<>();
        Deque<Integer> queue = new ArrayDeque<>();
        queue.push(1);
        distans[0] = 0;
        Integer target;
        while((target = queue.pollFirst()) != null){
            //List<Edge> list = set.get(target);
            List<Edge> list = node[target -1].edge;
            for(Edge e : list){
                if(visited.contains(e)){
                    continue;
                }else{
                    int d = (distans[target-1] + e.w) %2;
                    int i;
                    if(e.u != target ){
                        i = e.u;
                    }else{
                        i = e.v;
                    }
                    queue.addLast(i);
                    distans[i  -1] = d;
                    debug(i+":"+distans[i  -1]);
                    visited.add(e);
                }
            }
        }
        for(int i : distans){
            System.out.println(i%2);
        }
    }


}


Measured memory_bytes: 106484
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main() {
    long long ans = 0;
    long long N, M, K;
    cin >> N;
    for (long long i = 1; i <= N; i++) {
        ans += i*((long long)N/i)*(((long long)N/i)+1)/2;
    }
    cout << ans << endl;
}



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

#define int long long
#define ll long long
#define f1(i,a,b) for(int i=a;i<b;i++)
#define f2(i,a,b) for(int i=a;i>=b;i--)
#define endl '\n'
#define pb push_back
#define gp " "
#define ff first
#define ss second
#define mp make_pair

const int mod=1000000007;
ll temp;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    string s;
    cin>>s;
    if(s[2]==s[3] && s[4]==s[5])
    {
        cout<<"Yes"<<endl;
    }
    else
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<map>
using lint=int64_t;
using namespace std;

int main()
{
	lint N;
	string s[100010]={};
	map<string,lint> m;

	cin >> N;
	for(int i=0;i<N;i++)
		cin >> s[i];
	for(int i=0;i<N;i++)
	{
		sort(s[i].begin(),s[i].end());
		m[s[i]]++;

	}
	
	lint ans=0;
	for(auto&& i:m)
	{
		lint n=i.second;
		ans+=((n*(n-1))/2);
	}
	cout << ans << endl;
	return 0;
}



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

using namespace std;

using ll = long long;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    string s, t;
    cin >> s >> t;
    for (int i = 0; i < n; ++i) {
        cout << s[i] << t[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
//#pragma GCC optimize ("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/rope>
#define pb push_back
#define F first
#define S second
#define ins insert
#define mp make_pair
#define fo(i, n1, n, x) for(int i = n1; i <= n; i += x)
#define foo(i, n, n1, x) for(int i = n; i >= n1; i -= x)
#define bit __builtin_popcount
#define md (l + ((r - l) / 2))
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

using namespace std;
//using namespace __gnu_pbds;
//using namespace __gnu_cxx;


using ll = long long;

//#define int ll

using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;



const int N = 2e5 + 11, mod = 1e9 + 7, mod2 = 998244353;
const int MAX = 1e5 + 11;
const int INF1 = 2e9 + 11;
const ll INF2 = 2e18 + 11;
const double INF3 = 1e8 + 11;
const int base = 500;
const int P = 31;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double EPS = 1e-4;
const double PI = acos(-1.0);


//template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

char a, b, c;
main() {
  file("threesum");
  ios;
  cin >> a >> b >> c;
  if (a == '7' || b == '7' || c == '7') cout << "Yes";
  else cout << "No";
  return 0;
}
/**

*/


Measured memory_bytes: 3620
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <climits>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <functional>
#include <set>
#include <numeric>
#include <stack>
#include <utility>
#include <time.h>
#include <iterator>
//#include "util.h"

using namespace std;
typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vint;
typedef vector<ll> vll;

//呪文
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const pair<_KTy, _Ty>& m) { cout << "{" << m.first << ", " << m.second << "}"; return ostr; }
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const map<_KTy, _Ty>& m) { if (m.empty()) { cout << "{ }"; return ostr; } cout << "{" << *m.begin(); for (auto itr = ++m.begin(); itr != m.end(); itr++) { cout << ", " << *itr; } cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const vector<_Ty>& v) { if (v.empty()) { cout << "{ }"; return ostr; }	cout << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const set<_Ty>& s) { if (s.empty()) { cout << "{ }"; return ostr; } cout << "{" << *(s.begin()); for (auto itr = ++s.begin(); itr != s.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
#define PI 3.14159265358979323846
#define EPS 1e-8
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define all(x) (x).begin(), (x).end()



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

	string ans;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'B') {
			if(!ans.empty()) ans.pop_back();
		}
		else ans.push_back(s[i]);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import sys
stdin = sys.stdin

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from itertools import accumulate

n,x = li()
a = list(li())

# 係数リスト
coef = [5] + [2*i + 5 for i in range(n+1)]

a = a[::-1]
a_cum = [0] + list(accumulate(a))

ans = float("inf")
# 往復回数決め打ち
for k in range(1,n+1):
    cost = (n+k) * x
    i = 0
    while i*k <= n:
        cost += coef[i]*(a_cum[min((i+1)*k, n)] - a_cum[i*k])
        i += 1

    ans = min(ans, cost)
    
print(ans)

Measured memory_bytes: 97916
import numpy as np

N,M = map(int,input().split())

Q = np.zeros((N,2),dtype=int)
for i in range(M):
  p,S = input().split()
  p = int(p)-1
  if Q[p,0] == 0 and S == "AC":
    Q[p,0] = 1
  elif Q[p,0] == 0 and S == "WA":
    Q[p,1] += 1
  else:
    pass

Q[:,1] *= Q[:,0]
ret = Q.sum(axis=0)
print(ret[0],ret[1])

Measured memory_bytes: 14004
n = int(input())

a = [0] * n
flag = [True] * n
for i in range(n):
    a[i] = int(input())

ans = 0
now = 0
while 1:
    flag[now] = False
    now = a[now] - 1
    ans += 1
    if flag[now] == False:
        print(-1)
        exit()
    elif now == 1:
        break
print(ans)

Measured memory_bytes: 7796
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define repp(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
const static int MOD = (1e+9)+7;

int main(){
    int n,k; cin>> n >> k;
    vector<bool> ok(n,0);
    rep(i,k){
        int d; cin >> d;
        rep(j,d){
            int a; cin >> a;
            a--; ok[a]=1;
        }
    }
    int ans=0;
    rep(i,n){
        if(!ok[i]) ans++;
    }
    cout << ans << endl;
}


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

int main() {
  
  int N , M ;
  cin >> N >> M ;
  int ans = 0 ;
  vector<int> A(N);
  rep(i,N){
    cin >> A.at(i);
    if(A.at(i) >= M ) ans++ ;
  }
  cout << ans ; 
}
    



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define Mod 1000000007
#define ll long long
#define dd double
#define pb push_back
#define ff first
#define ss second
#define Mp make_pair
#define INF 999999999999999999
#define NN (ll)(1e6+5)
int mod(string s,int a) 
{ 
    int ans=0; 
    for (int i=0;i<s.length();i++) 
         ans=(ans*10+(int)s[i]-'0')%a; 
    return ans; 
}
ll min(ll x,ll y){if(x<y) return x;return y;}
ll max(ll x,ll y){if(x>y) return x;return y;}
ll power(ll x,unsigned ll y) 
{ 
    if (y==0) 
        return 1; 
    else if (y%2==0) 
        return power(x,y/2)*power(x,y/2); 
    else
        return x*power(x,y/2)*power(x,y/2); 
}
ll hcf(ll a,ll b) 
{ 
    if(b==0) 
        return a; 
    return hcf(b,a%b);  
}
int main()
{
   fio;
   /*#ifndef ONLINE_JUDGE 
    	freopen("input.txt", "r", stdin); 
    	freopen("output.txt", "w", stdout); 
    	freopen("error.txt", "w", stderr); 
   #endif*/
   ll TT=1;
   //cin>>TT;
   while(TT--)
   {    
       ll n,i,f=0,x;
       cin>>n;
       vector <ll> v(n);
       for(auto &u:v)
       {
           cin>>u;
           if(!f)
            x=u,f++;
           else
            x^=u; 
       }
       for(auto u:v)
        cout<<(x^u)<<" ";
   }
}

Measured memory_bytes: 4700
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;

int X,Y,Z;
int V[4];
P mass[51];
double dp[51][5001];

int main(){
  while(cin >> X >> Y >> Z , X){
    for(int i=0;i<X;i++) cin >> V[i];
    for(int i=0;i<=Y;i++){
      mass[i] = P(0,0);
    }
    for(int i=0;i<Z;i++){
      int N,E,A;
      cin >> N >> E >> A;
      mass[N] = P(E,A);
    }
    for(int i=0;i<51;i++){
      for(int j=0;j<5001;j++){
	dp[i][j] = 0.0;
      }
    }
    dp[0][0] = 1.0;
    int limit = 0;
    for(int i=0;i<Y;i++){
      limit += 100;
      for(int j=0;j<=limit;j++){
	if(dp[i][j]){
	  for(int k=0;k<X;k++){
	    int next_p=min(i+V[k],Y),next_m=j;
	    if(mass[next_p].first == 1){
	      next_p = min(next_p+mass[next_p].second,Y);
	    } else if(mass[next_p].first == 2){
	      next_m += mass[next_p].second;
	    } else if(mass[next_p].first == 3){
	      next_m = max(0,next_m-mass[next_p].second);
	    }
	    dp[next_p][next_m] += dp[i][j] / (double)X;
	  }
	}
      }
    }
    double ans = 0.0;
    for(int i=0;i<5001;i++){
      ans += dp[Y][i]*i;
    }
    cout << (int)ans << endl;
  }
}

Measured memory_bytes: 5024
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
      	int ans = 0;
      	if(s.equals("SUN"))ans=7;
      	if(s.equals("MON"))ans=6;
        if(s.equals("TUE"))ans=5;
        if(s.equals("WED"))ans=4;
        if(s.equals("THU"))ans=3;
        if(s.equals("FRI"))ans=2;
        if(s.equals("SAT"))ans=1;
        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int n;
    cin >> n;
    vector<ll> a(n),b(n);
    rep(i,n)cin >> a[i];
    rep(i,n)cin >> b[i];
    priority_queue<pair<ll,ll>> q;
    rep(i,n){
        if(b[i]>a[i])q.push({b[i],i});
        else if(b[i] < a[i]){
            cout << -1 << endl;
            return 0;
        }
    }
    ll ans = 0;
    while(!q.empty()){
        int i = q.top().second;q.pop();
        int r = (i+1)%n, l = (i-1+n)%n;
        if( b[i] - a[i] >= b[l] + b[r]){
            int k = (b[i] - a[i]) / (b[l] + b[r]);
            ans += k;
            b[i] -= k*(b[l]+b[r]);
            if(b[i] > a[i])q.push({b[i],i});
            else if(b[i] < a[i]){cout << -1 << endl; return 0;}
        }else {cout << -1 << endl; return 0;}
    }
    cout << ans << endl;
}


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

#define ll long long
#define Size 100001
ll dp[101][Size];
ll *weight;
ll *price;

ll Knapsack(ll n,ll max_price,ll capacity){
	ll inf = 1e10;
	ll ans=0;

	for(ll N=0;N<=n;N++){
		for(ll Price=0;Price<=max_price;Price++){
			if(N == 0 && Price == 0) dp[N][Price] = 0;
			else if(N==0) dp[N][Price] =inf;
			else if(price[N-1]<=Price){
				dp[N][Price] = min(weight[N-1]+dp[N-1][Price-price[N-1]],dp[N-1][Price]);
			}
			else{
				dp[N][Price] = dp[N-1][Price];
			}
		}
	}
	
	for(ll i=0;i<=max_price;i++){
		if(dp[n][i]<=capacity) ans = i;
	}
	return ans;
}

int main(){
	ll N,capacity,max_prize = 0;
	cin>>N>>capacity;
	weight = new ll[N];
	price = new ll[N];                    
	for(int i=0;i<N;i++){
		cin>>weight[i]>>price[i];
		max_prize += price[i];

	}
	cout<<Knapsack(N,max_prize,capacity);

	cout<<endl;
	return 0;
}

Measured memory_bytes: 79104