akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)n; i++)
using ll = long long;

int main(){
  int n;
  cin >> n;
  vector<int> a;
  rep(i,1<<n) {
    int x;
    cin >> x;
    a.push_back(x);
  }
  while((int)a.size() > 1) {
    vector<int> b;
    for(int i = 0; i < a.size(); i += 2) {
      if(a[i] > a[i+1]) b.push_back(a[i]-a[i+1]);
      else if(a[i] == a[i+1]) b.push_back(a[i]);
      else b.push_back(a[i+1]-a[i]);
    }
    a = b;
  }
  cout << a[0] << endl;
  return 0;
}


Measured memory_bytes: 5372
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define show(x) cout << #x << " = " << (x) << endl;
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl;
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl;
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ');
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
//cout << fixed << setprecision(10);
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};

int main () {
  int h, w;
  cin >> h >> w;
  char s[25][25];
  rep(i,h)rep(j,w) cin >> s[i][j];

  auto f = [&](int sy, int sx, int gy, int gx) {
    int d[25][25];
    rep(i,25)rep(j,25) d[i][j] = INF;
    queue<pii> q;
    q.push(pii(sy,sx));
    d[sy][sx] = 0;
    while (!q.empty()) {
      int y, x;
      tie(y,x) = q.front(); q.pop();
      if (y == gy && x == gx) break;
      rep(i,4) {
        int ny = y + dy[i];
        int nx = x + dx[i];
        if (!(0<=ny && ny<h && 0<=nx && nx<w)) continue;
        if (s[ny][nx] == '#') continue;
        if (d[ny][nx] != INF) continue;
        q.push(pii(ny,nx));
        d[ny][nx] = d[y][x] + 1;
      }
    }
    return d[gy][gx];
  };
  
  int ans = 0;
  rep(sy,h)rep(sx,w) {
    rep(gy,h)rep(gx,w) {
      if (sy == gy && sx == gx) continue;
      if (s[sy][sx] == '#') continue;
      if (s[gy][gx] == '#') continue;
      ans = max(ans,f(sy, sx, gy, gx));
    }
  }

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

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

int main(){
  int n,q; string s; cin >> n >> q >> s;
  vector<int> x(n);
  for(int i=0;i<n-1;i++){
    if(i>0)
      x.at(i)=x.at(i-1);
    if(s.at(i)=='A'&&s.at(i+1)=='C')
      x.at(i)++;
  }
  for(int i=0;i<q;i++){
    int a,b; cin >> a >> b;
    if(a==1)cout << x.at(b-2) << endl;
    else cout << x.at(b-2)-x.at(a-2) << endl;
  }
}

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

int M,D;

int main() {
  cin>>M>>D;
  int ans = 0;

  for (int i = 1; i <= M; i++) {
    for (int j = 1; j <= D; j++) {
      if (j < 20) continue;
      if (j%10 < 2) continue;
      if ((j/10)*(j%10) == i) ans++;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def p_count(n):
    return bin(n)[2:].count('1')


n = int(input())
x = input().rstrip()
x_dec = int(x,base = 2)

pop_cnt = x.count('1')
pop_cnt_0 = (pop_cnt + 1)
pop_cnt_1 = (pop_cnt - 1)
x_0 = pow(x_dec,1,pop_cnt_0)
x_1 = pow(x_dec,1,pop_cnt_1) if pop_cnt_1 > 0 else 0

x_bit = [0]*n

for i in range(n-1,-1,-1):
    if x[i] == '0':
        x_bit[i] = (x_0 + pow(2,n-1-i,pop_cnt_0))%pop_cnt_0
        #x_bit[i] = (x_dec + pow(2,n-1-i))%pop_cnt_0
        
    else:
        if pop_cnt_1 > 0:
            x_bit[i] = (x_1 - pow(2,n-1-i,pop_cnt_1))
            x_bit[i] = x_bit[i] if x_bit[i] >= 0 else x_bit[i] + pop_cnt_1
        else:
            x_bit[i] = -1

anslist = []
for i in range(n):
    if x_bit[i] == -1:
        anslist.append(0)
        continue
    ans = 1 
    now = x_bit[i]
    while True:
        if now == 0:
            break
        now = now%p_count(now)
        
        ans += 1
    anslist.append(ans)


for ans in anslist:
    print(ans)






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

int main() {
  string s, t, u;
  int a, b;
  cin >> s >> t >> a >> b >> u;
  if (s == u) a--;
  else b--;
  cout << a << " " << b << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long N,K,H,sum=0;
  vector<long> hp; 
  cin >> N >> K;
  if(N <= K){
  	cout << 0 << endl;
  }else{
  for(int i = 0;i<N;i++){
  	cin >> H;
    hp.push_back(H);
  }
  sort(hp.begin(),hp.end());
  for(int i=0;i<K;i++){
  	hp.pop_back();
  }
  for(int a:hp){
    sum += a;
  }
  cout << sum << endl;
  }
}

Measured memory_bytes: 2420
problem_num, sub_num = map(int, input().split())
ac = 0
wa = 0
rem_ac = {}
rem_wa = {}
for _ in range(sub_num):
    problem, result = input().split()
    # すでに問題を提出していたら
    if problem in rem_ac.keys():
        # 1ならすでにACしている
        if rem_ac[problem] == 1:
            continue
        # ACしてないなら
        else:
            if result == 'WA':
                rem_wa[problem] += 1
                wa += 1
            else:
                ac += 1
                rem_ac[problem] = 1
    # 初めて提出するなら
    else:
        rem_ac[problem] = 0
        rem_wa[problem] = 0
        if result == 'WA':
            rem_wa[problem] += 1
            wa += 1
        else:
            ac += 1
            rem_ac[problem] = 1

for key, value in rem_ac.items():
    if value == 0:
        wa -= rem_wa[key]

print(ac, wa)


Measured memory_bytes: 23356
// May this submission get accepted!

#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) do { cerr << "[DEBUG] " #q ": ["; REP(i, (q).size()) { cerr << (q)[i] << (i == i_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; } while (false)
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
#define CHOKUDAI_ const
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using cll = DANCE_ DANCE_ CHOKUDAI_;
using  ld = long double;
using namespace std;

// モジュール
constexpr ll pdiv = 1000000007LL;

// 処理内容
int main() {
    
    ll n; cin >> n;
    vector<vector<ll>> g(n);
    REP(i, n-1) {
        ll x, y; cin >> x >> y;
        --x; --y;
        g[x].push_back(y);
        g[y].push_back(x);
    }

    vector<ll> rank; rank.reserve(n);
    vector<vector<ll>> kid(n);
    {
        vector<bool> visited(n, false);
        deque<ll> q;
        q.push_back(0);
        visited[0] = true;
        while (q.size()) {
            ll u = q.front(); q.pop_front();
            rank.push_back(u);
            for (ll v : g[u]) {
                if (!visited[v]) {
                    visited[v] = true;
                    kid[u].push_back(v);
                    q.push_back(v);
                }
            }
        }
    }
    std::reverse(ALL_OF(rank));
    
    // dp[i][j] := 頂点iを色j(0が白,1が黒)に塗ったときの部分木の色の組み合わせ
    vector<vector<ll>> dp(n, vector<ll>(2, 0));
    for (ll u : rank) {
        dp[u][0] = dp[u][1] = 1;
        for (ll v : kid[u]) {
            (dp[u][1] *= dp[v][0]) %= pdiv;
            (dp[u][0] *= (dp[v][0] + dp[v][1]) % pdiv) %= pdiv;
        }
    }
    cout << (dp[0][0] + dp[0][1]) % pdiv << endl;
    
}

Measured memory_bytes: 17408
while True:
    h, w = map(int, input().strip().split())
    if h == w == 0:
        break
    elif h > 2 and w > 2:
        print('#'*w+'\n'+('#'+'.'*(w-2)+'#\n')*(h-2)+'#'*w+'\n')
    else:
        print(('#' * w + '\n') * h)

Measured memory_bytes: 7548
#include <iostream>
#include <cmath>

using namespace std;

int main(){
  int x[4];
  int y[4];
  int l;
  cin>>x[0]>>y[0]>>x[1]>>y[1];

  x[3]=-(y[1]-y[0])+x[0];
  y[3]=(x[1]-x[0])+y[0];

  x[2]=(y[0]-y[1])+x[1];
  y[2]=-(x[0]-x[1])+y[1];

  for(int i=2;i<4;i++){
    cout<<x[i]<<" "<<y[i]<<" ";
  }
  cout <<endl;

  return 0;
}

  


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main implements Runnable {
    static ContestScanner in;
    static Writer out;
    public static void main(String[] args) {
        new Thread(null, new Main(), "", 16 * 1024 * 1024).start();
    }

    public void run() {
        Main main = new Main();
        try {
            in = new ContestScanner();
            out = new Writer();
            main.solve();
            out.close();
            in.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    void solve() throws IOException {
        long a = in.nextLong();
        long b = in.nextLong();
        if (a == b) {
            System.out.println(0);
        } else {
            long min = Math.min(a, b);
            long max = Math.max(a, b);
            if ((min + max) % 2 != 0) {
                System.out.println("IMPOSSIBLE");
            } else {
                System.out.println((min + max) / 2);
            }
        }
    }
}

class Writer extends PrintWriter{
    public Writer(String filename)throws IOException
    {super(new BufferedWriter(new FileWriter(filename)));}
    public Writer()throws IOException {super(System.out);}
}
class ContestScanner implements Closeable {
    private BufferedReader in;private int c=-2;
    public ContestScanner()throws IOException
    {in=new BufferedReader(new InputStreamReader(System.in));}
    public ContestScanner(String filename)throws IOException
    {in=new BufferedReader(new InputStreamReader(new FileInputStream(filename)));}
    public String nextToken()throws IOException {
        StringBuilder sb=new StringBuilder();
        while((c=in.read())!=-1&&Character.isWhitespace(c));
        while(c!=-1&&!Character.isWhitespace(c)){sb.append((char)c);c=in.read();}
        return sb.toString();
    }
    public String readLine()throws IOException{
        StringBuilder sb=new StringBuilder();if(c==-2)c=in.read();
        while(c!=-1&&c!='\n'&&c!='\r'){sb.append((char)c);c=in.read();}
        return sb.toString();
    }
    public long nextLong()throws IOException,NumberFormatException
    {return Long.parseLong(nextToken());}
    public int nextInt()throws NumberFormatException,IOException
    {return(int)nextLong();}
    public double nextDouble()throws NumberFormatException,IOException
    {return Double.parseDouble(nextToken());}
    public void close() throws IOException {in.close();}
}


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

#define int long long
#define x first
#define y second

int n, a, b;

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);

	cin >> n >> a >> b;
	cout << min(b, n * a) << endl;
}




















































Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<cassert>
#define llong long long
using namespace std;

const int N = 4e3;
const int P = 1e9+7;
llong dp[N+3][N+3],sdp[N+3][N+3];
int n1,n2,m,len;
llong ans;

int main()
{
	scanf("%d%d%d",&n1,&n2,&m); len = (n1+n2-1)/(m-1);
	dp[0][0] = 1ll; for(int j=0; j<=n2; j++) sdp[0][j] = 1;
	for(int i=1; i<=len; i++)
	{
		for(int j=0; j<=n2; j++)
		{
			if(j>=m) {dp[i][j] = (sdp[i-1][j]-sdp[i-1][j-m]+P)%P;}
			else {dp[i][j] = sdp[i-1][j];}
			if((n2-j)%(m-1)==0 && i*(m-1)-j<=n1-1 && (n1-1-i*(m-1)+j)%(m-1)==0) {ans = (ans+dp[i][j]-dp[i-1][j]+P)%P;}
		}
		sdp[i][0] = dp[i][0]; for(int j=1; j<=n2; j++) sdp[i][j] = (sdp[i][j-1]+dp[i][j])%P;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 239744
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from functools import lru_cache, reduce
from math import ceil, floor

import heapq
import itertools
import operator

from fractions import gcd


inf = float('inf')


def get_int():
    return int(input())


def get_str():
    return input().strip()


def get_list_of_int():
    return [int(i) for i in input().split()]


def get_char_list():
    return list(input().strip())


# inputs
A, B, K = 0, 0, 0


def set_inputs():
    global A, B, K
    A, B, K = get_list_of_int()
    x = gcd(A, B)
    y = []
    for i in range(1, x+1):
        if x % i == 0:
            y.append(i)
    print(y[-K])


def main():
    set_inputs()


if __name__ == '__main__':
    main()


Measured memory_bytes: 65132
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

ll gcd(ll a, ll b){//ユークリッドの互除法
  if (a < b) gcd(b,a); //aの方がbよりでかいのが前提
  if (b == 0) return a; //aをbで割り切れたらreturn
  else gcd(b, a % b);
}

const int INF = 1<<30;

int n;
int m;
vector<int> g[1005];

vector<int> bfs(int start){
  vector<int> dist(n,INF),pre(n,-1);
  queue<int> q;
  dist[start] = 0;
  q.push(start);
  
  while(!q.empty()){
    int from = q.front();q.pop();
    for(auto to:g[from]){
      if(dist[to] != INF) continue; //すでに到着済みならcontinue
      pre[to] = from;
      dist[to] = dist[from] + 1;
      q.push(to);
    }
  }
  
  pair<int,int> best(INF,-1);
  
  rep(i,n){
    if(i == start) continue;
    for(auto to:g[i]){
      if(to == start){
        best = min(best, make_pair(dist[i],i));
      }
    }
  }
  
  if(best.first == INF) return vector<int>(n+1);
  int from = best.second;
  
  vector<int> ret;
  while(from != -1){
    ret.push_back(from);
    from = pre[from];
  }
  
  return ret;
}

int main(){
  cin >> n >> m;
  rep(i,m){
    int a,b; cin >> a >> b;
    a--;b--;
    g[a].push_back(b);
  }
  
  vector<int> res(n+1);
  
  rep(i,n){
    auto tmp = bfs(i);
    if(res.size()>tmp.size()) res = tmp;
  }
  
  if(res.size() == n+1){
    cout << "-1" << endl;
    return 0;
  }
  
  cout << res.size() << endl;
  
  for(auto v:res){
    cout << v+1 << endl;
  }
  
  return 0;
}

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

#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define forn(i,n) for(ll i=0;i<n;i++)
#define fore(i,a,b) for(ll i=a;i<=b;i++)
#define ford(i,n) for(ll i=n-1;i>=0;i--)
#define fi first
#define se second
#define endl "\n"
#define all(a) a.begin(),a.end()
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PI 3.14159265

const ll maxn=2e5+1,mod=1e9+7;

void file(){
	#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif
}

int main(){

    sync
   // file();
    
    int n;
    cin>>n;
    int x = 0;
    forn(i,n){
    	int v;
    	cin>>v;
    	x^=v;
    }
    if(x==0){
    	cout<<"Yes";
    }
    else{
    	cout<<"No";
    }
    
}

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vll = vector<ll>;
template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

ll N, L, T;
ll X[100005], W[100005];
vll xp, xn;
ll ans[100005] = {};
int main() {
    cin >> N >> L >> T;
    for (int i = 0; i < N; i++) {
        cin >> X[i] >> W[i];
        (W[i] == 1 ? xp : xn).push_back(X[i]);
        (W[i] == 1 ? xp : xn).push_back(X[i] + L);
    }
    sort(begin(xp), end(xp));
    sort(begin(xn), end(xn));

    for (int i = 0; i < N; i++) {
        ll t = T * 2 % L;
        if (W[i] == 1) {
            ll num = lower_bound(begin(xn), end(xn), X[i] + t) - lower_bound(begin(xn), end(xn), X[i]);
            num += (T * 2 / L) * (xn.size() / 2);
            ans[(i + num) % N] = (X[i] + T) % L;
        } else {
            ll num = --upper_bound(begin(xp), end(xp), X[i] + L) - --upper_bound(begin(xp), end(xp), X[i] + L - t);
            num += (T * 2 / L) * (xp.size() / 2);
            ans[(i + N - num % N) % N] = (X[i] + L - T % L) % L;
        } 
    }
    for (int i = 0; i < N; i++) {
        cout << ans[i] << el;
    }
    return (0);
}


Measured memory_bytes: 5356
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
#include <queue>
//#include <bits/stdc++.h>

typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// print(x, y, z);
// print(va.begin(), va.end());
void print(){ std::cout << std::endl; }
template <typename Head> void print(Head&& head) { std::cout << head << std::endl; }
template <typename Head, typename... Tail> void print(Head&& head, Tail&&... tail)
{
  std::cout << head << " ";
  print(std::forward<Tail>(tail)...); // or print(tail...);
}
template<typename Iterator> void printVec(Iterator begin, Iterator end)
{
  for (Iterator it = begin; it != end; it++) {
    std::cout << "[" << std::distance(begin, it) << "] " << *it << " ";
    if (std::distance(begin, it) % 20 == 19) { std::cout << std::endl; }
  }
  std::cout << std::endl;
}

template<typename T> T lminimum(const std::vector< T >& v) {return *std::min_element(v.begin(), v.end());}
template<typename T> T lmaximum(const std::vector< T >& v) {return *std::max_element(v.begin(), v.end());}
template<typename T> void lunique(std::vector< T >& v) {v.erase(std::unique(v.begin(), v.end()), v.end());}
template<typename T> void lsort(std::vector< T >& v) {std::sort(v.begin(), v.end());}
template<typename T> void lgreatersort(std::vector< T >& v) {std::sort(v.begin(), v.end(), std::greater<>());}
template<typename T> bool lnext_permutation(std::vector< T >& v) {return std::next_permutation(v.begin(), v.end());}

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

  ll N, C, K;
  std::cin >> N >> C >> K;
  std::vector< ll > vt(N, 0LL);
  for (ll i = 0; i < N; i++) {
    std::cin >> vt[i];
  }

  std::sort(vt.begin(), vt.end());
  ll bus  = 1;
  ll cnt  = 1;
  ll time = vt[0];
  for (ll i = 1; i < N; i++) {
    cnt++;
    //print("   ", bus, "i:", i, "vt", vt[i], "human:", cnt, time);
    if (time == 0) {
      time = vt[i];
    }
    if (vt[i] > time + K) {
      //print("TIM", bus, "i:", i, "vt", vt[i], "human:", cnt, time);
      bus++;
      cnt = 1;
      time = vt[i];
      continue;
    }
    if (cnt > C) {
      //print("CNT", bus, "i:", i, "vt", vt[i], "human:", cnt, time);
      bus++;
      cnt = 1;
      time = vt[i];
      continue;
    }
  }

  print(bus);
  return 0;
}


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

#ifdef LOCAL
#define debug(var) cerr << #var << " = " << var << endl;
#else
#define debug(var)
#endif

void init() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
}

void solve() {
	int x, t; scanf("%d%d", &x, &t);
	printf("%d", max(x-t, 0));
}

int main() {
	init();
	int t = 1; //scanf("%d", &t);
	while (t--) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 256
s = input()
c = 0

for i in range(len(s)):
    if i % 2 == 0:
        if s[i] == "0":
            c += 1
    else:
        if s[i] == "1":
            c += 1
if len(s) - c < c:
    c = len(s) - c
print(c)

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

int main() {
  int N;
  cin >> N;
  
  vector<int> d(N);
  for (int i = 0; i < N; i++)
    cin >> d.at(i);
  
  int s = 0;
  for (int i = 0; i < N; i++)
    if (!d.at(i) == 0) {
      for (int j = 0; j < N; j++) {
      	if (i < j && d.at(i) == d.at(j)) {
          s++;
          d.at(j) = 0;
        }
      }
    }
   
  cout << N - s << endl;
}


Measured memory_bytes: 256
//ssenseeeeeeeeeeeeeeeeeeeeeeeeeeeee
#include<bits/stdc++.h>
using namespace std;
typedef long long  ll;
typedef unsigned long long ull;
#define MX 1000000000
#define endl '\n'
#define startt ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fr first
#define sc second
#define MOD 1000000007

int main()
{
    int x;
    cin >> x;
    if(x > 399 && x < 600)
    {
        cout << 8 << endl;
    }
    if(x > 599 && x < 800)
    {
        cout << 7 << endl;
    }
    if(x > 799 && x < 1000)
    {
        cout << 6 << endl;
    }
    if(x > 999 && x < 1200)
    {
        cout << 5 << endl;
    }
    if(x > 1199 && x < 1400)
    {
        cout << 4 << endl;
    }
    if(x > 1399 && x < 1600)
    {
        cout << 3 << endl;
    }
    if(x > 1599 && x < 1800)
    {
        cout << 2 << endl;
    }
    if(x > 1799 && x < 2000)
    {
        cout << 1 << endl;
    }
}


Measured memory_bytes: 3628
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
// #include<C:\Users\J\Desktop\AC\athead.h>
#define showa(v) for(int iii = 0; iii < v.size(); iii++){ cout << v[iii] << " ";} cout << endl;
#define show(iiii) cout << iiii << endl; 
#define shows(iiiii) cout << iiiii << " ";
#define divs 1000000007
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include <cmath>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <set>
#include <deque>
#include <numeric>
#include<tuple>
#include <utility>
#include <map>
using namespace std;

int saiki(int n, vector<long long int> &memo){
    // showa(memo)
    long long int res = 0;
    if (memo[n] == -1){
        res += ((saiki(n-1, memo))+(saiki(n-2, memo)));
        memo[n] = res%divs;
        return memo[n];
    }
    else{
        return memo[n];
    }
}

int main(){
    int n, k, q;
    cin >> n >> k >> q;
    vector<int> a(q);
    vector<int> sc(n);
    vector<string> yn(n);
  
  if((q-k) < 0){
    rep(i,n){
      cout << "Yes" << endl;
    }
    return 0;
  }
    rep(i,n){
        sc[i] = 0;
        yn[i] = "No";
    }

    rep(i,q){
        cin >> a[i];
        sc[a[i]-1]++;
        if(sc[a[i]-1] > (q-k)){
            yn[a[i]-1] = "Yes";
        }
    }

    rep(i,n){
        cout << yn[i] << endl;
    }
}


Measured memory_bytes: 6784
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int Dy[8] = {-1,-1,0,1,1,1,0,-1};
int Dx[8] = {0,1,1,1,0,-1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int h,w,a,b;
    cin>>h>>w>>a>>b;
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            if(i<=b&&j<=a)cout<<1;
            else if(j<=a)cout<<0;
            else if(i<=b)cout<<0;
            else cout<<1;
        }
        cout<<endl;
    }
}

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

int main(){
    int a,b;
    cin >> a >> b;
    int ans = -1;
    rep(i,max(a,b)){
        if(abs(a-i)==abs(b-i)){
            ans=i;
        }
    }
    if(ans != -1){
        cout << ans << endl;
    }
    else{

        cout << "IMPOSSIBLE" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <list>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <algorithm>

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define MOD 1000000007

typedef long long ll;

using namespace std;

string grouping(int x){
	string group;
	if (x == 1 || x == 3 || x == 5 || x == 7 || x == 8 || x == 10 || x == 12)
	{
		group = "A";
	}
	else if (x == 4 || x == 6 || x == 9 || x == 11)
	{
		group = "B";
	}
	else if (x == 2)
	{
		group = "C";
	}

	return group;
}
int main(){
    int x, y;
    string ans;
    cin >> x >> y;
    if (grouping(x) == grouping(y)) ans = "Yes";
    else ans = "No";

    cout << ans << endl;
}


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 n=sc.nextInt();
		int a[]=new int[n];
		for(int i=0;i<n;i++) {
			a[i]=sc.nextInt();
		}
		boolean f=true;
		for(int i=n-1;i>0;i--) {
			if(a[i-1]-a[i]>=2) {
				f=false;
			}else if(a[i-1]-a[i]==1) {
				a[i-1]--;
			}
		}
		if(f)
		    System.out.print("Yes");
		else
			System.out.print("No");

	}

}

Measured memory_bytes: 50164
s = int(input())
a = []
a.append(s)
flag = True
i = 1
while flag == True:
	if(a[i-1] % 2 == 0):
		a.append(a[i-1] / 2)
	else:
		a.append(3 * a[i-1] + 1)
	if(len(a) != len(set(a))):
		flag = False
	i+=1
print(i)

Measured memory_bytes: 3060
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		int a = in.nextInt();
		int b= in.nextInt();
		if(a<b){
			System.out.println("a < b");
		}
		else if(a>b){
			System.out.println("a > b");
		}
		else {
			System.out.println("a == b");
		}
	}
}

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

#define rep(X,N) for(ll X = 0LL; X < (N); X++)
#define PI (acos(-1.0))
#define MODN 1000000007
#define MODN2 998244353
#define ALL(V) (V).begin(),(V).end()
#define INT_MAX_HALF (INT_MAX / 2)
#define EPS (1e-10)

using namespace std;
typedef long long ll;

int main(){

    int n;
    cin >> n;

    vector<ll> a(n);

    rep(i, n){
        cin >> a[i];
    }

    sort(ALL(a));

    vector<ll> acc(n);
    acc[0] = a[0];

    for(int i = 1; i < n; i++){
        acc[i] = acc[i - 1] + a[i];
    }

    vector<bool> able(n, false);
    able[n - 1] = true;

    rep(i, n - 1){
        if(a[i + 1] <= acc[i] * 2){
            able[i] = true;
        }
    }

    int ans = 0;

    for(int i = n - 1; i >= 0; i--){
        if(able[i]){
            ans++;
        }else{
            break;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	// your code goes here
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int x=ceil((double)c/b);
	int y=ceil((double)a/d);
	if(x<=y)
	cout<<"Yes"<<endl;
	else
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 3632
#pragma GCC optimize(2)
#include <bits/stdc++.h>
using namespace std;
bool compare(int a, int b)
{
	return a > b;
}
int a[100001];
int main()
{
	int n, cnt1 = 0, cnt2 = 0;
	scanf("%d", &n);
	for(int i=1; i<=n; i++)
		scanf("%d", &a[i]);
	sort(a+1, a+n+1, compare);
	for(int i=1; i<=n; i++)
		i%2 ? cnt1+=a[i] : cnt2+=a[i];
	printf("%d", abs(cnt1 - cnt2) );
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front
#define ll long long

ll arr[100005];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll x,n,q,sum=0,a,b;
   // vector <ll> arr(100005);
    cin>>n;
    
    for(int i=0; i<n; i++){
        cin>>x;
        sum += x;
        arr[x]++;
    }

    cin>>q;
    while(q--){
        cin>>a>>b;
        sum -= (a*arr[a]);
        sum += (b*arr[a]);
        arr[b] += arr[a];
        arr[a] = 0;

        cout << sum << "\n";
    }
    
    return 0;
}

Measured memory_bytes: 4412
import sys
from itertools import combinations
def input(): return sys.stdin.readline().strip()


def main():
    n = int(input())
    d = {'M': 0, 'A': 0, 'R': 0, 'C': 0, 'H': 0}
    for _ in range(n):
        c = input()
        if c[0] in d: d[c[0]] += 1
    #print(d)
    ans = 0
    for a, b, c in combinations(['M', 'A', 'R', 'C', 'H'], 3):
        ans += d[a] * d[b] * d[c]
    print(ans)

if __name__ == "__main__":
    main()


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

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

int main(){ 

int n,x;
cin >> n >> x;

int L[100];
int D[100];

rep(i, n-1){
	cin >> L[i];
}

rep(i,n){ 
	D[1] = 0;
	D[i]= D[i-1]+L[i-1];
}

int ans = 0;
rep(i,n){
	if(D[i] <= x) ans++;
}

cout << ans << endl;

return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define int long long
#define endl '\n'
using namespace std;
 
typedef long long ll;
#define db(x) cerr << #x << ": " << x << '\n';
#define read(a) int a; cin >> a;
#define reads(s) string s; cin >> s;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define readarr(a, n) int a[(n) + 1] = {}; FOR(i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}

#define print(a) cout << a << endl;
#define printarr(a, n) FOR (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) FOR (i, 1, n) {FOR (j, 1, m) cout << a[i][j] << " "; cout << endl;}
#define all(v) v.begin(), v.end()
#define sz(v) (int)(v.size())
#define rz(v, n) v.resize((n) + 1);
#define ld long double
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define vpi vector <pi>
#define vvi vector <vi>
#define setprec cout << fixed << showpoint << setprecision(20);
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ll N = 2e5 + 1;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int f(int x)
{
    int i = 0, cur = 0;
    while (cur <= x)
    {
        cur += i;
        i++;
    }
    
    return i - 2;
}

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	read(n);
	int sqr = sqrt(n);
	
	map <int, int> mp;
	FOR (i, 2, sqr)
	{
    	while (n % i == 0) mp[i]++, n /= i;
	}
	
	if (n > 1) mp[n]++;
	
	int cnt = 0;
	for (pi i: mp)
	{
	    cnt += f(i.se);
	}
	
	print(cnt);
	//FOR (i, 1, 20) cout << i << ": " << f(i) << endl;
}



















Measured memory_bytes: 3680
import java.util.*;
import java.lang.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = n / 1000;
        int b = (n - a * 1000) / 100;
        int c = (n - a * 1000 - b * 100) / 10;
        int d = n - a * 1000 - b * 100 - c * 10;
        if (a + b + c + d == 7) {
            System.out.println(a + "+" + b + "+" + c + "+" + d + "=7");
        } else if (a + b + c - d == 7) {
            System.out.println(a + "+" + b + "+" + c + "-" + d + "=7");
        } else if (a + b - c + d == 7) {
            System.out.println(a + "+" + b + "-" + c + "+" + d + "=7");
        } else if (a + b - c - d == 7) {
            System.out.println(a + "+" + b + "-" + c + "-" + d + "=7");
        } else if (a - b + c + d == 7) {
            System.out.println(a + "-" + b + "+" + c + "+" + d + "=7");
        } else if (a - b + c - d == 7) {
            System.out.println(a + "-" + b + "+" + c + "-" + d + "=7");
        } else if (a - b - c + d == 7) {
            System.out.println(a + "-" + b + "-" + c + "+" + d + "=7");
        } else if (a - b - c - d == 7) {
            System.out.println(a + "-" + b + "-" + c + "-" + d + "=7");
        }
    }
}

Measured memory_bytes: 23764
import java.util.Scanner;
class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n=sc.nextInt();
int m=sc.nextInt();
int c=sc.nextInt();
int b[] = new int[m];
for(int i=0; i<m; i++){
b[i]=sc.nextInt();
}
int a[][]=new int[n][m];
for(int i=0; i<n; i++){
for(int j=0; j<m; j++){
a[i][j]=sc.nextInt();
}}
int sum =0;
int total=0;
for(int i=0; i<n; i++){
for(int j=0; j<m; j++){
sum=sum+a[i][j]*b[j];
}
if (sum+c>0)
total++;
sum=0;
}
System.out.println(total);
}}


Measured memory_bytes: 23892
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

int main(void)
{
    int a, b, k;
    cin >> a >> b >> k;
    int cnt = 0;
    for (int i = min(a, b); i >= 1; i--)
    {
        if (a % i == 0 && b % i == 0)
        {
            cnt++;
        }
        if (cnt == k)
        {
            cout << i << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int N, M, X;
    scanf("%d %d %d", &N, &M, &X);
    int a[N];
    for (int i = 0; i < M; i++)
    {
        scanf("%d", &a[i]);
    }
    int mae = 0, ushiro = 0;
    int now = 0;
    for (int i = 0; i < N && now < M; i++)
    {
        if (a[now] != i) {
            continue;
        }
        if (i < X) {
            mae++;
        }
        else
        {
            ushiro++;
        }
        now++;
    }
    if (mae < ushiro){
        printf("%i",mae);
    }
    else
    {
        printf("%i", ushiro);
    }
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define range(i, l, r) for(long long int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (long long int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

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

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    if (v.size() == 0) return os << "]";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    os << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        os << ", " << *it;
    }
    return os << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    os << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        os << ", " << *it;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    os << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        os << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    os << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        os << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    string S, T; cin >> S >> T;
    lint A, B; cin >> A >> B;
    string U; cin >> U;
    if (S == U) A--;
    else B--;
    cout << A << " " << B << "\n";
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)

	sc.Scan()
	num, _ := strconv.Atoi(strings.Split(sc.Text(), " ")[0])
	lists := make([][]string, num)

	for sc.Scan() {
		inputs := strings.Split(sc.Text(), " ")
		num, _ := strconv.Atoi(inputs[1])

		if inputs[0] == "0" {
			lists[num] = append(lists[num], inputs[2])
		} else if inputs[0] == "1" {
			fmt.Printf("%s\n", strings.Join(lists[num], " "))
		} else if inputs[0] == "2" {
			lists[num] = []string{}
		}
	}
}



Measured memory_bytes: 44196
#include<bits/stdc++.h>
#define rep(i,k,n) for(int i=k;i<=n;i++)
#define rep2(i,k,n) for(int i=k;i>=n;i--)
using namespace std;
const int N=1e5+7;
const double eps=1e-8;
int n,a[N];
int main(){
	scanf("%d",&n);
	double S=0;
	rep(i,0,n-1){
		scanf("%d",&a[i]);
		S+=a[i];
	}
	S/=n;
	double mi=10000000.0;
	int ans=0;
	rep(i,0,n-1){
		if(fabs(a[i]-S) + eps <= mi){
			mi=fabs(a[i]-S);
			ans=i;
		}
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int A,B,C,X,Y;
  int ans=0;
  cin>>A>>B>>C>>X>>Y;
  int big=max(X,Y);
  int sma=min(X,Y);
  if(A+B>2*C && X>Y)
  {
    if(2*C*sma+A*(X-Y)<=2*C*big)
    {
    ans=2*C*sma+A*(X-Y);
  }else{
    ans=2*C*big;
  }
  }
  if(A+B>2*C && X<=Y)
  {
    if(ans=2*C*sma+B*(Y-X)<=2*C*big)
    {
    ans=2*C*sma+B*(Y-X);
  }else{
    ans=2*C*big;
  }
  }
  if(A+B<=2*C)
  {
    ans=A*X+B*Y;
  }
  cout<<ans<<endl;
  return 0;

}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
use std::io::*;
use std::str::FromStr;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

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

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);

impl<T: PartialEq> Eq for Total<T> {}

impl<T: PartialOrd> Ord for Total<T> {
    fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering {
        self.0.partial_cmp(&other.0).unwrap()
    }
}

//const MAX:usize = 100006;
//const INF:u64 = u64::max_value();

fn main() {
    let s:i32 = read();

    let mut map = HashMap::new();
    map.insert(s, true);
    let mut a:i32 = s;
    for i in 2..1000000 {
        if a%2==0 {
            let k:i32 = a/2;
            if map.contains_key(&k) {
                println!("{}", i);
                return ();
            }
            //debug!(i,a/2);
            map.insert(a/2,true);
            a = a/2;
        } else {
            let k:i32 = 3*a+1;
            if map.contains_key(&k) {
                println!("{}", i);
                return ();
            }
            //debug!(i,3*a+1);
            map.insert(3*a+1, true);
            a = 3*a+1;
        }
    }
}


Measured memory_bytes: 4352
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = (1e+9) + 7;
const ll INF = (ll)1000000007 * 1000000007;
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++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int dp[500001][4];
int main() {
	int n; string s; cin >> n >> s;
	if (n <= 2) {
		cout << 0 << endl; return 0;
	}
	int out = 0;
	vector<int> v;
	int cnt = 0;
	rep(i, n) {
		if (s[i] == '1') {
			cnt = 0;
			int chk = i;
			while (i + 1 < n&&s[i + 1] == '1')i++;
			v.push_back(i - chk + 1);
		}
		else {
			if (cnt == 0)cnt++;
			else {
				int len = v.size();
				if (len > 1) {
					rep(k, len + 1) {
						rep(j, 4) {
							dp[k][j] = 0;
						}
					}
					Rep(j, 1, len) {
						if (v[j] == 1) {
							dp[j][0] = dp[j - 1][3] + v[j];
							dp[j][1] = max(dp[j - 1][2] + v[j - 1], dp[j - 1][1] + v[j - 1] - 1);
							dp[j][2] = max({ dp[j - 1][0],dp[j - 1][1],dp[j - 1][2] });
							dp[j][3] = dp[j][2];
						}
						else {
							dp[j][0] = dp[j - 1][3] + v[j];
							dp[j][1] = max(dp[j - 1][2] + v[j - 1], dp[j - 1][1] + v[j - 1] - 1);
							dp[j][2] = max({ dp[j - 1][0],dp[j - 1][1],dp[j - 1][2] });
							dp[j][3] = max({ dp[j][0] - 1,dp[j][1], dp[j][2] });
						}
					}
					out += max({ dp[len-1][0],dp[len-1][1],dp[len - 1][2] });
				}
				v.clear();
			}
		}
	}
	int len = v.size();
	if (len > 1) {
		rep(k, len + 1) {
			rep(j, 4) {
				dp[k][j] = 0;
			}
		}
		Rep(j, 1, len) {
			if (v[j] == 1) {
				dp[j][0] = dp[j - 1][3] + v[j];
				dp[j][1] = max(dp[j - 1][2] + v[j - 1], dp[j - 1][1] + v[j - 1] - 1);
				dp[j][2] = max({ dp[j - 1][0],dp[j - 1][1],dp[j - 1][2] });
				dp[j][3] = dp[j][2];
			}
			else {
				dp[j][0] = dp[j - 1][3] + v[j];
				dp[j][1] = max(dp[j - 1][2] + v[j - 1], dp[j - 1][1] + v[j - 1] - 1);
				dp[j][2] = max({ dp[j - 1][0],dp[j - 1][1],dp[j - 1][2] });
				dp[j][3] = max({ dp[j][0] - 1,dp[j][1], dp[j][2] });
			}
		}
		out += max({ dp[len - 1][0],dp[len - 1][1],dp[len - 1][2] });
	}
	cout << out << endl;
	return 0;
}

Measured memory_bytes: 900
#include <bits/stdc++.h>
using namespace std;
int n;
string s;
int main(){
	cin>>n;
	cin>>s;
	if(n>=3200)
		cout<<s;
	else
		cout<<"red";
	return 0;
}
/*
模拟只会猜题意
贪心只能过样例
数学上来先打表
DP一般看规律
组合数学靠运气
计算几何瞎暴力
图论强行套模板
数论只会GCD
递归递推伤不起
搜索茫然TLE
分治做得像枚举
暴力枚举数第一
数据结构干瞪眼
怒刷水题找信心
涨姿势也不容易
考试一来全懵逼
*/

Measured memory_bytes: 256
use std::io::{BufRead, Write};

fn main () {
    let stdin = std::io::stdin();
    let stdout = std::io::stdout();
    let mut reader = std::io::BufReader::new(stdin.lock());
    let mut writer = std::io::BufWriter::new(stdout.lock());

    let (n, k, c): (usize, usize, usize) = {
        let mut buf = String::new();
        reader.read_line(&mut buf).unwrap();
        let mut iter = buf.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
        )
    };

    let s: Vec<char> = {
        let mut buf = String::new();
        reader.read_line(&mut buf).unwrap();
        buf.trim_end().chars().collect()
    };

    let mut left = vec![0; k];
    let (mut li, mut lj) = (0, 0);
    while li < n && lj < k {
        if s[li] == 'o' {
            left[lj] = li;
            li += c;
            lj += 1;
        }
        li += 1;
    }

    let mut right = vec![0; k];
    let (mut ri, mut rj) = (0, 0);
    while ri < n && rj < k {
        if s[n - 1 - ri] == 'o' {
            right[k - 1 - rj] = n - 1 - ri;
            ri += c;
            rj += 1;
        }
        ri += 1;
    }

    for i in 0..k {
        if left[i] == right[i] {
            writeln!(writer, "{}", left[i] + 1).unwrap();
        }
    }
}

Measured memory_bytes: 5788
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader stdIn = new BufferedReader(new InputStreamReader(System.in));
		String s;
		int inCnt = 0;
		while ((s = stdIn.readLine()) != null) {
			inCnt++;
			String[] se = s.split(" ");
			int h = Integer.valueOf(se[0]);
			int w = Integer.valueOf(se[1]);
			if (h == 0 && w == 0)
				break;
			doMain(inCnt, h, w);
		}
		System.exit(0);
	}

	private static void doMain(int inCnt, int h, int w) {
		String p = "";
		for (int i = 0; i < w; i++)
			p = p.concat("#");
		for (int i = 0; i < h; i++)
			System.out.println(p);
		System.out.println("");
	}
}

Measured memory_bytes: 25472
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;
 
#define rep(i,a,b) for(int i=a;i<b;++i)
#define per(i,a,b) for(int i=b-1;i>=a;--i)
#define pb push_back
typedef long long ll;
 
/////////
int const N = 19;
ll cnt = 0;
 
int dig[N], dif[N];
int n, m, d, len;
 
bool check(){
	ll n = 0;
	ll mn = 1;
	rep(i, 0, len){
		n += dig[i] * mn;
		mn *= 10;
	}
	ll revn = 0;
	mn = 1;
	per(i,0,len){
		revn += mn * dig[i];
		mn *= 10;
	}
	return (n - revn == d);
}
 
map<vector<int>, ll> mem;
 
ll rec(int addL, int subR, int r, int l){
	//++cnt;
	//if(cnt % (1000 * 1000) == 0) cerr << cnt << endl;
	if(l > r) return check();
	ll ret = 0;
	if(l == r){
		rep(i, 0, 10){
			dig[l] = i;
			ret += check();
		}
		return ret;
	}
	vector<int> curState;
	curState.pb(addL);
	curState.pb(subR);
	curState.pb(r);
	curState.pb(l);
	if(mem.find(curState) != mem.end()) return mem[curState];
	rep(ld, 0, 10){
		rep(rd, 0, 10){
			if(l == 0 && (ld == 0 || rd == 0)) continue;
			dig[l] = ld;
			dig[r] = rd;
			if(ld - rd == dif[l] + addL){
				if(subR){
					if(rd + 10 - ld == dif[r]) ret += rec(0, 0, r-1, l+1);
					if(rd + 10 - ld == dif[r] + 1) ret += rec(0, 1, r-1, l+1);
				}else{
					if(rd - ld == dif[r]) ret += rec(0, 0, r-1, l+1);
					if(rd - ld == dif[r] + 1) ret += rec(0, 1, r-1, l+1);
				}
			}
			if(ld + 10 - rd == dif[l] + addL){
				if(subR){
					if(rd + 10 - ld == dif[r]) ret += rec(1, 0, r-1, l+1);
					if(rd + 10 - ld == dif[r] + 1) ret += rec(1, 1, r-1, l+1);
				}else{
					if(rd - ld == dif[r]) ret += rec(1, 0, r-1, l+1);
					if(rd - ld == dif[r] + 1) ret += rec(1, 1, r-1, l+1);
				}
			}
		}
	}
 
	return mem[curState] = ret;
}
 
 
void solve(){
	int di;
	cin >> di;
	d = di;
	while(di){
		dif[m++] = di % 10;
		di /= 10;
	}
 
	ll ans = 0;
	rep(i, 2, N){
		len = i;
		mem.clear();
		ans += rec(0, 0, i-1, 0);
	}
	cout << ans << endl;
	//cout << "cnt = " << cnt << endl;
}
 
int main(){
#ifdef _DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
 
	solve();
 
	return 0;
}

Measured memory_bytes: 256