akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define pii std::pair<int,int>
#define pli std::pair<ll,int>
#define pil std::pair<int,ll>
#define psi std::pair<string,int>
#define pll std::pair<ll,ll>
#define pci std::pair<char,int>
#define sll(x) scanf("%lld",&x)
#define prll(x) printf("%lld ",x)
#define pri(x) printf("%d ",x)
#define si(x) scanf("%d",&x)
#define pb push_back
#define vll std::vector<ll>
#define vpi std::vector<std::pair<int,int>>
#define vi std::vector<int>
#define vvi std::vector<std::vector<int>>
#define vvpil std::vector<std::vector<std::pair<int,ll>>>
#define vlpii std::vector<std::list<pii>>
#define vlpil std::vector<std::list<pil>>
#define li std::list<int>
#define lpil std::list<pil>
#define Endl printf("\n")
#define vli vector<list<int>>
#define vvll vector<vector<ll>>
#define mp make_pair
#define x first
#define y second
#define ull uint64_t
#define ma 100000000
#define imie(...) "[" << #__VA_ARGS__": " << (__VA_ARGS__) << "] "
const ll  INF=10000000000000;
const ll mod =  1e9 + 7;
using namespace std;
void add(ll& a , ll b){
	a += b;
	if(a >= mod) a -= mod;
}
ll mul(ll a , ll b){
	return (a * b) % mod;
}
ull Pow(ull a , ull b){
	if(b == 0) return 1 ;
	ull c = Pow(a , b / 2) ;
	if(b % 2) return (a * ((c * c) % mod)) % mod;
	return (c * c) % mod ;
}
vi Digit(ll x){
	vi res ;
	while(x){
		res.pb(x % 10) ;
		x /= 10 ;
	}
	return res ;
}
		

int main(){
	IOS;
	cout.precision(30) ;
	vi occ1(1e5 + 1 , 0) ;
	vi occ2(1e5 + 1 , 0) ;
	int n ; cin >> n ;
	int x ; 
	for(int i = 0 ; i < n ; i++){
		cin >>x ;
		if(i % 2) occ2[x]++ ;
		else occ1[x]++ ;
	}
	int pos11 = -1  , pos22 = -1 ;
	int maax1 = -1 ,maax2 = -1 ,maax3 = -1 ,maax4 = -1  ; 
	for(int i = 0 ; i <= 1e5 ; i++){
		if(occ1[i] >= maax1){
			pos11 = i ;
			maax2 = maax1 ;
			maax1 = occ1[i] ;
		}
		else if(occ1[i] >= maax2) maax2 = occ1[i] ;
		if(occ2[i] >= maax3){
			pos22 = i ;
			maax4 = maax3 ;
			maax3 = occ2[i] ;
		}
		else if(occ2[i] >= maax4) maax4 = occ2[i] ;
	}
	if(pos11 != pos22) cout << n - maax1 - maax3 << endl ;
	else{
		if(maax2 >= maax4){
			cout << n - maax3 - maax2 << endl ;
		}
		else cout << n - maax1 - maax4 << endl ;
	}
	return 0;
}


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

using namespace std;
using LL = long long;



/////////////////////////////////////////////////////////////////////////////////////////////
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 wt(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define wt(x...)
#endif
/////////////////////////////////////////////////////////////////////////////////////////////


vector< LL > primeFactors(LL N) {

	vector< LL > ans;

	for(LL i = 2; i * i <= N; ++i) {
		while(N % i == 0LL) {
			N /= i;
			ans.push_back(i);
		}
	}

	if (N > 1) ans.push_back(N);

	return ans;

}

int main() {

	ios_base :: sync_with_stdio(0); cin.tie(NULL);
	
	LL N; cin >> N;

	vector< LL > factors = primeFactors(N);	

	int sz = factors.size();

	set < LL > used;
	used.insert(1LL);

	int ans = 0;

	for(int i = 0; i < sz; ++i) {
		LL now = factors[i];
		LL cur = 1;

		while(used.count(cur) && i < sz) {
			if (factors[i] != now) {
				--i;
				break;
			}
			cur *= factors[i];
			i += used.count(cur);
		}

		if (N % cur == 0 && !used.count(cur)) {
			++ans;
			used.insert(cur);
			N /= cur;
		}
	}

	cout << ans << '\n';

	return 0;
}

Measured memory_bytes: 3640
using System;

class _0052 {
    public static void Main() {
        int n, sum;

        while (true) {
            sum = 0;
            n = int.Parse(Console.ReadLine());
            if (n == 0) break;
            for(float b=5;b <= n; b *= 5)
                sum += (int)(n / b);
            Console.WriteLine(sum);
        }
    }
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vector<vector<int>> F(N, vector<int>(10)), P(N, vector<int>(11));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 10; j++) {
      cin >> F[i][j];
    }
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 11; j++) {
      cin >> P[i][j];
    }
  }
  int res = -(1 << 30);
  for (int bit = 1; bit < (1 << 10); bit++) {
    int cc = 0;
    for (int i = 0; i < N; i++) {
      int c = 0;
      for (int j = 0; j < 10; j++) {
        if (((bit >> j) & 1) && F[i][j]) c++;
      }
      cc += P[i][c];
    }
    res = max(res, cc);
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <complex>
#include <map>
#include <climits>
#include <sstream>
using namespace std;

#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second
#define mkp make_pair

static const double PI=6*asin(0.5);
typedef long long ll;
typedef complex<double> CP;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vint;
static const int INF=1<<24;

template <class T>
void initvv(vector<vector<T> > &v,int a,int b, const T  &t = T()){
	v.assign(a,vector<T>(b,t));
}

//v.erase(unique(v.begin(),v.end()),v.end());


int main(){
	int n;
	while(cin>>n,n){
		vint v(n);
		rep(i,n){
			cin>>v[i];
		}
		bool f=true;
		rep(i,10001){
			vint t;
			f=true;
			rep(j,v.size()){
				if(v[j]!=j+1){
					f=false;
					break;
				}
			}
			if(f){
				cout<<i<<endl;
				break;
			}
			int vs=v.size();
			rep(j,vs){
				v[j]--;
			}
			rep(j,vs){
				if(v[j]==0) continue;
				t.PB(v[j]);
			}
			t.PB(vs);
			v=t;
		}
		if(!f) cout<<-1<<endl;
	}
}

Measured memory_bytes: 1248
#include<bits/stdc++.h>
#define inf 1<<29
#define linf 1e16
#define eps (1e-8)
#define mod 1000000007
#define pi acos(-1)
#define phi (1.0+sqrt(5))/2.0
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define pd(a) printf("%.10f\n",(double)(a))
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(a)-1;(b)<=i;i--)
#define equals(a,b) (fabs((a)-(b))<eps)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<int,double> pid;
typedef pair<double,int> pdi;
typedef vector<int> vi;
typedef vector<pii> vpi;
const int dx[8]={1,0,-1,0,1,1,-1,-1};
const int dy[8]={0,1,0,-1,1,-1,1,-1};

int main()
{
  ull x,ans=0;
  cin>>x;
  ans=x/(11);
  ans*=2;
  x%=11;
  if(0<x && x<=6)ans++;
  else if(6<x)ans+=2; 
  cout<<ans<<endl;
  return 0;
}



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

const int INF = 2e9;
const ll mod = 1e9 + 7;

ll f(ll n){
    ll res = 1;
    for(int i = n;i > 0;i--){
        res *= i;
        res %= mod;
    }
    return res;
}

int main(){
    ll n,m;
    cin >> n >> m;
    ll ok = abs(n-m);
    if(ok > 1)cout << 0 << endl;
    else{
        ll a = f(n);
        ll b = f(m);
        ll ans = a*b%mod;
        if(ok < 1) ans *= 2;
      	ans %= mod;
        cout << ans << endl;
    }
}

Measured memory_bytes: 3608
object Main extends App {
  val n = readInt
  val ps = readLine.split(" ").map(_.toInt)
  println((1 to n-2).map(i => if((ps(i-1)<ps(i) && ps(i)<ps(i+1)) || (ps(i-1)>ps(i) && ps(i)>ps(i+1)))1 else 0).sum)
}

Measured memory_bytes: 25408
#include <bits/stdc++.h>
#define FASTIO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define LL long long int
using namespace std;

const int N = 3e6 + 5;
const int oo = 1e9 + 5;
const int MOD = 1e9 + 7;

LL powermod(LL a, LL b) {
    if (b == 0) return 1;
    LL res = powermod(a, b/2);
    res = (res * res)%MOD;
    if (b & 1) res = (res * a)%MOD;
    return res;
}
int fac[N], invfac[N];
void pre() {
    fac[0] = 1;
    for (int i=1;i<N;++i) fac[i] = (fac[i-1] * 1LL * i)%MOD;
    invfac[N-1] = powermod(fac[N-1], MOD-2);
    for (int i=N-2;i>=0;--i) {
        invfac[i] = (invfac[i+1] * 1LL * (i + 1))%MOD;
    }
}
LL ncr(int n, int r) {
    if (r < 0 || r > n) return 0;
    LL ans = (fac[n] * 1LL * invfac[r])%MOD;
    ans = (ans * 1LL * invfac[n-r])%MOD;
    return ans;
}
void solve() {
    int k;
    cin >> k;
    string str;
    cin >> str;
    int s = str.size();
    LL ans = 0, sixinv = powermod(26,MOD-2), have = 1, have2 = powermod(26, k);
    for (int i=0;i<=k;++i) {
        ans += ((ncr(s+i-1,s-1) * have)%MOD * have2)%MOD;
        have2 = (have2 * sixinv)%MOD;
        have = (have * 25)%MOD;
        if (ans >= MOD) ans -= MOD;
    }
    cout << ans << '\n';
} 

int main() {
    FASTIO;
    pre();
    int t = 1;
    // cin >> t;
    while(t--) solve();
    return 0;
}

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

#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;

int ctoi(char c) { return int(c - '0'); }

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

    string str;
    int k;
    cin >> str >> k;

    int n = str.size();

    // dp[i][j][0]: 頭からi桁目まで決めて，0でない桁がj個あり，strより小さいことが確定していない個数．
    // dp[i][j][1]: 頭からi桁目まで決めて，0でない桁がj個あり，strより小さいことが確定している個数．
    vector<vector<vll>> dp(n + 1, vector<vll>(k + 2, vll(2, 0)));
    dp[0][0][0] = 1;

    rep(i, 0, n) {
        rep(j, 0, k + 1) {
            if (str[i] == '0') {
                dp[i + 1][j][0] += dp[i][j][0];
                dp[i + 1][j][1] += dp[i][j][1];
                dp[i + 1][j + 1][1] += 9 * dp[i][j][1];
            } else {
                dp[i + 1][j][1] += dp[i][j][1];
                dp[i + 1][j][1] += dp[i][j][0];
                dp[i + 1][j + 1][0] += dp[i][j][0];
                dp[i + 1][j + 1][1] += 9 * dp[i][j][1];
                dp[i + 1][j + 1][1] += (ctoi(str[i]) - 1) * dp[i][j][0];
            }
        }
    }

    cout << dp[n][k][0] + dp[n][k][1] << endl;

    return 0;
}

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

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	int n; cin >> n;
	string s; cin >> s;
	string ans = "";
	rep(i, 0, s.size() - 1)
	{
		ans += (s[i] - 'A' + n) % 26 + 'A';
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
# AOJ ITP1_7_B

def numinput():
    a = input().split()
    for i in range(len(a)):
        a[i] = int(a[i])
    return a

def main():
    while True:
        a = numinput()
        n = a[0]; x = a[1]
        if n == 0 and x == 0: break
        # 1からnまでの異なる3つの数の和がxになる数の組の個数。
        count = 0
        for i in range(1, (x // 3) + 1):
            for j in range(i + 1, n + 1):
                if j < x - i - j <= n:
                    count += 1
                    # print(str(i) + " " + str(j) + " " + str(x - i - j))
        print(count)

if __name__ == "__main__":
    main()


Measured memory_bytes: 5592
import sys
from statistics import *
from collections import *
from operator import itemgetter
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

n = ni()
red = []
blue = []
for i in range(n):
    li = na()
    li.append(0)
    red.append(li)
for i in range(n):
    li = na()
    li.append(0)
    blue.append(li)
red = sorted(red, key=itemgetter(1))
blue = sorted(blue, key=itemgetter(0))
ct = 0
for i in range(n):
    c, d, r = blue[i]
    for j in range(n)[::-1]:
        a, b, l = red[j]
        if r == 0 and l == 0 and a < c and b < d:
            ct += 1
            red[j][2] = 1
            blue[i][2] = 1
            break
print(ct)


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

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  vector<Int> p(n);
  for(Int i=0;i<n;i++) cin>>p[i];

  vector<Int> r(n);
  for(Int i=0;i<n;i++) r[--p[i]]=i;
  
  Int ans=0,res=0,pre=n+1;
  for(Int i=0;i<n;i++){
    if(pre<r[i]) res++;
    else res=1;
    pre=r[i];
    chmax(ans,res);
  }

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


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,i;
  cin>>n;
  vector<int>h(n);
  vector<int>dp(n);
  for(i=0;i<n;++i)
  {
    cin>>h[i];
  }
  dp[0]=0;
  dp[1]=abs(h[0]-h[1]);
  for(i=2;i<n;++i)
  {
    dp[i]=min(dp[i-2]+abs(h[i-2]-h[i]),dp[i-1]+abs(h[i-1]-h[i]));
  }
  cout<<dp[n-1];
}


Measured memory_bytes: 1024
N,M=map(int,input().split())
S=input()
T=input()

def gcd(a,b):
    if a<b:a,b=b,a
    c=a%b
    while c>0:
        a,b=b,c
        c=a%b
    return b

def enstr(A,g):
    m=''
    for i in range(len(A)//g):
        m+=A[g*i]
    return m
    
if S[0]==T[0]:
    gcd=gcd(N,M)
    n,m=N//gcd,M//gcd
    s,t=enstr(S,n),enstr(T,m)
    if s==t:
        print(N*M//gcd)
    else:
        print(-1)
else:
    print(-1)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define maxn 100000
#define reg register
using namespace std;
inline int  read() {
    reg int s = 0, t = 0; reg char ch = getchar();
    while(ch > '9' || ch < '0') t |= ch == '-', ch = getchar();
    while(ch >= '0' && ch <= '9') s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar();
    return t ? -s : s;
}
int n, a, b, p, d[maxn+5];
int fa[maxn+5], dep[maxn+5];
vector <int> G[maxn+5], Q, rev, ans;
void DFS(int u) {
	for (int i = 0; i < G[u].size(); i++){
	int v = G[u][i]; if (v ^ fa[u])
		fa[v] = u, dep[v] = dep[u]+1, DFS(v);
	}
}
int main() {
	n = read();
	for (int i = 1, u, v; i < n; i++)
	 	u = read(), v = read(), d[u]++, d[v]++, 
		G[u].push_back(v), G[v].push_back(u);
	DFS(1);
	for (int i = 1; i <= n; i++)
		if (dep[i] > dep[a]) a = i;
	fa[a] = dep[a] = 0, DFS(a);
	for (int i = 1; i <= n; i++)
		if (dep[i] > dep[b]) b = i;
	for (int i = b; i; i = fa[i])
		if (i == a || i == b)
			Q.push_back(d[i]-1);
		else Q.push_back(d[i]-2);
	rev = Q, reverse(rev.begin(), rev.end());
	for (int i = 0; i < (int)Q.size(); i++)
		if (Q[i] < rev[i]) break;
		else if (Q[i] > rev[i])
			{Q = rev; break;}
	for (int c : Q) {
		p++;
		for (int i = 1; i <= c; i++)
			ans.push_back(p+i);
		ans.push_back(p), p += c;
	}
	if ((int)ans.size() < n)
		return puts("-1"), 0;
	for (int x : ans)
		printf("%d ", x);
	return puts(""), 0;
}

Measured memory_bytes: 13432
#include<stdio.h>
 
int main( ) {
    int a;
    int b;
    int c;
 
    scanf("%d %d %d",&a ,&b ,&c);
 
    if( a < b && b < c ) {
        printf("Yes\n");
    }else {
        printf("No\n");
    }
 
    return 0;
}
 

Measured memory_bytes: 580
#include<iostream>
using namespace std;
int main(){
	
	int a,b,c,d,e,f,x;

	cin>>a;
	cin>>b;
	cin>>c;
	cin>>d;
	cin>>e;

	if(a<40){a=40;}
	if(b<40){b=40;}
	if(c<40){c=40;}
	if(d<40){d=40;}
	if(e<40){e=40;}

	cout<<(a+b+c+d+e)/5<<endl;

return 0;
}


Measured memory_bytes: 3092
#include<iostream>
using namespace std;
int main(){
    int n, a, max=-1000000, min = 1000000;
    long int sum = 0;
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> a;
        sum+=a;
        if(a>max)
            max = a;
        if(a<min)
            min = a;
    }
    cout << min << ' ' << max << ' ' << sum << endl;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h> // Include every standard library
using namespace std;
int dirx[8] = {-1, 0, 0, 1, -1, -1, 1, 1};
int diry[8] = {0, 1, -1, 0, -1, 1, -1, 1};
#define sqr(x) ((LL)(x) * (x))
#define RESET(a, b) memset(a, b, sizeof(a))
#define ALLA(arr, sz) arr, arr + sz
#define REVERSE(v) reverse(ALL(v))
#define SORTA(arr, sz) sort(ALLA(arr, sz))
#define REVERSEA(arr, sz) reverse(ALLA(arr, sz))
#define TC(t) while (t--)
#define ms(s, n) memset(s, n, sizeof(s))
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define size(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed << setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
#define IOS                  \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pi> vii;
typedef vector<vi> vvi;
const int MOD = (int)1e9 + 7;
const int MOD2 = MOD + 2; //1007681537;
const int INF = (int)1e9;
const ll LINF = (ll)1e18;
const ld PI = acos((ld)-1);
const ld EPS = 1e-9;
inline ll gcd(ll a, ll b)
{
    ll r;
    while (b)
    {
        r = a % b;
        a = b;
        b = r;
    }
    return a;
}
inline ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
inline ll fpow(ll n, ll k, int p = MOD)
{
    ll r = 1;
    for (; k; k >>= 1)
    {
        if (k & 1)
            r = r * n % p;
        n = n * n % p;
    }
    return r;
}
inline ll isqrt(ll k)
{
    ll r = sqrt(k) + 1;
    while (r * r > k)
        r--;
    return r;
}
inline ll icbrt(ll k)
{
    ll r = cbrt(k) + 1;
    while (r * r * r > k)
        r--;
    return r;
}
inline int inv(int a, int p = MOD) { return fpow(a, p - 2, p); }
int modulo(int a, int b) { return (a % b + b) % b; }
#define db(x) cerr << #x << " = " << (x) << " ";

vi graph[100005];
bool visited[100005];
int deg[100005]; //deg[v]= no of edges going into node v. 
int dist[1000005];

void dfs(int v) {
    visited[v] = 1;
    for (int a : graph[v]) {
        dist[a] = max(dist[a], dist[v] + 1);
        deg[a]--;
        if(deg[a]==0)
            dfs(a);
    }
}

int main()
{
    IOS;
    int n, m;
    scanf("%d%d", &n, &m);
    while (m--){
        int x,y;
        scanf("%d%d", &x, &y);
        graph[x].pb(y);
        deg[y]++;
    }
    for (int a = 1; a <=n; a++) {
        if (visited[a] == 0 && deg[a] == 0)
            dfs(a);
    }
    int res = 0;
    for (int a = 1; a <= n; a++)
        res = max(res, dist[a]);
    printf("%d", res);
}


Measured memory_bytes: 14724
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=2e5+5;
const ll MOD=1e9 + 7;

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

    ll n;
    cin>>n;

    ll times = n/100;
    ll rem = n%100;

    if(times*5>=rem)cout<<1;
    else cout<<0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define for1(a,b,i) for(int i=a;i<=b;++i)
#define FOR2(a,b,i) for(int i=a;i>=b;--i)
using namespace std;
typedef long long ll;
inline int read() {
    int f=1,sum=0;
    char x=getchar();
    for(;(x<'0'||x>'9');x=getchar()) if(x=='-') f=-1;
    for(;x>='0'&&x<='9';x=getchar()) sum=sum*10+x-'0';
    return f*sum;
}
int n;
int a[500005][2],sta[500005];
int main(){
    n=read();
    for1(1,n,i) {
        a[i][0]=read();
        a[i][1]=read();
        sta[i*2]=a[i][1];
        sta[i*2-1]=a[i][0];
    }
    sort(sta+1,sta+2*n+1);
    
    ll ans=0,sum=0;
    for1(1,n,i) ans+=a[i][0],sum+=a[i][1];
    ans=min(ans,sum),sum=0;
    for1(1,n,i) sum+=sta[i];
    for1(1,n,i) {
        if(max(a[i][0],a[i][1])<sta[n]) return printf("%lld\n",sum),0;
        if(min(a[i][0],a[i][1])>sta[n]) return printf("%lld\n",sum),0;
        ll now=sum;
        now+=max(a[i][0],a[i][1])-sta[n];
        now+=max(0,min(a[i][0],a[i][1])-sta[n-1]);
        ans=min(ans,now);
    }
    printf("%lld\n",ans);
}

Measured memory_bytes: 3200
import java.util.*;

class Main {
    public static int pay(int N) {
        int ret = N / 15 * 200;
        return N*800 - ret;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        System.out.print(pay(N));
    }
}

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

int main()
{
    ll a,b,x,y;
    cin>>a>>b;
    y = (4*a - b)/2;
    x = a - y;
    if(x >= 0 && y >= 0 && (4*x + 2*y) == b)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3596
#include<iostream>
#include<string>
using namespace std;
int main(){
  int n,i;
  string s;
  cin>>n;
  cin>>s;
  if(n<s.length()){
  for( i=0;i<n;i++)cout<<s[i];
  cout<<"...";
  }
  else cout<<s;
}

Measured memory_bytes: 3596
l = []
for i in range(5):
  l.append(int(input()))

ans = 0
m = 10
x = 0
for i in range(5):
  if l[i]%10 < m and l[i]%10 > 0:
    m = l[i]%10
    x = i
for i in range(5):
  if i == x or l[i]%10 == 0:
    ans += l[i]
  else:
    ans += l[i] + 10 - l[i]%10
print(ans)

Measured memory_bytes: 3064
// #include <bits/stdc++.h>
#include<iostream>
#include<stack>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<iomanip>
#include<set>
#include<bitset>
#include<cmath>
#include<numeric>
#include<limits>
#include<functional>
#include <bitset>

#define REP(i, m, n) for(int i = (m); i < (n); i++)
#define rep(i,n) REP(i,0,n)
#define NIL -1
using namespace std;
typedef long long ll;
typedef long long int lli;
// static const int MOD = 10000007;
// static const int MAX = 100005;
// static const int NMAX = 5005;
// static const lli INFTY = 1000000000000;

// typedef priority_queue<int, greater<int>> RevQ;
int n;
// string s;
// lli l, r;
stack<int> m;
// vector<pair<int, int>> a(MAX);

// lli gcd(lli a, lli b) {
//   return b ? gcd(b, a%b) : a;
// }


int main(){
  cin >> n;
  if (n < 2) cout << 0 << endl;
  else {
    if (n % 2 == 0) cout << n/2 - 1 << endl;
    else cout << (n-1)/2 << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
const int mod = 1000000007;
#define ll long long

int main()
{
	int N, a[110];
	cin >> N;
	double ave = 0;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
		ave += a[i];
	}
	ave /= (double)N;
	double an = mod;
	int point = 0;
	for (int i = 0; i < N; i++) {
		if (abs(a[i] - ave) < an) {
			an = (double)abs(a[i] - ave);
			point = i;
		}
	}
	cout << point << endl;
}


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

int main(){
  double a, b;
  cin >> b >> a;
  int ans;
  if(a*100/10<(b+1)*100/8 && b*100/8<(a+1)*100/10){
    ans = ceil(max(a*100/10,b*100/8));
  }else{
    ans = -1;
  }
  cout << ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define sf1(n) scanf("%d",&n)
#define sf2(n,q) scanf("%d %d",&n,&q)
#define f first
#define ss second
#define pb push_back
#define lli long long
#define mem(ar,false) memset(ar,false,sizeof(ar))
#define mpr make_pair
#define endl "\n"
#define mod 1000000007
#define inf 9000000000000000000LL
using namespace std;

vector<int>v[100005];
int dp[100005];
int dfs(int u)
{
    if(dp[u]!=-1)
        return dp[u];
    int ret = 0;
    for(int i=0;i<v[u].size();i++)
    {
        ret = max(ret,1+dfs(v[u][i]));
    }
    return dp[u] = ret;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n,m;
    cin >> n >> m;
    for(int i=1;i<=m;i++)
    {
        int a,b;
        cin >> a >> b;
        v[a].pb(b);
    }
    int ans = 0;
    mem(dp,-1);
    for(int i=1;i<=n;i++)
    {
        ans = max(ans,dfs(i));
    }
    cout << ans << endl;

    return 0;

}



Measured memory_bytes: 11384
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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; }

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

    int n;ll k;cin>>n>>k;
    vector<int> a(n),nxt(n);
    vector<vector<int>> pos(200001);
    rep(i,n){
        cin>>a[i];
        pos[a[i]].push_back(i);
    }
    rep(i,n){
        auto ite=lower_bound(ALL(pos[a[i]]),i+1);
        if(ite==pos[a[i]].end()){
            nxt[i]=(*pos[a[i]].begin());
        }else{
            nxt[i]=(*ite);
        }
    }
    ll loop=1;
    int p=0;
    for(int TL=0;TL<=100000000;TL++){
        if(p>=nxt[p]) loop++;
        p=nxt[p]+1;
        if(p==n) break;
        if(TL==100000000){
            assert(false);
        }
    }
    // cout<<loop<<endl;
    k%=loop;
    // cout<<"k : "<<k<<endl;

    if(k==0){
        cout<<endl;
        return 0;
    }
    k--;
    p=0;
    vector<int> ans;
    while(p!=n){
        if(k>0){
            if(p>=nxt[p]) k--;
            p=nxt[p]+1;
        }else{
            if(p>=nxt[p]){
                ans.push_back(a[p]);
                p++;
            }
            else p=nxt[p]+1;
        }
    }
    rep(i,ans.size()){
        cout<<ans[i]<<(i==ans.size()-1?'\n':' ');
    }
    return 0;
}


Measured memory_bytes: 14968
#include <iostream>
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
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; }
struct io { io() { ios::sync_with_stdio(false); cin.tie(0); } };
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

signed main(void) 
{
    ll n;
    cin >> n;
    
    vll a(n);
    map<ll, ll> mp;
    
    rep(i, n) {
        cin >> a[i];
        mp[a[i]]++;
    }
    ll l1 = 0;
    ll l2 = 0;
    for (auto i: mp) {
        if (i.second >= 2) {
            l2 = l1;
            l1 = i.first;
        }
        if (i.second >= 4) {
            l2 = i.first;
            l1 = i.first;
        }
    }
    
    mes(l1*l2);
    
}


Measured memory_bytes: 10104
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

#define int long long
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//ここに関数定義や変数宣言







//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
signed main(){
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////



int a,b,c,k;

cin>>a>>b>>c>>k;
int sum=0;

if (a>=k)
{
	sum=k*1;
}

else{
	if (a+b>=k)
	{
		sum=a*1+b*0;
	}
	else{
		if (a+b+c>=k)
		{
			sum= a*1  +b*0 + ( -1*(k-a-b) );
		}
		else{
			sum=a*1  +b*0 + ( -1*c ) ;
		}

	}
}


int ans=sum;

cout<<ans<<endl;



return 0;

}

Measured memory_bytes: 3620
#include <string>
#include <stack>
#include <sstream>
#include <iostream>
using namespace std;

/*int poptwo(stack<int> S,int n,int m) {
	n = S.top();
	S.pop();
	m = S.top();
	S.pop();
}*/

int n,m,r;
int main() {
	string word;
	stack<int> S;
	while(cin >> word) {
		if(word == "+") {
			n = S.top();
			S.pop();
			m = S.top();
			S.pop();
			r = n + m;
			S.push(r);
		}
		else if(word == "-") {
			n = S.top();
			S.pop();
			m = S.top();
			S.pop();
			r = m - n;
			S.push(r);
		}
		else if(word == "*") {
			n = S.top();
			S.pop();
			m = S.top();
			S.pop();
			r = n * m;
			S.push(r);
		}
		else {
			std::istringstream sin(word);
			sin >> r;
			S.push(r);
		}
	}
	n = S.top();
	cout << n << endl;
}

Measured memory_bytes: 1236
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

int n;
vector<vector<int>> g;

void input() {
	cin >> n;
	g.resize(n);
	for (int i = 0; i < n - 1; ++i) {
		int a, b; cin >> a >> b;
		--a, --b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
}

vector<int> path;

tuple<bool, int> dfs(int s = 0, int p = -1) {
	int cnt_children = 0;
	int rem = 0;
	bool is_path = false;
	if (s == n - 1) is_path = true;
	for (auto c : g[s]) {
		if (c != p) {
			tuple<bool, int> tmp = dfs(c, s);
			is_path |= get<0>(tmp);
			cnt_children += get<1>(tmp) + 1;
			if (get<0>(tmp)) rem = get<1>(tmp) + 1;
		}
	}
	if (is_path)
		path.push_back(cnt_children + 1 - rem);
	return make_tuple(is_path, cnt_children);
}

int main() {
	input();
	dfs();
	reverse(path.begin(), path.end());
	int f_ptr = 0, s_ptr = path.size() - 1;
	int cnt_f = 0, cnt_s = 0;
	while (f_ptr <= s_ptr) {
		cnt_f += path[f_ptr++];
		if (s_ptr >= f_ptr)
			cnt_s += path[s_ptr--];
	}
	if (cnt_f > cnt_s)
		cout << "Fennec" << endl;
	else
		cout << "Snuke" << endl;
	return 0;
}


Measured memory_bytes: 9980
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;

const int N = 2e6 + 12;

#define mkp make_pair
#define sz(s) (int)(s.size())
#define eb emplace_back

int main () {
	clog << "Ready\n";
	
	int n;
	cin >> n;
	string s, t;
	cin >> s >> t;
	string res;
	for (int i = 0; i < sz(s); ++ i) {
		res += char(s[i]);
		res += char(t[i]);
	}
	cout << res;
	cerr << '\n';
	return 0;
}



Measured memory_bytes: 256
import Data.List

main = do
    _ <- getLine
    ss <- lines <$> getContents
    let s = normalize (ss!!0) (ss!!1)
    print . (`mod` 1000000007) . foldl' (*) (unit (head s)) $ zipWith solve s (drop 1 s)

normalize [] [] = []
normalize (x:xs) (y:ys)
    | x == y = 1:normalize xs ys
    | otherwise = 2:normalize (drop 1 xs) (drop 1 ys)

unit 1 = 3
unit 2 = 6

solve 2 2 = 3
solve 2 1 = 1
solve 1 2 = 2
solve 1 1 = 2


Measured memory_bytes: 508
#include <iostream>
#include <cassert>
#include <cstring>
#include <algorithm>
#include <vector>
 
using namespace std;
#define whole(xs) (xs).begin(),(xs.end())
 
int N, M;
 
struct Edge {
    int from, to, cost;
    Edge(int from, int to, int cost) :
        from(from), to(to), cost(cost) {}
    bool operator==(const Edge& e) const {
        return from == e.from &&
            to == e.to &&
            cost == e.cost;
    }
};
 
struct UnionFind {
    vector<int> parent;
    int N;
    UnionFind(int N) : N(N) {
        parent.resize(N);
        fill(whole(parent), -1);
    }
    int root(int x) {
        if (parent[x] == -1) return x;
        return parent[x] = root(parent[x]);
    }
    int query(int x, int y) {
        return root(x) == root(y);
    }
    void merge(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return;
        parent[y] = x;
    }
};
 
bool EdgeComp(const Edge& a, const Edge& b) {
    return a.cost < b.cost;
}

#define MN 503
 
int Count, Cost;
bool used[MN][MN];
int L[MN][MN];
bool dfs(vector< vector<Edge> >& G, int u, int v, int cost, vector<int>& prev) {
    //cout << "u, v = " << u << " " << v << endl;
    //cout << "prev[v]: " << prev[v] << endl;
    if (prev[v] == 0) {
        int a = v, b = u;
        do {
            //cout << "a, b: " << a << " " << b << endl;
            if (!used[a][b] && !used[b][a] && L[a][b] == cost) {
                //cout << "a, b = " << a << " " << b << endl;
                used[a][b] = true;
                used[b][a] = true;
                Count--;
                Cost -= L[a][b];
            }
            a = b;
            b = prev[b];
        } while (a != v);
        return true;
    }
    prev[v] = u;
    for (int i = 0; i < G[v].size(); i++) {
        Edge& e = G[v][i];
        if (e.to == u) continue;
        if (dfs(G, v, e.to, e.cost, prev)) return true;
    }
    return false;
}
 
int main() {
    cin >> N >> M;
    vector<Edge> es;
    memset(L, 0, sizeof(L));
    for (int i = 0; i < M; i++) {
        int s, d, c;
        cin >> s >> d >> c;
        L[s][d] = c;
        L[d][s] = c;
        es.push_back(Edge(s, d, c));
    }
    vector< vector<Edge> > G(N + 1);
    Count = 0;
    Cost = 0;
    UnionFind uf(N + 1);
    sort(whole(es), EdgeComp);
    memset(used, false, sizeof(used));
    for (int i = 0; i < M; i++) {
        //cout << "\t" << Count << " " << Cost << endl;
        Edge& e = es[i];
        if (uf.query(e.from, e.to)) {
            G[e.from].push_back(Edge(e.from, e.to, e.cost));
            G[e.to].push_back(Edge(e.to, e.from, e.cost));
            Cost += e.cost;
            Count++;
            vector<int> prev(N + 1, -1);
            dfs(G, 0, e.from, e.cost, prev);
            G[e.from].pop_back();
            G[e.to].pop_back();
        } else {
            uf.merge(e.from, e.to);
            G[e.from].push_back(Edge(e.from, e.to, e.cost));
            G[e.to].push_back(Edge(e.to, e.from, e.cost));
            Cost += e.cost;
            Count++;
        }
    }
    cout << Count << " " << Cost << endl;
    return 0;
}

Measured memory_bytes: 2992
import sys
import numpy as np

n, q = list(map(int, input().split()))
MOD = 10 ** 9 + 7
INV2 = (MOD + 1) // 2
lines = sys.stdin.readlines()
aaa = np.fromiter(map(int, lines[:n]), dtype=np.int)
mat = (aaa.reshape(1, -1) < aaa.reshape(-1, 1)).astype(np.int64)
# print(mat)
for line in lines[n:]:
    x, y = map(int, line.split())
    x -= 1
    y -= 1
    tmp = (mat[x, y] + mat[y, x]) * INV2 % MOD
    mat[x] = mat[y] = (mat[x] + mat[y]) * INV2 % MOD
    mat[:, x] = mat[:, y] = (mat[:, x] + mat[:, y]) * INV2 % MOD
    mat[x, x] = mat[y, y] = 0
    mat[x, y] = mat[y, x] = tmp

ans = int(np.triu(mat).sum() % MOD)
ans = (ans << q) % MOD
print(ans)


Measured memory_bytes: 233288
#include <bits/stdc++.h>
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rrepi(i,a,b) for(int i=((int)(b)-1);i>=(a);--i)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) rrepi(i,0,n)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define ZERO(x) memset(x,0,sizeof(x))
#define MINUS(x) memset(x,-1,sizeof(x))
#define UNIQUE(x) (x).erase(unique(ALL(x)), (x).end())
#define TOUPPER(x) transform(ALL(x), (x).begin(), ::toupper)
#define TOLOWER(x) transform(ALL(x), (x).begin(), ::tolower)
#define debug(var)  do{std::cout << #var << " : "; view(var);}while(0)
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){for(const auto& v : vv){ view(v); } }
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void viewarr(T arr[], int n) { for(int i = 0; i < n; ++i) std::cout << arr[i] << " "; std::cout << std::endl; }
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; }
ll qp(ll a,ll b){ll ans=1;do{if(b&1)ans=1ll*ans*a;a=1ll*a*a;}while(b>>=1);return ans;}
ll qp(ll a,ll b,ll mo){ll ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const int INF = 1e9;
const ll INFL = 1e18;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5;

int main() {
    int K; cin >> K;
    ll ans = 0;
    repi(a,1,K+1) repi(b,1,K+1) repi(c,1,K+1) {
        int m = gcd(a,b);
        m = gcd(m,c);
        ans += m;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3636
import math
a,b = map(int,input().split())
gcd = math.gcd(a,b)
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
print(len(set(prime_factorize(gcd)))+1)

Measured memory_bytes: 9000
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
typedef vector<int> VI;
typedef vector<ll> VLL;

int main(){
    ll n,q;
    string s;
    cin >> n >> q >> s;
    vector<pair<ll, ll>> lr(q);

    for(int i=0; i<q ; ++i){
        cin >> lr[i].first ;
        cin >> lr[i].second ;
    }
    
    VLL c(n);c[0] = 0;
    for(int i = 1; i<n; ++i){
        if(s[i-1]=='A' && s[i] == 'C'){
            c[i] = c[i-1] + 1;
        }else{
            c[i] = c[i-1];
        }
    }

    for(int i =0; i<q ; ++i){
        ll tmp1 = lr[i].first, tmp2 = lr[i].second;
        cout << c[tmp2-1] - c[tmp1-1] << endl;
    }
  return 0;
}

Measured memory_bytes: 3456
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define tr(container, it) \
        for (auto it = container.begin(); it != container.end(); it++)
#define scontains(c, x) ((c).find(x) != (c).end())   //O(log n)
#define contains(c, x) (find((c).begin(),(c).end(),x) != (c).end()) //O(n)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mll map<ll,ll>
#define intv(x, a, b)((x)>=a && (x)<=b)
#define  rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define  _for(i, end) for (__typeof(end) i = 0; i < (end); i += 1)
#define all(x) (x).begin(),(x).end()
//#define len(array)  (sizeof(array)/sizeof((array)[0]))
#define what_is(x) cerr << #x << " is " << x << endl;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define mod(x, m) ((((x) % (m)) + (m)) % (m))
const double PI = 2 * acos(.0);
const int INF = 0x3f3f3f3f;
const ll LLINF = 1000000000000000005LL;;
const ll MOD = (ll) (1e9) + 7;
void _mod(ll &x){x = mod(x, MOD);}
//const ll MOD = (ll) 998244353 ;
const double EPS = 1e-10;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *) array, (T *) (array + N), val);
}


#define int ll

ll sum = 0;
void D(int n)
{

    for (int i=1; i<=sqrt(n); i++)
    {
        if (n%i == 0)
        {

//            if (n/i == i){if(i*(i-1) > n)sum += i-1 ;}
            if (n/i == i){if(i!=1 && n/i == n/(i-1))sum += i-1 ;}


            else
//            {if (i*(i-1) > n)sum += i-1;
            {if(i!=1 && n/i == n/(i-1)) sum += i-1;
                if (n/i!=1 && n/(n/i) == n/(n/i-1))sum += n/i-1;}
        }
    }
}
class DDivRemNumber {
public:

    void solve(std::istream& cin, std::ostream& cout) {
        sum = 0;
        int N;
        cin >> N;
        D(N);
        cout << sum << endl;
}
};


#undef int
int main() {
	DDivRemNumber solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

#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, m, n) for(int i = (m); i < (n); ++i)

using ll = long long;
#define INF 1e9

int main(){
  int K, S;
  cin >> K >> S;
  int cnt = 0;
  REP(i, K+1){
    REP(j, K+1){
      if(S - i - j >= 0 && S-i-j <=K){
        cnt++;
      }
    }
  }
  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

#define MAX_N 1

typedef long long ll;

const double PI = 3.141592653589793;
const long long MOD = 1e9 + 7;
const long long INF = 1e15;
const int INF_INT = 1e9;

int main(){
    string s;
    cin >> s;
    int n = s.length();
    string ans = string();
    for(int i = n - 1; i >= 2; i--){
        if(i % 2 == 0){
            for(int j = 0; j <= n - i; j++){
                string left = s.substr(j,i/2);
                string right = s.substr(j + i/2,i/2);
                if(left == right){
                    ans = left + right;
                    cout << ans.length() << endl;
                    return 0;
                }
            }
        }
    }
    return 0;
}


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

typedef pair<int, int> ipair;
typedef vector<int> vi;
typedef long long ll ;
#define fo(i, n) for(int i=0;i<n;i++)
#define rep(i, a, b) for(int i=a; i<(b); i++)
#define pb emplace_back
#define mp make_pair
#define sz(x) (int)(x).size()
#define ff first
#define ss second
#define debug(x) cout << #x << "  " << x << endl;   
#define mem(x,y) memset(x,y,sizeof(x))
#define endl '\n'
#define all(x) x.begin(), x.end()

int main() {
    int n;  cin >> n;
    int ar[n];
    int dp[n];
    fo(i, n)    cin >> ar[i];
    dp[0] = 0;
    dp[1] = abs(ar[0]-ar[1]);
    rep(i, 2, n) {
        dp[i] = min((dp[i-1]+abs(ar[i]-ar[i-1])), (dp[i-2]+abs(ar[i]-ar[i-2])));
    }
    cout << dp[n-1];
}




Measured memory_bytes: 4368
import java.io.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

class Main {
    public static void main(String[] args) throws IOException {
       Scanner in = new Scanner(System.in);
       while(in.hasNextInt()) {
	       int a = in.nextInt();
	       char op = in.next().charAt(0);
	       int b = in.nextInt();

	       if(op=='?') return;

	       int ans = 0;
	       if(op == '+') {
		       ans=a+b;
	       } else if(op == '-') {
		       ans=a-b;
	       } else if(op == '*') {
		       ans=a*b;
	       } else if(op == '/') {
		       ans=a/b;
	       }
	       System.out.println(ans);
       }
    }
}

Measured memory_bytes: 18016
#include <iostream>
using namespace std ;
int main() {
    bool checkContainA = false ;
    bool checkContainB = false ;
    bool checkContainC = false ;
    string s ;
    cin >> s ;
    for (int i = 0 ; i< s.length() ;i++){
        if (s[i] == 'a'){checkContainA = true;}
        if  (s[i] == 'b') {checkContainB = true;}
        if (s[i] == 'c') {checkContainC = true;}
    }
    if (checkContainA && checkContainB && checkContainC){
        cout << "Yes";
    }else {
        cout << "No";
    }
    return 0;
}

Measured memory_bytes: 256
using System;

namespace abc171
{
    class Program
    {
        static void Main()
        {
            var nk = Console.ReadLine().Split(' ');
            var n = int.Parse(nk[0]);
            var k = int.Parse(nk[1]);
            var pList = ReadNumList();
            Array.Sort(pList);
            var total = 0;
            for (var i = 0; i < k; ++i)
            {
                total += pList[i];
            }
            Console.WriteLine(total);
        }
        static int[] ReadNumList()
        {
            var line = Console.ReadLine().Split(' ');
            var numList = new int[line.Length];
            for (var i = 0; i < line.Length; ++i)
            {
                numList[i] = int.Parse(line[i]);
            }
            return numList;
        }
    }
}


Measured memory_bytes: 27904
str = gets().split(" ");
q = str[0].to_i;
h = str[1].to_i;
s = str[2].to_i;
d = str[3].to_i;
n = gets().to_i;

q_p = q / 0.25;
h_p = h /0.5;
s_p = s / 1.0;
d_p = d / 2.0;

rank = Array.new(4);
rank[0] = q_p;
rank[1] = h_p;
rank[2] = s_p;
rank[3] = d_p;
rank.sort!


jun = Array.new(4);
for i in 0..3
	case rank[i]
	when q_p
		jun[i] = 1;
	when h_p
		jun[i] = 2;
	when s_p
		jun[i] = 4;
	when d_p
		jun[i] = 8;
	end
end

pay = 0;
n = n*4;

for j in 0..3
	count = 0
	count = n / jun[j];
	n = n % jun[j];
	case jun[j]
	when 1
		itibu = count*q;
	when 2
		itibu = count*h;
	when 4
		itibu = count*s;
	when 8
		itibu = count*d;
	end
		
	pay = pay + itibu;
end

puts(pay.to_i);


Measured memory_bytes: 3836
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main() {

	int A, B, s;

	cin >> A >> B;

	s = A + B;
	int h = A - B;
	int k = A * B;

	int answer = max(s, h);
	int ans = max(answer, k);

	cout << ans << endl;

}

Measured memory_bytes: 256
n = gets.to_i
as = gets.chomp.split.map(&:to_i)
MOD = 10**9 + 7
array = Array.new(n,0)
flag = true
as.each do |i|
  array[i] += 1
end
(0..n-1).each do|i|
  if n.even?
    if (i.odd? && array[i] != 2) || (i.even? && array[i] != 0)
      flag = false
    end
  else
    if (i == 0 && array[i] != 1) || (i.odd? && array[i] != 0) || (i != 0 && i.even? && array[i] != 2)
      flag = false
    end
  end
end
puts flag ? 2 ** (n/2) % MOD : 0

Measured memory_bytes: 9612
s=input()

start_0=0
start_1=0

for i,j in enumerate(s):
  if i%2==0 and j=="1":
    start_0+=1
  elif i%2!=0 and j=="0":
    start_0+=1
  elif i%2==0 and j=="0":
    start_1+=1
  elif i%2!=0 and j=="1":
    start_1+=1
    
print(min(start_0, start_1))
  

Measured memory_bytes: 9204