akhauriyash/Code-Regression huggingface dataset:
alpha = 'abcdefghijklmnopqrstuvwxyz'

letters = ''

while True:
    try:
        newLetters = str(input())
        letters += newLetters

    except:
        break

    
for a in alpha:
    x = 0
    for l in letters:
        if l.lower() == a:
            x += 1
    print(a + ' : ' + str(x))


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

int main()
{
	std::string str;

	std::cin >> str;

	for(int i=str.length()-1;i>=0;--i)
	{
		if(str.length()==0)
			break;

		std::cout << str[i];
	}
	std::cout << '\n';
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define pr pair<int, int>
#define v1d vector<int>
#define mp make_pair
#define pb push_back
#define v1p vector<pr>
#define vb vector<bool>
#define v2d vector<vector<int>>
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define S(v) sort(v.begin(), v.end())
#define RS(v) sort(v.rbegin(), v.rend())
#define eb emplace_back
#define endl "\n"
#define MOD 1000000007
#define pqx priority_queue <int>
#define pqn priority_queue <int, v1d, greater<int> >
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
int dx[] = {-1, 1, 0, 0};
int dy[] = {0, 0, -1, 1};

void bfs(int s, v2d &a, v1d &p) {
    p[s] = 0;
    queue<int> q;
    q.push(s);
    int n = a.size() - 1;
    vb vis(n + 1, false);
    vis[s] = true;
    while(!q.empty()) {
        int k = q.front();
        q.pop();
        for(auto &x : a[k]) {
            if(!vis[x]) {
                vis[x] = 1;
                p[x] = k;
                q.push(x);
            }
        }
    }
}

int32_t main() {
    fio
    int n, m; cin >> n >> m ;
    v1d p(n + 1);
    v2d a(n + 1);
    for(int i=0; i<m; ++i) {
        int u, v; cin >> u >> v;
        a[u].pb(v);
        a[v].pb(u);
    }
    bfs(1, a, p);
    bool ok = true;
    for(int i=2; i<=n && ok; ++i) {
        if(p[i] == 0) ok = false;
    }
    if(!ok) {
        cout << "No"; return 0;
    }
    cout << "Yes" << endl;
    for(int i=2; i<=n; ++i) cout << p[i] << '\n';
    
}

Measured memory_bytes: 12940
#include<stdio.h>
int main ()
{
    int a,b,c;
    char op;
    while(1){
        scanf("%d %c %d",&a , &op , &b);
        if (op == '+'){
            c = a + b;
        }
        else if( op == '-'){
            c = a - b;
        }
        else if( op == '*'){
            c = a * b;
        }
        else if ( op == '/'){
            c = a / b;
        }
        else break;
        
        printf ("%d\n",c);
    }
    return 0;
}


Measured memory_bytes: 2140
#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
using ll = long long;
using ld = long double;
#define repd(i,a,b) for (int i=a;i<int(b);i++)
#define rep(i,n) repd(i,0,n)
#define VARNAME(v) #v
using P = pair<int,int>;


int main() {
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int BEAM = 680;
  int d;vector<int> c(26);cin>>d;rep(i,26)cin>>c[i];
  vector<array<int, 26>> s(d);
  rep(i,d)rep(j,26)cin>>s[i][j];
  vector<int> curs = {0};
  vector<array<int, 26>> curl(1);
  vector<vector<int>> cura(1);
  rep(i,d){
    int len = int(curs.size()) * 26, ind = 0;
    vector<P> nxs(len);
    vector<array<int, 26>> nxl(len);
    vector<vector<int>> nxa(len);
    rep(j, curs.size()){
      rep(t, 26){
        int score = curs[j];
        array<int, 26> last = curl[j];
        vector<int> ans = cura[j];
        score += s[i][t];
        last[t] = i+1;
        rep(k,26)score -= c[k]*(i+1 - last[k]);
        ans.emplace_back(t);
        nxs[ind] = P(score, ind);
        nxl[ind] = last;
        nxa[ind] = ans;
        ind++;
      }
    }
    sort(nxs.rbegin(), nxs.rend());
    len = min(len, BEAM);
    curs.resize(len);curl.resize(len);cura.resize(len);
    rep(j,len){
      curs[j] = nxs[j].first;
      curl[j] = nxl[nxs[j].second];
      cura[j] = nxa[nxs[j].second];
    }
    BEAM--;
  }
  int ans = 0;
  rep(i,min(int(curs.size()), BEAM)){
    if(curs[ans] < curs[i])ans = i;
  }

  for(auto x : cura[ans]){
    cout << x+1 << endl;
  }
}


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

int main(){
    int n;
    cin >> n;
    vector<int> v,v2,v3;

    int a;
    for(int i=0;i<n;i++){
        cin >>a;
      	v.push_back(a);
    }
     for(int i=0;i<n;i++){
        cin >>a;
      	v2.push_back(a);
    }
       for(int i=0;i<n-1;i++){
        cin >>a;
      	v3.push_back(a);
    }
  int ans;
  for(int i=0;i<n;i++){
  	ans+=v2[i];
    if((v[i+1]-v[i])==1){
    ans+=v3[v[i]-1];
    }
  }
  cout << ans<<endl;
}

Measured memory_bytes: 384
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        String op = sc.next();
        int B = sc.nextInt();
        if(op.equals("+")) System.out.println(A + B);
        else if(op.equals("-")) System.out.println(A - B);
	}

}

Measured memory_bytes: 23252
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <unordered_set>
using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
int depth[2][100001];
int main(){
    std::ios::sync_with_stdio(false);
    int n,a,b;
    cin >> n;
    vector<int> edges[n];
    for(int i=0;i<n-1;++i)
    {
        cin >> a >> b;
        edges[a-1].push_back(b-1);
        edges[b-1].push_back(a-1);
    }

    for(int i=0;i<2;++i)
    {
        for(int j=0;j<n;++j)
        {
            depth[i][j] = 1 << 30;
        }
    }
    // bfs for black
    deque<int> q;
    q.push_back(0);
    depth[0][0] = 0;
    while(!q.empty())
    {
        int cur = q.front();
        q.pop_front();
        for(const int nxt: edges[cur])
        {
            if(nxt == n-1) continue;
            if(depth[0][nxt] == 1 << 30)
            {
                q.push_back(nxt);
            }

            depth[0][nxt] = min(depth[0][nxt], depth[0][cur] + 1);
            
        }
    }
    q.push_back(n-1);
    depth[1][n-1] = 0;
    while(!q.empty())
    {
        int cur = q.front();
        q.pop_front();
        for(const int nxt: edges[cur])
        {
            if(nxt == 0) continue;
            if(depth[1][nxt] == 1 << 30)
            {
                q.push_back(nxt);
            }
            depth[1][nxt] = min(depth[1][nxt], depth[1][cur] + 1);
        }
    }

    int black_count = 0;
    int white_count = 0;
    for(int i=0;i<n;++i)
    {
        //cerr << depth[0][i] << " " << depth[1][i] << endl;
        if(depth[0][i] <= depth[1][i])
        {
            black_count++;
        }
        else
        {
            white_count++;
        }
        
    }
    //cerr << black_count << " " << white_count << endl;
    if(black_count > white_count)
    {
        cout << "Fennec" << endl;
    }
    else
    {
        cout << "Snuke" << endl;
    }
    


}

Measured memory_bytes: 6528
#include<stdio.h>

int main(void){
  char array[4] ;
  char x,y;
  int count_x = 1, count_y = 1;

  scanf("%s",array);
  x = array[0]; // x:1文字目

  if(x != array[1]){ // 1文字目と2文字目が違う
    y = array[1];
    for(int i=0 ; i<2 ; i++){
    if(x == array[i+2])
      count_x++;
    else if(y == array[i+2])
      count_y++;
    }
  }
  else{              // 1文字目と2文字目が同じ 
    count_x++;
    y = array[2];
    if(y == array[3]){
      count_y++;
      if(x == y)   //全て同じ文字のとき
	count_x--; //後の条件から外す
    }
  }


  if(count_x == 2 && count_y == 2)
    printf("Yes\n");
  else
    printf("No\n");


  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<memory.h>
using namespace std;
int main()
{
	while (1){
		char map[101][101];
		bool flag[101][101];
		bool f = false;
		
		int h, w;
		cin >> h >> w;
		if (h == 0 && w == 0){
			return 0;
		}
		memset(flag, 0, sizeof(flag));
		for (int i = 0; i < h; i++){
			for (int i2 = 0; i2 < w; i2++){
				cin >> map[i][i2];
			}
		}
		int x, y;
		x = 0; y = 0;
		while (map[y][x] != '.'){
			if (flag[y][x] == true){
				cout << "LOOP" << endl;
				f = true;
				break;
			}
			if (map[y][x] == '>'){
				flag[y][x] = true;
				x++;
			}
			else if (map[y][x] == '<'){
				flag[y][x] = true;
				x--;
			}
			else if (map[y][x] == '^'){
				flag[y][x] = true;
				y--;
			}
			else if (map[y][x] == 'v'){
				flag[y][x] = true;
				y++;
			}

		}
		if (!f){
			cout << x << " " << y << endl;
		}
	}
}

Measured memory_bytes: 1184
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(a,b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout<<" "<<kbrni;cout<<endl
#define smap(m) cout<<#m<<":";each(kbrni,m)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 100005;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll x,y;
	cin >> x >> y;
	if(x - y >= -1 && x-y <= 1){
		cout << "Brown\n";
	}else{
		cout << "Alice\n";
	}
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a),i##_end=(b);i<=i##_end;++i)
#define For(i,a,b) for(int i=(a),i##_end=(b);i<i##_end;++i)
#define per(i,a,b) for(int i=(b),i##_st=(a);i>=i##_st;--i)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define dbg(x) cerr<<#x" = "<<x<<endl
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define Es(x,i) for(Edge *i=G[x];i;i=i->nxt)
typedef long long ll;
typedef pair<int,int> pii;
const int inf=~0u>>1,MOD=1e9+7;
inline int rd() {
    int x,c,f=1;while(!isdigit(c=getchar()))f=c!='-';x=c-'0';
    while(isdigit(c=getchar()))x=x*10+c-'0';return f?x:-x;
}

int main(){
	ll x,y;
	cin>>x>>y;
	y/=x;
	int ans=0;
	while(y)ans++,y>>=1;
	cout<<ans<<endl;
}

Measured memory_bytes: 764
N,M=map(int,input().split())
if M==1:
  if N==1:
    print(1)
  elif N==2:
    print(0)
  else:
    print(N-2)
elif M==2:
  print(0)
else:
  if N==1:
    print(M-2)
  elif N==2:
    print(0)
  else:
    print((M-2)*(N-2))

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

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

using namespace std;
typedef long long ll;



int main(void){
	ll n = 100;
	ll x;
	cin >> x;
	int i;
	for (i = 0; n < x; i++) {
		n += n * 0.01;
	}
	cout << i;
	

	cout << endl;
}


Measured memory_bytes: 3588
#include<iostream>
#include<cstring>
#include<algorithm>
#define INF 1<<28
using namespace std;
 
int p[222];
int memo[1111111];
int memo2[1111111];
 
int solve(int n){
   
  if(!n) return 0;
  if(~memo[n]) return memo[n];
 
  int ans = INF;
  for(int i=180;i>0;i--) if(n >= p[i]) ans = min(ans, solve(n-p[i])+1);
   
  return memo[n] = ans;
}
 
int solve2(int n){
   
  if(!n) return 0;
  if(~memo2[n]) return memo2[n];
 
  int ans = INF;
  for(int i=180;i>0;i--) if(p[i]&1 && n >= p[i]) ans = min(ans, solve2(n-p[i])+1);
 
  return memo2[n] = ans;
}
 
int main(){
   
  int n;
   
  memset(memo, -1, sizeof(memo));
  memset(memo2, -1, sizeof(memo2));
 
  for(int i=0;i<181;i++) p[i] = i*(i+1)*(i+2)/6;

  //for(int i=0;i<1111111;i+=10){ solve(i), solve2(i); }
  while(cin >> n, n) cout << solve(n) << " " << solve2(n) << endl;
 
}

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

int main(int argc, const char * argv[]) {
    int n;
    string s, ans;
    
    stack<char> st;
    pair<int, int> cnt;
    
    //初期化
    cnt.first = cnt.second = 0;
    
    //入力
    cin >> n;
    cin >> s;
    
    for (int i = 0; i < n; i++) {
        if (s[i] == '(') {
            st.push(s[i]);
        }else if(s[i] == ')'){
            if (st.empty() == true) {
                cnt.first++;
            }else if (st.top() == ')') {
                cnt.first++;
            }else if(st.top() == '('){
                st.pop();
            }
        }
    }
    if (!st.empty()) {
        cnt.second = st.size();
    }
    
    //出力
    for (int i = 0; i < cnt.first; i++) {
        cout << '(';
    }
    cout << s;
    for (int i = 0; i < cnt.second; i++) {
        cout << ')';
    }
    cout << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int X;
    int m3, m1;
    scanf("%d", &X);

    if(X>=2000){
        printf("1");
    }else{
        m3 = X / 100;
        X = X - 100 * m3;

        m1 = X;

        if ((m3 * 5) >= m1)
        {
            printf("1");
        }
        else{
            printf("0");
        }
    }

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
 
using namespace std;
 
#define ss second
#define ff first
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define all(a) (a).begin(),(a).end()
#define rep(i,a,b) for(int (i) = (a); (i) < (b); (i)++)
#define debug(x) cout << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vll = vector<ll>;
using vii = vector<pair<int,int>>;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3fLL;
const int maxn = 1e3+10;


int main(int argc,const char** argv){

	fastio;

	string date;
	cin >> date;

	int d1 = ((date[0] - '0') * 10) + (date[1] - '0');
	int d2 = ((date[2] - '0') * 10) + (date[3] - '0');


	// YYMM MMYY

	if(d1 <= 12 && d1 > 0 && d2 <= 12 && d2 > 0){
		cout << "AMBIGUOUS\n";
	}
	else if(d1 <= 12 && d1 > 0){
		cout << "MMYY\n";
	}
	else if(d2 <= 12 && d2 > 0){
		cout << "YYMM\n";
	}
	else{
		cout << "NA\n";
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(void){
    long long w=0,m=0;
    string s;
    cin>>s;
    for(int i=s.length()-1;i>=0;i--){
        if(s[i]=='W'){
            w++;
        }
        if(w>0&&s[i]=='B'){
            m+=w;
        }
    }
    cout<<m<<endl;
}


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

int main(void){
	int n = 0;
	int m = 0;
	int work = 0;
	cin >> n >> m;
	int vector_a [n][m];
	int vector_b[m];
	int vector_ans[m];
	for(int i = 0; i < n; i++){		//initialize
		for(int j = 0; j < m; j++){
			vector_a[i][j] = 0;
		}
	}
	for(int i = 0; i < m; i++){
		vector_b[i] = 0;
		vector_ans[i] = 0;
	}
	for(int i = 0; i < n; i++){		//input vector_a
		for(int j = 0; j < m; j++){
			cin >> vector_a[i][j];
		}
	}
	for(int i = 0; i < m; i++){		//input vector_b
		cin >> vector_b[i];
	}
	for(int i = 0; i < n; i++){
		work = 0;
		for(int j = 0; j < m; j++){
			work += vector_a[i][j] * vector_b[j];
		}
		vector_ans[i] = work;
	}
	for(int i = 0; i < n; i++){
		cout << vector_ans[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 1196
#include<bits/stdc++.h>
#define endl '\n'
#define int long long
#define eps 1e-9
#define oo 1e7+5

using namespace std;

typedef unsigned long long ull;
typedef vector<pair<int,pair<int,int>>> dirgraph;
typedef vector<vector<int>> graph;

int32_t main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);

	int n;
	cin>>n;
	vector<int> dp(3);
	for (int day = 0; day < n; day++)
	{
		vector<int> act(3);
		for(int &x:act)
		cin>>x;
		vector<int> temp(3);
		for (int i = 0; i < 3; i++)
		{
			for (int j = 0; j < 3; j++)
			{
				if(i!=j)
				{
					temp[j]=max(temp[j],dp[i]+act[j]);
				}
			}
			
		}
		dp=temp;
	}
	
	int ans=max({dp[0],dp[1],dp[2]});

	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <iomanip>
#include <stack>
#include <array>
#include <deque>
#include <forward_list>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <algorithm>
#include <iterator>
#include <string>
#include <cstring>
//#include <fstream>
#include <complex>
#define _USE_MATH_DEFINES
#include <cmath>
#include <math.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n;i>0;i--)
#define arep(a,i,n) for(int i=(a);i<(n);i++)
#define SORT(v) sort((v).begin(),(v).end())
const ll INF = (1LL << 50);
typedef pair<int, int> P;

int main() {

	int x;
	cin >> x;

	int a[6] = { 100,101,102,103,104,105 };

	int m[6] = { 1000000,1000000,1000000,1000000,1000000,1000000 };

	int dp[100000];

	memset(dp, -1, sizeof(dp));

	dp[0] = 0;

	for (int i = 0; i < 6; i++) {
		for (int j = 0; j <= x; j++) {
			if (dp[j] >= 0) {
				dp[j] = m[i];
			}
			else if (j < a[i] || dp[j - a[i]] <= 0) {
				dp[j] = -1;
			}
			else {
				dp[j] = dp[j - a[i]] - 1;
			}
		}
	}

	if (dp[x] >= 0) cout << 1 << endl;
	else cout << 0 << endl;

	return 0;

}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<pi> vpi;

#define debugone(x) cerr << #x << " " << x << endl;
#define debugtwo(x) cerr << #x << "-------------" << endl;for(auto &it: x) cerr << it << " ";cerr << endl;
#define debugthree(x, i, j) cerr << #x << "------------" << endl;cerr << "from " << i << " to " << j << endl;for(int k=i; k<=j; k++) cerr << x[k] << " ";cout << endl;


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

	int n, l;
	cin >> n >> l;

	if(l >= 0){
		cout << l * (n - 1) + (n * (n - 1)) / 2;
	}
	else{
		int posL = (-1) * l;
		int eat;
		if(posL >= n){
			eat = n;
		}
		else{
			eat = posL + 1;
		}

		cout << l * (n) + (n * (n - 1)) / 2 - (l + eat - 1) << endl;
	}
}			

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int count = 0;
		for(int i=0;i<n;i++){
			int r = scanner.nextInt();
			int l = scanner.nextInt();
			count += Math.abs(l+1 - r);
		}
		System.out.println(count);
	}

}


Measured memory_bytes: 27932
#include <bits/stdc++.h>
 
using namespace std;
inline void prep ()
{
  cin.tie (0);
  cin.sync_with_stdio (0);
};
const double pi = acos(-1.);
//printf(%.12lf\n,mid);
// __builtin_popcount(int) count 1's in binary
// get decimal part of number
/*
double intpart;
double thiss = modf((double)(n*m)/(double)k, &intpart);
*/
// round = (int)(num+.5)
long long mod = 1000000007;

// 32 mil = ~1 sec 
long long mymod(long long num){
  if (num< 0 && !(num%mod == 0)){
    if (mod == 1){
      return 0;
    }
    return mod-abs(num)%mod;
  }else{
    return num%mod;
  }
}
 
/*string sentence = And I feel fine...;
    istringstream iss(sentence);
*/  
 
double eps = .000000001;
long long modpow(long long x, long long n) { 
  if (n == 0) return 1%mod; 
  long long u = modpow(x,n/2); 
  u = (u*u)%mod; 
  if (n%2 == 1) u = (u*x)%mod; 
  return u;
}
int main ()
{
  prep();
  int n;
  cin >> n;
  int arr[n];
  int freq[100001]= {0};
  for (int i=0; i<n; i++){
      cin >> arr[i];
      freq[arr[i]]++;
  }
  if (n%2 == 0){
      for (int i=1; i<=n ;i+=2){
          if (freq[i] != 2){
              cout << 0;
              return 0;
          }
        } 
  }else{
    for (int i=0; i<=n ;i+=2){
      if (i == 0){
          if (freq[i] != 1){
              cout << 0;
              return 0;
          }
      }else{
          if (freq[i] != 2){
              cout << 0;
              return 0;
          }
      }
    } 
  }
  cout << modpow(2, n/2);
  return 0; 
}


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

int main(){
   vector<int> s(3);
   for(int i=0;i<3;i++){
       cin >> s.at(i);
   }
   if(s.at(0)==s.at(1)&&s.at(1)==s.at(2)&&s.at(0)==s.at(2)){
       cout << "No" << endl;
   }else if(s.at(0)!=s.at(1)&&s.at(1)!=s.at(2)&&s.at(0)!=s.at(2)){
       cout << "No" << endl;
   }else{
       cout << "Yes" << endl;
   }
}

Measured memory_bytes: 256
let split_string ?(pattern=" ") = Str.split @@ Str.regexp pattern

let (x, y, a, b, c) = Scanf.sscanf (read_line ()) "%d %d %d %d %d" @@ fun x y a b c -> (x, y, a, b, c)
let p = Array.of_list @@ List.map int_of_string @@ split_string @@ read_line ()
let q = Array.of_list @@ List.map int_of_string @@ split_string @@ read_line ()
let r = Array.of_list @@ List.map int_of_string @@ split_string @@ read_line ()

let rev a b = b - a

let () =
  Array.sort rev p;
  Array.sort rev q;
  let t = Array.concat [(Array.sub p 0 x); (Array.sub q 0 y); r] in
  Array.sort rev t;
  print_int @@ Array.fold_left (+) 0 (Array.sub t 0 (x + y));
  print_newline ()

Measured memory_bytes: 23156
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
using namespace std;

#define FILL(a, n, x) memset((a), (x), sizeof ((a)[0]) * (n))
#define FILLA(a, x) memset((a), (x), sizeof (a))
#define COPY(a, n, b) memcpy((b), (a), sizeof ((a)[0]) * (n))
#define COPYA(a, b) memcpy((b), (a), sizeof (a))

typedef unsigned long long lu;
typedef long long li;
typedef pair<int, int> pii;
int mod;

inline int Add(int x) { return x >= mod ? x - mod : x; }
inline void Add(int &x, int y) { x += y; if (x >= mod) x -= mod; }
inline int Sub(int x) { return x < 0 ? x + mod : x; }
inline void Sub(int &x, int y) { x = Sub(x - y); }
inline int Mul(int x, int y) { return (int)((lu)x * y % mod); }
inline int Mul(int x, int y, int z) { return (int)((lu)x * y % mod * z % mod); }

int Pow(int x, int y) {
  int z = 1;
  for (; y; y >>= 1) {
    if (y & 1) z = Mul(z, x);
    x = Mul(x, x);
  }
  return z;
}

int Fix(int x) { return Sub(x % mod); }

int Inv(int x) { return Pow(x, mod - 2); }
template <class T> inline void Max(T &x, T y) { if (y > x) x = y; }
template <class T> inline void Min(T &x, T y) { if (y < x) x = y; }

// ----------------------------------------

const int maxn = 1e5, maxmod = 1e6;

int n, m, q;

struct Edge {
  int a, b, c;
} edge[maxn];

int ID(int u, int p, int q) {
  return u * 6 + p * 3 + q;
}

const int maxN = maxn * 6;
int N, par[maxN];

void InitDsu(void) {
  N = 6 * n;
  for (int i = 0; i < N; ++i) par[i] = i;
}

int Find(int x) {
  return x == par[x] ? x : par[x] = Find(par[x]);
}

void Unite(int x, int y) {
  par[Find(x)] = Find(y);
}

int par4[maxmod];

int Find4(int x) {
  return x == par4[x] ? x : par4[x] = Find4(par4[x]);
}

void Init4(void) {
  for (int i = 0; i < mod; ++i) {
    par4[i] = i;
  }
  for (int i = 0; i < mod; ++i) {
    int j = i * 4 % mod;
    par4[Find4(i)] = Find4(j);
  }
}


int main(void) {
  scanf("%d%d%d%d", &n, &m, &q, &mod);
  int g = mod;
  for (int i = 0; i < m; ++i) {
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    --a; --b;
    edge[i] = {a, b, c};
    g = __gcd(g, mod + edge[i].c - edge[0].c);
  }
  int z = edge[0].c % g;
  mod = __gcd(mod, 3 * g);
  Init4();

  for (int i = 0; i < m; ++i) {
    edge[i].c = Fix(edge[i].c - z) / g;
  }

  InitDsu();
  for (int i = 0; i < m; ++i) {
    int u = edge[i].a, v = edge[i].b;
    for (int p = 0; p < 2; ++p) {
      for (int q = 0; q < 3; ++q) {
        Unite(ID(u, p, q), ID(v, !p, (2 * q + edge[i].c) % 3));
      }
    }
  }

  while (q--) {
    int s, t, r;
    scanf("%d%d%d", &s, &t, &r);
    --s; --t;
    bool ans = false;
    for (int p = 0; p < 2; ++p) {
      for (int q = 0; q < 3; ++q) {
        if (Find(ID(s, p, q)) == Find(ID(t, 0, 0))) {
          ans |= (Find4(Fix(r + z)) == Find4(Fix((1 << p) * z + Mul(q, g))));
        }
      }
    }
    puts(ans ? "YES" : "NO");
  }

  return 0;
}


Measured memory_bytes: 7040
#include <iostream>
#include <string>
#include <cmath>
#include <cstdio>
#define llint long long
#define inf 1e18

using namespace std;

llint r, n;
llint L[25], R[25], h[25];
llint len[25];
bool used[105][25];
llint zero = 52;

int main(void)
{
	while(1){
		cin >> r >> n;
		if(r == 0 && n == 0) break;
		
		for(int i = 0; i < 25; i++){
			for(int j = 0; j < 105; j++){
				used[j][i] = false;
			}
		}
		
		for(int i = 1; i <= n; i++){
			cin >> L[i] >> R[i] >> h[i];
			for(int j = L[i]; j <= R[i]-1; j++){
				for(int k = 1; k <= h[i]; k++){
					used[zero+j][k] = true;
				}
			}
		}
		
		/*for(int i = 1; i < 10; i++){
			for(int j = -10; j <= 10; j++){
				cout << used[zero+j][i] << " ";
			}
			cout << endl;
		}*/
		
		for(int i = 1; i < 25; i++){
			len[i] = inf;
			for(llint j = 0; j < 25; j++){
				if(!used[zero+j][i]){
					len[i] = min(len[i], j);
					break;
				}
			}
			for(llint j = 1; j < 25; j++){
				if(!used[zero-j][i]){
					len[i] = min(len[i], j-1);
					break;
				}
			}
		}
		len[0] = inf;
		//for(int i = 1; i < 25; i++) cout << len[i] << endl;
		
		double ans = inf;
		for(int i = 1; i < 25; i++){
			if(len[i-1] <= len[i]) continue;
			if(len[i] >= r-1e-9) continue;
			double s = sqrt((double)r*r-len[i]*len[i]);
			ans = min(ans, (i-1)-s+r);
			//cout<< i << " " << ans << endl;
		}
		printf("%.11f\n", ans);
	}
	
	return 0;
}


Measured memory_bytes: 3232
#include<cstdio>

int n;
char s[1005];
char cs[3]={'J','O','I'};
int dat[1005]={};
int dp[1005][8]={};


int isok(int c,int sb,int sn){
	if(((1<<c)&sn)==0)return 0;
	if((sb&sn)==0)return 0;
	return 1;
}


int main(void){
	scanf("%d%s",&n,s);
	for(int i=0;i<n;i++){
		for(int j=0;j<3;j++){
			if(s[i]==cs[j]){
				dat[i]=j;
			}
		}
	}
	
	for(int k=0;k<8;k++){
		dp[0][k] = isok(dat[0],1,k);
	}
	
	
	for(int d=1;d<n;d++){
		for(int k=0;k<8;k++){
			for(int p=0;p<8;p++){
				if(isok(dat[d],p,k)==0)continue;
				dp[d][k] += dp[d-1][p];
			}
			dp[d][k]%=10007;
		}
	}
	
	int ans = 0;
	for(int k=0;k<8;k++){
		ans += dp[n-1][k];
	}
	ans%=10007;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1060
s=input()
l=len(s)
mod=10**9+7
dp=[[0 for j in range(13)] for i in range(l+1)]
dp[0][0]=1
for i in range(1,l+1):
  if s[i-1]=='?':
    for j in range(10):
      for k in range(13):
        dp[i][(k*10+j)%13]+=dp[i-1][k]%mod
  else:
    for k in range(13):
      dp[i][(k*10+int(s[i-1]))%13]+=dp[i-1][k]%mod
print(dp[-1][5]%mod)

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

int main(){
    int alSize=26;
    int alph[alSize]={};
    char c;
    while(cin >> c){
        if ('A'<=c && c<='Z')
            alph[c-'A']++;
        else if ('a'<=c && c<='z')
            alph[c-'a']++;
    }
    for (int i=0; i<alSize; i++){
        char al = 'a'+i;
        cout << al << " : " << alph[i] << endl;
    }
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, M;
  cin >> N >> M;
  
  vector<int> cities(N);
  for (int m = 0; m < M; m++) {
    int a, b;
    cin >> a >> b;
    cities.at(a - 1) = cities.at(a - 1) + 1;
    cities.at(b - 1) = cities.at(b - 1) + 1;
  }
  for (int n = 0; n < N; n++) {
    cout << cities.at(n) << endl;
  }
}


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

ll n,A[200001],B[200001],C[200001],tree[10000001],pos,R,rao,ans;

void upd(int node,int tl,int tr){

    if(tl==tr){
        tree[node] ++;
        return ;
    }
    int mid = (tl+tr-1)/2;
    if(pos<=mid)
        upd(node*2,tl,mid);
    else
        upd(node*2+1,mid+1,tr);

    tree[node] = tree[node*2] + tree[node*2+1];
}

ll get(int node,int tl,int tr){

    if(tl>R)return 0;

    if(tr<=R)return tree[node];

    int mid = (tl+tr-1)/2;
    ll x = get(node*2,tl,mid);
    ll y = get(node*2+1,mid+1,tr);

    return x + y;
}


bool check(int x){

    rao = pos = 0 ;
        //cout<<x<<endl;
    for(int i=1;i<=8*n;i++)
        tree[i] = 0;

    for(int i=1;i<=n;i++){
        if(A[i]>=x)
            C[i] = 1;
        else
            C[i] = -1;
    }

    pos = 0;
    upd(1,-n,n);

    for(int i=1;i<=n;i++){

        pos += C[i];

        R = pos;
        rao += get(1,-n,n);
        //cout<<rao<<"-----"<<pos<<endl;

        if(rao >= (n*(n+1)/2+1)/2 )return true;

        upd(1,-n,n);
    }

    return false;

}

int main(){

    cin>>n;

    for(int i=1;i<=n;i++){
        cin>>A[i];
        B[i] = A[i];
    }

    sort(B+1,B+n+1);

    int l = 1 , r = n;

    while(l<=r){

        int mid = (l+r)/2;

        if(check(B[mid])){
            l = mid+1;
            ans = mid;
        } else {
            r = mid-1;
        }

    }

    cout<<B[ans]<<endl;
}


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

using namespace std;

#define pb push_back

const int maxi = 1e6+10;

pair<int,int> a[maxi], b[maxi], v1[maxi], help[maxi];
int cnt[maxi];
mt19937 rng(time(0));
int v[30];
pair<int, int> v2[5000][5000];
int curV2[maxi];

int solve(int x, int l)
{

    int curV = 0;
    v[curV++] = x;

    while(x>1){
        x/=2;
        v[curV++] = x;
    }

  int m = max(int (curV/2), 1);

  int curV1 = 0;

  for (int i = 0; i< m;i++)
    help[1<<i] = a[v[i]];

  for (int mask = 0;mask<(1<<m);mask++){

    int val = 0;
    int weig = 0;

     if (mask  > 0)
     {
         int bit = mask&(-mask);
         if (bit !=mask){
         weig = help[mask^bit].first + help[bit].first;
         val = help[mask^bit].second + help[bit].second;
         } else
         {
            weig = help[bit].first;
            val = help[bit].second;
         }
     }

     help[mask] = {weig, val};

     if (weig <=l) v1[++curV1] = {weig, val};
  }

  sort(v1+1 , v1 + curV1 + 1);

  cnt[0] = 0;

  for (int i = 1;i<=curV1;i++)
      cnt[i] = max(cnt[i- 1], v1[i].second);

  int ans = 0;

   int node;
   if (m!=curV)
    node = v[m]; else
    node = 0;

   int lo = 0;
    for (int i = curV2[node]; i>0;i--)
    {
        if (v2[node][i].first >l) continue;
         while(lo<=curV1 && v2[node][i].first + v1[lo].first <=l) lo++;

         lo--;

         ans = max(ans, cnt[lo] + v2[node][i].second);
    }

  return ans;

}

void precalc(int node)
{
  vector<int> v;

  int x = node;
  v.pb(x);

  while(x>1)
  {
      x/=2;
      v.pb(x);
  }

  int m = v.size();

  for (int mask = 0; mask<(1<<m);mask++)
  {
      int weig = 0;
      int val = 0;
     for (int j = 0 ;j <m;j++)
        if (mask&(1<<j))
     {
         val+=a[v[j]].second;
         weig+=a[v[j]].first;
     }

     curV2[node]++;

     v2[node][curV2[node]] = {weig, val};
  }

  sort(v2[node] + 1, v2[node] + curV2[node] + 1);

}

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

    for (int i = 1;i<=n;i++){
        scanf("%d%d",&a[i].first,&a[i].second);
        swap(a[i].first, a[i].second);
     //a[i] = {1, 1};
    }

   curV2[0] = 1;
   for (int i = 1;i<=min(n, 2048);i++)
    precalc(i);


    cin>>q;

    for (int i = 1;i<=q;i++){
        scanf("%d%d",&b[i].first, &b[i].second);
    // b[i] = {rng()%n + 1, rng() % 100000};
    }

    for (int i = 1;i<=q;i++)
    {
        int ans = solve(b[i].first,  b[i].second);
        printf("%d\n",ans);
    }

}
//Moj mali posao za Bari
//cekam da se vrati, donijece mi stvari
//a kad se vrati, pune se ormari
//svima da se hvalim, korzo da zapalim


Measured memory_bytes: 36740
# ABC157 - D

from collections import Counter

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

fn = [1]*N
CD = [0]*K

par = list(range(N))

def root(x):
    S = set()
    S.add(x)
    y = x
    while True:
        if par[y] == y:
            for s in S:
                par[s] = y
            return y
        S.add(y)
        y = par[y]

def unite(x,y):
    rx = root(x)
    ry = root(y)
    par[rx] = ry

for _ in range(M):
    A,B = map(int,input().split())
    A -= 1
    B -= 1
    fn[A] += 1
    fn[B] += 1
    unite(A,B)
    
for _ in range(K):
    C,D = map(int,input().split())
    C -= 1
    D -= 1
    CD[_] = (C,D)

par = [root(x) for x in range(N)]
c = Counter(par)

RESULT = [(c[par[x]] - fn[x]) for x in range(N)]

for C,D in CD:
    if par[C] == par[D]:
        RESULT[C] -= 1
        RESULT[D] -= 1

print(*RESULT,sep=" ")

Measured memory_bytes: 84440
#include<iostream>

using namespace std;

int main(void)

{
    int n, a;
    cin>>n;
    a = n%10;
    if(a == 2 ||a == 4 ||a == 2 ||a == 5 || a == 7 ||a == 9)
        cout<<"hon\n";
    else if(a == 0 ||a == 1 || a == 6 || a == 8)
    cout<<"pon\n";
    else cout<<"bon\n";
    return 0;
}


Measured memory_bytes: 3132
n,a,b,c=map(int,input().split())
L=[]

def base10to(n,b):
    if n//b:
        return base10to(n//b,b)+str(n%b)
    return str(n%b)

for i in range(n):
    L.append(int(input()))
ans=10**10
for i in range(4**n):
    S=base10to(i,4)
    S=S.zfill(n)
    A=[]
    B=[]
    C=[]
    for j in range(n):
        if S[j]=='0':
            continue
        elif S[j]=='1':
            A.append(L[j])
        elif S[j]=='2':
            B.append(L[j])
        else:
            C.append(L[j])
    if A and B and C:
        ans=min(ans,abs(a-sum(A))+(len(A)-1)*10+abs(b-sum(B))+(len(B)-1)*10+abs(c-sum(C))+(len(C)-1)*10)
print(ans)

Measured memory_bytes: 3064
import std.container;
import std.range;
import std.algorithm;
import std.array;
import std.string;
import std.conv;
import std.stdio;
import std.container;

void main() {
	int x;
	readf("%s", &x);

	if (x == 0) {
		writeln(1);
	} else {
		writeln(0);
	}
}


Measured memory_bytes: 2812
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
      return Array.new(size1){init}
  else
      return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

N=gets.to_i
A=get_i
ans=0
N.times do|i|
    ans+=1 if (i+1).odd? and A[i].odd?
end
puts ans

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
	int h, w, m;
	cin >> h >> w >> m;
	vector<int>hp(h), wp(w);
	set<pi>s;
	rep(i, m) {
		int y, x;
		cin >> y >> x;
		y--, x--;
		hp[y]++;
		wp[x]++;
		s.insert(pi(y, x));
	}
	int mh=0, mw=0;
	rep(i, h)mh = max(mh, hp[i]);
	rep(i, w)mw = max(mw, wp[i]);

	vector<int>hm, wm;
	rep(i, h)if (hp[i] == mh)hm.push_back(i);
	rep(i, w)if (wp[i] == mw)wm.push_back(i);

	ll ans = mh + mw;

	for(int y:hm)for(int x:wm) {
		if(s.count(pi(y,x)))continue;
		cout << ans << endl;
		return 0;
	}
	cout << --ans << endl;

	return 0;
}



Measured memory_bytes: 23792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template <class T = int>T in(){
    T x;
    cin >> x;
    return (x);
}

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

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

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int N = in()-1, K = in()-1;
    vector<int> A(N+1);
    REP(i,N)A[i] = in();
    cout << (N + K - 1)/K << "\n";
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#include<string.h>
#define ll long long
#define Start ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define fr first
#define sc second
# define M_PI           3.14159265358979323846
using namespace std;

int main()
{
    Start;
    int r;
    cin>>r;
    cout<<2*M_PI*r;




}






Measured memory_bytes: 3808
#include <iostream>
using namespace std;
int main() {
    string s,t;
    cin>>s>>t;
    int size=s.length(),sum=0;
    for (int i = 0; i < size ; i++) {
            if (s[i]!=t[i])
                sum++;
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 3896
import numpy as np
import math

N = int(input())

spot = np.zeros(N + 1)
spot[1:] = np.array(list(map(int, input().split())))

tot = int(np.abs(np.roll(spot, 1) - spot).sum())

for i in range(1, N+1):
    print(int(tot - math.fabs(spot[i] - spot[i-1]) - math.fabs(spot[(i+1) % (N+1)] - spot[i])\
            + math.fabs(spot[(i+1) % (N+1)] - spot[i-1])))

Measured memory_bytes: 22924
#include <cstdio>
#include <algorithm>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>

typedef long long ll;
typedef long long int lli;

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

template<class T>bool umax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool umin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using namespace std;


int main() {
    int N;
    cin>> N;
    printf("%d", 1110-N);


    return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <iterator>
#include <algorithm>
#include <map>
#include <string.h>
#include <vector>
#include <cmath>
#include <deque>
#include <iomanip>

using namespace std;
#define range(a) a.begin(), a.end()
#define rep(i, c) for(int i = 0; i < (int)c; i++)
typedef long long ll;

const string YES = "Yes";
const string NO = "No";

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

  int a, b, c; cin >> a >> b >> c;
  swap(a, b);
  swap(a, c);
  cout << a << " " << b << " " << c << endl;



  return 0;

}


Measured memory_bytes: 384
using System;
class B_Echo
{
    static void Main(string []args)
    {
        int N = int.Parse(Console.ReadLine());
        string S = Console.ReadLine();
        if (N % 2 == 1) Console.WriteLine("No");
        else
        {
            if (S.Substring(0, N / 2) == S.Substring(N / 2)) Console.WriteLine("Yes");
            else Console.WriteLine("No");
        }
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <memory>
#include <memory.h>
#include <cmath>
#include <fstream>
#include <cmath>
#include <numeric>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <sstream>
#include <cstdlib>
#include <cassert>
#include <cstdio>
#include <map>
#include <iomanip>
#include <list>
#include <cctype>
#include <algorithm>
#include <complex>
#define USE_MATH_DEFINES
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, m, n) for(int i = m; i < n; i++)
using namespace std;

typedef complex<double> xy_t;
typedef pair<xy_t, xy_t> line;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<int, PP> PPP;
const int INF = 1 << 29;
const double EPS = 1E-10;

int main(){
	int n;
	while(cin >> n && n){
		int cnt = 0;
		while(n != 1){
			if(n % 2 == 0) n /= 2;
			else n = n * 3 + 1;
			cnt++;
		}
		cout << cnt << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=(1LL<<60);
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n, k, now = 1;
    cin >> n >> k;
    for(int i=0;i<n;i++){
    	if(now * 2 >= now + k){
    		now += k;
    	}else{
    		now *= 2;
    	}
    }
    cout << now << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
using ll=long long;
using ull=unsigned long long;
template<typename T>using min_queue=priority_queue<T,vector<T>,greater<T>>;
template<typename T>using max_queue=priority_queue<T>;
#define Debug(x) cerr<<#x<<" = "<<x<<endl
#define Debug2(x,y) cerr<<#x<<" = "<<x<<", "<<#y<<" = "<<y<<endl
#define rep(i,n) for (int i=0;i<(n);i++)
#define Rep(i,a,b) for (int i=(a);i<=(b);i++)
#define repit(it,a) for (__typeof(a.begin()) it=a.begin();it!=a.end();++it)
#define eprintf(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define printtime eprintf("\n\nTime elasped : %.3f seconds.\n\n",clock()*1.0/1000)
#define RET(p,x) return p<<x<<endl,0
#define all(a) (a).begin(),(a).end()
#define reunique(v) v.erase(unique(all(v)),v.end())
#define sz(a) (int)a.size()
#define X first
#define Y second
#define fill_inf(a) memset(a,-19999873,sizeof(a))
#define fill_neginf(a) memset(a,-19999872,sizeof(a))
#define fill_0(a) memset(a,0,sizeof(a))
#define fill_neg1(a) memset(a,0,sizeof(a))
#define __str__(x) #x
#define sqr(x) ((x)*(x))
const int inf=1e9;
const long long lnf=1e18;
const long long h1=239017,h2=731604233;
const long long mod=1000000007,mod2=1000000009;
const long double pi=3.141592653589793238462643383279;
const long double EPS=1e-9;
ll n;
ll a[100005];
ll num=0;
ll ans=0;
int main()
{
	ios_base::sync_with_stdio(false);cin.tie();cout.tie();
	cout<<setprecision(15);
	cin>>n;
	for (ll i=1;i<=n;++i)
	{
		cin>>a[i];
	}
	for (ll i=0;i<=n;++i)
	{
		ans+=abs(a[0]-a[i]);
		a[0]=a[i];
	}
	ans+=abs(a[n]);
	a[0]=0;
	for (ll i=1;i<=n;++i)
	{
		cout<<ans-abs(a[i]-a[i-1])-abs(a[i]-a[i+1])+abs(a[i-1]-a[i+1])<<endl;
	}
	return 0;
}

Measured memory_bytes: 2048
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;

typedef long long int llint;

llint N;

int main() {
	cin >> N;
	llint ans = 0;
	for (llint i = 1; i <= N; i++) {
		if (i % 3 != 0 && i % 5 != 0) {
			ans += i;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  
  long N;
  cin >> N;
  vector<long> a(N);

  for(long i=0; i<N; i++){
  	cin >> a[i];
  }
  sort(a.begin(),a.end());
  
  int sum=N;
  
  for(long i=0; i<N; i++){
  	if(a[i]==a[i+1]){
    	sum-=2;
      i++;
    }
  }
  cout << sum << endl;

}
  

Measured memory_bytes: 1024
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FUNCTION__ << endl;
#define int long long

const long long INF = __LONG_LONG_MAX__ / 2;

using namespace std;
int a[200000];
bool visited[200000];

signed main(){
    int N;
    cin >> N;
    for (int i = 1; i< N+1 ; i++) visited[i] = false;
    for (int i = 1; i < N+1; i++){
      cin >> a[i];
    }

    int count = 0;
    int pos = 1;
    visited[1] = true;
    while(true){
      if (pos == 2) {
        cout << count;
        return 0;
      }
      pos = a[pos];
      if (visited[pos]) {
        cout << -1 ;
        return 0;
      }
      visited[pos] = true;
      count++;
    }
    return 0;
}


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

#define INF (INT32_MAX / 2)

int main()
{
	int H, N;
	cin >> H >> N;
	vector<int> A( N );
	vector<int> B( N );
	for( int i = 0; i < N; i++ ) {
		cin >> A[i] >> B[i];
	}

	vector<int> dp( H + 10000 + 1, INF );
	dp[0] = 0;
	for( int i = 0; i <= H; i++ ) {
		for( int j = 0; j < N; j++ ) {
			dp[i + A[j]] = min( dp[i + A[j]], dp[i] + B[j] );
		}
	}
	int ans = INF;
	for( int i = H; i < dp.size(); i++ ) {
		ans = min( ans, dp[i] );
	}

	cout << ans << endl;
}


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

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(i, (v).size()) { cout << v[i]; if (i != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


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> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)///
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	while (1) {
		int n, t, l, b;
		cin >> n >> t >> l >> b;
		if (!n)break;
		vi v(n + 1, 0);
		REP(i, l) {
			int k;
			cin >> k;
			v[k] = 1;
		}
		REP(i, b) {
			int k;
			cin >> k;
			v[k] = -11;
		}
		vector<vector<double>> dp(t + 2, vector<double>(n + 1, 0));//dp[i][j]:i???????????????j????????????????¢????
		dp[0][0] = 1;
		REP(i, t) {
			REP(j, n) {
				FOR(k, 1, 7) {
					int c;
					if (j + k > n)  c = 2 * n - j - k;
					else c = j + k;
					if (v[c] == 0)dp[i + 1][c] += dp[i][j] / 6;
					else if (v[c] == 1)dp[i + 2][c] += dp[i][j] / 6;
					else dp[i + 1][0] += dp[i][j] / 6;
				}
			}
		}
		double sum = 0;
		REP(i, t + 1)sum += dp[i][n];
		cout << fixed << setprecision(12) << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 3392
using System;
class p
{
  static void Main()
  {
    string[] input = Console.ReadLine().Split(' ');
    int a = int.Parse(input[0]);
    int b = int.Parse(input[1]);
    int h = 0;
    for (int i = 1; i <= (b - a); i++) {
      h += i;
    }
    Console.WriteLine(h - b);
  }
}

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

int main(){
	int a,b,c,i,j,t,n,p=0,ar[200010];
	cin>>a;
	string s;
	cin>>s;
	if(a&1) printf("No\n");
	else{
		b=a/2;
		for(i=0;i<b;i++){
			if(s[i]!=s[i+b]) p=1;
		}
		if(p) printf("No\n");
		else printf("Yes\n");
	}

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>

using namespace std;

#define INF 1 << 29
#define LL long long int

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

    int n;
    cin >> n;
    vector<int> vec(n);

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

    int count = 0;

    for(int i = 0; i < n-1; i++){
        if(i+1 == vec[i]){
            int tmp = vec[i];
            vec[i] = vec[i+1];
            vec[i+1] = tmp;
            count++;
        }
    }

    if(n == vec[n-1]){
        count++;
    }

    cout << count << endl;
    
    return 0;
}

Measured memory_bytes: 640
n = int(input())
a = list(map(int,input().split()))

ans = []
a.sort()
low = a[0]
high = a[-1]
for i in a[1:-1]:
    if i>0:
        ans.append([low,i])
        low = low - i
    else:
        ans.append([high,i])
        high = high - i

ans.append([high,low])
print(high-low)
for x,y in ans:
    print('{0} {1}'.format(x,y))

Measured memory_bytes: 23664
# AGC016A - Shrinking
# exhaustive search
def main():
    S = input().rstrip()
    T = set(S)
    ans = float("inf")
    for t in T:
        cnt = 0
        x = S
        while len(set(x)) != 1:
            cnt += 1
            tmp = ""
            for i in range(len(x) - 1):
                tmp += t if x[i] == t else x[i + 1]
            x = tmp
        ans = min(ans, cnt)
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3064