akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>
#include <cassert>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    cin >> n;
    if(n == 2){
        puts("-1");
    }else if(n == 3){
        puts("aa.\n..b\n..b");
    }else if(n == 6){
        puts("aa....\n..b...\n..b...\n...aa.\n.....b\n.....b");
    }else if(n == 7){
        puts("aabb..c\nb..aa.c\nba....d\n.a..aad\n..a..bc\n..a..bc\nccddcc.");
    }else if(n == 11){
        puts("aabb..c....\nb..aa.c....\nba....d....\n.a..aad....\n..a..bc....\n..a..bc....\nccddcc.....\n.......aabd\n.......ccbd\n.......bdaa\n.......bdcc");
    }else {
        vector<string> A, B;
        A = {"aabd", "ccbd", "bdaa", "bdcc"};
        B = {"aabba", "bcc.a", "b..db", "a..db", "abbaa"};
        vector<string> v(n, string(n, '.'));
        for (int i = 0; i*4 <= n; ++i) {
            if((n-i*4)%5==0){
                int j = (n-i*4)/5;
                int cur = 0;
                for (int k = 0; k < i; ++k) {
                    for (int l = 0; l < 4; ++l) {
                        for (int m = 0; m < 4; ++m) {
                            v[cur+l][cur+m] = A[l][m];
                        }
                    }
                    cur += 4;
                }
                for (int k = 0; k < j; ++k) {
                    for (int l = 0; l < 5; ++l) {
                        for (int m = 0; m < 5; ++m) {
                            v[cur+l][cur+m] = B[l][m];
                        }
                    }
                    cur += 5;
                }
                for (int k = 0; k < n; ++k) {
                    cout << v[k] << "\n";
                }
                return 0;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 2176
#include <stdio.h>
#include <string.h>

int
main(int argc, char *argv[])
{
  char str[201];
  scanf("%s", str);
  
  int l = strlen(str);
  
  for(int i = 1; i < l/2; i++){
   char a[100] = {}; char b[100] = {};
    strncpy(a, str + 0, l/2 - i);
    strncpy(b, str + (l/2 - i ), l/2 - i);
    if(strcmp(a,b) == 0) {
      printf("%d\n", l - 2*i);
      break;
    }
  }
  
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
int main()
{
    ft
    ll t,i,j,n,m,x,k;
    cin>>n>>m;
    if(m%2==1)
    {
        k=(n/m);
        cout<<(k*k*k)<<"\n";
    }
    else
    {
        k=(n/m);
        x=(n+(m/2))/m;
        cout<<((x*x*x)+(k*k*k))<<"\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<limits>
#include<stack>
#include<array>
#include<stdio.h>
#include<cstring>

using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<pair<int,int> > vii;
typedef vector<vii> vvii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;

int INF = std::numeric_limits<int>::max();
ll LLINF = 1e15;
int NINF = std::numeric_limits<int>::min();
int MOD = 1e9+7;

int col[] = {0,-1,0,1,1,1,-1,-1};
int row[] = {-1,0,1,0,1,-1,1,-1};

//knight moves
int cc[] = {1,2,2,1,-1,-1,-2,-2};
int rr[] = {-2,-1,1,2,-2,2,1,-1};

int main()
{
    //cout << LLINF ;
    ios::sync_with_stdio(0);
    cin.tie(0);

    int n,m;
    cin >> n >> m;

    vvll dp(n+1,vll(m+1,0));
    dp[1][1] = 1;

    for(int i = 1 ; i <= n; ++i)
        for(int j = 1 ; j <= m ; ++j)
        {
            char c;
            cin >> c;
            if(c == '#')
                dp[i][j] = -1;
        }

    for(int i = 1; i <= n ; ++i)
        for(int j = 1 ; j <= m; ++j)
            if(dp[i][j] == 0)
            {
                dp[i][j] =  (((dp[i-1][j] != -1?dp[i-1][j]:0)%MOD) + ((dp[i][j-1] != -1?dp[i][j-1]:0)%MOD) )%MOD;
            }
    cout << dp[n][m] ;

    return 0;
}

Measured memory_bytes: 11124
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <memory.h>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <ctime>
#include <iostream>
#include <functional>
#include <complex>
#include <stdlib.h>
#include <random>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<pii, int> p3i;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<p3i> v3i;
typedef vector<vii> vvii;
typedef vector<p3i> vp3i;
typedef long double ld;
typedef vector<ld> vld;

#define pb push_back
#define mp make_pair
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define REPD(i, n) for (int (i) = (n) - 1; (i) >= 0; (i)--)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define FORD(i,a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define sz(v) (int)(v).size()
#define all(v) (v).begin(), (v).end()
#define rv(v) reverse(all(v))
#define CL(v, val) memset((v), (val), sizeof((v)))
#define SORT(a) sort(all(a))
#define un(v) SORT(v), (v).resize(unique(all(v)) - (v).begin())
#define eps 1.0e-9
#define X first
#define Y second
#define bit(n) (1 << (n))
#define bit64(n) (ll(1) << (n))
#define sqr(x) ((x) * (x))

int main(void) {
	int a, b;
	scanf("%d%d", &a, &b);
	if (b >= a) {
		printf("unsafe\n");
	}
	else {
		printf("safe\n");
	}
	return 0;
}

Measured memory_bytes: 3676
import math

N,A,B,C = list(map(int,input().split(" ")))
ls = []
for i in range(N):
    ls.append(int(input()))

def fun(rec,a,b,c):
    if rec == N:
        return abs(A-a) + abs(B-b) + abs(C-c)-30 if a*b*c != 0 else 10e20

    ans =  [fun(rec + 1 ,a,b,c) , fun(rec + 1 ,a+ls[rec],b,c) + 10 ,fun(rec + 1 ,a,b+ls[rec],c) + 10 ,fun(rec + 1 ,a,b,c+ls[rec])+10] 
    return min(ans)
print(fun(0,0,0,0))




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


	public class StableSort
	{
		public static void Main(string[] args)
		{
			int count=int.Parse(Console.ReadLine());			
			string data=Console.ReadLine();
			string[] bubble=data.Split();//?????????????????°??????
			string[] selection=data.Split();
			string stable="Stable";
			string temp;
		
			//int[] target=new int[count];
			
			/*
			for(int d=0;d<count;d++)
			{
				target[d]=int.Parse(bubble[d][1].ToString);//????????????????????£??????
			}
			*/
		//bubble sort

			for(int i=0;i<count-1;i++)
			{
				for(int j=count-1;j>i;j--)
				{
					int target=int.Parse(bubble[j][1].ToString());
					int preTarget=int.Parse(bubble[j-1][1].ToString());
					if(target<preTarget)
					{
						temp=bubble[j-1];
						bubble[j-1]=bubble[j];
						bubble[j]=temp;
						
					}
				}				
			}
			
			Console.Write(bubble[0]);
			for(int k=1;k<bubble.Length;k++)
			{
				Console.Write(" "+bubble[k]);
			}
			Console.Write("\r\n");
			
			Console.WriteLine("Stable");
			
			
			//selectionSort
			for(int i=0;i<count-1;i++)
			{  
				int mini=i;
		
				for(int j=i+1;j<count;j++)
				{
					int targetMini=int.Parse(selection[mini][1].ToString());
					int target=int.Parse(selection[j][1].ToString());
					if(target<targetMini)
					{
						mini=j;						
					}					
				}
				if(i!=mini)
				{
					temp=selection[i];
					selection[i]=selection[mini];
					selection[mini]=temp;
				}
			}
			//stable??????
			bool isEqual=bubble.SequenceEqual(selection);
			
			if(isEqual)
			{
				stable="Stable";
			}
			else
			{
				stable="Not stable";
			}
			
			Console.Write(selection[0]);
			for(int k=1;k<selection.Length;k++)
			{
				Console.Write(" "+selection[k]);
			}
			Console.Write("\r\n");
			Console.WriteLine(stable);
		}
	}

Measured memory_bytes: 9308
#abc154 d
n,k=map(int,input().split())
p=list(map(int,input().split()))

r=[0]*(n+1)
s=0
for i in range(n):
    s+=p[i]
    r[i+1]=s


def kitaichi(x):
    return (k+x)/2

ans=0
for i in range(n-k+1):
    kitai=r[i+k]-r[i]
    ans=max(kitai,ans)
print(kitaichi(ans))


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

int main()
{
    int ans = 0;
    string s;
    cin >> s;
    for (int i = 0; i < (s.size() - 1); i++)
    {
        if(s.at(i) != s.at(i+1)) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
 
ll powmod(ll x,ll y){
    ll res=1;
    for(ll i=0;i<y;i++){
        res=res*x%mod;
    }
    return res;
}
int main(){
    ll n;
    cin>>n;
    ll ans=powmod(10,n)-powmod(9,n)-powmod(9,n)+powmod(8,n);
    ans%=mod;
    ans=(ans+mod)%mod;
    cout<<ans<<"\n";
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
int main(){
    string S;
    cin >> S;
    int ans = 0;
    for(int i = 0; i < S.size(); i++){
        if(S.at(i) == '1'){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	for(int i=0;i<5;i++)
	    cout<<s[i];
	cout<<' ';
	for(int i=6;i<13;i++)
	    cout<<s[i];
	cout<<' ';
	for(int i=14;i<19;i++)
	    cout<<s[i];
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <string>
#include <utility>
#include <vector>
#define FOR(i,a,b) for (int i=(a),for_##i##_max=(b);i<=(for_##i##_max);++i)
#define RFOR(i,a,b) for (int i=(a),rfor_##i##_min=(b);i>=(rfor_##i##_min);--i)
#define REP(i,n) for (int i=0,rep_##i##_len=(n);i<(rep_##i##_len);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

namespace { // Basics

template<typename T>
void chmin(T &x, T y) {
  x = std::min(x, y);
}

template<typename T>
void chmax(T &x, T y) {
  x = std::max(x, y);
}

template<typename T>
__attribute__((unused))
const auto minimum = static_cast<T const &(*)(T const &, T const &)>(std::min);

template<typename T>
__attribute__((unused))
const auto maximum = static_cast<T const &(*)(T const &, T const &)>(std::max);

template<typename T>
__attribute__((unused))
T constexpr infty = std::numeric_limits<T>::max / 3;
template<>
__attribute__((unused))
auto constexpr infty<int> = 1'100'100'100;
template<>
__attribute__((unused))
auto constexpr infty<long long int> = 100'500'400'300'200'100LL;

using lli = long long int;
using ld = long double;

} // namespace

using namespace std;

void solve(int m, int n) {
  int constexpr seq_limit = 7369000;
  vector<bool> seq(seq_limit, false);
  int bamboo_cnt = n;
  int y;
  for (y = m; ; ++y) {
    if (seq[y]) { continue; }
    if (bamboo_cnt == 0) { break; }
    --bamboo_cnt;
    for (int z = y; z < seq_limit; z += y) {
      seq[z] = true;
    }
  }
  cout << y << endl;
}

int main() {
  // cout << fixed << setprecision(10);

  int M, N;
  while (cin >> M >> N && M) {
    solve(M, N);
  }
  return 0;
}



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

using namespace std;
using ll = long long;
using ii = pair<ll, ll>;

const int MAX { 200010 };
const ll MOD { 1000000007 }, oo { 1LL << 62 };

ll solve(int N, const vector<ll>& xs)
{
    return 0;
}

int main()
{
    ios::sync_with_stdio(false);

    string S, T;
    cin >> S >> T;

    int ans = 0;

    for (size_t i = 0; i < S.size(); ++i)
        ans += (S[i] != T[i] ? 1 : 0);

    cout << ans << '\n';

    return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    vector<int> check(n, 0);
    int tmp = 1, count = 0;
    while(tmp != 2){
        if(check[tmp - 1] == 1){
            count = -1;
            break;
        }
        check[tmp - 1] = 1;
        tmp = a[tmp - 1];
        count++;
    }
    cout << count << endl;
}

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

#define INF 1 << 29
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)

using namespace std;

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

void gen_sosuu(int sosuu[]){
  REP(i,100010){
    sosuu[i] = true;
  }
  sosuu[0] = false;
  sosuu[1] = false;
  sosuu[2] = true;
  FOR(i,2,sqrt(100000)+1){
    if(sosuu[i] == false) continue;
    for(int j = 2; i*j<=100000;j++){
      //printf("%d %d %d\n",i*j,i,j);
      sosuu[i*j] =false;
    }
  }
}

int n;
int ma=0,x=0;
string s;

int main(){
  cin >> n >> s;
  REP(i,n){
    if(s[i] == 'I'){
      x++;
    }
    if(s[i] == 'D'){
      x--;
    }
    ma = max(ma,x);
  }
  cout << ma <<endl;
}


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

vector<vector<int>>G;

void bfs(vector<int>&tmp){
    queue<int>  que;
    que.push(0);
    while(!que.empty()){
        int now = que.front();
        que.pop();
        rep(i, G[now].size()){
            int next = G[now][i];
            if(tmp[next])   continue;
            que.push(next);
            tmp[next] = now+1;
        }
    }
}

int main(){
    int n,m;    cin >> n >> m;
    G.resize(n);
    rep(i, m){
        int a, b;   cin >> a >> b;
        --a;    --b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    vector<int>ans(n);
    bfs(ans);
    rep(i, n){
        if(!i){
            cout << "Yes" << endl;
        }else{
            cout << ans[i] << endl;
        }
    }
}


Measured memory_bytes: 10044
from collections import deque


def nth_ll(k):
    if k < 10:
        return k
    queue = deque([i for i in range(1, 10)])
    cnt = 9
    while True:
        n = queue.popleft()
        for i in range(-1 if n % 10 != 0 else 0, 2 if n % 10 != 9 else 1):
            queue.append(10 * n + n % 10 + i)
            cnt += 1
            if cnt == k:
                return queue.pop()

print(nth_ll(int(input())))


Measured memory_bytes: 6092
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i <b; i++)
typedef long long ll;
#define int ll
typedef vector<int> vi;
typedef vector<long long> vl;
typedef pair<int,int> pi;
#define trace(x) cout<<#x<<"="<<x<<"\n";
#define llp 1000000007
#define mod 1000000007

template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
    return os << "(" << p.first << ", " << p.second << ")";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "{";
    typename vector< T > :: const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "[";
    typename set< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
    os << "[";
    typename map< F , S >::const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << it -> first << " = " << it -> second ;
    }
    return os << "]";
}

#define deb(x) cerr << #x << " = " << x << endl;


int32_t main(){
	ios::sync_with_stdio(false);
    int n;
    cin>>n;
    string s;
    cin>>s;
    deque<pair<char, int> >Se;
    for(int i=0;i<n;i++){
        if(s[i]=='('){
            if(Se.size()==0){
                Se.PB({'(',1});
            }
            else{
                Se.PB({'(',Se[Se.size()-1].S+1});
            }
        }
        else{
            if(Se.size()==0){
                Se.PB({'(',1});
                Se.PB({')',0});
            }
            else{
                if(Se[Se.size()-1].S==0){
                    Se.push_front({'(',1});
                    Se.PB({')',0});
                }
                else{
                    Se.PB({')',Se[Se.size()-1].S-1});
                }
            }
        }
    }
    if(Se[Se.size()-1].S!=0){
        int no=Se[Se.size()-1].S;
        for(int i=0;i<no;i++){
            Se.PB({')',Se[Se.size()-1].S-1});
        }
    }
    for(int i=0;i<Se.size();i++){
        cout<<Se[i].F;
    }
    cout<<"\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const long long INF = 1001001001;
const long long MOD = 1000000007;
const double EPS = 1e-10;

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

    int num[4]={6000,4000,3000,2000};
    for(int i=0;i<4;i++){
        int t,n;
        cin>>t>>n;
        t--;
        cout<<n*num[t]<<endl;
    }
}


Measured memory_bytes: 3172
B[11],i;C(n,l,r,t){t=B[10-n];return!n--||t>l&&C(n,t,r)||t>r&&C(n,l,t);}main(){for(;~scanf("%*d%d"+!!*B*3,B+i);)i++-9||puts(C(10,0,i=0)?"YES":"NO");}

Measured memory_bytes: 0
#include <cstdio>
#include <string>
#include <cmath>
#include <string>
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>
#include <iomanip>
#include <tuple>
#include <queue>
#include <numeric>
using namespace std;
typedef long long ll;
#define rep(i, a, n) for (int i=a;i<n;++i)
#define repeq(i, a, n) for(int i=a;i<=n;++i)
#define repi(m, itr) for (auto itr = m.begin();itr != m.end();++itr)
#define per(i, a, n) for (int i=n-1; i>=a;--i)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()

// 
int N, T;
int c[1010], t[1010];
int ans = 10000;

int main(){
    cin >> N >> T;
    rep(i, 0, N){
        cin >> c[i] >> t[i];
        if(c[i]<=ans && t[i]<=T){
            ans = c[i];
        }
    }
    if(ans==10000){
        cout << "TLE" << endl;
    }else{
        cout << ans << endl;
    }
    return 0;
}




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

#define sz(a) int((a).size())
#define all(c) c.begin(), c.end()
#define ll long long
#define pb push_back
#define zoom                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define pl pair<ll, ll>
#define MOD 1000000007
#define endl "\n"
#define ff first
#define ss second
#define trace1(x) cerr << #x << ": " << x << endl
#define trace2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl
#define trace3(x, y, z) cerr << #x << ":" << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl
#define trace4(a, b, c, d) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl
#define trace5(a, b, c, d, e) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl
#define trace(v)                                   \
    for (auto it = v.begin(); it != v.end(); it++) \
        cerr << *it << " ";                        \
    cerr << endl;
#define tr(container, it) \
    for (typeof(container.begin()) it = container.begin(); it != container.end(); it++)

#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef vector<vi> vvi;

void solve()
{
    int a,b,c;
    cin>>a>>b>>c;

    int k;
    cin>>k;

    while(a>=b && k>0){
        b*=2;
        k--;
    }
    while(b>=c && k>0){
        c*=2;
        k--;
    }

    if(a<b && b<c){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

int main()
{
    zoom;
    ll t=1;
    //cin >> t;

    while (t--)
    {
        solve();
    }
}

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

int main() {
	
	int h,w;
	cin >> h >> w;
	vector<vector<char>> a(h,vector<char>(w));
	for(auto &i:a) for(auto &j:i) cin >> j;
	int m=0;
	for(int i=0; i<h; i++){
		for(int j=0; j<w; j++){
			if(a.at(i).at(j)=='.'){
				queue <pair<int,int>> q;
				vector<vector<int>> c(h,vector<int>(w,-1));
				c.at(i).at(j)=0;
				int m1=0;
				q.push(make_pair(i,j));
				while(!q.empty()){
					int k = q.front().first, l = q.front().second;
					q.pop();
					if(k<h-1 && a.at(k+1).at(l) =='.' && c.at(k+1).at(l)==-1){
						c.at(k+1).at(l) = c.at(k).at(l) + 1;
						q.push(make_pair(k+1,l));
					}
					if(k>0 && a.at(k-1).at(l) =='.' && c.at(k-1).at(l)==-1){
						c.at(k-1).at(l) = c.at(k).at(l) + 1;
						q.push(make_pair(k-1,l));
					}
					if(l<w-1 && a.at(k).at(l+1) =='.' && c.at(k).at(l+1)==-1){
						c.at(k).at(l+1) = c.at(k).at(l) + 1;
						q.push(make_pair(k,l+1));
					}
					if(l>0 && a.at(k).at(l-1) =='.' && c.at(k).at(l-1)==-1){
						c.at(k).at(l-1) = c.at(k).at(l) + 1;
						q.push(make_pair(k,l-1));
					}
					m1=c.at(k).at(l)+1;
				}
				m = max(m,m1);
			}
		}
	}
	cout << m-1 << endl;
}

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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

int main() {
  in(int, n, k);
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  for (int i = k; i < n; ++i) {
    if (a[i] > a[i - k]) {
      out("Yes");
    } else {
      out("No");
    }
  }
}


Measured memory_bytes: 4056
N = int(input())

def cnt(x, y):
    return y - x + 1

for i in range(1, 7):
    if 10 ** (i - 1) <= N < 10 ** i:
        dig = i
        # print(dig)
        if dig == 1:
            print(cnt(1, N))
        elif dig == 2:
            print(cnt(1, 9))
        elif dig == 3:
            print(cnt(1, N) - cnt(10, 99))
        elif dig == 4:
            print(cnt(1, N) - cnt(10, 99) - cnt(1000, N))
        elif dig == 5:
            print(cnt(1, N) - cnt(10, 99) - cnt(1000, 9999))
        elif dig == 6:
            print(cnt(1, N) - cnt(10,99) - cnt(1000,9999) - cnt(100000, N))


Measured memory_bytes: 9100
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  auto a = readln.chomp.to!int;
  auto b = readln.chomp.to!int;
  auto h = readln.chomp.to!int;
  writeln((a+b)*h/2);
}


Measured memory_bytes: 256
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(1000000)


# Debug output
def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))


# Binary converter
def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]


def gcd(n, m):
    if n % m == 0:
        return m
    else:
        return gcd(m, n % m)


def gcd_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = gcd(v, L[i])

    return v


def lcm(n, m):
    return (n * m) // gcd(n, m)


def lcm_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = lcm(v, L[i])

    return v


# Width First Search (+ Distance)
def wfs_d(D, N, K):
    """
    D: 隣接行列(距離付き)
    N: ノード数
    K: 始点ノード
    """

    dfk = [-1] * (N + 1)
    dfk[K] = 0

    cps = [(K, 0)]
    r = [False] * (N + 1)
    r[K] = True
    while len(cps) != 0:
        n_cps = []
        for cp, cd in cps:
            for i, dfcp in enumerate(D[cp]):
                if dfcp != -1 and not r[i]:
                    dfk[i] = cd + dfcp
                    n_cps.append((i, cd + dfcp))
                    r[i] = True

        cps = n_cps[:]

    return dfk


# Depth First Search (+Distance)
def dfs_d(v, pre, dist):
    """
    v:  現在のノード
    pre: １つ前のノード
    dist: 現在の距離

    以下は別途用意する
    D: 隣接リスト(行列ではない)
    D_dfs_d: dfs_d関数で用いる，始点ノードから見た距離リスト
    """

    global D
    global D_dfs_d

    D_dfs_d[v] = dist

    for next_v, d in D[v]:
        if next_v != pre:
            dfs_d(next_v, v, dist + d)

    return


def sigma(N):
    ans = 0
    for i in range(1, N + 1):
        ans += i
    return ans


def comb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2, r + 1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p - 1, r, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def bisearch(L, target):
    low = 0
    high = len(L) - 1
    
    while low <= high:
        mid = (low + high) // 2
        guess = L[mid]
        if guess == target:
            return True
        elif guess < target:
            low = mid + 1
        elif guess > target:
            high = mid - 1
    if guess != target:
        return False

# --------------------------------------------

dp = None


def main():
    A, B, C = input().split()
    
    if A[-1] == B[0] and B[-1] == C[0]:
        print("YES")
    else:
        print("NO")


main()


Measured memory_bytes: 4692
import sys

a, b, k = map(int, sys.stdin.readline().split())

if k-a>0:
  if b - (k - a) <= 0:
    b = 0
    a = 0
  else:
    b = b - (k - a)
    a = 0
else:
  a = a - k
  b = b
print(a, b)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
 
const int maxn = 2e5 + 20;

int cnt, n, k, a[maxn], ans;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> n;
	n *= 2;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	sort (a, a + n);
	reverse (a, a+n);
	long double res=  0;
	for (int i = 0; i < n; i++)
		res += (long double)(n - i - 1) / (n-1) * a[i];
	cout << fixed << setprecision(9) << res << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <functional>
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int n;
    cin >> n;

    vector<int> vec(n);
    for (int i = 0; i < n; ++i)
        cin >> vec[i];

    sort(vec.begin(), vec.end(), greater<int>());

    int max = 0;
    int prev = 101;
    for (int v : vec) {
        if (prev > v)
            ++max;

        prev = v;
    }

    cout << max << '\n';
}


Measured memory_bytes: 256
N=int(input())
A=[int(input()) for i in range(N)]
ans=sum(A)
if N==1:
  print(A[0]//2)
  exit()
for i in range(N-1):
  if A[i]%2==A[i+1]%2:
    A[i]=0
    A[i+1]=0
  elif A[i]%2==1 and A[i+1]==0:
    A[i]=1
  else:
    A[i]=0
    A[i+1]=1    
for i in range(N):
  ans-=A[i]
print(ans//2)
  

Measured memory_bytes: 50520
#include<vector>
#include<iostream>
#include<algorithm>
using namespace std;
#define MAX_N 101
#define MAX_W 100001
long long dp[MAX_N][MAX_W];

int main()
{
	long long N;
	cin >> N;
	long long W;
	cin >> W;
	vector<vector<long long>>v(N, vector<long long>(2));
	for (long long i = 0; i < N; i++)
	{
		cin >> v[i][0] >> v[i][1];

	}
	for (long long i = 0; i <= W; i++)
	{
		dp[0][i] = 0;
	}
	for (long long i = 0; i < N; i++)
	{
		for (long long j = 0; j <= W; j++)
		{
			if (j < v[i][1])
			{
				dp[i + 1][j] = dp[i][j];
			}
			else
			{
				dp[i + 1][j] = max(dp[i][j], dp[i][j - v[i][1]] + v[i][0]);
			}
		}
	}
	cout << dp[N][W] << endl;
	return 0;






}


Measured memory_bytes: 11460
#include <bits/stdc++.h>
#include <regex>
#ifdef _DEBUG
#include "debug.h"
#endif
#define int ll
#define FOR(i, s, e) for (int i = int(s); i < int(e); ++i)
#define REP(i, e) FOR(i, 0, e)
#ifdef int
#define INF (LLONG_MAX / 2)
#else
#define INF (INT_MAX / 2)
#endif
#define LINF (LLONG_MAX / 2)
#define EPS (1.0e-9)
#define mkpr make_pair
#define mktp make_tuple
#define var auto
#define self (*this)
#define in :
#define True true
#define False false
#define None nullptr
#define is ==
#define is_not !=
#define AST(exp, msg) if(!(exp)){EPR((msg))} assert((exp));
#define TAST(exp, msg) if(!(exp)){EPR((msg))} while(!(exp)){}
#define EPR(msg) cerr << (msg) << endl;
#define DBLEQ(a, b) (abs((a) - (b)) < EPS)
#define fst first
#define scd second
#define out &
#define tv(tp, i) get<i>(tp)
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vl = vector<ll>; using vvl = vector<vl>;
using vb = vector<bool>; using vvb = vector<vb>; using vd = vector<double>; using vvd = vector<vd>;
using vc = vector<char>; using vvc = vector<vc>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>; using pdd = pair<double, double>; using psl = pair<string, ll>;
using tiii = tuple<int, int, int>; using tlll = tuple<ll, ll, ll>;
const int MGN = 10; const int ARYSZ_MAX = (int)1e7;



int32_t main(int32_t argc, char* argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef _DEBUG
    vs args(argv, argv+argc);
    string sample = make_sample(args, 3);
    ifstream ifs(sample); cin.rdbuf(ifs.rdbuf());
#endif


    int X,Y, A,B,C; cin>>X>>Y>>A>>B>>C;
    vl P(A); REP(i,A) cin>>P[i];
    vl Q(B); REP(i,B) cin>>Q[i];
    vl R(C); REP(i,C) cin>>R[i];

    sort(P.rbegin(), P.rend());
    sort(Q.rbegin(), Q.rend());

    priority_queue<ll> pq_r, pq_g, pq_t;
    REP(i,X) pq_r.push(P[i]);
    REP(i,Y) pq_g.push(Q[i]);
    REP(i,C) pq_t.push(R[i]);
    pq_r.push(-1);
    pq_g.push(-1);
    pq_t.push(-1);

    ll ans = 0;
    //int x=0, y=0;
    REP(i, X+Y) {
        ll rd = pq_r.top();
        ll gr = pq_g.top();
        ll tr = pq_t.top();

        if (rd >= max(gr, tr)) {
            ans += rd;
            pq_r.pop();
        } else if (gr >= max(rd, tr)) {
            ans += gr;
            pq_g.pop();
        } else {
            ans += tr;
            pq_t.pop();
        }
    }

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 5620
n, m = list(map(int, input().split(' ')))


# 再帰処理：関数の中でその関数自身が呼び出されること。→ 繰り返し処理の実装が可能
def conversion(_n, _m):
    if int(_n / _m):
        return conversion(int(_n / _m), _m) + str(_n % _m)
    return str(_n % _m)


digit = (conversion(n, m))
print(len(digit))


Measured memory_bytes: 2940
import sys
import math
import copy
from typing import Tuple, List, Union
input = sys.stdin.readline


def binary_search(t, S):
    left = 0
    right = len (S)
    while left < right:
        mid = int ((left + right) / 2)
        if S [mid] == t:
            return True
        elif t < S[mid]:
            right = mid
        else:
            left = mid + 1
    return False


def main():
    n = int(input())
    S = tuple(map(int, input().split()))
    q = int(input())
    T = tuple(map(int, input().split()))
    return [binary_search(t, S) for t in T]



if __name__ == '__main__':
    print(sum(main()))



Measured memory_bytes: 18080
#include <bits/stdc++.h>
using namespace std;
 
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx,avx2,fma")
 
typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define MP make_pair
#define PB push_backpostdoctoral
#define X first
#define Y second
 
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cerr << #a << " = " << a << endl;
 
template<typename T> void setmax(T& x, T y) {x = max(x, y);}
template<typename T> void setmin(T& x, T y) {x = min(x, y);}
 
const double PI = acos(-1.0);
const LL INF = 1e9;
const LL LINF = INF * INF;

int main()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  	
  	string s;
  	cin >> s;
	
	for(auto& i: s) if (i == '?') i = 'D';
	cout << s << endl;
	return 0;
	
	int ans = 0;
	for(auto i: s) ans += i == 'D';
	FOR(i, 0, SZ(s) - 1) ans += s[i] == 'P' && s[i + 1] == 'D';
	cout << ans << endl;  	
  	
    cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
    return 0;
}


Measured memory_bytes: 3744
#include <cstdio>
#include <cassert>
#include <queue>
#include <deque>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <set>
#include <cstdlib>
#include <string>
#include <unordered_map>
#include <sstream>
using namespace std;

typedef long long int lli;
typedef pair<int, int> pii;
typedef unsigned char byte;
typedef unsigned int uint;
typedef unsigned long long int ulli;

int mat[220][220], chk[220];
pii pt[220];

#define red (pt)
#define blue (pt+n)

int main() {
    int i, j, n;
    scanf("%d", &n);
    for (i=1; i<=n; ++i) {
        scanf("%d%d", &pt[i].first, &pt[i].second);
        mat[0][i] = 1;
        mat[i+n][2*n+1] = 1;
    }
    for (i=1; i<=n; ++i) {
        scanf("%d%d", &pt[i+n].first, &pt[i+n].second);
    }
    for (i=1; i<=n; ++i) {
        for (j=1; j<=n; ++j) {
            if (red[i].first < blue[j].first && red[i].second < blue[j].second) {
                mat[i][n+j] = 1;
            }
        }
    }
    int c = 0;
    while (1) {
        queue<int> q;
        q.push(0);
        memset(chk, -1, sizeof(int) * 220);
        while (!q.empty()) {
            int f = q.front();
            q.pop();
            int i;
            for (i=0; i<=2*n+1; ++i) {
                if (mat[f][i] > 0 && chk[i] < 0) {
                    chk[i] = f;
                    q.push(i);
                }
            }
        }
        if (chk[2*n+1] < 0) break;
        int t = 2*n+1;
        while (t) {
            mat[chk[t]][t] = 0;
            mat[t][chk[t]] = 1;
            t = chk[t];
        }
        ++c;
    }
    printf("%d\n", c);
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define inf 1000000000
#define pb push_back
#define mp make_pair
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define yoi cout<<"yo"<<endl;
#define debug(i) cout<<i<<endl;
const int mod=1e9 +7;
int main(){
IOS;
lli a,b,c,d;
cin>>a>>b>>c>>d;
lli x=(b/c)-((a-1)/c);
lli y=(b/d)-((a-1)/d);
lli gcd=__gcd(c,d);
gcd=(c*d)/gcd;
lli z=(b/(gcd))-((a-1)/(gcd));
lli ans=b-a+1-x-y+z;
cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>

using namespace std;

vector<int> primes;

void prime_list(){
  primes.push_back(2);
  for(int i=3;i<=100009;i+=2){
    bool prime=true;
    for(int j=0;primes[j]*primes[j]<=i;j++){
      if(i%primes[j]==0){
        prime=false;
        break;
      }
    }
    if(prime){
      primes.push_back(i);
    }
  }
}

int main(){
  int n;
  cin >> n;
  prime_list();
  cout << n << ':';
  int prime_idx = 0;
  while(n>1){
    while(n%primes[prime_idx]==0){
      n/=primes[prime_idx];
      cout << ' ' << primes[prime_idx];
    }
    prime_idx++;
    if(prime_idx == primes.size()){
      cout << ' ' << n;
      break;
    }
  }
  cout << endl;
}


Measured memory_bytes: 3272
#include <iostream>
#include <vector>

using namespace std;

int main() {
  // 入力
  int H, W;
  vector<string> field;
  cin >> H >> W;
  field.resize(H);
  for(int i=0; i<H; i++) cin >> field[i];

  // 行方向の事前計算
  int rowIndex[H][W];
  int rowN[H * W];
  int _index=0, count=0;
  for(int i=0; i<H; i++) {
    for(int j=0; j<W+1; j++) {
      if(j==W || field[i][j]=='#') {
        // マップの端か、壁マス
        rowN[_index++] = count;
        count = 0;
      } else {
        rowIndex[i][j] = _index;
        count++;
      }
    }
  }

  // 列方向の事前計算
  int colIndex[H][W];
  int colN[H * W];
  _index=0, count=0;
  for(int j=0; j<W; j++) {
    for(int i=0; i<H+1; i++) {
      if(i==H || field[i][j]=='#') {
        // マップの端か、壁マス
        colN[_index++] = count;
        count = 0;
      } else {
        colIndex[i][j] = _index;
        count++;
      }
    }
  }

  // 照らせる最大値を求める
  int ans = 0;
  for(int i=0; i<H; i++) {
    for(int j=0; j<W; j++) {
      if(field[i][j] == '#') continue;
      int lightRowN = rowN[rowIndex[i][j]];
      int lightColN = colN[colIndex[i][j]];
      int lightSum = lightRowN + lightColN - 1; // 光源マスが重複するので-1
      ans = max(ans, lightSum);
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 66816
#include <iostream>

using namespace std;

int main()
{
    int n, p;
    cin >> n;
    int x[n], y[n];
    int sum = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> x[i];
    }
    for (int i = 0; i < n; i++)
    {
        cin >> y[i];
    }
    for (int i = 0; i < n; i++)
    {
        if (x[i] - y[i] > 0)
            sum += (x[i] - y[i]);
    }
    cout << sum;
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;

int main() {
	string s;
	cin >> s;
	VS a = { "KIHBR","AKIHBR","KIHABR","KIHBAR","KIHBRA","AKIHABR","AKIHBAR","AKIHBRA","KIHABAR","KIHABRA","KIHBARA","AKIHABAR","AKIHABRA","AKIHBARA","KIHABARA","AKIHABARA" };
	bool flag = false;
	rep(i, 16) {
		if (s == a[i])flag = true;
	}
	puts(flag ? "YES" : "NO");
}

Measured memory_bytes: 256
using System;

namespace Repeat
{
    class Program
    {
        static void Main(string[] args)
        {

            string inD0 = Console.ReadLine();
            int N = int.Parse(inD0);
            string charD;
            charD = "";

            for (int i=0; i < N ; i++)
            {
                charD += "ACL";
            }
            
            Console.WriteLine(charD);
        }
    }
}


Measured memory_bytes: 27316
import sys
N, K = map(int, input().split())
Xs = [int(s) for s in input().split()]

result = sys.maxsize
for i in range(len(Xs) - K + 1):
  a = abs(0 - Xs[i]) + Xs[i + K - 1] - Xs[i]
  b = abs(0 - Xs[i + K - 1]) + Xs[i + K - 1] - Xs[i]
  shortest = min(a, b)
  if shortest < result:
    result = shortest
    
print(result)
  

Measured memory_bytes: 14384
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<iomanip>
#include<map>
#include<queue>
#include<cmath>
#include<cstdio>

#define rep(i,n) for(int i=0; i<(n); ++i)
#define pai 3.1415926535897932384

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

int main(int argc, const char * argv[]) {
    string s;
    int c=0;
    int Ans=0;
    cin >> s;
    
    for(int i=0; i<3; i++){
        if(s[i] == 'R') c++;
        else c=0;
        
        if(c > Ans) Ans=c;
    }
    
    cout << Ans << endl;
    
    return 0;
}


Measured memory_bytes: 3156
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a;}

int main() {
  // Brute
  int K;
  cin >> K;
  ll ans = 0;
  for (int i = 1; i <= K; i++) {
    for (int j = 1; j <= K; j++) {
      int x = gcd(i, j);
      for (int k = 1; k <= K; k++) {
        ans += gcd(x, k);
      }
    }
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <utility>
#define mp make_pair
#define maxn 105
using namespace std;
const int inf = 0x3f3f3f3f;
const int neginf = 0xc0c0c0c0;
typedef long long ll;
typedef pair<int,int> P;
set <string> lst;
int n;
string s[maxn];
int main(){
	ios::sync_with_stdio(false);
	cin >> n;
	bool ok = true;
	for(int i=1;i<=n;i++){
		cin >> s[i];
		if(i > 1){
			if(lst.find(s[i]) != lst.end()) ok = false;
			if(s[i][0] != s[i - 1][(int)s[i - 1].size() - 1]) ok = false;
		}
		lst.insert(s[i]);
	}
	if(ok) puts("Yes");
	else puts("No");
	return 0;
}


Measured memory_bytes: 256
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

template<class T>
vector<T> divisor(T n) {
	vector<T> res;
	for (T i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			res.emplace_back(i);
			if (i * i != n) res.emplace_back(n / i);
		}
	}
	sort(res.begin(), res.end());
	return res;
}

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

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	lint N;
	cin >> N;

	auto div = divisor(N);

	lint ans = LINF;
	for (const auto &e : div) chmin(ans, e + N / e - 2);

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
using namespace std;
typedef long long ll;
typedef long double ld;
ll mod=1e9+7;

ll power(ll a,ll b){
    ll res=1;
    while(b){
        if(b&1)res=res*a %mod;
        a=a*a %mod;
        b/=2;
    }
    return res;
}

ll c(ll a,ll b){
    ll res=1;
    for(ll i=1;i<=b;i++)res=res*(a+1-i)%mod *power(i,mod-2)%mod;
    return res;
}

int main(){
    ll x,y;cin>>x>>y;
    if((x+y)%3!=0){cout<<0;return 0;}
    ll m=(2*x-y)/3,n=(2*y-x)/3;
    if(m<0||n<0){cout<<0;return 0;}
    if(m==0||n==0){cout<<1;return 0;}
    cout<<c(m+n,min(n,m))%mod;
}

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

using namespace std;

#define rep(i, n) for(int i=0; i<(int)(n); i++)

int sum_digit(int x){
    int sum = 0;
    while(x > 0){
        sum += x % 10;
        x /= 10;
    }
    return sum;
}

int main() {
    int X;
    cin >> X;

    int sum = sum_digit(X);
    if(X % sum == 0){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
t1,t2 = map(int, input().split())
a1,a2 = map(int, input().split())
b1,b2 = map(int, input().split())

d1=(a1-b1)*t1
d2=(a2-b2)*t2


if abs(d1) == abs(d2):
    print("infinity")
    exit()

if abs(d1) > abs(d2) or d1*d2>0:
    print(0)
    exit()

dif = abs(d2) - abs(d1)

ans=2*(abs(d1)//dif)
if abs(d1)%dif != 0:
    ans+=1
print(ans)

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ll long long
const int INF = 1e9 + 7;

using namespace std;

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

    int n,k;
    cin >> n >> k;
    vector<int> pattern;
    REP(i,30) if(k >> i & 1) pattern.push_back(i);

    vector<ll> ans(pattern.size(),0);
    ll ansk=0;
    REP(i,n){
        int a,b;
        cin >> a >> b;
        if(k == (k|a)){
            ansk += b;
        }
        REP(j,pattern.size()){
            if(((k>>pattern[j])-1)==(((k>>pattern[j])-1)|(a>>pattern[j]))){
                ans[j]+=b;
            }
        }
    }

    ans.push_back(ansk);
    cout << *max_element(ans.begin(),ans.end()) << endl;
    return 0;
}


Measured memory_bytes: 384
import java.math.*

fun main(args: Array<String>) {
    val N = readInputLine().toInt()
    
    val points = mutableListOf<Triple<Int, Int, Int>>()
    
    var ref = Triple(-1, -1, -1)
    
    for (i in 1..N) {
        val (x, y, h) = readInputLine().split(" ").map{it.toInt()}
        val point = Triple(x, y, h)
        points.add(point)
        if (ref.first == -1 && h != 0) {
            ref = point
        }
    }
    
    for (x in 0..100) {
        for (y in 0..100) {
            val h = ref.third + Math.abs(x - ref.first) + Math.abs(y - ref.second)
            
            var ok = true
            
            for (p in points) {
                if (p.third != Math.max(h - Math.abs(x - p.first) - Math.abs(y - p.second), 0)) {
                    ok = false
                    break
                }
            }
            
            if (ok) {
                println("$x $y $h")
                return
            }
        }
    }
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 37568