akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <set>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){

    std::fill( (T*)array, (T*)(array+N), val );
}

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

bool IsPrime(ll num){
    if(num < 2) return false;
    else if(num == 2) return true;
    else if(num % 2 == 0) return false;
    double sqrtNum = sqrt(num);
    for(ll i = 3; i <= sqrtNum; i += 2){
        if(num%i==0) return false;
    }
    return true;
}


signed main(){
  ll n,a,b; cin>>n>>a>>b;
  VL x(n); rep(i,n) cin>>x[i];
  VL y(n-1);
  ll ans = 0;
  reps(i,n-1){
    ans += min((x[i]-x[i-1])*a,b);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e15;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
typedef pair<double,double> point;
const ll MAX = 2010;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s,t;
    cin >> s >> t;
    SORT(s);
    RSORT(t);
    Yes(s < t);
}


Measured memory_bytes: 256
#include <iostream>
#include <list>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <chrono>
#include <math.h>
using namespace std;

using lli = long long int;
using Vint = std::vector<int>;
using Vlli = std::vector<lli>;
using Wint = std::vector<Vint>;
using Wlli = std::vector<Vlli>;
using Vbool = std::vector<bool>;
using pii = std::pair<int, int>;
using pll = std::pair<lli, lli>;
template <class T>
using Vec = std::vector<T>;

constexpr int MOD = 1e9 + 7;
constexpr int INFi = 2e9 + 1;
constexpr lli INFl = (lli)(9e18) + 1;
const vector<pii> DXDY = {std::make_pair(1, 0), std::make_pair(-1, 0), std::make_pair(0, 1), std::make_pair(0, -1)};
constexpr char BR = '\n';

#define FOR(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define FOReq(i, a, b) for(int (i) = (a); (i) <= (b); (i)++)
#define rFOR(i, a, b) for(int (i) = (b); (i) >= (a); i--)
#define FORstep(i, a, b, step) for(int (i) = (a); i < (b); i += (step))
#define REP(i, n) FOR(i, 0, n)
#define rREP(i, n) rFOR(i, 0, (n-1))
#define vREP(ele, vec) for(auto &(ele) : (vec))
#define vREPcopy(ele, vec) for(auto (ele) : (vec))
#define SORT(A) std::sort((A).begin(), (A).end())
// 座標圧縮 (for vector) : ソートしてから使うのが一般的 ; SORT(A) => COORDINATE_COMPRESSION(A)
#define COORDINATE_COMPRESSION(A) (A).erase(unique((A).begin(),(A).end()),(A).end())



template <class T> inline int argmin(std::vector<T> vec){return min_element(vec.begin(), vec.end()) - vec.begin();}
template <class T> inline int argmax(std::vector<T> vec){return max_element(vec.begin(), vec.end()) - vec.begin();}
template <class T> inline void chmax(T &a, T b){a = max(a, b);}
template <class T> inline void chmin(T &a, T b){a = min(a, b);}
inline int BitI(int k){return 1 << k;}
inline lli BitL(int k){return 1L << k;}
inline int toInt(string &s){int res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
inline int toInt(const string s){int res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
inline long long int toLong(string &s){lli res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
inline long long int toLong(const string s){lli res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
template <class T> inline std::string toString(T n){
  if(n == 0) return "0";
  std::string res = "";
  if(n < 0){n = -n;while(n != 0){res += (char)(n % 10 + '0'); n /= 10;}
  std::reverse(res.begin(), res.end()); return '-' + res;}
  while(n != 0){res += (char)(n % 10 + '0'); n /= 10;} std::reverse(res.begin(), res.end()); return res;
}

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~




int main(void){
  int n; scanf("%d", &n);
  Vint A(n); REP(i, n) scanf("%d", &A[i]);
  SORT(A);
  int cnt = -1;
  lli SUM = 0;
  for(int i = 0; i < n; i++){
    if(2 * SUM < A[i]) cnt = i;
    SUM += A[i];
  }
  printf("%d\n", n - cnt);
  return 0;
}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

constexpr int atcoder_mod = 1e9+7;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	int N=in(),K=in();
	auto C = vecin<char>(N);
	int num = 0;
	REP(i,N){
		if(C[i]=='R'){
			if(i<N-1 && C[i+1]=='R') num++;
		}
		else{
			if(i>0 && C[i-1]=='L') num++;
		}
	}

	out(min(N-1,2*K+num));
	return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<string.h>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#define ll long long int
#define ld long double
#define INF 1000000000
#define EPS 0.0000000001
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;
typedef pair<int, int> P;

int main()
{
  int n=0;
  int i,j;
  string s;

  cin>>s;

  rep(i,s.size()){
    if(s[i]=='C')
      n=1;
    if(s[i]=='F' && n==1){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
}


Measured memory_bytes: 256
n,k=map(int,input().split())
a=sorted(list(map(int,input().split())))
def groupby():
    global a
    a2=[[a[0],1]]
    for i in range(1,len(a)):
        if a2[-1][0]==a[i]:
            a2[-1][1]+=1
        else:
            a2.append([a[i],1])
    return a2
b=groupby()
b.sort(key=lambda x:x[1],reverse=True)
l=len(b)
ans=0
for i in range(k,l):
    ans+=b[i][1]
print(ans)

Measured memory_bytes: 102480
D=int(input())
clist=list(map(int,input().split()))
smat=[[int(x) for x in input().split()] for _ in range(D)]
#print(clist)
#print(smat)

index_set=set(range(26))
for d in range(D):
  max_index=-1
  max_sd=-1
  for i in index_set:
    if max_sd<smat[d][i]:
      max_index=i
      max_sd=smat[d][i]
      
  max_index2=-1
  max_sd2=-1
  for i in range(26):
    if max_sd<smat[d][i]:
      max_index2=i
      max_sd2=smat[d][i]
      
  if max_index==max_index2:
    print(max_index+1)
    index_set.remove(max_index)
  else:
    if max_sd2>8*max_sd:
      print(max_index2+1)
    else:
      print(max_index+1)
      index_set.remove(max_index)      
      
  if not index_set:
    index_set=set(range(26))
  else:
    sum_c=0
    for i in index_set:
      sum_c+=clist[i]
    if sum_c==0:
      index_set=set(range(26))

Measured memory_bytes: 69188
#include <iostream>
using namespace std;
using ll = int64_t;
int main() {
  ll n, k;
  cin >> n >> k;
  ll ans = 0;
  for (ll i = k; i <= n + 1; ++i) { ans = (ans + i * (n + 1 - i) + 1) % 1000000007; }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3584
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()

int main() {
  //
  int a, b, c, d, e, f;
  cin >> a >> b >> c >> d >> e >> f;
  double maxDensity = 0;
  int answ, anss;
  for (int x = 0; x <= f / 100; x += a) {
    for (int y = 0; y <= f / 100 - x; y += b) {
      int w = (x + y) * 100;
      if (w == 0) continue;
      int smax = min(w / 100 * e, f - w);
      for (int z = 0; z <= smax; z += c) {
        int s = d * ((smax - z) / d) + z;
        if (w + s > f) continue;
        double density = (double)100 * s / (double)(s + w);
        if (density >= maxDensity) {
          maxDensity = density;
          answ = w;
          anss = s;
        }
      }
    }
  }
  cout << answ + anss << " " << anss << endl;
  return 0;
}
// 900 *3000

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

using namespace std;

#define rep(i, n) for(int i=0; i<(n); ++i)
#define all(c) (c).begin(), (c).end()
const double inf = 1e8, eps = 1e-8;

template<typename T> inline void chmin(T& t, T f){if(t > f)t = f;}

struct Edge {
    int u, v, d;
    Edge(int u, int v, int d):u(u), v(v), d(d){}
};

int n, m, p, a, b;
vector<int> t;
vector<Edge> es;

string solve(){
    vector<vector<double> > dp(1<<n, vector<double>(m, inf));
    dp[0][a] = 0.;
    rep(i, 1<<n)rep(j, n){
        if(i >> j & 1)continue;
        for(auto e: es){
            chmin(dp[i | 1<<j][e.u], dp[i][e.v] + 1. * e.d / t[j]);
            chmin(dp[i | 1<<j][e.v], dp[i][e.u] + 1. * e.d / t[j]);
        }
    }
    double res = inf;
    rep(i, 1<<n)chmin(res, dp[i][b]);
    stringstream ss;
    if(abs(res - inf) < eps)ss << "Impossible";
    else ss << fixed << setprecision(3) << res;
    return ss.str();
}

int main(){
    while(cin >> n >> m >> p >> a >> b, n|m|p|a|b){
        a--; b--;
        t.assign(n, 0);
        rep(i, n)cin >> t[i];
        es.clear();
        rep(i, p){
            int x, y, z;
            cin >> x >> y >> z;
            x--; y--;
            es.emplace_back(x, y, z);
        }
        cout << solve() << '\n';
    }
    return 0;
}

Measured memory_bytes: 1376
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstdio>
#define REP(i, n) for (int i = 0; i < (n); i++)
 
using namespace std;
 
int main() {
  int p, q, r;
  cin >> p >> q >> r;
  cout << min(min(p + q, q + r), r + p) << endl;
}

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

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

    string buf = s;
    string target = "()";
    if(!buf.empty())
    {
        string::size_type pos = 0;
        while((pos = buf.find(target ,0)) != string::npos)
        {
            buf.replace(pos, target.length(), "");
        }
    }

    int len = buf.length();

    int p = 0, m = 0;
    for (int i = 0; i < len; i++)
    {
        if(buf[i] == '(')p++;
        else m++;
    }
    
    for (int i = 0; i < m; i++)cout << "(";
    cout << s;
    for (int i = 0; i < p; i++)cout << ")";
    cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int a, b;
  scanf("%d %d",&a,&b);
  if(a>9||b>9)
  {
    printf("-1");
  }
  else
  {
    printf("%d",a*b);
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int max;
		if(a+b < a-b){
			max = a-b;
		}
		else{
			max = a+b;
		}
		if(max < a * b){
			max = a * b;
		}

		System.out.println(max);
	}

}


Measured memory_bytes: 22740
#include<stdio.h>
#include<string.h>

int dice[6];	//top, front, bottom, rear, left, right.
int n;

int north(){
	int t = dice[0];
	dice[0] = dice[1];
	dice[1] = dice[2];
	dice[2] = dice[3];
	dice[3] = t;
	return dice[0];
}

int east(){
	int t = dice[0];
	dice[0] = dice[4];
	dice[4] = dice[2];
	dice[2] = dice[5];
	dice[5] = t;
	return dice[0];
}

int west(){
	int t = dice[0];
	dice[0] = dice[5];
	dice[5] = dice[2];
	dice[2] = dice[4];
	dice[4] = t;
	return dice[0];
}

int south(){
	int t = dice[0];
	dice[0] = dice[3];
	dice[3] = dice[2];
	dice[2] = dice[1];
	dice[1] = t;
	return dice[0];
}

int right(){
	int t = dice[1];
	dice[1] = dice[5];
	dice[5] = dice[3];
	dice[3] = dice[4];
	dice[4] = t;
	return dice[0];
}

int left(){
	int t = dice[1];
	dice[1] = dice[4];
	dice[4] = dice[3];
	dice[3] = dice[5];
	dice[5] = t;
	return dice[0];
}

int input(){
	scanf("%d", &n);
	return n;
}

int run(){
	int i, re = 1;
	char str[16];
	dice[0] = 1;
	dice[1] = 2;
	dice[2] = 6;
	dice[3] = 5;
	dice[4] = 4;
	dice[5] = 3;
	for( i = 0; i < n; i++ ){
		scanf("%s", str);
		if( strcmp(str, "North") == 0 ){
			re += north();
		}else if( strcmp(str, "East") == 0 ){
			re += east();
		}else if( strcmp(str, "West") == 0 ){
			re += west();
		}else if( strcmp(str, "South") == 0 ){
			re += south();
		}else if( strcmp(str, "Left") == 0 ){
			re += left();
		}else if( strcmp(str, "Right") == 0 ){
			re += right();
		}
	}
	printf("%d\n", re);
	return 0;
}

int main(){
	while( input() ){ run(); }
	return 0;
}

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

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

// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


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






#define pf                  printf
#define sf(a)               scanf("%d",&a)
#define sfl(a)              scanf("%lld",&a)
#define sff(a,b)            scanf("%d %d",&a,&b)
#define sffl(a,b)           scanf("%lld %lld",&a,&b)
#define sfff(a,b,c)         scanf("%d %d %d",&a,&b,&c)
#define sfffl(a,b,c)        scanf("%lld %lld %lld",&a,&b,&c)
#define sffff(a,b,c,d)      scanf("%d %d %d %d",&a,&b,&c,&d)
#define sffffl(a,b,c,d)     scanf("%lld %lld %lld %lld",&a,&b,&c,&d)
#define sfffff(a,b,c,d,e)   scanf("%d %d %d %d %d",&a,&b,&c,&d,&e)
#define sfffffl(a,b,c,d,e)  scanf("%lld %lld %lld %lld %lld",&a,&b,&c,&d,&e)
#define sfc(a)              scanf("%c",&a)
#define pii                 pair<int,int>
#define ms(a,b)             memset(a,b,sizeof(a))
#define pb(a)               push_back(a)
#define pbp(a,b)            push_back({a,b})
#define db                  double
#define ft                  float
#define ll                  long long
#define ull                 unsigned long long
#define pii                 pair<int,int>
#define ff                  first
#define ss                  second
#define sz(x)               x.size()
#define all(x)              x.begin(),x.end()
#define CIN                 ios_base::sync_with_stdio(0); cin.tie(0)
#define max3(a, b, c)       max(a, b) > max(b, c) ? max(a, b) : max(b, c)
#define min3(a, b, c)       min(a, b) < min(b, c) ? min(a, b) : min(b, c)
#define for0(i,n)           for(int i=0;i<n;i++)
#define for1(i,n)           for(int i=1;i<=n;i++)
#define forrev(i,n)         for(int i=n-1; i>=0; i--)
#define forab(i,a,b)        for(int i=a;i<=b;i++)
#define forba(i,b,a)        for(int i=b;i>=a;i--)
#define stlloop(x)          for(__typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define gcd(a, b)           __gcd(a, b)
#define lcm(a, b)           ((a)*((b)/gcd(a,b)))
#define case1(z)            cout<<"Case "<<z<<": "
#define case2(z)            printf("Case %d: ",z)
#define PI                  acos(-1) //3.14159265358979323846264338328
#define valid(tx,ty)        tx>=0 && tx<row && ty>=0 && ty<col
#define intlim              2147483648
#define N                   1005
#define inf                 100000008
#define mod                 1000000007

/*------------------------------Graph Moves----------------------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/


int main()
{
    ll a,b,c;
    cin>>a>>b>>c;
    if(a+b+c>=22)
        cout<<"bust"<<endl;
    else
        cout<<"win"<<endl;

    //main();
    return 0;
}
































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

#define int long long
#define double long double
#define ff first
#define ss second
#define endl '\n'
#define ii pair<int, int>
#define mp make_pair
#define mt make_tuple
#define DESYNC                      \
  ios_base::sync_with_stdio(false); \
  cin.tie(0);                       \
  cout.tie(0)
#define pb push_back
#define vi vector<int>
#define vii vector<ii>
#define all(x) x.begin(), x.end()
#define EPS 1e-9
#define INF 1e18
#define ROOT 1
#define M 1000000007
#define curtime chrono::steady_clock::now().time_since_epoch().count
#define rep(i, beg, n, s) for (int i = beg; i < n; i += s)
const double PI = acos(-1);

using namespace std;

inline int mod(int n, int m) {
  int ret = n % m;
  if (ret < 0) ret += m;
  return ret;
}

int gcd(int a, int b) {
  if (a == 0)
    return b;
  else
    return gcd(b % a, a);
}
//#define MULTIPLE_TEST_CASE
void solution() {
  int n;
  int ans = -1;
  for (int i = 0; i < 5; i++) {
    int x;
    cin >> x;
    if (x == 0) ans = i + 1;
  }
  cout << ans << endl;
}

int32_t main() {
  DESYNC;
  mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  int t = 1;
#ifdef MULTIPLE_TEST_CASE
  cin >> t;
#endif
  while (t--) solution();
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define db(x) (cerr << #x << ": " << (x) << '\n')
#define cps CLOCKS_PER_SEC
#define tests(t) int t; cin >> t; while(t--)
#define iceil(n, x) (((n) + (x) - 1) / (x))
#define eb emplace_back
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define sz size()
#define all(v) (v).begin(), (v).end()
#define uni(v) sort(all(v)), (v).erase(unique(all(v)), (v).end())
#define fi first
#define se second
#define bitcount(x) __builtin_popcount(x)
#define bit(x) (1LL << x)
#define PI acos(-1.0)
#define EPS 1e-9

#define mod 1000000007
#define maxn 2005

using namespace std;

using namespace __gnu_pbds;
template<class key, class cmp = std::less<key>>
using ordered_set = tree<key, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
///All indexing is 0-based
///methods: find_by_order(k); & order_of_key(k);
///To make it an ordered_multiset, use pairs of (value, time_of_insertion)
///to distinguish values which are similar

typedef long long ll;
typedef double ld;
typedef pair<ll, ll> par;

ll sol,Dp[11][11],a,b,p,N;

int main()
{
    #ifdef acm
    freopen("a.in","r",stdin);
    #endif // acm
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    cin >> N;

    p = 1;
    for(int i=1;i<=N;i++){
        b = i%10 , a = i/p;
        if( (int)log10(i+1)>(int)log10(i))
            p*=10;
        Dp[a][b]++;
    }

    for(int i=1;i<=9;i++)
        for(int j=1;j<=9;j++)
            sol+=Dp[j][i] * Dp[i][j];

    cout << sol;






}



Measured memory_bytes: 768
while True:
  data = [[0 for _ in range(8)] for _ in range(8)]
  for i in range(8):
    data_in = input()
    for j in range(8):
      data[i][j] = int(data_in[j])
  block = []
  for i in range(8):
    for j in range(8):
      if data[i][j] == 1:
        block.append([i,j])
  piv_x = block[0][0]
  piv_y = block[0][1]
  if block[3][0] == piv_x + 1 and block[3][1] == piv_y + 1:
    print("A")
  elif block[3][0] == piv_x + 3:
    print("B")
  elif block[3][1] == piv_y + 3:
    print("C")
  elif block[3][1] == piv_y - 1 and block[3][0] == piv_x + 2:
    print("D")
  elif block[3][1] == piv_y + 2 and block[3][0] == piv_x + 1:
    print("E")
  elif block[3][1] == piv_y + 1 and block[3][0] == piv_x + 2:
    print("F")
  elif block[3][1] == piv_y and block[3][0] == piv_x + 1:
    print("G")
  try:
    data_in = input()
  except EOFError:
    break


Measured memory_bytes: 5616
using System;
using System.Collections.Generic;
using System.Linq;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
           int A, B, H, M;
            string[] str = Console.ReadLine().Split(' ');
            A = int.Parse(str[0]);
            B = int.Parse(str[1]);
            Console.WriteLine(A*B);
        }
        
    }
}

Measured memory_bytes: 27536
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
  int n, i, m = 0;
  vector<int> t(101);
  while (cin >> n)
    t[n]++;
  for (auto e : t)
    m = max(e, m);
  for (i = 1; i < 101; i++)
    if (m == t[i]) cout << i << endl;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int,int> pii;
typedef long long ll;
const long long MOD=1000000007;
#define rep(i,n) for(long long i=0;i<(n);i++)
#define rep2(i,m,n) for(long long i=(m);i<(n);i++)
#define ALL(v) v.begin(), v.end()
#define pb push_back







int main(){

    ll n;
    cin>>n;

    vector<ll> data(n+1);
    rep(i,n){
        ll tmp;
        cin>>tmp;
        data.at(i+1)=tmp;
    }

    ll money=1000;
    ll kabu=0;

    for (ll i=1;i<=n;i++){
        if (i==n){
            money+=kabu*data.at(n);
        }


        else {
            if (data.at(i+1)>data.at(i) and money>0){
                kabu+=(money/data.at(i));
                money-=(money/data.at(i))*data.at(i);
            }
            else if (data.at(i+1)<data.at(i) and kabu>0){
                money+=kabu*data.at(i);
                kabu=0;
            }
        }

    }

    cout<<money<<endl;




}








            






Measured memory_bytes: 3608
from collections import deque, Counter

N = input()
l = len(N)

h = deque(['3','5','7'])
rlt = 0

while h:
  a = h.popleft()
  if int(N) >= int(a):
    dic = Counter(a)
    if dic['3'] > 0 and dic['5'] > 0 and dic['7'] > 0:
      rlt += 1
  if len(a) < l:
    for s in ('3','5','7'):
      h.append(a+s)
      
print(rlt)

Measured memory_bytes: 77944
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define F first
#define S second
#define pb push_back
#define pp pop_back
#define ubo upper_bound
#define lbo lower_bound
#define VI vector<int>
#define VL vector<ll>
#define VP vector<pii >
#define all(x) x.begin(), x.end()
#define M vector<VI >

using namespace std;

#define pss pair<string, string>

int n;
ll c[55];
string s[55];
map<pss, bool> mp;

void sht(pss &x){
	reverse(all(x.F));
	while(x.F.size() && x.S.size()){
		if(x.F.back() != x.S.back()) break;
		x.F.pp(); x.S.pp();
	} reverse(all(x.F));
}

bool pch(pss &x){
	bool ret = 1;
	int sz = max(x.F.size(), x.S.size());
	if(x.S.size()){
		for(int i=0; i<sz/2; i++) if(x.S[i] != x.S[sz-1-i]) ret = 0;
	} else {
		for(int i=0; i<sz/2; i++) if(x.F[i] != x.F[sz-1-i]) ret = 0;
	}
	return ret;
}

int main(){

	cin >> n;
	for(int i=0; i<n; i++) cin >> s[i] >> c[i];

	ll ans = -1;

	priority_queue<pair<ll, pss > > q;

	for(int i=0; i<n; i++){
		for(int j=0; j<2; j++){
			pss nx;
			if(j&1) nx.F = s[i];
			else nx.S = s[i];
			q.push({-c[i], nx});
		}
	}


	while(!q.empty()){
		auto cr = q.top();
		q.pop();

		sht(cr.S);
		if(mp[cr.S] || min(cr.S.F.size(), cr.S.S.size()) > 0) continue;

		if(pch(cr.S)){
			ans = -cr.F;
			break;
		}

		mp[cr.S] = 1;

		for(int i=0; i<n; i++){
			if(cr.S.F.empty()) q.push({cr.F-c[i], {s[i], cr.S.S}});
			if(cr.S.S.empty()) q.push({cr.F-c[i], {cr.S.F, s[i]}});
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 9160
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <cstring>

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

#define vii vector<int>
#define vll vector<ll>
#define vip vector<pair<int,int> >
#define pb push_back


int main(int argc,char* argv[])
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    //#ifndef ONLINE_JUDGE
    //   freopen("input.txt", "r", stdin);
    //   freopen("output.txt", "w",stdout);
    //#endif

    /*int tc;
    cin>>tc;
    while(tc--)
    {

    }*/
    int a,b;
    string x,y;
    cin>>x>>y>>a>>b;
    string u;
    cin>>u;
    if(u==x) --a;
    else --b;
    cout<<a<<" "<<b;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){

  int a, b, c;
  cin >> a >> b >> c;

  int day = 0;
  int coin = 0;

  while(coin < c){
    day++;
    if(day % 7 == 0){
      coin += b;
    }
    coin += a;
  }
  cout << day << '\n';

  

  return 0;
}



Measured memory_bytes: 3100
#include<stdio.h>
#include<math.h>
#include<string.h>
#define loop(i,n) for(int i=0; i<n; i++)

int main(){
  int a,b,c,d,t,ans;
	while(1){
		ans = 0;
		int r[200]={};
		scanf("%d%d",&a,&b);
		if(a==0 && b==0) break;
		loop(i,a){
			scanf("%d",&c);
			loop(i,c){
				scanf("%d",&d);
				r[d]++;
			}
		}
		t = 0;
		loop(i,200){
			if(r[i]>=b && ans<i && t<r[i]){
				ans = i;
				t = r[i];
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}



Measured memory_bytes: 2100
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ff first
#define ss second
#define boost ios::sync_with_stdio(false);cin.tie(nullptr)
#include "string"

const int N = 2e3 + 5;
const int M = 1e9 + 7;

int mod(int m) {
   m %= M;
   return (m + M) % M;
}

int power(int x,int y) {
   int res = 1;
   x = mod(x);
   while (y > 0) {
      if (y & 1)
         res =mod(res*x);
      y = y>>1;
      x = mod(x*x);
   }
   return mod(res);
}

int a[N],b[N],dp[N][N];
int n,m;

int solve(int i,int j){
	if(i >= n or j >= m)
		return 0;
	int &tmp = dp[i][j];
	if(tmp != -1)
		return tmp;
	tmp = mod(solve(i+1,j) + solve(i,j+1));
	if(a[i] == b[j])
		tmp = mod(tmp + 1);
	else
		tmp = mod(tmp - solve(i+1,j+1));
	return tmp;
}

int32_t main(){
	boost;
	cin>>n>>m;
	for(int i=0;i<n;i++)
		cin>>a[i];
	for(int i=0;i<m;i++)
		cin>>b[i];
	memset(dp,-1,sizeof dp);
	int ans = solve(0,0);
	ans = mod(ans + 1);
	cout<<ans<<endl;	
}



Measured memory_bytes: 35404
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);


int main(){
    string s;cin>>s;
    string ans="";
    rep(i,0,s.size()-1){
        ans=ans+'x';
    }
    cout<<ans<<endl;
    
    return 0;
}


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

struct Node{
  int depth;
  Node* child[2];
  Node(){
    child[0]=child[1]=nullptr;
  }
};

int main(){
  int N; ll L; cin>>N>>L;
  Node* root=new Node;
  root->depth=0;
  rep(i,N){
    string s; cin>>s;
    Node* cur=root;
    rep(j,s.length()){
      int c=s[j]-'0', d=cur->depth;
      if(cur->child[c]==nullptr){
        cur->child[c]=new Node;
        cur->child[c]->depth=d+1;
      }
      cur=cur->child[c];
    }
  }

  queue<Node*> que;
  que.push(root);
  ll ans=0;
  while(que.size()){
    Node* cur=que.front(); que.pop();
    if((cur->child[0]==nullptr)&&(cur->child[1]==nullptr)) continue;
    if((cur->child[0]==nullptr)||(cur->child[1]==nullptr)){
      int d=cur->depth;
      ans^=(__builtin_ctz(L-d)+1);
    }
    rep(i,2) if(cur->child[i]!=nullptr) que.push(cur->child[i]);
  }
  if(ans==0) cout<<"Bob\n";
  else cout<<"Alice\n";
  return 0;
}


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

int main(){
	int a,b,c;
	
	scanf("%d %d %d",&a,&b,&c);
	
	int temp;
	
	temp=a;
	a=b;
	b=temp;
	
	temp=a;
	a=c;
	c=temp;
	
	printf("%d %d %d\n",a,b,c); 
	
	return 0;
}

Measured memory_bytes: 256
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

def main():
    s = input()
    if s == 'hi':
        print('Yes')
        return
    if s == 'hihi':
        print('Yes')
        return
    if s == 'hihihi':
        print('Yes')
        return
    if s == 'hihihihi':
        print('Yes')
        return
    if s == 'hihihihihi':
        print('Yes')
        return
    print('No')
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 39020
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
using namespace std;

int main(){

    int n; cin >> n;

    string word[n];
    for(int i=0; i<n; i++){
        cin >> word[i];
    }

    bool endflag = false;
    for(int i=1; i<n; i++){
        for(int j=0; j<i; j++){
            if(word[i] == word[j]){
                cout << "No" << endl;
                endflag = true;
                break;
            }
            else if(word[i-1][word[i-1].size()-1] != word[i][0]){
                cout << "No" << endl;
                endflag = true;
                break;
            }
        }
        if(endflag) break;
    }

    if(!endflag) cout << "Yes" << endl;

    return 0;
}

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

#define ll long long
#define ull unsigned long long
#define pb push_back
#define pii pair<int, int>
#define sz size()

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>void __f(const char* name, Arg1&& arg1){cout<<name<<" : "<<arg1<<"\n";}
template <typename Arg1, typename... Args>void __f(const char* names, Arg1&& arg1, Args&&... args)
{const char* comma=strchr(names+1,',');cout.write(names,comma-names)<<" : "<<arg1<<" , ";__f(comma+1, args...);} 
#define traceloop(x,a) { cerr<<#a<<": "; for(ll ix=0;ix<x;ix++) cerr<<a[ix]<<" "; cerr<<endl; }

int main()
{
	ios::sync_with_stdio(0);

	int i, j, k, n;

	cin>>n>>k;
	int a[n];
	vector<bool> dp(k+1, 0);
	for(i=0;i<n;++i)
		cin>>a[i];

	dp[0] = 0;
	for(i=0;i<k;++i)
	{
		for(j=0;j<n;++j)
		{
			if(i + a[j] <= k)
				if(!dp[i])
					dp[i + a[j]] = 1;
		}
	}

	//traceloop(k+1, dp);

	if(dp[k])
		cout << "First\n";
	else
		cout << "Second\n";

	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int INF = numeric_limits<int>::max() / 2;
using ll = long long;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k;
    cin >> n >> k;
    vector<int> x(n);
    for(int i = 0; i < n; i++){
        cin >> x[i];
    }
    int ans = INF;
    for(int i = 0; i + k - 1< n; i++){
        ans = min(ans, x[i+k-1] - x[i] + min(abs(x[i+k-1]), abs(x[i])));
    }
    cout << ans << endl;
    return 0;
}

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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



void solve() {
	int N; cin >> N;
    map<string, int> m;
    rep(i, N){
        string s; cin >> s;
        // m[s];
        m[s]++;
    }
    int M; cin >> M;
    rep(i, M){
        string s; cin >> s;
        m[s]--;
    }
    int ans=0;
    for(auto a : m){
        ans = max(ans, a.second);
    }
    cout << ans << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


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

using namespace std;

const long long MOD = 1e9 + 7;

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

    // N 以下の素数を生成
    vector<bool> is_prime(N + 1, true);
    is_prime[0] = false;
    is_prime[1] = false;
    for (int i = 2; i <= N; i++) {
        if (is_prime[i]) {
            for (int j = 2; i*j <= N; j++) is_prime[i*j] = false;
        }
    }

    // N! の素因数分解
    vector<int> prime_num(N + 1);
    for (int i = 2; i <= N; i++) {
        if (is_prime[i]) {
            int p = i;
            while (p <= N) {
                prime_num[i] += N/p;
                p *= i;
            }
        }
    }

    long long ans = 1;
    for (int i = 2; i <= N; i++) {
        if (is_prime[i]) {
            ans *= prime_num[i] + 1;
            ans %= MOD;
        }
    }

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;
const int INF=1000000000;

vector<LL> X;
LL memo[3001][3001][2];
int N;

LL dfs(int a,int b,int c){
    if(~memo[a][b][c]) return memo[a][b][c];
    if(a==b) return memo[a][b][c]=0;
    LL ret=0;
    if(!c){
        ret=max(dfs(a+1,b,c^1)+X[a],dfs(a,b-1,c^1)+X[b-1]);
    }
    else{
        ret=min(dfs(a+1,b,c^1)-X[a],dfs(a,b-1,c^1)-X[b-1]);
    }
    return memo[a][b][c]=ret;
}



int main(){
    cin >> N;
    for (int i = 0; i < N; i++) {
        LL x;cin >> x;
        X.pb(x);
    }
    memset(memo,-1,sizeof(memo));
    cout << dfs(0,N,0) << endl;
    return 0;
}



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

int main()
{
	int N,T,A, H, ans;
	cin >> N >> T >> A;
	double min(pow(10,10));
	for(int i(0);i<N;++i){
		cin >> H;
		if( abs(A - T + H * 0.006) < min){
			min = abs(A - T + H * 0.006);
			ans = i;
		}
	}
	cout << ans + 1 << endl;
	return 0;
}

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

// infty
#define ULLINF (ULLONG_MAX)
#define LLINF  (LLONG_MAX)
#define IINF   (INT_MAX)
#define INF    (1<<29)

// math
#define Sq(x) ((x)*(x))

// container utility
#define ALL(x) (x).begin(), (x).end()
#define MP make_pair
#define PB push_back

// rep
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

// typedef
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef vector<VI> VVI;

typedef long long ll;

// pair util
#define FST first
#define SND second

// range validator
#define CK(n,a,b) (a<=n && n<b)

// conversion
template<class T> inline string toStr(T a) { ostringstream oss_; oss_ << a; return oss_.str(); }
inline int toInt(string s) { return atoi(s.c_str()); }

// prime
bool isPrime(int a) { for(int i=2; i*i <=a; i++) if(a%i == 0) return false; return true; }

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

//////////////////////////////////////////////////////////////

string line;
set<int> memo[200][200];
set<PII> used;

set<int> eval(int const l, int const r) {
  
  /*
  for(int i=l; i<r; i++) cout << line[i];
  cout << endl;
  */
  set<int>& ret = memo[l][r];
  if(l == r) return ret;
  
  if(used.count(MP(l, r))) return ret;
  used.insert(MP(l, r));
  
  // check is digits [l, r)
  bool digits = true;
  for(int i=l; i<r; i++) { digits = digits && isdigit(line[i]); }
  if(digits) { ret.insert(toInt(line.substr(l, r-l))); return ret; }
  
  int par = 0; bool check = true;
  for(int i=l; i<r-1; i++) {
    if(line[i] == '(') { par ++; }
    if(line[i] == ')') { par --; }
    if(par == 0) { check = false; }
  }
  
  // "(expr)"
  if(check) {
    if(line[r-1] == ')') {
      /*
      for(int i=l; i<r; i++) cout << line[i];
      cout << endl;
      */
      return ret = eval(l+1, r-1);
    }
  }
  
  par = 0;
  // parsing loop
  for(int i=l; i<r; i++) {
    if(line[i] == '(') { par ++; }
    if(line[i] == ')') { par --; }
    if(par != 0) continue;
    
    switch(line[i]) {
    case '+': case '-': case '*': case '/': {
      set<int> st_a = eval(l, i), st_b = eval(i+1, r);
      set<int>::iterator iter_a, iter_b;
      for(iter_a = st_a.begin(); iter_a!=st_a.end(); iter_a++) {
	for(iter_b = st_b.begin(); iter_b!=st_b.end(); iter_b++) {
	  if(line[i] == '+') { ret.insert(*iter_a + *iter_b); }
	  if(line[i] == '-') { ret.insert(*iter_a - *iter_b); }
	  if(line[i] == '*') { ret.insert(*iter_a * *iter_b); }
	  if(line[i] == '/') {
	    if(*iter_b == 0) continue;
	    ret.insert(*iter_a / *iter_b);
	  }
	}
      }
      break;
    }
    default:;
    }
  } // for parsing loop
  
  return ret;
}

int main() {
  
  while(cin >> line) {
    for(int i=0; i<200; i++)
      for(int j=0; j<200; j++)
	memo[i][j].clear();
    
    used.clear();
    
    if(line == "#") break;
    cout << eval(0, line.size()).size() << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3208
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
typedef long long lint;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int A, B, C;
	cin >> A >> B >> C;

	cout << min({ A + B,B + C,C + A }) << "\n";

	return 0;
}

Measured memory_bytes: 256
import sys

def main():
    x,y=map(int,input().split())
    s=2*x+y
    t=2*y+x
    if s//3-(s%3==0)==t//3-(t%3==0):
        print('Brown')
    else:
        print('Alice')

if __name__=='__main__':
    main()


Measured memory_bytes: 9124
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(v) v.begin(),v.end()

int main() {
  int h,w,k;
  cin >> h >> w >> k;
  char c[h][w];
  for(int i=0;i<h;i++){
  	for(int j=0;j<w;j++){
    	cin >> c[i][j];
    }
    cout << endl;
  }
  
  int result=0;
  for(int bit1=0;bit1<(1<<h);bit1++){
  	for(int bit2=0;bit2<(1<<w);bit2++){
      char d[h][w];
      for(int i=0;i<h;i++){
  	for(int j=0;j<w;j++){
    	d[i][j]=c[i][j];
    }
  }
      int count=0;
      for(int i=0;i<h;i++){
         if(bit1&(1<<i)){
         	for(int j=0;j<w;j++){
            	d[i][j]=' ';
            }
         }
      }
      for(int i=0;i<w;i++){
         if(bit2&(1<<i)){
         	for(int j=0;j<h;j++){
            	d[j][i]=' ';
            }
         }
      }
      for(int i=0;i<h;i++){
  	    for(int j=0;j<w;j++){
    	if(d[i][j]=='#'){count++;}
   		 }
 	  }
      if(count==k)result++;
    }
  }
  
  cout << result;
}


Measured memory_bytes: 3632
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define EQ(a,b) (abs((a)-(b))<eps)
vector<int> sz,w,v;
int main()
{
	for(int i=60;i<=160;i+=20){sz.pb(i);v.pb(i*10);}
	w.pb(2);
	for(int i=1;i<=5;i++)w.pb(i*5);
	while(1)
	{
		int n;
		int ans = 0;
		scanf("%d",&n);
		if(n==0)break;
		for(int i=0;i<n;i++)
		{
			int x,y,h,we;
			scanf("%d %d %d %d",&x,&y,&h,&we);
			int s = x+y+h;
			for(int j=0;j<6;j++)
			{
				if(s<=sz[j]&&we<=w[j])
				{
					ans+=v[j];
					break;
				}
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 1208
package main

import "fmt"

func main(){
	var N int
	fmt.Scan(&N)

	var A = make([]int , N)
	var ans = make([]int, N)
	
	for i := 1 ; i < N ; i++ {
		fmt.Scan(&A[i])
	}

	for i := 1 ; i < N ; i++{
		ans[A[i]-1]++
	}
	for i := 0 ; i < N ; i++{
		fmt.Println(ans[i])
	}
}

Measured memory_bytes: 8528
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using P = pair<ll, ll>;

constexpr double PI = 3.14159265358979323846;
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

class FXorSum3 {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n; cin >> n;
      vector<ll> a(n);
      vector<int> b(60);
      rep(i, n) {
        cin >> a[i];
      }
      rep(i, 60) {
        ll s = 1LL<<i;
        rep(j, n) {
          if (s&a[j]) {
            b[i]++;
          }
        }
      }

      ll ans = 0;
      set<int, greater<>> st;
      vector<bool> used(n);
      ll base = 0;
      rep(i, 60) {
        if (b[i]%2==1) {
          ans += (1LL<<i);
        } else if (b[i] > 0) {
          st.insert(i);
          base += (1LL<<i);
        }
      }

      rep(i, n) {
        a[i] &= base;
        if (a[i] == 0) used[i] = true;
      }

      vector<ll> vec2;
      for(auto e: st) {
        //debug(e);
        int k = -1;
        ll s = 1LL<<e;
        rep(i, n) {
          if (used[i]) continue;
          if (a[i]&s) {
            k = i;
            break;
          }
        }
        debug(k);
        if (k==-1) continue;
        vec2.push_back(a[k]);
        used[k] = true;
        rep(i, n) {
          if (used[i]) continue;
          if (a[i]&s) {
            a[i] ^= a[k];
          }
        }
      }

      ll ans2 = 0;
      for(auto e: vec2) {
        debug(e);
        chmax(ans2, ans2^e);
      }
      cout << ans + ans2*2 << endl;
    }
};

signed main() {
  FXorSum3 solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 1152