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

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define _dec(i,N,j) for(int i = (N-1);i >= (j);i--)
#define _rec(i,N,j) for(int i = (N);i >=(j);i--)
#define ALL(x) x.begin(),x.end()
#define MEM(a,n) memset(a,n,sizeof(a))
#define fst first
#define scd second
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

int get_int(){int x;scanf("%d",&x);return x;}
LL get_ll(){LL x;scanf("%lld",&x);return x;}
double get_db(){double x;scanf("%lf",&x);return x;}

template<typename T> int chmin(T &a,T b){if(a > b){a = b;return 1;}else return 0;}
template<typename T> int chmax(T &a,T b){if(a < b){a = b;return 1;}else return 0;}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {_for(i,0,v.size()) os << v[i] << " ";return os;}
template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){for(auto a:v) os << a <<" ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& v){os << v.fst <<" "<<v.scd << " ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const map<T1,T2>& v){for(auto a:v) cout << a << endl;return os;}

static const int dx[8] = { -1,  0, 1, 0,  1, -1,  1, -1};
static const int dy[8] = {0,  1, 0,  -1,  1, -1, -1,  1};
const double pi  = acos(-1.0);
const double eps = 1e-8;
const LL  INF  = 0x3f3f3f3f3f3f3f3f;
const int inf  = 0x3f3f3f3f;


int main()
{
    int ok = 1;
    int N;
    cin >> N;
    _for(i,0,N){
        int num;cin >> num;
        if( (num % 2) == 0){
            if( ((num%3) != 0) && ((num % 5) != 0)) ok = 0;
        }
    }

    if(ok) cout << "APPROVED"<<endl;
    else cout << "DENIED" <<endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int abso(int x)
{
    return x>0?x:(-1*x);
}
int main()
{
    int i,j,p=0,n,k;
    cin>>n>>k;
    int h[n+1];
    for(i=1;i<=n;i++)
        cin>>h[i];
    int ans[n+1];
    ans[1]=0;
    ans[2]=abso(h[2]-h[1]);
    for(i=3;i<=n;i++)
    {
        ans[i]=ans[i-1]+abso(h[i]-h[i-1]);
        for(j=i-1,p=0;j>=1&&p<k;j--)
        {
            ans[i]=min(ans[j]+abso(h[i]-h[j]),ans[i]);
            p++;
        }
    }
    cout<<ans[n]<<endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
vector<int> v;
int main(){
	int n;
	scanf("%d", &n);
	if(n == 0) return !printf("0\n");
	for(int i=0;i<60;i++){
		int rem = n%-2;
		n /= -2;
		if(rem < 0){
			rem += 2;
			n += 1;
		}
		v.push_back(rem);
	}
	reverse(v.begin(), v.end());
	bool st = 0;
	for(int i=0;i<v.size();i++){
		if(v[i] == 1) st = 1;
		if(st) printf("%d", v[i]);
	}
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
typedef long long ll;
const ll N=605,mo=1e9+7;
ll a[N][N],b[N],c[N],ans,n,k;
ll f[N][N]; 
int main(){
	cin>>n>>k;n*=2;
	for (int i=1;i<=k;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		a[x][y]++;
		a[y][x]++;
		b[x]++;
		b[y]++;
	}
	c[0]=1;
	for (int i=1;i<=n;i++){
		for (int j=1;j<=n;j++){
			a[i][j]+=a[i-1][j]+a[i][j-1]-a[i-1][j-1];
		}
		b[i]+=b[i-1];
		if (i>1)c[i]=c[i-2]*(i-1)%mo;
	}
	ans=c[n-2*k];
	for (int i=1;i<=n;i++){
		for (int j=i+1;j<n;j++){
			int s1=a[j][j]+a[i-1][i-1]-a[j][i-1]-a[i-1][j],s2=b[j]-b[i-1];
			if (s1!=s2)continue;
			f[i][j]=c[j-i+1-s1];
			for (int l=i+1;l<j;l++)
				f[i][j]=(f[i][j]-f[i][l]*c[j-l-b[j]+b[l]])%mo;
			(ans+=f[i][j]*c[n-(j-i+1-s1)-2*k])%=mo;
		}
	}
	ans=(ans%mo+mo)%mo;
	cout<<ans<<endl;
}

Measured memory_bytes: 5888
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define ZREP(i,n) for(int i=1;i<(n);++i)
#define int ll
#define Endl endl


signed main(){
    int N;
    string s[14514];
    int Ans=0;
    int L=0,R=0,B=0;
    cin >> N;
    REP(i,N){
        cin >> s[i];
        int n=s[i].size();
        REP(j,n-1){
            if(s[i][j]=='A' && s[i][j+1]=='B'){
                Ans++;
            }
        }
        if(s[i][0]=='B' && s[i][n-1]=='A'){
            B++;
        }else if(s[i][0]=='B'){
            L++;
        }else if(s[i][n-1]=='A'){
            R++;
        }
    }
    
    //cout << Ans << " " << L << " " << R << " " << B << endl;
    if(L>0&&R>0){
        Ans+=B+1;
        L--;R--;
    }else if(L>0 && R==0){
        Ans+=B;
        L--;
    }else if(L==0 && R>0){
        Ans+=B;
        R--;
    }else{
        Ans+=max(B-1,0LL);
    }
    Ans+=min(L,R);
    
    cout << Ans << endl;
    return 0;
}


Measured memory_bytes: 896
#include <stdio.h>
#include <math.h>
 
int main() {
    int m[10];
    int ans[3];
    for(int i=0; i<10; i++) scanf("%d", &m[i]);
 
    ans[0] = 0; ans[1] = 0; ans[2] = 0;
    for(int j=0; j<10; j++) {
        if(m[ans[0]] < m[j]) {
            ans[0] = j;
        }
    }
    if(ans[1] == ans[0]) {
        if(ans[1] == 0) ans[1] = 1;
        else ans[1] = ans[0]-1;
    }
    for(int j=0; j<10; j++) {
        if(m[ans[1]] < m[j] && ans[0] != j) {
            ans[1] = j;
        }
    }
    if(ans[2] == ans[0]) {
        if(ans[2] == 0) ans[2] = 2;
        else ans[2] = ans[0]-2;
    }
    for(int j=0; j<10; j++) {
        if(m[ans[2]] < m[j] && ans[0] != j && ans[1] != j) {
            ans[2] = j;
        }
    }
    printf("%d\n%d\n%d\n", m[ans[0]], m[ans[1]], m[ans[2]]);
    return 0;
}


Measured memory_bytes: 2748
/**
 * Author : Deep Raval
 * There are no two words in the English language more harmful than "good job".
 * 1729 0_0
**/
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <bitset>
#include <iomanip>
#include <assert.h>
#include <numeric>
using namespace std;
using ll = long long;
#define endl '\n'
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) 
{
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define FAST_IO ios::sync_with_stdio(0); std::cin.tie(0);
#define bp(x) __builtin_popcount(x)
#define zf(x) __builtin_clz(x)
#define zl(x) __builtin_ctz(x)
#define par(x) __bultin_parity(x)
#define all(x) (x).begin(), (x).end()
/* **************************************************************************************** */

void test_case()
{
	FAST_IO
    string s, t;
    cin >> s >> t;
    ll ans= 0;
    for(ll i = 0; i < s.length(); i ++)
    {
        if(s[i] != t[i])
            ans++;
    }
    cout << ans << endl;
	return ;
}
int main()
{
	FAST_IO
        test_case();
	return 0;
}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
//typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define UNIQUE(c) sort(ALL(c)), c.erase(unique(ALL(c)), c.end())

const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = {0, 1, 0, -1};

int main() {
  // use scanf in CodeForces!
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N; cin >> N;
  vector<int> A(3), B(3);
  REP(i, 3) cin >> A[i];
  REP(i, 3) cin >> B[i];

  vector<int> dp(N+1);
  REP(w, N+1) {
    REP(i, 3) {
      if (w >= A[i]) {
        dp[w] = max(dp[w], dp[w-A[i]] + B[i] - A[i]);
      }
    }
  }

  int M = *max_element(ALL(dp)) + N;
  vector<ll> dp2(M+1);
  REP(w, M+1) {
    REP(i, 3) {
      if (w >= B[i]) {
        dp2[w] = max(dp2[w], dp2[w-B[i]] + A[i] - B[i]);
      }
    }
  }

  cout << *max_element(ALL(dp2)) + M << endl;

  return 0;
}


Measured memory_bytes: 195584
#include<iostream>
#include<algorithm>
#include<vector>
#include<utility>
#include<climits>
#include<cstring>
#include<cmath>
#include<stdio.h>

using namespace std;

int main(){
	long long a,b,c,k;
	cin>>a>>b>>c>>k;
	if(k%2)
		cout<<b-a;
	else
		cout<<a-b;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.util.stream.*;
 
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    List<Integer> list = new ArrayList<Integer>();
    for(int i = 0; i < n; i++) {
    	list.add(sc.nextInt());
    }
    
    //重複を削除
    List<Integer> ans = list.stream().distinct().collect(Collectors.toList());
    
    System.out.println(ans.size());
  }
}


Measured memory_bytes: 28500
/**
 * ????§???¢

????§???¢????????? a, b ??¨?????????????§? C ???????????????????§???¢?????¢??? S?????¨????????? L, a ???????????¨????????¨???????????? h ????±???????????????°?????????????????????????????????

Input
a ?????????, b ?????????, C?????§????????????????????´??°???????????????????????§?????????????????????

Output
S, L, h ???????????????1??????????????????????????????0.0001??\????????????????????£????????????????????¨????????????

Sample Input
4 3 90
Sample Output
6.00000000
12.00000000
3.00000000
 */

#include <iostream>
#include <sstream>
#include <cmath>
#include <iomanip>

int main(int argc, char const *argv[]) {
  std::string Param;
  std::istringstream iss;
  double a, b, c;
  unsigned short C;
  double S, L, h;
  const double Pi = atan((double)INFINITY) * 2;

  getline(std::cin, Param);
  iss.str(Param);
  iss >> a >> b >> C;

  double Radians = C * Pi / 180;
  c = sqrt(pow(a, 2) + pow(b, 2) - 2 * a * b * cos(Radians));
  L = a + b + c;
  h = sin(Radians) * b;
  S = a * h / 2;
  std::cout << std::fixed << std::setprecision(8);
  std::cout << S << std::endl;
  std::cout << L << std::endl;
  std::cout << h << std::endl;

  return 0;
}

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

int main(){
  int A,B,K;
  cin >> A >> B >> K;
  if (B - A >= 2*K){
    for (int i = 0;i < K;i++){
      cout << A+i <<endl;
    }
    for (int i = 0;i < K;i++){
      cout << B-K+1+i <<endl;
    }
  }else{
    for (int i = 0;i <= B-A;i++){
      cout << A+i <<endl;
    }
  }
}


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

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);	cout.tie(NULL);
	int n;	cin >> n;
	map<string, int> ans;
	while(n--) {
		string s;	cin >> s;
		ans[s]++;		
	}
	cout << "AC" << " x " <<ans["AC"]<<'\n';
	cout << "WA" << " x " <<ans["WA"]<<'\n';
	cout << "TLE" << " x " <<ans["TLE"]<< '\n';
	cout << "RE" << " x " <<ans["RE"] <<'\n';
	return 0;
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
template<typename T> inline void chkmin(T &a, const T &b) { a = a < b ? a : b; }
template<typename T> inline void chkmax(T &a, const T &b) { a = a > b ? a : b; }

const int MAXN = 3005;
int a[MAXN], f[MAXN], n;
vector<int> gra[MAXN];

void dfs(int u, int fa) {
	f[u] = 0;
	for (int v : gra[u]) if (v != fa && a[v] < a[u]) {
		dfs(v, u);
		f[u] |= !f[v];
	}
}

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%d", a + i);
	for (int i = 1; i < n; i++) {
		int u, v; scanf("%d%d", &u, &v);
		gra[u].push_back(v), gra[v].push_back(u);
	}
	for (int i = 1; i <= n; i++) {
		dfs(i, 0);
		if (f[i]) printf("%d ", i);
	}
	return 0;
}

Measured memory_bytes: 512
lines = STDIN.read.strip.lines.map(&:strip)

n = lines.first.to_i

def f(num)
    return 1 if num < 2
    num * f(num-1)
end

if n % 2 == 1
    puts 0
    exit(0)
end

curr = n
cnt = 0
while curr % 5 != 0
    curr = curr - 1
end
exp = 1
while n / (5 ** exp * 2) > 0
    cnt += (n / (5 ** exp * 2))
    exp += 1
end

# while curr > 9
    
#     curr = curr - 10
# end

puts cnt

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> sunuke(n);
  rep(i, n) sunuke[i] = 0;
  rep(i, k) {
    int d;
    cin >> d;
    rep(j, d) {
      int a;
      cin >> a; sunuke[a-1]++;
    }
  }
  int ans = 0;
  rep(i, n) if (sunuke[i] == 0) ans++;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H, W;
  cin >> H >> W;
  // H × W 要素の配列を宣言
  vector<vector<char>> data(H, vector<char>(W));

  vector<int> data_FragH(H);
  vector<int> data_FragW(W);
  // 入力
  for (int j = 0; j < H; j++) {
      for (int k = 0; k < W; k++) {
        cin >> data.at(j).at(k);
      }
   }
  
  int count;
  for( int i = 0; i < H; i++){
    count = 0;
    for ( int j = 0; j < W; j++){
      if ( data.at(i).at(j) == '.'){
        count++;
      }
    }
    if(count == W){
      data_FragH.at(i)=1;
    }
  }
  for( int i = 0; i < W; i++){
    count = 0;
    for ( int j = 0; j < H; j++){
      if ( data.at(j).at(i) == '.'){
        count++;
      }
    }
    if(count == H){
      data_FragW.at(i)=1;
    }
  }
  
  //出力
  for (int i = 0; i < H; i++) {
    if (data_FragH.at(i)==0){
      for (int j = 0; j < W; j++) {
        if (data_FragW.at(j)==0){
        	cout << data.at(i).at(j);
        }
      }
      cout << endl;
    }
    
   }
}

Measured memory_bytes: 256
n = gets.to_i

def encoder(x)
  a = x.to_s[0]
  b = x.to_s[-1]
  
  a+b
end

map = {}
(1..n).each do |i|
  encoded = encoder(i)
  if map[encoded]
    map[encoded] += 1
  else
    map[encoded] = 1
  end
end

count = 0
(1..n).each do |j|
  encoded = encoder(j)
  if encoded.size == 1
    oposite = encoded
  else
    oposite = encoded[1]+encoded[0]
  end
  count += map[oposite] if map[oposite]
end

puts count

Measured memory_bytes: 1788
fun main(args: Array<String>) = yorukatsu22c()

fun yorukatsu22c() {
    val list = (1..3).map { readLine()!!.map { it - 'a' } }.toMutableList()

    var turn = 0

    while (true) {
        val next = if (list[turn].isEmpty())
            return println((turn + 'A'.toInt()).toChar()) else list[turn].first()
        list[turn] = list[turn].drop(1)
        turn = next
    }
}


Measured memory_bytes: 33732
import java.util.*;
import java.io.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.lang.Math.*;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
        int n,i,j,v;
        Scanner scan=new Scanner(System.in);
        n=scan.nextInt();
        int m[]=new int[n];
        int k[]=new int[n];
        for(i=0;i<m.length;i++)
        {
        	m[i]=scan.nextInt();
        }
        
        for(i=0;i<m.length-1;i++)
        {
        	System.out.print(m[i]+" ");
        }
        System.out.println(m[n-1]);
        for(i=1;i<=m.length-1;i++)
        {
        	v=m[i];
        	j=i-1;
        	while(j>=0&&m[j]>v)
        	{
        		m[j+1]=m[j];
        		j--;
        	}
        	m[j+1]=v;
        	for(j=0;j<m.length-1;j++)
        	{
        		System.out.print(m[j]+" ");
        	}
        	System.out.println(m[n-1]);
        }
	}
}

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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

const int ST_MAX = (1 << 21);
const int INF = 1e9 + 7;

template <class T> class ST{
	T x[ST_MAX * 2];
	
	T eval(T a , T b){			//評価
		return min(a,b);
	}
	
	void ren(int a){			//更新
		x[a] = eval(x[2 * a] , x[2 * a + 1]);
		if(a > 0) ren(a / 2);
	}
	
	T read_ST(int a , int b , int e , int s , int f){		//値の取得
		if(e <= s || f <= b) return INF;
		if(s <= b && e <= f) return x[a];
		return eval(read_ST(2 * a , b , (b + e) / 2 , s , f) , read_ST(2 * a + 1 , (b + e) / 2 , e , s , f));
	}
	
public:
	
	ST(){
		fill(x,x+ST_MAX*2,INF);
	}
	
	void put(int a , T b){	//更新の開始
		if(x[a+ST_MAX] <= b) return;
		x[a + ST_MAX] = b;
		ren((a + ST_MAX) / 2);
	}
	
	T get(int s , int f){	//値の取得の開始
		return read_ST(1 , 0 , ST_MAX , s , f);
	}
};

const int MC = 200010;
int N,Q;
int b[MC];
int s[MC];
P2 p[MC];
ST<int> st;

int main(){
	cin >> N;
	repp(i,1,N+1){
		cin >> b[i];
		s[i] = s[i-1] + !b[i];
	}
	cin >> Q;
	repp(i,0,Q){
		cin >> p[i].first >> p[i].second;
	}
	sort(p,p+Q);
	int ans = 0;
	int it = 0;
	repp(i,1,N+1){
		while(it < Q && p[it].first == i){
			int z = st.get(i,p[it].second);
			st.put(p[it].second,min(z,ans+s[N]-s[i-1]));
			//cout << ' ' << p[it].first << ' ' << p[it].second << ' ' << z << ' ' << ans+s[N]-s[i-1] << endl;
			++it;
		}
		ans = min(ans+b[i],st.get(i,i+1)-s[N]+s[i]);
		//cout << i << ' ' << ans << endl;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 19840
# coding: utf-8
# Your code here!

import math

a, b, C = map(int, input().split())
S = a * b * 0.5 * math.sin(math.radians(C))
L = a + b + (a * a + b * b - 2 * a * b * math.cos(math.radians(C))) ** 0.5
h = b * math.sin(math.radians(C))

print('{:.8f}'.format(S))
print('{:.8f}'.format(L))
print('{:.8f}'.format(h))


Measured memory_bytes: 5724
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

using static Input;
using static Util;
class Program
{
    static int L;
    static int[] A;

    static void INPUT()
    {
        L = NextInt();
        A = LineInt();
    }
    static void OUT()
    {
        var aa = new int[L + 1];
        var hs = new HashSet<int>();
        foreach (var a in A)
        {
            aa[a]++;
            hs.Add(a);
        }

        var sum = 0L;
        foreach (var a in hs)
        {
            sum += combination(aa[a], 2);
        }

        var sb = new StringBuilder();
        foreach (var a in A)
        {
            sb.Append(sum - aa[a] + 1);
            sb.AppendLine();
        }

        Console.WriteLine(sb.ToString());
    }
    static void Main(string[] args)
    {
#if DEBUG  
        //TESTINPUT();
        INPUT();

#else
        INPUT();
#endif
        OUT();
    }

    static void TESTINPUT()
    {
        L = 999;
    }

}

public class Input
{
    public const long MOD = 1000000007;
    public const int INF = 1000000007;
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}

class Util
{
    /// <summary>
    /// 階乗
    /// </summary>
    /// <param name="n"></param>
    /// <returns></returns>
    public static long Factorial(int n)
    {
        var num = 1L;
        for (var i = 2; i <= n; i++)
            num *= i;
        return num;
    }

    /// <summary>
    /// 階乗
    /// </summary>
    /// <param name="n"></param>
    /// <returns></returns>
    public static long permutation(int a, int b)
    {
        var num = 1L;
        for (var i = 0; i < b; i++)
            num *= (a - i);
        return num;
    }

    /// <summary>
    /// 組み合わせ
    /// </summary>
    /// <param name="n"></param>
    /// <returns></returns>
    public static long combination(int a, int b)
    {
        return permutation(a, b) / Factorial(b);
    }
}




Measured memory_bytes: 49724
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long int A,B,C,K;
  cin>>A>>B>>C>>K;
  long long int answer=0;
 if(K>=A){
   answer+=A;
   K-=A;
     if(K>=B){
   K-=B;
  }else{
  }
  if(K>=C){
    answer-=C;
  }else{
    answer-=K;
  }
 }else{
   answer=K;
 }

    cout<<answer<<endl;
 return 0; 
}

Measured memory_bytes: 3628
import math
N = int(input())
zeinuki = math.floor(N / 1.08)
if N != math.floor(zeinuki * 1.08):
  if N != math.floor((zeinuki + 1) * 1.08):
    print(':(')
  else:
    print(zeinuki + 1)
else:
  print(zeinuki)

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

using namespace std;
#define ll long long
#define ld long double

int main()
{
    ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
    int k;
    cin >> k;
    int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout << a[k-1] << endl;
}


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

#define MAX_N 10
#define MAX_D 10

int N, D;
int X[MAX_N][MAX_D]; 

int main() {
    cin >> N >> D;

    for (int i = 0; i < N; i++) {
        for (int j = 0; j < D; j++) {
            cin >> X[i][j];
        }
    }

    int ans = 0;
    // 1個目の点
    for (int i = 0; i <= N - 2; i++) {
        // 2個目の点
        for (int j = i + 1; j <= N - 1; j++) {
            double tmp = 0;
            // printf("i: %d, j: %d\n", i, j);
            // D 計算
            for (int k = 0; k < D; k++) {
                // printf("i: %d, j: %d X[i][k]: %d X[i + 1][k]: %d, calc %d\n", i, j, X[i][k], X[j][k], X[i][k] - X[j][k]);
                // cout << pow(X[i][k] - X[j][k], 2) << endl;
                tmp += pow(X[i][k] - X[j][k], 2);
            }
            // cout << tmp << endl;
            double a = pow(tmp, 0.5);
            // cout << a << endl;
            if (floor(a) == a) {
                ans++;
            }
        }
    }

    cout << ans << endl;
}

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

bool check(int x){
    int plus = 0;
    while(x){
        plus++;
        x /= 10;
    }
    return plus % 2 == 1;
}

int main()
{
 int n;
 cin >> n;
 int ans = 0; 
 for(int i = 0; i<= n; i++ ){
 if(check(i)){
     ans++;
 }
     
 }
 cout << ans << endl;
 return 0;
}


Measured memory_bytes: 256
function Main(arg) {
  let [s, t] = arg.trim().split('\n');
  let count = 0;
  if(s != t){
    for(i = 0; i < s.length; i++){
      const size = s.length > i+1 ? i+1 : s.length;
      if (s.substring(i, size) != t.substring(i, size) ){
        count++;
      }
    }
  }
  console.log(count);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 33052
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>

#define REP(i,a,n) for(int i=a;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define vsort(v) sort(v.begin(),v.end())
#define asort(a,n) sort(a, a + n)
#define vi vector<int>
#define vd vector<double>

//ここからAtCoder向けdefine
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;

using namespace std;

int main(){
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    int amari = 0;
    int tgt = N;
    while(N > 0){
        amari += N % 10;
        N = N / 10;
    }
    if(tgt % amari == 0){
        yes;
    }else{
        no;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

const int INF = 1001001001;


const ll M = 1000000007;
vector<ll> fac(3000001); //n!(mod M)
vector<ll> ifac(3000001); //k!^{M-2} (mod M) 

ll mpow(ll x, ll n){ //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % M;
        x = x*x % M;
        n = n >> 1;
    }
    return ans;
}

ll comb(ll a, ll b){ //aCbをmod計算
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % M;
    return tmp * fac[a] % M;
}

int main(){
    ll x, y;
    ll mod = 1e9 + 7;
    cin >> x >> y;
    if (y>2*x || y<x/2.0) cout << 0 << endl;
    else if ((2*x-y)%3==0) {
        fac[0] = 1;
        ifac[0] = 1;
        for(ll i = 0; i<3000000; i++){
            fac[i+1] = fac[i]*(i+1) % M; // n!(mod M)
            ifac[i+1] = ifac[i]*mpow(i+1, M-2) % M; // k!^{M-2} (mod M) ←累乗にmpowを採用
        }
        int a = (-x + 2*y) / 3;
        int b = (2*x - y ) / 3;
        //cout << a << " " << b << endl;
        cout << comb(a+b, b)%M << endl;
    } else cout << 0 << endl;
}


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

using namespace std;
using ll=long long;
using ull=unsigned long long;

typedef pair<int,int>Pi;
typedef pair<long long,long long>P;
typedef pair<long long,P>PP;
typedef pair<P,P>PPP;

const long long MOD=1e9+7;
const long long INF=5e18;
const int di[4]={1,0,-1,0};
const int dj[4]={0,1,0,-1};

#define fr first
#define sc second
#define pb push_back
#define eb emplace_back
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()

ll n,a[100010];

void input(){
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i];
	return;
}

void solve(){
	for(int i=0;i<n;i++){
		if(a[i]%2==1){
			cout<<"first"<<endl;
			return;
		}
	}
	cout<<"second"<<endl;
	return;
}

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

Measured memory_bytes: 1024
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys
# from pprint import pprint

mat = [[x for x in map(int, sys.stdin.readline().rstrip().split()) ] for y in range(3)]

# print(mat)

t = mat[0][0]

da1 = mat[1][0] - t
da2 = mat[2][0] - t

db1 = mat[0][1] - t
db2 = mat[0][2] - t

flag = True

# Row 2
if not (mat[1][1] == t + da1 + db1 and mat[1][2] == t + da1 + db2):
  flag = False

# Row 3
if not (mat[2][1] == t + da2 + db1 and mat[2][2] == t + da2 + db2):
  flag = False

if flag:
  print('Yes')
else:
  print('No')


Measured memory_bytes: 3064
a_b = [int(x) for x in input().split()]

for i in range(len(a_b)):
    num=a_b[i]
    if num==1:
        num=1000
    a_b[i] = num
    
ans='Draw'
if a_b[0] > a_b[1]:
    ans='Alice'
elif a_b[0] < a_b[1]:
    ans='Bob'
    
print(ans)

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

const int mo=1e9+7;
int n,a[110],dp[55][110][110];

int main()
{
#ifdef h10
	freopen("F.in","r",stdin);
	freopen("F.out","w",stdout);
#endif
	int i,j,k,l;
	scanf("%d",&n);
	for (i=1;i<n<<1;i++)
		scanf("%d",&a[i]);
	if (n==1) {puts("1"); return 0;}
	sort(a+1,a+n+n);
	int L=(a[n-1]!=a[n]);
	int R=(a[n]!=a[n+1]);
	dp[n][1+L+R][1+L]=1;
	for (i=n;i>1;i--)
	{
		int L=(a[(i-1)-1]!=a[(i-1)]);
		int R=(a[n+n-(i-1)]!=a[n+n-(i-1)+1]);
		for (j=1;j<n<<1;j++)
		for (k=1;k<=j;k++)
			if (dp[i][j][k])
			{
				for (l=1;l<k;l++)
					(dp[i-1][j-(k-l-1)+L+R][l+L]+=dp[i][j][k])%=mo;
				(dp[i-1][j+L+R][k+L]+=dp[i][j][k])%=mo;
				for (l=k+1;l<=j;l++)
					(dp[i-1][j-(l-k-1)+L+R][k+1+L]+=dp[i][j][k])%=mo;
			}
	}
	int Ans=0;
	for (j=1;j<=n+n+2;j++)
	for (k=1;k<=j;k++)
		(Ans+=dp[1][j][k])%=mo;
	printf("%d\n",Ans);
}


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

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC targett("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
#define fast ios::sync_with_stdio(0);cin.tie(0);
#define endl        '\n'
#define ll          long long int
#define pb          push_back
#define sz(x)       (int)(x).size()
const ll mod = 1e9 + 7;

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


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

//--------------------------------------------------------------------------------------------------------------------------//

ll dp[100005];
int main() {
	fast
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int n;
	cin >> n;
	int h[n];
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}

	for (int i = 1; i < n; i++) {
		if (i == 1) {
			dp[i] = dp[i - 1] + abs(h[i] - h[i - 1]);
		} else {
			dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]) , dp[i - 2] + abs(h[i] - h[i - 2]));
		}
	}
	cout << dp[n - 1] << endl;


	return 0;

}





Measured memory_bytes: 4684
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
ll MOD = 1000000007ll;
using namespace std;

int main(int argc, char const *argv[])
{
    ll n, k;
    cin >> n >> k;
    vector<int> a(n, 0);
    rep(i, n) cin >> a[i];
    map<int, ll> mp, mp2;
    rep(i, n) rep(j, i + 1, n)
    {
        if (a[i] > a[j])
        {
            mp[i]++;
        }
        if (a[j] > a[i])
            mp2[j]++;
    }
    ll ans = 0;
    ll kk = k * (k + 1) / 2;
    kk %= MOD;
    ll kk2 = k * (k - 1) / 2;
    kk2 %= MOD;
    rep(i, n)
    {
        // cerr << mp[i] << endl;
        ans += mp[i] * kk;
        ans %= MOD;
        ans += mp2[i] *kk2;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A[] = {1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,
                       15,2,2,5,4,1,4,1,51};
  int K;
  cin >> K;
  cout << A[K-1] << endl;
  return 0;
}


Measured memory_bytes: 256
x, k, d = list(map(int, input().split()))

x = abs(x)
m = x//d

if m > k:
    print(x-k*d)
else:
    k2 = k-m
    if k2 % 2 == 0:
        print(x-m*d)
    else:
        print(abs(x-(m+1)*d))

Measured memory_bytes: 9180
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#include <map>
#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++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }




int main() {
    double x,t;
    cin >> x >> t;
    cout << x/t << endl;
}


Measured memory_bytes: 256
N, *A = map(int, open(0).read().split())
MOD = 998244353

S = sum(A)
dp0 = [0]*(S+1)
dp0[0] = 1
for a in A:
    for i in range(S, a-1, -1):
        dp0[i] = (dp0[i] + dp0[i-a]*2) % MOD
dp1 = [0]*(S+1)
dp1[0] = 1
for a in A:
    for i in range(S, a-1, -1):
        dp1[i] = (dp1[i] + dp1[i-a]) % MOD

ans = pow(3, N, MOD)
for L in range(0, S+1):
    if L <= S-L:
        ans = (ans - dp0[L]*3) % MOD
if S % 2 == 0:
    ans = (ans + dp1[S//2]*3) % MOD
print(ans)

Measured memory_bytes: 43356
N,X,Y = list(map(int, input().split()))
X,Y = X-1,Y-1
ans = [0] * (N-1)
for i in range(N):
  for j in range(i+1,N):
    d = min(j-i, abs(j-X) + 1 + abs(i-Y), abs(j-Y) + 1 + abs(i-X))
    ans[d-1] += 1
    
for a in ans:
  print(a)
  
#print(ans)

Measured memory_bytes: 3444
import glob
import os
import numpy as np


bn = os.path.basename(__file__).split('.')[0]
dn = os.path.dirname(__file__).split('/')

# 問題ごとのディレクトリのトップからの相対パス
REL_PATH = dn[len(dn)-2] + '\\' + dn[len(dn)-1] + '\\' + bn

# テスト用ファイル置き場のトップ
TOP_PATH = 'C:\\AtCoder'

class Common:

    problem = []
    index = 0

    def __init__(self, rel_path):
        self.rel_path = rel_path

    def initialize(self, path):
        file = open(path)
        self.problem = file.readlines()
        self.index = 0
        return

    def input_data(self):
        try:
            IS_TEST
            self.index += 1
            return self.problem[self.index-1]

        except NameError:
            return input()

    def resolve(self):
        pass

    def exec_resolve(self):
        try:
            IS_TEST
            for path in glob.glob(TOP_PATH + '\\' + self.rel_path + '/*.txt'):
                print("Test: " + path)
                self.initialize(path)
                self.resolve()
                print("\n\n")
        except NameError:
            self.resolve()


class Solver(Common):

    def rec(self, N, M, X, now_index, now_knowledge, now_price, books):

        if now_index > N:
            return 12 * 10**5 +1

        next_knowledge = now_knowledge + books[now_index][1:]
        if np.min(next_knowledge) >= X:
            result1 = now_price + books[now_index][0]
        else:
            result1 = self.rec(N, M, X, now_index+1, next_knowledge,  now_price + books[now_index][0], books)

        result2 = self.rec(N, M, X, now_index+1, now_knowledge,  now_price, books)

        if result1 < result2:
            return result1
        else:
            return result2

    def resolve(self):

        N, M, X = map(int, self.input_data().split())

        books = [None]*(N+1)
        for i in range(N):
            books[i+1] = np.array(list(map(int, self.input_data().split())))

        result = self.rec(N, M, X, 1, np.zeros(M), 0, books)
        if result == 12 * 10**5 +1:
            print('-1')
        else:
            print(str(result))


solver = Solver(REL_PATH)
solver.exec_resolve()


Measured memory_bytes: 27208
// https://atcoder.jp/contests/abc062/tasks/abc062_c
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int h, w;
    cin >> h >> w;
    if (h % 3 == 0 || w % 3 == 0) {
        cout << "0\n";
    } else {
        int minv = 1e9;
        REP(e, 2) {
            int h1 = h / 3;
            int w1 = w / 2;
            vector<int> s(3);
            REP(i, 2) REP(j, 2) {
                s[0] = (h1 + i) * w;
                s[1] = (h - h1 - i) * (w1 + j);
                s[2] = (h - h1 - i) * (w - w1 - j);
                sort(ALL(s));
                minv = min(minv, abs(s[0] - s[2]));
            }
            swap(h, w);
        }
        if (w % 3 != 0) {
            minv = min(minv, h);
        }
        if (h % 3 != 0) {
            minv = min(minv, w);
        }

        cout << minv << "\n";
    }

    return 0;
}


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

#define REP(i ,n) for(int i=0 ;i < n; i++)
#define REPB(i ,n) for(int i=n; i >= 0; i--)
#define FOR(i ,m ,n) for(int i=m; i < n; i++)
#define FORB(i, m, n) for(int i=m; i>= m; i--)
#define ll long long
#define pb push_back
#define popb pop_back
#define debug(i) cout << i << endl
using namespace std;
int main(){
  int a,b,c;
  cin >> a >> b >> c;

  cout << min(c, b / a) << endl;
  return 0;
}

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

class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int n = saori.saori_hayami();
		HashSet<String> s = new HashSet<>();
		for(int i = 0;i < n;i++){
			String str = saori.nextHayami();
			if(!s.contains(str)){
				s.add(str);
			}
		}
		System.out.println(s.size());
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 60932
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define X                           first
#define Y                           second
#define sep                         ' '
#define endl                        '\n'
#define SZ(x)                       ll(x.size())

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

const ll MAXN = 1e5 + 10;
const ll LOG = 22;
const ll INF = 8e18;
const ll MOD = 1e9 + 7; // 998244353; // 1e9 + 9;

ll k , ans;

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

    cin >> k;
    for(int i = 1 ; i <= k ; i++){
        for(int j = 1 ; j <= k ; j++){
            for(int l = 1 ; l <= k ; l++){
                ans += __gcd(__gcd(i , j) , l);
            }
        }
    }
    cout << ans << endl;

    return 0;
}
/*

*/


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	string s,t,res="";
	cin>>n;
	assert(n>=1 && n<=100);
	cin>>s;
	cin>>t;
	for(int i=0;i<n;i++){
		res=res+s[i]+t[i];
	}
	cout<<res<<endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <set>
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
using namespace std;

#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (int i=0; i < (int)(n); i++)  // 0 ~ n-1
#define REPN(i, n) for (int i=1; i <= (int)(n); i++)  // 1 ~ n
#define MIN(vec) min_element(ALL((vec)))  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
typedef long long ll;

const int MOD = 1000000007;  // 1 000 000 007

ll bans[60];
ll paty[60];

ll f(ll n, ll x) {
    if (n == 0) return x <= 0 ? 0 : 1;
    else if (x <= 1 + bans[n - 1]) return f(n - 1, x - 1);
    else if (x == 2 + bans[n - 1]) return 1 + paty[n - 1];
    else return paty[n - 1] + 1 + f(n - 1, x - 2 - bans[n - 1]);
}

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

    // input
    ll N, X;
    cin >> N >> X;
    
    bans[0] = 1;
    paty[0] = 1;
    for (int i = 1; i < N; ++i) {
        bans[i] = 2*bans[i - 1] + 3;
        paty[i] = 2*paty[i - 1] + 1;
    }
    
    cout << f(N, X) << "\n";

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int W=sc.nextInt();
        int H=sc.nextInt();
        int x=sc.nextInt();
        int y=sc.nextInt();
        int r=sc.nextInt();
        if(H>=y+r&&W>=x+r&&0<=y-r&&0<=x-r)
            System.out.println("Yes");
        else
            System.out.println("No");
    }
}


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

int main() {
	int	N;
	cin >> N;
	vector<int> vec;
	rep(i, N)
	{
		int a;
		cin >> a;
		vec.push_back(a);
	}
	int M;
	cin >> M;
	rep(i, M)
	{
		int bg, en, a;
		cin >> bg >> en >> a;
		vector<int>::iterator itb, ite;
		itb = next(vec.begin(), bg);
		ite = next(vec.begin(), en);
		int	count;
		count = 0;
		for (itb; itb != ite; itb++)
		{
			if (*itb == a)
				count++;
		}
		cout << count << endl;
	}
}



Measured memory_bytes: 3144
mygcd :: Integral a => a -> a -> a
mygcd a 0 = a
mygcd a b = mygcd b $ mod a b

main :: IO ()
main = putStr . unlines .
    map (\(a : b : _) -> show $ mygcd a b) .
        map (map read) . map words . lines =<< getContents

Measured memory_bytes: 3992
using System;
class Program
{
    static void Main(string[] args)
    {

        string[] s = Console.ReadLine().Split(' ');

        int a, b;

        a = int.Parse(s[0]);
        b = int.Parse(s[1]);
       

        Console.WriteLine("{0} {1}", a*b,a*2+b*2);

        return;
    }

}

Measured memory_bytes: 9160
#include <iostream>
#include <vector>
#include <algorithm>
#define ll long long
#define int long long
using namespace std;

signed main() {
	int n;
	cin >> n;
	vector<ll> a(n + 1);
	for (int i = 0; i <= n; i++)
		cin >> a[i];
	vector<ll> mx(n + 1);
	vector<ll> mn(n + 1);
	mn[n] = a[n];
	mx[n] = a[n];
	for (int i = n - 1; i >= 0; i--) {
		ll big = mx[i + 1] + a[i];
		ll small = (mn[i + 1] + 1) / 2 + a[i];
		mx[i] = big;
		mn[i] = small;
	}
	ll answer = 0;
	ll now = 1;
	if (now < mn[0]) {
		cout << -1 << endl;
		return 0;
	}
	for (int i = 0; i < n; i++) {
		answer += now;
		now -= a[i];
		if (now < 0) {
			cout << -1 << endl;
			return 0;
		}
		ll gen = min(now * 2, mx[i + 1]);
		if (gen < mn[i + 1] || gen < now) {
			cout << -1 << endl;
			return 0;
		}
		now = gen;
	}
	answer += now;
	cout << answer << endl;
}

Measured memory_bytes: 5636
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int n,v,p;
ll a[100100],b[100100],m;

bool check(int j){
	int i,cnt=0;
	ll t,lft,tmp;
	for(i=0; i<n; ++i){
		b[i] = a[i];
	}
	lft = m*(v-1);
	b[j] += m; t = b[j];
	for(i=0; i<n; ++i){
		if(!lft){
			break;
		}
		tmp = min({m+a[i]-b[i],max(t-b[i],0ll),lft});
		b[i] += tmp;
		lft -= tmp;
	}
	for(i=n-1; i>=0; --i){
		if(!lft){
			break;
		}
		tmp = min(m+a[i]-b[i],lft);
		b[i] += tmp;
		lft -= tmp;
	}
	if(lft){
		return false;
	}
	for(i=0; i<n; ++i){
		if(b[i]>b[j]){
			++cnt;
		}
	}
	return (cnt<p);
}

int main(void){
	int i,ok,ng,med,ans=0;
	cin >> n >> m >> v >> p;
	for(i=0; i<n; ++i){
		cin >> a[i];
	}
	sort(a,a+n);
	ok = n-1; ng = -1;
	while(ok-ng>1){
		med = (ok+ng)/2;
		if(check(med)){
			ok = med;
		}else{
			ng = med;
		}
	}
	for(i=0; i<n; ++i){
		if(a[i]>=a[ok]){
			++ans;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1792
import math
from collections import Counter

def comb(n,r):
    f=math.factorial
    return f(n)//(f(r)*f(n-r))

N,A,B=list(map(int,input().split()))
v=sorted(list(map(int,input().split())),reverse=True) # 全要素

m=sum(v[:A])/A # 平均値の最大値(A個の場合)

c=Counter(v[:A]) # 大きい方からA個の要素のみ
# この中の最小の要素は，v[A-1]
a=v[A-1]

n=v.count(a) # v内のaの個数
r=c[a] # c内のaの個数

# n個のaの中から，r個を選ぶ方法
ans=comb(n,r)

# n個のaの中から，r個以上min(r+(B-A),n)個以下を選ぶ方法
# ※これはv[0]==v[A]のときのみ
if v[0]==v[A]:
    for i in range(r+1,min(r+(B-A)+1,n+1)):
        ans+=comb(n,i)

print(m)
print(ans)

Measured memory_bytes: 39024
import sys

if __name__ == "__main__":
    lines = sys.stdin.readlines()
    A = map(int, lines[1].split())
    H = len(A)

    for i in range(H):
        print "node {0}: key = {1},".format(i + 1, A[i]),
        if i > 0:
            print "parent key = {0},".format(A[(i + 1) / 2 - 1]),
        if 2 * i + 1 < H:
            print "left key = {0},".format(A[2 * i + 1]),
            if 2 * i + 2 < H:
                print "right key = {0},".format(A[2 * i + 2]),
        print ""

Measured memory_bytes: 6452
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <string>
#include <vector>
#include <iomanip>
#include <iterator>
#include <algorithm>

using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) rep(i, 0, n)
#define reprrev(i, a, b) for (int i = (int)(b) - 1; i >= (int)(a); i++)
#define reprev(i, n) reprrev(i, 0, n)

typedef vector<int> vi;
typedef vector<string> vs;

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

	if (A + B > C + D) {
		cout << "Left" << endl;
	}
	else if (A + B < C + D) {
		cout << "Right" << endl;
	}
	else {
		cout << "Balanced" << endl;
	}

	return 0;
}




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

int p[1000006];
map<int,int> m;
void fun()
{
	p[1]=1,p[0]=1;
	for(int i=0;i<1000006;i++)
		p[i]=i;
	for(int i=2;i*i<1000006;i++)
	{
		if(p[i]==i)
		{
			for(int j=i;j<1000006;j+=i)
			{
				if(p[j]==j)
					p[j]=i;
			}
		}
	}
}
int fun1(int x)
{
	vector<int> v;
	map<int,int> m1;
	while(x!=1)
	{
		if(m1[p[x]]==0)
			v.push_back(p[x]);
		m1[p[x]]=1;
		x/=p[x];
	}
	// for(int i=0;i<v.size();i++)
	// 	cout<<v[i]<<" ";
	// cout<<endl;
	for(int i=0;i<v.size();i++)
	{
		if(m[v[i]]!=0)
			return 1;
		m[v[i]]=1;
	}
	return 0;
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout<<setprecision(10)<<fixed;
	
	int n;
	cin>>n;
	int a[n];
	fun();
	for(int i=0;i<n;i++)
		cin>>a[i];
	int g=a[0];
	for(int i=1;i<n;i++)
		g=__gcd(g,a[i]);
	if(g!=1)
		cout<<"not coprime"<<endl;
	else
	{
		int f=0;
		for(int i=0;i<n;i++)
		{
			int t1=fun1(a[i]);
			if(t1==1)
			{
				f=1;
				break;
			}
		}
		if(f==1)
			cout<<"setwise coprime"<<endl;
		else
			cout<<"pairwise coprime"<<endl;
	}
	return 0;
}

Measured memory_bytes: 19200