akhauriyash/Code-Regression huggingface dataset:
#define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
  return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

int m;
string s;

bool search(int pos, int len, int x) {
  if (pos == len) {
    // cout << s << endl;
    if (--m == 0) {
      cout << s << endl;
      return true;
    }
    return false;
  }
  for (int y = 0; y < 10; ++y) {
    if (pos == 0 && y == 0) continue;
    if (pos > 0 && abs(x - y) > 1) continue;
    s += (char)('0' + y);
    if (search(pos + 1, len, y)) return true;
    s.pop_back();
  }
  return false;
}

int main() {
  cin >> m;
  for (int len = 1; len <= 10; ++len) {
    if (search(0, len, 0)) return 0;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x);i<=(y);i++)
using namespace std;
#define N 200005
int n,f[N],Max;
int main(){
	scanf("%d",&n);
	rep (i,1,n){
		int x;scanf("%d",&x);
		f[x]=f[x-1]+1;Max=max(Max,f[x]);
	}
	printf("%d\n",n-Max);
	return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <vector>
#include <stdio.h>
#include <math.h>
#include <algorithm>
#include <queue>
#include <cmath>
#include <cstdio>
using namespace std;
int main(){
int n;
cin>>n;
long long ans=1;
for(int i=1;i<=n;i++){
ans*=i;
ans=ans%1000000007;}
cout<<ans;
system("pause");
return 0;
}

Measured memory_bytes: 504
const MOD: u64 = 1000000007;

fn main() {
	let mut s = String::new();
	std::io::stdin().read_line(&mut s).unwrap();
	let s: Vec<_> = s.trim().bytes().collect();
	let mut cum = vec![(0u32, 0u32, 0u32, 0u32); s.len() + 1];
	for (i, &b) in s.iter().enumerate() {
		match b {
			b'A' => cum[i + 1] = (cum[i].0 + 1, cum[i].1, cum[i].2, cum[i].3),
			b'B' => cum[i + 1] = (cum[i].0, cum[i].1 + 1, cum[i].2, cum[i].3),
			b'C' => cum[i + 1] = (cum[i].0, cum[i].1, cum[i].2 + 1, cum[i].3),
			_    => cum[i + 1] = (cum[i].0, cum[i].1, cum[i].2, cum[i].3 + 1),

		}
	}
	let mut ans = 0;
	for (i, &b) in s[1..s.len() - 1].iter().enumerate() {
		if b == b'A' || b == b'C' { continue; }
		let al = cum[i + 1].0;
		let ql = cum[i + 1].3;
		let cr = cum[s.len()].2 - cum[i + 2].2;
		let qr = cum[s.len()].3 - cum[i + 2].3;
		ans = (ans +
			((al as u64) * mod_pow(3, ql) + if ql > 0 { (ql as u64) * mod_pow(3, ql - 1) } else { 0 }) % MOD *
			(((cr as u64) * mod_pow(3, qr) + if qr > 0 { (qr as u64) * mod_pow(3, qr - 1) } else { 0 }) % MOD)) % MOD;
	}
	println!("{}", ans);
}

fn mod_pow(a: u64, n: u32) -> u64 {
	let mut r = 1;
	let mut a = a;
	let mut n = n;
	while n > 0 {
		if n & 1 != 0 {
			r = r * a % MOD;
		}
		a = a * a % MOD;
		n >>= 1;
	}
	r
}


Measured memory_bytes: 6396
s = gets.chop
n = s.length
if s == s.reverse && s[0..n/2-1] == s[0..n/2-1].reverse && s[(n+3)/2-1..n-1] == s[(n+3)/2-1..n-1].reverse
  puts 'Yes'
else
  puts 'No'
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
const int maxn = 100100, mod = 1'000'000'007;
int mul(long long a, long long b){
	return a * b % mod;
}
vector<int> e[maxn];
int k;
int solve(int u, int p, int p2){
	int ways = k;
	ways--;
	if(p) ways--;
	ways = max(ways, 0);
	int now = 1;
	for(int v : e[u]){
		if(v == p) continue;
		now = mul(now, ways); ways--;
		now = mul(now, solve(v, u, p));
		ways = max(ways, 0);
	}
	return now;
}
int main(){
	int n; cin >> n >> k;
       	for(int i = 0; i < n - 1; i++){
		int u, v; cin >> u >> v;
		e[u].push_back(v);
		e[v].push_back(u);
	}
	cout << mul(k, solve(1, 0, 0)) << endl;
	return 0;
}	



Measured memory_bytes: 11520
package main

import (
	"bufio"
	"fmt"
	"math"
	"math/rand"
	"os"
	"time"
)

var D int
var cs []int
var ss [][]int

func main() {
	D = ReadInt()
	cs = ReadInts(26)
	ss = make([][]int, D)
	for i := 0; i < D; i++ {
		ss[i] = ReadInts(26)
	}

	// naives
	answers := []int{}
	last := make([]int, 26)
	for d := 1; d <= D; d++ {
		maxT, maxScore := -1, math.MinInt32
		for i := 0; i < 26; i++ {
			s := ss[d-1][i] - cs[i]*(d-last[i])
			if s > maxScore {
				maxT, maxScore = i, s
			}
		}
		last[maxT] = d
		answers = append(answers, maxT+1)
	}

	rand.Seed(123456777)

	score := scores(answers)
	bestAnswers, bestScore := Dup(answers), score

	start := time.Now()
	timeout := 1950 * time.Millisecond

	for {
		elapsed := time.Now().Sub(start)
		if elapsed >= timeout {
			break
		}

		d, q := rand.Intn(D)+1, rand.Intn(26)+1
		orig := answers[d-1]
		answers[d-1] = q
		score := scores(answers)

		best := false
		if score > bestScore {
			best = true
			bestAnswers, bestScore = Dup(answers), score
		}

		if elapsed < time.Second {
			// 最初はベストのときだけ更新する
			if best {
				// none
			} else {
				answers[d-1] = orig // revert
			}
		} else {
			// answers[d-1] = orig // revert
		}
	}

	for _, v := range bestAnswers {
		fmt.Println(v)
	}
}

func Dup(xs []int) []int {
	return append([]int{}, xs...)
}

func scores(answers []int) int {
	last := make([]int, 26)
	score := 0
	for d := 1; d <= D; d++ {
		t := answers[d-1] - 1
		score += ss[d-1][t]
		last[t] = d
		for i := 0; i < 26; i++ {
			score -= cs[i] * (d - last[i])
		}
	}
	return score
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int) { Scan(&i); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 4768
#include<iostream>
using namespace std;
#define MAX 101

main(){
  int T[MAX];

  for ( int i = 0; i < MAX; i++ ) T[i] = 0;
  int x;
  while(  cin >>x ) T[x]++;

  int maxv = 0;
  for ( int i = 0; i < MAX; i++ ){
    if ( maxv < T[i] ){
      maxv = T[i];
    }
  }

  for ( int i = 0; i < MAX; i++ ){
    if ( maxv == T[i] ) cout <<  i << endl;
  }
}

Measured memory_bytes: 0
from sys import stdin
data = stdin.readlines()

n = int(data[0].split()[0])
a = [int(s) for s in data[1].split()]
a = sorted(a)

max = a[-1]

l = [0]*(max+1)

for i in a:
    l[i] += 1
    if l[i] == 1:
        for j in range(i*2,max+1,i):
            l[j] = 2
print(l.count(1))

Measured memory_bytes: 32696
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<list>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<string>
#define sgn(v) (abs((v))<eps?0:((v)<0?-1:1))
#define sqr(v) ((v)*(v))
#define tri(v) ((v)*(v)*(v))
#define MP make_pair
#define PB push_back
#define FI first
#define SE second
#define debug 0
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<double,int> PDI;
typedef pair<double,double> PDD;
typedef pair<int,int> PII;
typedef pair<int,LL> PIL;
typedef pair<LL,int> PLI;
typedef pair<LL,LL> PLL;
const double eps=1e-8;
const double pi=acos(-1);
using namespace std;
const int maxn=4e4+100;
double x[maxn],y[maxn];
const double inf=1e100;
int main()
{
	int n,i;
	scanf("%d",&n);
	double sumx,sumy,sqrx,sqry,sqrxy,triy,trix;
	double sumxy=0,xxy=0,xyy=0;
	sumx=sumy=sqrx=sqry=sqrxy=0;
	trix=triy=0;
	for(i=0;i<n;++i)
	{
		scanf("%lf%lf",&x[i],&y[i]);
		sumxy+=(x[i]*y[i]);
		sumx+=x[i];
		sumy+=y[i];
		xyy+=x[i]*sqr(y[i]);
		xxy+=sqr(x[i])*y[i];
		sqrx+=sqr(x[i]);
		sqry+=sqr(y[i]);
		sqrxy+=(sqr(x[i])+sqr(y[i]));
		triy+=tri(y[i]);
		trix+=tri(x[i]);
	}
	double C=n*sqrx-sumx*sumx;
	double D=n*sumxy-sumx*sumy;
	double E=n*trix+n*xyy-sqrxy*sumx;
	double G=n*sqry-sumy*sumy;
	double H=n*xxy+n*triy-sqrxy*sumy;
	double a,b,c;
	a=(H*D-E*G)/(C*G-sqr(D));
	b=(H*C-E*D)/(sqr(D)-G*C);
	c=-(sqrxy+a*sumx+b*sumy)/n;
	printf("%.3f %.3f %.3f\n",a,b,c);
	return 0;
}

Measured memory_bytes: 1872
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  string a,b;
  cin>>a>>b;
  int al=a.length();
  int bl=b.length();
  if(al>bl){
    rep(i,al-bl){
      b='0'+b;
    }
  }
  else if(al<bl){
    rep(i,bl-al){
      a='0'+a;
    }
    
    
  }
  if(a>b)cout<<"GREATER"<<endl;
  else if(a<b)cout<<"LESS"<<endl;
  else cout<<"EQUAL"<<endl;



  return 0;

}


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

using namespace std;

int main()
{
    #ifdef lOCAL_EXEC
    #else
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #endif // lOCAL_EXEC
    long long int n,i,j,k,x,y,sum=0,m=1000000007;
    cin>>n;
    long long int A[n+1],suf[n+2]={0};
    for(i=1;i<=n;i++){
        cin>>A[i];
    }
    for(i=n;i>=1;i--){
        suf[i]=suf[i+1];
        suf[i]+=A[i];
    }
    for(i=1;i<=n;i++){
        sum+=(A[i]*(suf[i+1]%m))%m;
    }
    cout<<(sum+m)%m;
    return 0;
}


Measured memory_bytes: 6760
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {//233
	int n,l;
	cin>>n>>l;
	int mi = INT_MAX,ans = 0;
	int sum = 0;
	REP(i,0,n-1) {
		sum+=l+i;
		if(abs(l+i)<mi){
			mi = abs(l+i);
			ans=l+i;
		}
	}
	sum-=ans;
	cout<<sum;
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
const double Pi = acos(-1);
double a,b,x;
int main()
{
	scanf("%lf%lf%lf",&a,&b,&x);
	if(x<=a*a*b/2) printf("%.10f\n",180*atan(a*b*b/(2*x))/Pi);
	else printf("%.10f\n",180*atan(2*(a*a*b-x)/(a*a*a))/Pi);
}

Measured memory_bytes: 512
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <unordered_map>
#include <climits>
#include <set>
#include <unordered_set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>
#include <locale>
#include <random>
#include <type_traits>
#include <chrono>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

using LL = long long;

int main() {

    int N;
    cin >> N;

    vector<int> H(N);
    for (int i = 0; i < N; i++) cin >> H[i];

    H[0]--;
    for (int i = 0; i < N - 1; i++) {
        if (H[i] < H[i + 1]) {
            H[i + 1]--;
        }
    }

    bool good = true;
    for(int i = 0;i<N-1;i++){
        if(H[i] > H[i + 1]){
            good = false;
        }
    }

    if(good) cout << "Yes" << endl;
    else cout << "No" << endl;

}





































Measured memory_bytes: 640
import java.util.*;

public class Main {
    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        long ans = 0;
        long a = 0;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == 'W') {
                ans += (i - a);
                a++;
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 27476
from sys import stdin
S = stdin.readline().rstrip()
# print(S)
N = len(S)
s0 = ''
s1 = ''
c0 = 0
c1 = 0
for itr in range(0,N):
    if itr%2 == 0:
        s0 += "0"
        s1 += "1"
    else:
        s0 += "1"
        s1 += "0"
# print("s0:",s0)
# print("s1:",s1)

for itr in range(0,N):
    if S[itr] != s0[itr]: c0 += 1
    if S[itr] != s1[itr]: c1 += 1

# print('c0:',c0,'c1:',c1)
if c0 >= c1:
    print(c1)
else:
    print(c0)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<class F>auto recursive(F f){return[f](auto...a){return f(f,a...);};}
template<class T>using rev_priority_queue=priority_queue<T,vector<T>,greater<T>>;
template<class T>using vector2d=vector<vector<T>>;
struct fixprec{int p;fixprec(int p):p(p){}};
ostream&operator<<(ostream&o,fixprec f){return o<<fixed<<setprecision(f.p);}
int main() {
    int N;
    double d0, x;
    cin >> N >> d0 >> x;
    double ans = 0;
    for(; N > 1; N--) {
        ans += d0 + (2.0 * N - 1.0) * x / 2.0;
        d0 = ((2.0 * N + 2.0) * d0 + 5.0 * x) / (2.0 * N);
        x *= (N + 2.0) / N;
    }
    ans += d0 + x / 2.0;
    cout << fixprec(14) << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cassert>
#define InfL 1000000000
#define InfLL 1000000000000000000LL
#define mod 1000000007
#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;
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<db> vd;

int main() {
	int K;
	string S;
	cin >> K;
	cin >> S;
	
	string ans = S;
	if (S.length() > K) {
		ans = S.substr(0, K);
		ans += "...";
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3628
a = gets.chomp.to_i
b = gets.chomp.to_i
c = gets.chomp.to_i
d = gets.chomp.to_i
e = gets.chomp.to_i
o = [a,b,c,d,e].sort_by { |e| (e % 10) == 0 ? 10 : (e % 10) }.reverse
sum = 0
0.upto(3) do |i|
  sum += (o[i] / 10) * 10
  sum += 10 if o[i] % 10 != 0
end
puts sum + o.last


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

#define int long long
#define counter(m)     for(int i=0;i<m;i++)
#define gcd            __gcd
#define endl           "\n"
#define pb             emplace_back
#define setbits(x)     __builtin_popcountll(x)
#define zrobits(x)     __builtin_ctzll(x)
#define mod            1000000007
#define mod2           998244353
#define maxe           *max_element
#define mine           *min_element
#define inf            1e18
#define deci(x, y)      fixed<<setprecision(y)<<x
#define w(t)           int t; cin>>t; while(t--)
#define nitin          ios_base::sync_with_stdio(false); cin.tie(NULL)
#define PI             3.141592653589793238
using namespace std;

int32_t main() {
    nitin;
    int n;
    cin>>n;
    vector<int>v(3*n);
    for(auto &c:v) cin>>c;
    sort(v.begin(),v.end());
    int ans=0;
    int temp=n;
    for(int i=3*n-2;temp;temp-- , i-=2 )
    {
        ans+=v[i];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 5556
#include<stdio.h>
#define K 38
#define N 1407

int main(){
    printf("%d %d\n",N,K);
    int i,j,x,p=2,pp,mk[2048][64],pa[64]={0};
    for(i=1;i<=K;i++){
        mk[i][1]=1;
        for(j=2;j<=K;j++){
            mk[i][j]=p;p++;
        }
    }
   pp=K;
   for(i=2;i<=K;i++){
        p=0;
        for(j=2;j<=K;j++){
            pa[j]=p;p+=(i-2);p%=(K-1);
        }
        for(x=2;x<=K;x++){
        pp++;
        for(j=1;j<=K;j++){
            if(j==1){mk[pp][j]=i;}
            else{mk[pp][j]=mk[j][pa[j]+2];pa[j]++;pa[j]%=(K-1);}
        }
        }
    }
    for(i=1;i<=N;i++){
        for(j=1;j<=K;j++){
            printf("%d",mk[i][j]);
            if(j!=K){printf(" ");}
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 768
import numpy as np
import sys
from scipy.sparse.csgraph import floyd_warshall

input = sys.stdin.readline


def solve():
    n, m, le = map(int, input().split())
    g1 = (le + 1) * np.zeros((n, n))
    for _ in range(m):
        a, b, c = map(int, input().split())
        if c <= le:
            g1[a - 1, b - 1] = c
            g1[b - 1, a - 1] = c

    fw1 = floyd_warshall(g1, directed=False)

    g2 = 1000 * np.zeros((n, n))
    g2[fw1 <= le] = 1

    fw2 = floyd_warshall(g2, directed=False)

    q = int(input())
    res_list = [-1] * q
    for i in range(q):
        s, t = map(int, input().split())
        res = fw2[s - 1, t - 1]
        if res <= n:
            res_list[i] = int(res - 1)

    for r in res_list:
        print(r)

if __name__ == "__main__":
    solve()

Measured memory_bytes: 18212
#include <stdio.h>

int main(void)
{
   int a, b;
   scanf("%d %d", &a, &b);
   if (a > b)
   {
      printf("a > b\n");
   }
   if (a == b)
   {
      printf("a == b\n");
   }
   if(a<b)
   {
      printf("a < b\n");
   }

   return 0;
}


Measured memory_bytes: 2048
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<map>
#include<stack>
#include<set>
#include<vector>
#include<functional>
using namespace std;
typedef long long LL;
inline LL read()
{
	LL kk=0,f=1;
	char cc=getchar();
	while(cc<'0'||cc>'9'){if(cc=='-')f=-1;cc=getchar();}
	while(cc>='0'&&cc<='9'){kk=(kk<<1)+(kk<<3)+cc-'0';cc=getchar();}
	return kk*f;
}

int main()
{
	LL k=read(),a=read(),b=read();
	bool flag=0;
	for(LL i=1;i<=1000;++i)
	{
		LL now=k*i;
		if(now>=a&&now<=b)flag=1;
		if(now>b)break;
	}
	if(flag)printf("OK\n");
	else printf("NG\n");
}

Measured memory_bytes: 3620
#include <stdio.h>
int main(void) {
  int n, a[200000], b[20000],
      bb = 0, c[20000], cc = 0, d[20000], dd = 0, e[20000], ee = 0, f[20000],
      ff = 0, g[20000], gg = 0, h[20000], hh = 0, x[20000], xx = 0, y[20000],
      yy = 0, z[20000], zz = 0;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    // for (int j = 0; j < i; j++) {
    //   if (a[i] == a[j]) {
    //     puts("NO");
    //     return 0;
    //   }
    // }
    if (a[i] % 10 == 0) {
      b[bb] = a[i];
      bb++;
      for (int j = 0; j < bb - 1; j++) {
        if (a[i] == b[j]) {
          puts("NO");
          return 0;
        }
      }
    }
    if (a[i] % 10 == 1) {
      c[cc] = a[i];
      cc++;
      for (int j = 0; j < cc - 1; j++) {
        if (a[i] == c[j]) {
          puts("NO");
          return 0;
        }
      }
    }
    if (a[i] % 10 == 2) {
      d[dd] = a[i];
      dd++;
      for (int j = 0; j < dd - 1; j++) {
        if (a[i] == d[j]) {
          puts("NO");
          return 0;
        }
      }
    }
    if (a[i] % 10 == 3) {
      e[ee] = a[i];
      ee++;
      for (int j = 0; j < ee - 1; j++) {
        if (a[i] == e[j]) {
          puts("NO");
          return 0;
        }
      }
    }
    if (a[i] % 10 == 4) {
      f[ff] = a[i];
      ff++;
      for (int j = 0; j < ff - 1; j++) {
        if (a[i] == f[j]) {
          puts("NO");
          return 0;
        }
      }
    }
    if (a[i] % 10 == 5) {
      g[gg] = a[i];
      gg++;
      for (int j = 0; j < gg - 1; j++) {
        if (a[i] == g[j]) {
          puts("NO");
          return 0;
        }
      }
    }
    if (a[i] % 10 == 6) {
      h[hh] = a[i];
      hh++;
      for (int j = 0; j < hh - 1; j++) {
        if (a[i] == h[j]) {
          puts("NO");
          return 0;
        }
      }
    }
    if (a[i] % 10 == 7) {
      x[xx] = a[i];
      xx++;
      for (int j = 0; j < xx - 1; j++) {
        if (a[i] == x[j]) {
          puts("NO");
          return 0;
        }
      }
    }
    if (a[i] % 10 == 8) {
      y[yy] = a[i];
      yy++;
      for (int j = 0; j < yy - 1; j++) {
        if (a[i] == y[j]) {
          puts("NO");
          return 0;
        }
      }
    }
    if (a[i] % 10 == 9) {
      z[zz] = a[i];
      zz++;
      for (int j = 0; j < zz - 1; j++) {
        if (a[i] == z[j]) {
          puts("NO");
          return 0;
        }
      }
    }
  }
  puts("YES");
  return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
using namespace std;
typedef pair<int,int>P;
#define F first
#define S second

signed main(){
    int n,q;
    string s;
    cin>>n>>q>>s;
    int dp[n+10]={};

    for(int i=0;i<s.size()-1;i++){
        if(s[i]=='A'&&s[i+1]=='C'){
            dp[i]=1;
        }
    }
    for(int i=1;i<s.size();i++)dp[i]+=dp[i-1];
        //r(i,s.size())cout<<dp[i]<<endl;
    while(q--){
        int l,r;
        cin>>l>>r;
        l-=2;r--;
        if(0<=l)cout<<dp[r-1]-dp[l]<<endl;
        else cout<<dp[r-1]<<endl;
    }
}

Measured memory_bytes: 1792
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#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 complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void solve() {
	int n; cin >> n;
    string s = to_string(n);
    rep(i, 3) {
        if(s[i] == '1') cout << '9';
        else if(s[i] == '9') cout << '1';
        else cout << s[i];
    }
    cout << endl;
}

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

Measured memory_bytes: 3656
n,m=map(int,input().split())
ans=0

s=[list(map(int,input().split())) for _ in range(m)]
p=list(map(int,input().split()))
for  i in range(1<<(n)):
    for j in range(m):
        c=0
        for ss in s[j][1:]:
            if i&(1<<(ss-1)):
                c+=1
        if c%2!=p[j]:
            break
    else:
        ans+=1

print(ans)

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

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define rer(i, a, b) for (int i = (int)a; i <= (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<int> > vvi;
typedef vector<pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

const int inf = 1000000000;
const int mod = 1000000007;
const double eps = 1e-9;
const int dx[] = { -1, 0, 1, 0};
const int dy[] = { 0, -1, 0, 1};

int main() {
	int x, y, s;
	while (cin >> x >> y >> s, x || y || s) {
		int ans = 0;
		for (int i = 1; i < s; ++i) {
			for (int j = 1; j < s; ++j) {
				int ax = i * (100 + x) / 100;
				int bx = j * (100 + x) / 100;
				if (ax + bx == s) {
					int ay = i * (100 + y) / 100;
					int by = j * (100 + y) / 100;
					ans = max(ans, ay + by);
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1164
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    N = int(rl())
    xy = [list(map(int, rl().split())) for _ in range(N)]
    
    a = [xi + yi for xi, yi in xy]
    a.sort()
    b = [xi - yi for xi, yi in xy]
    b.sort()
    ans = max(a[-1] - a[0], b[-1] - b[0])
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 123768
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
const ll M = 1e9 + 7;
int ni[] = {-1, 0, 1, 0};
int nj[] = {0, -1, 0, 1};

int main() {
  int h,w;
  cin >> h >> w;
  vector<string> a(h);
  rep(i,h) cin >> a[i];

  queue<pair<int, int>> q;
  rep(i,h) rep(j,w) if(a[i][j] == '#') q.emplace(i,j);

  int ans = 0;
  while(!q.empty()){ 
    queue<pair<int, int>> t;
    while(!q.empty()){
      int si = q.front().first;
      int sj = q.front().second;
      q.pop();
      rep(i,4){
        int x = si + ni[i];
        int y = sj + nj[i];
        if (x < 0 || y < 0 || x >= h || y >= w) continue;
        if (a[x][y] == '.'){
          a[x][y] = '#';
          t.emplace(x,y);
        }
      }
    }
    q = t;
    if(!q.empty()) ans++;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 13728
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

const int nmax = 8;
bool graph[nmax][nmax];

int dfs(int v, int N, bool visited[nmax]){
  bool all_visited = true;
  for(int i=0;i<N;i++){
    if(visited[i] == false) all_visited = false;
  }
  
  if(all_visited) return 1;
  
  int ret = 0;
  for(int i=0;i<N;i++){
    if(graph[v][i]==false) continue;
    if(visited[i]) continue;
    
    visited[i] = true;
    ret += dfs(i, N, visited);
    visited[i] = false;
  }
  return ret;
}

int main(){
  int N, M;
  
  cin >> N >> M;
  for(int i=0;i<M;i++){
    int a, b;
    cin >> a >> b;
    graph[a-1][b-1] = graph[b-1][a-1] = true;
  }
  
  bool visited[nmax];
  for(int i=0;i<N;i++) visited[i] = false;
  
  visited[0] = true;
  cout << dfs(0, N, visited) << endl;
  
  return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())

l = [list(map(int, input().split())) for _ in range(m)]

l2 = [[0 for i in range(n)] for i in range(n)]

for i in l:
    l2[i[0] - 1][i[1] - 1] += 1
    l2[i[1] - 1][i[0] - 1] += 1

for i in l2:
    print(sum(i))

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

public class Main {

	static int[] S ;
	public static void main(String[] args) throws Exception {
		// TODO 自動生成されたメソッド・スタブ

		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String W = in.readLine();
		int N = Integer.parseInt(W);


		long[] A = new long[N];
		long[] B = new long[N];

		W = in.readLine();
		String[] Ws = W.split(" ");
		long ans =0;
		long min = Long.MAX_VALUE;
		for (int i = 0; i < Ws.length; i++) {

			A[i] = Long.parseLong(Ws[i]);
			B[i] = A[i];
			if(i > 0){
				if(B[i-1] < 0 &&B[i] < 0){
					B[i-1]*=-1;
					B[i]*=-1;
				}
			}
			ans+=Math.abs(A[i]);
			min = Math.min(min, Math.abs(A[i]));
		}

		int m=0;
		for (int i = 0; i < N; i++) {
			if(B[i] < 0){
				m++;
			}
		}
		if(m%2 ==1){
			ans-=min*2;
		}

		System.out.println(ans);
	}

}


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

typedef long long int ll;
typedef long double ld;

#define Pb push_back
#define Mp make_pair

#define ff first
#define ss second

#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))

#define INF LONG_LONG_MAX
#define MINF LONG_LONG_MIN

#define endl "\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

#define db1(x) cout<<#x<<" : "<<x<<endl;
#define db2(x,y) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<endl;
#define db3(x,y,z) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<"\t"<<#z<<" : "<<z<<endl;

const int N = 1e5+5;
ll dp[N][3];
ll n;
ll v[N][3];

void solve()
{
  cin >> n;
  for(int i=0;i<n;i++)
  {
    cin >> v[i][0] >> v[i][1] >> v[i][2];
  }
  dp[0][0]=v[0][0];
  dp[0][1]=v[0][1];
  dp[0][2]=v[0][2];
  for(int i=1;i<n;i++)
  {
    dp[i][0] = v[i][0] + max(dp[i-1][1],dp[i-1][2]);
    dp[i][1] = v[i][1] + max(dp[i-1][0],dp[i-1][2]);
    dp[i][2] = v[i][2] + max(dp[i-1][0],dp[i-1][1]);
  }
  ll ans = Max(dp[n-1][0],dp[n-1][1],dp[n-1][2]);
  cout << ans;
}

signed main()
{
  IOS;
  //freopen("input.txt", "rt", stdin);
  //freopen("output.txt", "wt", stdout);
  int t=1;
  //cin >> t;
  while(t--)
  {
    solve();
  }
  return 0;
}
/*==============================================================================================================================================================*/


Measured memory_bytes: 8248
import qualified Data.ByteString.Lazy.Char8 as B
import Data.Maybe
import Data.List

solve :: Int -> Int -> [[Int]] -> (Int, [[Int]])
solve h w ass = (length coms, coms)
  where
    coms = reverse $ snd $ rowop $ zip [1..h] $ map (zip [1..w]) ass

rowop :: [(Int, [(Int, Int)])] -> (Maybe Int, [[Int]])
rowop [] = (Nothing, [])
rowop ((y,ps):pss) = (newPos, addCom ++ newCommands ++ commands)
  where
    (pos, commands) = rowop pss
    (newPos, newCommands) = colop y pos ps
    addCom = case newPos of
      Nothing -> []
      Just x -> if y == 1 then [] else [[y, x, y-1, x]]

colop :: Int -> Maybe Int -> [(Int, Int)] -> (Maybe Int, [[Int]])
colop _ _ [] = (Nothing, [])
colop y pos ((x,a):ps)
  | isOdd = case endP of
      Nothing -> (Just x, commands)
      Just x' -> (Nothing, newCommands x x' ++ commands)
  | otherwise = (endP, commands)
  where
    (endP, commands) = colop y pos ps
    isOdd | Just x == pos = a `mod` 2 == 0
          | otherwise     = a `mod` 2 == 1
    newCommands x1 x2 = [[y, x-1, y, x] | x <- [x2,x2-1..x1+1]]

bsReadInts :: B.ByteString -> [Int]
bsReadInts = map (fst . fromJust . B.readInt) . B.words

main = do
  cont <- B.getContents
  let [h, w] : ass = map bsReadInts (B.lines cont)
      (n, yss) = solve h w ass
  B.putStr $ B.unlines $ map (B.unwords . map (B.pack . show)) ([n] : yss)


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

using namespace std;

using ll = long long;
using ull = unsigned long long;

int main(int argc, char const *argv[]) {
	ll n,k;
	std::cin >> n >> k;

	if (k % 2 == 0) {
		std::cout << ll(pow(n / k , 3) + pow(n / (k / 2) - n / k, 3)) << '\n';
	}
	else {
		std::cout << ll(pow(n / k , 3)) << '\n';
	}
	return 0;
}


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

#ifndef DEBUG
#define endl '\n'
#define debug(...)
#else
#define debug(...) __VA_ARGS__
#endif
#define debugf(...) debug(printf(__VA_ARGS__);)

const int N = 1e5 + 5;



int (((((main)))))() <%
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    
    int n; cin >> n;
    string s, t;
    cin >> s >> t;

    for (int i = 0; i < n; i++) {
        cout << s[i] << t[i];
    }
    cout << endl;
    
    return 0;
%>

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	static int MAX = 100000;
	static int dp[] = new int[MAX + 10];

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		dp[0] = 0;

		for (int i = 1; i <= MAX; i++) {
			dp[i] = MAX;
			int power = 1;
			while (power <= i) {
				dp[i] = Math.min(dp[i], dp[i - power] + 1);
				power *= 6;
			}
			power = 1;
			while(power <= i) {
				dp[i] = Math.min(dp[i], dp[i - power] + 1);
				power *= 9;
			}
		}

		System.out.println(dp[N]);
	}
}

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

typedef long long ll;
#define mod 1000000007

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
int n, m;
vector<vector<int>> adj;
vector<int> dp;
vector<bool> vis;
void dfs(int u, int d){
    vis[u] = true;
    for(auto& e:adj[u]){
        if(!vis[e]){
            dfs(e, 1);
        }
        dp[u] = max(dp[u], 1 + dp[e]);
    }
}
void solve(){
    cin>>n>>m;
    adj.resize(n);
    dp.resize(n, 0);
    vis.resize(n, false);
    for(int i = 0; i < m; i++){
        int x1, y1;
        cin>>x1>>y1;
        adj[x1 - 1].push_back(y1 - 1);
        // adj[y1 - 1].push_back(x1 - 1);
    }
    // debug(adj);
    for(int i = 0; i < n; i++){
        if(!vis[i]){
            dfs(i, 0);
        }
    }
    cout<<*max_element(dp.begin(), dp.end());
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    // cin >> t;
    // pre();
    while (t--)
        solve();

    return 0;
}

Measured memory_bytes: 10980
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int field[10][10];
int sx[]={-1,0,0,0,1},sy[]={0,-1,0,1,0};
int bx[]={-2,-1,-1,-1,0,0,0,0,0,1,1,1,2},by[]={0,-1,0,1,-2,-1,0,1,2,-1,0,1,0};
bool f(int x,int y){
	return x>=0 && x<10 && y>=0 && y<10;
}
void small(int x,int y){
	for(int i=0;i<5;i++){
		if(f(x+sx[i],y+sy[i]))field[x+sx[i]][y+sy[i]]++;
	}
}
void middle(int x,int y){
	for(int i=-1;i<=1;i++){
		for(int j=-1;j<=1;j++){
			if(f(x+i,y+j))field[x+i][y+j]++;
		}
	}
}
void big(int x,int y){
	for(int i=0;i<13;i++){
		if(f(x+bx[i],y+by[i]))field[x+bx[i]][y+by[i]]++;
	}
} 
int main(){
	int x,y,size,ans=0,count=0;
	char com;
	for(int i=0;i<10;i++){
		for(int j=0;j<10;j++){
			field[i][j]=0;
		}
	}
	while(cin>>x>>com>>y>>com>>size){
		if(size==1)small(x,y);
		else if(size==2)middle(x,y);
		else big(x,y);
	}
	for(int i=0;i<10;i++){
		for(int j=0;j<10;j++){
			if(field[i][j]==0)count++;
			else ans=max(ans,field[i][j]);
		}
	}
	cout<<count<<endl<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1160
#include <cstdio>

const int maxn = 1e5 + 100;

int rt, m, n, nxt[maxn << 1], head[maxn], to[maxn << 1], sz[maxn], q[maxn], par[maxn], hs[maxn];
long long w[maxn << 1], ans, mn = 10000000000ll;

template<typename T>
bool chkmax(T &x, const T &y) {
    return x < y ? x = y, 1 : 0;
}

int centroid() {
    m = 0;
    q[m++] = 1;
    for (int i = 0; i < m; ++i) {
        int u = q[i];
        sz[u] = 1;
        hs[u] = 0;
        for (int j = head[u]; j; j = nxt[j]) {
            if(to[j] != par[u]) {
                par[q[m++] = to[j]] = u;
            }
        }
    }
    for (int i = n - 1; ~i; --i) {
        int u = q[i], v = par[u];
        chkmax(hs[u], n - sz[u]);
        if((hs[u] << 1) <= n) {
            return u;
        }
        sz[v] += sz[u];
        chkmax(hs[v], sz[u]);
    }
}

void dfs(int u, int p = 0, long long w = 0) {
    sz[u] = 1;
    for (int i = head[u]; i; i = nxt[i]) {
        if(to[i] != p) {
            dfs(to[i], u, ::w[i]);
            sz[u] += sz[to[i]];
        }
    }
    ans += w * sz[u] * 2;
    return;
}

int main() {
    scanf("%d", &n);
    for (int i = 1; i < n; ++i) {
        int u, v;
        long long x;
        scanf("%d%d%lld", &u, &v, &x);
        nxt[++m] = head[u];
        head[u] = m;
        to[m] = v;
        w[m] = x;
        nxt[++m] = head[v];
        head[v] = m;
        to[m] = u;
        w[m] = x;
    }
    rt = centroid();
    dfs(rt);
    for (int i = head[rt]; i; i = nxt[i]) {
        if((sz[to[i]] << 1) == n) {
            mn = w[i];
            break;
        }
        (w[i] < mn) && (mn = w[i]);
    }
    return !printf("%lld\n", ans - mn);
}

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

map<int, int> mp;
int s;

int solve();
int func(int x);

int main() {
  cin >> s;
  cout << solve() << endl;
  return 0;
}

int solve() {
  int ans = 1;
  ++mp[s];
  while(1) {
    ++ans;
    s = func(s);
    if(mp[s] != 0) break;
    ++mp[s];
  }
  return ans;
}

int func(int x) {
  if(x % 2 == 0) return x / 2;
  return 3 * x + 1;
}

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

struct F {
	long long a, b;
	F() {}
	F(long long _a, long long _b) : a(_a), b(_b) {}
	F operator + (const F &f) {
		long long x = a * f.a, y = b * f.a + a * f.b;
		long long g = __gcd(x, y);
		return F(x / g, y / g);
	}
	F operator - (const F &f) {
		long long x = a * f.a, y = b * f.a - a * f.b;
		long long g = __gcd(x, y);
		return F(x / g, y / g);
	}
	F operator * (const F &f) {
		long long x = a * f.a, y = b * f.b;
		long long g = __gcd(x, y);
		return F(x / g, y / g);
	}
	F operator / (const F &f) {
		long long x = a * f.b, y = b * f.a;
		long long g = __gcd(x, y);
		return F(x / g, y / g);
	}
};
const double pi = acos(-1);
const double eps = 1e-8;
inline int sign(double a) {
	return a < -eps ? -1 : a > eps;
}
inline int cmp(double a, double b) {
	return sign(a - b);
}
double add(double a, double b) {
	if (abs(a + b) < eps * (abs(a) + abs(b))) return 0;
	return a + b;
}
struct P {
	double x, y;
	P() {}
	P(double x, double y) : x(x), y(y) {}
	P operator + (const P &p) { return P(add(x, p.x), add(y, p.y)); }
	P operator - (const P &p) { return P(add(x, -p.x), add(y, -p.y)); }
	P operator * (double d) { return P(x * d, y * d); }
	P operator / (double d) { return P(x / d, y / d); }
	double dot(const P &p) { return add(x * p.x, y * p.y); }
	double det(const P &p) { return add(x * p.y, -y * p.x); }
	double alpha() { return atan2(y, x); }
	double abs() { return sqrt(abs2()); }
	double abs2() { return x * x + y * y; }
	P rot90() { P(-y, x); }
	P unit() { return *this / abs(); }
	bool operator < (P p) const {
		int c = cmp(x, p.x);
		if (c) return c == -1;
		return cmp(y, p.y) == -1;
	}
	friend istream& operator>>(istream &in, P &p) {
		in >> p.x >> p.y;
		return in;
	}
	friend ostream& operator<<(ostream& out, P &p) {
		out << p.x << ' ' << p.y;
		return out;
	}
};
P projection(P p1, P p2, P q) {
	P dir = p2 - p1;
	return p1 + dir * (dir.dot(q - p1) / dir.abs2());
}
double dist(const P &a, const P &b) {
	double x = a.x - b.x, y = a.y - b.y;
	return sqrt(x * x + y * y);
}
bool on_seg(P p1, P p2, P q) {
	return (p1 - q).det(p2 - q) == 0 && (p1 - q).dot(p2 - q) <= 0;
}
P intersection(P p1, P p2, P q1, P q2) {
	return p1 + (p2 - p1) * ((q2 - q1).det(q1 - p1) / (q2 - q1).det(p2 - p1));
}

int main() {
#ifdef LOCAL_DEFINE
	//freopen("data.in", "rt", stdin);
	//freopen("data.out", "w", stdout);
	auto _start = chrono::high_resolution_clock::now();
#endif

	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	P p1, p2;
	cin >> p1 >> p2;
	int q;
	cin >> q;
	while (q--) {
		P p;
		cin >> p;
		P ans = projection(p1, p2, p);
		cout << ans << '\n';
	}

#ifdef LOCAL_DEFINE
	auto _end = chrono::high_resolution_clock::now();
	cerr << "elapsed time: " << chrono::duration<double, milli>(_end - _start).count() << " ms\n";
#endif
	return 0;
}


Measured memory_bytes: 3300
#include<bits/stdc++.h>
using namespace std;
int n;
long long value[2][3];
long long dfs(long long capital, long long i, vector<pair<long long,long long>> &product){
  if(product.size() == 0) return capital;
  else if(i == product.size()-1) return capital/product[i].first*product[i].second + capital%product[i].first;
  long long ret=0;
  for(int j=0;j*product[i].first<=capital;j++) ret=max(ret,dfs(capital-j*product[i].first,i+1,product) + j*product[i].second);
  return ret;
}
int main(){
  cin >> n;
  for(int i=0;i<2;i++) for(int j=0;j<3;j++) cin >> value[i][j];
  vector<pair<long long,long long>> forth,back;
  for(int j=0;j<3;j++){
    if(value[0][j]<value[1][j]) forth.push_back({value[0][j],value[1][j]});
    if(value[0][j]>value[1][j]) back.push_back({value[1][j],value[0][j]});                                             
  }
  cout << dfs(dfs(n,0,forth),0,back) << endl;
}


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

typedef long long ll;

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
      cin.tie(0);
        ll n;
    cin>>n;
    set<string>s;
    ll flag=1;
    string prev="";
    while(n--)
    {
        string str;
        cin>>str;
        if(s.find(str)!=s.end())
        {
            flag=0;
        }
        ll alpha = prev.length();
        if(prev=="")
        {
            prev=str;
        }
        else
        {
            if(prev[alpha-1]!=str[0])
                flag=0;
            prev=str;
        }
        s.insert(str);
    }
    if(flag==0)
        cout<<"No";
    else
        cout<<"Yes";
    return 0;
}

Measured memory_bytes: 256
class UnionFind():
    def __init__(self, n):
        self.n=n
        self.parents=[-1]*n #各要素の親要素の番号を格納するリスト

    def find(self, x): #要素xが属するグループの根を返す
        if self.parents[x]<0:
            return x
        else:
            self.parents[x]=self.find(self.parents[x])
            return self.parents[x]

    def union(self,x,y): #要素xが属するグループと要素yが属するグループとを併合する
        x=self.find(x)
        y=self.find(y)

        if x==y:
            return

        if self.parents[x]>self.parents[y]:
            x,y=y,x

        self.parents[x]+=self.parents[y]
        self.parents[y]=x

    def size(self,x): #要素xが属するグループのサイズ（要素数）を返す
        return -self.parents[self.find(x)]

    def same(self,x,y): #要素x, yが同じグループに属するかどうかを返す
        return self.find(x)==self.find(y)

    def members(self,x): #要素xが属するグループに属する要素をリストで返す
        root=self.find(x)
        return [i for i in range(self.n) if self.find(i)==root]

    def roots(self): #すべての根の要素をリストで返す
        return [i for i, x in enumerate(self.parents) if x<0]

    def group_count(self): #グループの数を返す
        return len(self.roots())

    def all_group_members(self): #{ルート要素: [そのグループに含まれる要素のリスト], ...}の辞書を返す
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

#print(list(uf.all_group_members().values())) #グループ一覧を表示
#0-indexed n=5なら頂点の名前は0,1,2,3,4

n,m=map(int,input().split())
uf=UnionFind(n)
ans=0
a=[[int(i) for i in input().split()]for i in range(m)]

for i in a:
    x,y=i
    uf.union(x-1,y-1)
cnt=uf.group_count()

for i in range(m):
    uf_new=UnionFind(n)
    for j in range(m):
        x,y=a[j]
        if j==i:
            continue
        uf_new.union(x-1,y-1)
    cnt_new=uf_new.group_count()
    if cnt!=cnt_new:
        ans+=1
print(ans)
        

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;n>i;++i)
using namespace std;
using ll=int64_t;
using vi=vector<int>;
using VI=vector<ll>;
using vis=vector<string>;
using vvi=vector<vi>;
int main(){
    int n;
    cin>>n;
    cout<<(n-1)/2<<endl;
}

Measured memory_bytes: 3616
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int Y = sc.nextInt();
		
		
		for(int i = 0; i <= N; i++) {
			for(int j =0; j <= N-i; j++) {
				int k = N - (i + j);
				if(10000 * i + 5000 * j + 1000* k == Y){
					System.out.println(i + " " + j + " "+ k);
					return;
				}
			}
		}
		System.out.println("-1 -1 -1");	
	}
}


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

// ABC120B - K-th Common Divisor
// https://atcoder.jp/contests/abc120/tasks/abc120_b
void ABC120B() {
	int A, B, K;
	cin >> A >> B >> K;

	//vector<int> k(100); //サイズを宣言すると、その要素分だけ0で埋め尽くされる(←だと0～99まで0になる)
	vector<int> k;
	for(int i = 1; i <= 100; i++)
	{
		int a = A % i;
		int b = B % i;
		//cout << "a : " << a << endl;
		//cout << "b : " << b << endl;
		if (a != 0 || b != 0) {
			continue;
		}

		k.push_back(i);
		//printf("%dをkに追加\n",i);
	}

	sort(k.rbegin(), k.rend()); //降順

	//for (int i = 0; i < k.size(); i++)
	//{
	//	cout <<"k : " << k[i] << endl;
	//}
	cout << k[K - 1] << endl;
}


int main() {
	ABC120B();

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll MOD=1000000007;
const long double PI=3.1415926535;


int main() {
  ll N,ans=0;
  cin>>N;
  ll word[N][N];
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      word[i][j]=3;
    }
  }
  for(int i=0;i<N;i++){
    ll a;
    cin>>a;
    for(int j=0;j<a;j++){
      ll b,c;
      cin>>b>>c;
      word[i][b-1]=c;
    }
  }
  for(ll i=0;i<(1<<N);i++){
    bitset<15> bit(i);
    ll cnt=bit.count();
    for(int i=0;i<N;i++){
      if(bit[i]==0){
        continue;
      }
      for(int j=0;j<N;j++){
        if(word[i][j]==3){
          continue;
        }
        if(bit[i]==bit[j]&&word[i][j]==1){
          continue;
        }
        if(bit[i]!=bit[j]&&word[i][j]==0){
          continue;
        }
        goto END;
      }
    }
    ans=max(ans,cnt);
    END:;
  }
  cout<<ans;
    
}

Measured memory_bytes: 256