akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;

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

        ll a = 0;
        ll b = 0;
        for (auto i : m) {
//              cout << i.first << " " << i.second << endl;
                if (a == 0 && i.second > 1) {
                        a = i.first;
                }
                else if (b == 0 && i.second > 1) {
                        b = i.first;
                        break;
                }
        }
        ll sq = 0;
        ll sa = 0;
        ll sb = 0;
        for (auto i : m) {
//              cout << i.first << " " << i.second << endl;
                if (sa == 0 && i.second > 3) {
                        sa = i.first;
                        break;
                }
        }
        sq = sa * sa;
        ll ans = (sq > (a*b)) ? sq : a*b;
        cout << ans << endl;




}


Measured memory_bytes: 7296
import java.util.*;
import java.util.stream.Collectors;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	Main(BufferedReader in) throws IOException {
		String[] tokens = in.readLine().split(" ");
		int[] args = new int[4];
		for (int i = 0; i < 4; ++i) {
			args[i] = Integer.parseInt(tokens[i]);
		}
		boolean enable = false;
		if (Math.abs(args[2] - args[0]) <= args[3]) {
			enable = true;
		} else if (Math.abs(args[2] - args[1]) <= args[3] && Math.abs(args[1] - args[0]) <= args[3]) {
			enable = true;
		}
		System.out.println((enable ? "Yes" : "No"));
	}

	void calc() {
	}

	void showResult() {
	}
}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
typedef unsigned ui;
constexpr ui N(1e5+11),M(N<<1);
ui head[N],to[M],nxt[M],e_cnt;
void addedge(ui u,ui v)
{
	to[++e_cnt]=v;
	nxt[e_cnt]=head[u];
	head[u]=e_cnt;
	return;
}
ui col[N],cnt[4];
bool DFS(ui u)
{
	++cnt[col[u]];
	bool ans(true);
	for(unsigned e(head[u]),v(to[e]);e;v=to[e=nxt[e]])
	{
		cnt[3]+=e&1;
		if(~col[v])
			ans&=e&1?(col[u]+1)%3==col[v]:(col[v]+1)%3==col[u];
		else
		{
			col[v]=(col[u]+(e&1?1:2))%3;
			ans&=DFS(v);
		}
	}
	return ans;
}
signed main(void)
{
	ui n,m;
	scanf("%u%u",&n,&m);
	for(ui u,v;m;--m)
	{
		scanf("%u%u",&u,&v);
		addedge(u,v);
		addedge(v,u);
	}
	long long unsigned ans(0);
	memset(col,255,sizeof(col));
	for(ui i(1);i<=n;++i)
		if(!~col[i])
		{
			col[i]=cnt[0]=cnt[1]=cnt[2]=cnt[3]=0;
			if(DFS(i))
				ans+=!cnt[0]||!cnt[1]||!cnt[2]?cnt[3]:1llu*cnt[0]*cnt[1]+1llu*cnt[1]*cnt[2]+1llu*cnt[2]*cnt[0];
			else
				ans+=1llu*(cnt[0]+cnt[1]+cnt[2])*(cnt[0]+cnt[1]+cnt[2]);
		}
	printf("%llu\n",ans);
	return 0;
}

Measured memory_bytes: 7296
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
        String[] line = new String[num];
        String[][] s = new String[num][10];
        for(int i=0; i<num; i++){
          line[i] = sc.next();
          s[i] = line[i].split("");
        }
        int count = 0;
        int aNum = 0;
        int bNum = 0;
        int baNum= 0;
        int check = 0;
        for(int i=0; i<num; i++){
          for(int j=0; j<line[i].length()-1; j++){
            if(s[i][j].equals("A") && s[i][j+1].equals("B")) count++;
            if(j == 0 && s[i][j].equals("B")) {
              bNum++;
              check = 1;
            }
            if(j == line[i].length()-2 && s[i][j+1].equals("A")) {
              if(check == 1){
                baNum++;
                aNum++;
              }
              else aNum++;
            }
          }
          check = 0;
        }
        int plus = (aNum <= bNum) ? aNum : bNum;
        //if(aNum == num && bNum == num) plus--;
        if(baNum > 0 && baNum == aNum && baNum == bNum) plus -= 1;
		System.out.println(count+plus);
        //System.out.println(aNum);
        //System.out.println(bNum);
	}
}

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

namespace AOJ_ITP_1_3_C
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                string[] s = Console.ReadLine().Split(' ');
                int a = int.Parse(s[0]);
                int b = int.Parse(s[1]);
                if (a == 0 && b == 0)
                    break;
                if(a > b)
                {
                    int tmp = a;
                    a = b;
                    b = tmp;
                }
                Console.WriteLine("{0} {1}", a, b);
            }
        }
    }
}



Measured memory_bytes: 17924
#include <bits/stdc++.h>
#define INF 100000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;


//=============modpow============================
ll modpow(ll a, ll n, ll mod)
{
    ll res = 1;
    while (n > 0)
    {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//=================================================


//=============modinv============================
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

//=================================================

int main()
{
  ll mod = 1000000007;
  ll N;
  cin >> N;
  ll A;
  vector<ll> factor(1000001, 0);
  vector<ll> modinv_A(N);

  for (ll i = 0; i < N; ++i) {
    cin >> A;
    modinv_A.at(i) = modinv(A, mod);
    ll temp = A;
    for (ll j = 2; j * j <= temp; ++j) {
      if (A % j == 0) {
        ll cnt = 0;
        while (A % j == 0) {
          A /= j;
          cnt += 1;
        }
        factor.at(j) = max(factor.at(j), cnt);
      }
    }
    // cout << "A" << A << endl;
    factor.at(A) = max(1ll, factor.at(A));
  }

  ll lcm = 1;
  // for (ll i = 0; i < 1000001; ++i) {
  //   if (factor.at(i) != 0) {
  //     cout << "i:" << i << "cnt" << factor.at(i) << endl;
  //   }
  // }

  for (ll i = 2; i < 1000001; ++i) {
    if (factor.at(i) == 0) {
      continue;
    }
    lcm = (lcm * modpow(i, factor.at(i), mod)) % mod;
  }
  ll ans = 0;
  for (ll i = 0; i < N; ++i) {
    ans = (ans + (modinv_A.at(i) * lcm) % mod) % mod;
  }
  cout << ans << endl;
}


Measured memory_bytes: 8192
#pragma GCC optimize("Ofast")   //Comment optimisations for interactive problems (use endl)
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>

using namespace std;

#define  fastio         ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(10);
#define  randomINIT     mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define  foo(i,a,n)     for(ll i = (a); i <= n; i++)
#define  frr(i,a,n)     for(ll i = (a); i >= n; i--)
#define  fo(i,n)        for(ll i = 0; i < n; i++)
#define  all(x)         (x).begin(),(x).end()
#define  mset(x,val)    memset(x,val,sizeof(x))
#define  newl           cout<<"\n"
#define  pb             push_back
#define  mp             make_pair
#define  s              second
#define  f              first
#define  dline          cerr<<"///REACHED///\n";
#define  deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define  deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define  deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef  long long             ll;
typedef  long double           ld;
typedef  pair<ll,ll>           pll;
typedef  vector<ll>            vll;
typedef  vector<pll>           vpll;

const ll   MOD   =  1e+9+7;
const ll   INF   =  0x7f7f7f7f7f7f7f7f;
const int  INFi  =  0x7f7f7f7f;
const ll   MAXN  =  1e+5+7;

vll adj[MAXN];ll visit[MAXN]={};
int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1};
int dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};

//<<-----Declare Variable Here------->>//
int t=1;
ll n;
ll lcs[3005][3005] = {};
string s1,s2;
//<<-----Implement Functions Here---->>//

//<<-----Start of Main--------------->>//
void MAIN(){
		cin>>s1>>s2;
		for(ll i=0;i<=s1.size();i++)
		{
			for(ll j=0;j<=s2.size();j++)
			{
				if(i==0||j==0){lcs[i][j] = 0;continue;}
				lcs[i][j] = max(lcs[i-1][j],lcs[i][j-1]);
				if(s1[i-1] == s2[j-1])lcs[i][j] = 1 + lcs[i-1][j-1];
				
			}
		}
		ll sz = lcs[s1.size()][s2.size()];
		ll i = s1.size(),j = s2.size();
		string s3;
		while(i>0&&j>0)
		{
			if(s1[i-1]==s2[j-1])
			{
				s3+=s1[i-1];i--;j--;

			}
			else if(lcs[i-1][j]>lcs[i][j-1])i--;
			else j--;
		}
		reverse(all(s3));cout<<s3;

	}

int main(){
	fastio;randomINIT;

	//cin>>t;
	while(t--){
		MAIN();
	}

   
}

Measured memory_bytes: 73984
#include <iostream>
#include <cstdio>
using namespace std;
int main(){
    char a[4],b[4];
    bool tr=true;
    for(int i=1;i<=3;i++)
        cin>>a[i];
    for(int i=1;i<=3;i++){
        cin>>b[i];
        if(!(b[i]==a[4-i]))
            tr=false;
    }
    if(tr)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
sum = a[0]
min = a[0]
max = a[0]
for i in range(1, n):
  if a[i] < min:
    min = a[i]
  if a[i] > max:
    max = a[i]
  sum += a[i]
print(min, max, sum)
  

Measured memory_bytes: 8552
import java.util.*;

public class Main{
	
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
  	char[] a=sc.next().toCharArray(),b=sc.next().toCharArray();
    int f=0;
    if(a.length>b.length){
      System.out.println("GREATER");
    }else if(a.length<b.length){
      System.out.println("LESS");
    }else{
      for(int i=0;i<a.length;i++){
        if(Integer.parseInt(String.valueOf(a[i]))>Integer.parseInt(String.valueOf(b[i]))){
          System.out.println("GREATER");
          f++;
          break;
        }else if(Integer.parseInt(String.valueOf(a[i]))<Integer.parseInt(String.valueOf(b[i]))){
          System.out.println("LESS");
          f++;
          break;
        }else{}
      }
      if(f==0){
        System.out.println("EQUAL");
      }
    }
  }
}


Measured memory_bytes: 23124
#include<stdio.h>

#define nMAX 10000
#define qMAX 500
#define FOUND 1
#define NOT_FOUND 0

int linerSearch(int *,int,int);

int main()
{
  int n,S[nMAX],q,T[qMAX],i,count=0;

  scanf("%d",&n);

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

  scanf("%d",&q);

  for(i = 0 ; i < q ; i++)
    {
      scanf("%d",&T[i]);
    }

  for(i = 0 ; i < q ; i++)
    {
      if(linerSearch(S,T[i],n)) count++;
    }

  printf("%d\n",count);
  
  return 0;
}

int linerSearch(int *S,int key,int n)
{
  int i;

  for(i = 0 ; i < n ; i++)
    {
      if(S[i] == key) return FOUND;
    }
  return NOT_FOUND;
}



Measured memory_bytes: 2108
#include<stdio.h>
#include<map>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<utility>
#include<string.h>
#include<string>
#define n 200000
#define loop(i, a, b) for(int i=a; i<=b; i++)
using namespace std;
typedef pair<int, int> P;
typedef long long lli;
typedef double llf;
bool visit[n + 50];
int arr1[n + 50], arr2[n + 50], a, b, c, d, e, f;
string str1, str2;
struct edge{
	int from, to, weight;
	bool operator < (const edge& thing) const
	{
		return thing.weight < weight;
	}
};
vector<edge> V[n + 50];
void addedge(int a, int b, int c)
{
	edge temp;
	temp.from = a;
	temp.to = b;
	temp.weight = c;
}

////////////////////////////////////////

void solve()
{
	cin >> a >> b;
	int sum = 0, mi = 2147483647;
	loop(i, 0, a - 1)
	{
		cin >> arr1[i];
		sum += arr1[i];
		mi = min(mi, arr1[i]); 
	}
	int count = a;
	b -= sum;
	count += b / mi;
	cout << count; 
}
int main()
{
	int times = 1;
//	cin >> times;
	loop(i, 0, times - 1)
	{
		solve();
		printf("\n");
	}
	return 0;
}



Measured memory_bytes: 6400
#include<bits/stdc++.h>
#define REP(i,N) for (int i=0;i<(N); ++i)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long ll;
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

int main(){
    int K,X;
    cin >>K>>X;
    vector<int>ans(2*K-1);
    REP(i,2*K-1){
        ans[i]=X-K+1+i;
    }
    REP(i,2*K-1) cout <<ans[i]<<' ';
}

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

using namespace std;

int solve(int n){
    int res = 0;
    for(int x=0; x*x <= n - x; ++x){
        for(int y=x; x*x + y*y <= n - x - y; ++y){
            for(int z=y; x*x + y*y + z*z <= n - x - y - z; ++z){
                int w = sqrt(n - x*x - y*y - z*z);
                res += z <= w && x*x + y*y + z*z + w*w == n;
            }
        }
    }
    return res;
}

int main(){
    for(int n; cin >> n, n; cout << solve(n) << '\n');
    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
 
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<ll, ll> pii;
 
#define REP(a,b,c) for(ll (a)=(b);(a)<(c);(a)++)
#define PER(a,b,c) for(ll (a)=(b);(a)>=(c);(a)--)
 
void in(ll &x){ cin >> x; }
void pin(ll &x, ll &y){ cin >> x >> y; }


int main(){
    ll N,M,K,a,b,p,q,x,y,z;
    pin(a, b);
    REP(i,1,20000){
        if(i*8/100==a && i*10/100==b){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

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

typedef long long ll;

const int Maxb = 61;
const int Maxn = 205;

int T;
int n;
ll a[Maxn];
string s;
ll B[Maxb];

int main()
{
    scanf("%d", &T);
    while (T--) {
        scanf("%d", &n);
        for (int i = 0; i < n; i++)
            scanf("%lld", &a[i]);
        cin >> s;
        fill(B, B + Maxb, 0ll);
        bool los = false;
        for (int i = n - 1; i >= 0 && !los; i--)
            if (s[i] == '0')
                for (int j = Maxb - 1; j >= 0; j--) {
                    if (a[i] & 1ll << ll(j))
                        if (B[j]) a[i] ^= B[j];
                        else { B[j] = a[i]; break; }
                }
            else {
                for (int j = Maxb - 1; j >= 0; j--) if (a[i] & 1ll << ll(j))
                    if (B[j]) a[i] ^= B[j];
                    else break;
                if (a[i] > 0) los = true;
            }
        printf("%d\n", int(los));
    }
    return 0;
}


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

vector<int> a(3000, 0);
long long tmp[3005][2] = {-1};
vector<vector<vector<long long> > > dp(3000, vector<vector<long long>>(3000, vector<long long>(2, -1)));

long long helper(int i, int j, int c){
	if(i > j)
		return 0;
	if(dp[i][j][c] != -1)
		return dp[i][j][c];
	if(c == 1)
		return dp[i][j][c] = max(a[i] + helper(i+1, j, 0), a[j] + helper(i, j-1, 0));
	else
		return dp[i][j][c] = min(helper(i+1, j, 1), helper(i, j-1, 1));
}

int main() {
	// your code goes here
	int n;
	cin>>n;
	// vector<bool> dp(k+1, false);
	long long total = 0;	
	for(int i=0; i<n; i++){
		cin>>a[i];
		total += a[i];
	}
	// dp[0] = false;
	
	// for(int i=0; i<3000; i++)
	// 	for(int j=0; j<3000; j++)
	// 		for(int z=0; z<2; z++)
	// 			cout<<dp[i][j][z]<<' ';
	long long res = helper(0, n-1, 1);
	// cout<<res<<endl;
	// cout<<total<<endl;
	cout<<2*res - total;
	// while(i <= j){
	// 	if(a[i] > a[j]){
	// 		if(c == 0)
	// 			x += a[i];
	// 		i++;
	// 	}
	// 	else if()
	// }
	// for(int i=0; i<n; i++) cin>>choices[i];
	
	return 0;
}

Measured memory_bytes: 495884
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(input())
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())

N,K = inpl()
aa = [inpl() for _ in range(N)]

def Matdot(A,B):
    C = [[0]*N for _ in range(N)]
    for i in range(N):
        for j in range(N):
            for k in range(N):
                C[i][j] += A[i][k]*B[k][j]
            C[i][j] %= mod
    return C

def power(aa,k):
    if k == 1:
        return aa
    elif k%2 == 0:
        tmp = power(aa,k//2)
        return Matdot(tmp,tmp)
    else:
        tmp = power(aa,(k-1)//2)
        return Matdot(Matdot(tmp,tmp),aa)


aa =  power(aa,K)
ans = 0
for a in aa:
    ans += sum(a)
    ans %= mod
print(ans)


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

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

using namespace std;

const int INF = 10000;

int main()
{
	
	int a, b, c;

	cin >> a >> b >> c;

	int count = 0;

	//cの約数を求める
	for (int i = a; i <= b; i++) {
		if (c % i != 0) continue;

		count++;
	}

	cout << count << endl;

	return 0;
}



Measured memory_bytes: 3116
import java.awt.geom.Point2D;
import java.util.*;
  
public class Main {
    Scanner sc = new Scanner(System.in);
  
    public static void main(String[] args) {
        new Main(); 
    }
  
    public Main() {
        new aoj1157().doIt();
    }
    class aoj1157{
    	class UnionFind{
    		int [] par,rank;
    		int num;
    		public UnionFind(int n){
    			par = new int[n];
    			rank = new int[n];
    			for(int i = 0;i < n;i++){
    				par[i] = i;
    				rank[i] = 0;
    			}
    			num = n;
    		}
    		int find(int x){
    			if(par[x] == x)return x;
    			else return par[x] = find(par[x]);
    		}
    		void unite(int x,int y){
    			x = find(x);
    			y = find(y);
    			if(x == y)return;
    			if(rank[x] < rank[y])par[x] = y;
    			else{
    				par[y] = x;
    				if(rank[x] == rank[y])rank[x]++;
    			}
    			num--;
    		}
    		boolean same(int x,int y){
    			return find(x) == find(y);
    		}
    	}
        void doIt(){
        	int n = sc.nextInt();
        	int m = sc.nextInt();
        	int num[] = new int[n+1];
        	UnionFind uf = new UnionFind(n+1);
        	for(int i = 0;i < m;i++){
        		int s = sc.nextInt();
        		int g = sc.nextInt();
        		uf.unite(s,g);
        	}
        	for(int i = 1;i < n+1;i++){
        		num[uf.find(i)]++;
        	}
        	int S = 0;
        	int V = 0;
        	for(int i = 1;i < n+1;i++){
        		if(num[i] == 1)V++;
        		else if(num[i] > 1)S++;
        	}
        	System.out.println(Math.abs(V-S));
        }
    }
}

Measured memory_bytes: 26456
from fractions import gcd

K = int(input())
ans = (K * (K+1)) // 2

for i in range(1,K-1):
    for j in range(i+1,K):
        t = gcd(i,j)
        for k in range(j+1,K+1):
            ans += gcd(k,t) * 6

for i in range(1,K):
    for j in range(i+1,K+1):
        ans += gcd(i,j) * 6
    
print(ans)

Measured memory_bytes: 10676
#include <bits/stdc++.h>
//Remove below header file if c++ version greater than 14
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>

#define ll long long int
#define pb push_back
#define fastIO ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define endl '\n'
#define deb(x) cout << #x << " "<< x << endl;
#define fo(i, n) for(i=0; i<n; i++)
#define Fo(i, k, n) for(i=k; i<n; i++)

using namespace std;
using mii=map<int, int>;
using mll=map<ll, ll>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
const int mod = 1000000007;

ll desc(ll x, ll y)
{
    return x > y;
}

bool isPerfectSquare(long double x)
{
    // Find floating point value of
    // square root of x.
    long double sr = sqrt(x);

    // If square root is an integer
    return ((sr - floor(sr)) == 0);
}

int main() {
    fastIO
    int i, j, n, d1;
    cin >>  n >> d1;
    vector<vector<int>> arr;

    fo(i, n)
    {
     vi temp(d1, 0);
     fo(j, d1)
        cin >> temp[j];
     arr.pb(temp);
    }

/*
    for(const auto x: arr) {
        vector<int> temp = x;
        for(auto x1: temp)
            cout << x1 << " ";
        cout << endl;
    }
*/
    ll c = 0;
    fo(i, n)
    {

        for(int j = i+1; j<n ;j++)
        {
            long double d = 0;
            for(int k = 0; k < arr[j].size(); k++)
            {
                d += pow(arr[i][k] - arr[j][k] ,2);
            }
            if(isPerfectSquare(d))
                c += 1;
        }
    }
    cout << c << endl;
    return 0;
}

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

int main(){
  lint n, sum=0;
  cin>>n;
  vector<lint> s(n);
  for(lint i=0;i<n;i++){
    cin>>s[i];
    sum+=s[i];
  }
  
  if(sum%10!=0){
    cout<<sum<<endl;
    return 0;
  }
  
  sort(s.begin(), s.end());
  
  for(lint i=0;i<n;i++){
    if(s[i]%10!=0){
      cout<<sum-s[i]<<endl;
      return 0;
    }
  }
  cout<<0<<endl;
  return 0;
}
  

Measured memory_bytes: 256
N,M = map(int,input().split())
A = [input() for i in range(N)]
B = [input() for i in range(M)]
dxy = []
for y in range(M) :
    for x in range(M) :
        dxy.append((x,y))
flag = 0
for y in range(N) :
    for x in range(N) :
        if A[y][x] == B[0][0] and flag == 0 :
            counter = 0
            for dx,dy in dxy :
                if flag == 0 :
                    nx = x+dx
                    ny = y+dy
                    if not (0 <= nx <= N-1) :
                        break
                    if not (0 <= ny <= N-1) :
                        break
                    if A[ny][nx] == B[dy][dx] :
                        counter += 1
            if counter == M**2 :
                flag = 1
if flag == 1 :
    print("Yes")
else :
    print("No")


Measured memory_bytes: 3192
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S, T;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

int main() {
    cin>>N;
    map<string, ll> num;
    rep(i,N){
        cin>>S;
        ++num[S];
    }
    ll ans = 0;
    for(auto a : num){
        ans = max(ans, a.se);
    }
    set<string> s;
    for(auto a : num){
        if(a.se == ans) s.insert(a.fi);
    }
    for(string stri : s) cout<<stri<<endl;
}

Measured memory_bytes: 34560
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n = int(readline())
a = list(map(int, read().split()))

dic = {}
ans = 0

for i in range(n):
  ans += 1
  try:
    dic[a[i]] += 1
    if dic[a[i]] == a[i]:
      ans -= a[i]
  except KeyError:
    dic[a[i]] = 1
    if dic[a[i]] == a[i]:
      ans -= a[i]

print(ans)


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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

class BIT {
   public:
    explicit BIT(int64_t n) : values(n + 1) {}

    void inc(int64_t idx) {
        ++idx;

        while (idx < values.size()) {
            ++values[idx];
            idx += (idx & -idx);
        }
    }

    // [0, idx) in 0-indexed
    // [1, idx] in 1-indexed
    int64_t query(int64_t idx) {
        int64_t ret = 0;

        while (idx > 0) {
            ret += values[idx];
            idx -= (idx & -idx);
        }

        return ret;
    }

    vector<int64_t> values;
};

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

    vector<int64_t> b(n);
    map<int64_t, int64_t> idxs;
    int64_t s = 0;
    for (auto i : irange(0L, n)) {
        int64_t a;
        cin >> a;

        s += a;
        b[i] = s - k * (i + 1);
        idxs[b[i]] = 0;
    }

    idxs[0] = 0;

    int64_t idx = 0;
    for (auto& kv : idxs) {
        kv.second = idx++;
    }

    BIT bit(idxs.size());
    bit.inc(idxs[0]);
    int64_t ans = 0;
    for (auto bb : b) {
        ans += bit.query(idxs[bb] + 1);
        bit.inc(idxs[bb]);
    }

    cout << ans << endl;
}

Measured memory_bytes: 15872
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 998244353;
const int INF = LLONG_MAX;

signed main(){

    string s; cin >> s;
    int n = (int)s.size();
    vector<int> a(2 * n, 0);   
    vector<int> b(2 * n, 0);   
    for(int i = 0; i < n; i++){
        if(s[i] == '2') a[i] += 2;
        else if(s[i] == '1'){
            a[i]++;
            b[i]++;
        }else b[i] += 2;
    }

    for(int i = 1; i < 2 * n; i++){
        a[i] += a[i - 1];
        b[i] += b[i - 1];
    }

    int sumR = a[2 * n - 1];
    int sumB = b[2 * n - 1];

    // dp[i][j] := i 番目まで見て、r を j 個使った時の通り数
    vector<vector<int> > dp(2 * n + 1, vector<int> (sumR + 1, 0));
    dp[0][0] = 1LL;
    for(int i = 0; i < 2 * n; i++){
        for(int j = 0; j <= sumR; j++){
            if(dp[i][j] == 0) continue;
            
            //r を使う
            if(a[i] - j > 0){
                dp[i + 1][j + 1] += dp[i][j];
                dp[i + 1][j + 1] %= MOD;
            }

            //b を使う
            if(b[i] - i + j > 0){
                dp[i + 1][j] += dp[i][j];
                dp[i + 1][j] %= MOD;
            }
        }
    }

    cout << dp[2 * n][sumR] << endl;
    return 0;
}

Measured memory_bytes: 125440
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <tuple>
#include <map>
using namespace std;
int main(void){
    int n;
    cin >> n;
    vector<tuple<string,int,int>> p(n);
    for(int i = 0;i < n;i++){
        string s; int a;
        cin >> s >> a;
        p[i] = make_tuple(s,(-1)*a,i);
    }
    
    sort(p.begin(), p.end());
    
    string tmp = get<0>(p[0]);
    vector<int> A;
    for(int i = 0;i < n;i++){
        int x = get<2>(p[i]);
        cout << (x+1) << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <iomanip>
using namespace std;
#define rep(i, N) for (ll i = 0; i < (N); i++)
typedef long long ll;

int gcd2(int a, int b)
{
    if (a % b == 0)
    {
        return b;
    }
    else
    {
        return gcd2(b, a % b);
    }
}
int gcd3(int a, int b, int c)
{
    a = gcd2(a, b);
    return gcd2(a, c);
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int k;
    cin >> k;
    ll sum = 0;
    for (int i = 1; i <= k; i++)
    {
        for (int l = 1; l <= k; l++)
        {
            for (int g = 1; g <= k; g++)
            {
                sum += gcd3(i, l, g);
            }
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 3652
#include <iostream>
#include <cstring>
using namespace std;
const int N = 1010;
int a[N], b[N];
int main(){
	memset(a, 0, sizeof(a));
	memset(b, 0, sizeof(b));
	int t;
	cin >> t;
	for(int i = 1; i <= t; i ++)
		cin >> a[i] >> b[i];
	bool flag = false;
	for(int i = 1; i <= t - 2; i ++){
		if(a[i] == b[i]){
			if(a[i + 1] == b[i + 1]){
				if(a[i + 2] == b[i + 2]){
					cout << "Yes" << endl;
					flag = true;
					return 0;
				}else
					continue;
			}else
				continue;
		}else
			continue;
	}
	if(!flag)
		cout << "No" << endl;
	return 0;
} 

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main() {
    #ifdef DEBUG
    std::ifstream in("/home/share/inputf.in");
    std::cin.rdbuf(in.rdbuf());
    #endif
    const int64_t INF = 1e10;
    int N;
    cin >> N;
    vector<int64_t> h(N), ans(N);
    for(int i = 0; i < N; i++) {
        cin >> h[i];
        ans[i] = INF;
    }
    ans[0] = 0;
    for(int i = 0; i < N; i++) {
        for(int j = 1; j <= 2; j++) {
            if(i + j < N) {
                ans[i + j] = min(ans[i + j], abs(h[i + j] - h[i]) + ans[i]);
            }
        }
    }
    cout << ans[N - 1] << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define SZ(v) ((int)(v).size())
#define rep(i,n) for(int i=0;i<(n);i++)
#define foreach(it,c) for(__typeof(c.begin()) it=c.begin();it!=c.end();it++)
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef long long ll;
typedef unsigned uint;
typedef double db;
typedef pair<int,int> pii;
const int INF=0x3f3f3f3f;
const ll LL_INF=0x3f3f3f3f3f3f3f3f;
const int dx[4]={1,-1,0,0};
const int dy[4]={0,0,1,-1};
int inline in(){
	int x=0,c;
	for(;(uint)((c=getchar())-'0')>=10;){
		if(c=='-')return -in();
		if(!~c)throw ~0;
	}
	do{
		x=(x<<3)+(x<<1)+(c-'0');
	}while((uint)((c=getchar())-'0')<10);
	return x;
}
int main(){
    cin.sync_with_stdio(false);cin.tie(0);
	int n;
	cin>>n;
	int ans=0;
	for(int i=1;i<=n;i++){
		string s=to_string(i);
		if(SZ(s)%2==1)ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
   int n, a, b;
   cin >> n >> a >> b;
   int prob[3] = { 0 };

   for(int i=0;i<n;i++){
      int score;
      cin >> score;
      if(score <= a ){
         prob[0]++;
      }else if(score <= b){
         prob[1]++;
      }else{
         prob[2]++;
      }
   }

   int ans = prob[0];
   for(int i=1;i<3;i++){
      if(prob[i] < ans ){
         ans = prob[i];
      }
   }

   cout << ans << endl;
}

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

int main()
{

    char S[5];
    char T[5];
    int c=0;

     cin>>S>>T;

    for(int i=0;i<3;i++)
    {

        if(S[i]==T[i])
            c++;
    }


cout<<c<<"\n";




    return 0;
}


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

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

#define all(x) (x).begin(),(x).end()
#define IN(type,a) type a;cin >> a


using ll = long long;

int main() {
    int k;
    IN(ll, h);
    IN(int, n);
    ll s = 0;
    REP(i, n){
        cin >> k;
        s += k;
    }
    if(s>=h){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
object Main{
  def cut(cards: Array[Int],p:Int,c:Int): Array[Int] = {
    cards.slice(p-1,p-1+c) ++ cards.take(p-1) ++ cards.drop(p+c-1)
  }
  def main(args: Array[String]){
    var nr = readLine.split(" ").map( n => n.toInt )
    var n = nr(0)
    var r = nr(1)
    while(n>0&&r>0){
      var cards = new Array[Int](n)
      for(i <- 0 until n) cards(i) = n-i
      for(i <- 0 until r){
        val pc = readLine.split(" ").map( n => n.toInt )
        val p = pc(0)
        val c = pc(1)
        cards = cut(cards,p,c)
      }
      println( cards.head )
      nr = readLine.split(" ").map( n => n.toInt )
      n = nr(0)
      r = nr(1)
    }
  }
}

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

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

Measured memory_bytes: 256
package main

import (
	"bufio"
	"os"
	"strconv"
	"fmt"
)

var scanner= bufio.NewScanner(os.Stdin)

func main() {
	for scanner.Scan() {
		n, _ := strconv.Atoi(scanner.Text())
		if n%39 == 0 {
			fmt.Println(fmt.Sprintf("3C%02d", 39))
			continue
		}
		fmt.Println(fmt.Sprintf("3C%02d", n%39))
	}
}


Measured memory_bytes: 1124
def cal(T):
    T = list(T)
    for i in range(len(T)-1):
        if T[i] == "P" and T[i+1] == "?":
            T[i+1] = "D"
        if T[i] == "?" and T[i+1] == "D":
            T[i] = "P"
    for i in range(len(T)-1):
        if T[i] == "?" and T[i+1] == "?":
            T[i],T[i+1] = "P","D"
    for i in range(len(T)):
        if T[i] == "?":
            T[i] = "D"
    T = "".join(T)
    return T

def main():
    T = input()

    print(cal(T))

if __name__ == "__main__":
    main()


Measured memory_bytes: 10776
#include <iostream>
using namespace std;
int main(){
    int n,d,x;
    cin >> n >> d >> x;
    int ans = x;
    for(int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        int t = 1;
        while(t<=d){
            ans++;
            t += a;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vi2;
typedef vector<vi2> vi3;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<ll> vll;
typedef vector<vll> vll2;
typedef vector<vll2> vll3;
typedef vector<bool> vb;

#define el '\n'
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repi(i, a, b) for (int i = a; i >= b; i--)
#define umap unordered_map
#define uset unordered_set
#define vec vector
#define loop(a) for (auto &x : a)
#define all(a) a.begin(), a.end()
#define mp make_pair

const int modulo = 998244353;

void adds(int &a, int b) {
    a+=b;
    if (a >= modulo) {
        a-=modulo;
    }
}

int mul(int a, int b) {
    return (ll)a * b % modulo;
}

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

    int n, s;
    cin >> n >> s;
    vi a(n);
    loop(a) {
        cin >> x;
    }

    // cnt[k,s]: number of k subset of {a[0]..a[i]} with sum equaling to s

    vi2 cnt(n,vi(3001));
    cnt[0][0]=2;
    cnt[0][a[0]]=1;
    rep(i,1,n) {
        rep(s1,0,3001) {
            cnt[i][s1] = mul(2,cnt[i-1][s1]);
            if (s1 >= a[i]) {
                adds(cnt[i][s1], cnt[i-1][s1-a[i]]);
            }
        }
    }
    cout << cnt[n-1][s] << el;

    // cnt[s1]: number of subset of {a[0]..a[i]} with sum eqauling to s. 
    /* vi cnt(3001), cnt1(3001); */
    /* int ans = 0; */
    /* rep(i,0,n) { */
    /*     rep(s1,1,3001) { */
    /*         if (cnt[s1]>0) { */
    /*             int s2 = s1 + a[i]; */
    /*             if (s2 <= 3000) { */
    /*                 adds(cnt1[s2], cnt[s1]); */
    /*             } */
    /*         } */
    /*     } */
    /*     adds(cnt1[a[i]], 1); */
    /*     rep(s1,1,3001) { */
    /*         adds(cnt[s1], cnt1[s1]); */
    /*     } */
    /*     adds(ans, cnt[s]); */
    /*     cnt1.assign(3001, 0); */
    /* } */

    /* cout << ans << el; */
}


Measured memory_bytes: 38472
//  ____            _                  _                       _       _
// |  _ \ _   _ ___| |_    ___ _ __   | |_ ___ _ __ ___  _ __ | | __ _| |_ ___
// | |_) | | | / __| __|  / __| '_ \  | __/ _ \ '_ ` _ \| '_ \| |/ _` | __/ _ \
// |  _ <| |_| \__ \ |_  | (__| |_) | | ||  __/ | | | | | |_) | | (_| | ||  __/
// |_| \_\\__,_|___/\__|  \___| .__/___\__\___|_| |_| |_| .__/|_|\__,_|\__\___|
//                            |_| |_____|               |_|

//https://github.com/manta1130/Competitive_Programming_Template_Rust

#[macro_use]
mod input {

    use std;
    use std::io;

    const SPLIT_DELIMITER: char = ' ';

    #[macro_export]
    #[allow(unused_macros)]
    macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

    #[allow(dead_code)]
    pub fn input_line_str() -> String {
        let mut s = String::new();
        io::stdin().read_line(&mut s).unwrap();
        s.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn p<T>(t: T)
    where
        T: std::fmt::Display,
    {
        println!("{}", t);
    }

    #[allow(dead_code)]
    pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
    where
        T: std::str::FromStr,
    {
        let mut v: Vec<Vec<T>> = Vec::new();

        for _ in 0..line {
            let vec_line = input_vector();
            v.push(vec_line);
        }
        v
    }

    #[allow(dead_code)]
    pub fn input_vector<T>() -> Vec<T>
    where
        T: std::str::FromStr,
    {
        let mut v: Vec<T> = Vec::new();

        let s = input_line_str();
        let split_result = s.split(SPLIT_DELIMITER);
        for z in split_result {
            let buf = match z.parse() {
                Ok(r) => r,
                Err(_) => panic!("Parse Error"),
            };
            v.push(buf);
        }
        v
    }

    #[allow(dead_code)]
    pub fn input_vector_row<T>(n: usize) -> Vec<T>
    where
        T: std::str::FromStr,
    {
        let mut v = Vec::with_capacity(n);
        for _ in 0..n {
            let buf = match input_line_str().parse() {
                Ok(r) => r,
                Err(_) => panic!("Parse Error"),
            };
            v.push(buf);
        }
        v
    }

    pub trait ToCharVec {
        fn to_charvec(&self) -> Vec<char>;
    }

    impl ToCharVec for String {
        fn to_charvec(&self) -> Vec<char> {
            self.to_string().chars().collect::<Vec<_>>()
        }
    }
}

use input::*;

fn main()
{
    let mut n:usize;
    input!(n);
    if n<1200{
        println!("ABC");
    }else{
        println!("ARC");
    }
}



Measured memory_bytes: 4352
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <limits.h>
#include <assert.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string>
#include <bitset>
#include <vector>
using namespace std;

#define LL long long

#define fi first
#define se second
#define lson l,mid,id<<1
#define rson mid+1,r,id<<1|1
#define ls id<<1
#define rs id<<1|1
#define MID(a,b) (((a)+(b))>>1)
#define maxx(a,b) ((a)<(b)?(b):(a))
#define minx(a,b) ((a)<(b)?(a):(b))
#define absx(a) ((a)<0?-(a):(a))
#define mk(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define itr iterator
#define lowbit(x) ((x)&-(x))

typedef unsigned LL ULL;
typedef unsigned uint;
typedef map<int,int> mii;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<LL,LL> pLL;

template< typename T > inline void read(T &x) {
    static bool fr_f; static char fr_ch;
    fr_f=0; x=0; fr_ch=getchar();
    while(fr_ch<'0' || '9'<fr_ch) {if(fr_ch=='-') fr_f=1; fr_ch=getchar();}
    while('0'<=fr_ch && fr_ch<='9') {x=(x<<1)+(x<<3)+fr_ch-'0'; fr_ch=getchar();}
    if(fr_f) x=-x;
}

template< typename T > inline void Max (T &a, T b) {if(a<b) a=b;}
template< typename T > inline void Min (T &a, T b) {if(b<a) a=b;}
template< typename T > inline void Swap(T &a, T &b) {T c=a;a=b;b=c;}
template< typename T > inline T Abs(T a) {if(a<0) return -a; else return a;}

const double   pi = acos(-1.0) ;
const int     MOD = (int)1e9+7 ;
const int     INF = (int)0x3f3f3f3f ;
const LL     LINF = (LL)INF<<32|INF ;
const int    SINF = (uint)(-1)>>1 ;
const LL    SLINF = (ULL)(-1)>>1 ;
const double DINF = 1e50 ;
const double  eps = 1e-5 ;
const int    maxn = (int) 1e5+20 ;
const int    maxm = (int) 1e6+20 ;
const int    maxk = (int) 1000+20 ;

inline int sig(double x) {return x<-eps?-1:x>eps;}
inline LL fp(LL a,LL n,LL p) {LL res=1; for(;n;n>>=1,a=a*a%p) if(n&1) res=res*a%p; return res;}
template<typename T>inline T gcd(T a,T b) {for(T c;b;c=a%b,a=b,b=c); return a;}

//--------------------start--------------------

int n;
int L[maxn], R[maxn];

void work()
{
    read(n);
    for(int i = 1; i <= n; i++)
    {
        read(L[i]);
        read(R[i]);
    }

    sort(L, L + 1 + n);
    sort(R, R + 1 + n);

    LL ans = 0;
    for(int i = 0; i <= n; i++)
    {
        ans += max(0, L[n - i] - R[i]);
    }

    cout <<ans * 2 <<endl;
}

//---------------------end---------------------

int main()
{
#ifdef yukihana0416
freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);
#endif // yukihana0416
    work();
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <stack>
using namespace std;

int a[2];
int k, c;

int main(){

	cin >> a[0] >> a[1] >> k;

	sort(a,a + 2);

	for (int i = a[0]; i > 0; i--){
		if (a[0] % i == 0){
			if (a[1] % i == 0){
				c++;
				if (k == c){
					cout << i << endl;
					break;
				}
			}
		}
	}

	return 0;
}

Measured memory_bytes: 256
"""
import random
import functools
import copy
import bisect
import array
import re
import collections
import heapq
import fractions
import itertools
import string
import math
from operator import itemgetter as ig
from bisect import bisect_left, bisect_right, insort_left, insort_right
from itertools import permutations, combinations, product, accumulate, groupby
from heapq import heappush, heappop
from collections import deque, defaultdict, Counter
import sys
sys.setrecursionlimit(10 ** 7)
# import numpy as np

inf = 10 ** 20
INF = float("INF")
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]
ddn9 = ddn + [(0, 0)]
'''for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:'''
"""

from collections import deque
import sys
sys.setrecursionlimit(10 ** 7)


def wi(): return list(map(int, sys.stdin.readline().split()))
# WideIntPoint


def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]


def ws(): return sys.stdin.readline().split()


def si(): return int(sys.stdin.readline())  # SingleInt


def ss(): return input()


def hi(n): return [si() for _ in range(n)]


def hs(n): return [ss() for _ in range(n)]  # HeightString


def s_list(): return list(input())


def mi(n): return [wi() for _ in range(n)]  # MatrixInt


def mip(n): return [wip() for _ in range(n)]


def ms(n): return [ws() for _ in range(n)]


def num_grid(n): return [[int(i) for i in sys.stdin.readline().split()[
    0]] for _ in range(n)]  # NumberGrid


def grid(n): return [s_list() for _ in range(n)]


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


def round_up(a, b):
    """ a/b の切り上げ """
    c = (a + b - 1) / b
    return c


def lcm(a, b):
    """a,bの最小公倍数"""
    return a * b // gcd(a, b)


def floor(a, b):
    """floor(a/b) 整数値を返す"""
    c = (a - a % b)/b
    return int(c)


def main():

    K = int(input())
    q = deque()
    for i in range(1, 10):
        q.append(i)
    cnt = 9
    if cnt >= K:
        print(q[K-1])
        sys.exit()
    while cnt < K:
        x = q.popleft()
        d = x % 10
        for v in [d-1, d, d+1]:
            if 0 <= v <= 9:
                y = x*10 + v
                q.append(y)
                cnt += 1
                if cnt == K:
                    break
    print(y)


if __name__ == '__main__':
    main()


Measured memory_bytes: 40688
n = int(input())
Taro_ten = 0
Hanako_ten = 0
for i in range(n) :
    a, b = list(input().split())
    Taro = list(a)
    Hanako = list(b)
    length = min(len(Taro), len(Hanako))
    for i in range(length) :
        if ord(Taro[i]) > ord(Hanako[i]) :
            Taro_ten += 3
            break
        elif ord(Taro[i]) < ord(Hanako[i]) :
            Hanako_ten += 3
            break
        if i == length -1 :
            if len(Taro) > length :
                Taro_ten += 3
            elif len(Hanako) > length :
                Hanako_ten += 3
            else :
                Taro_ten += 1
                Hanako_ten += 1
print(Taro_ten, Hanako_ten)


Measured memory_bytes: 5596
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  int sum=a+b+c;
  int max_sum=max(a,max(b,c))*3;
  if((max_sum-sum)%2==0)cout << (max_sum-sum)/2 << endl;
  else cout << 2+(max_sum-sum)/2 << endl;
}

Measured memory_bytes: 3592
#include<cstdio>
#include<algorithm>
using namespace std;
int D[1 << 15][15], S[1 << 15], U[1<<15][15];
int w[15][15], n, m, sum;
int main() {
	int i, a, b, c, j, k, l;
	scanf("%d%d", &n, &m);
	for (i = 0; i < m; i++) {
		scanf("%d%d%d", &a, &b, &c);
		a--, b--;
		w[a][b] = w[b][a] = c;
		sum += c;
		for (j = 0; j < (1 << n); j++) {
			if (((~j)&((1 << a) | (1 << b))) == 0)S[j] += c;
			if (j&(1 << a)) U[j][b] += c;
			if (j&(1 << b)) U[j][a] += c;
		}
	}
	for (i = 0; i < (1 << n); i++) {
		for (j = 0; j < n; j++)D[i][j] = -1e9;
	}
	D[1][0] = 0;
	for (i = 0; i < (1 << n); i++) {
		for (j = 0; j < n; j++) {
			if (D[i][j] < 0)continue;
			int b = (1 << n) - i - 1;
			for (k = b;k; k = (k - 1)&b) {
				D[i | k][j] = max(D[i | k][j], D[i][j] + S[k] + U[k][j]);
			}
			for (k = 0; k < n; k++) {
				if (i&(1 << k))continue;
				if (!w[j][k])continue;
				D[i | (1 << k)][k] = max(D[i | (1 << k)][k], D[i][j] + w[j][k]);
			}
		}
	}
	printf("%d\n", sum - D[(1 << n) - 1][n - 1]);
}

Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
typedef long long  ll;
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
int main(){
// #ifndef ONLINE_JUDGE
// freopen("in.txxt","r",stdin);
// #endif
int a,b;
cin>>a>>b;
if(a%b==0)
	cout<<-1<<endl;
else
	cout<<lcm(a,b)-a<<endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <cmath>
#include <utility>
#include <algorithm>
#include <queue>

struct vertex
{
  long long x;
  long long y;
  long long r;
};

int main()
{
  long long sx, sy, tx, ty;
  int n;
  scanf("%lld%lld%lld%lld%d", &sx, &sy, &tx, &ty, &n);
  vertex vs[1002];
  for (int i = 0; i < n; ++i)
  {
    scanf("%lld%lld%lld", &vs[i].x, &vs[i].y, &vs[i].r);
  }
  vs[n] = vertex{sx, sy, 0};
  vs[n + 1] = vertex{tx, ty, 0};

  double edges[1002][1002];
  edges[n + 1][n + 1] = 0;
  for (int i = 0; i < n + 1; ++i)
  {
    edges[i][i] = 0;
    for (int j = i + 1; j < n + 2; ++j)
    {
      double dist = std::max(0., std::sqrt((vs[i].x - vs[j].x) * (vs[i].x - vs[j].x) + (vs[i].y - vs[j].y) * (vs[i].y - vs[j].y)) - (vs[i].r + vs[j].r));
      edges[i][j] = dist;
      edges[j][i] = dist;
    }
  }
  using pair = std::pair<double, int>;
  std::priority_queue<pair, std::vector<pair>, std::greater<pair>> q;
  double dist[1002];
  std::fill(dist, dist + n + 2, 1e18);
  q.emplace(0, n);
  while (q.size() > 0)
  {
    pair p = q.top(); q.pop();
    if (dist[p.second] < p.first) continue;
    for (int i = 0; i < n + 2; ++i)
    {
      if (p.first + edges[p.second][i] < dist[i])
      {
        dist[i] = p.first + edges[p.second][i];
        q.emplace(p.first + edges[p.second][i], i);
      }
    }
  }
  printf("%.12f\n", dist[n + 1]);
}

Measured memory_bytes: 13296
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); ++i)
#define all(v) v.begin(), v.end()
#define mp make_pair
#define INF 1e9

void init()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
}

int main()
{
    init();
    int n,k;
    cin>>n>>k;
    vector<long long>a(n);
    rep(i,n){
        cin>>a[i];
    }
    rep(i,n-k){
        if(a[i]<a[i+k])cout<<"Yes"<<endl;
        else cout << "No" << endl;
    }

}


Measured memory_bytes: 4780
#include <bits/stdc++.h>
using namespace std;
using pp=pair<int,int>;
using ll=long long;

int main() {
  int N, K, Q, A;
  cin >> N >> K >> Q;
  vector<int> V(N, 0);
  for (int i=0; i<Q; i++) {
    cin >> A;
    V[A-1]++;
  }
  for (int i=0; i<N; i++) {
    if (Q-V[i]>=K) {
      cout << "No" << endl;
    }
    else {
      cout << "Yes" << endl;
    }
  }
}

Measured memory_bytes: 3772
#include <cmath>
#include <iostream>
using namespace std;
typedef long long ll;

ll pow3(ll N) { return N * N * N; }

int main() {
  int N, K;
  cin >> N >> K;

  if (K % 2 == 0) cout << pow3(N / K) + pow3((N + K / 2) / K) << endl;
  if (K % 2 == 1) cout << pow3(N / K) << endl;
  return 0;
}

Measured memory_bytes: 256