akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  int x,a;
  cin >> x >> a;
  if(x<a){
    cout << 0 << endl;
  }else{
    cout << 10 << endl;
  }
}


Measured memory_bytes: 256
# coding: utf-8
n = int(input())
L = list(map(int,input().split()))
l=[]
A=[]
ans=0
for i in range(n-2):
    for j in range(i+1, n-1):
        for k in range(j+1, n):
            a=L[i]
            b=L[j]
            c=L[k]
            if a!=b and b!=c and c!=a and a+b>c and b+c>a and c+a>b:
                #print(i+1,j+1,k+1)
                #print(a,b,c)
                ans += 1
#print(L)
#print()
print(ans)

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    int C0 = 0, C1 = 0, C2 = 0, C3 = 0;
    for (int i = 0; i < N; ++i) {
        string S;
        cin >> S;
        if (S == "AC") {
            ++C0;
        } else if (S == "WA") {
            ++C1;
        } else if (S == "TLE") {
            ++C2;
        } else {
            ++C3;
        }
    }
    cout << "AC x " << C0 << '\n';
    cout << "WA x " << C1 << '\n';
    cout << "TLE x " << C2 << '\n';
    cout << "RE x " << C3 << '\n';
    return 0;
}

Measured memory_bytes: 3644
package main

import (
	"fmt"
	"strconv"
)


// bit全探索

func main() {
	var abcd, ans string
	fmt.Scan(&abcd)

	var sum int
	s := split(abcd)
	for bit := 0; bit < (1 << (len(s)-1)); bit++ {
		num, _ := strconv.Atoi(s[0])
		sum = num
		ans = s[0]

		for i := 0; i < len(s) - 1; i++ {
			num, _ = strconv.Atoi(s[i+1])
			if (bit >> i) & 1 == 1{
				sum += num
				ans += "+" + s[i+1]
			} else {
				sum -= num
				ans += "-" + s[i+1]
			}
		}
		if sum == 7 {
			ans += "=7"
			break
		}
	}
	fmt.Println(ans)
}

func split(s string) []string {
	ret := make([]string, len([]rune(s)))
	for i, v := range []rune(s) {
		ret[i] = string(v)
	}
	return ret
}


Measured memory_bytes: 1772
import java.io.*;

class Main {

	public static void main(String args[]) throws IOException {
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);
		
		String str = br.readLine();
		
		char ch[] = str.toCharArray();
		
		for(int i = 0; i < ch.length; i++){
			if(Character.isUpperCase(ch[i])){
				ch[i] = Character.toLowerCase(ch[i]);
			}else ch[i] = Character.toUpperCase(ch[i]);
		}
		for(int i = 0; i < ch.length; i++){
			System.out.print(ch[i]);
		}	
		System.out.println();
	}
}	

Measured memory_bytes: 25064
import java.io.*;
import java.util.*;


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		int max = 0;
		
		max = Math.max(max, 10 * a + b + c);
		max = Math.max(max, a + 10 * b + c);
		max = Math.max(max, a + b + 10 * c);

		pr.println(max);
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(INPUT == null ? System.in : new ByteArrayInputStream(INPUT.getBytes()));
		pr = new Printer(System.out);

		solve();

//		pr.close();
		pr.flush();
//		sc.close();
	}

	static String INPUT = null;

	private static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
	}
}


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

using namespace std;


int main()
{
  int  A,B,K;

  cin >> A >>B >> K;
  
for (int i=min(A,B); i>0; i--) 
   { 
      if (A % i==0 && B % i == 0) 
         K--; 
      if (!K) {
         cout << i; 
         return 0;}
   } 
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 REP(i,n) for(int i = 1; i < n; i++)
#define repll(i,n) for(ll i = 0; i < n; i++)
#define REPll(i,n) for(ll i = 1; i < n; i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define yesorno(a) printf(a ? "yes\n" : "no\n")
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define YESorNO(a) printf(a ? "YES\n" : "NO\n") 
#define endl "\n"
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}


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

  int a, b, c;
  cin >> a >> b >> c;
  swap(a,b);
  swap(a,c);
  cout << a << " " << b << " " << c;
}

Measured memory_bytes: 256
// Problem : B - FizzBuzz Sum
// Contest : AtCoder Beginner Contest 162
// URL : https://atcoder.jp/contests/abc162/tasks/abc162_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define eb emplace_back
#define pb push_back
#define int long long
#define vi vector<int>
#define vv vector<vector<int>>
#define pii pair<int,int>
#define m_p(x,y) make_pair(x,y)
#define vp vector<pair<int,int>>
#define setbits(x) __builtin_popcountll(x)
#define f first
#define se second
#define inc(v,n,x) v.resize(n,x)
#define iniz(n) memset(n,0,sizeof(n))
#define inin(n) memset(n,-1,sizeof(n))
#define inimi(n) memset(n,0xc0,sizeof(n))
#define inima(n) memset(n,0x3f,sizeof(n))
#define all(v) (v).begin(),(v).end()
using namespace std;
using namespace __gnu_pbds;
template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
double pi=acos(-1.0);
int md=1e9+7;
int dx1[]={0,0,-1,1};
int dy1[]={1,-1,0,0};
template<class T>
T abst(T a)
{return a<0?-a:a;}
template<class T> using ordered_set=tree<
T,
null_type,
less_equal<T>,
rb_tree_tag,
tree_order_statistics_node_update>;
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
struct HASH{
  size_t operator()(const pii &x)const{
    return (size_t) x.first * 37U + (size_t) x.second;}};
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

int Pow(int n,int x){int ans=1;
 while(x>0)
 {if(x&1)ans=(ans*n)%md;n=(n*n)%md;x=x>>1;}
 return ans;}

 vi fact,inv;
void inverse(int n)
{inv.resize(n+1);inv[0]=1;
for(int i=1;i<=n;i++)inv[i]=Pow(fact[i],md-2);}
void factorial(int n)
{fact.resize(n+1);fact[0]=1;
for(int i=1;i<=n;i++)fact[i]=(fact[i-1]*i)%md;}
int ncr(int n,int r){
return (((fact[n]*inv[r])%md)*inv[n-r])%md;
}

int max(int a,int b){return a>b?a:b;}
int min(int a,int b){return a<b?a:b;}
void solve()
{
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int n;cin>>n;int sum=0;
for(int i=1;i<=n;i++)
{
	if(i%3==0 or i%5==0)
	continue;
	else
	sum+=i;

}
cout<<sum;
}

int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t=1;
//cin>>t;
for(int i=1;i<=t;i++)
{
    solve();
}
}


Measured memory_bytes: 3656
fun main(args: Array<String>) {
    var (a, b, c, k) = readLine()!!.split(" ").map(String::toInt)
    var num = 0
    for(i in 1..k) {
        if(a > 0) {
            num += 1
            a -= 1
            continue
        }
        if(b > 0) {
            num += 0
            b -= 1
            continue
        }
        if(c > 0) {
            num -= 1
            c -= 1
        }
    }
    println(num)
}

Measured memory_bytes: 36788
#include <cstdio>
#include <climits>
#include <algorithm>
using namespace std;

int main() {
  int i, j, k, s, t, u;
  int l[8];
  int m[8] = {4, 1, 4, 1, 2, 1, 2, 1};
  int o[8] = {0, 2, 6, 4, 7, 1, 5, 3};

  while (1) {
    for (i=0; i<8; i++) {
      s = scanf("%d", &l[i]);
    }
    if (s!=1) break;
    t = 0;
    for (i=0; i<8; i++) {
      s = 0;
      for (j=0, k=o[i]; j<8; j++, k++, k%=8) {
        s += min(l[j], m[k]);
      }
      if (s >= t) {
        t = s;
        u = i;
      }
    }
    printf("%d", m[o[u]]);
    for (i=1, j=(o[u]+1)%8; i<8; i++, j++, j%=8) {
      printf(" %d", m[j]);
    }
    printf("\n");
  }

  return 0;
}

Measured memory_bytes: 1032
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=(1LL<<60);
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    ll le = -3000LL, ri = 3000LL;
    for(ll i = le ; i < ri ; i++){
    	for(ll j = le ; j < ri ; j++){
    		if(i*i*i*i*i - j*j*j*j*j == n){
    			cout << i << " " << j << endl;
    			return 0;
    		}
    	}
    }
    return 0;
}


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

int main(){
  string str[11],str2;
  int N,t=0;
  int po[11][4],sc[11],T;
  
  while(1){
    cin>>N;

    if(N==0) break;

    for(int i=0;i<N;i++){
      cin>>str[i];
      for(int j=0;j<3;j++){
	cin>>po[i][j];
      }
    }
    for(int i=0;i<N;i++){
      sc[i]=po[i][0]*3+po[i][2];
    }
    
    for(int i=0;i<N-1;i++){
      for(int j=N-1;j>i;j--){
	if(sc[j-1]<sc[j]){
	  T=sc[j];
	  sc[j]=sc[j-1];
	  sc[j-1]=T;
	  str2=str[j-1];
	  str[j-1]=str[j];
	  str[j]=str2;
	}
      }
    }
    if(t>0) cout<<endl;
    t++;

    for(int i=0;i<N;i++){
        cout<<str[i]<<","<<sc[i]<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1212
def main():
    s = input()
    t = input()
    l = len(t)

    minCount = l

    for i in range(len(s)-l+1):
        s1 = s[i:i+l]
        count = 0
        for j in range(len(s1)):
            if s1[j] != t[j]:
                count += 1
        minCount = min(minCount, count)

    print(minCount); 
    


if __name__ == '__main__':
    main();


Measured memory_bytes: 9112
/**
 * Square Route
 */

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import static java.lang.Integer.parseInt;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;

		while ((line = br.readLine()) != null && !line.isEmpty()) {
			int n = parseInt(line.substring(0, line.indexOf(' ')));
			int m = parseInt(line.substring(line.indexOf(' ') + 1));
			if ((n | m) == 0) break;

			//
			int[] ns = new int[n + 1];
			int[] ms = new int[m + 1];

			for (int i = 1; i < n + 1; i++) {
				ns[i] = parseInt(br.readLine()) + ns[i - 1];
			}
			for (int i = 1; i < m + 1; i++) {
				ms[i] = parseInt(br.readLine()) + ms[i - 1];
			}

			//
			int[][] nm = new int[Math.max(ns[n], ms[m]) + 1][2];

			for (int i = 0; i < n; i++) {
				for (int j = i + 1; j < n + 1; j++) {
					nm[ns[j] - ns[i]][0]++;
				}
			}
			for (int i = 0; i < m; i++) {
				for (int j = i + 1; j < m + 1; j++) {
					nm[ms[j] - ms[i]][1]++;
				}
			}

			int sum = 0;
			for (int i = 1; i < nm.length; i++) {
				if (nm[i][0] != 0 && nm[i][1] != 0)
					sum += nm[i][0] * nm[i][1];
			}
			System.out.println(sum);
		} //end while
	} //end main
}

Measured memory_bytes: 90876
#include<iostream>
using namespace std;
int main()
{
	char x;
	cin>>x;
	if(x>='a'&& x<'z')
	{
		cout<<static_cast<char>(x+1);
	}
	if(x=='z') cout<<'a';
	
	
	
	
	return 0;
}


Measured memory_bytes: 256
Imports System

Public Class Program

    Public Shared Sub Main(args As String())

        Dim N As Byte = Byte.Parse(Console.ReadLine)
        Dim S() As Byte = System.Text.Encoding.ASCII.GetBytes(Console.ReadLine)


        For i As Integer = 0 To S.Length - 1
            S(i) += N
            If S(i) >= 91 Then
                S(i) -= 26
            End If
        Next

        Console.WriteLine(System.Text.Encoding.ASCII.GetChars(S))

    End Sub
End Class


Measured memory_bytes: 13140
n,m = map(int,input().split())
si = []
for i in range(m):
    p,y = map(int,input().split())
    si.append([i,p,y])
si.sort(key=lambda x:x[2])
ans = []
all = [0]*n
for i in range(m):
    now = si[i]
    all[now[1]-1] += 1
    x = all[now[1]-1]
    ans.append([now[0],now[1],x])
ans.sort(key=lambda x:x[0])
for i in range(m):
    now = ans[i]
    str_1 = str(now[1])
    str_1 = str_1.zfill(6)
    str_2 = str(now[2])
    str_2 = str_2.zfill(6)
    print(str_1+str_2)

Measured memory_bytes: 38820
#include <bits/stdc++.h>
using namespace std;
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;}
using Int = long long;
const char newl = '\n';

//INSERT ABOVE HERE
const int LOG = 60;
const int MAX = 2e5+10;
int dp[LOG][MAX];
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  int n;
  long long k;
  cin>>n>>k;
  vector<int> as(n);
  for(int i=0;i<n;i++) cin>>as[i],as[i]--;

  for(int i=0;i<n;i++) dp[0][i]=as[i];

  for(int k=1;k<LOG;k++)
    for(int i=0;i<n;i++)
      dp[k][i]=dp[k-1][dp[k-1][i]];

  int cur=0;
  for(int i=0;i<LOG;i++)
    if((k>>i)&1) cur=dp[i][cur];
  cout<<cur+1<<newl;
  return 0;
}


Measured memory_bytes: 50992
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << endl
#define debugArray(x, n)                           \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
  cerr << #x << "[" << hoge << "]: " << x[hoge] << endl
using namespace std;

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string N;
  cin >> N;
  int n = N.length();
  long long dp[n + 1][2];
  dp[n][0] = 0;
  dp[n][1] = 0;
  for (int i = n - 1; i >= 0; i--) {
    dp[i][0] = INT_MAX;
    dp[i][1] = INT_MAX;
    int dig = N[i] - '0';
    for (int j = 0; j < 10 - dig; j++) {
      dp[i][0] = min(dp[i][0], dp[i + 1][0] + j + j + dig);
    }
    for (int j = 0; j + 1 < 10 - dig; j++) {
      dp[i][0] = min(dp[i][0], dp[i + 1][1] + j + j + dig + 1);
    }
    for (int j = 10 - dig; j < 10; j++) {
      dp[i][1] = min(dp[i][1], dp[i + 1][0] + j + (j + dig) % 10);
    }
    if (i < n - 1)
      for (int j = 9 - dig; j < 10; j++) {
        dp[i][1] = min(dp[i][1], dp[i + 1][1] + j + (j + dig + 1) % 10);
      }
  }
  long long ans = min(dp[0][0], dp[0][1] + 1);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 19768
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iostream>
#define N 100005
#define int long long
using std::max;
using std::min;
using std::swap;

int n,m;
int val[N],sum[N];

int getint(){
	int x=0,f=0;char ch=getchar();
	while(!isdigit(ch)) f|=ch=='-',ch=getchar();
	while(isdigit(ch)) x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}

signed main(){
	n=getint(),m=getint();
	for(int i=1;i<=n;i++)
		val[i]=getint(),sum[i]=sum[i-1]+val[i];
	int p=std::lower_bound(val+1,val+1+n,0)-val;
	if(p==1){
		printf("%lld\n",val[m]);
		return 0;
	} int ans=2e18;
	for(int i=0;i<=min(p-1,m);i++){
		if(!i){
			if(p+m-1>n) continue;
			ans=min(ans,val[p+m-1]);
			continue;
		}
		int a=-val[p-i];
		// printf("a=%lld\n",a);
		// a-=val[p-1];
		int want=m-i;
		if(m-i+p-1>n) continue;
		int b=val[p+want-1];
		if(!want) b=0;
		// b+=val[p];
		ans=min(ans,min(2*a+b,2*b+a));
		// printf("i=%lld,ans=%lld,a=%lld,b=%lld\n",i,ans,a,b);
	} printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1792
paper = [[0 for i in range(15)] for j in range(15)]
base = 2
 
while True:
    try:
        x, y, s = list(map(int, input().split(',')))
    except EOFError:
        break
         
    x += 2
    y += 2
    if s == 3:
        paper[x-2][y] += 1
        paper[x+2][y] += 1
        paper[x][y-2] += 1
        paper[x][y+2] += 1
 
    if s >= 2:
        paper[x-1][y-1] += 1
        paper[x-1][y+1] += 1
        paper[x+1][y-1] += 1
        paper[x+1][y+1] += 1
 
    paper[x][y] += 1
    paper[x-1][y] += 1
    paper[x+1][y] += 1
    paper[x][y-1] += 1
    paper[x][y+1] += 1
 
cnt = max = 0;
for x in range(2, 12):
    for y in range(2, 12):
        if paper[x][y] == 0:
            cnt += 1
        if paper[x][y] > max:
            max = paper[x][y]
 
print(cnt, max, sep='\n')


Measured memory_bytes: 5624
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in Actual solution is at the top
 *
 * @author Silviase
 */
public class Main {

  public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    Scanner in = new Scanner(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    A01MatrixTask solver = new A01MatrixTask();
    solver.solve(1, in, out);
    out.close();
  }

  static class A01MatrixTask {

    public void solve(int testNumber, Scanner in, PrintWriter out) {
      // h w a bなら...
        /*
        0000..01111..1 (a, w-a)
        0000..01111..1
        0000..01111..1
        1111..10000..0
        1111..10000..0
        1111..10000..0
        (b, h-b)
        各列についてa,が少なく,各行についてbが少ない.
         */

      int h, w, a, b;
      h = in.nextInt();
      w = in.nextInt();
      a = in.nextInt();
      b = in.nextInt();

      int[][] ar = new int[h][w];
      for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
          ar[i][j] = (i < b) ^ (j < a) ? 1 : 0;
        }
      }

      StringBuilder sb = new StringBuilder();
      for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
          sb.append(ar[i][j]);
        }
        sb.append("\n");
      }
      out.println(sb);

    }

  }
}



Measured memory_bytes: 33996
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)

class union_find {
public:
vector<int> par,rank,lsize;
union_find(int n): par(n),rank(n),lsize(n){
   for (int i=0;i < n;i++){
      par[i]=i;
      rank[i]=0;
      lsize[i]=1;
   }
}

int find(int x){
   if (par[x]==x){
      return x;
   }
   else{
      return par[x] = find(par[x]); 
   }
}

void unite(int x ,int y){
   x=find(x);
   y=find(y);
   if (x==y) return;
   if (rank[x] < rank[y]){
      lsize[y] += lsize[x];
      lsize[x] = -1;
      par[x] = y;
   }else{
      lsize[x] += lsize[y];
      lsize[y] = -1;
      par[y]=x;
      if (rank[x]==rank[y]) rank[x]++;
   }   
}

bool same(int x, int y){
   return find(x) == find(y);
}

int size(int x){
   if (lsize[x] == -1){
      x=find(x);
   }
   return lsize[x];
}
};

int main(){
  int n;
  cin >> n;
  vector<int> v(n,0);
  rep(i,n-1){
    int x;
    cin >> x;
    v[x-1]++;
  }
  string s;
  rep(i,n){
    cout << v[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 4052
var lines = [];


var readline = require("readline");
var rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout
});

rl.on('line', function (x) {
  lines.push(x);
});

rl.on('close', function () {

  var tmp = lines.shift().split(" ");

  var N = Number(tmp[0]);
  var M = Number(tmp[1]);

  var drink = Array(N + 1);

  for (var i = 0; i < N; i++) {
    tmp = lines[i].split(" ");
    drink[i + 1] = {
      yen: Number(tmp[0]),
      hon: Number(tmp[1]),
    }
  }

  drink.sort(function (a, b) { return (a.yen - b.yen) });

  var result = 0;
  var can = M;
  for (var i = 0; i < N; i++) {
    if (can - drink[i].hon === 0) { result = result + can * drink[i].yen; break; }
    else if (can - drink[i].hon < 0) { result = result + can * drink[i].yen; break; }
    else {
      result = result + drink[i].hon * drink[i].yen;
      can = can - drink[i].hon;

    }
  }

  console.log(result)
});


Measured memory_bytes: 51596
import sys

n = int(input())
s = input()

array = [[True, True], [True, False], [False, False], [False, True]]

for i in range(1, n):
  for v in array:
    flag = ((s[i] == 'o') == v[i])
    v.append((flag == v[i-1]))
    
for v in array:
  flag1 = (v[1] == v[-2])
  flag2 = ((s[0] == 'o') == v[0])
  flag = (flag1 == flag2)
  
  if v[0] == v[-1] and flag:
    for c in v[0:len(v)-1]:
      if c:
        print('S', end='')
      else:
        print('W', end='')
        
    print()
    
    sys.exit(0)
    
print(-1)

Measured memory_bytes: 8636
#include <bits/stdc++.h>
using namespace std;
void solve(int n,int m,int a){
    int h,p,q;
    vector<vector<int>> loute(n+1,vector<int>(1000,0));
    for(int i=0;i<m;i++){
        cin>>h>>p>>q;
        loute[p][1000-h]=q;
        loute[q][1000-h]=p;
    }
    int loc=a;
    for(int i=0;i<1000;i++){
        if(loute[loc][i])loc=loute[loc][i];
    }
    cout<<loc<<endl;
}
int main(){
    int n,m,a;
    while(cin>>n>>m>>a,n){
        solve(n,m,a);
    }
}



Measured memory_bytes: 3256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define puf push_front
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
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 (a>b) { a=b; return 1; } return 0; }

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

    string s; cin >> s;
    int cnt = 0;
    rep(i,s.size()) {
        if(s[i] == '1') cnt++;
    }
    cout << cnt << endl;
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
main()
{ int n,b,i=9,ans=0;
cin>>n;
while(n!=1)
     {
         if(n%i)
         i--;
         else
         {
             n=n/i;
             ans++;
         }
         if(i==1)
         break;
         
    }
    if(ans<=2)
    {
     if(n==1)
     cout<<"Yes"<<endl;
     else
     cout<<"No"<<endl;
}
else
cout<<"No"<<endl;
}

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

using namespace std;

int main(){

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int n;
    cin >> n;

    bool ok = false;
    int sol;

    for(int i=1;i<=n;++i){
        if((int)(i*1.08) == n){
            ok = true;
            sol = i;
            break;
        }
    }

    if(ok) cout << sol << '\n';
    else cout << ":(\n";

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define fr(i, a, b) for (ll i = a; i < b; i++)
#define pb(v, a) v.push_back(a)
#define Sort(v) sort(v.begin(), v.end())
#define For(m) for (auto it = m.begin(); it != m.end(); it++)
#define mod 1000000007
#define PI 3.14159265358979323846
#define fast                                                                   \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(NULL);
using namespace std;

  
int main() {
  fast 
  ll a,b;
  cin >> a >> b;
  ll x =max(a,b);
  if(a==b)
  {
      cout << 2*a;
      return 0;
  }
  cout << 2*x-1;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int N,Q;
int S[2<<17];
vector<int>G[2<<17];
void dfs(int u,int p,int s)
{
	S[u]+=s;
	for(int v:G[u])if(v!=p)dfs(v,u,S[u]);
}
main()
{
	cin>>N>>Q;
	for(int i=1;i<N;i++)
	{
		int a,b;cin>>a>>b;a--,b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	for(int i=0;i<Q;i++)
	{
		int p,x;cin>>p>>x;
		S[p-1]+=x;
	}
	dfs(0,-1,0);
	for(int i=0;i<N;i++)cout<<S[i]<<endl;
}

Measured memory_bytes: 24960
//
//AtCoder Beginner Contest 124
//A
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>
#include <bitset>
#include <numeric>

using namespace std;

#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--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;

const double PI = 3.14159265358979323846;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }            //最小公倍数

int main()
{
    int a,b;
    cin >> a >> b;

    int ans = 0;
    REP(i,2){
        if (a>=b){
            ans += a;
            a--;
        }else{
            ans += b;
            b--;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3632
//Author- VMAX


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_multiset tree<long long , null_type,less_equal<long long >, rb_tree_tag,tree_order_statistics_node_update>
#define ordered_set tree<long long , null_type,less<long long >, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
#define ll long long int
#define YES cout<<"YES"<<"\n";
#define NO cout<<"NO"<<"\n";
#define ld     long double 
#define yes cout<<"yes"<<"\n";
#define no cout<<"no"<<"\n";
#define No cout<<"No"<<"\n";
#define Yes cout<<"Yes"<<"\n";
#define f(i,a) for(i=0;i<a;i++)
#define fo(i,a) for(i=1;i<=a;i++)
#define fa(i,a) for(auto i:a)
#define r(i,a) for(auto i=a.rbegin();i!=a.rend();i++)
#define en cout<<"\n";
#define ull unsigned long long int
#define o(x) cout<<x<<"\n";
#define o1(x) cout<<x<<" ";
#define pb push_back
#define F first
#define in insert
#define mp make_pair
#define S second
#define pre(n) cout<<fixed<<setprecision(n);
#define      gcd(a,b)    __gcd(a,b)
#define bs            binary_search
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define test ll t;cin>>t;while(t-->0)
const ll Mod = 998244353;
#define mod 1000000007
#define pi 3.14159265358979323846
#define all(x) x.begin(),x.end()
#define re return 0;
// *#######################################################################################*

/*
bool isp(ll n)
{
    ll i;
    for(i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {
            return false;
        }
        
    }
}
  */
  long long lcm(long long a, long long b){//最小公倍数を求める
   return a * b / gcd(a, b);
}
       int main()
       
       {
        fast
        
          ll a,b,c,d;
          cin>>a>>b>>c>>d;
          a--;
          ll z=lcm(c,d);
          ll s=b-a-((b/c)+b/d-b/z-a/d-a/c+a/z);
          o(s)

        
 
          re
}


Measured memory_bytes: 3592
import java.util.Scanner;

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

        while (sc.hasNext()) {
            String s = sc.next();
            if (vowel.contains(s)) {
                System.out.println("vowel");
            } else {
                System.out.println("consonant");
            }
        }
    }
}


Measured memory_bytes: 21972
#include<iostream>
using namespace std;
int main(){
int N;
cin>>N;
int t=N%10;
  if(t==2||t==4||t==5||t==7||t==9)
    cout<<"hon";
  else if(t==0||t==1||t==6||t==8)
    cout<<"pon";
  else
    cout<<"bon";
}


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

long long int N, a, t[3], i;

int main(){
    scanf("%lld", &N);
    for(; i < N; ++i){
        scanf("%lld", &a);
        if(a & 1)++*t;
        else if(a & 2)++t[1];
        else ++t[2];
    }
    puts(*t > t[2] + 1 ? "No" : *t > t[2] && t[1] ? "No" : "Yes");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using llpair=pair<ll,ll>;
using llvec=vector<ll>;
using llmat=vector<vector<ll>>;
#define llmattp(name,a,b,num) name(a,vector<ll>(b,num))
#define LLINF 1LL<<60
#define ABS(x) ( (x)>0 ? (x) : -(x) )

template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

ll gcd(ll a, ll b) {
	if(a==0||b==0) return 0;
	if(a<b) swap(a,b);
	ll tmp = a%b;
	while(tmp!=0) {
		a = b;
		b = tmp;
		tmp = a%b;
	}
	return b;
}

ll lcm(ll a, ll b) {
	return a*b/gcd(a,b);
}

ll factorial(ll x) {
	ll f=1;
	for(ll i=2; i<x; i++) {
		f*=i;
	}
	return f;
}

ll nPr(ll n, ll r) {
	ll result=1;
	for(ll i=r+1; i<=n; i++) result*=i;
	return result;
}

ll nCr(ll n, ll r) {

	if (n == 0) { return 0; }
	if (r == 0) { return 1; }
	if (r == 1) { return n; }
	if (n == r) { return 1; }

	if (r > n / 2) { r = n / 2; }

	double result = 1;
	for (double i = 1; i <= r; i++) {
		result *= (n - i + 1) / i;
	}

	return (ll)result;
}

bool IsPrime(ll num) {
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

	double sqrtNum = sqrt(num);
	for (ll i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			// 素数ではない
			return false;
		}
	}

	// 素数である
	return true;
}

ll GreaterBinarySearch(llvec array, ll key, ll max, ll min) {
	if(array[max]<array[min]) {
		return -1LL;
	} else {
		ll mid = max + (min-max)/2;
		if(array[mid]<key) {
			return GreaterBinarySearch(array,key,max,mid-1);
		} if(array[mid]>key) {
			return GreaterBinarySearch(array,key,mid+1,min);
		} else {
			return mid;
		}
	}
}

int main() {
	int a,b,m; cin>>a>>b>>m;
	int amin=100001,bmin=100001;
	int apri[a]; for(int i=0; i<a; i++) { cin>>apri[i]; chmin(amin,apri[i]); }
	int bpri[b]; for(int i=0; i<b; i++) { cin>>bpri[i]; chmin(bmin,bpri[i]); }
	int sum=amin+bmin;
	int x,y,c;
	int tempmin;
	for(int i=0; i<m; i++) {
		cin>>x>>y>>c;
		tempmin=apri[x-1]+bpri[y-1]-c;
		chmin(sum,tempmin);
	}

	cout<<sum<<endl;

}


Measured memory_bytes: 1024
def func(n, yen):
    n += 1
    for x in range(n):
        for y in range(n-x):
            z = n - x - y - 1
            if (x+y+z) == n-1 and 10000*x + 5000*y + 1000*z == yen:
                comb = (x, y, z)
                print(" ".join([str(i) for i in comb]))
                return
    print("-1 -1 -1")
    return


n, y = map(int, input().split())
func(n, y)

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

struct node {
  int id;
  struct node *parent;
  int child_id[2];
  struct node *child[2];
};

struct node *tree;

void preorder(struct node *p);
void inorder(struct node *p);
void postorder(struct node *p);

int main(int argc, char *argv[])
{
  int n, ch, i, j, num;

  scanf("%d", &n);

  tree = (struct node *)malloc(sizeof(struct node) * n);

  for (i = 0; i < n; i++) tree[i].parent = NULL;

  for (i = 0; i < n; i++) {
    scanf("%d", &num);
    tree[num].id = num;

    for (j = 0; j < 2; j++) {
      scanf("%d", &(tree[num].child_id[j]));
      if (tree[num].child_id[j] == -1) tree[num].child[j] = NULL;
      else {
        ch = tree[num].child_id[j];
        tree[num].child[j] = &tree[ch];
        tree[ch].parent = &tree[num];
      }
    }
  }

  for (i = 0; i < n; i++) {
    if (tree[i].parent == NULL) break;
  }
  printf("Preorder\n");
  preorder(&tree[i]);
  printf("\n");
  printf("Inorder\n");
  inorder(&tree[i]);
  printf("\n");
  printf("Postorder\n");
  postorder(&tree[i]);
  printf("\n");

  return 0;
}

void preorder(struct node *p)
{
  printf(" %d", p->id);
  if (p->child[0] != NULL) preorder(p->child[0]);
  if (p->child[1] != NULL) preorder(p->child[1]);
}

void inorder(struct node *p)
{
  if (p->child[0] != NULL) inorder(p->child[0]);
  printf(" %d", p->id);
  if (p->child[1] != NULL) inorder(p->child[1]);
}

void postorder(struct node *p)
{
  if (p->child[0] != NULL) postorder(p->child[0]);
  if (p->child[1] != NULL) postorder(p->child[1]);
  printf(" %d", p->id);
}

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


int main() {
  int k;
  cin >> k;
  
  if(k >= 30){
    cout << "Yes" << endl;
    return 0;
  }
  
  cout << "No" << endl;
  return 0;
  
  
}

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

int main() {
  char s[100000] = {0};
  cin >> s;
  int i;
  for (i = 0; s[i] != 0; i++) {
    if (s[i] == 'd') {
      if (!(s[i + 1] == 'r' && s[i + 2] == 'e' && s[i + 3] == 'a' && s[i + 4] == 'm')) {
        cout << "NO" << endl;
        return 0;
      } else {
        i += 4;
      }
    } else if (s[i] == 'e' && s[i + 1] == 'r' ) {
      if (!(s[i + 2] == 'a' && s[i + 3] == 's' && s[i + 4] == 'e')) {
        if ((s[i + 2] == 'd' || s[i + 2] || s[i + 2] == 0)) {
          if (s[i - 1] == 'm') {
            i += 1;
          } else {
            cout << "NO" << endl;
            return 0;
          }
        } else {
          cout << "NO" << endl;
          return 0;
        }
      } else {
        if (s[i + 5] == 'r') {
          i += 5;
        } else {
          i += 4;
        }
      }
    } else {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz size()
#define pb push_back 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;
const ll INF=1000000000000000;

vector<ll> pw2(51,1); vector<ll> pw10(19,1);
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll mid(ll x,ll y,ll z){return x>y?y>=z?y:min(z,x):x>=z?x:min(y,z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll myceil(ll x,ll y){if(x<=y) return 1;else if(x%y==0) return x/y;else return x/y+1;}
ll digsz(ll x){if(x==0) return 1;else{ll ans=0;while(x){x/=10;ans++;}return ans;}}
ll digsum(ll x){ll sum=0;while(x){sum+=x%10;x/=10;}return sum;}
vector<ll> divisor(ll x){vector<ll> div;
	for(ll i=1;i*i<=x;i++){if(x%i==0){div.pb(i);if(i*i!=x)div.pb(x/i);}}
	sort(div.bg,div.ed);return div;}

int main(){
	ll A,B,C; cin>>A>>B>>C;
	if(C==mid(A,B,C)) cout<<"Yes";
	else cout<<"No";    
}

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(), m = sc.nextInt();
        int ans = 0;
        int[] ht = new int[n];
        boolean[] vis = new boolean[n];
        for (int i = 0; i < n; i++) {
            ht[i] = sc.nextInt();
        }
        Map<Integer, Set<Integer>> map = new HashMap<>();
        for (int i = 0; i < m; i++) {
            int a = sc.nextInt(), b = sc.nextInt();
            vis[a - 1] = true;
            vis[b - 1] = true;
            map.putIfAbsent(a, new HashSet<>());
            map.get(a).add(b);
            map.putIfAbsent(b, new HashSet<>());
            map.get(b).add(a);
        }

        for (Integer v : map.keySet()) {
            Set<Integer> l = map.get(v);
            boolean isGood = true;
            for (Integer e : l) {
                if (ht[e - 1] >= ht[v - 1]) {
                    isGood = false;
                    break;
                }
            }
            if (isGood) ans++;
        }

        for (boolean b : vis) {
            if (!b) ans++;
        }
        System.out.println(ans);
    }
}


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


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

  int64_t A_C,B_C,A_D,B_D,A_CD,B_CD;

  int64_t tmp,x,r;

  A_C=(A-1)/C;
  A_D=(A-1)/D;
  B_C=(B)/C;
  B_D=(B)/D;

  if(C<D){
    tmp = C;
    C = D;
    D = tmp;
  }
  x=C*D;
  /* ユークリッドの互除法 */
  r = C % D;
  while(r!=0){
    C = D;
    D = r;
    r = C % D;
  }
  //cout << x/D << endl;
  



  A_CD=(A-1)/(x/D);
  B_CD=(B)/(x/D);

  //cout << (B_C+B_D-B_CD) << endl;
   // cout << (A_C+A_D-A_CD) << endl;


  cout << (B-A+1)-((B_C+B_D-B_CD)-(A_C+A_D-A_CD)) << endl;



  }










Measured memory_bytes: 256
#include <bits/stdc++.h>
//#define inf 0x3f3f3f3f3f3f3f3f
#define inf 0x3f3f3f3f
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define inv(x) Power(x, mod - 2)
#define fi first
#define se second
#define MP make_pair
#define PB push_back

using namespace std;
typedef pair<int,int> Pair;
typedef long double ld;
typedef long long ll;

const int mod = 998244353, MAX = 1e5, N = 50005;
//template{{{
const long double Pi = 3.14159265358979323846l;
inline int add(int x, int y) { x += y; return x >= mod ? x - mod : x; };
inline void inc(int &x, int y) { x += y; x -= (x >= mod ? mod : 0); }
inline int mul(int x, int y) { return 1ll * x * y % mod; }
inline int Power(int x, int y) {
	int ans = 1;
	while (y) {
		if (y & 1) ans = mul(ans, x);
		x = mul(x, x), y >>= 1;
	} return ans;
}

/*char buf[1<<23],obuf[1<<23],*p1=buf,*p2=buf, *O = obuf;
#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
void print(int x) {
    if(x > 9) print(x / 10);
    *O++=x%10+'0';
} */

template <class T> inline T	input() {
	T x; char ch; bool flag = false;
	while (!isdigit(ch = getchar())) flag |= ch == '-';
	for (x = ch ^ 48; isdigit(ch = getchar()); x = x * 10 + (ch ^ 48));
	return flag ? -x : x;
}

template <class T> inline bool chkmin(T &x, T y) { x = x < y ? x : y; return x == y; }
template <class T> inline bool chkmax(T &x, T y) { x = x > y ? x : y; return x == y; }
template <class T> inline T gcd(T x, T y) { return !y ? x : gcd(y, x % y); }
template <class T> inline T sqrm(T x) { return (ll) x * x % mod; }
template <class T> inline T sqr(T x) { return x * x; }

struct {
	inline operator int () { return input<int>(); }
	inline operator long long () { return input<long long>(); }
	template <class T> inline void operator () (T &x) { x = *this; }
	template<class T, class ...A> inline void operator () (T &x, A &...a)
	{ x = *this; this -> operator ()(a...); }
} read; //}}}

int n;

int main() {
#ifdef local
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
	freopen("log", "w", stderr);
#endif

	ll ans = 0;
	cin >> n;
	for (int a = 1; a <= n; ++a)
		for (int b = 1; b <= n; ++b)
			for (int c = 1; c <= n; ++c)
				ans += gcd(a, gcd(b, c));
	printf("%lld\n", ans);
	return 0;
}


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

#define int long long

using namespace std;

#define MOD 1000000007
#define SZ 105


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

        int n,l;
        cin>>n>>l;

        vector < string > me;
        for(int i=0;i<n;i++)
        {
                string s;
                cin>>s;
                me.push_back(s);
        }

        sort(me.begin(),me.end());

        for(int i=0;i<n;i++)
        {
                cout<<me[i];
        }
        cout<<endl;


        return 0;

}

Measured memory_bytes: 256
def solve():
    a,b,c,d=map(int,input().split())
    i=0
    while(a>0 and c>0):
        if i%2==0:
            c-=b
        else:
            a-=d
        i+=1
    if(c<=0):
        print('Yes')
    else:
        print('No')
solve()


Measured memory_bytes: 9156
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long 
#define llinf 1e17
#define nllinf -4e18
 
#define vll vector<ll>
#define sll set<ll>
#define pll pair<ll,ll> 
#define vpll vector<pair<ll,ll > >
 
#define repup(a,b,i) for(i=a;i<=b;i++)
#define repdown(a,b,i) for(i=b; i>=a; i--)
#define repupx(a,b,i,x) for(i=a;i<=b;i+=x)
	
#define repit(v,it) for(it=v.begin(); it!=v.end(); it++)
#define itall(v) v.begin(),v.end()
#define pb push_back
#define pf push_front
#define mp make_pair
#define fr first
#define sc second
 
#define err(n) cout<<n<<" ";
#define t1 cout<<",";
 
ll MOD= 1e9 +7;

ll dp[3005][3005];

int main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
ll i,j,k;

ll n;cin>>n;
ll a[n];repup(0,n-1,i)cin>>a[i];

ll l,r;
repdown(0,n-1,l){
	repup(l,n-1,r){
		if(l==r){dp[l][r]=a[l];continue;}
		dp[l][r]= max(a[l]-dp[l+1][r], a[r]- dp[l][r-1]);
	}
}
cout<<dp[0][n-1];

}

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

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#############
# Main Code #
#############

R = inputI()

print(R*3.1415926535*2)

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

int main () {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	double R;
	cin >> R;
	double result = PI*R*2;
	cout << (result);
}

Measured memory_bytes: 3800
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int n;
  cin >> n;
  int h[n];
  REP(i, n) cin >> h[i];
  bool ok = true;
  for (int i = n - 1; i > 1; --i) {
    if (h[i] < h[i - 1]) {
      h[i - 1]--;
    }
    if (h[i] < h[i - 1]) {
      ok = false;
    }
  }
  cout << (ok ? "Yes" : "No") << endl;
  return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void solve() {
    ll N;
    cin >> N;
    ll ans = 0;
    rep(i, N) {
        ans += i;
    }
    cout << ans << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (((a)%mod) * ((b)%mod)) % mod
#define rollcall cout << "I'm Sucu." << endl;
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define dmt(x, y, z) make_tuple(x, y, z)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define fi first
#define se second
// debug
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p){
  os << "(" << p.first << "," << p.second << ")";return os;
}
template <typename T, typename U, typename V>
ostream &operator<<(ostream &os, const tuple<T, U, V> &t){
  os << "(" << get<0>(t) << "," << get<1>(t) << "," << get<2>(t) << ")";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for (auto it = v.begin();it != v.end();++it){
    if(it != v.begin())os << " ";os << *it;
  }return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &mp){
  for(auto x: mp)os << "(" << x.first << "," << x.second << ")" << endl;
  return os;
}
template<typename T, int SIZE>
int array_length(const T (&)[SIZE]){return SIZE;}
template<typename T, int N>
void PRINTF(const T (&a)[N], int s = N, int t = -1, bool f = true){
	if(t == -1){rep(i,s){if(i)cout << " ";cout << a[i];}}
	else repi(i,s,t){if(i!=s)cout << " ";cout << a[i];}
	if(f)cout << "\n";
}
template<typename T, int N1, int N2>
void PRINTF(const T (&a)[N1][N2], int h = N1, int w = N2){
	rep(i,h){rep(j,w){cout << a[i][j] << " \n"[j==w-1];}}
}
string substr(const string &str, int S1, int S2 = -1){
  if(S2 == -1)return str.substr(S1);
  return str.substr(S1, S2-S1);
}
// typedef
typedef complex<double> Point;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef tuple<int, int, int> TT;
typedef pair<int, TT> PT;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;
// int sum = accumulate(a, a+n, 0LL);
// int mx = max_element(a, a+n);
// int mn = min_element(a, a+n);
// int cnt = count(a, a+n, k);


vector<P> G[200000];
int d[200000];
void dfs(int u, int s){
  if(s == 0)d[u] = 1;
  else d[u] = 2;
  rep(i,G[u].size()){
    P p = G[u][i];
    if(d[p.fi] != 0)continue;
    dfs(p.fi, (s+p.se)%2);
  }
  return;
}

signed main(){
  int n;cin >> n;
  rep(i,n-1){
    int u, v, w;cin >> u >> v >> w;
    G[u].pb(P(v, w));
    G[v].pb(P(u, w));
  }
  
  dfs(1, 0);
  rrep(i,n)cout << d[i]-1 << endl;
  return 0;
}






Measured memory_bytes: 12544