akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
int a[50];
int k;
int main()
{
   cin>>n;
   if(n==0)
   {
       cout<<n<<endl;
       return 0;
   }
   while(n)
   {
      if(n%2)
      {
          a[k++]=1;
          n=(n-1)/(-2);
      }
      else
      {
          a[k++]=0;
          n=n/(-2);
      }
   }
   for(int i=k-1;i>=0;i--)
    cout<<a[i];
   cout<<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <vector>
#include <stack>
#include <set>
#define  STATE  30
using namespace std;
int dp[STATE][STATE][STATE][STATE];
vector <int> A, B, Y, Z, X;
stack <int> stk;
int n, m, r, state;
inline void init (void)
{
    Y.clear();
    Z.clear();
    X.clear();      
    A.resize(n);
    B.resize(m);
    for (int i=0;i<n;++i) cin>>A[i];
    for (int i=0;i<m;++i) cin>>B[i];
    state = STATE;
}
inline void toChomskyForm (int y)
{
    for (;;)
    {
        Z.push_back(stk.top()); stk.pop();
        Y.push_back(stk.top()); stk.pop();      
        if (stk.empty())
        {
           X.push_back(y);
           return ;
        }
        else
        {
            X.push_back(++state);     
            stk.push(state); 
        }
    }          
}
inline void makeGrammar (void)
{
    int k, y, tmp;
    for (int i=0;i<r;++i)          
    {
        cin>>k;    
        for (int j=0;j<k;++j)
        {
            cin>>tmp;    
            stk.push(tmp);
        }
        cin>>y;
        toChomskyForm (y);
    }   
}
inline vector < vector < set<int> > > CYK ( const vector <int> &A )
{
    int n = A.size();          
    vector < vector< set<int> > > dp(n,vector< set<int> >(n+1));
    for (int i=0;i<n;++i) dp[i][1].insert(A[i]);
    
    for (int len=2;len<=n;++len)
    for (int i=0;i<n;++i)
    for (int j=0;j<X.size();++j)
    for (int k=1;k<len;++k)
    {
        int ii = (i+k)%n;    
        if (dp[i][k].count(Y[j])&&dp[ii][len-k].count(Z[j])) 
           dp[i][len].insert(X[j]);
    }      
    return dp;   
}
inline vector < vector<int> > makeBitset ( const vector < vector < set<int> > > &A )
{
    int n = A.size();
    vector < vector<int> > ans(n,vector<int>(n+1,0));
    for (int i=0;i<n;++i)
    for (int w=0;w<=n;++w)
    for (int k=0;k<=STATE;++k)
        if (A[i][w].count(k)) ans[i][w] |= 1<<k;
    return ans;
}

inline void solve (void)
{
    vector < vector<int> > ai = makeBitset( CYK(A) );
    vector < vector<int> > bi = makeBitset( CYK(B) );
    memset (dp,-1,sizeof(dp));
    for (int i=0;i<n;++i)
    for (int j=0;j<m;++j) dp[i][0][j][0] = 0;
    
    for (int nn=0;nn<n;++nn)
    for (int mm=0;mm<m;++mm)
    for (int i=0;i<n;++i)
    for (int j=0;j<m;++j)
    {
        if (dp[i][nn][j][mm] == -1) continue;    
        for (int p=nn+1;p<=n;++p)
        for (int q=mm+1;q<=m;++q)
        {
            int ii = (i+nn)%n;
            int jj = (j+mm)%m;
            if (ai[ii][p-nn] & bi[jj][q-mm])
               dp[i][p][j][q] = max(dp[i][p][j][q],dp[i][nn][j][mm]+1);
        }
    }
    int ans = -1;
    for (int i=0;i<n;++i)
    for (int j=0;j<m;++j) ans = max(ans,dp[i][n][j][m]);   
    cout<<ans<<endl;
}
int main(void)
{
    ios_base :: sync_with_stdio(0);
    //cin.open("PF.cin.txt",ios::in);
    //out.open("PF.out.txt",ios::out);
    while (cin>>n>>m>>r && n && m)
    {
          init ();
          makeGrammar ();
          solve ();
    }
    return 0;    
}

Measured memory_bytes: 4592
import scala.io.StdIn.readInt

object Main extends App {
  val n = readInt
  var minv = readInt
  var maxv = Int.MinValue

  for(i<-1 until n) {
    val m = readInt
    if(m-minv > maxv)
      maxv = m-minv
    if(minv > m)
      minv = m
  }
  println(maxv)
}

Measured memory_bytes: 64132
#include<bits/stdc++.h>
#define int long long
#define lld long long double
#define pb push_back
#define mp make_pair
#define M 1000000007
using namespace std;

int f(int a[], int n) {
	int dp[n];
	dp[0] = 0;
	dp[1] = abs(a[1] - a[0]);
	for (int i = 2; i < n; i++) {
		dp[i] = min( dp[i - 2] + abs(a[i] - a[i - 2]), dp[i - 1] + abs(a[i] - a[i - 1]));
	}
	return dp[n - 1];
}

void solve() {
	int i, j, k, n, m, ans = 0, cnt = 0, sum = 0;
	cin >> n;
	int a[n];
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
	}
	cout << f(a, n);
}

int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif
	//int t; cin >> t; while (t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 5168
#include<iostream>
using namespace std;
int N;
main()
{
	while(cin>>N,N)
	{
		int pre=0,ans=0;
		int x=0,y=0;
		for(int i=0;i<N;i++)
		{
			string s;cin>>s;
			if(s=="lu")
			{
				x=1;
			}
			else if(s=="ru")
			{
				y=1;
			}
			else if(s=="ld")
			{
				x=0;
			}
			else
			{
				y=0;
			}
			if(x==1&&y==1)
			{
				if(pre==0)ans++;
				pre=1;
			}
			else if(x==0&&y==0)
			{
				if(pre==1)ans++;
				pre=0;
			}
		}
		cout<<ans<<endl;
	}
}



Measured memory_bytes: 3168
import heapq

N,K=map(int,input().split())
A=list(map(int,input().split()))
l=[0]*max(A)
ans=0
for item in A:
    l[item-1]+=1
    
heapq.heapify(l)

while len(l)>K:
    ans+=heapq.heappop(l)
    
print(ans)

Measured memory_bytes: 24964
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;
import java.util.Stack;

class Task {
    List<Integer> list;
    Deque<Integer> process;

    Task(List<Integer> list, Deque<Integer> process) {
        this.list = list;
        this.process = process;
    }
}

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
 
        int n = sc.nextInt();
        List<Integer> b = new LinkedList<>();
        for(int i = 0; i < n; i++) {
            b.add(sc.nextInt());
        }

        Deque<Integer> ans = null;
        Stack<Task> stack = new Stack<>();
        stack.add(new Task(b, new ArrayDeque<Integer>()));
        loop : while(!stack.isEmpty()) {
            Task task = stack.pop();
            List<Integer> tmp = task.list;
            Deque<Integer> tmpprocess = task.process;

            if(tmp.size() == 0) {
                ans = tmpprocess;
                break;
            }

            for(int i = 0; i < tmp.size(); i++) {
                if(tmp.get(i) == i + 1) {
                    List<Integer> list = new LinkedList<>();
                    for(int j = 0; j < tmp.size(); j++) {
                        int x = tmp.get(j);
                        if(x > j + 1) continue loop;
                        list.add(x);
                    }
                    list.remove(i);
                    Deque<Integer> process = new ArrayDeque<>();
                    for(int x : tmpprocess) {
                        process.addLast(x);
                    }
                    process.addFirst(i + 1);
                    stack.add(new Task(list, process));
                }
            }
        }

        if(ans == null) {
            System.out.println(-1);
        }else {
            for(int x : ans) {
                System.out.println(x);
            }
        }
 
        sc.close();
    }
}

Measured memory_bytes: 24788
def main():
    import sys
    input = sys.stdin.readline
    s = input().strip()
    N = len(s)
    l = -1
    r = N
    if len(set(s)) == 1:
        print(0)
        exit()
    while l < r:
        l += 1
        r -= 1
        while s[l] == 'x':
            l += 1
        while s[r] == 'x':
            r -= 1
        if s[l] != s[r]:
            print(-1)
            exit()
    
    ans = 0
    while l != -1 or r != N:
        if l == -1:
            ans += N - r
            break
        if r == N:
            ans += l + 1
            break
        if s[l] == s[r]:
            l -= 1
            r += 1
            continue
        elif s[l] == 'x':
            ans += 1
            l -= 1
        elif s[r] == 'x':
            ans += 1
            r += 1
        
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1e9;
const LL LLINF = 1e16;

int main(){
    int n;
    cin >> n;
    vector<pair<LL, LL>> c(n);
    rep(i, n){
        LL x, y;
        cin >> x >> y;
        c[i] = make_pair(x, y);
    }
    multiset<pair<LL, LL>> m;
    rep(i, n){
        REP(j, 0, n){
            if(i != j) m.insert(make_pair(c[i].first-c[j].first, c[i].second-c[j].second));
        }
    }
    int tmp = 1;
    int ans = 0;
    pair<LL, LL> x = make_pair(LLINF, LLINF);
    repe(i, m){
        // cout << i.first << " " << i.second << endl;
        // cout << x.first << " " << x.second << endl;
        if(i == x) tmp++;
        else{
            chmax(ans, tmp);
            x = i;
            tmp = 1;
        }
    }
    if(n > 1) chmax(ans, tmp);

    cout << n-ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define tll tuple<ll, ll, ll>
#define all(c) c.begin(),c.end()
 
const ll inf = 1000000001;
const ll INF = 1e18;
const ll MOD = 1000000007;

vector<ll> g[202020];
ll score[202020];

void dfs(int node, ll prev){
  score[node] += score[prev];
  for (int i=0;i<g[node].size();i++){
    if (g[node][i] == prev) continue;
    dfs(g[node][i], node);
  }
}

int main(){
  fill(score, score+202020, 0);
  ll n, q;
  cin >> n >> q;
  for(int i=0;i<n-1;i++){
    int a, b;
    cin >> a >> b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  
  for(int i=0;i<q;i++){
    int p;
    ll x;
    cin >> p >> x;
    score[p] += x;
  }
  
  dfs(1,0);
  
  for (int i=1;i<=n;i++) cout << score[i] << " ";
  cout << endl;
  //cout << ans << endl;
}

Measured memory_bytes: 24320
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int main() {
  int a,b;
  cin>>a>>b;
  int s=b-a;
  s--;
  int r=s*(s+1)/2;
  cout<<r-a<<endl;
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
#define all(x) begin(x),end(x)
#define rall(x) (x).rbegin(),(x).rend()
#define REP(i,b,n) for(int i=(int)(b);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define repsz(i,v) rep(i,(v).size())
#define aur auto&
#define bit(n) (1LL<<(n))
#define eb emplace_back
#define mt make_tuple
#define fst first
#define snd second
using namespace std;
typedef long long ll;
//#define int long long
template<class C>int size(const C &c){ return c.size(); }
template<class T,class ...U>bool chmin(T&a, const U&...bs){const T b(bs...);if(a<=b)return false;a=b;return true;}
template<class T,class ...U>bool chmax(T&a, const U&...bs){const T b(bs...);if(a>=b)return false;a=b;return true;}

bool solve(){
    int n; cin >> n;
    int a, b; cin >> a >> b;
    cout << min(a, b) << ' ' << max(0, a + b - n) << endl;
    return true;
}
signed main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << std::fixed << std::setprecision(10);
    solve();
    return 0;
}
// vim:set foldmethod=marker commentstring=//%s:


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

int main(){
    int T,H,M,S;
    cin >>T;
    H= T/3600;
    M= (T/60)%60;
    S= T % 60;
    
    cout<<H<<":"<<M<<":"<<S<<endl;
    
    return 0;
    

}


Measured memory_bytes: 3116
/* Author rumoisen */
/* created 2018/10/18 */

#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#include <numeric>
#include <iostream>

using namespace std;
 
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7
#define pb push_back

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

void no(){cout<<"No"<<endl;exit(0);}
void yes(){cout<<"Yes"<<endl;exit(0);}
void No(){cout<<"NO"<<endl;exit(0);}
void Yes(){cout<<"YES"<<endl;exit(0);}

using namespace std;

int main(void)
{
    int n;
    cin>>n;
    vector<int> x(n),y(n),h(n);
    REP(i,n) cin>>x[i]>>y[i]>>h[i];
    int MAX=100;
    for(int posy=0;posy<=MAX;posy++){
        for(int posx=0;posx<=MAX;posx++){
            int needh=-1;
            for(int i=0;i<n;i++){
                if(h[i]>0){
                    int tmp=h[i]+abs(posx-x[i])+abs(posy-y[i]);
                    if(needh==-1){
                        needh=tmp;
                    }
                    else{
                        if(needh!=tmp){
                            needh=-2;
                            break;
                        }
                    }
                }
            }
            if(needh==-2) continue;
            for(int i=0;i<n;i++){
                if(h[i]==0){
                    int yj=abs(posx-x[i])+abs(posy-y[i]);
                    if(needh>yj){
                        needh=-2;
                        break;
                    }
                }
            }
            if(needh==-2) continue;
            cout<<posx<<" "<<posy<<" "<<needh<<endl;
            return 0;
        }
    }
}

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

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

using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset

typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;

#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'

char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 122)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 122)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 122)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
bool isect (int l1, int r1, int l2, int r2){
    pii p1,p2;
    p1 = mp(l1,r1); p2 = mp(l2,r2);
    if(p1>p2)swap(p1,p2);
    if(p2.fi <= p1.se)return true;
    else return false;
}
ll fexp (ll num1, ll num2, ll MOD){
    if(num2==0)return 1;
    else if(num2==1)return num1;
    else{
        ll temp = fexp (num1,num2/2,MOD); ll res = ((temp%MOD) * (temp%MOD))%MOD;
        if(num2%2==1) res = ((res%MOD)*(num1%MOD))%MOD; return res;
    }
}
ll invmod (ll num, ll MOD){return fexp (num,MOD-2,MOD);}
ll gcd (ll num1, ll num2){
    if(num1 < num2) swap(num1,num2); ll num3 = num1 % num2 ;
    while(num3 > 0){ num1 = num2; num2 = num3; num3 = num1 % num2;}
    return num2;
}
ll lcm (ll num1 , ll num2){return (ll) (num1/gcd(num1,num2))*num2;}
// end of Template
int n;
double ans;
int main(){

//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n;
    for(int i=1;i<=n;i++)
        if(i%2)ans++;
    cout<<fixed<<setprecision(8)<<ans/n<<newl;
}


Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <string>
#include <vector>
using namespace std;
int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	set<string> s;
	vector<string> Ans;
	int n; string m, str; cin >> n;
	for (int i = 0; i < n;i++) {
		cin >> m >> str;
		if (m == "find") { if (s.find(str) != s.end()) { Ans.push_back("yes"); } else { Ans.push_back("no"); } }
		else { s.insert(str); }
	}
	for (int i = 0; i < Ans.size(); i++) {
		cout << Ans[i] << endl;
	}
}

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

int main() {
    int N ;
    string S;
    cin >> N;
    
    for(int i = 0; i < N; i++){
        cin >> S;
        if (S == "Y") {
            cout << "Four" << endl;
            break;
        }
        if (i == N - 1) {
            cout << "Three" << endl;
        }
    }   
}

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

int main() {
 int x,y;
 cin >> x >> y;
 if(y%2==0&&y/2>=x&&y<=4*x) cout << "Yes" << endl;
 else cout << "No" << endl;
}

Measured memory_bytes: 3592
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct pole{
	struct pole* next;
	int y;
} Pole;

Pole* table[5001];

int search(int x,int y)
{
	if(x < 0 || y < 0 || x > 5000 || y > 5000)return 0;
	if(table[x] != NULL)
	{
		Pole* pt = table[x];
		while(pt->next != NULL)
		{
			if(pt->y == y)
				return 1;
			pt = pt->next;
		}
		if(pt->y == y)
			return 1;
	}
	return 0;
}

void delete(int x,int y)
{
	Pole* pt = table[x];
	if(pt->y == y)
	{
		table[x] = pt->next;
		return;
	}
	while(1)
	{
		if(pt->next->y == y)
		{
			pt->next = pt->next->next;
			return;
		}
		pt = pt->next;
	}
}

int main()
{
	int** poleList;
	int n;
	int i,j,k,l,m,o;
	while(scanf("%d",&n),n)
	{
		for(i = 0;i <= 5000;i++)
		{
			table[i] = NULL;
		}
		poleList = (int**)malloc(sizeof(int*)*n);
		for(i = 0;i < n;i++)
		{
			int x,y;
			scanf("%d %d",&x,&y);
			poleList[i] = (int*)malloc(sizeof(int)*2);
			poleList[i][0] = x;
			poleList[i][1] = y;
			if(table[x] == NULL)
			{
				table[x] = (Pole*)malloc(sizeof(Pole));
				table[x]->next = NULL;
				table[x]->y = y;
			}
			else
			{
				Pole* tmp = table[x];
				table[x] = (Pole*)malloc(sizeof(Pole));
				table[x]->next = tmp;
				table[x]->y = y;
			}
		}
		int maxsq = 0;
		for(i = 0;i < n;i++)
		{
			for(j = (i+1);j < n;j++)
			{
				double posx[6] = {
					poleList[i][0]+poleList[i][1]-poleList[j][1],
					poleList[j][0]+poleList[i][1]-poleList[j][1],
					poleList[i][0]-poleList[i][1]+poleList[j][1],
					poleList[j][0]-poleList[i][1]+poleList[j][1],
					(poleList[i][0]+poleList[j][0]+poleList[i][1]-poleList[j][1])/2,
					(poleList[i][0]+poleList[j][0]-poleList[i][1]+poleList[j][1])/2
				};
				double posy[6] = {
					poleList[i][1]-poleList[i][0]+poleList[j][0],
					poleList[j][1]-poleList[i][0]+poleList[j][0],
					poleList[i][1]+poleList[i][0]-poleList[j][0],
					poleList[j][1]+poleList[i][0]-poleList[j][0],
					(poleList[i][1]+poleList[j][1]-poleList[i][0]+poleList[j][0])/2,
					(poleList[i][1]+poleList[j][1]+poleList[i][0]-poleList[j][0])/2
				};
				int sq = (poleList[i][0]-poleList[j][0])*(poleList[i][0]-poleList[j][0])
					+(poleList[i][1]-poleList[j][1])*(poleList[i][1]-poleList[j][1]);
				if(search(posx[0],posy[0]) && search(posx[1],posy[1]) || search(posx[2],posy[2]) && search(posx[3],posy[3]))
				{
					if(sq < maxsq)continue;
					else maxsq = sq;
				}
				else if(search(posx[4],posy[4]) && search(posx[5],posy[5]))
				{
					if(sq < maxsq*2)continue;
					else maxsq = sq/2;
				}
			}
			delete(poleList[i][0],poleList[i][1]);
		}
		printf("%d\n",maxsq);
	}
	return 0;
}

Measured memory_bytes: 0
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    h,w = map(int, input().split())
    alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' #26
    l = [list(input().rstrip().split()) for _ in range(h)]
    for i in range(h):
        for j in range(w):
            if l[i][j] == 'snuke':
                print('{}{}'.format(alphabet[j], i+1))

if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
import java.util.*;
public class Main{
  public static void main(String[] args){
    long count = 0l;
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int d = sc.nextInt();
    double x[][] = new double[n][d];
    for(int i = 0;i<n;i++){
      for(int j = 0;j<d;j++){
        x[i][j] = sc.nextDouble();
      }
    }
    for(int i = 0;i<n-1;i++){
      for(int j = i+1;j<n;j++){
        double nijou = 0;
        for(int k = 0;k<d;k++){
          nijou += (x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
        }
        double ruuto = Math.sqrt(nijou);
        if(seisuu(ruuto))count++;
      }
    }
    System.out.println(count);
  }

  public static boolean seisuu(double x){
    double check = x - (double)(int)x;
    boolean a = false;
    if(check == 0.0)a=true;
    return a;
  }
}


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

using namespace std;

using ll = long long;
constexpr ll MOD = 1e9 + 7;
constexpr ll INF = 1e18;

int main() {
    ll n, m, i, j, k;
    cin >> n;
    ll Q;
    cin >> Q;
    vector<vector<ll>> G(n);
    for(i = 0; i < n - 1; i++) {
        ll a, b;
        cin >> a >> b;
        --a, --b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    ll cnt[n] = {};
    for(i = 0; i < Q; i++) {
        ll p, x;
        cin >> p >> x;
        cnt[p - 1] += x;
    }

    function<void(ll,ll)> dfs = [&](ll now,ll par) {
        //cout << now << endl;
        for(ll x = 0; x < G[now].size(); x++) {
            if(G[now][x] != par) {
                cnt[G[now][x]] += cnt[now];
                dfs(G[now][x],now);
            }
        }
    };
    dfs(0ll,-1);
    ll ret = 0;
    for(i = 0; i < n; i++) {
        cout << cnt[i] << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 27392
#include <bits/stdc++.h>
using namespace std;
#define REP(i, init, n) for(int i = (int)(init); i < (int)(n); i++)

#define vi vector<int>
#define vl vector<long>
#define vvi vector<vector<int>>
#define vvl vector<vector<long>>
#define pint pair<int, int>
#define plong pair<long, long>

int main() {
    int M; 
    cin>>M;
    vector<plong> N;
    long sum_d = 0;
    long keta = 0;
    REP(i, 0, M){
        long d, c;
        cin >> d >> c;
        sum_d += d*c;
        keta += c;
    }
    cout << (sum_d-1) / 9 + keta - 1 << endl;
}

Measured memory_bytes: 256
using System;

namespace ConsoleApp8
{
    class Program
    {
        static void Main(string[] args)
        {
            long[]  xkd = Array.ConvertAll(System.Console.ReadLine().Split(' '),long.Parse);
            if(xkd[0]<0)
            {
                xkd[0]= -xkd[0];
            }
            long kai = xkd[0] / xkd[2];
            long kotae = 0;
            kotae = xkd[0] - kai * xkd[2];
            if (kai<=xkd[1])
            {
                long zansu = xkd[1] - kai;
                if( zansu%2 ==1)
                {
                    long kai1 =Math.Abs( kotae + xkd[2]);
                    long kai2 =Math.Abs( kotae - xkd[2]);
                    if (kai1 > kai2)
                    {
                        kotae = kai2;
                    }
                    else
                    {
                        kotae = kai1;
                    }
                }
                else
                {
                    long kai1 = Math.Abs(kotae);
                    long kai2 = Math.Abs(kotae - 2*xkd[2]);
                    if (kai1 > kai2)
                    {
                        kotae = kai2;
                    }
                    else
                    {
                        kotae = kai1;
                    }

                }

            }
            else
            {
                kotae = xkd[0] - xkd[1] * xkd[2];
            }
            Console.WriteLine(kotae);
        }
    }
}


Measured memory_bytes: 27512
import math
a,b,C = map(float,input().split())
S = 1/2*a*b*math.sin(C*math.pi/180)
c = math.sqrt(a**2+b**2-2*a*b*math.cos(C*math.pi/180))
L = a+b+c
h = 2*S/a
print(format(S,'.8f'))
print(format(L,'.8f'))
print(format(h,'.8f'))


Measured memory_bytes: 5700
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll mod=1000000007;
ll ans=1,n,x,y,z,S,C;
ll dp[41][1<<17];
int main()
{
	cin>>n>>x>>y>>z;
	for (int i=1;i<=n;i++) ans=(ll)(ans*10)%mod;
	C=(1<<z-1)|(1<<y+z-1)|(1<<x+y+z-1);
	S=(1<<x+y+z)-1;
	memset(dp,0,sizeof(dp));
	dp[0][0]=1;
	for (int i=1;i<=n;i++)
	  for (int s=0;s<=S;s++)
	  {
	  	if (dp[i-1][s]==0) continue;
		for (int j=1;j<=10;j++)
		{	
			int st=(s<<j)|(1<<j-1);
			st&=S;
			if ((st&C)!=C) 
				dp[i][st]=(dp[i][st]+dp[i-1][s])%mod;
		}
	  }
	for (int i=0;i<=S;i++) ans=(ans-dp[n][i]+mod)%mod;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 42240
using System;
using System.Collections.Generic;
class Solve{
    int N;
    int[] a;
    public Solve(){}
    public static int Main(){
        new Solve().Calc();
        return 0;
    }
    void Calc(){
        getinput();
        int[] b = new int[N];
        int[] c = new int[N];
        long count = 0;
        Stack s = new Stack(N);
        for(int i=0;i<N;i++){
            int j;
            while(true){
                j = s.pop();
                if(j == -1){
                    break;
                }
                else if(a[j] < a[i]){
                    s.push(j);
                    break;
                }
                else{
                    b[j] = i;
                }
            }
            s.push(i);
        }
        while(true){
            int j = s.pop();
            if(j == -1){
                break;
            }
            else{
                b[j] = N;
            }
        }
        for(int i=N-1;i>=0;i--){
            int j;
            while(true){
                j = s.pop();
                if(j == -1){
                    break;
                }
                else if(a[j] < a[i]){
                    s.push(j);
                    break;
                }
                else{
                    c[j] = i;
                }
            }
            s.push(i);
        }
        while(true){
            int j = s.pop();
            if(j == -1){
                break;
            }
            else{
                c[j] = -1;
            }
        }
        for(int i=0;i<N;i++){
            count += (long)(b[i]-i)*(long)(i-c[i])*(long)a[i];
        }
        Console.WriteLine(count);
    }
    void getinput(){
        N = int.Parse(Console.ReadLine());
        string[] str = Console.ReadLine().Split(' ');
        a = new int[N];
        for(int i=0;i<N;i++){
            a[i] = int.Parse(str[i]);
        }
    }    
}
class Stack{
    int[] array;
    int pointer;
    public Stack(){
        array = new int[100000];
        pointer = -1;
    }
    public Stack(int i){
        array = new int[i];
        pointer = -1;
    }
    public int pop(){
	    if(pointer == -1){
            return -1;
        }
        else{
            pointer--;
            return array[pointer+1];
        }
    }
    public void push(int t){
        array[pointer+1] = t;
        pointer++; 
    }
}

Measured memory_bytes: 19032
#include<cstdio>
#include<algorithm>
using namespace std;
long long Get(long long n, long long m) {
	long long res = min(n, m);
	if (n % 3 == 0 || m % 3 == 0)res = 0;
	for (int i = 1; i < n; i++) {
		long long t1 = i * m, t2 = (n - i)*(m / 2), t3 = (n - i)*((m + 1) / 2);
		res = min(res, max(max(t1, t2), t3) - min(min(t1, t2), t3));
	}
	return res;
}
int main() {
	long long n, m;
	int i;
	scanf("%lld%lld", &n, &m);
	printf("%lld\n", min(Get(n, m), Get(m, n)));
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
using namespace std;
int main(void){
    string W, H;
    int c = 0;
    cin >> W;
    while(cin >> H){
        for(int j = 0; j < H.size(); j++){
            if(isupper(H[j])) H[j] = tolower(H[j]);
        }
        if(H == W) c++;
        if(H == "END_OF_TEXT") break;
    }
    cout << c << endl;
    return 0;
}


Measured memory_bytes: 3148
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>

static void
array_print(uint32_t *array, unsigned int size)
{
    int i = 0;

    for(i = 0; i < size; i++){
        printf("%d ", array[i] );
    }
    putchar('\n');
}

void merge_sort (uint32_t array[], int left, int right) {
  int i, j, k, mid;
  int work[101]={0};  // 作業用配列

  if (left < right) {
    mid = (left + right)/2; // 真ん中
    merge_sort(array, left, mid);  // 左を整列
    merge_sort(array, mid+1, right);  // 右を整列
    for (i = mid; i >= left; i--) { work[i] = array[i]; } // 左半分
    for (j = mid+1; j <= right; j++) {
      work[right-(j-(mid+1))] = array[j]; // 右半分を逆順
    }
    i = left; j = right;
    for (k = left; k <= right; k++) {
      if (work[i] < work[j]) { array[k] = work[i++]; }
      else                   { array[k] = work[j--]; }
    }
  }
}

float kaizyou(int n){
    int i;
    float ans=1;

    if( n  <= 0)return 1;
    for(i=0;i<n;i++) ans *= 2;
    return ans;
}

int main(int argc, char const *argv[]) {
  uint32_t value[50]={0},n,i,j,flag=0;
  double max=0,sum=0;

  scanf("%d",&n );
  for(i=0;i<n;i++){
    scanf("%d",&value[i] );
    if(max < value[i])max = value[i];
  }

  //array_print(value, n);

  merge_sort(value, 0, n-1);

  //array_print(value,n);

  for(i=0;i < n;i++){
    sum += kaizyou((i+1) - 2) * value[i];
  }

  printf("%f\n", sum / kaizyou(n-1));

  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <string>
#include <cstring>
#include <functional>

using namespace std;

// const int maxn = ;

int n, m;

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	cin >> n >> m;
	vector<pair<int, int> > d(n);
	for (int i = 0; i < n; ++i)
		cin >> d[i].first >> d[i].second;

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

	long long ans = 0;
	for (int i = 0; m > 0 && i < n; ++i) {
		int cur = min(m, d[i].second);
		ans += (long long)d[i].first * cur;
		m -= cur;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<algorithm>
using namespace std;
inline char gc(){
    static char now[1<<16],*S,*T;
    if (T==S){T=(S=now)+fread(now,1,1<<16,stdin);if (T==S) return EOF;}
    return *S++;
}
inline int read(){
    int x=0;char ch=gc();
    while(ch<'0'||ch>'9') ch=gc();
    while(ch<='9'&&ch>='0') x=x*10+ch-'0',ch=gc();
    return x;
}
int n,cnt[110000];
int main(){
    //freopen("arc.in","r",stdin);
    n=read();int max1=0,x=0;for (int i=1;i<=n;++i) x=read(),max1=max(max1,x),cnt[x]++;int kind=0,sum=0;
    for (int i=1;i<=max1;++i) if (cnt[i]) sum+=cnt[i]-1,kind++;
    if (sum%2) kind--; printf("%d",kind);
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <numeric>
#include <cmath>
#include <iomanip> //cout << fixed << setprecision(15) << << endl;
#include <cassert>
//#include "atcoder/all"

using namespace std;
//using namespace atcoder;

#define ll long long int
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define P pair<int,int>

int mx8[] = {0,0,1,-1,-1,1,-1,1};
int my8[] = {-1,1,0,0,-1,-1,1,1};
int mx4[] = {1,-1,0,0};
int my4[] = {0,0,-1,1};
const int MOD = 1000000007;


int main(){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    
    vector<int> b(1000003);
    rep(i,n){
        if(b[a[i]] <= 1){
            for(int j = 1; j <= 1000003/a[i]; j++){
                b[a[i]*j]++;
            }
        }
    }
    int cnt = 0;
    rep(i,n){
        if(b[a[i]] == 1) {
            cnt++;
        }
    }
    cout << cnt << endl;
}



Measured memory_bytes: 7928
def check(s: str):
  if len(s) >= 5 and s[-5:] in ['dream', 'erase']:
    return s[:-5]
  elif len(s) >= 6 and s[-6:] in ['eraser']:
    return s[:-6]
  elif len(s) >= 7 and s[-7:] in ['dreamer']:
    return s[:-7]
  return None

s = input()
matched = True
while len(s) > 0:
  s = check(s)
  if s is None:
    matched = False
    break
if matched:
  print('YES')
else:
  print('NO')

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a[6];
  for(int i=1;i<6;i++)
  {
    cin>>a[i];
    if(a[i]==0)
    {
      cout<<i<<endl;
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 3552
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
//const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) {cout << (A) << '\n'; exit(0);}

int main()
{
  ll N;
  cin >> N;
  vector<ll> X(1010, 0);
  for (ll i = 0; i < N; i++)
  {
    ll L;
    cin >> L;
    X.at(L)++;
  }

  ll ans = 0;
  for (ll a = 1; a <= 1000; a++)
  {
    if (X.at(a) == 0)
      continue;
    
    for (ll b = a; b <= 1000; b++)
    {
      if (X.at(b) == 0)
        continue;
      
      for (ll c = b; c <= 1000; c++)
      {
        if (X.at(c) == 0)
          continue;
        if (c >= a + b)
          break;

        if (a == b && b == c)
          ans += X.at(a) * (X.at(b) - 1) * (X.at(c) - 2) / 6;
        else if (a == b)
          ans += X.at(a) * (X.at(b) - 1) * X.at(c) / 2;
        else if (b == c)
          ans += X.at(a) * X.at(b) * (X.at(c) - 1) / 2;
        else
          ans += X.at(a) * X.at(b) * X.at(c);
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <functional>
 
using namespace std;
 
 
int main()
{
	int N;
    cin >> N;

    bool f1 = false, f2= false;
    
    long n = 1, c = 0;
    while(1)
    {
        if(n % 3 == 0)
        	f1 = true;
        if(n % 5 == 0)
        	f2 = true;
      
        if(!f1 && !f2)
            c += n;
      
     	f1 = false, f2 = false;
      
        if(n == N)
            break;
      
      	n ++;
    }
    
    cout << c;
 
	return 0;
}

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

typedef long long lint;
typedef long double ldouble;
#define REP(i, x, n) for(int i = x ; i < n ; i++)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())

const int IINF = 1e9 + 10;
const lint LLINF = 1e18;
const lint MOD = 1e9 + 7;
const lint inv = MOD - 2;

int main(){
    int h, w;
    cin >> h >> w;
    lint c[10][10];
    rep(i, 10){
        rep(j, 10){
            cin >> c[i][j];
        }
    }
    rep(k, 10){
        rep(i, 10){
            rep(j, 10){
                c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
            }
        }
    }
    lint ans = 0;
    rep(i, h){
        rep(j, w){
            int a;
            cin >> a;
            if(a != -1){
                ans += c[a][1];
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	if(a>=1&&a<=13&&b>=1&&b<=13){
		if(a==b)
        cout<<"Draw"<<endl;	
		else if(a==1)
		cout<<"Alice"<<endl;
		else if(b==1)
		cout<<"Bob"<<endl;
		else if(a>b)
	    cout<<"Alice"<<endl;
	    else
	    cout<<"Bob"<<endl;}
		
			
		
	}

Measured memory_bytes: 256
S = input().strip()

for i in range(1, len(S)):
    if S[i] == S[i-1]:
        print(i, i+1)
        exit()
    if i >= 2:
        if S[i] == S[i - 2]:
            print(i-1, i+1)
            exit()
print(-1, -1)


Measured memory_bytes: 3188
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<algorithm>
#define ll long long
using namespace std;
struct dog {
	string a;
	int b;
};
int main()
{
	//int n, m;
	//cin >> n >> m;
	//if (n == m)cout << "Yes";
	//else cout << "No";

	//int a;
	//int b;
	//cin >> a >> b;
	//
	//if (a > b)
	//	for (int i = 0; i < a; i++)
	//		cout << b;
	//else
	//	for (int i = 0; i < b; i++)
	//		cout << a;

	int a,ans = 1,min;
	cin >> a >> min;
	for (int i = 1; i < a; i++) {
		int x;
		cin >> x;
		if (x < min) ans++, swap(x, min);
	}
	cout << ans << endl;


}



Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10; //1e-9?
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    int n; cin >> n;
    VI a(n); cin >> a;
    int m = 0;
    FOR(i, 0, n - 1) {
        if (m < a[i])--a[i];
        chmax(m, a[i]);
    }
    FOR(i, 0, n - 1)if (a[i] > a[i + 1]) {
        cout << "No\n";
        return 0;
    }
    cout << "Yes\n";
}

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

int main() {
    string arr[100],arr2[200][100];
    int h,w; cin>>h>>w;
    for (int i = 0; i < h; i++){
        cin>>arr[i];
    }
    for (int i = 0; i < h; i++){
        cout<<arr[i]<<endl;
        cout<<arr[i]<<endl;
    }
}

Measured memory_bytes: 384
#include<stdio.h>

int main(void){
    int n,m,a,b,i,j;
    scanf("%d %d", &n, &m);
    int A[n][m];
    int B[m];
    int C[n];
    for ( i = 0 ; i < n ; i++ ){
        for ( j = 0 ; j < m ; j++ ){
            scanf("%d", &A[i][j]);
        }
    }
    for ( j = 0 ; j < m ; j++ ){
        scanf("%d", &B[j]);
    }
    for ( i = 0 ; i < n ; i++ ){
        C[i] = 0;
        for ( j = 0 ; j < m ; j++ ){
            C[i] = A[i][j] * B[j] + C[i];
        }
        printf("%d\n", C[i]);
    }
    return 0;
}


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

typedef long long ll;
typedef long double ld;

#define imx INT_MAX
#define imn INT_MIN
#define llmx LLONG_MAX
#define llmn LLONG_MIN

#define fi first
#define se second
#define pb push_back

int gcd(int a, int b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	ll sum =0;
	for (int i = 1; i <= n; i++)
	{
		for(int j=1; j <= n; j++)
		{
			for(int k=1; k <=n ;k++)
			{
				sum+=gcd(gcd(i, j), k);
			}
		}
	}
	cout<<sum<<endl;
}

Measured memory_bytes: 3612
input_str = STDIN.gets
n = input_str.to_i

$result = []
$result[0] = 1
$result[1] = 1
# for num in 2..n do
#   result[num] = result[num - 1] + result[num - 2]
# end
for i in 0..n do
  $result[i] = 0
end

$result[0] = 1
$result[1] = 1

def fib num
  if $result[num] != 0
    return $result[num]
  end
  a = fib (num - 1)
  b = fib (num - 2)
  $result[num] = a + b

  return $result[num]
end

fib n
puts $result[n]



Measured memory_bytes: 8920
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int GetFirstDigitNumber(int N) {
	return N % 10;
}

int main() {

	const int p = 5;
	vector<int> c(p);
	int minDigit = 2147483647;
	int minIndex = -1;
	for (int i = 0; i < p; i++) {
		cin >> c[i];
		int digit = GetFirstDigitNumber(c[i]);
		if (digit != 0 && chmin(minDigit, digit) ) {
			minIndex = i;
		}
	}
	
	int ans = 0;
	if (minIndex == -1) {
		for (int i = 0; i < p; i++) ans += c[i];		
	}
	else {
		for (int i = 0; i < p; i++) {
			if (i == minIndex) continue;
			int digit = GetFirstDigitNumber(c[i]);
			if (digit == 0) ans += c[i];
			else ans += (c[i] / 10 + 1) * 10;
		}
		ans += c[minIndex];
	}

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

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

typedef long long LL;
#define lowbit(x) ((x)&(-x))
#define INF 0x3f3f3f3f
#define memset(a,b) memset(a,b,sizeof(a))
#define	GE() printf(">----------\n")
#define	IN() freopen("in.txt","r",stdin)
#define	OUT() freopen("out.txt","w",stdout)
const int mod=1e9+7;
const LL inf=0x3f3f3f3f3f3f3f3f;
const double pi=acos(-1.0);
const double eps=1e-8;
const int maxn=100005;

int n, p;
vector<int> E[maxn];
int vis[maxn];

int dfs(int u, int step){
    vis[u]=1;
    if(u==n){
        int mid=step/2+1+step%2;
        if(step==mid)p=u;
        return mid;
    }
    for(int i=0;i<E[u].size();i++){
        int v=E[u][i];
        if(!vis[v]){
            int mid=dfs(v, step+1);
            if(mid&&step==mid&&!p)p=u;
            if(mid)return mid;
        }
    }
    return 0;
}

int dfs2(int u){
    vis[u]=1;
    if(u==p)return 0;
    int add=0;
    for(int i=0;i<E[u].size();i++){
        int v=E[u][i];
        if(!vis[v]){
            add+=dfs2(v);
        }
    }
    return add+1;
}

int main() {
    while(~scanf("%d", &n)){
        p=0;
        int u, v;
        for(int i=1;i<=n;i++)E[i].clear();
        for(int i=0;i<n-1;i++){
            scanf("%d%d", &u, &v);
            E[u].push_back(v);
            E[v].push_back(u);
        }
        memset(vis, 0);
        dfs(1, 1);
        memset(vis, 0);
        int sum=dfs2(1);
        printf("%s\n", sum>n-sum?"Fennec":"Snuke");
    }
    return 0;
}


Measured memory_bytes: 10752
//                             In The Name Of Allah
#include <bits/stdc++.h>
#define	ss second
#define ff first
#define use_fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ret(n) return cout << n, 0
#define se(n) cout << setprecision(n) << fixed
#define pb push_back
#define int long long
#define ld long double
using namespace std; 
 
const int N = 2e5 + 1000, OO = 1e9, M = 998244353, P = 6151, SQ = 1000, lg = 12;
typedef pair <int, int> pii;

int32_t main() {
    use_fast;
    string s, t;
	cin >> s >> t;
	cout << t << s << endl;    
	return 0; 
}
/*
be carefull :
1- if not solve after 20 min, read again twice
2- after submit read the code again
3- fun with contest
4- ... 
*/	

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

using namespace std;
using ll = long long;

template<class T> ostream& operator<<(ostream& os, const vector<T> arr){ for(int i = 0; i < (int)arr.size(); i++)cout << arr[i] << (i == (int)arr.size() -1 ? "" : " "); return os;}

int main()
{
    int n; cin >> n;
    bool res = true; //転倒数が0でない
    vector<int> a(n);
    for(int i = 0; i < n; i++)cin >> a[i];
    int cnt = 0;

    while(res) {
        res = false;
        for(int j = n - 1; j >= 1; j--) {
            if(a[j - 1] > a[j]){
                swap(a[j], a[j - 1]);
                res = true;
                cnt++;
            }
        }
    }
    cout << a << endl;
    cout << cnt << endl;
}


Measured memory_bytes: 3152
/*|In The Name Of Allah|*/

#include <bits/stdc++.h>

using namespace std;

const int N = 12;
const int M = 1e3;

int n;
int m;
int cost[M];
int unlocks[M];
int mem[M][1 << N];

int go(int idx , int mask){
    if(mask == (1 << n) - 1)
        return 0;
    if(idx == m)
        return 1e9;
    if(~mem[idx][mask])
        return mem[idx][mask];
    int mn = go(idx + 1 , mask);
    mn = min(mn , go(idx + 1 , mask | unlocks[idx]) + cost[idx]);
    return mem[idx][mask] = mn;
}

int main(){
    scanf("%d%d" , &n , &m);
    for(int i = 0; i < m; i++){
        int x;
        scanf("%d%d" , &cost[i] , &x);
        int mask = 0;
        for(int j = 0; j < x; j++){
            int y;
            scanf("%d" , &y);
            y--;
            mask ^= 1 << y;
        }
        unlocks[i] = mask;
    }
    memset(mem , -1 , sizeof mem);
    int ans = go(0 , 0);
    if(ans >= 1e9){
        puts("-1");
    } else {
        printf("%d\n" , ans);
    }
}


Measured memory_bytes: 16256