akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#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;

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

    bitset<10> d;
    for(int i=0; i<k; ++i){
        int a;
        cin >> a;
        d[a] = true;
    }

    for(;;){
        string s = to_string(n);
        bool ok = true;
        for(char c : s){
            if(d[c-'0'])
                ok = false;
        }
        if(ok)
            break;
        ++ n;
    }
    cout << n << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <vector>
 
using namespace std;
 
////////////////////////?????§???????§?//////////////////////////////////////
#define MAX_V 1000 * 2 + 16
int V;                 // ??¶?????°
vector<int> G[MAX_V];    // ???????????\??¨
int match[MAX_V];      // ??????????????¶???
bool used[MAX_V];      // DFS?????¨??°??????????????°
 
// ??????????¢???????????????\u???v??????
void add_edge(int u, int v)
{
	G[u].push_back(v);
	G[v].push_back(u);
}
 
// ??????DFS???????¢???????
bool dfs(int v)
{
	used[v] = true;
	for (vector<int>::iterator it = G[v].begin(); it != G[v].end(); ++it)
	{
		int u = *it, w = match[u];
		if (w < 0 || !used[w] && dfs(w))
		{
			match[v] = u;
			match[u] = v;
			return true;
		}
	}
 
	return false;
}
 
// ?±??§£?????????????????§??????
int bipartite_matching()
{
	int res = 0;
	memset(match, -1, sizeof(match));
	for (int v = 0; v < V; ++v)
	{
		if (match[v] < 0)
		{
			memset(used, 0, sizeof(used));
			if (dfs(v))
			{
				++res;
			}
		}
	}
 
	return res;
}
 
void clear()
{
	for (int i = 0; i < V; ++i)
	{
		G[i].clear();
	}
}
 
///////////////////////////////?????§?????????/////////////////////////////////////
#define  MAX_N 100
#define  MAX_L 1000
#define  INF 0x3f3f3f3f
 
int distance_matrix[MAX_N][MAX_N];		// ????????´?????????
int p[MAX_L], t[MAX_L];					// ?????´???????????¶???
 
bool update_min(int& v, const int& t)
{
	if (t < v)
	{
		v = t;
		return true;
	}
	return false;
}
 
///////////////////////////SubMain//////////////////////////////////
int main(int argc, char *argv[])
{
	int N, M, L;
	while (scanf("%d%d%d", &N, &M, &L) != EOF && N)
	{
		V = L * 2;
		clear();
		memset(distance_matrix, INF, sizeof(distance_matrix));
 
		for (int _ = 0; _ < M; ++_)
		{
			int u, v, d;
			scanf("%d%d%d", &u, &v, &d);
			distance_matrix[u][v] = distance_matrix[v][u] = d;
		}
 
		for (int i = 0; i < L; ++i)
		{
			scanf("%d%d", p + i, t + i);
		}
 
		// warshall_floyd ????????´?????????
		for (int k = 0; k < N; ++k) 
		{
			distance_matrix[k][k] = 0;
			for (int i = 0; i < N; ++i) 
			{
				for (int j = 0; j < N; ++j) 
				{
					update_min(distance_matrix[i][j], distance_matrix[i][k] + distance_matrix[k][j]);
				}
			}
		}
 
		for (int i = 0; i < L; ++i) 
		{
			for (int j = 0; j < L; ++j)  
			{
				if (i != j && t[i] + distance_matrix[p[i]][p[j]] <= t[j])
				{
					add_edge(2 * i, 2 * j + 1);	// ?????\??¨i????????????j???????????????
				}
			}
		}
 
		printf("%d\n", L - bipartite_matching());
	}
	return 0;
}
///////////////////////////End Sub//////////////////////////////////

Measured memory_bytes: 11008
#include <iostream>
using namespace std;
int main(){
    int n, m;
    int a[55], b[55];
    cin >> n >> m;
    for(int i = 0; i < m; i++){
        cin >> a[i] >> b[i];
        a[i] -= 1;
        b[i] -= 1;
    }

    int ans[55];
    for(int i = 0; i < n; i++){
        ans[i] = 0;
    }

    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            if(a[j] == i || b[j] == i){
                ans[i] += 1;
            }
        }
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
int main() {
  int N,L;
  string O="";
  cin>>N>>L;
  vector<string> S(N);
  	for(int i=0;i<N;i++){
      cin>>S.at(i);
    }
    
    sort(S.begin(),S.end());
  	for(int i=0;i<N;i++){
      O+=S.at(i);
    }
  cout<<O<<endl;
}

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

typedef long long ll;

#define F first 
#define S second 
#define PB push_back
#define MP make_pair 
#define rep(i,a,b) for (ll i=a;i<b;i++)
const ll INF = 1LL << 60;

typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<ll> vl;
typedef pair<ll,ll> pl;


int main()
{
    ll n,k;
    cin>>n>>k;

    ll cnt=0;
    while(n>0) {
        n = n/k;
        cnt++;
    }
    cout<<cnt<<endl;

    return 0; 
}



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

#define ld long double
#define ll long long int
#define ull unsigned long long int
#define vi vector<int>
#define vl vector<ll>
#define vvi vector< vector<int> >
#define vvl vector< vector<ll> >
#define repd(i, a, b) for (int i=(a);i<(b);i++)
#define rep(i, n) repd(i,0,n)
#define ALL(v) v.begin(), v.end()
#define INF 1e9

using namespace std;

/**
 * calculate GCD(greatest common divisor)
 * @param a
 * @param b
 * @return
 */
unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

/**
 * change minimum
 * @tparam T
 * @param a
 * @param b
 * @return bool
 */
template<class T>
inline bool changeMinimum(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

/**
 * change maximum
 * @tparam T
 * @param a
 * @param b
 * @return bool
 */
template<class T>
inline bool changeMaximum(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

/**
 * output answer
 * @tparam T
 * @param answer
 * @return
 */
template<typename T>
T output(T answer) {
    cout << answer << endl;
    return 0;
}

/** ----from here ---------------------------------------------------------- */

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


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define kika "kika"
#define tam 60
#define ll long long
#define ii pair <int, int>
#define dl pair <ll, ll>
#define vi vector <int>
#define vl vector <ll>
#define vii vector <ii>
#define graph vector <vi>

using namespace std;

	string c[tam];
	int t[tam];

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

	int n;
	cin >> n;
	string in1;
	int in2;
	for (int i = 0; i < n; ++i)
	{
		cin >> in1 >> in2;
		c[i] = in1;
		t[i] = in2;
	}
	cin >> in1;
	int i;
	for (i = 0; i < n; ++i)
	{
		if (in1 == c[i]) break;
	}
	int suma = 0;
	for (i++; i < n; i++) {
		suma += t[i];
	}
	cout << suma << "\n";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<array>
#include<algorithm>
#include<deque>
#include<vector>

int main(void) {
	using namespace std;
	int N, K,h,result;
	int def = 1000000000, def2 = 0;
	vector<int>vec;
	cin >> N >> K;
	for (int i = 0; i < N;i++) {
		cin >> h;
		vec.push_back(h);
	}
	sort(vec.begin(),vec.end());
	for (int i = 0; i < N - (K - 1);i++) {
		def2 = vec[K - 1 + i] - vec[i];
		if (def > def2) {
			def = def2;
			result = def2;
		}
	}
	cout << result << endl;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int L, A, B, C, D;
    cin >> L >> A >> B >> C >> D;
    int t = max((A + C - 1) / C, (B + D - 1) / D);
    cout << L - t << "\n";
    return 0;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    int a,b ,c;
    cin >> a >> b >> c;

    if(a == b && a != c){
        cout << "Yes" << endl;
        return 0;
    } else if(a == b && b != c) {
        cout << "Yes" << endl;
        return 0;
    }

    if(b == c && b != a){
        cout << "Yes" << endl;
        return 0;
    } else if(b == c && c != a){
        cout << "Yes" << endl;
        return 0;
    }

    if(a == c && a != b){
        cout << "Yes" << endl;
        return 0;
    } else if(b == c && c != b){
        cout << "Yes" << endl;
        return 0;
    }

    cout << "No" << endl;

}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            var H = int.Parse(input[0]);
            var W = int.Parse(input[1]);

            var maps = new List<List<char>>();

            for (int i = 0; i < H; i++)
            {
                var tmp = Console.ReadLine().ToCharArray().ToList();
                maps.Add(tmp);
            }

            for(int i=0;i<H;i++)
            {
                for(int k=0;k<W;k++)
                {
                    if(maps[i][k]=='#')
                    {
                        if(!((k > 0 && maps[i][k - 1] == '#') ||
                           (k < W - 1 && maps[i][k + 1] == '#') ||
                           (i > 0 && maps[i-1][k] == '#') ||
                           (i < H - 1 && maps[i+1][k] == '#')) )
                        {
                            Console.WriteLine("No");
                            return;
                        }
                    }
                }
            }

            Console.WriteLine("Yes");
        }
    }

Measured memory_bytes: 13268
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n=nxt(),m=nxt();
    vector <int> v(n+1);
    for(int i=1;i<=n;i++)
        cin>>v[i];
    vector <bool> good(n+1,1);
    while(m--)
    {
        int x=nxt(),y=nxt();
        if(v[x]<=v[y])
            good[x]=0;
        if(v[y]<=v[x])
            good[y]=0;
    }
    int  ans=0;
    for(int i=1;i<=n;i++)
        if(good[i])
            ans++;
        cout<<ans<<endl;
    
    
    return 0;   
}




 
 


Measured memory_bytes: 3708
#include <stdio.h>
#include <string.h>
int main(){
char x;
int sum=0,y=0,ans=0,i,z;
while(scanf("%c",&x)!=EOF){
z=x-'0';
if(z>=0 && z<=9){
if(y==0){sum*=10;}sum+=z;y=0;
}else{y=1; ans+=sum; sum=0;}
}
if(sum!=0){
	ans+=sum;}
printf("%d\n",ans);
return 0;
}

Measured memory_bytes: 968
#include<bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define show(x) cout<<#x<<"="<<x<<"\n"
using namespace std;

int n,m;
string s;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout<<fixed;
#ifdef LOCAL_DEFINE
    FILE *stream1;
    //FILE *stream2;
    stream1=freopen("in","r",stdin);
    //stream2=freopen("out","w",stdout);
    if(stream1==NULL)return 0;
    //if(stream2==NULL)return 0;
#endif
    cin>>n>>m;
    for(int i=0;i<=n;i++){
        for(int j=0;j<=n-i;j++){
            if(i*10000+j*5000+(n-i-j)*1000==m){
                cout<<i<<" "<<j<<" "<<(n-i-j)<<endl;
                return 0;
            }
        }
    }
    cout<<-1<<" "<<-1<<" "<<-1<<endl;
#ifdef LOCAL_DEFINE
    cerr<<"Time elapsed: "<<1.0*clock()/CLOCKS_PER_SEC<<"s.\n";
    fclose(stream1);
    //fclose(stream2);
#endif
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
	int g,i, y, t;
	g = 17;
	cin >> i >> y >> t;
	int r;
	r = i + y + t;
	if (r == g) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1<<30;

int main(){
  int n, T;cin>>n>>T;int ans=INF;
  for(int i=0;i<n;i++){
    int c, t;cin>>c>>t;
    if(t<=T)ans=min(ans, c);
  }
  cout << (ans==INF?"TLE":to_string(ans)) << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<math.h>
#include<numeric>
#include<algorithm>
using namespace std;

int main() {
	int a;
	int b;
	cin >> a;
	cin >> b;

	string ans;

	if (a > b) {
		for (int i = 0; i < a; i++) {
			ans += to_string(b);
		}
	}
	else {
		for (int i = 0; i < b; i++) {
			ans += to_string(a);
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
from itertools import product
N,C=map(int, input().split())
cost=[[int(st) for st in input().split()] for _ in range(C)]
count={0: {}, 1: {}, 2: {}}
for y in range(N):
    for x, v in enumerate(map(int, input().split())):
        rest = (x+y) % 3
        count[rest][v] = 1 + count[rest].get(v, 0)
mincost = 9223372036854775807
for cc in product(*[range(1, C+1)]*3):
    if cc[0] != cc[1] and cc[0] != cc[2] and cc[1] != cc[2]:
        sumcost = 0
        for i in range(3):
            for cl, cnt in count[i].items():
                sumcost += cnt*cost[cl-1][cc[i]-1]
        mincost = min(sumcost, mincost)
print(mincost)


Measured memory_bytes: 3064
import java.util.*;
public class Main {

	public static void main(String[] args) {
	Scanner cin = new Scanner(System.in);
	while(true){
		if(!cin.hasNext()){
			break;
		}
		String s=cin.nextLine(),ans="";
		for(int i=0;i<s.length();i++){
			if(s.charAt(i)=='@'){ 
				for(int q=0;q<s.charAt(i+1)-48;q++){
					ans=ans+s.charAt(i+2);
				}
				i=i+2;
			}
			else if(s.charAt(i)!='@'){
				ans=ans+s.charAt(i);
			}
		}
		System.out.println(ans);
	}
	}

}

Measured memory_bytes: 17156
#include <iostream>
#include <cmath>
using namespace std;
typedef long long ll;
int main (void) {
    int N;
    int P;

    cin >> N >> P;
    bool is_all_even = true;
    for (int i = 0; i < N; i++) {
        int A;
        cin >> A;
        if (A % 2 == 1) {
            is_all_even = false;
        }
    }

    ll ans = 0;
    if (is_all_even) {
        if (!P) {
            ans = pow(2, N);
        }
    } else {
        ans = pow(2, N - 1);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
# -*- coding: utf-8 -*-
n=int(input())
alist=list(map(int,input().split()))
m_p=alist[0]
money=int(1000%alist[0])
kabu=int(1000/alist[0])
for i in range(n):
  if m_p<alist[i]:
    m_p=alist[i]
    money+=kabu*m_p
  elif m_p>alist[i]:
    money+=kabu*m_p
    m_p=alist[i]
  else:
    continue
  kabu=int(money/m_p)
  money=int(money%m_p)
money+=kabu*m_p
print(money)

Measured memory_bytes: 8988
#include<iostream>
using namespace std;
int dp[10005];
int n,W;
int v[105];
int w[105];
int main(){
	cin>>n>>W;
	for(int i=1;i<=n;i++)	cin>>v[i]>>w[i];
	for(int i=1;i<=n;i++)
		for(int j=W;j>=w[i];j--)
			dp[j]=max(dp[j],dp[j-w[i]]+v[i]);
	cout<<dp[W]<<endl; 
}


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

using namespace std;

#define ll long long
#define pi 3.1415926535897932384626433
#define MAX 100000000000000000
#define sz = LLONG_MAX;

//char alpha[26] = {'a' ,'b','c', 'd', 'e', 'f' ,'g', 'h', 'i', 'j', 'k', 'm' ,'n' ,'o' ,'p' ,'q', 'r' ,'s', 't', 'u', 'v' ,'w' ,'x' ,'y', 'z'};

//Bits
/*
    Number of leading zeroes: builtin_clz(x)
    Number of trailing zeroes : builtin_ctz(x)
    Number of 1-bits: __builtin_popcount(x)

    1<<0, this means shifting of binary digit 1 by 0 positions to the left and after the operation, the result will be ‘1’
    1<<1, this means shifting of binary digit 1 by 1 position to the left and after the operation, the result will be ‘10’
    1<<2, this means shifting of binary digit 1 by 2 positions to the left and after operation, the result will be ‘100’

    1>>0, this means shifting of binary digit 1 by 0 positions to the right and after operation, the result will be ‘0’
    number>>1, when number = 4 in decimal and 100 in binary, this means shifting of binary representation of number right by 1 position and after the operation, the result will be ‘10’ i.e. 2, in decimal.

*/



//Factorial
ll fac(ll n)
{
    ll p=1;
    for(ll i=n;i>0;i--)
    {
        p*=i;
    }
    return p;
}



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

    ll test_case=1;    //cin>>test_case;

    while(test_case--)
    {
       ll n,d;
       cin>>n>>d;
       ll ans=0;

       while(n--)
       {
           ll x,y;
           cin>>x>>y;
           ll dis=x*x+y*y;
           if(sqrt(dis)<=d)
            ans++;
       }
       cout<<ans;




    //Case_Ends_Here :)
    }
}


Measured memory_bytes: 3696
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

constexpr int M = 1e5;
int c[2];

struct Graph {
    struct Vertex { int n, f; };
    struct Edge { int i, n; };
    Graph(int n, int m) : v(n, { -1, 0 }), e(m), n(n), m(0) {}
    void add_edge(int i, int j) {
        e[m] = { j, v[i].n };
        v[i].n = m;
        m++;
    }
    void dfs(int i) {
        if (v[i].f) return;
        v[i].f = 1;
        c[i >= M]++;
        for (int j = v[i].n; j >= 0; j = e[j].n) {
            Edge &o = e[j];
            dfs(o.i);
        }
    }
    vector<Vertex> v;
    vector<Edge> e;
    int n, m;
};

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

    int n;
    cin >> n;

    Graph g(M * 2, n * 2);
    for (int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;
        x--; y--;

        g.add_edge(x, M + y);
        g.add_edge(M + y, x);
    }

    ll s = -n;
    for (int i = 0; i < M; i++) {
        c[0] = c[1] = 0;
        g.dfs(i);
        s += (ll)c[0] * c[1];
    }
    cout << s << endl;

    return 0;
}

Measured memory_bytes: 4096
#include <iostream>
using namespace std;
int main(){
  int n, l; cin >> n >> l;
  // taste = l+i-1;
  int num_skip = 1;
  if(l<0){
    num_skip = 1-l;
    if(num_skip > n) num_skip = n;
  }
  int ans = (l-1)*(n-1);
  for(int i=1; i<n+1; i++){
    if(i == num_skip) continue;
    ans += i;
  }
  cout << ans << "\n";
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn lower_bound<F>(l: isize, r: isize, criterion: F) -> isize
where
    F: Fn(isize) -> bool,
{
    let mut l = l;
    let mut r = r;
    while r - l > 1 {
        let mid = l + (r - l) / 2;
        if criterion(mid) {
            r = mid;
        } else {
            l = mid;
        }
    }
    l
}

fn solve() {
    let (H,W,h,w) = get!(isize, isize, isize, isize);

    let crit = |base: isize| {
        H*W*base-(base*h*w+1)*(H/h)*(W/w) > 0
    };
    let base = lower_bound(0, 1_000_000_000, crit)+1;
    if base*(h*w-1)+1 > 1_000_000_000 || base == 1_000_000_000 {
        println!("No");
        return;
    }
    println!("Yes");

    let minus = -(base*(h*w-1)+1);
    for i in 0..H {
        for j in 0..W {
            if i%h == h-1 && j%w == w-1 {
                print!("{} ", minus);
            } else {
                print!("{} ", base);
            }
        }
        println!("");
    }
}


Measured memory_bytes: 9596
#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>
#include <queue>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define print(x) cout<<(x)<<'\n'
#define print_vec(v) rep(i,v.size()){if(i!=0)cout<<" ";cout<<v[i];}cout<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<'\n'
#define pb push_back
#define mp make_pair
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pll=pair<ll,ll>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vstr=vector<string>;

ll N;

void solve() {
    cin >> N;
    set<string> history;
    string str;
    cin >> str;
    history.insert(str);
    char tail = str[str.size()-1];
    bool ok = true;
    rep(i,N-1){
        cin >> str;
        if((str[0] != tail) || (history.find(str) != history.end())) ok = false;
        history.insert(str);
        tail = str[str.size()-1];
    }
    print(ok ? "Yes":"No");
}
 
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
    //int q; cin >> q;
	//while (q--)
		solve();
    return 0;
}

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

int main(){
  int N, M;
  cin >> N >> M;
  cout << (N+M-3)/(M-1) << endl;
}
    

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

using namespace std;
typedef long long ll;
int main() {
    string s;
    cin >> s;
    for(ll i = 0; i < s.size(); i += 2) {
        if(s[i] == 'L'){
            cout << "No" << endl;
            return 0;
        }
    }
    for(ll i = 1; i < s.size(); i += 2) {
        if(s[i] == 'R') {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
l=[]
k=[]
g=set(())
d={}
cnt=0
for i in range(n):
  tmp=list(map(int,input().split()))
  k.append(tmp[0])
  l.append(tmp[1:])
  for j in tmp[1:]:
    if j in d:
      pass
    else:
      d[j]=cnt
      cnt+=1
mi=d.keys()
# Union FInd
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
    def size(self, x):
        return -self.parents[self.find(x)]
    def same(self, x, y):
        return self.find(x) == self.find(y)
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]
    def group_count(self):
        return len(self.roots())
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}
    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
uf=UnionFind(len(mi))
for li in l:
  if len(li)==1:continue
  for x in li[1:]:
    uf.union(d[li[0]],d[x])
if uf.group_count()>1:
  print('NO')
else:
  print('YES')


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

vector<int> X(5);

int ten(int x) {
  int rest = x % 10;
  if (rest == 0) {
    return x;
  } else {
    return x + 10 - rest;
  }
}

void solve() {
  sort(X.begin(), X.end());
  ll ans = 10000000000;
  do {
    ll tmp = 0;
    int i = 0;
    for (auto v : X) {
      i++;
      if (i != 5) {
        tmp += ten(v);
      } else {
        tmp += v;
      }
    }
    ans = min(tmp, ans);
  } while (next_permutation(X.begin(), X.end()));
  cout << ans << "\n";
}

int main() {
  cin >> X[0] >> X[1] >> X[2] >> X[3] >> X[4];
  solve();
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int num[101] = {0};
	int a, b, c;
	int ans = 0;
	
	cin >> a >> b >> c;
	
	num[a]++;
	num[b]++;
	num[c]++;
	
	for (int i = 0; i <= 100; i++) {
		if (num[i] > 0) {
			ans++;
		}
	}
	
	cout << ans << endl;
	
	return (0);
}

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

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  string s;
  cin >> s;
  int n = s.size();
  int ans[n];
  REP(i, n) ans[i] = 1;
  REP(i, n) {
    if (i == n - 1) continue;
    if (s[i] == 'R' && s[i + 1] == 'R') {
      ans[i + 2] += ans[i];
      ans[i] = 0;
    }
  }
  RREP(i, n) {
    if (i == 0) continue;
    if (s[i] == 'L' && s[i - 1] == 'L') {
      ans[i - 2] += ans[i];
      ans[i] = 0;
    }
  }
  REP(i, n) {
    if (i) cout << " ";
    cout << ans[i];
  }
  cout << "\n";
  return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main(void){
    int hill,top[3];
    int i;
    for(i=0;i<3;i++){
        top[i]=0;
    }
    for(i=0;i<10;i++){
        scanf("%d",&hill);
        if(top[0]<hill){
            top[2]=top[1];
            top[1]=top[0];
            top[0]=hill;
        }else if(top[1]<hill){
            top[2]=top[1];
            top[1]=hill;
        }else if(top[2]<hill){
            top[2]=hill;
        }
    }

    for(i=0;i<3;i++){
        printf("%d\n",top[i]);
    }
    return 0;
}


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

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

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

	int N; cin >> N;

	int ans = 1;
	for (;ans*ans <= N;ans++){

	}

	ans--;
	cout << ans*ans << endl;

	return 0;

}


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

using namespace std;
int sx, sy, tx, ty;
int main(){
  cin >> sx >> sy >> tx >> ty;
  for(int i = sx;i < tx;i++)cout << "R";
  for(int i = sy;i < ty;i++)cout << "U";
  for(int i = tx;i > sx;i--)cout << "L";
  for(int i = ty;i > sy;i--)cout << "D";
  cout << "D";
  for(int i = sx;i < tx+1;i++)cout << "R";
  for(int i = sy-1;i < ty;i++)cout << "U";
  cout << "L";
  cout << "U";
  for(int i = tx;i > sx-1;i--)cout << "L";
  for(int i = ty+1;i > sy;i--)cout << "D";
  cout << "R" << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {


    Scanner sc =new Scanner(System.in);
    int n =sc.nextInt();
    int k=sc.nextInt();
    int[] a= new int[n];
    int[] b=new int[n+1];
    for(int i=0;i<n;i++) {
    	a[i]=sc.nextInt();
    	b[a[i]]++;
       }
  java.util.Arrays.sort(b);
   int ans = 0;
   for( int p=0;p<=n-k;p++) {
	   ans = b[p]+ans;

   }
   System.out.println(ans);
	}

}


Measured memory_bytes: 66144
#include <stdio.h>

int main(void)
{
	double n;
	int ni;
	int s[4];
	int i;
	
	while (1){
		scanf("%lf", &n);
		if (n < 0){
			break;
		}
		ni = n;
		if (ni > 255){
			printf("NA\n");
			continue;
		}
		
		s[0] = s[1] = s[2] = s[3] = 0;
		n -= ni;
		
		n *= 2;
		if (n >= 1){
			s[0] = 1;
			n = n - (int)n;
		}
		n *= 2;
		if (n >= 1){
			s[1] = 1;
			n = n - (int)n;
		}
		n *= 2;
		if (n >= 1){
			s[2] = 1;
			n = n - (int)n;
		}
		n *= 2;
		if (n >= 1){
			s[3] = 1;
			n = n - (int)n;
		}
		n *= 2;
		if (n != 0){
			printf("NA\n");
			continue;
		}
		
		for (i = 0; i < 8; i++){
			if ((ni & (1 << (7 - i))) == 0){
				printf("0");
			}
			else{
				printf("1");
			}
		}

		printf(".");

		for (i = 0; i < 4; i++){
			printf("%d", s[i]);
		}
		printf("\n");
	}

	return (0);
}

Measured memory_bytes: 648
#include<iostream>

using namespace std;

int main()
{
	int ame[100],i,temp;
	
	for(i = 0;	scanf("%d",&ame[i]) != EOF;i++){
		if(ame[i] == 0){
			break;
		}
	}
	temp = i;
	for(;i > -1;i--){
		ame[i] = ame[i] % 39;
		if(ame[i] == 0){
			ame[i] = 39;
		}
	}
	for(i = 0; i < temp; i++){
	printf("3C%02d\n",ame[i]);
	}
}

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

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

Measured memory_bytes: 256
def chk3(n):
  if n==2:
    return True
  else:
    return False
def chk2(n):
  if n==4 or n==6 or n==9 or n==11:
    return True
  else:
    return False
def chk1(n):
  if n==1 or n==3 or n==5 or n==7 or n==8 or n==10 or n==12:
    return True
  else:
    return False
x,y=map(int,input().split())
if (chk3(x)==chk3(y) and chk3(x)==True) or (chk2(x)==chk2(y) and chk2(x)==True) or (chk1(x)==chk1(y) and chk1(x)==True):
  print("Yes")
else: 
  print("No")


Measured memory_bytes: 3064
#include <algorithm>
#include <array>
#include <cassert>
#include <iostream>
#include <vector>
using namespace std;

template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }

#ifdef NEAL_DEBUG
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif


int main() {
    ios::sync_with_stdio(false);
#ifndef NEAL_DEBUG
    cin.tie(nullptr);
#endif

    int N;
    cin >> N;
    int total = 0;

    for (int a = 1; a < N; a++)
        for (int b = 1; a * b < N; b++)
            total++;

    cout << total << '\n';
}


Measured memory_bytes: 3648
fn solve() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n: usize = sc.read();
    if n < 1000 {
        println!("ABC");
    } else {
        println!("ABD");
    }
}

fn main() {
    std::thread::Builder::new()
        .stack_size(64 * 1024 * 1024) // 64MB
        .spawn(|| solve())
        .unwrap()
        .join()
        .unwrap();
}

//snippet from kenkoooo
pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self.stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_line(&mut self) -> String {
        use std::io::Read;
        let buf = self.stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b'\n' || b == b'\r')
            .take_while(|&b| b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 8572
while True:
    try:
        N = int(input())
        W = list(map(int, input().split()))
        
        T = 0
        S1 = W[0]
        S2 = sum(W[1:])
        delta = [abs(S1-S2)]
        for T in range(1, N-1):
            S1 += W[T]
            S2 -= W[T]
            delta.append(abs(S1-S2))
        print(min(delta))
    except:
        break

Measured memory_bytes: 3064
a,b,c,d=map(int,input().split())

e = 0

while a > 0 and c > 0:
  if e == 0:
    c = c - b
    e = 1
  else:
    a = a - d
    e = 0
    
if a <= 0:
  print("No")
else:
  print("Yes")

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

int main() {
  int N,T,A;
  cin>>N>>T>>A;
  
  vector<int> vec(N);
  for(int i=0;i<N;i++){
    cin>>vec.at(i);
  }
  
  vector<int> tem(N);
  for(int i=0;i<N;i++){
    tem.at(i)=1000*T-6*vec.at(i);
  }
  
  int num =0;
  double hi=tem.at(0);
  for(int i=1;i<N;i++){
    if(abs(hi-1000*A)>abs(tem.at(i)-1000*A)){
      hi=tem.at(i);
      num=i;
    }
  }
  cout<<num+1<<endl;
}

Measured memory_bytes: 256
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    x = int(readline())
    for i in range(x, 10 ** 10):
        b = True
        for j in range(2, int(i ** 0.5) + 1):
            if i % j == 0:
                b = False
                break
        if b:
            print(i)
            exit()


if __name__ == '__main__':
    solve()


Measured memory_bytes: 38896
#include <bits/stdc++.h>
#define int long long
using namespace std;
int f(int n){
    if(n<5)return 0;
    return (n/5+f(n/5));
}
int32_t main() {
    ios::sync_with_stdio(0),cin.tie(0);
    int n;
    cin >> n;
    if(n%2==0)
        cout << f(n/2);
    else
        cout << 0;
}

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

int main() {
	typedef complex<double> xy;
	xy p[20];
	int n = 0;
	double x, y, s;
	while ( ~scanf( "%lf, %lf", &x, &y ) ) {
		p[n++] = xy( x, y );
	}
	for ( int i = 1; i < n - 1; i++ ) {
		s += ( conj( p[i] - p[0] ) * ( p[i + 1] - p[0] ) ).imag() / 2;
	}
	printf( "%.6f\n", abs(s) );
}

Measured memory_bytes: 1244
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    N=int(input())
    A=list(map(int,input().split()))
    B=list(map(int,input().split()))
    cnt=0
    for i in range(N):
        val=min(A[i],B[i])
        A[i]-=val
        B[i]-=val
        cnt+=val

        val=min(A[i+1],B[i])
        A[i+1]-=val
        cnt+=val

    print(cnt)




resolve()

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

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int N;
int A[110000], B[110000];
pint pA[110000], pB[110000];
set<int> setA, setB;
signed main() {
    cin >> N;
    for (int i = 0; i < N; i++)cin >> A[i] >> B[i];
    for (int i = 0; i < N; i++)pA[i] = pint(A[i], i), pB[i] = pint(B[i], i);
    sort(pA, pA + N);
    sort(pB, pB + N);
    reverse(pB, pB + N);
    int ans = 0;
    int idx = -1;
    for (int i = 0; i < N; i++) {
        ans += min(pA[i].first, pB[i].first);
        if (pA[i].first <= pB[i].first) {
            setA.insert(pA[i].second), setB.insert(pB[i].second);
            idx = i;
        }
    }
    if (idx == -1 || idx == N - 1) {
        cout << ans << endl;
        return 0;
    }
    if (setA == setB) {
        bool lch = idx != 0 && pA[idx].second == pB[idx].second, rch = idx != N - 2 && pA[idx + 1].second == pB[idx + 1].second;
        int cur = 1145141919810LL;
        if (lch) {
            if (rch) {
                cur = min(cur, min(pA[idx].first, pB[idx + 2].first) + min(pA[idx + 1].first, pB[idx - 1].first) - pA[idx].first - pB[idx + 2].first);
                cur = min(cur, min(pA[idx - 1].first, pB[idx + 2].first) + min(pA[idx + 1].first, pB[idx].first) - pA[idx - 1].first - pB[idx + 2].first);
                cur = min(cur, min(pA[idx].first, pB[idx + 1].first) + min(pA[idx + 2].first, pB[idx - 1].first) - pA[idx].first - pB[idx + 1].first);
                cur = min(cur, min(pA[idx - 1].first, pB[idx + 1].first) + min(pA[idx + 2].first, pB[idx].first) - pA[idx - 1].first - pB[idx + 1].first);
            } else {
                cur = min(cur, min(pA[idx].first, pB[idx + 1].first) + min(pA[idx + 1].first, pB[idx - 1].first) - pA[idx].first - pB[idx + 1].first);
                cur = min(cur, min(pA[idx - 1].first, pB[idx + 1].first) + min(pA[idx + 1].first, pB[idx].first) - pA[idx - 1].first - pB[idx + 1].first);
            }
        } else {
            if (rch) {
                cur = min(cur, min(pA[idx].first, pB[idx + 1].first) + min(pA[idx + 2].first, pB[idx].first) - pA[idx].first - pB[idx + 1].first);
                cur = min(cur, min(pA[idx].first, pB[idx + 2].first) + min(pA[idx + 1].first, pB[idx].first) - pA[idx].first - pB[idx + 2].first);
            } else {
                cur = min(cur, min(pA[idx].first, pB[idx + 1].first) + min(pA[idx + 1].first, pB[idx].first) - pA[idx].first - pB[idx + 1].first);
            }
        }
        ans += cur;
    }
    cout << ans << endl;
}


Measured memory_bytes: 14464
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <map>
#include <cmath>
using namespace std;
typedef long long ll;

int main()
{
	int n, x; cin >> n >> x;
	ll cnt = 0;
	vector<int>A(n);
	for (int i = 0; i < n; i++) {
		int a; cin >> a;
		if (a > x) {
			cnt += a - x;
			a = x;
		}
		A[i] = a;
	}
	vector<int>A1(A);
	ll cnt1 = 0;
	for (int i = 1; i < n; i++) {
		if (A1[i] + A1[i - 1] > x) {
			cnt1 += A1[i] + A1[i - 1] - x;
			A1[i] = x - A1[i - 1];
		}
	}
	vector<int>A2(A);
	ll cnt2 = 0;
	for (int i = n-2; i >= 0; i--) {
		if (A2[i] + A2[i + 1] > x) {
			cnt2 += A2[i] + A2[i + 1] - x;
			A2[i] = x - A2[i + 1];
		}
	}

	cout << cnt+min(cnt1,cnt2) << endl;

    return 0;
}


Measured memory_bytes: 1408
import math


def read():
    K = int(input())
    return K,

def solve(K):
    ans = 0
    cache = [[math.gcd(i, j) for j in range(K+1)] for i in range(K+1)]
    for a in range(1, K+1):
        for b in range(1, K+1):
            for c in range(1, K+1):
                bc = cache[b][c]
                abc = cache[a][bc]  
                ans += abc
    return ans


if __name__ == '__main__':
    inputs = read()
    print("{}".format(solve(*inputs)))


Measured memory_bytes: 9512
#pragma gcc optimize("Ofast")

#include "bits/stdc++.h"
using namespace std;
typedef int64_t lld;
typedef pair<int,int> pii;
typedef pair<lld,lld> pll;
typedef pair<int,pll> pip;
typedef pair<pll,int> ppi;
typedef pair<lld,pll> plp;
typedef pair<pll,lld> ppl;
typedef pair<pll,pll> ppp;
template<typename T>
using maxHeap = priority_queue<T,vector<T>,less<T>>;
template<typename T>
using minHeap = priority_queue<T,vector<T>,greater<T>>;
#define ff first
#define ss second
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define endl '\n'
#define jizz cin.tie(0);cout.tie(0);ios::sync_with_stdio(0);
inline void input(int &_x) {
    _x = 0;
    int _tmp = 1; char _tc = getchar();
    while((_tc < '0' || _tc > '9') && _tc != '-') _tc = getchar();
    if(_tc == '-') _tc = getchar(), _tmp = -1;
    while(_tc >= '0' && _tc <= '9') _x = _x*10+(_tc-48), _tc = getchar();
    _x *= _tmp;
}
inline void output(int _x) {
    char _buff[20]; int _f = 0;
    if(_x == 0)putchar('0');
    while(_x > 0)
    {
        _buff[_f++] = _x%10+'0';
        _x /= 10;
    }
    for(_f-=1; _f >= 0; _f--)
        putchar(_buff[_f]);
    putchar('\n');
}
template<typename Iter>
ostream& _out(ostream &s, Iter b, Iter e) {
    s<<"[";
    for ( auto it=b; it!=e; it++ ) s<<(it==b?"":" ")<<*it;
    s<<"]";
    return s;
}
template<class T1,class T2>
ostream& operator<<(ostream& out, pair<T1,T2> p) {
    return out << '(' << p.first << ", " << p.second << ')';
}
template<typename T>
ostream& operator <<( ostream &s, const vector<T> &c ) {
     return _out(s,c.begin(),c.end());
 }
#ifdef erd1
    #define pprint(x) cerr<<__PRETTY_FUNCTION__<<":"<<__LINE__<<" - "<<(#x)<<"="<<(x)<<endl
#else
    #define pprint(x)
#endif

// code starts here
array<array<vector<lld>,51>,51> ans;
vector<pii> v;
signed main(){
    for(int i = 0; i <= 50; i++){
        ans[i][i].pb(0);
        for(int j = 0; i-j > j; j++)
            for(int k = 1; k <= i; k++)
                for(auto x: ans[i%k][j])
                    ans[i][j].pb((1LL<<k)|x);
    }
    lld res = 0;
    int n;
    cin >> n;
    v.resize(n);
    for(auto& x: v)cin >> x.ff;
    for(auto& x: v)cin >> x.ss;
    for(auto p: v)if(!ans[p.ff][p.ss].size())return cout << -1 << endl, 0;
    for(int i = 0; i < n; i++){
        lld a = 0;
        for(auto p: v){
            lld ax = LLONG_MAX;
            for(lld x: ans[p.ff][p.ss])
                ax = min(ax, (x|res)^res);
            //cout << p << ax << " " << ans[p.ff][p.ss] << endl;
            a = max(a, ax);
        }
        res |= a;
    }
    cout << res << endl;
}


Measured memory_bytes: 640
#include<iostream>
#include<cmath>
#include<cstdio>

double abs(double d){
	return (d>0)?d:-d;
}

int main(){
	int m, n;
	while(std::cin >> m, m){
		double Sm = 0, Sn = 0;
		int remained_angle = 360;

		for(int i=0;i<m-1;i++){
			int angle;
			std::cin >> angle;
			Sm += sin(1.0 * angle * M_PI / 180);
			remained_angle -= angle;
		}
		Sm += sin(1.0 * remained_angle * M_PI / 180);

		remained_angle = 360;
		std::cin >> n;
		for(int i=0;i<n-1;i++){
			int angle;
			std::cin >> angle;
			Sn += sin(1.0 * angle * M_PI / 180);
			remained_angle -= angle;
		}
		Sn += sin(1.0 * remained_angle * M_PI / 180);

		if(abs(Sm - Sn) < 1e-8){
			puts("0");
		}else if(Sm > Sn){
			puts("1");
		}else{
			puts("2");
		}
	}
}

Measured memory_bytes: 1156
#include <cstdio>
#include <sstream>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <iostream>
#include <fstream>
#include <numeric>
#include <string>
#include <vector>
#include <cstring>
#include <map>
#include <iterator>


using namespace std;

int rep[100100];
int findr(int );
int findr(int x)
{
    if(rep[x]==x)return x;
    return findr(rep[x]);
}


int main()
{
    int n, q, i, j, a, x, y, t;


    scanf("%d %d", &n, &q);
    for(i=0; i<n; i++) rep[i]=i;
    for(i=0; i<q; i++)
    {
        scanf("%d %d %d", &a, &x, &y);
        if(a==0)
        {
            int repu = findr(x);
            int repv = findr(y);
            rep[repu] = rep[repv];
            /*if(repu != repv)
            {
                rep[repu]=repv;
            }*/
        }
        else
        {
            if(findr(x)==findr(y))
            {
                printf("1\n");
            }
            else
            {
                printf("0\n");
            }
        }
    }

    return 0;
}

Measured memory_bytes: 1204
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int count =0;
        int ans =0;
        int x=0;
        int waru=0;
        
        
        
        
        for(int i=1; i<=N;i++){
            count=0;
            waru=i;
            while(waru>=1){
                if(waru==1){
                    count++;
                    waru=0;
                }else if(waru%2==0){
                    count++;
                    waru=waru/2;
                    
                }else if(waru%2==1){
                    waru=waru/2;
                    
                }
                
            }
            if(ans<count){
                ans=count;
                x=i;
            }
            
        }
        System.out.println(x);
    }
}


Measured memory_bytes: 35948
def main():
    examC()

def examA():
    N = I()
    ans = 1^N
    print(ans)
    return

def examB():
    a, b, c, d = LI()
    ans = max(a*c,a*d,b*c,b*d)
    print(ans)
    return

def examC():
    N = I()
    if N==1:
        ans = 0
    else:
        ans = pow(10,N,mod) - pow(9,N,mod)*2 + pow(8,N,mod)
        ans += mod*2
        ans %= mod
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

def test():
    i = I()
    li = LI()
    lsi = LSI()
    si = LS()
    print(i)
    print(li)
    print(lsi)
    print(si)
    return

from decimal import getcontext,Decimal as dec
import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(input())
def LI(): return list(map(int,sys.stdin.readline().split()))
def DI(): return dec(input())
def LDI(): return list(map(dec,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,alphabet_convert,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 1<<31
_ep = dec("0.000000000001")
alphabet = [chr(ord('a') + i) for i in range(26)]
alphabet_convert = {chr(ord('a') + i): i for i in range(26)}

getcontext().prec = 28

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    main()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

Measured memory_bytes: 10552