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

using namespace std;

int main()
{
  int N, X[100], Y[100];

  scanf("%d", &N);

  for(int i = 0; i < N; i++) scanf("%d", X + i);
  for(int i = 0; i < N; i++) scanf("%d", Y + i);

  int ret = 0;
  for(int i = 0; i < N; i++) ret = max(ret, abs(X[i] - Y[i]));

  auto get = [&](double p)
  {
    double res = 0;
    for(int i = 0; i < N; i++) {
      res += pow(abs(X[i] - Y[i]), p);
    }
    return (pow(res, 1.0 / p));
  };

  cout << fixed << setprecision(10);
  cout << get(1) << endl;
  cout << get(2) << endl;
  cout << get(3) << endl;
  cout << ret << endl;
}

Measured memory_bytes: 3424
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
int n,dx[8]={-1,-1,-1,0,0,1,1,1},dy[8]={-1,0,1,-1,1,-1,0,1},ans;
map<P,int> m;
bool check(int x, int y) {
  return x>=0&&x<n&&y>=0&&y<n;
}
 
P S(vector<string> s) {
  P p=P(0,0);
  for(int i=0; i<n; i++) {
    for(int j=0; j<n; j++) {
      if(s[i][j]=='#') p.first|=1<<(i*n+j);
      if(s[i][j]=='@') p.second=i*n+j;
    }
  }
  return p;
}
 
vector<string> change(vector<string> s) {
  vector<string> t=s;
  for(int i=0; i<n; i++) {
    for(int j=0; j<n; j++) {
      int c=0;
      for(int k=0; k<8; k++) {
        int x=i+dx[k],y=j+dy[k];
        if(!check(x,y)) continue;
        if(s[x][y]!='.') c++;
      }
      if(s[i][j]=='#') {
        if(c==2||c==3) t[i][j]='#';
        else t[i][j]='.';
      }
      if(s[i][j]=='.') {
        if(c==3) t[i][j]='#';
        else t[i][j]='.';
      }
      if(s[i][j]=='@') t[i][j]='@';
    }
  }
  return t;
}
 
int main() {
  while(cin >> n && n) {
    vector<string> s(n);
    for(int i=0; i<n; i++) cin >> s[i];
    queue<P> que;
    P p=S(s);
    que.push(p);
    m.clear();
    m[p]=0;
    while(!que.empty()) {
      P p=que.front();que.pop();
      vector<string> s(n);
      bool f=1;
      for(int i=0; i<n; i++) {
        for(int j=0; j<n; j++) {
          if(p.first&(1<<(i*n+j))) s[i]+='#',f=0;
          else s[i]+='.';
        }
      }
      s[p.second/n][p.second%n]='@';
      if(f) {
        cout << m[p] << endl;
        goto end;
      }
      int nx=p.second/n,ny=p.second%n,c=m[p];
      for(int i=0; i<8; i++) {
        int x=nx+dx[i],y=ny+dy[i];
        if(!check(x,y)||s[x][y]!='.') continue;
        vector<string> t=s;
        t[nx][ny]='.';
        t[x][y]='@';
        t=change(t);
        P q=S(t);
        if(m.count(q)) continue;
        m[q]=c+1;
        que.push(q);
      }
    }
    cout << -1 << endl;
  end:;
  }
  return 0;
}


Measured memory_bytes: 2480
#include <bits/stdc++.h>
using namespace std;
long long n;
int main (){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n;
for (long long i=sqrt(n); i>0; i--){
	if (n%i) continue;
	cout << i+(n/i)-2;
	return 0;
}
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

//find_by_order gives kth-largest element
//order_of_key gives the number of items in the set that are strictly smaller!!

// OT.find_by_order(k-1)
// 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define db4(x, y, z, w) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << "," << #w << "=" << w << endl
#define ll long long
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define X first
#define Y second
#define sz(x) (int)((x).size())
#define pii pair<int,int>
#define MOD (ll)(998244353)
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
typedef vector<int> vi;
#define inf (ll)(1e18)
#define double long double
#define int long long

//////////////////////
// const int N = 2005;


int32_t main() {

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

    int n;
    cin >> n;

    if(n > 999)  cout << "ABD\n";
    else cout << "ABC\n";

}

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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)

int main() {
  string s;
  cin >> s;
  for(int i=0; i < s.size(); i++) cout << "x";
  cout << endl;
}


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

int main() {
  	int N;
    cin >> N;
    int A[N];
  	for (int i=0; i<N; i++) { cin >> A[i]; }

  	int a = pow(10, 9);
  	for (int i=0; i<N; i++) {
      int c = 0;
      while (A[i] % 2 == 0) {
        A[i] /= 2;
        c++;
      }
      if (a > c) {
        a = c;
      }
    }
  	cout << a << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,k,n) for(int i=(k);i<(int)(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) begin(x),end(x)
using namespace std;
using ll = int64_t;

int main() {
  ll n;
  cin>>n;
  vector<tuple<ll, ll>> vt;
  REP(i,n) {
    ll a;
    cin>>a;
    vt.emplace_back(a, i);
  }
  sort(ALL(vt));
  set<ll> s;
  s.insert(-1);
  s.insert(n);
  ll sum = 0;
  REP(i,n) {
    ll val, idx;
    tie(val, idx) = vt[i];
    const auto ritr = s.upper_bound(idx);
    const auto r = *ritr;
    const auto l = *prev(ritr);
    sum += (idx - l) * (r - idx) * val;
    s.insert(idx);
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 13676
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#define ll long long
using namespace std;
int main(){
     int C0 = 0;
     int C1 = 0;
     string S;
     cin >> S;

     for(int i = 0; i < S.size(); i++){
          if(S[i] == '0'){
               C0++;
          }else{
               C1++;
          }
     }
     cout << 2*min(C0,C1) << endl;
     return 0;
}

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

int main(){
    string s;
    cin >> s;
    if(s[s.size()-1]=='s') cout << s << "es" << endl;
    else cout << s << "s" << endl;

    return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define ll long long
#define P pair<int,int>
int N;
struct edge{int to,cost;};
vector<edge> G[300010];
ll D[300010];
void dijkstra(int s){
  priority_queue<P,vector<P>,greater<P>> Q;
  rep(i,N) D[i]=1000000000000000000;
  D[s]=0;
  Q.push(P(0,s));
  while(!Q.empty()){
    P p=Q.top();
    Q.pop();
    int x=p.second;
    if(D[x]<p.first) continue;
    rep(i,G[x].size()){
      edge e=G[x][i];
      if(D[e.to]>D[x]+e.cost){
        D[e.to]=D[x]+e.cost;
        Q.push(P(D[e.to],e.to));
      }
    }
  }
}
int main(){
  cin>>N;
  int M;
  cin>>M;
  vector<int> U(M),V(M);
  rep(i,M) cin>>U[i]>>V[i];
  int S,T;
  cin>>S>>T;
  rep(i,M){
    edge e0={V[i]-1+N,1};
    edge e1={V[i]-1+N*2,1};
    edge e2={V[i]-1,1};
    G[U[i]-1].push_back(e0);
    G[U[i]-1+N].push_back(e1);
    G[U[i]-1+N*2].push_back(e2);
  }
  N*=3;
  dijkstra(S-1);
  int ans=-1;
  if(D[T-1]!=1000000000000000000) ans=D[T-1]/3;
  cout<<ans<<endl;
}



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

using namespace std;
const int N = 3e5;
long long f[N][2];
long long a[N], g[N];
int n;
int main() {
    ios_base::sync_with_stdio(0);
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    int ok = 0;
    for (int i = 1; i <= n; i++)
        if (a[i] > 0) ok = 1;
    long long mx = -1e18, nm = 0;
    if (!ok) {
        for (int i = 1; i <= n; i++)
            if (a[i] > mx) {
                mx = a[i];
                nm = i;
            }
        cout << mx << "\n";
        cout << n - 1 << "\n";
        for (int i = n; i > nm; i--) cout << i << "\n";
        for (int i = 1; i < nm; i++) cout << 1 << "\n";
        return 0;
    }
    for (int i = 1; i <= n; i++) {
        long long s = 0, tk = 0;
        for (int j = i; j <= n; j += 2) {
            if (a[j] >= 0) {
                s += a[j];
                tk = 1;
            }
        }
        if (s > mx && tk) {
            mx = s;
            nm = i;
        }
    }
    cout << mx << "\n";
    vector<int> lst, ans;
    int frst = -1;
    for (int i = nm; i <= n; i += 2)
        if (a[i] > 0) {
            if (frst == -1) frst = i - 1;
            lst.push_back(i - frst);
        }
    for (int i = n; i > frst + lst.back(); i--) ans.push_back(i);
    for (int i = 1; i <= frst; i++) ans.push_back(1);
    int del = 0;
    for (int i = 0; i + 1 < lst.size(); i++) {
        int m = (lst[i] - 2 * del + lst[i + 1]) / 2;
        for (int k = 1; k < lst[i + 1] - lst[i]; k += 2) {
            ans.push_back(m - k / 2);
            del += 2;
        }
    }
    cout << ans.size() << "\n";
    for (auto it = ans.begin(); it != ans.end(); it++) cout << *it << "\n";
    return 0;
}




















































































































































































































































Measured memory_bytes: 2304
package main

import (
	"fmt"
	"os"
)

func main() {
	var s string
	fmt.Scan(&s)
	hash := make(map[string]bool)

	for i := 0; i < len(s); i++ {
		if hash[string(s[i])] {
			fmt.Println("no")
			os.Exit(0)
		}
		hash[string(s[i])] = true
	}
	fmt.Println("yes")
}

// nの階乗(mod M) ただしMは素数
// return: nまでの階乗を示す全値(e.g., fact[5] = 5!を示す値)
func mfactorial(n int, M int) []int {
	fact := make([]int, n+1)
	fact[0] = 1
	for i := 1; i <= n; i++ {
		fact[i] = (fact[i-1] * i) % M
	}
	return fact
}

// x^n (mod M) ただしMは素数
// See https://qiita.com/ofutonfuton/items/92b1a6f4a7775f00b6ae
func mpow(x, n, M int) int {
	ans := 1
	for n != 0 {
		if n&1 == 1 {
			ans = ans * x % M
		}
		x = x * x % M
		n = n >> 1
	}
	return ans
}

// nCk (mod M) ただしMは素数
// @see https://qiita.com/ofutonfuton/items/92b1a6f4a7775f00b6ae
func combi(n, k, M int) int {
	return commonPermutationAndCombination(n, k, M, true)
}

// nPk (mod M) ただしMは素数
// @see https://qiita.com/ofutonfuton/items/92b1a6f4a7775f00b6ae
func permutation(n, k, M int) int {
	return commonPermutationAndCombination(n, k, M, false)
}

func commonPermutationAndCombination(n, k, M int, combi bool) int {
	if n == 0 && k == 0 {
		return 1
	} else if n < k || n < 0 {
		return 0
	}
	fact := mfactorial(n, M)

	ans := fact[n] * mpow(fact[n-k], M-2, M) % M
	if combi {
		ans *= mpow(fact[k], M-2, M) % M
	}

	return ans % M
}


Measured memory_bytes: 512
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <bitset>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <utility>
using namespace std;

int main() {
    int L, R, d;
    cin >> L >> R >> d;
    int result = 0;
    for (int i = L; i <= R; ++i) {
        if (i % d == 0) {
            result += 1;
        }
    }
    cout << result << endl;
}


Measured memory_bytes: 3560
H, W = map(int, input().split())
S = [input() for _ in range(H)]
dp = [[[1000] * 2 for _ in range(W)] for _ in range(H)]


def F(h, w, f):
    if f == -1:
        if S[h][w] == ".":
            return False
        else:
            return True
    if S[h][w] == "#":
        return False
    else:
        return True


if S[0][0] == "#":
    dp[0][0][0] = 1
    dp[0][0][1] = 1
else:
    dp[0][0][0] = 0
    dp[0][0][1] = 0

for i in range(H):
    for j in range(W):
        if j != 0:
            if S[i][j] == S[i][j - 1]:
                dp[i][j][0] = min(dp[i][j][0], dp[i][j - 1][0])
                dp[i][j][1] = min(dp[i][j][1], dp[i][j - 1][1])
            else:
                dp[i][j][0] = min(dp[i][j][0], dp[i][j - 1][1] + 1)
                dp[i][j][1] = min(dp[i][j][1], dp[i][j - 1][0] + 1)
        if i != 0:
            if S[i][j] == S[i - 1][j]:
                dp[i][j][0] = min(dp[i][j][0], dp[i - 1][j][0])
                dp[i][j][1] = min(dp[i][j][1], dp[i - 1][j][1])
            else:
                dp[i][j][0] = min(dp[i][j][0], dp[i - 1][j][1] + 1)
                dp[i][j][1] = min(dp[i][j][1], dp[i - 1][j][0] + 1)

print((min(dp[H - 1][W - 1]) + 1) // 2)



Measured memory_bytes: 45804
{-# LANGUAGE PartialTypeSignatures #-}
module Main (main) where

import qualified Data.ByteString.Char8 as C8
import qualified Data.Char as C
import qualified Data.List as L
import Data.Maybe

main :: IO ()
main = readInts >>= output . solve

solve :: [Int] -> Int
solve [n] = sum . map toFizzBuzz $ [1..n]
  where
    toFizzBuzz n =
      if n `mod` 3 == 0 || n `mod` 5 == 0
        then 0
        else n

output :: Int -> IO ()
output = print

-- utils
readInts :: IO [Int]
readInts = L.unfoldr (C8.readInt . C8.dropWhile C.isSpace) <$> C8.getLine

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

int64_t DP[2][1<<16];
int main(){
    int N;
    while(cin>>N,N){
        fill(DP[0],DP[2],0);
        for(int i=1;i<=N;i++){
            int M;
            int64_t L;
            cin>>M>>L;
            int bit=0;
            for(int j=0;j<M;j++){
                int S,E;
                cin>>S>>E;
                S-=6;E-=6;
                for(int k=S;k<E;k++) bit|=(1<<k);
            }
            for(int b=0;b<(1<<16);b++) DP[i&1][b]=DP[i&1^1][b];
            for(int b=0;b<(1<<16);b++){
                if(bit&b) continue;
                else DP[i&1][bit^b]=max(DP[i&1][bit^b],DP[i&1^1][b]+L);
            }
        }
        int64_t ans = 0;
        for(int b=0;b<(1<<16);b++) ans = max(ans, DP[N&1][b]);
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 4112
/**
     **author : _KMS_
     **created : 12-03-2020
**/
#include<bits/stdc++.h>
using namespace std;
const long long M =1e5+100,MOD=2e9;
typedef long long ll;
int arr[M];
ll way;
int main() 
{ 
      
 ios::sync_with_stdio(false);
 cin.tie(0);
 int n,m;
 cin>>n;
 for(int i=0;i<n;i++)cin>>arr[i];
 sort(arr,arr+n);
 for(int i=n-1;i>=1;i--)
 {
       int l=0,r=i-1;
       while(l<r)
       {
             if(arr[i]<arr[l]+arr[r])
             {
                   way+=(ll)(r-l);
                   r--;
             }
             else
             l++;
       }
 }
 cout<<way<<"\n";

 
	return 0; 
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
   ll a,i,j,k,sum=0;
   cin>>a;
   for(i=1;i<=a;i++)
   {
       for(j=1;j<=a;j++)
       {
           for(k=1;k<=a;k++)
           {
               sum+=__gcd(i,__gcd(j,k));
           }
       }
   }
   cout<<sum<<endl;





    return 0;
}


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

using namespace std;

long long inf=1000000007;

int main(){
	long long und;
	cin>>und;

	for(long long i=1;i<=3500;i++){
		for(long long j=1;j<=3500;j++){
			if((4*i*j-und*j-und*i)>0 && (und*i*j)%(4*i*j-und*j-und*i)==0){
				cout<<i<<" "<<j<<" "<<(und*i*j)/(4*i*j-und*j-und*i)<<endl;
				return 0;
			}
		}
	}

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <map>
#include <vector>
#include <set>
#include <math.h>
#include <queue>
using namespace std;

const long long mod = 998244353 ;

map<int,int,greater<int> > ori_a,a;
map<int,int,greater<int> >::iterator it1,it2;
int f[200010],n;

int check(long long time,long long k){
    a=ori_a;
   // printf("%lld\n",time);
    for (int i=0;i<n;++i)
    {//printf("%d %d;",i,k);
        if (a.size()==1){
            long long tmp=time/f[i];
            it1=a.begin();
            if(it1->first>tmp){
                k-=1LL*(it1->first-tmp)*(it1->second);
                int num=it1->second;
                a.erase(it1);a[tmp]+=num;
                if (k<0) return 0;
            }
            it1=a.begin();
            it1->second--;
            if (it1->second ==0) a.erase(it1);
            continue;
        }

            long long tmp=time/f[i];
            it1=a.begin();
            it2=a.begin();it2++;
            if (tmp<=it2->first){
                k-=1LL*(it1->first-it2->first)*(it1->second);
                it2->second+=it1->second;
                a.erase(it1);
                if (k<0) return 0;
                --i;continue;
            }
            if (it1->first>tmp){
                k-=1LL*(it1->first-tmp)*(it1->second);
                int num=it1->second;
                a.erase(it1);a[tmp]+=num;
                if (k<0) return 0;
            }
            it1=a.begin();it1->second--;
            if (it1->second ==0) a.erase(it1);
            continue;

    }
    return 1;

}

int main()
{
    long long k;scanf("%d%lld",&n,&k);
    for (int i=0;i<n;++i){
        int tmpa;
        scanf("%d",&tmpa);
        ori_a[tmpa]++;
    }
    for (int i=0;i<n;++i) scanf("%d",&f[i]);
    sort(f,f+n);

    long long ll=0,rr=1LL*1e6*1e6;long long ans=rr;
    while (ll<=rr){
        long long mid=(ll+rr)/2;
        if (check(mid,k)){ ans=mid; rr=mid-1;}
        else ll=mid+1;
    }
    printf("%lld\n",ans);

}


Measured memory_bytes: 20096
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;

#define REP(i, n) for (int i = 0; i < (n); i++)
#define REP1(i, n) for (int i = 1; i < (n); i++)
#define CIN(A) int A; cin >> A;
#define CIN2(A, B) int A, B; cin >> A >> B;
#define CIN3(A, B, C) int A, B, C; cin >> A >> B >> C;
#define CINVEC(A, N) vector<int> A; REP(i, N) { int a; cin >> a; A.emplace_back(a); }
#define ANS(ans) cout << (ans) << endl
#define rsort(p, q) sort(p, q, greater<int>());

#define DEBUGV(V) REP(i, V.size() - 1) cout << V.at(i) << " "; cout << endl 

int
main()
{
  CIN2(H, W);

  cout << "#";
  REP(i, W) cout << "#";
  cout << "#" << endl;
  REP(i, H) {
    cout << "#";
    string S;
    cin >> S;
    cout << S;
    cout << "#" << endl;
  }
  cout << "#";
  REP(i, W) cout << "#";
  cout << "#" << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define lp(i,n) for(i=0;i<n;i++)
int main(){
  int i;
  int j;
  int h;
  int w;
  while(1){
  scanf("%d %d", &h, &w);
  if(h == 0 && w == 0){break;}
  lp(i,h){
    lp(j,w){
      printf("#");
    }printf("\n");
  }
  printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2044
/**Bismillahir Rahmanir Rahim.**/
#include<bits/stdc++.h>
#include<stdlib.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<cstring>
#include<cstdio>
using namespace std;
typedef long long int            ll;
typedef long double              ld;
#define Faster  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pi                 acos(-1);
#define test        int t; cin>>t; while(t--)
//scanf("%[^\n]%*c", str);
//sort(s,s+n,greater<int>());
//cin.getline(array,size);
int main()
{
    #ifndef ONLINE_JUDGE
        clock_t tStart = clock();
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    string a;
    cin>>a;
    if(a[a.size()-1]=='s')
    {
    	cout<<a<<"es"<<endl;
    }
    else
    	cout<<a<<"s"<<endl;
    
    #ifndef ONLINE_JUDGE
        fprintf(stderr, "\n>> Runtime: %.10fs\n", (double) (clock() - tStart) / CLOCKS_PER_SEC);
    #endif
}

Measured memory_bytes: 3628
import java.math.*;
import java.io.*;
import java.util.*;

public class Main {
	public static void main(String[] args) throws IOException{
		FastScanner sc = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
		int t = 1;
		while (t-->0) {
		    int k = sc.nextInt();
		    int[][] gcd = new int[k+1][k+1];
		    for (int i=1;i<=k ;i++ ){
		        for(int j=i;j<=k;j++){
		            gcd[i][j] = gcd[j][i] = gcd(i,j);
		        }
		    }
		    long sum = 0;
		    for(int i=1;i<=k;i++){
		        for(int j=1;j<=k;j++){
		            for(int j1=1;j1<=k;j1++){
		                sum+=gcd(j1,gcd[i][j]);
		            }
		        }
		    }
		    out.println(sum);
		}
		out.close();
	}
	static int gcd(int a, int b){
	    if(b==0) return a;
	    return gcd(b,a%b);
	}
	static class Pair implements Comparable<Pair>{
		int a, b;
		public Pair(int c, int d){
			a = c;
			b = d;
		}
		public int compareTo(Pair p){
		    return a-p.a;
		}
	}
	static class FastScanner {
		BufferedReader br;
		StringTokenizer st;
		FastScanner(File f) {
			try {
				br = new BufferedReader(new FileReader(f));
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			}
		}
		FastScanner(InputStream f) {
			br = new BufferedReader(new InputStreamReader(f));
		}
		String nextLine() {
			try {
				return br.readLine();
			} catch (IOException e) {
				return null;
			}
		}
		String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}
		int nextInt() {
			return Integer.parseInt(next());
		}
		long nextLong() {
			return Long.parseLong(next());
		}
		double nextDouble() {
			return Double.parseDouble(next());
		}
	}
}

Measured memory_bytes: 33932
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

using namespace std;
typedef long long int ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;

int main()
{
    ll N, X;
    cin >> N >> X;
    ll _min = MOD;
    ll cnt = 0;
    rep(i, N) {
        ll m;
        cin >> m;
        _min = min(_min, m);
        X -= m;
        cnt++;
    }
    print(cnt + X / _min);
    return 0;
}


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

int main() {
int N,K;
  cin>>N>>K;
  int x=1;
  for(int i=1; i<=N; i++){
   if(x*2<x+K){x*=2;}
   else{x+=K;}
  }
  cout<<x<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vector<int>>
#define vvb vector<vector<bool>>
#define vb vector<bool>
#define vpli vector<pair<long long, int>>
#define deb(x) cout <<"deb "<<#x<<" "<< x << endl;
#define all(x) x.begin(), x.end()
ll MOD = 1e9 + 7;
const int INF = 2e9 + 10;
void solve()
{
    unordered_set<int> st;
    int n;
    cin>>n;
    int x;
    for(int i=0;i<n;i++)
    {
        cin>>x;
        if(st.find(x) != st.end())
        {
            cout<<"NO\n";
            return;
        }
        st.insert(x);
    }
    cout<<"YES\n";
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    //cin >> t;
    while (t--)
        solve();
    return 0;
}

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

using namespace std;

int main(){

	int n;
	int q;
	while(cin>>q&&q!=-1){
		int val=1150;
		if(q>10){
			int m=min(q,20)-10;
			val+=m*125;
		}
		if(q>20){
			int m=min(q,30)-20;
			val+=m*140;
		}
		if(q>30){
			int m=q-30;
			val+=m*160;
		}
		cout<<4280-val<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
int main() {
  char Ans[30] = "abcdefghijklmnopqrstuvwxyz";
  char C;
  scanf("%c", &C);
  int i;
  for (i = 0; i < 26; ++i) {
    if (C == Ans[i]) {
      printf("%c\n", Ans[i+1]);
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 128
n=int(input())
list=[]
for i in range(n):
    s,p=input().split()
    list.append([s,int(p),i+1])
sort1=lambda val: val[1]
list.sort(reverse=True,key=sort1)
sort2=lambda val: val[0]
list.sort(key=sort2)
for i in range(n):
    print(list[i][2])


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

int main() {
    int n, d;
    cin >> n >> d;
    int ans = 0;
    int last = 0;
    for (int i = 1; i <= n; i++) {
        if (last < i) {
            last = i + 2*d;
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
n = input()
hon = ["2", "4", "5", "7", "9"]
pon = ["0", "1", "6", "8"]
bon = ["3"]

if n[-1] in hon:
    print("hon")
if n[-1] in pon:
    print("pon")
if n[-1] in bon:
    print("bon") 

Measured memory_bytes: 9120
#include <cstdio>
#include <set>
#include <cmath>

using LL = long long;

std::multiset<int> tree;

LL solve(int n, int m) {
  while (m--) {
    auto iter = tree.begin();
    int cur = *iter;
    if (cur == 0) break;
    cur = std::ceil(cur / 2.0);
    tree.erase(iter);
    tree.insert(cur);
  }
  
  LL res = 0;
  for (const auto &cur : tree) {
    res -= cur;  // res += (-cur)
  }
  return res;
}

int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 0, in; i < n; ++i) {
    scanf("%d", &in);
    tree.insert(-in);
  }
  printf("%lld\n", solve(n, m));
  return 0;
}


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

namespace ABC_C
{
    class C093
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string[] a0 = Console.ReadLine().Split(' ');
            List<int> X = a0.Select(x => int.Parse(x)).ToList();
            List<int> S = new List<int>(X);
            S.Sort();

            int candS = S[N / 2 - 1];
            int candL = S[N / 2];

            foreach(int x in X)
            {
                if (x <= candS) Console.WriteLine(candL);
                else Console.WriteLine(candS);
            }

        }

    }
}


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

using namespace std;

struct kek{
    long long a;
    long long b;
};

long long n,m,i,j;
kek t[100005];

bool cmp(kek a, kek b)
{
    return a.a<b.a;
}

int main() 
{
    cin>>n>>m;
    for (i=1; i<=n; i++)
    {
        cin>>t[i].a>>t[i].b;
    }
    
    sort(t+1,t+n+1,cmp);
    
    long long nr=0;
    long long sum=0;
    i=1;
    while (nr<m)
    {
        long long take=min(m-nr,t[i].b);
        nr+=take;
        sum+=t[i].a*take;
        i++;
    }
    
    cout<<sum;
    
}

Measured memory_bytes: 1792
//_nebula_
#include<bits/stdc++.h>
using namespace std;
#define int long  long
#define double long double
int t;
const int m=1e9+7;
int factt(int n)
{
    int ans=1;
    for(int i=1;i<=n;i++)
    {
        ans*=i;
        ans=ans%m;
    }
    return ans;
}
int max(int a,int b,int c)
{
    return max(a,max(b,c));
}
int min(int a,int b,int c)
{
    return min(a,min(b,c));
}
int fspow(int x,int y)
{
    int ans;
    if(y==0) return 1;
    ans=fspow(x, y/2);
    if(y%2==0) return (ans*ans)%m;
    return (x*(ans*ans)%m)%m;
}
int gcd(int x,int y)
{
    if(x<y) swap(x,y);
    if(y==0) return x;
    return gcd(x%y,y);
}
int p2(int x)
{
    int ans=0;
    while(x>=1)
    {
        ans++;
        x/=2;
    }
    return ans;
}
signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    t=1;
    // freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
   // cin>>t;
    // int tmp=t;
    while(t--)
    {
        int x,k,d;
        cin>>x>>k>>d;
        x=abs(x);
        int ans;
        if(k<=x/d)
        {
          cout<<x-k*d<<endl;
          continue;
        }
        int v=k-x/d;
        if(v&1) ans=abs(x-(x/d+1)*d);
        else ans=x-(x/d)*d;
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 3640
#include<stdio.h>
int main(void){
    
    int N, a[1000],i,max,min,answer;
    scanf("%d",&N); 
    
    scanf("%d",&a[0]);
    max = min = a[0];

    for(i = 1;i < N;i++){
        scanf("%d",&a[i]);
        if(a[i] >= max){
            max = a[i];
        }
        if(a[i] <= min){
            min = a[i];
        }

    }

    answer = max - min;
   
    printf("%d",answer);

}

Measured memory_bytes: 128
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr long long MOD = 1000000000 + 7;
constexpr long long INF = 100000000000000;
const double PI = acos(-1);

int main() {
	string s;
	cin >> s;
	if (s.substr(0, 4) == "YAKI") cout<<"Yes" << endl;
	else cout << "No" << endl;
}

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

int main()
{
    int n;
    cin >> n;
    vector<int> vec(n);
    for (int i=0; i<n; i++)
    {
        cin >> vec.at(i);
    }
    for (int j=n-1; j>=0; j--)
    {
        cout << vec.at(j);
        if (j==0)
        {
            cout << endl;
        }
        else
        {
            cout << " ";
        }
    }
}


Measured memory_bytes: 3092
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

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

def main():
    A, B, C, D = map(int, input().split())
    B_C = B // C
    B_D = B // D
    A_C = (A-1) // C
    A_D = (A-1) // D
    min_lcm = lcm(C, D)
    B_min_lcm = B // min_lcm
    A_min_lcm = (A-1) // min_lcm
    x = (B - A + 1) - ((B_C - A_C) + (B_D - A_D) - (B_min_lcm - A_min_lcm))
    print(x)

if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include<stdio.h>

int main(){
  int K,A,B;
  int c=0;
  
  scanf("%d\n%d %d",&K,&A,&B);
  for(int i=K;i<=B;i+=K){
    if(A<=i){
      c=1;
      break;
    }
  }
  if(c==0)
    printf("NG\n");
  else
    printf("OK\n");
  
  return 0;
}

Measured memory_bytes: 1660
#include<iostream>

using namespace std;

int ans(int n)
{
  if(n<=1) return 0;
  return (n-1) + ans(n-1);
}

int main()
{
  int N,M;
  
  cin >> N >> M;
  
  cout << ans(N) + ans(M) << endl;
  
  return 0;
}

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

void fast(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
}

int main(){
    fast();
    ll a,b,m,ans=INT_MAX;
    cin>>a>>b>>m;
    ll ar[a],br[b];
    for(ll i=0;i<a;i++)cin>>ar[i];
    for(ll i=0;i<b;i++)cin>>br[i];
    while(m--){
    	ll x,y,c;
    	cin>>x>>y>>c;
    	x--,y--;
    	ans=min(ans,ar[x]+br[y]-c);
	}
	sort(ar,ar+a);
	sort(br,br+b);
	ans=min(ans,ar[0]+br[0]);
	cout<<ans;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define LIMIT(d_in, d_min, d_max) max(d_min, min(d_max, d_in))
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	int N, M, Q;
	cin >> N >> M >> Q;

	vector<lint> s(N + 2);
	vector<lint> t(M + 2);

	s[0] = t[0] = -INF64;
	for (int i = 0; i < N; i++)
	{
		cin >> s[i + 1];
	}

	for (int i = 0; i < M; i++)
	{
		cin >> t[i + 1];
	}

	s[N + 1] = t[M + 1] = INF64;
	for (int i = 0; i < Q; i++)
	{
		lint p;
		cin >> p;
		lint up_s = s[lower_bound(all(s), p) - s.begin()];
		lint up_t = t[lower_bound(all(t), p) - t.begin()];
		lint down_s = s[upper_bound(all(s), p) - s.begin() - 1];
		lint down_t = t[upper_bound(all(t), p) - t.begin() - 1];

		lint ans = INF64;
		ans = min(ans, max(up_s, up_t) - p);
		ans = min(ans, p - min(down_s, down_t));
		ans = min(ans, up_t - down_s + min(p - down_s, up_t - p));
		ans = min(ans, up_s - down_t + min(p - down_t, up_s - p));
		cout << ans << endl;
	}

	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

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

using namespace std;

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	long long a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << max({ a*c,a*d,b*c,b*d });
	return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    int x = -1;
    rep(i, n) {
        cin >> a[i];
        if (a[i]==1) x = i;
    }
    int ans = 1001001001;
    rep(i, k) {
        int l = max(x-i, 0);
        int r = max(n-x-1-(k-1-i), 0);
        int res = 1;
        if (l>0) res += (l-1)/(k-1)+1;
        if (r>0) res += (r-1)/(k-1)+1;
        
        chmin(ans, res);
    }
    
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
import math

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

gusu = 0
kisu = 0

if N >= 2:
    gusu = math.factorial(N) / ( math.factorial(N - 2) * 2 )

if M >= 2:
    kisu = math.factorial(M) / ( math.factorial(M - 2) * 2 )

print(int(gusu + kisu))

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

    static int mod = 1000000007;

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int m = Integer.parseInt(scan.next());
        int n = Integer.parseInt(scan.next());
        scan.close();

        System.out.println(modPow(m, n));
    }

    private static long modPow(long m, long n) {
        if (n == 0) {
            return 1;
        }

        if (n % 2 == 0) {
            return modPow(m * m % mod, n / 2);
        } else {
            return modPow(m * m % mod, (n - 1) / 2) * m % mod;
        }
    }

}



Measured memory_bytes: 26320
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;

int main(){
  int n;
  string s;
  vector<int> r,g,b;
  set<int> st;
  cin >> n >> s;
  rep(i,n){
    if(s[i]=='R'){
      r.emplace_back(i);
    } else if(s[i]=='G'){
      g.emplace_back(i);
    } else{
      b.emplace_back(i);
      st.insert(i);
    }
  }

  ll ans = 0;
  ll tmp = b.size();
  for(auto a:r){
    for(auto p:g){
      ans += tmp;
      if(st.find(p+p-a)!=st.end()){
        ans--;
      }
      if(st.find(a+a-p)!=st.end()){
        ans--;
      }
      if((p+a)%2==0 && st.find((p+a)/2)!=st.end()){
        ans--;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3688
# coding:utf-8

import sys
import math
import time
#import numpy as np
import collections
from collections import deque
from collections import Counter
import queue
import copy
import bisect
import heapq

#sys.setrecursionlimit(10**7)
#N, Q = map(int, input().split())
#G = [list(input()) for i in range(H)]
#INF = V * 10001
#A = [int(i) for i in input().split()]
#AB = [list(map(int, input().split())) for _ in range(K)]


N = str(input())
ans = "No"

if(N[0] == "7" or N[1] == "7" or N[2] == "7"):
  ans = "Yes"
print(ans)


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

using namespace std;

# define int long long
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double, int> pdi;
typedef pair<ll, ll> pll;

# define S second
# define F first
# define kill(x) return(cout << x << endl, 0)
# define debug(x) cerr<< #x << " : " << x << endl
# define ddebug(x, y) cerr<< #x << " : " << x  << ", " << #y << " : " << y << endl
# define sz(s) (int)s.size()
# define sq(x) (x) * (x)
# define PB(x) push_back(x)
# define smax(x, y) (x) = max((x), (y))
# define smin(x, y) (x) = min((x), (y))
# define all(x) x.begin(), x.end()
# define SP fixed << setprecision(10)

int a[3 * 100 * 1000 + 10];

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

	int n;
	cin >> n;
	for (int i = 0; i < 3 * n; i ++)
		cin >> a[i];
	sort(a, a + 3 * n, greater<int>());

	int ans = 0;
	for (int i = 1; i < 2 * n; i += 2)
		ans += a[i];
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 2560
import std;

void main() {
    auto N = readln.split[0].to!long;
    auto A = readln.split.to!(long[]);
    ulong[long] Aminus;
    foreach (j; 0 .. N) {
        if (j-A[j] !in Aminus) Aminus[j-A[j]] = 0;
        Aminus[j-A[j]]++;
    }
    ulong ans;
    foreach (i; 0 .. N) {
        if (A[i]+i !in Aminus) continue;
        ans += Aminus[A[i]+i];
    }
    writeln(ans);
}



Measured memory_bytes: 23132
//Catchharsh
#include<bits/stdc++.h>
#define ll long long int 
#define ld long double
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define F first
#define S second
#define sz(x) x.size()
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define see(x) cout<<#x<<" = "<<x<<endl
const ll MOD = 1e9+7;
const ll INF = 1011111111;
const ll LLINF = 1000111000111000111LL;
const ld EPS = 1e-10;
const ld PI = 3.14159265358979323;
using namespace std;
ll power (ll base,ll exponent)
{
    ll ans=1;
    //base%=MOD;
    //exponent%=(MOD-1);
    while(exponent!=0)
    {
      if(exponent&1) ans=(1LL*ans*base);
      base=(1LL*base*base);
      exponent>>=1;
    }
    return ans;
}

int32_t main()
{   
     IOS;
    set<ll> s;
    for(ll i=0;i<3;i++)
    {
      ll x;
      cin>>x;
      s.insert(x);
    } 
    if(s.size()==2) cout<<"Yes"<<endl;
    else cout<<"No";
     
     
     cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';             
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repp(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;

int dp[310];

signed main(){
    dp[0] = 1;
    rep(i, 1, 18){
        rep(j, 0, 310){
            if(j - i*i >= 0){
                dp[j] += dp[j - i*i];
            }
        }
    }

    int n;
    while(cin >> n, n){
        cout << dp[n] << endl;
    }
}

Measured memory_bytes: 1156
package main

import "fmt"

func main() {
	boss := make(map[int]int)
	var n int
	fmt.Scan(&n)
	var a int
	for i := 1; i < n; i++ {
		fmt.Scan(&a)
		boss[a]++
	}
	for i := 1; i < n+1; i++ {
		v, isExist := boss[i]
		if isExist {
			fmt.Println(v)
		} else {
			fmt.Println("0")
		}
	}
}


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

#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back

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

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

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

    int n,L;
    while(cin>>n>>L,n+L)
    {
	vector<int> a;
	a.push_back(n);

	REP(j,20)
	{
	    int d[6];
	    REP(i,L){
		d[i]=n%10;
		n/=10;
	    }
	    sort(d,d+L);
	    
	    int ma=0,mi=0;
	    REP(i,L){
		ma+=pow(10,i)*d[i];
		mi+=pow(10,i)*d[L-1-i];
	    }
	    n=ma-mi;
	    int i=a.size();
	    a.push_back(n);

	    REP(j,i){
		if(a[i]==a[j]){
		    cout<<j<<" "<<a[i]<<" "<<i-j<<endl;
		    goto g;
		}
	    }
	}
	g:;
    }

}



Measured memory_bytes: 3304
#include <stdio.h>

int main(void) {
	int card[4][13];
	char name;
	int num, x;
	int i, j;
	
	scanf("%d", &num);
	for(i = 0; i < 4 ;i++) {
		for(j = 0; j < 13; j++) {
			card[i][j] = 0;
		}
	}

	for(i = 0; i < num; i++) {
		while(getchar() != '\n');
		scanf("%c %d", &name, &x);
		if(name == 'S') card[0][x - 1] = 1;
		else if(name == 'H') card[1][x - 1] = 1;
		else if(name == 'C') card[2][x - 1] = 1;
		else if(name == 'D') card[3][x - 1] = 1;
	}

	for(i = 0; i < 4 ;i++) {
		for(j = 0; j < 13; j++) {
			if(card[i][j] == 1) continue;
			else if(i == 0) printf("S %d\n", j + 1);
			else if(i == 1) printf("H %d\n", j + 1);
			else if(i == 2) printf("C %d\n", j + 1);
			else if(i == 3) printf("D %d\n", j + 1);
		}
	}

	return 0;
}


Measured memory_bytes: 2060
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    S = "00" + S;
    int N = S.length();
    int ans = 0;
    for(int i = N - 1; i >= 0; i--) {
        if(S[i] > '9') {
            S[i - 1]++;
            S[i] -= 10;
        }
        if(S[i] <= '4' || (S[i] == '5' && S[i - 1] < '5')) {
            ans += S[i] - '0';
        } else {
            ans += 10 - (S[i] - '0');
            S[i - 1]++;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 5308
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector> 
using namespace std;

long long cnt;
int l;
int A[1000000];
int n;
vector<int> G;

 void insertionSort(int A[], int n, int g)
{
	for(int i=0;i<n;i++)
	{
		int v=A[i];
		int j=i-g;
		while(j>=0&&A[j]>v)
		{
			A[j+g]=A[j];
			j-=g;
			cnt++;
		}
		A[j+g]=v;
	}
}

void shellSort(int A[], int n)
{
	for(int h=1; ; )
	{
		if(h>n) break;
		G.push_back(h);
		h=h*3+1;
	}
	for(int i=G.size()-1; i>=0; i--)
		insertionSort(A,n,G[i]);
}

int main()
{
	cin>>n;
	for(int i=0; i<n; i++)
	scanf("%d", &A[i]);
	cnt=0;
	shellSort(A,n);
	cout<< G.size()<<endl;
	for(int i= G.size()-1;i>=0;i--)
	{
		printf("%d",G[i]);
		if(i)printf(" ");
	}
	printf("\n");
	printf("%d\n",cnt);
	for(int i=0;i<n;i++)
	printf("%d\n",A[i]);
	return 0;
	}



Measured memory_bytes: 7164
n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))
b = 10 ** 5
c = 0
for i in range(len(h)):
    if abs((t - h[i] * 0.006) - a) < b:
        b = abs((t - h[i] * 0.006) - a)
        c = i
print(c + 1)

Measured memory_bytes: 9272
#include <iostream>
#include <string.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
using namespace std;
int main(void){
    int N; cin>>N;
    long A[N]; long B[N];
    for(int i=0;i<N;i++){
        cin>>A[i];
        B[i]=A[i]-(i+1);
    }
    sort(B,B+N);
    if((N-1)%2==0){
        long b=B[(N-1)/2];
        long ans=0;
        for(int i=0;i<N;i++){
           ans+=abs(b-B[i]);
        }
        cout<<ans;
    }
    else {
        long b1=B[(N-1)/2];
        long b2=B[(N-1)/2+1];
        long ans1=0;
        long ans2=0;
        for(int i=0;i<N;i++){
            ans1+=abs(b1-B[i]);
            ans2+=abs(b2-B[i]);
        }
        if(ans1>ans2){cout<<ans1;}
        else {cout<<ans2;}
    }
    return 0;
}


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

using namespace std;

string s, t;
int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  bool tst;
  cin >> s >> t;
  if(s.size() != t.size()){
    cout << "No\n";
    return 0;
  }
  for(int i = 0; i < s.size(); ++i){
    tst = 1;
    for(int j = 0; j < s.size(); ++j)
      tst &= (s[(i + j)%s.size()] == t[j]);
    if(tst){
      cout << "Yes\n";
      return 0;
    }
  }
  cout << "No\n";

  return 0;
}


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

using namespace std;
 
#define MD 1000000007
typedef long long int ll;

int main(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    int left=0,right=0;
    for(int i=1;i<n;i++){
        if(s[i]=='E'){
            right++;
        }
    }
    int mi=right;
    for(int i=1;i<n;i++){
        if(s[i-1]=='W'){
            left+=1;
        }
        if(s[i]=='E'){
            right-=1;
        }
        mi=min(mi,left+right);
    }
    cout<<mi<<endl;
    return 0;
}

Measured memory_bytes: 900
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int H = sc.nextInt();
    int W = sc.nextInt();
    int N = sc.nextInt();
    
    int M = Math.max(H,W);
    System.out.println((N+M-1)/M);
  }
}

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

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

typedef long long LL;
typedef unsigned long UL;

using namespace std;

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

    int n, lt;
    cin >> n >> lt;
    vector<pair<int, int>> c(n);
    REP(i, n) cin >> c[i].first >> c[i].second;

    sort(c.begin(), c.end(), [](const pair<int, int>& first, const pair<int, int> second) {return second.first > first.first; });

    REP(i, n)
    {
        if (c[i].second <= lt)
        {
            cout << c[i].first << endl;
            return 0;
        }
    }

    cout << "TLE" << endl;

    return 0;
}

Measured memory_bytes: 256
row = list(map(int, input().split()))
s = [input().split() for i in range(row[0])]
for i in range(row[0]):
    s[i] = list(s[i][0])
dx = [0, -1, 1, 0]
dy = [-1, 0, 0, 1]
Flag = True
for i in range(row[0]):
    for j in range(row[1]):
        if s[i][j] == "#":
            flag = False
            for d in range(4):
                nx = i + dx[d]
                ny = j + dy[d]
                if 0 <= nx < row[0] and 0<= ny < row[1]:
                    if s[nx][ny] == "#":
                        flag = True
                        break
            if flag == False:
                Flag = False
                break
    if Flag == False:
        print("No")
        break
if Flag:
    print("Yes")

Measured memory_bytes: 3064
class Combination:
    def __init__(self, n_max, mod=10**9+7):
        self.mod = mod
        self.modinv = self.make_modinv_list(n_max)
        self.fac, self.facinv = self.make_factorial_list(n_max)

    def __call__(self, n, r):
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def make_factorial_list(self, n):
        # 階乗のリストと階乗のmod逆元のリストを返す O(n)
        # self.make_modinv_list()が先に実行されている必要がある
        fac = [1]
        facinv = [1]
        for i in range(1, n+1):
            fac.append(fac[i-1] * i % self.mod)
            facinv.append(facinv[i-1] * self.modinv[i] % self.mod)
        return fac, facinv

    def make_modinv_list(self, n):
        # 0からnまでのmod逆元のリストを返す O(n)
        modinv = [0] * (n+1)
        modinv[1] = 1
        for i in range(2, n+1):
            modinv[i] = self.mod - self.mod//i * modinv[self.mod%i] % self.mod
        return modinv

def main():
    x,y = map(int,input().split())
    comb = Combination(10**6)

    if (x+y)%3==0:
        n_max = x//2
        ans = 0
        for i in range(n_max+1):
            if y == 2*x-3*i:
                ans = (ans+comb(x-i,i))%(10**9+7)
        print(ans)
    else:
        print(int(0))
if __name__=='__main__':
    main()

Measured memory_bytes: 126280