akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

queue<pair<int, int>> q; //first int distance, second int current node location

int dist[200005];

vector<int> g[200005];

int main()
{

    int n, m;

    cin >> n >> m;

    for (int i = 0; i < m; i++)
    {
        int a, b;
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    memset(dist, -1, sizeof(dist)); // works only for 0 or -1

    int start = 1;
    q.push(make_pair(0, start));

    while (!q.empty())
    {
        int d = q.front().first, u = q.front().second;

        q.pop();

        if (dist[u] != -1)
        {
            continue;
        }

        dist[u] = d;

        for (int i = 0; i < g[u].size(); i++)
        {
            q.push(make_pair(d + 1, g[u][i]));
        }
    }

    int fdist = dist[n];

    if (fdist == 2)
    {
        cout << "POSSIBLE";
    }
    else
    {
        cout << "IMPOSSIBLE";
    }

    return 0;
}

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

int n, cnt = 1;

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		int b;
		cin >> b;
		if(b == cnt) cnt++;
	}
	if(cnt == 1) cnt = n + 2;
	cout << n - cnt + 1;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
int main() {
    int H, W, A, B;
    cin >> H >> W >> A >> B;

    for (int i=0; i<H; i++) {
        for (int j=0; j<W; j++) {
            if (i < H-B) {
                if (j < A) cout << 0;
                else cout << 1;
            } else {
                if (j < A) cout << 1;
                else cout << 0;
            }
        }
        cout << endl;
    }

    return 0;
}



Measured memory_bytes: 1280
import java.util.*;

public class Main {

    public static void main(String[] args) {
        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();
        }
        Arrays.sort(a);
        boolean flag = true;
//        long res = 0;

        if (n % 2 == 0) {
            for (int i = 0; i < n; i += 2) {
                if (a[i] != a[i + 1]) {
                    flag = false;
                    break;
                }
            }

        } else {
            for (int i = 1; i < n; i += 2) {
                if (a[i] != a[i + 1]) {
                    flag = false;
                    break;
                }
            }
            if (a[0] != 0) {
                flag = false;
            }

        }

        if (flag) {
            long res = 1;
            for (int x=0; x<n/2; x++) { 
                res = 2*res%1000000007; 
            }
//            res = (long) Math.pow(2, n / 2);
            System.out.println(res);
        }else{
            System.out.println(0);
        }

//        res %= 1000000007;


    }

}


Measured memory_bytes: 52152
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcdEx(ll a, ll b, ll *x, ll *y) {
    if (!a) {*x = 0; *y = 1; return b;}
    ll x1, y1, gcd = gcdEx(b % a, a, &x1, &y1); *x = y1 - (b / a) * x1; *y = x1; return gcd;
}
ll modI(ll b, ll m)      {ll x, y; gcdEx(b, m, &x, &y); return (x % m + m) % m;}
typedef pair<ll, ll>      pii;
typedef vector<ll>         vi;
typedef vector<pii>         vii;
typedef set<ll>            si;
typedef map<string, ll>    msi;
#define all(x) (x).begin(), (x).end()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
#define loop(i,b,n)           for(ll i=b;i<n;i++)
#define loopv(i,b,n,a)         for(ll i=b;i<n;i+=a)
#define loopr(i,b,n)           for(ll i=n;i>=0;i--)

#define sum(a)     ( accumulate ((a).begin(), (a).end(), 0ll))
#define mine(a)    (*min_element((a).begin(), (a).end()))
#define maxe(a)    (*max_element((a).begin(), (a).end()))
#define mini(a)    ( min_element((a).begin(), (a).end()) - (a).begin())
#define maxi(a)    ( max_element((a).begin(), (a).end()) - (a).begin())
#define lowb(a, x) ( lower_bound((a).begin(), (a).end(), (x)) - (a).begin())
#define uppb(a, x) ( upper_bound((a).begin(), (a).end(), (x)) - (a).begin())

#define start_routine() ll begtime = clock();
#define end_routine() ll endtime = clock(); \
                      cerr << "\n\n" << "Time elapsed: " << \
                      (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n"; \
                      return 0
#define mp                  make_pair
#define ff                  first
#define ss                  second
#define pb                  push_back
#define MOD                 1000000007
#define modA(a,b)           (((a%MOD)+(b%MOD))%MOD)
#define modS(a,b)           (((((a%MOD)-(b%MOD))%MOD)<0)?(ll)(MOD+((a%MOD)-(b%MOD))%MOD):(ll)(((a%MOD)-(b%MOD))%MOD))
#define modM(a,b)           (ll)((((ll)(a%MOD))*((ll)(b%MOD)))%MOD)
#define modD(a,b)           ((modI(b,MOD)*(a%MOD))%MOD)
ll modP(ll x, ll y)         {
    ll r = 1; x %= MOD; while (y > 0) {
        if (y & 1) {r = (r * x) % MOD;}
        y = y >> 1; x = (x * x) % MOD;
    } return r;
}
ll max(ll a, ll b) {return (a > b ? a : b);}
ll min(ll a, ll b) {return (a < b ? a : b);}
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << '\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cout.write(names, comma - names) << " = " << arg1 << " | "; __f(comma + 1, args...);
}
ll gcd( ll a, ll b )
{
    if (b == 0)
    {
        return a;
    }
    else
    {
        return gcd( b, (a % b) );
    }
}
ll lcm (ll a, ll b)
{
    ll ans = (a  / gcd(a, b)) * b;
    return ans;
}

#define test int t;cin >>t;while(t--)
int main()
{

    ll k;
    string s;
    cin >> k >> s;
    if (k >= s.size())
    {
        cout << s;
    }
    else
    {

        for (int i = 0; i < k; i++)
            cout << s[i];
        ll n = s.size();
      cout << "...";

    }
}

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

int main() {
    int W, H;
    cin >> W >> H;
    vector<long long int> p(W), q(H);
    for (auto& i : p) cin >> i;
    for (auto& i : q) cin >> i;

    p.push_back(1e12);
    q.push_back(1e12);

    sort(p.begin(), p.end());
    sort(q.begin(), q.end());

    long long int sum = 0LL;
    for (int i = 0, r = 0, l = 0, sr = H+1, sl = W+1; i < W + H; i++) {
        if (p[r] <= q[l]) {
            sum += 1LL * (long long int)sr * p[r];
            r++;
            sl--;
        } else {
            sum += 1LL * (long long int)sl * q[l];
            l++;
            sr--;
        }
    }

    cout << sum << endl;

    return 0;
}


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

int main(){

    long x;
    cin >> x;
    int i = 0;
    long base = 100;
    while(1){
        base += base*0.01;
        i++;
        if(base >= x){
            cout << i << endl;
            break;
        }
        
    }
    return 0;
}

Measured memory_bytes: 3612
//#include <bits/stdc++.h>                          //include all library  
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <sstream>
#include <vector>
#include <stack>
#include <string.h>
#include <functional> // greater<int> はfunctionalヘッダ
using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)          //REP(i, 10){...} //i=0～i=9までのループ
#define REPR(i, n) for(int i = n;i >= 0;i--)        //REPR(i, 10){...} //i=10～i=0までのループ
#define FOR(i, m, n) for(int i = m;i < n;i++)       //FOR(i, 3, 10){...} //i=3～i=9までのループ
#define FORR(i, m, n) for(int i = m;i >= n;i--)     //FORR(i, 10, 3){...} //i=10～i=3までのループ
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
#define PI 3.141592653589
#define npos -1

int main()
{
  int n;
  cin >> n;
  if(n%10 == 9 or n/10 == 9) cout << "Yes";
  else cout << "No";
  cout << endl;
}

Measured memory_bytes: 256
#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; 
typedef short int si;
typedef long long int ll;
typedef long int li;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<li,li> pli;
typedef pair<ll,ll> pll;
#define Max 1000001
#define inf INT_MAX
#define linf LONG_MAX 
#define llinf LONG_LONG_MAX
#define rep(i,a,b) for(i=a;i<=b;i++)
#define rrep(i,a,b) for(i=a;i>=b;i--)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define pb push_back
#define pf push_front
#define rb pop_back
#define rf pop_front
#define mkp make_pair
#define F first
#define S second
#define ub upper_bound
#define lb lower_bound
#define all(v) v.begin(),v.end()
#define endl '\n'
const ll N=11;
ll mod=1e9+7;
signed main()
{
    fast;
    ll pro=1,temp,n,m,k,t,i,j,l,r,mid,x,y,z,rem,carry=0,ind,ans=0,mx=-llinf,mn=llinf,cnt=0,curr=0,prev,sum=0,flag=0,i1=-1,i2=-1;
    multiset<ll,greater<ll>> ms;
    cin>>n;
    ll a[n];
    rep(i,0,n-1)
    {
        cin>>a[i];
        ms.insert(a[i]);
    }
    rep(i,0,n-1)
    {
        ms.erase(ms.find(a[i]));
        cout<<*(ms.begin())<<endl;
        ms.insert(a[i]);
    }
    return 0;
} 
 

Measured memory_bytes: 12544
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
      int a=0,b1=0,b2=0,b3=0;
      cin >> a ;
      b1=a/100;
      b2=(a%100)/10;
      b3=(a%100)%10;
      cout << b1+b2+b3 << endl;
    }

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;


ll dp[110][10]; // 上からhの時にxにいる場合の数

int main(){
    int h, w, k;
    cin >> h >> w >> k;
    dp[0][0] = 1;

    rep(i, h){
        rep(j, w){ // dp[i][j]を配る
            ll x=0, y=0, z=0;
            for(int bits = 0; bits < (1<<(w-1)); bits++){ // bits<<i : iとi+1に橋が繋がっている
                bool flag = true;
                rep(m, w-2) if ((bits&(1<<m)) && (bits&(1<<(m+1)))) flag = false;
                if (!flag) continue;

                if (j == 0){
                    if (bits&(1<<j)) x++;
                    else y++;
                }
                else if (j == w - 1){
                    if (bits&(1<<(j-1))) z++;
                    else y++;
                }
                else {
                    if (bits&(1<<j)) x++;
                    else if (bits&(1<<(j-1))) z++;
                    else y++;
                }
            }
            if (j < w-1){
                dp[i+1][j+1] += x * dp[i][j];
                dp[i+1][j+1] %= MOD;
            }
            if (0 < j){
                dp[i+1][j-1] += z * dp[i][j];
                dp[i+1][j-1] %= MOD;
            }
            dp[i+1][j] += y * dp[i][j];
            dp[i+1][j] %= MOD;
        }
    }

    cout << dp[h][k-1] << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int s[10005],t[10005];
    int n,q;
    cin>>n;
    for(int i=0;i<n;i++) cin>>s[i];
    cin>>q;
    for(int i=0;i<q;i++) cin>>t[i];
    int ans=0;
    for(int i=0;i<q;i++){
        int tmp=t[i];
        for(int j=0;j<n;j++){
            if(tmp==s[j]){
                ans++;
                break;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 3100
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H):
    '''
    H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right

# https://atcoder.jp/contests/arc086/tasks/arc086_a
N, K = read_ints()
A = read_ints()
# 個数をカウント ソート、sum
cnt = Counter(A)
v = sorted(cnt.values(), reverse=True)
if len(v) <= K:
    print(0)
else:
    print(N - sum(v[:K]))


Measured memory_bytes: 93520
#include <iostream>
#include<iomanip>
#include <set>
#include <vector>
#include <map>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <queue>
#include <stack>
using namespace std;

const int NN=2e5+10;

int N;
int T;
int t[NN];



int main()
{
    scanf("%d%d",&N,&T);
    long long sum=0;
    long long sta=0;
    long long now=0;
    scanf("%d",&t[0]);
    sta=T;
    sum+=T;
    for(int i=1;i<N;i++){
        scanf("%d",&t[i]);
        if(t[i]>sta){
            sta=t[i]+T;
            sum+=T;
        }
        else{
            int ans=sta-t[i];
            sta=t[i]+T;
            sum+=T;
            sum=sum-ans;
        }
    }
    printf("%lld\n",sum);
}





Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define N 2005
using namespace std;
typedef long long ll;
typedef double db;
int n,m,a[N][N],ans,l[N],r[N],st[N],top,h[N];
char c[N];
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i)
	{
		scanf("%s",c+1);
		for(int j=1;j<=m;++j) a[i][j]=(c[j]=='.');
	}
	ans=max(n,m);
	for(int i=1;i<n;++i)
		for(int j=1;j<m;++j) a[i][j]=(a[i][j]+a[i+1][j]+a[i][j+1]+a[i+1][j+1])%2;
	for(int i=1;i<n;++i)
	{
		for(int j=1;j<m;++j) a[i][j]=(a[i][j]==1?0:a[i-1][j]+1),h[j]=a[i][j];
		st[top=0]=0;
		for(int j=1;j<m;++j)
		{
			while(top&&h[j]<=h[st[top]]) top--;
			l[j]=st[top]+1,st[++top]=j;
		}
		st[top=0]=m;
		for(int j=m-1;j;--j)
		{
			while(top&&h[j]<=h[st[top]]) top--;
			r[j]=st[top]-1,st[++top]=j;
		}
		for(int j=1;j<m;++j) ans=max(ans,(h[j]+1)*(r[j]-l[j]+2));
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 16000
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
#define debug(val) cerr << "The value of " << #val << " is = " << val << '\n';
typedef long long ll;
typedef long double ld;
const ld pi = 4*atan((ld)1);
const ll mod = 1e9 + 7;
const ll inf = 922337203685477;
const ll nax = 5e3 + 5;

ll n, k;
ll p[nax], c[nax];
ll pref[nax][nax];
vector<vector<ll>> v(nax);

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	cin >> n >> k;
	for(ll i = 0; i < n; i++){
		cin >> p[i];
		p[i]--;
	}
	for(ll i = 0; i < n; i++){
		cin >> c[i];
	}
	for(ll i = 0; i < n; i++){
		ll cur = i;
		while(p[cur] != i){
			v[i].pb(p[cur]);
			cur = p[cur];
		}
		v[i].pb(i);
	}
	for(ll i = 0; i < n; i++){
		for(ll j = 0; j < v[i].size(); j++){
			pref[i][j] += c[v[i][j]];
			if(j > 0){
				pref[i][j] += pref[i][j-1];
			}
		}
	}
	ll ans = -inf;
	for(ll i = 0; i < n; i++){
		ll temp = pref[i][v[i].size()-1];
		if(temp > 0){
			if(k <= (ll)v[i].size()){
				ll mini = min((ll)v[i].size(), k);
				for(ll j = 0; j < mini; j++){
					ans = max(ans, pref[i][j]);
				}
			}
			else{
				ll dif = k / (ll)v[i].size();
				ll cur = dif * temp;
				ll rem = k % (ll)v[i].size();
				for(ll j = 0; j < rem; j++){
					ans = max(ans, cur + pref[i][j]);
				}
				cur -= temp;
				for(ll j = 0; j < v[i].size(); j++){
					ans = max(ans, cur + pref[i][j]);
				}
			}
		}
		else{
			ll mini = min((ll)v[i].size(), k);
			for(ll j = 0; j < mini; j++){
				ans = max(ans, pref[i][j]);
			}
		}
	}	
	cout << ans << '\n';
}



Measured memory_bytes: 414452
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using G = vector<vector<int>>;
    
int main(){
    int n;
    cin >> n;
    vector<vector<ll>> happy(n, vector<ll>(3));
    rep(i,n) cin >> happy[i][0] >> happy[i][1] >> happy[i][2];

    vector<vector<ll>> dp(n, vector<ll>(3, 0));
    
    rep(i,n){
        if(i==0){
            rep(j,3) dp[i][j] = happy[i][j];
            continue;
        }
        rep(j,3){
            rep(k,3){
                if(j==k) continue;
                ll m = dp[i-1][k] + happy[i][j];
                dp[i][j] = max(dp[i][j], m);
            }
        }
    }

    ll ans = 0;
    rep(i,3){
        ans = max(ans, dp[n-1][i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 11136
a1, b1 = map(int, input().split())
a2, b2 = map(int, input().split())
a3, b3 = map(int, input().split())

load = [a1, b1, a2, b2, a3, b3]
load_dict = dict()
for i in range(6):
    if load[i] in load_dict:
        load_dict[load[i]] += 1
    else:
        load_dict[load[i]] = 1
        
if max(load_dict.values()) >= 3 or len(load_dict) <= 3:
    print("NO")
else:
    print("YES")

Measured memory_bytes: 9156
program station_and_bus
  implicit none
  character(3) :: s
  integer :: n = 0, i
  read(*,*) s
  do i = 1, 3
    n = n+ichar(s(i:i))-65
  end do
  if (n == 0 .or. n == 3) then
    write(*,'(a)') "No"
  else
    write(*,'(a)') "Yes"
  end if
end program station_and_bus

Measured memory_bytes: 640
while 1:
    n ,x=map(int, input().split())

    if n+x==0:
        break
    count=0
    for i in range(1,n+1):
        for j in range(i+1,n+1):
            for k in range(j+1,n+1):
                judge=i+j+k
                if judge==x:
                    count=count+1
    print(count)
                    


Measured memory_bytes: 5596
#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 ll long long
#define uint unsigned int
#define ull  unsigned long long
#define pb push_back
#define mk make_pair
#define ins insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define X first
#define Y second
#define umap unordered_map
#define speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define setvalue(d,s,e,n) for(int qwe = s; qwe < e; ++qwe) d[qwe] = n
#define mset multiset
#define pqueue priority_queue
   
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
        
const int  N = 2e5 + 314;
const int INF = 1e9;
const double PI = acos(-1);
const int MOD = 1e9 + 7;
const double eps = 1e-9;
 
void solve(){
    int c[4][4];
    for(int i = 1; i <= 3; ++i) {
        for(int j = 1; j <= 3; ++j )
            cin >> c[i][j];
    }
    for(int i = -60; i <= 60; ++i){
        for(int j = -50; j <= 50; ++j) {
            for(int k = -50; k  <= 50; ++k ) {
                int a[4] = {-1,i,j,k};
                set <int> b[4];
                for(int q = 1; q <= 3; ++q) {
                    for(int r = 1; r <= 3; ++r) {
                        b[r].ins(c[q][r] - a[q]); 
                    }
                }
                int cnt = 0;
                for(int r = 1; r <= 3; ++r ) {
                    cnt += b[r].size() == 1;
                }
                if(cnt == 3){
                    cout << "Yes";
                    return;
                }
            }
        }
        
    }
    cout << "No";
}

 
int main(){
    speed();
    int t = 1;
    // cin >> t;
    while(t--)solve();
}

Measured memory_bytes: 256
import sys
def input():
  return sys.stdin.readline().rstrip()

N=int(input())
a=list(map(int,input().split()))

ans=0
for i in range(N):
  tmp=0
  while a[i]%2==0:
    tmp+=1
    a[i]//=2
  ans+=tmp

print(ans)


Measured memory_bytes: 68560
n, h = map(int, input().split())
h2 = h
l = []
for i in range(n):
  l.append(list(map(int,input().split())))

l_b = sorted(l, key=lambda x: x[1])
l = sorted(l_b, reverse=True, key=lambda x: x[0])
c_a = 0
c_b = 0
b_sum = 0

for i in range(n-1, -1, -1):
  if l_b[i][1] >= l[0][0]:
    b_sum += l_b[i][1]
    h -= l_b[i][1]
    c_b += 1
    if h <= 0:
      print(c_b)
      exit()
import math
c_a = math.ceil((h2 - b_sum) / l[0][0])


print(c_a+c_b)


Measured memory_bytes: 98964
#include <bits/stdc++.h>
#include <algorithm>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) (x).begin(), (x).end()
#define PB(x) push_back(x)
#define MP(x,y) make_pair(x,y)
using namespace std;
typedef long long ll;
 
long long N, X[1009], Y[1009], H[1009]; vector<tuple<long long, long long, long long>>vec;
 
int main() {
	cin >> N; tuple<long long, long long, long long>G = make_tuple(-1, -1, -1);
	for (int i = 1; i <= N; i++) {
		cin >> X[i] >> Y[i] >> H[i];
		if (H[i] >= 1) G = make_tuple(X[i], Y[i], H[i]);
	}
	for (int i = 0; i <= 100; i++) {
		for (int j = 0; j <= 100; j++) {
			long long V = get<2>(G) + abs(get<0>(G) - i) + abs(get<1>(G) - j); V = max(V, 0LL); bool flag = true;
			for (int k = 1; k <= N; k++) {
				long long VV = V - abs(X[k] - i) - abs(Y[k] - j); VV = max(VV, 0LL);
				if (H[k] != VV) flag = false;
			}
			if (flag == true) vec.push_back(make_tuple(i, j, V));
		}
	}
	if (vec.size() == 1) {
		cout << get<0>(vec[0]) << " " << get<1>(vec[0]) << " " << get<2>(vec[0]) << endl;
	}
	return 0;
}

Measured memory_bytes: 384
/* atcoder */
#include "bits/stdc++.h"
using namespace std;

/* typedef */
/* long系 */
typedef long long ll;   // long long
typedef long double ld; // long double
/* vector系 */
typedef vector<int> vi;                    // intのvector
typedef vector<double> vd;                 // doubleのvector
typedef vector<ll> vll;                    // llのvector
typedef vector<ld> vld;                    // ldのvector
typedef vector<pair<int, int>> vi_i;       // i_iのvector
typedef vector<pair<double, double>> vd_d; // d_dのvector
typedef vector<pair<ll, ll>> vl_l;         // l_lのvector
typedef vector<pair<ld, ld>> vld_ld;       // ld_ldのvector
typedef vector<string> vs;                 // stringのvector
/* pair系 */
typedef pair<int, int> i_i;       // int同士のpair
typedef pair<double, double> d_d; // double同士のpair
typedef pair<ll, ll> l_l;         // ll同士のpair
typedef pair<ld, ld> ld_ld;       // ld同士のpair

/* define */
#define all(v) v.begin(), v.end() // コンテナ全体
#define PI (acos(-1))             // 円周率pi

/* stringstream */
stringstream ss;
stringstream init_ss; // save default formatting

/* main */
void Main(void)
{
    int n;
    cin >> n;
    vi a;
    a.resize(n);
    for (int rv = 0; rv < n; rv++)
    {
        cin >> a[rv];
    }
    reverse(all(a));
    a.resize(n);
    for (int rv = 0; rv < n; rv++)
    {
        cout << a[rv];
        if (rv < n - 1)
            cout << " ";
        else
            cout << endl;
    }
}

int main(int argc, char const *argv[])
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();

    return 0;
}



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

typedef pair<int, int> P;

int main() {
    int n, m;
    cin >> n >> m;
    int path[n+1][n+1];
    memset(path, 0, sizeof(path));

    rep(i,m) {
        int a, b;
        cin >> a >> b;
        --a, --b;
        path[a][b] = 1;
        path[b][a] = 1;
    }

    int root[n];
    rep(i,n) root[i] = i;

    int ans = 0;
    do {
        bool flg = true;
        for (int i=0; i<n-1; ++i) {
            if (!path[root[i]][root[i+1]]) flg = false;
        }
        if (flg) ++ans;
    } while (next_permutation(root+1, root+n));

    cout << ans << endl;

    return 0;
}

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

signed main(){

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

    int n; string s;
    cin >> n >> s;
    if (n % 2 == 1) cout << "No" << endl;
    else if (s.substr(0,n/2) != s.substr(n/2,n/2)) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int l,a,b,c,d,x,y,z;
	scanf("%d %d %d %d %d",&l,&a,&b,&c,&d);
	x=a/c;
	if(a%c>0){
		x+=1;
	}
	y=b/d;
	if(b%d>0){
		y+=1;
	}
	if(x>y){
		z=l-x;
	}
	else{
		z=l-y;
	}
	printf("%d\n",z);
	return 0;
}

Measured memory_bytes: 2720
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int a,b,c,sum;
    scanf("%d %d %d",&a,&b,&c);
    sum = b/a;
    if(sum > c)
    {
        printf("%d\n",c);
    }else{
        printf("%d\n",sum);
    }

    return 0;
}


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

int main() {
	int h,w;
	for(int j=0;j<1000;j++){
		cin>>h>>w;
		if(h==0 && w==0){
			break;
		}
		for(int j=0;j<h;j++){
			for(int i=0;i<w;i++){
				if(i==0 || j==0 || i==w-1 ||j==h-1){
				cout<<"#";
				}else{
					cout<<".";
				}
			}
			cout<<endl;
		}
		cout<<endl;
	}

	// your code goes here
	return 0;
}

Measured memory_bytes: 1152
import sys
from collections import Counter

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(readline())
words = read().rstrip().decode().split()

counter = Counter(words)
for x in ['AC', 'WA', 'TLE', 'RE']:
    n = counter[x]
    print('{} x {}'.format(x, n))

Measured memory_bytes: 17400
#include<bits/stdc++.h>
using namespace std;
char s1[101],s2[101];
int main()
{
    gets(s1);
    gets(s2);
    int n=strlen(s1);
    int m=strlen(s2); 
    sort(s1,s1+n);
    sort(s2,s2+m);
    for(int i=0;i<fmax(n,m);i++)
    {
        if(s1[i]<s2[m-i-1])
        {
            printf("Yes\n");
            return 0;
        }
        if(s1[i]>s2[m-i-1])
            break;
    }
    printf("No\n");
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a,b,r;
    char op;
    scanf("%d %c %d",&a,&op,&b);
    switch(op)
    {
    case '+':
        {
          r=a+b;
          printf("%d\n",r);
          break;
        }
    case '-':
        {
            r=a-b;
            printf("%d\n",r);
            break;
        }

    }
    return 0;

}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <bitset>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using lint = long long;
using namespace std;

const int MOD = 1000000007;
const lint INF = 1LL << 60;

const double PI = acos(-1);
const double Rad2Deg = 180.0 / PI;
const double Deg2Rad = PI / 180.0;

int main() {
    int N;
    string S, T;
    cin >> N;
    cin >> S >> T;

    string a = "";
    for (int i = 0; i < N; i++) {
        a += S[i];
        a += T[i];
    }
    cout << a << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
   	ll n, i, j;
   	cin >> n;
   	ll a[n];
   	for(i = 0; i < n ; i++){
   		cin >> a[i];
   	}
   	ll ans = 0;
   	for(i = 0; i < n ; i++){
   	    for(j = i+1; j < n; j++){
   			ans+=(a[i]*a[j]);
   		}
   	}
   	cout << ans << endl;
    return 0;
} 


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int ans[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main(int argc, char const *argv[])
{
    int k; cin >> k;
    cout << ans[k - 1];
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

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

        int n = sc.nextInt();
        int k = sc.nextInt();
        int mod = 998244353;

        int[] l = new int[k];
        int[] r = new int[k];
        long[] sum = new long[k];

        for(int i = 0; i < k; i++){
            l[i] = sc.nextInt();
            r[i] = sc.nextInt();
        }

        long[] dp = new long[n * 2];
        dp[1] = 1;

        for(int i = 1; i <= n; i++){
            //System.out.println("i = " + i);
            for(int j = 0; j < k; j++){
                int ra = Math.min(n, i - l[j]);
                ra = Math.max(0, ra);
                int la = Math.max(0, i - r[j]);
                la = Math.min(n, la);
                sum[j] += dp[ra];
                dp[i] += sum[j];
                sum[j] -= dp[la];
                //System.out.println("la = " + la);
                //System.out.println("ra = " + ra);
            }
            dp[i] %= mod;
            //System.out.println(Arrays.toString(dp));
        }
        System.out.println(dp[n]);

    }
}
/*

5 2
3 3
5 5

 */

Measured memory_bytes: 40036
/*input
869121
*/
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <climits>
#include <random>

using namespace std; 

template<typename T>
using minpq = priority_queue<T, vector<T>, greater<T>>;
int GCD(int x,int y){return y?GCD(y,x%y):x;}
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define rep(i,n) for(int i=0;i<(n);i++)
#define repl(i,a,b) for(int i=(a);i<(b);i++)
#define repm(i,a,b) for(int i=(a);i>(b);i--)
#define rept(v) for(auto it=v.begin();it<v.end();it++)
#define all(v) v.begin(),v.end()
const int INF = 1<<30;
typedef long long ll;
typedef pair<int,int> pii;

int const MOD = 1e9+7;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
	ll n;
	cin >> n;
	// (all possibilities) - (no 0s) - (no 9s) + (only 1-8)
	ll pow10=1, pow9=1, pow8=1;
	rep(i, n) {
		pow10=(pow10*10)%MOD;
		pow9=(pow9*9)%MOD;
		pow8=(pow8*8)%MOD;
	}
	ll ans;
	ans = (pow10-pow9+MOD)%MOD;
	ans = (ans-pow9+MOD)%MOD;
	ans = (ans+pow8+MOD)%MOD;
	cout << ans;
	return 0;	
}

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

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

    for(int i = 0; i < t.size(); i++) {
        if(t.at(i) == '?') {
            t.replace(i, 1, "D");
        }
    }
    cout << t << endl;
    return 0;
}

Measured memory_bytes: 3752
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(S: str):
    if S.count('A') == 3 or S.count('B') == 3:
        print(NO)
    else:
        print(YES)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
# -*- coding: utf-8 -*-
S = input()

if S[0] != 'A':
    print('WA')
elif 'C' not in S[2:-1]:
    print('WA')
else:
    i = S[2:-1].find('C')
    S = S[1:2 + i] + S[2 + i + 1:]
    if not S.islower():
        print('WA')
    else:
        print('AC')


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

using namespace std;

int main( void )
{
	string in;
	char stack[101];
	while(getline(cin, in), in[0] != '.') {
		int pointer = 0;
		bool hit = true;
		int len = in.size();
		for(int i=0; i < len; ++i) {
			if(in[i] == '(' || in[i] == '[') {
				stack[pointer++] = in[i];
			}
			else if(in[i] == ')') {
				if(!pointer || '(' != stack[--pointer]) hit = false;
			}
			else if(in[i] == ']') {
				if(!pointer || '[' != stack[--pointer]) hit = false;
			}
		}
		if(!pointer && hit)
			cout << "yes" << endl;
		else
			cout << "no" << endl;
	}
}

Measured memory_bytes: 900
#include<iostream>
#include<string>
using namespace std;
int main(void){
    int n;
    cin>>n;
    string s[50];
    for(int i(0);i<n;i++){
        cin>>s[i];
    }
    int cnt[50][26]={0};
    for(int i(0);i<n;i++){
        for(int j(0);j<s[i].size();j++){
            cnt[i][(int)(s[i][j]-97)]++;
        }
    }
    for(int i(0);i<26;i++){
        int min(cnt[0][i]);
        for(int j(1);j<n;j++){
            if(min>cnt[j][i])min = cnt[j][i];
        }
        for(int j(0);j<min;j++){
            cout<<(char)(i+97);
        }
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 888
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

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


int main(){
    
    string s,t;
    cin >> s >> t;
    s += t;
    
    int n = stoi(s);

    int i = 1;
    while(i < n){
	if(i*i == n){
	    Yes;
	    ret 0;
	}
	i++;
    }
    No;

    return  0;
}


Measured memory_bytes: 256
from math import floor, sqrt
from collections import Counter
from itertools import permutations

def getPrimeFactor(x):
    ans = []
    for d in range(2, floor(sqrt(x)) + 1):
        while x % d == 0:
            ans.append(d)
            x //= d
    if x != 1:
        ans.append(x)
    return ans

N = int(input())

cntP = Counter()
for x in range(2, N + 1):
    PF = getPrimeFactor(x)
    cntP.update(PF)

As = cntP.values()
ans = 0
for A1, A2, A3 in permutations(As, 3):
    if A1 >= 2 and A2 >= 4 and A3 >= 4: ans += 1
ans //= 2

for A1, A2 in permutations(As, 2):
    if A1 >= 4 and A2 >= 14: ans += 1
    if A1 >= 2 and A2 >= 24: ans += 1

for A in As:
    if A >= 74: ans += 1

print(ans)


Measured memory_bytes: 3444
a = list(map(int,input().split()))
a.sort()
b = list(map(lambda x:x%2,a))
ans = 0

if sum(b) in (1,2):
    ans += 1
    for i in range(3):
        if sum(b) == 1:
            a[i] -= b[i]
        else:
            a[i] += b[i]

ans += (a[2]-a[0])//2+ (a[2]-a[1])//2
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using bint = boost::multiprecision::cpp_int;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repSE(i,s,n) for (int i = (s); i < (n); i++)
#define rrepSE(i,s,e) for (int i = (s); i > (e); i--)
#define ssort(v) sort(v.begin(), v.end())
#define gsort(v) sort(v.rbegin(), v.rend())
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }
const int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
const int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;

int main()
{
    int n;
    cin >> n;
    vector<int> d1(n), d2(n);
    rep(i,n) cin >> d1[i] >> d2[i];
    int ans = false;
    rep(i,n-2) {
        if (d1[i] == d2[i] && d1[i+1] == d2[i+1] && d1[i+2] == d2[i+2]) {
            ans = true;
            break;
        }
    }
    cout << (ans?"Yes":"No") << "\n";
    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
using namespace std;

// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>

vector <ld> v;
ld dp[3005][3005];

ll fep(ll x, ll y, ll mod)
{ll res=1;while(y>0){if(y&1)res=(res*x)%mod;
    y=y>>1;x=(x*x)%mod;}return res%mod;}

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

	ll n,i,m,j,k,y,a,b;
	ld x,sm=0;
	string s;
	
	cout << fixed << setprecision(10);
	
	cin >> n;
	v.pb(0);
	for(i=0;i<n;i++)
	{
		cin >> x;
		v.pb(x);
	}
	dp[0][0]=1;
	for(i=1;i<=n;i++)
	{
		for(j=0;j<=i;j++)
		{
			dp[i][j]=dp[i-1][j]*(1.0-v[i]);
			if(j)
				dp[i][j]+=dp[i-1][j-1]*v[i];
//			cout << i << "," << j << "-" << dp[i][j] << " ";
		}
//		cout << endl;
	}
	for(i=1+n/2;i<=n;i++)
		sm+=dp[n][i];
	cout << sm;
	return 0;
}


Measured memory_bytes: 139392
#include<iostream>
using namespace std;
int a[1000010];
int vis[1000010];
int main(){
    int s;
    cin>>s;
    a[1]=s;
    vis[a[1]]=1;
    for(int i=2;i<=1e6;i++){
        if(a[i-1]%2==0)
            a[i]=a[i-1]/2;
        else
            a[i]=a[i-1]*3+1;
        if(vis[a[i]]){
            cout<<i;
            return 0;
        }
        vis[a[i]]=1;
    }
}


Measured memory_bytes: 2304
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<cstdio>

using namespace std;

const int INF=100000;
#define rep(i,n) for(int i=0;i<(n);i++)

char map[100][100];
int r[11];
int h,w,d,n;

bool flag[100][100];
int dist[100][100];

// 図面のマスク
void f(int x,int y,int k) {
    int sup;
    int inf;

    int temp[100][100]={};

    if(k==0) {
        sup=r[0];
        inf=-1;
    }
    else if(k==d) {
        sup=100000;
        inf=r[d-1];
    }
    else {
        sup=r[k];
        inf=r[k-1];
    }

    rep(i,h) rep(j,w) {
        int dx = abs(x-i);
        int dy = abs(y-j);

        if(dy<=sup && dx<=sup) {
            temp[i][j]=1;

        }
    }
    rep(i,h) rep(j,w) {
        int dx = abs(x-i);
        int dy = abs(y-j);

        if((inf>=dx && inf>=dy)) temp[i][j]=0;
    }

    rep(i,h) {
        rep(j,w) {
            flag[i][j]&=temp[i][j];
        }
    }
}

//たどり着けるか
void f2() {
    int sx,sy;

    int dx[4]={1,0,-1,0};
    int dy[4]={0,1,0,-1};
    rep(i,100) rep(j,100) dist[i][j]=INF;
    rep(i,h) rep(j,w) {
        if(map[i][j]=='D') {
            sx=i;
            sy=j;
        }
    }
    dist[sx][sy]=0;

    queue<pair<int,int> > que;
    que.push(make_pair(sx,sy));

    while(que.size()) {
        pair<int,int> p = que.front(); que.pop();
        rep(i,4) {
            int nx=dx[i]+p.first;
            int ny=dy[i]+p.second;
            if(0<=nx&&nx<h&&0<=ny&&ny<w && map[nx][ny]!='#' && dist[nx][ny]==INF) {
                dist[nx][ny] = dist[p.first][p.second] + 1;
                que.push(make_pair(nx,ny));
            }
        }
    }


}

int main() {
    cin>>h>>w>>d>>n;
    rep(i,100) rep(j,100) map[i][j]='#';
    rep(i,h) cin>>map[i];
    rep(i,d) cin>>r[i];

    rep(i,h) rep(j,w) if(map[i][j]!='#') flag[i][j]=1;
    rep(i,n) {
        int x,y,k;
        cin>>x>>y>>k;
        swap(x,y);
        f(x,y,k);
    }
    int cnt=0;
    rep(i,h) {
        rep(j,w) {
            if(flag[i][j]) cnt++;
            //cout<<flag[i][j]<<" ";
        }
        //cout<<endl;
    }

    f2();
    bool a,b;
    a=b=false;
    rep(i,h) rep(j,w) {
        if(dist[i][j]!=INF && flag[i][j]) a=true;
        if(dist[i][j]==INF && flag[i][j]) b=true;
    }
    if(a&&b) cout<<"Unknown"<<endl;
    if(a&&!b) cout<<"Yes"<<endl;
    if(!a&&b) cout<<"No"<<endl;
    if(!a&&!b) cout<<"Broken"<<endl;



    return 0;
}

Measured memory_bytes: 1316
S=input()
N=len(S)
mod=10**9+7
DP=[[0]*13 for i in range(N+1)]
DP[0][0]=1
for i in range(N):
  if S[i]=='?':
    for j in range(13):
      for k in range(10):
        DP[i+1][(j*10+k)%13]+=DP[i][j]
    for j in range(13):
      DP[i+1][j]%=mod
  else:
    for j in range(13):
      DP[i+1][(j*10+int(S[i]))%13]=DP[i][j]
print(DP[N][5])

Measured memory_bytes: 88452
menu = []
mod = []
menu.append(int(input()))
menu.append(int(input()))
menu.append(int(input()))
menu.append(int(input()))
menu.append(int(input()))

last = 0
for i in range(len(menu)):
    tmp = menu[i] % 10
    if tmp != 0 :
        mod.append(10 - tmp)
    else:
        mod.append(0)

    last = max(last,mod[i])


print(menu[0]+mod[0]+menu[1]+mod[1]+menu[2]+mod[2]+menu[3]+mod[3]+menu[4]+mod[4]-last)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;

int main(){
    long long n;
    cin >> n;
    long long sum;
    long long result[n];
    long long v[n];
    for(long long i = 0; i < n; i++){
        long long a;
        cin >> a;
        v[i] = a;
        if(i == 0){
            sum = a;
        }
        else{
            sum = sum^a;
        }
    }
    //printf("sum %lld\n", sum);

    for(long long i = 0; i < n; i++){
       result[i] = sum^v[i];
    }

    for(long long i = 0; i < n; i++){
       result[i] = sum^v[i];
       printf("%lld ", result[i]);
    }
    printf("\n");

    //long long a = 20^11^9^24; 
    //cout << a << endl;
    //long long b = 20^a;
    //cout << b << endl;
    return 0;
}

Measured memory_bytes: 6820
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Tarek
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BDigits solver = new BDigits();
        solver.solve(1, in, out);
        out.close();
    }

    static class BDigits {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int k = in.nextInt();
            int coun = 0;
            while (n > 0) {
                if (n % k == 0) {
                    coun++;
                    n /= k;
                } else n--;
            }
            out.println(coun + 1);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define emb emplace_back
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define N  99999
#define f first 
#define em emplace
#define s second
using lint=long long int;

typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<string> vs;

 
#define fori(n) for(int i=0; i<int(n); i++)
 
#define cins(s) string s; cin>>s;
#define cini(i) lint i; cin>>i;
#define cind(d) double d; cin>>d;
#define cinai(a, n) vi a(n); fori(n) { cin>>a[i]; }
#define cinas(s, n) vs s(n); fori(n) { cin>>s[i]; }
#define cinad(a, n) vd a(n); fori(n) { cin>>a[i]; }
#define z 1000000007 


void solve(){
  
  cini(n);
  vector<int>dp(3);


  for(int i=0;i<n;i++){
     vector<int>v(3);

     for(int j=0;j<3;j++){
           cin>>v[j];
            int m=0;
           for(int k=0;k<3;k++){

              if(j!=k){
                m=max(dp[k],m);
              }
           }
           v[j]+=m;
     }
    dp.clear();
    v.swap(dp);
  }
     
     int a=*max_element(dp.begin(),dp.end());
     cout<<a<<endl;




}
 
 
int main()
{ 
 
  



  solve();
 }

Measured memory_bytes: 256