akhauriyash/Code-Regression huggingface dataset:
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn solve(n: i32, m: i32, an: Vec<i32>) -> i64 {
    let mut heap = ::std::collections::BinaryHeap::new();
    for ai in an {
        heap.push(ai);
    }

    for _ in 0..m {
        if let Some(h) = heap.pop() {
            heap.push(h / 2);
        }
    }

    heap.into_vec().into_iter().map(|v| v as i64).sum()
}

fn main() {
    input!{
        n: i32,
        m: i32,
        an: [i32; n]
    }

    println!("{:?}", solve(n, m, an));
}


Measured memory_bytes: 6396
#include<bits/stdc++.h>
#define MN 700
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
bitset<705> b;
int s[MN+5][MN+5],n,m,vis[MN+5],c[MN+5],flag,num[2];
void dfs(int x,int v)
{
	vis[x]=1;c[x]=v;++num[v];
	for(int j=1;j<=n;++j) if(j!=x&&!s[x][j])
	{
		if(!vis[j]) dfs(j,v^1);
		else if(c[j]!=v^1) flag=1;	
	}
}
int main()
{
	n=read();m=read();b[0]=1;
	for(int i=1;i<=m;++i) 
	{
		int x=read(),y=read();
		s[x][y]=s[y][x]=1;	
	}
	for(int i=1;i<=n;++i) 
		if(!vis[i]) num[0]=num[1]=0,dfs(i,0),b=(b<<num[0])|(b<<num[1]);
	if(flag) return 0*puts("-1");int ans=1e9;
	for(int j=0;j<=n;++j) if(b[j]) ans=min(ans,j*(j-1)/2+(n-j)*(n-j-1)/2);
	cout<<ans; 
	return 0;
}



Measured memory_bytes: 2176
#include<bits/stdc++.h>
#define ll                  long long
#define dl                 double
#define pb                push_back
#define F                  first
#define S                  second
#define endl              "\n"
#define rep(i,a,b)       for(i=a;i<b;i++)
#define all(v)             v.begin(),v.end()
#define allr(v)            v.rbegin(),v.rend()
#define mod              1000000007LL
#define CIN(V,s,n)      for(int i=s;i<n;i++){cin >> V[i];}
#define COUT(V,s,n)   {for(int i=s;i<n;i++){cout <<  V[i] << " "  ;} cout << endl;}
#define fast               ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define CLEAR(V);      for(ll i=0;i<V.size();i++) V[i] = 0;
#define N                  150
#define tmod             998244353LL
using namespace std;

bool sBs(const pair<int,int> &a,const pair<int,int> &b)
{   return (a.second < b.second);   }

ll SUMD(ll n);
ll BS(vector<pair< ll ,ll > > &PS,ll s,ll e,ll ser);
ll MI(ll a, ll m);
//bool P[N+1];
void Sieve(int n=N);
ll Powb(ll b,ll n);

int main()
{
fast;
ll q=1,t;
//cin >> q;
while(q--)
{
    ll i,j,n,m,k,l,r,a,b,c=0,d,e,g,p,q,u,v,w,x,y,flag=1;
    //n=m=k=i=j=l=r=a=b=c=d=u=v=w=p=x=y=0;
    cin >> n;
    map<string,int> M;
    for(i=0;i<n;i++)
    {
        string s;
         cin >> s; M[s]++;
    }
    cout << (ll) M.size();
}
    return 0;
}

//*****************************************************************************************************************************************

ll Powb(ll b,ll n)
{
    if(n==0) return 1LL;
    if(n==1) return b;
    ll temp = Powb(b,n/2);
    if(n%2==0){return (temp*temp)%mod;}
    else{return (b*((temp*temp)%mod))%mod;}
}

ll SUMD(ll n)
{   ll sum=0;
    while(n>0){sum += n%10;n = n/10;}
    return sum;

}
ll BS(vector<pair<ll,ll> > &PS,ll s,ll e,ll ser)
{
    if(s>e)
        return s;
    ll mid = (s+e)/2;
    if(PS[mid].F==ser)
    {
        return mid;
    }
    else if(PS[mid].F > ser)
    {
        return BS(PS,s,mid-1,ser);
    }
    else
        return BS(PS,mid+1,e,ser);
}
ll MI(ll a, ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;
    if (m == 1)
      return 0;
    while (a > 1)
    {
        ll q = a / m;
        ll t = m;
        m = a % m, a = t;
        t = y;
        y = x - q * y;
        x = t;
    }
    if (x < 0)
       x += m0;
    return x;
}
/*
void Sieve(int n)
{
    memset(P,true,sizeof(P));
    P[0] = false;
    P[1]= false;
    for(ll i=2;i*i<=n;i++)
    {
        if(P[i])
        {
            for(ll j=i*i;j<=n;j+=i)
            {
                P[j]=false;
            }
        }
    }

}

*/


Measured memory_bytes: 19236
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int> 


int main(){
  string S; cin >> S;

  while (S.size()){
    if (S.size()>=5 && (S.substr(S.size()-5)=="dream" || S.substr(S.size()-5)=="erase")) S.erase(S.size()-5);
    else if (S.size()>=6 && S.substr(S.size()-6)=="eraser") S.erase(S.size()-6);
    else if (S.size()>=7 && S.substr(S.size()-7)=="dreamer") S.erase(S.size()-7);
    else break;
    
  }

  if (S.size()==0) cout << "YES" << endl;
  else cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 512
import math
n = int(input())

p = []
for i in range(1, int(math.sqrt(n+1))+1):
    if n % i == 0:
        p.append(i)

ans = 11
for i in p:
    a, b = str(i), str(n//i)
    ans = min(ans, max(len(a), len(b)))

print(ans)


Measured memory_bytes: 3060
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int x = sc.nextInt();
        if (x <= 500 * n) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

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

#define ll long long 
#define sz(x) (int)x.size()

using namespace std;

int main(){
	int a,b,x=0;
	string s;
	cin>>a>>b>>s;
	for(int i=0;i<a+b+1;i++){
		x+=s[i]=='-';
	}
	if(x>1 || s[a]!='-'){
		cout<<"No";
	}
	else cout<<"Yes";


	
	
}

Measured memory_bytes: 3592
#include <stdio.h>

int main(){
    int h,w;
    scanf("%d%d", &h, &w);
    while(h!=0||w!=0){
        int i,j;
        for(i=0;i<h;i++){
            for(j=0;j<w;j++){
                printf("#");
            }
            printf("\n");
        }
        scanf("%d%d", &h, &w);
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2052
#include <stdio.h>
#include <string.h>
int getint(char );
int main(){
  int n,i,j,min,cnt=0;
  char a[36][2],a1[36][2],a2[36][2],array[2];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",&a[i]);
    strcpy(a1[i],a[i]);
    strcpy(a2[i],a[i]);
  }
  for(i=0;i<n;i++){
    for(j=n-1;j>i;j--){
      if(getint(a1[j][1])<getint(a1[j-1][1])){
	array[0]=a1[j][0];
	array[1]=a1[j][1];
	a1[j][0]=a1[j-1][0];
	a1[j][1]=a1[j-1][1];
	a1[j-1][0]=array[0];
	a1[j-1][1]=array[1];
      }
    }
  }
  for(i=0;i<n;i++){
    for(j=0;j<2;j++){
    printf("%c",a1[i][j]);
    }
    if(i!=n-1)printf(" ");
  }
  printf("\n");
  printf("Stable\n");
  for(i=0;i<n;i++){
    min=i;
    for(j=i;j<n;j++){
      if(getint(a2[j][1])<getint(a2[min][1]))min=j;
    }
    array[0]=a2[i][0];
    array[1]=a2[i][1];
    a2[i][0]=a2[min][0];
    a2[i][1]=a2[min][1];
    a2[min][0]=array[0];
    a2[min][1]=array[1];
  }
  for(i=0;i<n;i++){
    for(j=0;j<2;j++){
    printf("%c",a2[i][j]);
    }
    if(i!=n-1)printf(" ");
  }
  printf("\n");
  for(i=0;i<n;i++){
    if(strcmp(a1[i],a2[i])!=0)cnt++;
  }
  if(cnt!=0)printf("Not stable\n");
  else printf("Stable\n");
  return 0;
}
int getint(char i){
  return (int)i-48;
}



Measured memory_bytes: 2636
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

void searchAccess(const vector<vector<int> >& edges, int start, vector<bool>& access)
{
    int n = edges.size();
    access.assign(n, false);

    access[start] = true; // 有向グラフの場合、この行を削るとaccess[start]は閉路の有無
    queue<int> q;
    q.push(start);
    while(!q.empty()){
        int j = q.front();
        q.pop();
        for(unsigned i=0; i<edges[j].size(); ++i){
            if(!access[edges[j][i]]){
                q.push(edges[j][i]);
                access[edges[j][i]] = true;
            }
        }
    }
}
void searchAccess(const vector<vector<int> >& edges, vector<vector<bool> >& access)
{
    int n = edges.size();
    access.resize(n);
    for(int i=0; i<n; ++i)
        searchAccess(edges, i, access[i]);
}

int main()
{
    int n;
    cin >> n;
    map<string, int> index;
    vector<int> x(n);
    for(int i=0; i<n; ++i){
        string a;
        cin >> a >> x[i];
        index[a] = i;
    }

    int m;
    cin >> m;
    vector<vector<int> > edges(n);
    for(int i=0; i<m; ++i){
        string s, t;
        cin >> s >> t;
        int a = index[s];
        int b = index[t];
        edges[a].push_back(b);
        edges[b].push_back(a);
    }

    vector<vector<bool> > access;
    searchAccess(edges, access);

    int ans = 0;
    for(int i=0; i<n; ++i){
        int cost = INT_MAX;
        for(int j=0; j<n; ++j){
            if(access[i][j])
                cost = min(cost, x[j]);
        }
        ans += cost;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 5224
c = []
c.append(list(map(int,input().split())))
c.append(list(map(int,input().split())))
c.append(list(map(int,input().split())))

for i in range(2):
    if c[i+1][0] -c[i][0] == c[i+1][1] -c[i][1] == c[i+1][2] -c[i][2]:
        pass
    else:
        print('No')
        exit(0)
for i in range(2):
    if c[0][i+1] -c[0][i] == c[1][i+1] -c[1][i] == c[2][i+1] -c[2][i]:
        pass
    else:
        print('No')
        exit(0)
print('Yes')


Measured memory_bytes: 3064
import sys
input = sys.stdin.readline
'''
n, m = map(int, input().split())
n = int(input())
A = list(map(int, input().split()))
for test in range(int(input())):
'''
inf = 100000000000000000  # 1e17

n, m = map(int, input().split())
A = list(map(int, input().split()))
A.append(n + A[0])
ans=0
for i in range(m):
    ans = max(ans, A[i + 1] - A[i])
print(n - ans)


Measured memory_bytes: 72012
n=int(input())
ans=[]

for i in range(n):
    ans.append(input())

#print(ans)
ans2=set(ans)
#print(ans2)

if len(ans2)!=n:
    print("No")
    exit()

for i in range(n-1):
    if ans[i][-1]==ans[i+1][0]:
        continue
    else:
        print("No")
        exit()
print("Yes")


Measured memory_bytes: 3060
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>

using namespace std;

const int inf = (int) 1e9;

int main() {
  int n;
  cin >> n;
  int a[n], b[n], c[n];
  for (int i = 1; i <= n; i++) {
    cin >> a[i] >> b[i] >> c[i];
  }
  long long dp[n + 5][4];
  dp[0][0] = dp[0][1] = dp[0][2] = 0;
  for (int i = 1; i <= n; i++) {
    dp[i][0] = a[i] + max(dp[i - 1][1], dp[i - 1][2]);
    dp[i][1] = b[i] + max(dp[i - 1][0], dp[i - 1][2]);
    dp[i][2] = c[i] + max(dp[i - 1][0], dp[i - 1][1]);
  }
  cout << max({dp[n][0], dp[n][1], dp[n][2]}) << endl;
  return 0;
}


Measured memory_bytes: 4480
package main

import (
  "fmt"
  "strconv"
)

func stoi(s string) int {
  d, _ := strconv.Atoi(s)
  return d
}

func main() {
  var s string 
  fmt.Scan(&s)
  a, b := stoi(s[:2]), stoi(s[2:])
  bl1 := a >= 1 && a <= 12
  bl2 := b >= 1 && b <= 12
  var res string 
  if bl1 {
    if bl2 {
      res = "AMBIGUOUS"
    } else {
      res = "MMYY"
    } 
  } else {
    if bl2 {
      res = "YYMM"
    } else {
      res = "NA"
    }
  }
  fmt.Println(res)
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cassert>

#define rep(i,n)	for(int i = 0;i < n;i++)
#define rep2(i,n)	for(int i = 1;i <= n;i++)
#define each(i,x)	for(auto & i : x)

int table[6][6] = {
{0,4,2,5,3,0},
{3,0,6,1,0,4},
{5,1,0,0,6,2},
{2,6,0,0,1,5},
{4,0,1,6,0,3},
{0,3,5,2,4,0}};


struct dice
{
	int top;
	int front;
	int left;
	void toFront(){int tmp = top;top = 7-front;front = tmp;}
	void toLeft(){int tmp = top;top = 7-left;left = tmp;}
};

using namespace std;

int main()
{
	while(1)
	{
		int n;
		cin >> n;
		if(n == 0)
			break;
		vector<vector<stack<dice>>> ary(41,vector<stack<dice>>(41));
		rep(i,n)
		{
			int x = 20;
			int y = 20;
			int t,f;
			cin >> t >> f;
			dice d = {t,f,table[t-1][f-1]};
			while(1)
			{
				map<int,int> dir;
				if(ary[x+1][y].size() < ary[x][y].size())
				{
					if(7-d.left >= 4)
					{
						dir.insert(make_pair(7-d.left,0));
					}
				}
				if(ary[x-1][y].size() < ary[x][y].size())
				{
					if(d.left >= 4)
					{
						dir.insert(make_pair(d.left,1));
					}
				}
				if(ary[x][y+1].size() < ary[x][y].size())
				{
					if(7-d.front >= 4)
					{
						dir.insert(make_pair(7-d.front,2));
					}
				}
				if(ary[x][y-1].size() < ary[x][y].size())
				{
					if(d.front >= 4)
					{
						dir.insert(make_pair(d.front,3));
					}
				}
				if(dir.size())
				{
					auto it = dir.end();
					it--;
					switch(it->second)
					{
						case 0:
							x++;
							d.toLeft();d.toLeft();d.toLeft();
							break;
						case 1:
							x--;
							d.toLeft();
							break;
						case 2:
							y++;
							d.toFront();d.toFront();d.toFront();
							break;
						case 3:
							y--;
							d.toFront();
							break;
					}
				}
				else
				{
					ary[x][y].push(d);
					break;
				}
			}
		}
		vector<int> cnt(6);
		rep(i,41)
		{
			rep(j,41)
			{
				if(!ary[i][j].empty() && ary[i][j].top().top != 0)
				{
					cnt[ary[i][j].top().top-1]++;
				}
			}
		}
		rep(i,5)
		{
			cout << cnt[i] << ' ';
		}
		cout << cnt[5] << endl;
	}
	return 0;
}

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

using namespace std;

int n, a, b, c;
int ans = INT_MAX;
// 0 = a  ,1 = b, 2 = c, 3 = x
vector<int> l;

void calc(vector<int> choice) {
	int len_a = 0, len_b = 0, len_c = 0;
	int count_a = -1, count_b = -1, count_c = -1;
	for (int i = 0; i < n; ++i) {
		switch (choice[i])
		{
		case 0:len_a += l[i]; count_a++; break;
		case 1:len_b += l[i]; count_b++; break;
		case 2:len_c += l[i]; count_c++; break;

		}
	}
	if (len_a != 0 && len_b != 0 && len_c != 0) {
		int cost = 0;
		cost += count_a * 10;
		cost += count_b * 10;
		cost += count_c * 10;
		cost += abs(a - len_a);
		cost += abs(b - len_b);
		cost += abs(c - len_c);
		ans = min(ans, cost);
	}

}

void dfs(int depth, vector<int> choice) {
	if (depth == n) {
		calc(choice);
	}
	else {
		for (int i = 0; i < 4; ++i) {
			choice.push_back(i);
			dfs(depth + 1, choice);
			choice.pop_back();
		}
	}

}

int main() {

	cin >> n >> a >> b >> c;
	l.resize(n);
	for (int i = 0; i < n; ++i) {
		cin >> l[i];
	}
	vector<int> chice;
	dfs(0, chice);

	cout << ans << endl;

	return 0;
}


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

using namespace std;
using ll = long long int;
using pii = pair<int, int>;
using pil = pair<int, ll>;

int main() {
	int r, D, x2000;
	cin >> r >> D >> x2000;

	vector<int> x;
	int tx = x2000;
	for (int i = 0; i < 10; i++)
	{
		tx = r * tx - D;
		x.push_back(tx);
	}

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

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>;
#define FIO ios_base::sync_with_stdio(0); cin.tie(0);
#define T() int tt; cin>>tt; while(tt--)
#define mp make_pair
#define pb push_back
#define lchild (2*node+1)
#define rchild (2*node+2)
#define f first
#define s second
#define br cout<<endl

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;

ll gcd(ll a, ll b){
    if(b==0)return a;
    else gcd(b, a%b);
}
ll pwr(ll base, ll p, ll mod){
    ll ans=1; while(p){if(p&1)ans=(ans*base)%mod; base=(base*base)%mod; p/=2;} return ans;
}


int main(){
    FIO
    int n; cin >> n;
    int a[n+1];
    int b[n+1];
    memset(b, 0, sizeof(b));

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

    int i=1;
    ll res=0;
    bool mode=true;
    if(a[i]==2){
        cout << 1 << endl;
        return 0;
    }
    else {
        while(b[a[i]]!=1){
        b[a[i]] = 1;
        res++;
        i = a[i];
        if(i==a[i])break;

        if(a[i]==2){
            mode = false;
            res++;
            break;
        }
    }

    if(!mode) cout << res << endl;
    else cout << -1 << endl;
    }




return 0;
}


Measured memory_bytes: 1024
import std.stdio;

void main() {
  while(true) {
    uint[][][char] mapping;
    char[3][3] field;
    foreach (c; ['b', 'w', '+'])
      mapping[c] = new uint[][](3, 3);
    for(int i = 0; i < 3; i++)
      for(int j = 0; j < 3; j++) {
        scanf(j == 2 ? "%c\n" : "%c", &field[i][j]);
        if (field[i][j] == '0') goto end;
      }

    for(int i = 0; i < 3; i++)
      for(int j = 0; j < 3; j++) {
        mapping[field[i][j]][0][j]++;
        mapping[field[i][j]][1][i]++;
      }

    for(int i = 0; i < 3; i++) {
      mapping[field[i][i]][2][0]++;
      mapping[field[2 - i][i]][2][1]++;
    }
    
    for(int i = 0; i < 3; i++)
      for (int j = 0; j < 3; j++)
        foreach (c; ['b', 'w'])
          if (mapping[c][i][j] == 3) {writeln(c); goto next;}
    
    writeln("NA");
  next:;
  }
end:;
}

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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef long long int64;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define GSORT(x) sort(all(x), greater<int>())
#define MIN(x) *min_element(all(x))
#define MAX(x) *max_element(all(x))
#define in(x) cin >> x
#define co(x) cout << x
#define el  cout << endl
#define dump(x)  cout << #x << " = " << (x) << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }


int main() {
    string str, subStr = "ABC";
    int n;
    cin >> n;
    cin >> str;

    VI result;

    int subStrSize = subStr.size();
    int pos = str.find(subStr);

    while (pos != std::string::npos) {
        result.push_back(pos);
        pos = str.find(subStr, pos + subStrSize);
    }
    cout << result.size();

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 #include <math.h>
 #include <iostream>
 #include <iomanip>
 using namespace std;
 
 int main(){
    int H, A;

    cin >> H >> A;
    if (H % A!=0)
        cout << H/A+1 << endl;
    else
        cout << H/A << endl;
    return 0;
 }
 


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

#define MAX_V 204
#define INF 2000000000

typedef struct {
	int x;
	int y;
} point;

typedef vector<int> vi;

int res[MAX_V][MAX_V] = {0}, mf, f, s, t; // global variables
vi p; // p stores the BFS spanning tree from s

bool g(point a, point b) {
	return (a.x < b.x && a.y < b.y);
}

void augment(int v, int minEdge) { // traverse BFS spanning tree from s->t
if (v == s) { f = minEdge; return; } // record minEdge in a global var f
else if (p[v] != -1) { augment(p[v], min(minEdge, res[p[v]][v]));
res[p[v]][v] -= f; res[v][p[v]] += f; } }

int main() {
	vector<point> red;
	int n; cin >> n;
	for(int i=0;i<n;i++) {
		int x, y;
		cin >> x >> y;
		point p; p.x = x; p.y = y;
		red.push_back(p);
	}
	for(int i=0;i<n;i++) {
		int x, y;
		cin >> x >> y;
		point p; p.x = x; p.y = y;
		red.push_back(p);
	}
	s = 2*n; t = 2*n+1;
	for(int i=0;i<n;i++) {
		for(int j=n;j<2*n;j++) {
			if(g(red[i], red[j])) {
				res[i][j] = 1;
			} else {
				res[i][j] = 0;
			}
		}
	}
	for(int i=0;i<n;i++) {
		res[s][i] = 1;
		res[s][i+n] = 0;
		res[i+n][t] = 1;
		res[i][t] = 0;
	}
	res[s][t] = 0;

	// inside int main(): set up ‘res’, ‘s’, and ‘t’ with appropriate values
	mf = 0; // mf stands for max_flow
	while (1) { // O(VE^2) (actually O(V^3 E) Edmonds Karp’s algorithm
		f = 0;
		// run BFS, compare with the original BFS shown in Section 4.2.2
		vi dist(MAX_V, INF); dist[s] = 0; queue<int> q; q.push(s);
		p.assign(MAX_V, -1); // record the BFS spanning tree, from s to t!
		while (!q.empty()) {
			int u = q.front(); q.pop();
			if (u == t) break; // immediately stop BFS if we already reach sink t
	
			for (int v = 0; v < MAX_V; v++) // note: this part is slow
			if (res[u][v] > 0 && dist[v] == INF)
				dist[v] = dist[u] + 1, q.push(v), p[v] = u; // 3 lines in 1!
		}
	
		augment(t, INF); // find the min edge weight ‘f’ in this path, if any
	
		if (f == 0) break; // we cannot send any more flow (‘f’ = 0), terminate
			mf += f; // we can still send a flow, increase the max flow!
	}
	printf("%d\n", mf); // this is the max flow value

	return 0;
}

Measured memory_bytes: 384
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

int main(){
  str s;
  cin >> s;
  ll n = s.length();
  ll ans = INF;
  ll changed = false;
  REP(i,n-1){
    if(s[i]!=s[i+1]){
      ans = min(ans,max(i+1,n-i-1));
      changed = true;
    }
  }
  if(!changed){
    cout << n << endl;
  }else{
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define mod 1000000007 //10^9+7
#define div 998244353
#define rep(i,n) for(int i=0;i<n;i++)
int n,ans,sub=1;
int a[20];
int mypow(int a,int b){
    if(b==1)return a;
    if(b%2)return (mypow(a,b/2)*mypow(a,(b/2)+1))%div;
    return (mypow(a,b/2)*mypow(a,b/2))%div;
}
signed main(){
    cin>>n;
    rep(i,n){
        cin>>a[i];
        if(a[i]%2==0)sub*=2;
    }
    ans=mypow(3,n);
    ans-=sub;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
import numpy as np

N = INT()
print("Yes" if N%10 == 9 or N//10 == 9 else "No")

Measured memory_bytes: 13588
#include <algorithm>
#include <iostream>
#include <queue>
using namespace std;

int n;
queue<int> A, B, C;

void riffle(int c) {
    int x = n / 2;
    for (int i = 0; i < x; i++) {
        B.push(C.front());
        C.pop();
    }
    x = n - x;
    for (int i = 0; i < x; i++) {
        A.push(C.front());
        C.pop();
    }
    while (!A.empty() || !B.empty()) {
        for (int i = 0; i < c; i++) {
            if (A.empty()) break;
            C.push(A.front());
            A.pop();
        }
        for (int i = 0; i < c; i++) {
            if (B.empty()) break;
            C.push(B.front());
            B.pop();
        }
    }
    return;
}

int main() {
    int r, c;
    while (cin >> n >> r) {
        for (int i = 0; i < n; i++) C.push(i);
        for (int i = 0; i < r; i++) {
            cin >> c;
            riffle(c);
        }
        int ans;
        while(!C.empty()){
            ans = C.front();
            C.pop();
        }
        cout << ans << endl;
    }

    return 0;
}

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

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin >> s;
	if (s[0] == s[2]){
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (H, W, A, B) = listOfInt()
    val S = Array<Array<Int>>(H) { Array<Int>(W) { 0 } }
    for (h in 0 until H) {
        for (w in 0 until W) {
            if (h < B)
                if (w < A) S[h][w] = 0
                else S[h][w] = 1
            else
                if (w < A) S[h][w] = 1
                else S[h][w] = 0
        }
        println(S[h].joinToString(separator = ""))
    }
}
fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt(delta: Int = 0) = listOfString().map { Integer.parseInt(it) + delta }

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

#define ll long long
#define INF INT_MAX/3
#define pi 2*acos(0.0)
#define eps 1e-14

const int MAX_N = (int)1e+5;
const int MAX_M = (int)1e+2;
ll n, A, B;
ll x[MAX_N];
void input()
{
	cin >> n >> A >> B;
	for (int i = 0; i < n; i++) {
		cin >> x[i];
	}
}

void solve() {
	ll ans = 0;
	for (int i = 0; i < n-1; i++) {
		if (A*(x[i + 1] - x[i]) < B) {
			ans += A*(x[i + 1] - x[i]);
		}
		else {
			ans += B;
		}
	}
	cout << ans << endl;
}
int main() {
	input();
	solve();
	return 0;
}

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

int main(){
  int n;
  cin>>n;
  int a[501];
  for(int i=0;i<n*2;i++)cin>>a[i];
  sort(a,a+2*n);
  
  int ans=0;
  for(int i=0;i<2*n;i+=2)ans+=min(a[i],a[i+1]);
  cout <<ans<<endl;
  return 0;
}


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

int main(){

	int i,j;
	int a[1000]={0},b[1000]={0},n,k,ak,bk,kk,sum;
	char aa[1000]={'0'},bb[1000]={'0'},ans[1000]={'0'};

	scanf("%d",&n);

	for(i=0;i<n;i++){
		for(j=0;j<1000;j++){
			aa[j]='0';
			bb[j]='0';
			ans[j]='0';
		}

		scanf("%s %s",aa,bb);
		j=0;
		ak=strlen(aa);
		bk=strlen(bb);
		if(ak>80 || bk>80){
			printf("overflow\n");
			continue;
		}
		k=(ak-->bk--)?ak:bk;
		kk=0;
		sum=0;
		while(k>=0){
			if(((ak>bk)?bk:ak)>=0){
				ans[sum]=aa[ak]-'0'+bb[bk]-'0'+kk+'0';
			}
			else{
				if(ak>bk){
					ans[sum]=aa[ak]+kk;
				}
				else{
					ans[sum]=bb[bk]+kk;
				}
			}
			kk=0;
			if(ans[sum]>'9'){
				ans[sum]-=10;
				kk=1;
			}

			ak--;
			bk--;
			k--;
			sum++;
		}
		if(kk==1)ans[sum++]=kk+'0';
		ans[sum]='\0';
		j=0;
		sum=strlen(ans);
		if(sum-->80){
			printf("overflow\n");
			continue;
		}
		while(sum>=0){
			if(sum==strlen(ans)-1){
				if(ans[sum]==0){
					sum--;
					continue;
				}
			}
			printf("%c",ans[sum--]);
		}
		printf("\n");
	}

	return 0;
}

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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16

ll n,m,r;
ll dist[300][300];
ll a[300];

int main(){
	cin.sync_with_stdio(false);
  cin>>n>>m>>r;
  rep(i,r){
    cin>>a[i];
    a[i]--;
  }
  sort(a,a+r);
  rep(i,n)rep(j,n){
    if(i==j)dist[i][j]=0;
    else dist[i][j]=INF;
  }
  rep(i,m){
    ll aa,b,c;
    cin>>aa>>b>>c;
    aa--;b--;
    dist[aa][b]=dist[b][aa]=c;
  }
  rep(k,n)rep(i,n)rep(j,n)minch(dist[i][j],dist[i][k]+dist[k][j]);
  ll res=INF;
  do{
    ll s=0;
    repl(i,1,r)s+=dist[a[i-1]][a[i]];
    minch(res,s);
  }while(next_permutation(a,a+r));
  cout<<res<<endl;
	return 0; 
}


Measured memory_bytes: 768
#include <stdio.h>


int main() {
	int w, h, n;
	scanf("%d %d %d", &w, &h, &n);

	int x, y, a;
	int w_ = w, h_ = h, x1 = 0, x2 = w, y3 = 0, y4 = h;
	int i;

	for (i = 0; i < n; i++) {
		scanf("%d %d %d", &x, &y, &a);
		if (a == 1 && x > x1) x1 = x;
		else if (a == 2 && x < x2) x2 = x;
		else if (a == 3 && y > y3) y3 = y;
		else if (a == 4 && y < y4) y4 = y;
	}

	w_ = x2 - x1 > 0 ? x2 - x1 : 0;
	h_ = y4 - y3 > 0 ? y4 - y3 : 0;

	printf("%d\n", w_ * h_);
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int r = Integer.parseInt(scanner.next());
        int g = Integer.parseInt(scanner.next());
        int b = Integer.parseInt(scanner.next());
        scanner.close();

        int rgb = r * 100 + g * 10 + b;

        if (rgb % 4 == 0) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}


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

using namespace std;

#define fastio cin.tie(NULL);cout.tie(NULL);ios_base::sync_with_stdio(0);
#define debug(x) cout << x << endl;
#define endl '\n'
#define sz(x) (int)x.size()
#define popcount __builtin_popcount
#define MAXN 200005
#define LOG 20
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define pb push_back
#define int long long

typedef long long ll;
typedef pair <ll, ll> pii;
typedef vector <int> vi;
typedef vector <pii> vii;
typedef vector <vi> matriz;

int n;
int v[MAXN];

int32_t main(){
    fastio
    cin >> n;
    for(int i = 1; i <= n; i++) cin >> v[i];

    int res = 0;
    for(int i = 1; i <= n; i++){
        for(int j = i + 1; j <= n; j++){
            res += v[i] * v[j];
        }
    }

    cout << res << endl;
    
    return 0;
}

Measured memory_bytes: 3648
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<set>
#include<queue>

using namespace std;

#define INF 1000000007

int main(){
  int n;
  cin >> n;
  if(n % 2){
    cout << ((double)n+1)/(2*n) << endl;
  }
  else cout << 0.5 << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // TODO 自動生成されたメソッド・スタブ
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        int c = scan.nextInt();
        int count=0;
        for(int i=a;i<=b;i++){
            if(c%i==0){
                count++;
            }
        }
        System.out.printf("%d\n",count);
    }

}



Measured memory_bytes: 26392
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)

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

  deque<ll> ans;
  ans.push_back(A[0]);
  for (ll i = 1; i < N; i++) {
    auto it = lower_bound(begin(ans), end(ans), A[i]);
    if (it == begin(ans)) {
      ans.push_front(A[i]);
    } else {
      auto pre = prev(it);
      *pre = A[i];
    }
  }

  cout << ans.size() << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

int ka[100010];
int ka2[100010];

int comb(int x, int y) {
	if (y > x)return 0;
	return ka2[y] * mod_pow(ka[y], mod - 2, mod) % mod;
}

int n, m, d;
long double s, t;

signed main() {
	cin >> n >> m >> d;
	s = n * n;
	if (!d)t = n;
	else t = (n - d) * 2;
	printf("%.10Lf", t / s * (m - 1));
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int x = scan.nextInt();
		int a = scan.nextInt();
		int b = scan.nextInt();
		scan.close();
		if(a>=b)System.out.println("delicious");
		else if(x-(b-a)>=0)System.out.println("safe");
		else System.out.println("dangerous");
	}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define pi 3.1415926535897932384626
using namespace std;
  
struct P{
  int x,y;
  bool operator <(const P &a) const{
    return y<a.y;
  };
};
  
int a,b,c,d,i,k,n,m,e,dx[10]={1,0,-1,0,1,1,-1,-1},dy[10]={0,1,0,-1,1,-1,1,-1};
int o[4];
int l[3];
int j[3];


long long x,y,z,mod=1000000007;
//string r,r1,r2,r3,r4,r5;
char r[1];
vector<int> v[1],v1;
queue<int> q;
stack<int> s;
map<int,int> p;
P u[1];
  
bool as(P a,P b)
{
  if(a.x!=b.x)
  return a.x<b.x;
  return a.y<b.y;
}

int main()
{
  for(int t=1;t<=3;t++)
  scanf("%d",&o[t]);
  sort(o+1,o+3+1);
  if((o[1]==o[2]&&o[2]!=o[3])||(o[2]==o[3]&&o[2]!=o[1])) puts("Yes");
  else puts("No");
}


Measured memory_bytes: 256
from __future__ import division


def dist(vx, vy, p, n):
    if p == float("inf"):
        d = max([abs(vx[i] - vy[i]) for i in range(n)])
        return d
    d = 0
    for i in range(n):
        d += abs(vx[i]-vy[i]) ** p
    d = d ** (1/p)
    return d


n = int(raw_input())
vx = map(int, raw_input().split())
vy = map(int, raw_input().split())

print "{:.6f}".format(dist(vx, vy, 1, n))
print "{:.6f}".format(dist(vx, vy, 2, n))
print "{:.6f}".format(dist(vx, vy, 3, n))
print "{:.6f}".format(dist(vx, vy, float("inf"), n))

Measured memory_bytes: 6684
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin >> s;
    if(s[0] == s[1] && s[2] == s[3] || s[0] == s[2] && s[1] == s[3] || s[0] == s[3] && s[1] == s[2])
    {
        if(!(s[0] == s[1] && s[0] == s[2] && s[0] == s[3]))
        {
            cout << "Yes";
        }
        else
        {
            cout << "No";
        }
        
    }
    else
    {
        cout << "No";
    }
    
    return 0;
}

Measured memory_bytes: 256
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <numeric>
#include <iomanip>
#define M_PI acos(-1)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1000000007;
const int MAX_V = 201;
int now = 0;

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
struct edge {
	int t;
	edge(int _t) : t(_t) {}
};
bool use[100010];


vector<edge> te[100010];
vector<edge> fe[100010];
int d[100100];
ll rec(int num) {
	if (num == 0) return 0;
	return rec(num - 1) + num;
}
ll gcd(int a, int b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll calc(ll b,ll n) {
	if (n < b) return n;
	return calc(b, n / b) + n % b;
}

void Solve() {

	string s;
	cin >> s;
	int n = s.size();
	int c[100];
	fill(c, c + 100, 0);
	for (size_t i = 0; i < n; i++)
	{
		c[s[i] - 'a']++;
	}

	int kind = 0;
	for (size_t i = 0; i < 100; i++)
	{
		kind += c[i] > 0;
	}

	if (kind == 1) {
		cout << "Second" << endl;
		return;
	}

	if (s[0] == s[n - 1]) {
		cout << (n % 2 == 0 ? "First" : "Second") << endl;
		return;
	}
	else {
		cout << ((n - 1) % 2 == 0 ? "First" : "Second") << endl;
		return;
	}

	if (kind == 2) {
		bool ok = true;
		for (size_t i = 2; i < n; i += 2)
		{
			if (s[i - 2] != s[i]) {
				ok = false;
				break;
			}
		}
		if (ok) {
			cout << "Second" << endl;
		}
		else if(n % 2 == 0){

		}
	}
}


int main() {
	Solve();
	return 0;
}



Measured memory_bytes: 6272
n,x = map(int,input().split())
A = list(map(int,input().split()))
B = A.copy()
B = B[::-1]
ans = 0
tmp = 0
for i in range(n-1):
    if A[i] + A[i+1] >x:
        d = (A[i] + A[i+1]) -x
        tmp+= d
        if A[i+1] >=d:
            A[i+1] -=d
        else:
            A[i] = A[i] - (d-A[i+1])
            A[i+1] = 0
A = B
ans = tmp
tmp=0
for i in range(n-1):
    if A[i] + A[i+1] >x:
        d = (A[i] + A[i+1])-x
        tmp+= d
        if A[i+1] >=d:
            A[i+1] -=d
        else:
            A[i] = A[i] - (d-A[i+1])
            A[i+1] = 0

print(min(ans,tmp))


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

int main(){
    vector<vector<int>> c(3, vector<int>(3));
    for(int i=0; i<3; i++){
        for(int j=0; j<3; j++){
            cin >> c[i][j];
        }
    }

    for(int i=1; i<3; i++){
        for(int j=1; j<3; j++){
            if(c[i][j] - c[i][j-1] != c[i-1][j] - c[i-1][j-1]){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    for(int i=1; i<3; i++){
        for(int j=1; j<3; j++){
            if(c[i][j] - c[i-1][j] != c[i][j-1] - c[i-1][j-1]){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

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

int main(){
    int a,b;
    cin>>a>>b;
    if(a<b)
        cout<<"a < b"<<endl;
    else if(a>b)
        cout<<"a > b"<<endl;
    else
        cout<<"a == b"<<endl;
    
}

Measured memory_bytes: 1156
import math
K = int(input())
sumval = 0
for a in range(1, K+1):
    for b in range(1, K+1):
        for c in range(1, K+1):
            f = math.gcd(a,b)
            g = math.gcd(f,c)
            sumval += g
print(sumval)

Measured memory_bytes: 67876
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <cstring>
#include <map>
#include <unordered_map>
#include <tuple>
 
using namespace std;
 
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define umap unordered_map
#define uset unordered_set
#define cina(s, n, a) for(int i = s; i < n; i++) cin >> a[i]
#define couta(s, n, a) for(int i = s; i < n; i++) cout << a[i] << ' '
#define copy(s, n, a, b) for(int i = s; i < n; i++) b[i] = a[i]
#define yesno(ok) cout << (ok ? "YES\n" : "NO\n")
#define mod(a, b) (b + (a % b)) % b
#define MOD (int)1e9 + 7
 
typedef long long ll;
typedef unsigned long long ull;
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;

void add_self (int& a, int b){ a += b; if (a >= MOD) a -= MOD; }
//-------------------------------------------------------------------------------------------------------//

void solve(){
    int n, k;
    cin >> n >> k;
    int cnt = 0;
    while(n > 0){
        n /= k;
        cnt++;
    }
    cout << cnt;
}

int main(){
    ios::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int q = 1;
    //cin >> q;
    for(int i = 1; i <= q; i++){
        solve();
    }
}


Measured memory_bytes: 256
const input = require('fs').readFileSync('/dev/stdin', 'utf8');
const lines = input.trim().split('\n');

while (line = lines.shift()) {
	const [n, max] = line.split(' ').map(Number);

	if (n === 0 && max === 0) {break;}

	const prices = lines.shift().split(' ').map(Number);

	const allSum = [];

	prices.map((priceA, indexA) => {
			prices.map((priceB, indexB) => {
				if (indexA !== indexB) {
					const sum = priceA + priceB;

					if(sum <= max) {
						allSum.push(sum);
					}
				}
			})
		}
	);

	const answer = allSum.sort((a,b) => b - a)[0];

	console.log(answer || 'NONE');
}



Measured memory_bytes: 55728
#include <iostream>
using namespace std;
typedef long long ll;
int main()
{
	ll n;
	cin>>n;
	ll ans=0;
	ll now=100;
	while(now<n){
		ans++;
		ll add=now/100;
		now+=add;
	}
	cout<<ans;
	return 0;
}

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

int f[101][11],p[101][11];

int main(){
  int n;
  cin >> n;
  for(int i=0;i<n;++i){
    for(int j=0;j<10;++j){
      cin >> f[i][j];
    }
  }
  for(int i=0;i<n;++i){
    for(int j=0;j<11;++j){
      cin >> p[i][j];
    }
  }
  int ans=-1001001001;
  for(int bit=1;bit<1<<10;++bit){
    int cal=0;
    for(int i=0;i<n;++i){
      int c=0;
      for(int j=0;j<10;++j){
        if(bit & (1<<j)){
          if(f[i][j])c++;
        }
      }
      cal+=p[i][c];
    }
    ans=max(ans,cal);
  }
  cout << ans << endl;
  return 0;
}


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

#pragma GCC optimize("O2,no-stack-protector,unroll-loops,fast-math")

#define F first
#define S second
#define pb push_back
#define SZ(x) (ll)(x.size())
#define all(x) x.begin(),x.end()
#define MP make_pair

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

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll maxn=1e5+10, maxm=5e3+10, lg=60, mod=1e9+7, inf=1e18;

ll n,m,k,a[maxn],par[maxn][lg+1];

int main(){
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i], par[i][0]=i;
	cin>>m>>k;
	while(m--){
		ll x; cin>>x;
		swap(par[x-1][0],par[x][0]);
	}
	for(int j=1;j<=lg;j++)for(int i=1;i<n;i++) par[i][j]=par[par[i][j-1]][j-1];
	ll nw=a[1];
	for(int i=1;i<n;i++){
		cout<<nw<<endl;
		ll p=i; for(int j=0;j<=lg;j++)if(k>>j&1) p=par[p][j];
		nw+=a[p+1]-a[p];
	}
	cout<<nw<<endl;
	
	return 0;
}






Measured memory_bytes: 52072
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
ll dp[51][5001];
int main()
{
	int num, mok;
	scanf("%d%d", &num, &mok);
	dp[0][2500] = 1;
	for (int i = 0; i < num; i++)
	{
		int z;
		scanf("%d", &z);
		z -= mok;
		for (int j = -2500; j <= 2500; j++)
		{
			if (-2500 <= j + z&&j + z <= 2500)
			{
				dp[i + 1][j + z + 2500] += dp[i][j + 2500];
			}
			dp[i + 1][j + 2500] += dp[i][j + 2500];
		}
	}
	printf("%lld\n", dp[num][2500] - 1);
}

Measured memory_bytes: 2176
H, W = map(int, input().split())
S = [str(input()) for i in range(H)]

L = [[0 for j in range(W)] for i in range(H)]
R = [[0 for j in range(W)] for i in range(H)]
U = [[0 for j in range(W)] for i in range(H)]
D = [[0 for j in range(W)] for i in range(H)]
for i in range(H):
    for j in range(W):
        L[i][j] = 0 if S[i][j] == '#' else 1 + (0 if j == 0 else L[i][j-1])
    for j in range(W-1, -1, -1):
        R[i][j] = 0 if S[i][j] == '#' else 1 + (0 if j == W-1 else R[i][j+1])
for j in range(W):
    for i in range(H):
        U[i][j] = 0 if S[i][j] == '#' else 1 + (0 if i == 0 else U[i-1][j])
    for i in range(H-1, -1, -1):
        D[i][j] = 0 if S[i][j] == '#' else 1 + (0 if i == H-1 else D[i+1][j])
ans = 0
for i in range(H):
    for j in range(W):
        ans = max(ans, L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3)

print(ans)

Measured memory_bytes: 184708
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

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

typedef long long lint;

using namespace std;
lint p=1e9+7;

int main(){
  int N,M;
  cin>>N>>M;
  vector<int> S(N),T(M);
  REP(i,N)cin>>S[i];
  REP(i,M)cin>>T[i];
  vector<vector<lint> > dp(N+1,vector<lint>(M+1,0)),s(N+1,vector<lint>(M+1,0));
  FOR(i,1,N+1)FOR(j,1,M+1){
    if(S[i-1]==T[j-1])dp[i][j]=s[i-1][j-1]+1;
    dp[i][j]%=p;
    s[i][j]=s[i-1][j]+s[i][j-1]-s[i-1][j-1]+dp[i][j];
    s[i][j]+=p;
    s[i][j]%=p;
  }
  cout<<s[N][M]+1<<endl;
  return 0;
}


Measured memory_bytes: 62976
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		//??????????????°
		int[] mountain;
		int taihi;

		//??????
		Scanner sc = new Scanner(System.in);

		mountain = new int[10];
		for(int i=0; i<10; i++){
			mountain[i] = sc.nextInt();
		}


		for(int i=0; i<mountain.length; i++){
			for(int y = i+1; y<mountain.length; y++){
				if(mountain[i]<mountain[y]){
					taihi = mountain[i];
					mountain[i] = mountain[y];
					mountain[y] = taihi;
				}
			}
		}
		for(int i=0; i<3; i++){
			System.out.println(mountain[i]);
		}
	}
}

Measured memory_bytes: 26320
#include <stdio.h>
#define N 1000

int main(){

  int n,m,l,i,j,r;
  int a[N][N];

  scanf("%d",&n);
  for( i = 1 ; i <= n ; i++){
    scanf("%d",&r);
    scanf("%d",&m);
    l = 0;
    for( j = 1 ; j <= m ; j++){
      scanf("%d",&l);
      a[i][l] = 1;
    }
  }

   for( i = 1 ; i <= n ; i++){
    for( j = 1 ; j <= n ; j++){
      if( a[i][j] == 1 ) printf("1");
      else printf("0");
      if(j < n) printf(" ");
    }
    printf("\n");
  }

   return 0;
}



Measured memory_bytes: 2076
n=int(input())-1
csf=[list(map(int,input().split())) for i in range(n)]
# print(csf)
for i in range(n):
    time=0
    for j in range(i,n):
        if time<csf[j][1]:
            time=csf[j][1]+csf[j][0]
        elif time%csf[j][2]!=0:
            time+=csf[j][2]-(time%csf[j][2])+csf[j][0]
        else:
            time+=csf[j][0]
    print(time)
print(0)

Measured memory_bytes: 42220
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll n;
    cin >> n;

    vl a(n);
    rep(i, n) {
        cin >> a[i];
    }

    vl b(n);
    rep(i, n) {
        if(i%2 == 0) {
            b[0] += a[i];
        }
        else {
            b[0] -= a[i];
        }
    }
    
    rep(i, n-1) {
        b[i+1] = 2*a[i] - b[i];
    }

    rep(i, n) {
        cout << b[i] << " ";
    }
    
    cout << endl;
    re0;
}

Measured memory_bytes: 2944