akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
using namespace std;
int main(void){
    int s;
    cin>>s;
    int P[1000]={};
    P[0]=s;
    for(int i=1;i<1000;i++){
        if(P[i-1]%2==0){
            P[i]=P[i-1]/2;
        }
        else{
            P[i]=P[i-1]*3+1;
        }
        for(int j=0;j<=i;j++){
            if(P[j]==P[i] & j!=i){
                cout<<i+1<<endl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long int a,b,n,i,a1,a2;
    cin>>a>>b>>n;
     i=n;
    while(i>=b)
    {
        i--;
    }
    a1=((a*i)/b);
    a2=(i/b);
    cout<<a1-a*a2;
    return 0;
}


Measured memory_bytes: 3564
import java.util.Scanner;

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

		int n = sc.nextInt();
		int d = sc.nextInt();
		int x = sc.nextInt();
		int cnt = 0;
		for (int i = 0; i < n; i++) {
			int a = sc.nextInt();
			for (int j = 1; j <= d; j += a) {
				cnt++;
			}
		}

		System.out.println(cnt + x);

		sc.close();
	}
}


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

int main(){
	int d,n;
	cin >> d >> n;
	if(n != 100)cout << (ll)(n * pow(100, d)) << endl;
	else cout << (ll)((n + 1) * pow(100, d)) << endl;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    long long ans = 0;
    for(int i = 0; i < n - 1; i++) {
        if(a[i] > a[i + 1]) {
            ans += a[i] - a[i + 1];
            a[i + 1] = a[i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4056
#include <cstdlib>
#include <iostream>
#include <typeinfo>
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
  char c1, c2, c3, c4;
  int a, b, c, d;
  cin >> c1 >> c2 >> c3 >> c4;
  a = c1 - '0';
  b = c2 - '0';
  c = c3 - '0';
  d = c4 - '0';
  int i, j, k;
  vector<char> op{'+', '-'};
  int sum = 0;
  bool ok = false;
  for (i = 0; i < 2; i++)
  {
    for (j = 0; j < 2; j++)
    {
      for (k = 0; k < 2; k++)
      {
        sum = a;
        if (i == 0)
        {
          sum += b;
        }
        else
        {
          sum -= b;
        }
        if (j == 0)
        {
          sum += c;
        }
        else
        {
          sum -= c;
        }
        if (k == 0)
        {
          sum += d;
        }
        else
        {
          sum -= d;
        }
        if (sum == 7)
        {
          ok = true;
          break;
        }
      }
      if (ok)
      {
        break;
      }
    }
    if (ok)
    {
      break;
    }
  }
  cout << a << op.at(i) << b << op.at(j) << c << op.at(k) << d << "=7" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <utility>
#include <string>
#include <cmath>
#include <set>
#include <functional>
#include <map>
#include <queue>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; ++i)
#define show(x) cout << #x << " = " << x << endl;
#define MAX_V 1005
typedef long long ll;
typedef pair<int,int> pii;
int main(){
    ll n,x;
    cin >> n >> x;
    vector<ll>a(n);
    vector<ll>b(n);
    ll ans = 0;
    rep(i,n){
        cin >> a[i];
        if(a[i]>x){
            
            ans += a[i]-x;
            a[i] = x;
            //show(ans);
        }
    }
    rep(i,n-1){
        b[i] = a[i]+a[i+1];
    }
    if(b[0]>x){
        if(b[0]-x>a[1]){
            b[1]=a[2];
            ans+=b[0]-x;
        }else{
            ans+=b[0]-x;
            b[1]-=b[0]-x;
        }
    }
    for(int i=1;i<n-1;i++){
        if(b[i]>x){
            ans+=b[i]-x;
            b[i+1]-=b[i]-x;
        }
    }
    cout << ans << endl;
}

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

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("3 4");
            //6
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("2 2");
            //1
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        int[] wkArr = InputList[0].Split(' ').Select(X => int.Parse(X)).ToArray();
        int n = wkArr[0];
        int m = wkArr[1];

        Console.WriteLine((n - 1) * (m - 1));
    }
}


Measured memory_bytes: 13780
#define _USE_MATH_DEFINES

#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <utility>
#include <climits>
#include <vector>
#include <map>
#include <queue>
#include <set>
using namespace std;

#define ll long long
const int MOD = 1000000007;//10^9+7
const string SPACE = " ";

ll powsur(ll a, ll b, ll p) {

	if (b == 0) {

		return 1;

	}
	else if (b % 2 == 0) {

		ll d = powsur(a, b / 2, p);
		return ((d%p)*(d%p)) % p;

	}
	else {

		return ((a%p)*powsur(a, b - 1, p) % p) % p;

	}

}
//pは素数,aのb乗をpで割った余り

ll CMOD(ll n, ll r, ll p) {

	ll a = 1, b = 1, c = 1, re;
	for (int i = 1; i <= n; i++) {

		a *= i;
		a = a%p;

	}
	for (int i = 1; i <= r; i++) {

		b *= i;
		b = b%p;

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

		c *= i;
		c = c%p;

	}
	b = powsur(b, p - 2, p);
	c = powsur(c, p - 2, p);
	re = ((a%p)*(b%p)) % p;
	re = ((re%p)*c%p) % p;

	return re;

}
//pは素数,(nCr)%p

ll gcd(ll a, ll b) {

	if (a > b) {

		ll tmp = a;
		a = b;
		b = tmp;

	}
	ll r;
	r = b%a;
	if (r == 0)return a;
	else return gcd(r, a);

}
//最大公約数

ll lcm(ll a, ll b) {

	return (a / gcd(a, b))*b;

}
//最小公倍数

ll MAX(ll a, ll b) {

	if (a > b)return a;
	else return b;

}
//MAX

ll MIN(ll a, ll b) {

	if (a < b)return a;
	else return b;

}
//MIN

bool p_judge(ll p) {

	if (p == 1)return false;
	else if (p == 2)return true;
	else {

		bool flag = true;
		for (int i = 2; i <= sqrt(p); i++) {

			if (p%i == 0) {

				flag = false;
				break;

			}

		}
		return flag;

	}

}
//素数判定,素数=true,合成数=false

int main() {

	int A, B, C, n[3];
	cin >> n[0] >> n[1] >> n[2];
	sort(n, n + 3);
	A = n[2];
	B = n[1];
	C = n[0];
	if ((A - (C + (A - B))) % 2 == 0) {
		
		cout << (A - B) + (A - (C + (A - B))) / 2 << endl;

	}
	else {

		cout << (A - B) + (A - (C + (A - B)) + 1) / 2 + 1 << endl;

	}

	return 0;
}

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

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

template <std::uint_fast64_t Modulus> class mod_int {
    using u64 = std::uint_fast64_t;

public:
    u64 val;

    constexpr explicit mod_int(const u64 x = 0) noexcept : val(x % Modulus) {}
    constexpr u64 &value() noexcept { return val; }
    constexpr const u64 &value() const noexcept { return val; }
    constexpr mod_int operator+(const mod_int rhs) const noexcept {
        return mod_int(*this) += rhs;
    }
    constexpr mod_int operator-(const mod_int rhs) const noexcept {
        return mod_int(*this) -= rhs;
    }
    constexpr mod_int operator*(const mod_int rhs) const noexcept {
        return mod_int(*this) *= rhs;
    }
    constexpr mod_int operator/(const mod_int rhs) const noexcept {
        return mod_int(*this) /= rhs;
    }
    constexpr mod_int &operator+=(const mod_int rhs) noexcept {
        val += rhs.val;
        if (val >= Modulus) {
            val -= Modulus;
        }
        return *this;
    }
    constexpr mod_int &operator-=(const mod_int rhs) noexcept {
        if (val < rhs.val) {
            val += Modulus;
        }
        val -= rhs.val;
        return *this;
    }
    constexpr mod_int &operator*=(const mod_int rhs) noexcept {
        val = val * rhs.val % Modulus;
        return *this;
    }
    constexpr mod_int &operator/=(mod_int rhs) noexcept {
        u64 exp = Modulus - 2;
        while (exp) {
            if (exp % 2) {
                *this *= rhs;
            }
            rhs *= rhs;
            exp /= 2;
        }
        return *this;
    }
};

const ll MOD=1e9+7;



void solve() {
    int N,M;
    cin >> N >> M;
    if (abs(N-M) >1) {
        cout << 0 << endl;
        return;
    }

    mod_int<MOD> a,b;
    a.val = 1;
    b.val = 1;
    mod_int<MOD> v;
    REPR(i,N) {
        v.val = i;
        if (i != 0) a*=v;
    }
    REPR(i,M) {
        v.val = i;
        if (i != 0) b*=v;
    }

    if (abs(N-M) ==0) {
        v.val = 2;
        a*=v;
    }

    cout << (a*b).val << endl;
}

int main() {
    solve();
    return 0;
}


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

using namespace std;


int gcd(int a, int b) {
    if(b == 0) return a;
    return gcd(b, a % b);
}



int main() {
    int A,B,C;
    cin >> A >> B >> C;

    if(A == B && B == C) {
        if(A % 2 == 0) {
            cout << "-1" << endl;
        } else {   
            cout << "0" << endl;
        }
    } else {
        int cnt = 0;
        for(cnt = 0; ; cnt++) {
            if(A % 2 != 0 || B % 2 != 0 || C % 2 != 0) break;
            int nA = (B + C) / 2;
            int nB = (A + C) / 2;
            int nC = (A + B) / 2;
            A = nA;
            B = nB;
            C = nC;
        }
        cout << cnt << endl;
    }


    
}



Measured memory_bytes: 256
import itertools
import collections

N = input()

if int(N) < 100:
    print(0)
    exit()

product_list = []
for i in range(3,len(N)+1):
    product_list += list(itertools.product('753', repeat=i))

res = 0

for i in product_list:
    num = "".join(list(i))
    if int(N) < int(num):
        continue
    if num.count('5') > 0 and num.count('7') > 0 and num.count('3') > 0:
        res += 1

print(res)

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

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    vector<pair<int, int>> p;
    rep(i, N) {
        cin >> A[i];
        p.emplace_back(A[i], i);
    }
    sort(p.begin(), p.end());
    rep(i, N) {
        if (i) cout << " ";
        cout << p[i].second+1;
    }
    cout << endl;

}


Measured memory_bytes: 2164
#include<bits/stdc++.h>
using namespace std;
template<class T>
using PAIR = pair<T,T>;
template<class T>
using vec = vector<T>;
template<class T>
using maps = map<string, T>;
template<class T>
using mapi = map<int, T>;
using ll = long long;
int main(){int N;
    cin >> N;
    vector<int>A;
    vector<int>B;
    vector<int>C;
    for(int i = 0;i < N;i++){
        int x;
        cin >> x;
        A.push_back(x);
    }
    for(int i = 0;i < N;i++){
        int x;
        cin >> x;
        B.push_back(x);
    }
    for(int i = 0;i < N-1;i++){
        int x;
        cin >> x;
        C.push_back(x);
    }
    int ans = 0;
    for(int i = 0;i < N;i++){
        ans+=B[A[i]-1];
        if(i != N-1 && A[i]+1 == A[i+1]){
            ans+=C[A[i]-1];
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
	int n,t;
	cin >> n;
	vector<int> pAry(n);
	vector<int> pArys(n);
	int total = 0;
	for (int i = 0; i < n; i++)
	{
		cin >> t;
		if(t != i + 1)total++;

		
	}

	if(total == 0 || total == 2 ){
		cout << "YES" << endl;
	}
	else{ 
		cout << "NO" << endl;
	}
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

D = int(input())
C = list(map(int, input().split()))
L = [0 for _ in range(26)]

for _ in range(1,D+1):
  S = list(map(int, input().split()))
  contest_index = -1
  contest_manzoku = -10**9
  for i in range(26):
    i_manzoku = S[i]+C[i]+L[i]
    if i_manzoku > contest_manzoku:
      contest_index = i
      contest_manzoku = i_manzoku
  print(contest_index+1)
  for i in range(26):
    if i==contest_index:
      L[i] = 0
    else:
      L[i] += C[i]

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

typedef long long ll;

ll md = 1000000007;

vector<ll> a;
vector<ll> x;

int main(int, char**) 
{
	ll n;
	std::cin >> n;
	double x = n;
	double y = sqrt(x);
	ll s = floor(y);
	for (int i = s; i > 0; i--) {
		if (n % i == 0) {
			ll t = n / i;
			// cerr << "t=" << t << ", i=" <<  i << endl;
			cout << (t -1 + i - 1) << endl;
			return 0;
		}
	}
	
	return 0;
}


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

class Trees{
  vector<int> par;
  vector<int> rank;
  vector<int> size;
  
  public:
  int root(int i){
    int rt;
    if(par[i]==i){rt=i;rank[i]=1;}
    else{rt=root(par[i]);par[i]=rt;rank[i]=2;}
    return rt;
  }
  void unite(int i,int j){
    int rki=rank[i];int rkj=rank[j];
    if(rki<rkj){par[root(i)]=root(j);rank[i]++;}
    else{par[root(j)]=root(i);rank[j]++;}
  }
  bool same(int i,int j){
    return root(i)==root(j);
  }

  Trees(int n){
    for(int i=0;i<n;i++) {par.push_back(i);rank.push_back(1);size.push_back(0);}
  }
  void sizeinit(){
    for(int i=0;i<size.size();i++)size[i]=0;
    for(int i=0;i<size.size();i++)size[root(i)]+=1;
  }
  int getsize(int i){return size[root(i)];}
};

int main(){
  int N,M,K;cin>>N>>M>>K;
  Trees tree(N);
  vector<int>A(M),B(M),C(K),D(K);
  for(int i=0;i<M;i++){
    int a,b;cin>>a>>b;A[i]=a-1;B[i]=b-1;
    tree.unite(a-1,b-1);
  }
  for(int i=0;i<K;i++){
    int c,d;cin>>c>>d;C[i]=c-1;D[i]=d-1;
  }
  vector<int>ans(N,-1);
  for(int i=0;i<M;i++){
    if(tree.same(A[i],B[i])){
      ans[A[i]]--;ans[B[i]]--;
    }
  }
  for(int i=0;i<K;i++){
    if(tree.same(C[i],D[i])){
      ans[C[i]]--;ans[D[i]]--;
    }
  }
  tree.sizeinit();
  for(int i=0;i<N;i++)cout<<ans[i]+tree.getsize(i)<<" ";
}

/*




友達繋がってればいい?

bitsetもNが大きいとO(N)になる


出力がN人分になるとそれぞれで友達候補を出すのでダメ
最初からbitsetにしたい??





*/

Measured memory_bytes: 4204
import collections

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

C = collections.Counter(L)

def cmb(n):
    return n * (n-1) // 2

ans = 0
for key in C:
    a = cmb(C[key])    
    ans += a
    
for i in L:
    x = C[i] -1
    y =  cmb(C[i]) - cmb(x) 
    print(ans - y)

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

string s;

int main() {
	
	getline(cin,s);
	int len=s.length()-1;
	
	int ans1=0,ans2=0;
	for(int i=0;i<=len;i++) {
		if (i&1) {
			if (s[i] == '0') ans1++;
		}
		else  {
			if (s[i] == '1') ans1++;
		}
	}
	
	for(int i=0;i<=len;i++) {
		if (i&1) {
			if (s[i] == '1') ans2++;
		}
		else  {
			if (s[i] == '0') ans2++;
		}
	}
	
	printf("%d",min(ans2,ans1));
	
	return 0;
}

Measured memory_bytes: 512
import std.stdio, std.algorithm, std.string, std.conv, std.array, std.range, std.math;
int readint() { return readln.chomp.to!int; }
int[] readints() { return readln.split.to!(int[]); }

bool is_prime(int x) {
    for (int i=2; i*i<=x; i++) if(x % i == 0) return false;
    return x != 1;
}

int[] make_primes() {
    int[] a;
    foreach(i; 5..55555+1) if(is_prime(i)) a ~= i;
    return a;
}

void main() {
    int n = readint();
    int[] ans = make_primes.filter!(x => x%5 == 1).array;
    writefln("%(%s %)", ans[0..n]);
}

Measured memory_bytes: 380
#include <cstdio>
#include <algorithm>
#include <vector>

class Node {
public:
    int location;
    int p, l, r;
    Node() {}
};

class Point {
public:
    int id, x, y;
    Point() {}
    Point(int id, int x, int y): id(id), x(x), y(y) {}
    bool operator < (const Point &p) const {
        return id < p.id;
    }
    void print() {
        printf("%d\n", id);
    }
};

const int MAX = 1000000;
const int NIL = -1;

int N;
Point P[MAX];
Node T[MAX];
int np;

bool lessX(const Point &p1, const Point &p2) { return p1.x < p2.x; }
bool lessY(const Point &p1, const Point &p2) { return p1.y < p2.y; }

int makeKDTree(int l, int r, int depth) {
    if (!(l < r)) return NIL;
    int mid = (l + r) / 2;
    int t = np++;
    if (depth % 2 == 0) {
        std::sort(P + l, P + r, lessX);
    } else {
        std::sort(P + l, P + r, lessY);
    }
    T[t].location = mid;
    T[t].l = makeKDTree(l, mid, depth + 1);
    T[t].r = makeKDTree(mid + 1, r, depth + 1);

    return t;
}

void find(
    int v,
    int sx,
    int tx,
    int sy,
    int ty,
    int depth,
    std::vector<Point> &ans
) {
    int x = P[T[v].location].x;
    int y = P[T[v].location].y;

    if (sx <= x && x <= tx && sy <= y && y <= ty) {
        ans.push_back(P[T[v].location]);
    }

    if (depth % 2 == 0) {
        if (T[v].l != NIL) {
            if (sx <= x) find(T[v].l, sx, tx, sy, ty, depth + 1, ans);
        }
        if (T[v].r != NIL) {
            if (x <= tx) find(T[v].r, sx, tx, sy, ty, depth + 1, ans);
        }
    } else {
        if (T[v].l != NIL) {
            if (sy <= y) find(T[v].l, sx, tx, sy, ty, depth + 1, ans);
        }
        if (T[v].r != NIL) {
            if (y <= ty) find(T[v].r, sx, tx, sy, ty, depth + 1, ans);
        }
    }
}

int main() {
    int x, y;
    scanf("%d", &N);
    for (int i = 0; i < N; i++) {
        scanf("%d %d", &x, &y);
        P[i] = Point(i, x, y);
        T[i].l = T[i].r = T[i].p = NIL;
    }

    np = 0;

    int root = makeKDTree(0, N, 0);

    int q;
    scanf("%d", &q);
    int sx, tx, sy, ty;
    std::vector<Point> ans;
    for (int i = 0; i < q; i++) {
        scanf("%d %d %d %d", &sx, &tx, &sy, &ty);
        ans.clear();
        find(root, sx, tx, sy, ty, 0, ans);
        std::sort(ans.begin(), ans.end());
        for (int j = 0; j < ans.size(); j++) {
            ans[j].print();
        }
        printf("\n");
    }

    return 0;
}


Measured memory_bytes: 15932
#include <cstdio>

int main(void) {
    int A, B;
    std::scanf("%d", &A);
    std::scanf("%d", &B);
    if (A >= 13) {
        printf("%d", B);
    } else if (A >= 6) {
        printf("%d", B / 2);
    } else {
        printf("%d", 0);
    }
    return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e14;
typedef long long ll;
typedef long double ld;
typedef pair <ll, ll> pii;

void faster()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

const ll MAXN = 1e6 + 10;
const ll N = 4000 + 10;
const ll MN = 200 + 10;
const ll mod = 1e6;

ll w[MAXN] , a[MAXN] , dp[110][N * 100] , prefix[MAXN];

int main()
{
	faster();
	ll n, W;
	cin >> n >> W;
	for (int i = 0; i < n; i++)
	{
		cin >> w[i + 1] >> a[i + 1];
		prefix[i + 1] = prefix[i] + a[i + 1];
	}
	for (int i = 1; i <= n; i++)
	{
		for (ll j = 1; j <= prefix[n]; j++)
			dp[i][j] = inf;
	}
	for (int j = 1; j <= prefix[n]; j++)
		dp[0][j] = inf;
	dp[0][0] = 0;
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= prefix[i]; j++)
		{
			if(j >= a[i])
				dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - a[i]] + w[i]);
			else
				dp[i][j] = dp[i - 1][j];
		}
	}
	for (int i = prefix[n]; i >= 0; i--)
	{
		if(dp[n][i] <= W)
		{
			cout << i << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 289152
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
#define m 1000000007
#define dd double
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,b) for(int i=1;i<=b;i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define F first
#define S second
int main() 
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int p,q,r,n,i,d,sum=0;
	cin>>n;
	for(p=1;p<=n;++p)
		for(q=1;q<=n;++q)
			for(r=1;r<=n;++r)
			{
				d=1;
				i=1;
				while(i<=p&&i<=q&&i<=r){
				if(p%i==0 && q%i==0 && r%i==0)
					d=i;
				i++;
				}
				sum+=d;
			}
	cout<<sum;
}

Measured memory_bytes: 3644
#include <stdio.h>

int partition(int A[],int p,int r){
	int x = A[r];
	int temp;
	int i = p-1;
	for(int j = p; j < r; j++){
		if(A[j] <= x){
			i++;
			temp = A[j];
			A[j] = A[i];
			A[i] = temp;
		}
	}
	temp = A[i+1];
	A[i+1] = A[r];
	A[r] = temp;
	return i + 1;
}

int main(void) {
	int num;
	int arr[10000000];
	scanf("%d",&num);
	for(int i = 0; i < num; i++)scanf("%d",&arr[i]);
	int x = partition(arr,0,num-1);
	for(int i = 0; i < num;){
		if(i == x){
			printf("[%d]",arr[i]);
		}else{
			printf("%d",arr[i]);
		}
		if(num > ++i){
			printf(" ");
		}else{
			printf("\n");
		}
	}
	return 0;
}



Measured memory_bytes: 2148
#include<iostream>
#include<string>
using namespace std;
int main(){
	int n;
	cin >> n;
	string a, b, c;
	cin >> a >> b;
	c = a.at(0);
	c += b.at(0);
	for (int i = 1; i < n; i++){
		c += a.at(i);
		c += b.at(i);
	}
	cout << c << endl;
}

Measured memory_bytes: 256
#pragma GCC optimze("Ofast")
#include <bits/stdc++.h>

using namespace std;

#ifndef aa
#define trace(...)
#define endl '\n'
#endif
#define pb push_back
# define ub upper_bound
#define lb lower_bound
#define fi first
#define se second
#define int long long
typedef long long ll;
typedef long double ld;
#define double long double
#define pii pair<int,int>
#define pdd pair<double,double>
#define pll pair<ll,ll>
#define sz(x) ((long long)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define frev(a,b,c) for(int a=c; a>=b; a--)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define trav(a,x) for(auto &a:x)
#define all(con) con.begin(),con.end()
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;
//mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());
//const int mod = 998244353;
const int mod = 1000000007;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef map<int, int> mii;
typedef set<int> si;
typedef queue<int> qi;


const int N = 2e5 + 5;



void solve() {

	int n;
	cin >> n;
	vi a(n), b(n);
	fr(i, 0, n - 1)
		cin >> a[i] >> b[i];
	sort(all(a));
	sort(all(b));
	if (n % 2 == 0) {
		int x = n / 2;
		cout << (b[x] + b[x - 1] - a[x] - a[x - 1] + 1) << endl;
		return;
	}
	int x = n / 2;
	cout << b[x] - a[x] + 1 << endl;

}


signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//srand(chrono::high_resolution_clock::now().time_since_epoch().count());
	cout << fixed << setprecision(15);
	int t = 1;
	//cin >> t;

	while (t--)
		solve();
#ifdef aa
	cout << endl << endl << endl << endl << "Time elapsed: " << (double)(clock() - clk) / CLOCKS_PER_SEC << endl;
#endif
	return 0;
}


int norm(int a) {
	while (a >= mod) a -= mod;
	while (a < 0) a += mod;
	return a;
}

int powm(int a, int b) {
	int res = 1;
	while (b) {
		if (b & 1)
			res = (res * a) % mod;
		a = (a * a) % mod;
		b >>= 1;
	}
	return res;
}


int divide(int a, int b) {
	return (a % mod) * powm(b, mod - 2) % mod;
}


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

int main(){
	int a, b;
	while(cin >> a >> b && !(a == 0 && b == 0)){
		int num = 0;
		for(int i = 1; i <= a-2; i++){
			for(int j = i+1; j <= a-1; j++){
				for(int k = j+1; k <= a; k++){
					if(i+j+k == b)
						num++;
				}
			}
		}
		cout << num << endl;
	}
	return 0;
}


Measured memory_bytes: 3048
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define For(i,j,k)	for(int i=j;i<=k;++i)
#define Dow(i,j,k)	for(int i=k;i>=j;--i)
#define ll long long
#define inf 1e8
using namespace std;
inline ll read()
{
	ll t=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')	c=getchar();}
	while(c>='0'&&c<='9')	t=t*10+c-48,c=getchar();
	return t*f;
}
struct mmp{int l,r;}	p[20001];
inline bool cmp(mmp x,mmp y){return x.l<y.l;}
int n,q[10001],top,ans,hz[10001];
char a[10001],b[10001];
inline int get_lower(int x)
{
	int l=1,r=top,ans=-1;
	while(l<=r)
	{
		int mid=l+r>>1;
		if(q[mid]<=x)	ans=mid,l=mid+1;else	r=mid-1;
	}
	if(ans==-1)	return -1;
	return q[ans];
}
inline int get_upper(int x)
{
	int l=1,r=top,ans=-1;
	while(l<=r)
	{
		int mid=l+r>>1;
		if(q[mid]>=x)	ans=mid,r=mid-1;else	l=mid+1;
	}
	if(ans==-1)	return -1;
	return q[ans];
}
inline void solve(int &ANS,int yuan,int x,int zuo,int you)
{
	int tans=0;
	tans=abs(yuan-you)+abs(you-zuo)+abs(zuo-x);
	tans=min(tans, abs(yuan-zuo)+abs(zuo-you)+abs(you-x) );
	ANS=tans;
}
inline void doit(int L,int R)
{
	int tep=n+1-L+R;
	int cnt=0,tans=0;
	For(i,tep,tep+n-1)
	{
		if(a[i-tep+1]==b[i])	continue;
		tans++;
		if(a[i-tep+1]=='0')	continue;
		int tl=i-get_lower(i),tr=get_upper(i)-i;
		if(tl==i+1)	tl=inf;if(tr==-(i+1))	tr=inf;
		p[++cnt].l=tl;p[cnt].r=tr;
	}
	sort(p+1,p+cnt+1,cmp);hz[cnt+1]=0;
	Dow(i,1,cnt)	hz[i]=max(hz[i+1],p[i].r);
	int ANS=inf,QL=0,QR=0,QANS=0;
	For(i,0,cnt)
	{
		QL=p[i].l;QR=hz[i+1];
		QL=max(QL,0);QR=max(QR,0);
		solve(QANS,n+1,tep,tep-QL,tep+QR);
		ANS=min(ANS,QANS+tans);
	}
	ans=min(ANS,ans);
}
int main()
{
	scanf("\n%s",a+1);
	scanf("\n%s",b+1);
	n=strlen(b+1);
	ans=inf;
	For(i,1,n)	b[n+i]=b[2*n+i]=b[i];
	For(i,1,3*n)	if(b[i]=='1')	q[++top]=i;
	For(i,0,n)	doit(i,0);
	For(i,1,n)	doit(0,i);
	if(ans==inf)	puts("-1");else cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<math.h>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<map>
#include<numeric>
#define rep(i,n) for(int i=0;i<n;++i)
#define yes cout<<"Yes"<<endl
#define no cout<<"No"<<endl
#define mod 1000000007
using namespace std;
using ll = long long;
int main() {
	int N;	cin >> N;
	vector<int> a(N);
	int ans = 0;
	rep(i, N)cin >> a[i];
	rep(i, N) {
		while (a[i] % 2 == 0) {
			a[i] /= 2;
			++ans;
		}
	}
	cout << ans << endl;
	cin >> N;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const int vx[]={1,0,-1,0}, vy[]={0,1,0,-1};
const ll LINF=1e18;
const ld PI=abs(acos(-1));

map<int, int> mp;

int main(){
	int n; cin >> n;
	REP(i,0,n){
		int a; cin >> a;
		mp[a]++;
	}
	int m; cin >> m;
	REP(i,0,m){
		int a; cin >> a;
		mp[a]--;
	}
	
	for(auto s:mp){
		if(s.second < 0){
			cout << "NO" << endl;
			return 0;
		}
	}
	
	cout << "YES" << endl;
	return 0;
}


Measured memory_bytes: 9600
s = input()
t = input()

ok = False
if s == t:
    print("Yes")
    ok = True
if not ok:
    for i in range(1, len(s)):
        # print(i)
        tmp = s[-i:] + s[:-i]
        # print(tmp)
        if tmp == t:
            print("Yes")
            ok = True
            break
if not ok:
    print("No")

Measured memory_bytes: 3060
a, b, c, x, y = map(int, input().split())

price = 0
if c >= (a + b) / 2:
    price += a * x + b * y

elif x <= y:
    price += c * 2 * x
    if b >= c * 2:
        price += c * 2 * (y - x)
    else:
        price += b * (y - x)

else:
    price += c * 2 * y
    if a >= c * 2:
        price += c * 2 * (x - y)
    else:
        price += a * (x - y)

print(price)



Measured memory_bytes: 3064
#include <stdio.h>

int main() {
  int N, M;
  int A[100];

  scanf("%d %d", &N, &M);
  for (int i = 0; i < N; i++)
    scanf("%d", &A[i]);
  
  // calculate
  int total = 0;
  for (int i = 0; i < N; i++)
    total = total + A[i];

  // count selectable item
  int count = 0;
  for (int i = 0; i < N; i++)
  {
    if (A[i] >= total / (4.0 * M))
      count = count + 1;
  }  

  if (count >= M)
    printf("Yes\n");
  else
    printf("No\n");
  
  return 0;
}

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

int main() {
	int n;
	std::cin >> n;
	
	// setではい
	std::set<int> se;
	for (int i = 0; i < n; i++) {
		int d;
		std::cin >> d;
		se.insert(d);
	}

	std::cout << se.size() << std::endl;
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

string cake[300];
int ans[300][300];

signed main() {
	int h, w, k; cin >> h >> w >> k;
	for (int i = 0; i < h; ++i)
		cin >> cake[i];

	// h_idx : 最後にイチゴを見たのが上から何行目か
	int h_idx = -1, idx = 1;
	for (int i = 0; i < h; ++i) {
		// 横一直線にイチゴがあるかないか
		bool exist = false;
		for (int j = 0; j < w; ++j)
			if (cake[i][j] == '#')
				exist = true;
		if (!exist) continue;
		// イチゴのある場合
		bool first_s = false;
		for (int j = 0; j < w; ++j) {
			if (j == 0 || cake[i][j] == '#') ++idx;
			if ((!first_s) && cake[i][j] == '#') {
				first_s = true;
				if (j != 0) --idx;
			}
			if (h_idx == -1 && j == 0) idx = 1;
			for (int ii = h_idx + 1;ii <= i; ++ii)
				ans[ii][j] = idx;
		}
		h_idx = i;
	}
	for (int i = h_idx + 1; i < h; ++i)
		for (int j = 0; j < w; ++j)
			ans[i][j] = ans[h_idx][j];
	
	for (int i = 0; i < h; ++i) {
		for (int j = 0; j < w; ++j)
			cout << ans[i][j] << " ";
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=1e18;



// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
}comb(200005);


//nPk
 mint f(int n, int k) {
    if (n < 0) return 0;
    // nPk = nCk * k!
    mint res = comb(n,k);
    res *= comb.fact[k];
    return res;
}




//組み合わせの数nCrを計算
   int calcNumOfCombination(int n, int r){
       int num = 1;
       for(int i = 1; i <= r; i++){
           num = num * (n - i + 1) / i;
       }
       return num;
   }


int main() {
  ll h,w,n;
  cin>>h>>w>>n;
  vector<P> g(n);
  rep(i,n){
    ll r1,c1;
    cin>>r1>>c1;
    r1--;c1--;
    g[i]=make_pair(r1,c1);
  }
sort(g.begin(),g.end());
  mint dp[n+5];
  //mint test=comb(6,2);
  //cout<<test;
  rep(i,n){
  //  cout<<"i"<<i<<endl;
    ll r1=g[i].first;
    ll c1=g[i].second;
  //  cout<<"r"<<r1<<"c"<<c1<<endl;

    mint now=comb(r1+c1,r1);
  //  cout<<now<<endl;


    rep(j,n){
      ll r2=g[j].first;
      ll c2=g[j].second;
      if (r2>r1 or c2>c1)continue;
      mint temp=dp[j]*comb((r1-r2+c1-c2),r1-r2);
      now-=temp;
    }
  //  cout<<now<<endl;
    dp[i]=now;

  }
  mint ans=comb(h+w-2,w-1);
//  cout<<ans<<endl;
  rep(i,n){
    ll hnow=h-1-g[i].first;
    ll cnow=w-1-g[i].second;

    mint temp=comb(hnow+cnow,hnow);
    temp*=dp[i];
    ans-=temp;
  }
  cout<<ans<<endl;

}


Measured memory_bytes: 6220
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<usize>();
    let mut d = HashSet::new();
    for i in 0..n {
        d.insert(read::<usize>());
    }
    println!("{}", d.len());
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
//cout << fixed << setprecision(8) << a << endl;
#define Fast_Input ios_base :: sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
#define pb push_back
#define mem(a, b)     memset(a, b, sizeof(a))
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef long long ll;
typedef tree<int,null_type,greater<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
/*sort(v.begin(), v.end(),
     [](const pair<int, int>& x, const pair<int, int>& y)
{
    if (x.first != y.first)
        return x.first < y.first;
    return x.second < y.second;
});
*/
int const fx[]= {+1,+0,-1,+1};
int const fy[]= {-1,+1,+0,+0};
const int inf = numeric_limits<int>::max();
const int mx=1e9;
const int mod=1e9+7;
int main()
{
    ll x,k,d,y;
    cin >> x >> k >> d;
    x=abs(x);
    y=x/d;
    if(k<=y)
    {
        y=min(y,k);
        cout << x-(y*d) << endl;
    }
    else
    {
        ll z=k-y;
        x-=(y*d);
        if(z%2==0)cout << x << endl;
        else
        {
            ll w=x+d;
            ll u=abs(x-d);
            cout << min(w,u) << endl;
        }
    }
    return 0;
}




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

#define REP(i, n) for(int (i) = 0; (i) < (n); ++(i))
#define REPR(i, n) for(int (i) = (n); (i) >= 0; --(i))
#define FOR(i, n, m) for(int (i) = (n); (i) < (m); ++(i))

constexpr int INF = 1e9;
// constexpr ll INF = 1LL<<61;
constexpr ll mod = 1e9+7;

bool cmp(pair<int, int> l, pair<int, int> r){
  return l.second > r.second;
}

int main(){
  int N;
  cin >> N;
  vector<string> S(N);
  vector<pair<int, int>> zen, kou;
  REP(i, N){
    cin >> S[i];
    int right = 0, left = 0;
    REP(j, (int)S[i].size()){
      if(S[i][j] == '('){
        right++;
      }
      else{
        if(right){
          right--;
        }
        else{
          left++;
        }
      }
    }
    if(right - left >= 0){
      zen.push_back({left, right});
    }
    else{
      kou.push_back({left, right});
    }
  }
  sort(zen.begin(), zen.end());
  sort(kou.begin(), kou.end(), cmp);
  vector<pair<int,int>> pr = zen;
  pr.insert(pr.end(), kou.begin(), kou.end());
  string ans = "Yes";
  int cnt = 0;
  REP(i, (int)pr.size()){
    cnt -= pr[i].first;
    if(cnt < 0){
      ans = "No";
    }
    cnt += pr[i].second;
  }
  if(cnt != 0){
    ans = "No";
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 54036
h, w = gets.chomp.split(' ').map(&:to_i)
array = []
h.times do
  array << gets.chomp.split('')
end

h.times do |i|
  w.times do |j|
    next if array[i][j] != ?#
    if ((i == 0) || (array[i-1][j] != ?#)) && ((i == h - 1) || (array[i+1][j] != ?#)) && ((j == 0) || (array[i][j-1] != ?#)) && ((j == w - 1) || (array[i][j+1] != ?#))
      puts 'No'
      exit
    end
  end
end

puts 'Yes'

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

int main(){
    int N,M;
    cin >> N >> M;
    vector<int> a(M);
    vector<int> b(M);
    rep(i,M){
        cin >> a.at(i) >> b.at(i);
    }
    vector<int> num(N);
    rep(i,N){
        num.at(i)=i+1;
    }
    sort(num.begin(),num.end());
    int ans=0;
    bool bflag=false;
    bool aflag=false;
    do{
        if(num.at(0)!=1){
            break;
        }
        aflag=true;
        bflag=false;
        rep(i,N-1){
            bflag=false;
            rep(j,M){
                if((num.at(i)==a.at(j)&&num.at(i+1)==b.at(j))
                ||num.at(i)==b.at(j)&&num.at(i+1)==a.at(j)){
                    bflag=true;
                    break;
                }
            }
            if(bflag){ 
                continue;
            }else{
                aflag=false;
                break;
            }
            
        }
        if(aflag){
            ans++;
        }
    }while(next_permutation(num.begin(),num.end()));

    cout << ans << endl;
}

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

const int MOD = 1e9 + 7;
const int MAXN = 112345;

int n;
string s;
bool possible = false;
int v[MAXN];
int ans[MAXN];

inline bool query(int pos){
	if(v[pos] == 0) return (s[pos] == 'o'); // sheep
	return (s[pos] != 'o'); // wolf
}

void solve(int test){
	
	bool failed = false;
	
	for(int i = 0 ; i < n ; i ++){
		
		int prev = (i ? i - 1 : n - 1);
		int nxt = (i == n - 1 ? 0 : i + 1);
		
		if(query(i)){
			
			if(v[prev] != -1 && v[nxt] != -1){
				if(v[prev] != v[nxt]){
					failed = true;
					break;
				}
			} else if(v[prev] != -1){
				v[nxt] = v[prev];
			} else if(v[nxt] != -1){
				v[prev] = v[nxt];
			} else {
				v[prev] = v[nxt] = test;
			}
			
		} else {
			
			if(v[prev] != -1 && v[nxt] != -1){
				if(v[prev] == v[nxt]){
					failed = true;
					break;
				}
			} else if(v[prev] != -1){
				v[nxt] = v[prev] ^ 1;
			} else if(v[nxt] != -1){
				v[prev] = v[nxt] ^ 1;
			} else {
				v[prev] = test;
				v[nxt] = test ^ 1;
			}
		}
	}
	
	if(!failed){
	//	cout << "success ";
	//	cout << test << "\n";
		possible = true;
		for(int i = 0 ; i < n ; i ++)
			ans[i] = v[i];
		
	}
	
	return;
}

int main(){
	
	ios_base :: sync_with_stdio(false);
	cin.tie(0);
	
	cin >> n;
	cin >> s;
	
	// assume first position is sheep
	memset(v, -1, sizeof v);
	v[0] = 0;
	solve(0);
	
	memset(v, -1, sizeof v);
	v[0] = 0;
	solve(1);
	
	// assume first position is wolf
	memset(v, -1, sizeof v);
	v[0] = 1;
	solve(0);
	
	memset(v, -1, sizeof v);
	v[0] = 1;
	solve(1);
	
	if(!possible){
		cout << "-1\n";
		return 0;
	}
	
	for(int i = 0 ; i < n ; i ++){
		if(ans[i] == 0) cout << "S";
		else cout << "W";
	}
	
	cout << "\n";
	
	return 0;
}

Measured memory_bytes: 4624
N = int(input())
ans = [0]*(N-1)

edge = [[] for _ in range(N)]

for i in range(N-1):
    a,b = map(int,input().split())
    edge[a-1].append([b-1,i])
    edge[b-1].append([a-1,i])

print(max([len(x) for x in edge]))

que = [[0,0]]
while(que):
    p_num,p_color = que.pop()
    color = 1
    for c_num,edgenum in edge[p_num]:
        if ans[edgenum] != 0:
            continue
        if color == p_color:
            color += 1
        ans[edgenum] = color
        que.append([c_num,color])
        color += 1
for i in range(N-1):
    print(ans[i])


Measured memory_bytes: 83616
from collections import deque
S = input()
Q = int(input())
left = deque()
right = deque()
rotate = 1
for i in range(Q):
    n = [str(i) for i in input().split()]
    if n[0] == "1":
        rotate *= -1
    else:
        if n[1] == "1":
            if rotate == 1:
                left.appendleft(n[2])
            else:
                right.append(n[2])
        else:
            if rotate == 1:
                right.append(n[2])
            else:
                left.appendleft(n[2])
left = list(left)
right = list(right)
ans = "".join(left)
ans += S
ans += "".join(right)
if rotate == 1:
    print(ans)
else:
    print(ans[::-1])

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

int main(){
	int N,M; cin>>N>>M;
	string T(N,'-');
	rep(i,M){
		int s,c; cin>>s>>c; s--, c+='0';
		if(T[s] !='-' && T[s] != c){ puts("-1"); return 0; }
		if(N!=1 && s==0 && c=='0'){ puts("-1"); return 0; }
		T[s] = c;
	}

	int ans = INT_MAX;
	rep(i,1000){
		string A = to_string(i);
		if(A.size() != N) continue;
		bool exist = true;
		rep(j,N) if(T[j]!='-' && T[j]!=A[j]){ exist = false; break; }
		if(exist) ans = min(ans, i);
	}
	cout<< ans <<endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
const int inf=0x3f3f3f3f;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	long long a,b;
	cin>>a>>b;
	cout<<a*b<<endl;
	return 0;
}




Measured memory_bytes: 3648
/*
    Problem 86
    https://atcoder.jp/contests/abc075/tasks/abc075_c
*/
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* class */
class DisjointSet {
public:
    vector<int> d;
    DisjointSet (int size) {d.assign(size, -1);}
    int find(int x) { return (d[x] < 0) ? x : d[x] = find(d[x]); }
    bool unite(int x, int y) {
        x = find(x), y = find(y);
        if (x == y) return false;
        if (d[x] > d[y]) swap(x, y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x, int y) {return find(x) == find(y);}
    int size(int x) {return -d[find(x)];}
};
/* global variables */
/* function */
/* main */
int main(){
    int N, M;
    cin >> N >> M;
    vector<pii> p(M);
    for (int i = 0; i < M; i++) {
        int x, y;
        cin >> x >> y;
        x--; y--;
        p[i] = pii(x, y);
    }
    int ans = 0;
    for (pii exclusion : p) {
        DisjointSet ds = DisjointSet(N);
        for (pii edge : p) {
            if (edge == exclusion) continue;
            ds.unite(edge.first, edge.second);
        }
        if (ds.size(0) != N) ans++;
    }
    cout << ans << '\n';
}

Measured memory_bytes: 3580
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int t = sc.nextInt();
        int[] a = new int[t];
        int max = 0;
        int rest = 0;
        for (int i = 0; i < t; i++) {
            a[i] = sc.nextInt();
            rest += a[i];
            max = Math.max(max, a[i]);
        }
        rest -= max;
        if (rest >= max - 1) {
            System.out.println(0);
            return;
        }
        System.out.println(max - rest - 1);
    }

}


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

#define ff              first
#define ss              second
#define int             long long
#define ll              long long
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)      __builtin_ctzll(x)
#define mod             998244353
#define Mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define vpii            vector<pair<int,int> >
#define all(x)          x.begin(),x.end()
#define gcd(m,n)        __gcd(m,n)
#define matrixprint(arr,a,b,c,d) for(int i=a;i<=c;i++){for(int j=b;j<=d;j++){cout<<arr[i][j]<<" ";}cout<<"\n";}
#define show(arr,x,y)   for(int i=x;i<=y;i++){cout<<arr[i]<<" ";}cout<<"\n"
#define sz               size()
#define inc(i,x,y)      for(int i=x;i<=y;i++)
#define dec(i,x,y)      for(int i=x;i>=y;i--)



#define TRACE
#ifdef TRACE
#define deb(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << std::endl;
    }
    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...);
    }
#else
#define deb(...)
#endif

void fast()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//#ifndef ONLINE_JUDGE
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
//#endif
}

//////////////////////////////code//////////////////////////////

int32_t main()
{
  fast();

  int n,w;cin>>n>>w;

  vi wt(n+1),val(n+1);
  int MAX=0;
  for(int i=1;i<=n;i++) cin>>wt[i],cin>>val[i],MAX+=val[i];

  int dp[101][100001];

  for(int i=0;i<=100;i++)

   for(int j=0;j<=MAX;j++)
   {
    dp[i][j]=inf;
    dp[i][val[i]]=wt[i];
   }
   
  for(int i=1;i<=n;i++)
  {
      for(int j=0;j<=MAX;j++)
      {
          if(j-val[i]>=0 && dp[i-1][j-val[i]]!=inf && dp[i-1][j-val[i]]+wt[i]<=w)
            dp[i][j]=min(dp[i-1][j],min(dp[i-1][j-val[i]]+wt[i],dp[i][j]));
          else
            dp[i][j]=dp[i-1][j];

      }
  }
  int ans=0;
  
  for(int i=MAX;i>=0;i--)
  {  //deb(dp[n][i]);
      if(dp[n][i]!=inf && dp[n][i]<=w)
      ans = max(ans,i);
  }
  cout<<ans;


}


Measured memory_bytes: 79232
#include <bits/stdc++.h>
using namespace std;
int floor(int x, int y) {
    if(x%y==0) return x/y;
    return x/y+1;
}
int main() {
    int N, K;
    cin >> N >> K;
    
    cout << floor(N-1, K-1) << endl;
   
}


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

int main() {
    string S;
    cin >> S;
    map<char, int> cnt;
    for(int i = 0; i < S.size(); i++) {
        if(cnt.count(S[i]) == 0) {
            cnt[S[i]] = 1;
        } else {
            cout << "no" << endl;
            return 0;
        }
    }
    cout << "yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>



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

using namespace std;
int a,b;

int main(){
  cin >> a >> b;
  cout << (a+b+1)/2 << endl;
  return 0;
}


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

int main(){
    long long int n, x;
    cin >> n >> x;

    long long int a = n-x;
    long long int b = x;
    if(a < b) swap(a,b);
    
    long long int ans = 0;
    while(b != 0){
        ans += (a / b) * 3 * b;
        a %= b;
        swap(a,b);
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
    // input
    int n;
    scanf("%d", &n);
    int a[n];
    rep(i,0,n) scanf("%d", &a[i]);
    rep(k,0,n) {
        if(k != 0) printf(" ");
        printf("%d", a[k]);
    }
    printf("\n");
    //sort
    rep(i,1,n){
        int v = a[i];
        int j = i-1;
        while (j >= 0 && a[j] > v){
            a[j+1] = a[j];
            j--;
        }
        a[j+1] = v;
        rep(k,0,n) {
            if(k != 0) printf(" ");
            printf("%d", a[k]);
        }
        printf("\n");
    }   
}


Measured memory_bytes: 3216