akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <set>
using namespace std;
typedef long long ll;

string str;
ll K;


int main() {
	cin >> str;
	cin >> K;

	for (int i = 0; i < str.length(); ++i) {
		if (str[i] != '1') {
			cout << str[i]; return 0;
		}
		K--;
		if (K == 0) {
			cout << str[i]; return 0;
		}
	}

}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>

using namespace std;
int n,m,s,c,flag;
int num[4];
int visit[4];

int main()
{
    scanf("%d%d",&n,&m);
    {
        while(m--)
        {
            scanf("%d%d",&s,&c);
            if(visit[s]&&c!=num[s])
                flag=1;
            visit[s]=1;
            num[s]=c;
        }
        if(flag)
            printf("-1\n");
        else if((num[1]==0&&n>1&&visit[1]))
            printf("-1\n");
        else if(num[1]==0&&n>1&&!visit[1])
        {
            printf("1");
            for(int i=2;i<=n;i++)
                printf("%d",num[i]);
            printf("\n");
        }
        else
        {
            for(int i=1;i<=n;i++)
                printf("%d",num[i]);
            printf("\n");
        }
    }
}

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

int main(){
  unsigned long long a=0;
  string s;
  cin >> s;
  int n=0;
  for(int i=0; i<s.size(); i++){
    n = s[i]-48;
    a = a+n;
  }
  if(a%9==0){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  
}


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

struct Node{
    int key;
    struct Node *right;
    struct Node *left;
    struct Node *parent;
};
struct Node *root;

void inorder(struct Node *);
void preorder(struct Node *);
struct Node *find(int);
void insert(int);

int main(){
    int n,x;
    char com[20];

    scanf("%d", &n);

    for (int i = 0; i < n; i++ ){
        scanf("%s", com);
        if(com[0] == 'i'){
            scanf("%d",&x);
            insert(x);
        } 
        else if(com[0] == 'p'){
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        } 
        else if (com[0] == 'f'){
            scanf("%d", &x);
            struct Node *t = find(x);
            if(t != NULL) printf("yes\n");
            else printf("no\n");
        }
    }

    return 0;
}

void inorder(struct Node *A){
    if(A == NULL)return;
    inorder(A->left);
    printf(" %d",A->key);
    inorder(A->right);
}

void preorder(struct Node *A){
    if(A == NULL)return;
    printf(" %d",A->key);
    preorder(A->left);
    preorder(A->right);
}

void insert(int key){
    struct Node *y = NULL;
    struct Node *x = root;
    struct Node *z = malloc(sizeof(struct Node));
    z->key = key;
    z->left = z->right = z->parent = NULL;

    while(x != NULL){
        y = x;
        if(z->key < x->key){
            x = x->left;
        }
        else{
            x = x->right;
        }
    }

    z->parent = y;

    if(y == NULL){
        root = z;
    }
    else if(z->key < y->key){
        y->left = z;
    }
    else{
        y->right = z;
    }
}

struct Node *find(int x){
    struct Node *t;
    t = root;
    while(t != NULL){
        if(t->key > x){
            t = t->left;
        }
        else if(t->key < x){
            t = t->right;
        }
        else break;
    }
    return t;
}


Measured memory_bytes: 20468
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define all(v) (v).begin(), (v).end()
#define rev(s) (s).rbegin(), (s).rend()
#define MP make_pair
#define X first
#define Y second

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;


bool check(vi v){
	FOR(i, 1, 10){
		if(v[i] < 2) continue;
		vi num = v;
		num[i] -= 2;
		FOR(j, 3, 10){
			while(num[j]&&num[j-1]&&num[j-2]){
				if(num[j-2]%3 == 0) break;
				num[j]--;
				num[j-1]--;
				num[j-2]--;
			}
		}
		bool ok = true;
		rep(j, 10){
			if(num[j]&&(num[j]!=3)) ok = false;
		}
		if(ok) return true;
	}

	return false;
}

int main(){
	string s;
	while(cin >> s){
		vi num(10, 0);
		rep(i, s.size()){
			num[s[i]-'0']++;
		}
		vector<int> ans;
		FOR(i, 1, 10){
			if(num[i] >= 4) continue;
			num[i]++;
			if(check(num)) ans.push_back(i);
			num[i]--;
		}
		if(ans.empty()) ans.push_back(0);
		rep(i, ans.size()) cout << (i?" ":"") << ans[i];
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 1204
require 'prime'
require 'set'
require 'tsort'
include Math
ALP = ('a'..'z').to_a
INF = 0xffffffffffffffff
def max(a,b);              a > b ? a : b                              end
def min(a,b);              a < b ?  a : b                             end
def swap(a,b);             a, b = b, a                                end
def gif;                   gets.to_i                                  end
def gff;                   gets.to_f                                  end
def gsf;                   gets.chomp                                 end
def gi;                    gets.split.map(&:to_i)                     end
def gf;                    gets.split.map(&:to_f)                     end
def gs;                    gets.chomp.split.map(&:to_s)               end
def gc;                    gets.chomp.split('')                       end
def pr(num);               num.prime_division                         end
def pr?(num);              Prime.prime?(num)                          end
def digit(num);            num.to_s.length                            end
def array(s,ini=nil);      Array.new(s){ini}                          end
def darray(s1,s2,ini=nil); Array.new(s1){Array.new(s2){ini}}          end
def rep(num);              num.times{|i|yield(i)}                     end
def repl(st,en,n=1);       st.step(en,n){|i|yield(i)}                 end

n = gif
a = gi
b = []
if n % 2 == 0
  repl n-1, 1, -2 do |variable|
    b << variable
  end

  repl 1, n-1,2 do |variable|
    b << variable
  end
else
  repl n-1, 0, -2 do |variable|
    b << variable
  end

  repl 2, n-1, 2 do |variable|
    b << variable
  end
end


aa = Hash.new
bb = Hash.new
a.each do |ta|
  aa[ta] ||= 0
  aa[ta] += 1
end

b.each do |tb|
  bb[tb] ||= 0
  bb[tb] += 1
end

jd = true
b.each do |i|
  if bb[i] != aa[i]
    jd = false
    break
  end
end

ans = jd ? 2 ** (n/2) : 0
puts ans % (10**9 + 7)


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

int main()
{
    int k;
    string s;
    cin >> k >> s;

    if (s.length() <= k)
        cout << s << endl;
    else
    {
        rep(i, k) cout << s[i];
        cout << "..." << endl;
    }
}

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

#define  BeatMeScanf  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define  tc(x)        int x; cin >> x; while(x--)
#define  ll           long long
#define  vi           vector<int>
#define  pii          pair<int,int>
#define  mii          map<int,int>
#define  inf          1<<28
#define  mem(x,y)     memset(x, y, sizeof(x))
#define  ps(x,y)      fixed<<setprecision(y)<<x
#define  show(val)    cout<< #val << " -> " << val << endl
#define  Case         cout<< "Case "<< ++cs << ": "
#define  all(v)       (v).begin(), (v).end()
#define  rall(v)      (v).rbegin(), (v).rend()
#define  MOD          1000000007
#define  MAX          100005
#define PI 3.14159265358979323846264338327950L

int main()
{
    BeatMeScanf;
    long double a, b, h, m;
    cin >> a >> b >> h >> m;

    long double angle = abs((60*h-11*m)/2);
    angle *= PI/180;

    long double ans = (a*a+b*b) - 2*a*b*cos(angle);
    cout << ps(sqrtl(ans),15) << '\n';
    
    return 0;
}



Measured memory_bytes: 4148
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

i64 n;
string s;
int main() {
  cin >> n >> s;
  bool f = n % 2 == 0;
  for (int i = 0, j = n / 2; j < n; ++i, ++j) {
    f = f && s[i] == s[j];
  }
  cout << (f ? "Yes\n" : "No\n");
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
using ll = long long;
using namespace std;

int main(){
    ll k,x;
    cin>>k>>x;
    for(ll i=x-k+1;i<x+k;i++){
        cout<<i<<" ";
    }
    
}


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

int main(){
    int N;
    cin>>N;
    vector<string> S(N);
    for(int i=0;i<N;i++){
        cin>>S.at(i);
    }
    // cout<<S.at(0)<<endl;
    map<string,int> mp;
    for(int i=0;i<N;i++){
        mp[S.at(i)]++;
    }
    cout<<"AC x "<<mp["AC"]<<endl;
    cout<<"WA x "<<mp["WA"]<<endl;
    cout<<"TLE x "<<mp["TLE"]<<endl;
    cout<<"RE x "<<mp["RE"]<<endl;
}

Measured memory_bytes: 6420
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>
using namespace std;
 
#define ll long long
 
 
int main() {
  	ll num=0;
  	ll N, M;
  	cin >> N >> M; 
  	
  	ll H[N];
  	for(ll i=0; i<N; i++){
		cin >> H[i];
    }
  	
  	ll BP[N];
  	for(ll i=0; i<N; i++){
		BP[i]=0;
    }
  	
  	ll A[M], B[M];
  	for(ll i=0; i<M; i++){
      	cin >> A[i] >> B[i];
      	if(H[A[i]-1] > H[B[i]-1]){
          	BP[B[i]-1]++;
        }
      	else if (H[A[i]-1] < H[B[i]-1]){
          	BP[A[i]-1]++;
        }
      	else{
        	BP[A[i]-1]++;
          	BP[B[i]-1]++;
        }
    }
  	
  	for(ll i=0; i<N; i++){
      	//cout << BP[i] << endl;
		if(BP[i]==0){
          	num++;
        }
    }
  	
  	
	cout << num << endl;
}

Measured memory_bytes: 6744
import sys

letters = "abcdefghijklmnopqrstuvwxyz"
sentence = sys.stdin.read()

table = [0] * 26

for i in sentence:
	count = 0
	for j in letters:
		if i == j or i == j.upper():
			table[count] += 1
		count += 1


for x in range(26):
	print("%s : %d" % (letters[x], table[x]))


Measured memory_bytes: 5560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vii;
typedef vector<ll> vll;

#define X first
#define Y second
#define rep(i,n) for(ll i=0; i<(n); i++)
#define repp(i,ed,b) for(ll i=ed; i<=(b); i++)
#define repp2(i,b,ed) for(ll i=b; i>=(ed); i--)
#define fill(ed,val) memset(ed, (val), sizeof(ed))
#define mp make_pair
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define uni(c) c.resize(distance(c.begin(), unique(all(c))))
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);
#define IO(input_file_name) ifstream cin(input_file_name);ofstream cout("output.txt")
#define sc(n) scanf("%lld",&n)

ll mod= 1e9 + 7, mod1=1e9+9;
const ll N=200005;


int main()
{   
    io;
    
    ll a,b,c;
    cin>>a>>b>>c;
    ll tmp=a*b*(c-c/2*2);
    tmp=min(tmp,b*c*(a-a/2*2));
    tmp=min(tmp,a*c*(b-b/2*2));
    cout<<tmp;
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<iterator>
using namespace std;

int main(){
  int N;
  cin >> N;
  vector<int> v1{istream_iterator<int>(cin),istream_iterator<int>()};
  vector<int> v2;
  int tmp = 1;
  for (int i = 0; i < N; ++i){
    if( tmp == v1[i] ) ++tmp;
  }
  
  if(tmp == 1) cout << -1 << endl;
  else cout << N - tmp + 1 <<endl;
  return 0;
  
}

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

const ll mod = 1e9;

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

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

int main(){
    int n;
    cin >> n;
    vector<ll> t(n);
    rep(i,n) cin >> t[i];
    ll ans = 1;
    rep(i,n) ans = lcm(ans,t[i]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
m = int(input())

for i in range(m):
    d = input()
    _set = set()
    for i in range(len(d)-1):
        w1 = d[:i+1]
        w2 = d[i+1:]
        w1_r = w1[::-1]
        w2_r = w2[::-1]
        _set.add(w1 + w2)
        _set.add(w2 + w1)
        _set.add(w1_r+w2_r)
        _set.add(w2_r+w1_r)
        _set.add(w1 + w2_r)
        _set.add(w2 + w1_r)
        _set.add((w1_r) + w2)
        _set.add((w2_r) + w1)

    print(len(_set))

Measured memory_bytes: 6792
import java.util.*;
public class Main {
	public static void main(String[] args)
	{
		//変数
		//int count=0;
		//boolean sw=false;
		int answer=0;
		//String answer="NO";
		//List<Integer> h=new ArrayList<Integer>();
		//int af=Integer.MAX_VALUE;
		int N=0;
		int v=0;
		int e=0;
		//int t[]=new int[(int)Math.pow(10,5)];
		//入力
		Scanner sc = new Scanner(System.in);
		N=sc.nextInt();
		int h[]=new int[N];
		for(int i=0;i<N;i++)
		{
			h[i]=sc.nextInt();
		}
		//int a=sc.nextInt();
		//String S=sc.next();
		//int [][] cost =new int[N-1][2];
		
		//処理
		for(int i=0;i<N;i++)
		{
			v+=h[i];
		}
		for(int i=1;i<N;i++)
		{
			e+=Math.min(h[i-1],h[i]);
		}
		answer=v-e;
		// 出力
		System.out.println(answer);
	}
}

Measured memory_bytes: 22740
def matmul(p,q):
  c = [[0 for i in range(n)] for j in range(n)]
  for i in range(n):
    for j in range(n):
      for l in range(n):
        c[i][j] += p[i][l]*q[l][j]
        c[i][j] %= mod
  return c
n,k = map(int,input().split())
a = [list(map(int,input().split())) for i in range(n)]
mod = 10**9+7
als = [a]
for i in range(100):
  alsnxt = matmul(als[-1],als[-1])
  als.append(alsnxt)
ansmat = [[0 for i in range(n)] for j in range(n)]
for i in range(n):
  ansmat[i][i] = 1
for i in range(100):
  if k&1<<i:
    ansmat = matmul(ansmat,als[i])
ans = 0
for i in range(n):
  for j in range(n):
    ans += ansmat[i][j]
    ans %= mod
print(ans)

Measured memory_bytes: 47708
import itertools, math

n, d = map(int, input().split())
points = []
count = 0
for i in range(n):
    points.append(list(map(int, input().split())))

for p_1, p_2 in itertools.combinations(points, 2):
    dist = 0
    for i in range(d):
        dist += (p_1[i] - p_2[i]) ** 2
    if math.sqrt(dist).is_integer():
        count += 1
        
print(count)

Measured memory_bytes: 3064
def c_guess_the_number():
    N, M = [int(i) for i in input().split()]
    Conds = [[int(i) for i in input().split()] for j in range(M)]

    digit = [-1] * N
    # 同じ桁に異なる数字を割り当てている場合を検出
    for s, c in Conds:
        if digit[s - 1] not in (-1, c):
            return -1
        digit[s - 1] = c

    # N 桁目に 0 を割り当てなければならない場合
    # 基本的に N+1 桁の数となり矛盾するが、例外的に N = 1 だと 0 とすればよい。
    if digit[0] == 0:
        return -1 if N >= 2 else 0

    # 指定されなかった桁は基本的に 0 とすればよいが、N 桁目は 0 にできない。
    # 例外的に、N = 1, M = 0 だと N 桁目も 0 にできる。
    for d, value in enumerate(digit):
        if value == -1:
            digit[d] = 1 if (N >= 2 and d == 0) else 0
    return ''.join(map(str, digit))

print(c_guess_the_number())

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long

int main() {
    fastio;
    ll m;
    cin >> m;
    ll hap = 0;
    while (m) {
        if (m >= 500) {
            hap += 1000;
            m -= 500;
            continue;
        }
        if (m >= 5) {
            hap += 5;
            m -= 5;
            continue;
        }
        if (m >= 100) {
            m -= 100;
            continue;
        }
        if (m >= 50) {
            m -= 50;
            continue;
        }
        if (m >= 10) {
            m -= 10;
            continue;
        }
        if (m >= 1) {
            m -= 1;
            continue;
        }
    }
    cout << hap;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] p = new int[n];
        for(int i = 0; i < n; i++) p[i] = scan.nextInt();
        int out = 1;
        int min = Integer.MAX_VALUE;
        for(int i = 1; i < n; i++){
            min = Math.min(min, Math.min(p[i], p[i - 1]));
            if(min >= p[i]) out++;
        }
        System.out.println(out);
        scan.close();
    }
}

Measured memory_bytes: 88116
import sys
import itertools
# import math
# from pprint import pprint
import numpy as np


N,M,X = map(int, sys.stdin.readline().strip().split())
C = []
for _ in range(0, N):
    C.append(list(map(int, sys.stdin.readline().strip().split())))

# N = 3
# M = 3
# X = 10
#
# C = [
#     [60,2,2,4],
#     [70,8,7,9],
#     [50,2,3,9],
# ]

C.sort(key=lambda x:x[0])

ans = None
for i in range(1, N+1):
    for j in itertools.combinations(C, i):
        l = [k[1:] for k in j]
        # pprint(l)
        if len(l) > 1:
            ll = np.sum(l, axis=0)
            # print(ll)
            flag = all((m >= X) for m in ll)
        else:
            flag = all((m >= X) for m in l[0])
        if flag:
            n = np.sum(j, axis=0)[0]
            if ans == None or  ans > n:
                ans = n

if ans:
    print(ans)
else:
    print(-1)


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

//Made with <3 by MinumCoklatPanas
typedef long long ll;
const int INF = 1e9;
const ll INFF = 1e18;
const int MAXN = 510;
const int MOD = 1e9 + 7;
const double PI = acos(-1.0);
const double INFD = 1E9;
const double EPS = 1e-9;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin >> s;
    int cnt = 0;
    int ans = 0;
    for (int i = 0 ; i < 3 ; i++)
    {
        if (s[i] == 'S')
        {
            ans = max(ans,cnt);
            cnt = 0;
        }
        else
            cnt++;
    }
    ans = max(ans,cnt);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3648
{-# LANGUAGE ScopedTypeVariables #-}
import Control.Applicative
import Control.Monad
import Control.Monad.State
import Control.DeepSeq
import Data.Array
import Data.Bits
import Data.Char
import Data.Functor.Identity
import Data.List
import Data.Maybe
import Data.Ord
import Data.Tree
import Data.Tuple
import qualified System.IO
import qualified Data.Map as M
import qualified Data.Set as S
import qualified Data.Sequence as Q
import qualified Data.ByteString.Char8 as B

main = do
  [h,w] :: [Z] <- readLnList
  ass <- replicateM h getLine
  let n = length . filter (== '#') $ concat ass
  putStrLn $ if n == h+w-1 then "Possible" else "Impossible"


type Z = Int
type Q = Rational
type R = Double
type S = String

fint :: (Integral a, Num b) => a -> b
fint = fromIntegral

getInt = fst . fromJust . B.readInt <$> B.getLine
getIntPair = (\[a,b]->(a,b)) <$> getInts
getInts = map (fst . fromJust . B.readInt) . B.words <$> B.getLine
getStr = B.unpack <$> B.getLine

yesNo :: Bool -> String
yesNo True = "Yes"
yesNo False = "No"

printList :: (Show a) => [a] -> IO ()
printList = putStrLn . unwords . map show

readLnList :: (Read a) => IO [a]
readLnList = map read . words <$> getLine


-----  Union-find
type UnionFindT v m a = StateT (M.Map v (UnionFindVal v)) m a
newtype UnionFindVal v = UnionFindVal v

runUnionFindT :: (Monad m) => UnionFindT v m a -> m a
runUnionFindT = flip evalStateT $ M.empty

runUnionFind = runIdentity . runUnionFindT

ufFresh :: (Monad m, Ord v) => v -> UnionFindT v m ()
ufFresh v = modify $ M.insert v (UnionFindVal v)

ufClass :: (Monad m, Ord v) => v -> UnionFindT v m v
ufClass v = do
  (UnionFindVal pv) <- gets (M.! v)
  if v == pv
    then return v
    else do
      c <- ufClass pv
      modify $ M.insert v (UnionFindVal c)
      return c

ufUnify v w = do
  cv <- ufClass v
  cw <- ufClass w
  modify $ M.insert cw (UnionFindVal cv)
  return $ cv /= cw


Measured memory_bytes: 508
#include <bits/stdc++.h>
 
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<ll, ll> pii;
 
#define REP(a,b,c) for(ll (a)=(b);(a)<(c);(a)++)
#define PER(a,b,c) for(ll (a)=(b);(a)>=(c);(a)--)
 
void ii(ll &x){ cin >> x; }
void is(string &x){ cin >> x; }
void oi(ll &x){ cout << x; }
void os(string &x){ cout << x; }
void oie(ll &x){ cout << x << endl; }
void ose(string &x){ cout << x << endl; }
 
int main(){
    string s; is(s);    
    if(s.length()%2==1){
        cout << "No" << endl;
        return 0;
    }
    for(ll i=0;i<s.length();i+=2){
        if(s[i]!='h'||s[i+1]!='i'){
            cout << "No" << endl;;
            return 0;
        }
    }

    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<long double,long double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<62;
const double pi=acos(-1);
const long double eps=1e-7;
const ll mod=1e6+3;
const int dx[8]={0,1,0,-1,-1,-1,1,1},dy[8]={1,0,-1,0,-1,1,-1,1};

int n;
vp a;

int main(){
	cin>>n;
	a=vp(n);
	for(int i=0;i<n;i++) cin>>a[i].first>>a[i].second;
	sort(a.begin(),a.end());
	cout<<a[n-1].first+a[n-1].second<<endl;
}

Measured memory_bytes: 1024
from copy import deepcopy

# 全探索でいけるやろ
n = int(input())
a = list(map(int, input().split()))
ans = 0


def f(ret, idx):
    if idx == n:
        yield ret
    else:
        for x in [-1, 0, 1]:
            next_ret = deepcopy(ret)
            next_ret.append(a[idx] + x)
            yield from f(next_ret, idx + 1)


for g in f([], 0):
    res = len(list(filter(lambda x: x % 2 == 0, g)))
    ans += 1 if res > 0 else 0
print(ans)


Measured memory_bytes: 3572
from collections import Counter
n=int(input())
v=list(map(int,input().split()))
c1=Counter(v[::2])
c2=Counter(v[1::2])
c1[0]=0
c2[0]=0
c10,c11=c1.most_common(2)
c20,c21=c2.most_common(2)
if c10[0]!=c20[0]:
    print(n-(c10[1]+c20[1]))
else:
    print(n-max(c10[1]+c21[1],c11[1]+c20[1]))

Measured memory_bytes: 18656
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
const ll INF=1e18;
const int MOD=1e9+7;
const double pi=acos(-1);

int main(){
  ll n,k;
  cin >> n >>k;
  ll x,y;
  rep(i,n){
    ll a;
    cin >> a;
    if(a==1){
      x=i;
      y=n-x-1;
    }
  }
  ll ans=(x+k-2)/(k-1);
  y-=ans*(k-1)-x;
  y=max(y,0ll);
  ans+=(y+k-2)/(k-1);
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;

void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,m;
    cin >> n >> m;
    vector<bool> a(n+1,false);
    int cnt1=0,cnt2=0;
    vector<pair<int,string>> q(m);
    vector<bool> w(n+1,false);
    rep(i,m){
        int p;
        string s;
        cin >> p >> s;
        q[i].first = p;
        q[i].second = s;
        if(s=="AC"){
            w[p]=true;
        }
    }
    rep(i,m){
        if(q[i].second=="AC"){
            if(!a[q[i].first]){
                cnt1++;
                a[q[i].first]=true;
            }
        }
        else{
            if(!a[q[i].first]){
                if(w[q[i].first]){
                    cnt2++;
                }
            }
        }
    }
    cout << cnt1 << " " << cnt2;

    return 0;
}

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

int main() {
    char A = 'A';
    char in;cin >> in;
    string ans = "a";
    for (int i = 0; i < 26; i++)
    {
        if(A + i == in)ans = "A";
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  int64_t res = 0;
  vector table(20, vector(20, 0));
  for (int i = 0; i < N; i++) {
    string s;
    cin >> s;
    auto pos = s.find(".");
    if (pos == string::npos) {
      s += string(9, '0');
    } else {
      s.erase(s.begin() + pos);
      s += string(9 - ((int)s.size() - pos), '0');
    }
    int64_t x = static_cast<int64_t>(stoll(s));
    pair<int, int> a = make_pair(0, 0);
    while (x % 2 == 0) {
      x /= 2;
      a.first++;
    }
    while (x % 5 == 0) {
      x /= 5;
      a.second++;
    }
    a.first = min(a.first, 18);
    a.second = min(a.second, 18);
    for (int j = 18 - a.first; j < 20; j++) {
      for (int k = 18 - a.second; k < 20; k++) {
        res += table[j][k];
      }
    }
    table[a.first][a.second]++;
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 3644
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
#include<tuple>
#include<string>
typedef long long int ll;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define F first
#define S second
using namespace std;
const ll INF = 10000000000000;

int main() {
  int a,b,c;
  cin>>a>>b>>c;
  cout<<max({c-(a-b),0})<<endl;
}

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

int main()
{
    int n,k;
    cin>>n>>k;
    int arr[n];
    double exp[n];
    for(int i=0;i<n;++i){
        cin>>arr[i];
        exp[i] = ((double)arr[i]/2.0) + 0.5;
        //cout<<exp[i]<<endl;
    }
    double pref[n];
    for(int i=0;i<n;++i){
        if(i==0){
            pref[i] = exp[i];
        }else
            pref[i] = exp[i] + pref[i-1];
    }
    double maxsum = pref[k-1];
    for(int i=k; i<n;++i){
        if(pref[i] - pref[i-k]>maxsum)
            maxsum = pref[i] - pref[i-k];
    }
    cout<<fixed;
    cout<<setprecision(12)<<maxsum<<endl;
    return 0;
}

Measured memory_bytes: 4096
import java.util.Scanner;

public class Main {
	  
	public static void main(String args[]) {
		    Scanner scanner = new Scanner(System.in);
		    
		    int R = scanner.nextInt();
		    int G = scanner.nextInt();
		    
		    System.out.println( 2 * G - R );
		    
		    scanner.close(); }
		  }

Measured memory_bytes: 21844
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        while (true) {
            int n = sc.nextInt();
            if (n == 0)
                break;
            while (n != 0) {
                int a = sc.nextInt();
                int b = sc.nextInt();
                int c = sc.nextInt();
                int d = sc.nextInt();
                int e = sc.nextInt();
                int f = sc.nextInt();
                int g = sc.nextInt();
                int h = sc.nextInt();
                int x = a * e - b * f - c * g - d * h;
                int y = a * f + b * e + c * h - d * g;
                int z = a * g - b * h + e * c + d * f;
                int w = a * h + b * g - c * f + d * e;
                System.out.println(x + " " + y + " " + z + " " + w);
                n--;
            }
        }
    }
}

Measured memory_bytes: 12000
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int[] a = new int[n-1];
		int[] num = new int[n];

		int i = 0;
		while(i < n-1) {
			a[i] = sc.nextInt();
			num[i] = 0;
			i++;
		}

		num[n-1] = 0;

		for(i = 0; i < n-1; i++) {
			num[a[i]-1]++;
		}

		for(i = 0; i < n; i++) {
			System.out.println(num[i]);
		}
	}

}

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

int main() {

string s ;
int n,a=0,w=0,t=0,r=0;
cin >> n ;

for (int i=0 ; i < n ; i++){

   cin >> s;

   if (s=="AC"){
    a++;
   }
   else if ( s=="WA"){
    w++;
   }
   else if (s=="TLE"){
    t++;
   }
   else if (s=="RE"){
    r++;
   }
}


cout << "AC x " << a << endl << "WA x " << w << endl << "TLE x " << t << endl << "RE x " << r << endl;

	return 0;

}


Measured memory_bytes: 3624
#include <iostream>
 
using namespace std;
 
int main() {
    string a;
    cin >> a;
    while (a != "0") {
        int b = 0;
        for (int i = 0; i < a.length(); i++) {
            b += a[i] - 48;
        }
        cout << b << endl;
        cin >> a;
    }
}


Measured memory_bytes: 3144
use proconio::input;
use proconio::marker::Chars;
use std::collections::HashMap;

fn main() {
  input!{
    s: Chars
  };

  let m = 2019;
  let mut dp = vec![0u32; s.len()+1];
  let mut map : HashMap<u32, u64> = HashMap::new();
  let mut e = 1;

  map.entry(0).or_insert(1);
  // dbg!(&s[2], s[2].to_digit(10).unwrap());
  for i in (0..s.len()).rev() {
    let a = s[i].to_digit(10).unwrap() as u32;
    dp[i] = (a * e + dp[i+1]) % m;
    let v = map.entry(dp[i]).or_insert(0);
    *v+=1;
    e = e * 10 % m;
  }
  let mut ans : u64 = 0;
  for (_, v) in map.iter() {
    ans += v * (v - 1) / 2;
  }
  println!("{}", ans);
}


Measured memory_bytes: 4016
#include<iostream>
#include<vector>
#include<string>
#include<array>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<numeric>
#include<iomanip>
#include<utility>
#include<cstdlib>
#include<typeinfo>


using namespace std;
#define INF 1000000005
int main()
{
int n,m;
std::cin >> n >> m;
std::vector<int> coin;
for(int i = 0; i < m; i++){
    int temp;
    std::cin >> temp;
    coin.push_back(temp);
}
std::sort(coin.begin(),coin.end());
int money[50001];
for(int i = 0; i < n + 1; i++){
    money[i] = INF; 
}
for(int i = 1; i < n + 1; i++){
    for(int j = 0; j < m; j++){
        if(coin[j] == i){
            money[i] = 1;
        } else if(i - coin[j] >= 1){
            if(money[i] > 1 + money[i - coin[j]]){
                money[i] = 1 + money[i - coin[j]];
            }
        } 
    }
}
std::cout << money[n] << std::endl;
return 0;
}


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

using ll = long long;

constexpr ll MOD = 1e9+7;
constexpr ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

int main(int argc, char **argv)
{
	ll N; cin >> N;
	vector<ll> A(N);
	vector<ll> sum(N+1, 0);
	REP(i, N) cin >> A[i];
	sort(A.begin(), A.end());
	REP(i, N) sum[i+1] = sum[i] + A[i];


	ll j{0};
	REP(i, N)
	{
		if (sum[i]*2 < A[i])
			j = i;
	}
	std::cout << N - j << std::endl;
}


Measured memory_bytes: 1792
;;; body

(defun solve (n k x)
  (flet ((calc-dist (i-left i-right)
           (let ((left (aref x i-left))
                 (right (aref x (1- i-right))))
             (min (+ (abs left) (abs (- right left)))
                  (+ (abs right) (abs (- right left)))))))
    (if (= n 1)
        (abs (aref x 0))
        (reduce #'min 
                (let ((acc nil))
                  (loop with i = 0  while (<= (+ i k) n) do
                       (push (calc-dist i
                                        (+ i k))
                             acc)
                       (incf i))
                  acc)))))

(defun main ()
  (let ((n (read))
        (k (read)))
    (let ((x (make-array n
                         :initial-contents (loop repeat n collect (read)))))
      (princ (solve n k x))
      (fresh-line))))

#-swank (main)


Measured memory_bytes: 78456
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i=0; i<int(n); i++)
#define RNG(i, f, t) for(int i=int(f); i<=int(t); i++)
#define REV(i, f, t) for(int i=int(f); i>=int(t); --i)
#define ALL(v) (v).begin(), (v).end()
#define EXIT(answer) { cerr<<"EXIT #"<<__LINE__<<endl; cout<<answer<<endl; exit(0); }
#define sz(v) int(v.size())
bool RELAXED = false;
template<int,typename T> struct MINMAX{ T val; MINMAX(T val) : val(val) {} };
template<typename T> MINMAX<1,T> MAX(T val) { return MINMAX<1,T>(val); };
template<typename T> MINMAX<2,T> MIN(T val) { return MINMAX<2,T>(val); };
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<1,U> rhs) { return lhs = (rhs.val > lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<2,U> rhs) { return lhs = (rhs.val < lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T, typename U> istream& operator>>(istream& in, pair<T,U> &p) { in>>p.first>>p.second; return in; }
template<typename T> inline vector<T> READ(int n) { vector<T> vec(n); FOR(i,n) cin>>vec[i]; return vec; }
template<typename T> using min_heap = priority_queue<T, vector<T>, greater<T> >;
typedef signed long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

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

    string s ; cin>>s;
    bool ok = s[2]==s[3] && s[4]==s[5];
    cout<<(ok?"Yes":"No")<<endl;
}

Measured memory_bytes: 256
N = gets.to_i
AS = gets.split.map(&:to_i)

n0 = n1 = n2 = 0
AS.each do |n|
  if n % 4 == 0 then n2 += 1
  elsif n % 2 == 0 then n1 += 1
  else n0 += 1
  end
end

if n2 >= N/2
  puts "Yes"
elsif n1 >= N - (n2*2)
  puts "Yes"
else
  puts "No"
end


Measured memory_bytes: 8452
import sys;
import math;
def get_ints(): return map(int, sys.stdin.readline().strip().split())
def get_array(): return list(map(int, sys.stdin.readline().strip().split()))
def get_string(): return sys.stdin.readline().strip()

n = int(input());
arr = [];
for i in range(n):
    tarr = get_array();
    arr.append(tarr);
dp = [[0,0,0] for i in range(n)];
dp[0][0]=arr[0][0];
dp[0][1]=arr[0][1];
dp[0][2]=arr[0][2];
for i in range(1,n):
    for j in range(3):
        dp[i][j]=arr[i][j]+max(dp[i-1][(j+1)%3],dp[i-1][(j+2)%3]);
print(max(dp[n-1]));


Measured memory_bytes: 97268
n = int(input())
ans = []
dict = {}
for i in range(n):
    a = input()
    if a in dict:
        if dict[a] == 0:
            dict[a] = 1
        else:
            dict[a] = 0
    else:
        dict[a] = 1

ans = 0
for v in dict.values():
    ans += v

#print(dict)
print(ans)


Measured memory_bytes: 59864
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int main(){
    int n, sum=0;
    cin >> n;
    int t=n;
    while(t > 0){
        sum += t % 10;
        t /= 10;
    }
    if(n%sum == 0)cout << "Yes" <<endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
import math

def main():
    A,B,H,M=map(int,input().split())

    radianM=6*M
    radianH=30*H+(0.5*M)

    theta=math.radians(abs(radianM-radianH))

    C2=pow(A,2)+pow(B,2)-(2*A*B*math.cos(theta))
    C=math.sqrt(C2)

    print(C)

if __name__=="__main__":
    main()


Measured memory_bytes: 9500
program sample
    implicit none
  
    integer(8) :: i,j,k,m,n,h,w,b
    

    integer(8)::a(3,3),che(3,3)
    read(*,*) a
    read(*,*) n
    che=0
    do i=1,n
        read(*,*)b
        do j=1,3
            do k=1,3

                if (b==a(j,k))then
                    che(j,k)=1
                end if

            end do
        end do
    end do
    do i=1,3
        if (che(i,1)==1 .and. che(i,2)==1 .and. che(i,3)==1)then
            write(*,*)'Yes'
            stop
        end if
    end do
    do i=1,3
        if (che(1,i)==1 .and. che(2,i)==1 .and. che(3,i)==1)then
            write(*,*)'Yes'
            stop
        end if
    end do
    
    if (che(1,1)==1 .and. che(2,2)==1 .and. che(3,3)==1)then
            write(*,*)'Yes'
            stop
    end if
    

    if (che(1,3)==1 .and. che(2,2)==1 .and. che(3,1)==1)then
        write(*,*)'Yes'
        stop
    end if

    write(*,*)'No'
    stop
end program sample
  



Measured memory_bytes: 384
#include <iostream>
#include <cstdlib>
#include <fstream>
#include <set>
#include <unordered_set>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <map>
#include <unordered_map>
#include <iomanip>
#include <numeric>

using namespace std;

typedef long long ll;

#define forn(i, n) for(int i = 0; i < (int)(n);++i)
#define fore(i, a, b) for(int i = (int)(a); i <= (int)(b); ++i)
#define fi first
#define se second
#define pb push_back
#define pll pair<ll,ll>
#define vi vector<int>
#define vc vector<char>
#define vs vector<string>
#define vb vector<bool>
#define vvi vector<vi>
#define vpll vector<pll>
#define vll vector<ll>
#define vvll vector<vll>
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

ll n;

void fastik() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
}

//ifstream &cin
void solve(){

}

ll get(ll x){
    return (n+x-1)/x;
}

bool check(char c){
    return c == 'A' || c == 'C' || c == 'G' || c =='T';
}

int main() {
    fastik();
    ll n,m,c;cin>>n>>m>>c;
    vll b(m);
    forn(i,m){
        cin >> b[i];
    }

    ll ans = 0;
    forn(i,n){
        vll a(m);
        ll s = 0;
        forn(j,m){
            cin >> a[j];
            s+= a[j]*b[j];
        }
        s+=c;
        if(s>0){
            ans++;
        }
    }

    cout << ans;

}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
using namespace std;

void output_array(int* A, int N){
    for(int i = 0; i < N; i++){
        printf("%d", A[i]);
        if(i != N - 1){
            printf(" ");
        }else{
            printf("\n");
        }
    }
}

int selectionSort(int* A, int N){
    int count = 0;
    for(int i = 0; i < N; i++){
        int minj = i;
        for(int j = i; j < N; j++){
            if(A[j] < A[minj]){
                minj = j;
            }
        }
        if (i != minj){
            swap(A[i], A[minj]);
            count++;
        }
    }
    return count;
}


int main(void){
    int N;
    scanf("%d", &N);
    int A[N];
    for(int i = 0; i < N; i++){
        scanf("%d", &A[i]);
    }
    int count = selectionSort(A, N);
    output_array(A, N);
    printf("%d\n", count);
}



Measured memory_bytes: 3192
#include <iostream>

using namespace std;

typedef long long ll;

int main() {
    ll x, k, d; cin >> x >> k >> d;

    if (x < 0)
        x = -x;

    if (x / d >= k)
        cout << x - d * k << endl;
    else {
        if ((k-x/d) % 2 == 0)
            cout << x%d << endl;
        else 
            cout << d - x%d << endl;
    }
    return 0;
}

Measured memory_bytes: 3596
#include "bits/stdc++.h"
using namespace std;

#define int long long
#define MAX_N (200005)
#define INF (1LL<<60)
#define EPS (1e-7)
#define DEBUG(x) cerr << #x <<":"<< x << endl;
#define DEBUGVC(x) cerr << #x <<": "; for(auto p:(x)) cerr << p <<" "; cerr << endl;
#define DEBUGVCP(x) for(auto p:(x)) cerr << #x <<": "<< p.first <<", "<< p.second << endl;
#define DEBUG2(x, y) cerr << #x <<" : "<< x <<", "<< #y <<" : "<< y << endl;
#define DEBUG3(x, y, z) cerr << #x <<" : "<< x <<", "<< #y <<" : "<< y <<", "<< #z <<" : "<< z << endl;
const int MOD = (int)1e9+7;
#define P pair<int,int>


signed main() {
    int W, H, x, y;
    cin >> W >> H >> x >> y;

    if((x*2 == W) && (y*2 == H)){
        printf("%.10f", W*H/2.0);
        cout <<" "<< 1 << endl;
    }
    else {
        printf("%.10f", W*H/2.0);
        cout <<" "<< 0 << endl;
    }
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
main()
{
        int h,n,sum=0;
        cin>>h>>n;
        for(int i = 0 ; i<n; i++){
            int x ;
            cin>>x;
            sum+=x;
        }

        if(sum >= h)cout<<"Yes\n";
        else cout<<"No\n";



    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define fn for(int i =0 ;i <n;i++)
#define fn1 for( int i =1;i<=n;i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define endl '\n'
# define PI  3.14159265358979323846
#define MOD 1000000007
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
const int N = 2e6+5;
const int INF = 1e18L;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}
int ar[N];
int dp[N];
signed main(){
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	// #endif
	IOS;
	int T=1;
	// cin >> T;
	while(T--){
		int n;
		cin >> n ;
		int ans = 0;
		int m = n;
		fn1{
			fm1{
				for(int k=1;k<=n;k++){
					int x = __gcd(i,j);
					x = __gcd(x,k);
					ans+=x;
				}
			}
		}
		cout <<ans;

	
	
	}
	cerr << "Time Taken : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
	return 0;
}

Measured memory_bytes: 3804
# -*- coding: utf-8 -*-
#Python
import sys

N=input()
adj=[[] for i in range(N+1)]

#隣接リスト
for i in range(N-1):
    x,y=list(map(int,raw_input().split()))
    adj[x].append(y)
    adj[y].append(x)

#print adj

#訪問判別フラグ
F=(N+1)*[0]

#Stack
S=[]

#距離
dist=(N+1)*[0]


#先頭から深さ優先探索
S.append(1)
while len(S) != 0:
	#print S
	v=S.pop()
	#print v
	
	if F[v]==0:
		F[v]=1
		#print F
		for u in adj[v]:
			#print "u::"+str(u)
			if F[u]==0:
				S.append(u)
				dist[u]=dist[v]+1
				#print S

#print dist



#訪問判別フラグ
F=(N+1)*[0]

#Stack
S=[]

#距離
dist2=(N+1)*[0]

#最後から深さ優先探索
S.append(N)
while len(S) != 0:
	#print S
	v=S.pop()
	#print v
	
	if F[v]==0:
		F[v]=1
		#print F
		for u in adj[v]:
			#print "u::"+str(u)
			if F[u]==0:
				S.append(u)
				dist2[u]=dist2[v]+1
				#print S

#print dist2



f_p=0
s_p=0
for k in range(1,N+1):
	if dist[k]<=dist2[k]:
		f_p+=1
	else:
		s_p+=1


if f_p>s_p:
	print 'Fennec'
else:
	print 'Snuke'


Measured memory_bytes: 30324
#include <bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w",stdout);
    #endif
    int a;
    cin>>a;
    int b = a%10;
    if(b==2 || b==4 || b==5 ||  b==7 || b==9) cout<<"hon";
    else if(b==0 || b==1 || b==6 || b==8) cout<<"pon";
    else{cout<<"bon";}
     
}

Measured memory_bytes: 3636
using System;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] val_str = Console.ReadLine().Split(' ');
            int[] intArry = val_str.Select(int.Parse).ToArray();
            Array.Sort(intArry);

            int sum = intArry[0] + intArry[1];

            Console.WriteLine(sum);
        }
    }
}

Measured memory_bytes: 13396
def s():
 def b(M,x,y,n=1):
  M[x][y]=0;a=n
  if M[x-1][y]:a=max(a,b(M,x-1,y,n+1))
  if M[x][y-1]:a=max(a,b(M,x,y-1,n+1))
  if M[x+1][y]:a=max(a,b(M,x+1,y,n+1))
  if M[x][y+1]:a=max(a,b(M,x,y+1,n+1))
  M[x][y]=1
  return a
 for e in iter(input,'0'):
  n,m=int(e),int(input())
  P=[[0]*(n+2)for _ in[0]*(m+2)]
  for i in range(m):P[i+1][1:-1]=map(int,input().split())
  print(max({b(P,i,j)for i in range(1,m+1)for j in range(1,n+1)if P[i][j]}))
if'__main__'==__name__:s()


Measured memory_bytes: 5724
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		String ans = "";

		for (int i = 0; i < S.length(); i++) {
			if (S.charAt(i) == '0') {
				ans += 0;
			}
			if (S.charAt(i) == '1') {
				ans += 1;
			}
			if (S.charAt(i) == 'B') {
				if (ans.length() > 0) {
					ans = ans.substring(0, ans.length() - 1);
				} else {
					continue;
				}
			}
		}

		System.out.println(ans);
	}

}


Measured memory_bytes: 21716
#include "bits/stdc++.h"
#include <cmath>
#include <iomanip>
using namespace std;
 
#define f first
#define s second
 
#define pb push_back
#define pp pop_back
#define mp make_pair
 
#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
#define clr(a,v) memset(a, v, sizeof(a))
 
#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)
#define reflex ios_base::sync_with_stdio(false)
 
#define nl '\n'
#define ioi exit(0);
 

#define PI 3.14159265

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
 
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int N= (int)5e5 + 7;
const int inf = (int)1e9 + 7;
//const int mod = (int)1e9 + 7;
//const int mod = 1000000007;
const ll linf = (ll)1e18 + 7;
 
const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int kx[] = {-1,1,2,2,1,-1,-2,-2};
const int ky[] = {2,2,1,-1,-2,-2,-1,1};

const int mod = 998244353;

struct dsu{
	int parent[N];
	void make_set(int v){
		parent[v] = v;
	}
	
	int find_set(int v){
		if(v == parent[v])
			return v;
		return find_set(parent[v]);
	}
	
	void union_sets(int a, int b){
		a = find_set(a);
		b = find_set(b);
		if(a != b)
			parent[b] = a;
	}
};


//~ vector< vector<int> > edge;
//~ int main(){
	//~ int n, m; cin >> n >> m;
	//~ for(int i = 1; i <= m; i++){
		//~ int w, u, v; cin>> w >> u >> v;
		//~ edge.push_back({w,u,v});
	//~ }
	//~ sort(edge.begin(), edge.end());
	//~ vector< vector<int> > ans;
	//~ dsu d;
	//~ d.make_set(n);
	//~ for(int i = 0; i < (int)edge.size(); i++){
	//~ for(int i = 0; i < 1; i++){
		//~ int u = edge[i][1];
		//~ int v = edge[i][2];
		//~ int x = d.find_set(u);
		//~ int y = d.find_set(v);
		//~ cout<< x<<" "<<y<<endl;
		//~ if(u != v){
			//~ d.union_sets(u, v);
			//~ ans.push_back(edge[i]);
		//~ }
	//~ }
	
	//~ for(int i = 0; i < (int) edge.size(); i++){
		//~ cout<< ans[i][0]<<" "<<ans[i][1]<<" "<<ans[i][2]<<endl; 
	//~ }
	//~ return 0;
//~ }
 
		

int main(){
	int r; cin>>r;
	cout<<r*r;
	
	return 0;
}


Measured memory_bytes: 256