akhauriyash/Code-Regression huggingface dataset:
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
////////////////////////////


int main(){fastio
    ll n,r;cin>>n>>r;
    if(n<10){
        r+=100*(10-n);
    }
    cout<<r<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;

int n;
ll a[10005], b[10005], x = 0, y = 0;

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
 
	cin >> n;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    for (int i = 0; i < n; i++)
        cin >> b[i];

    for (int i = 0; i < n; i++) {
        if (a[i] > b[i])
            x += a[i]-b[i];
        if (a[i] < b[i])
            y += (b[i]-a[i])/2;
    }

    if (y >= x)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
 
	return 0;
}

Measured memory_bytes: 384
//In The Name Of GOD

#include <bits/stdc++.h>
using namespace std;
typedef long long ll ;
const ll mod = 998244353;
const ll inf = 2000000000;
const ll infll = (ll)2*1000*1000*1000*1000*1000*1000;
const ll maxn = 100*1000+1;
#define pb push_back
#define pp pop_back
#define X first
#define Y second
#define IO ios_base::sync_with_stdio(false);

int ans[maxn];

bool prime(int x){
  for(int i=2;i<=(int)sqrt(x);i++){
    if(x%i==0){
      return false;
    }
  }
  return true;
}

int main(){
  IO;
  ans[1]=0;
  for(int i=3;i<=maxn;i+=2){
    if(prime(i)&&prime((i+1)/2)){
      ans[i]=ans[i-2]+1;
    }else{
      ans[i]=ans[i-2];
    }
  }
  int q;
  cin>>q;
  for(int i=0;i<q;i++){
    int l,r;
    cin>>l>>r;
    cout<<ans[r]-ans[max(l-2,0)]<<endl;
  }
}


Measured memory_bytes: 1024
#include<iostream>
#define PI 3.141592653589
using namespace std;

int main(){
	while(1){
		int x,y;
		char c;
		cin >> x >> c>>y;
		
		if(c=='?')break;
		int z;
		switch(c){
			case '+':
				z=x+y;
				break;
			case '-':
				z=x-y;
				break;
			case '*':
				z=x*y;
				break;
			case '/':
				z=x/y;
				break;
			case '%':
				z=x%y;
				break;
		}
		printf("%d\n",z);
	}
	
	return 0;
}

Measured memory_bytes: 0
n = int(input())
h = list(map(int, input().split()))
flag = 1
for i in range(1, n):
    if h[-i] - h[-(i+1)] <= -2:
        flag = 0
        break
    if h[-i] - h[-(i+1)] == -1:
        h[-(i+1)] -= 1
print("Yes") if flag else print("No")

Measured memory_bytes: 15020
N = int(input())
A = list(map(int, input().split()))


# number_to_prime[i]: i の最小の素因数, iが素数ならば0
number_to_prime = [0] * (10**6 + 1)

# preprocess
for i in range(2, 10**6+1):
    if not number_to_prime[i]:
        j = 1
        while j*i <= 10**6:
            number_to_prime[j*i] = i
            j += 1

def is_pairwise():
    used_primes = [False] * (10**6 + 1)
    pairwise_flag = 1
    for a in A:
        curr_primes = set()
        while a > 1:
            prime = number_to_prime[a]
            while a % prime == 0:
                a //= prime
            if used_primes[prime]:
                return False
            used_primes[prime] = 1
    return True

def is_setwise(*A):
    import math
    from functools import reduce

    return reduce(math.gcd, A) == 1

if is_pairwise():
    print("pairwise coprime")
elif is_setwise(*A):
    print("setwise coprime")
else:
    print("not coprime")

Measured memory_bytes: 134612
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
map<int,int>mp;
int ans[200000];
vector<int>g[200000];
int k[200000];
void dfs(int s, int p, int sum){
    ans[s] = sum;
    for(int x : g[s]){
        if(x != p)dfs(x,s,sum+k[x]);
    }
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, q;
    cin >> n >> q;
    rep(i,n-1){
        int a, b;
        cin >> a >> b;
        a--,b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    while(q--){
        int a, b;
        cin >> a >> b;
        a--;
        k[a] += b;
    }
    dfs(0,-1,k[0]);
    rep(i,n)cout << ans[i] << " \n"[i == n - 1];
}


Measured memory_bytes: 24064
A=[list(map(int, input().split())) for _ in range(3)]
N=int(input())
B=[int(input()) for _ in range(N)]
card=[[False for _ in range(3)] for _ in range(3)]

for b in B:
    for i in range(3):
        for j in range(3):
            if b==A[i][j]:
                card[i][j]=True

ans="No"
if card[0][0] and card[0][1] and card[0][2]:
    ans="Yes"
elif card[1][0] and card[1][1] and card[1][2]:
    ans="Yes"
elif card[2][0] and card[2][1] and card[2][2]:
    ans="Yes"
elif card[0][0] and card[1][0] and card[2][0]:
    ans="Yes"
elif card[0][1] and card[1][1] and card[2][1]:
    ans="Yes"
elif card[0][2] and card[1][2] and card[2][2]:
    ans="Yes"
elif card[0][0] and card[1][1] and card[2][2]:
    ans="Yes"
elif card[0][2] and card[1][1] and card[2][0]:
    ans="Yes"
print(ans)

Measured memory_bytes: 38384
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef ll Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
// a^b mod MOD
ll powmod(ll a,ll b,ll m=1000000007){
	ll out=1;
	ll p=a%m;
	while(b){
		if(b&1)out=out*p%m;
		p=p*p%m;
		b>>=1;
	}
	return out;
}
int main(){
	int n,m,MOD=1000000007;
	cin>>n>>m;
	vi a(n),b(n);
	rep(i,n)cin>>a[i];
	rep(i,n)cin>>b[i];
	
	vvi me(n,vi(m+1));
	rep(i,n)rep(j,m+1){
		int sum=0;
		loop(k,a[i],b[i]+1)(sum+=powmod(k,j))%=MOD;
		me[i][j]=sum;
	}
	
	vvi dp(n+1,vi(m+1));
	dp[0][0]=1;
	rep(i,n)rep(j,m+1)rep(k,m+1-j)
		(dp[i+1][j+k]+=dp[i][j]*me[i][k]%MOD)%=MOD;
	
	cout<<dp[n][m]<<endl;
}








Measured memory_bytes: 2816
import numpy as np

N,K,Q = map(int, input().split())
A = []
for i in range(Q):
  tmp = int(input())
  A.append(tmp)

count_A = np.zeros(N)
for i in range(Q):
  count_A[A[i]-1] += 1

for i in range(N):
  if K-(Q-count_A[i]) <= 0:
    print('No')
  else:
    print('Yes')
  
               

Measured memory_bytes: 18244
r, c = (int(x) for x in input().split())

s = ([0 for x in range(c)])

for i in range(r):
    cell = ([int(x) for x in input().split()])
    
    cell_sum = 0
    for j in range(c):
        print(cell[j], end=' ')
        
        s[j] += cell[j]
        cell_sum += cell[j]
    print(cell_sum)

total = 0;
for i in s:
    print(i, end=' ')
    
    total += i
    
print(total)


Measured memory_bytes: 5640
using System;
 
namespace _135C
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] read = Console.ReadLine().Split();
            long H = long.Parse(read[0]);
            long W = long.Parse(read[1]);
            if(H == 1 || W == 1){
                Console.WriteLine(1);
            }
            else if((H*W)%2==0){
                Console.WriteLine(H*W/2);
            }else{
                Console.WriteLine(H*W/2+1);
            }
        }
    }
}

Measured memory_bytes: 11092
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int m = sc.nextInt();
		int x = sc.nextInt();

		int[] c = new int[n];
		int[][] a = new int[n][m];

		for ( int i=0; i<n; i++ ) {
			c[i] = sc.nextInt();
			for ( int j=0; j<m; j++ ) {
				a[i][j] = sc.nextInt();
			}
		}

		// 全部買ってもだめなら絶対だめ
		for ( int j=0; j<m; j++ ) {
			int rki = 0;
			for ( int i=0; i<n; i++ ) {
				rki += a[i][j];
			}
			if ( rki<x ) {
				System.out.println(-1);
				System.exit(0);
			}
		}

		int g = 0;
		// 仮に、合計金額
		for ( int i=0; i<n; i++ ) {
			g += c[i];
		}

		int[] b = new int[n];
		int f = 1;
		while ( f>0 ) {
			f = createbit(b, f);

			int f1 = 0;
			for ( int j=0; j<m; j++ ) {
				int rki = 0;
				for ( int i=0; i<n; i++ ) {
					rki += a[i][j]*b[i];
				}
				if ( rki<x ) {
					f1 = -1;
					break;
				}
			}

			if ( f1==0 ) {
				int g1 = 0;
				for ( int i=0; i<n; i++ ) {
					g1 += c[i]*b[i];
				}
				g = Math.min(g, g1);
			}
		}

		System.out.println(g);
	}

	private static int createbit(int[] ary, int flag){
		int hen = flag;
		for ( int i=ary.length-1; i>=0; i-- ) {
			ary[i] = hen%2;
			hen = hen/2;
		}

		int mod = (int)Math.pow(2, ary.length);
		return (flag+1)%mod;
	}
}

Measured memory_bytes: 37648
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t n;
  cin >> n;
  int64_t a,cnt[n];
  for(int64_t i=1;i<=n;i++)cnt[i]=0;
  while(cin >> a){
    cnt[a]++;
  }
  for(int64_t i=1;i<=n;i++){
    cout << cnt[i] << endl;
  }
}


Measured memory_bytes: 5144
N,K = map(int,input().split(" "))
a = list(map(int,input().split(" ")))

for i in range(N-1):
    a[i+1] += a[i]

seq = []
for i in range(N):
    for sl in range(i+1):
        if sl == 0:
            seq.append(a[N-1-i+sl])
        else:
            seq.append(a[N-1-i+sl] - a[sl-1])

ans = 0
l = len(seq)
for i in range(50,-1,-1):
    cnt = 0
    s = set()
    for j in range(l):
        if seq[j] >= 0 and (seq[j] & (1<<i)) != 0:
            cnt += 1
            s.add(j)

    if cnt >= K:
        ans += (1 << i)
        for j in range(l):
            if j in s:
                seq[j] = seq[j] - (1 << i)
            else:
                seq[j] = -1


print(ans)

Measured memory_bytes: 73652
import java.io.*;
import java.util.*;


public class Main {
    static final long DIV = 1000000007;
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        String s = sc.next();
        for(int u=0; u<3; u++){
            if(s.charAt(u) == s.charAt(u+1)){
                System.out.println("Bad");
                return;

            }
        }
        System.out.println("Good");
    }

    private static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;

        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }

        private int readByte() {
            if (hasNextByte())
                return buffer[ptr++];
            else
                return -1;
        }

        private static boolean isPrintableChar(int c) {
            return 33 <= c && c <= 126;
        }

        public boolean hasNext() {
            while (hasNextByte() && !isPrintableChar(buffer[ptr]))
                ptr++;
            return hasNextByte();
        }

        public String next() {
            if (!hasNext())
                throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while (isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }

        public long nextLong() {
            if (!hasNext())
                throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while (true) {
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if (b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }

        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
                throw new NumberFormatException();
            return (int) nl;
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}



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

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

#define rep(i,j) for(int i=0;i<(j);i++)
#define reps(i,j,k) for(int i=j;i<k;i++)
#define in(i,j,k) ((i)>=(j)&&(i)<=(k))
#define INF (1<<28)
#define pb push_back
#define fs first
#define sc second

const char dx[]={0,1,0,-1},dy[]={1,0,-1,0};
template<class T>
ostream &operator<<(ostream &out, const vector<T> &v){
	out << "{";
	rep(i,v.size()) out << v[i] << ", " ;
	return out << "}" << endl;
}
template<class S,class T>
ostream &operator<<(ostream &out, const pair<S,T> p){
	return out << "(" << p.fs << ", " << p.sc << ")";
}
int main(){
	string str;
	cin >> str;
	int ok = 0;
	rep(i,str.length()){
		if(ok == 0 && str[i]=='C')ok++;
		if(ok && str[i]=='F')ok++;
	}
	cout << (ok>1?"Yes":"No") << endl;
	return 0;
}


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

using namespace std;

int main(){
    long long n, m, k;
    cin >> n >> m >> k;
    vector<long long> a(n), b(m);
    for(int i = 0; i < n; i++) cin >> a[i];
    for(int i = 0; i < m; i++) cin >> b[i];
    long long ans = 0, tmp = 0, a_sum = 0, b_sum = 0, i, j;
    for(i = 0; i < n; i++){
        if(a_sum + a[i] > k) break;
        a_sum += a[i];
        ans++;
    }
    for(j = 0; j < m; j++){
        if(a_sum + b_sum + b[j] > k) break;
        b_sum += b[j];
        ans++;
    }
    i--;
    tmp = ans;
    while(i >= 0){
        tmp--;
        a_sum -= a[i];
        for(; j < m; j++){
            if(a_sum + b_sum + b[j] > k) break;
            b_sum += b[j];
            tmp++;
        }
        i--;
        ans = max(ans, tmp);
    }
    cout << ans;
    return 0;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> d(N,0);
  
  for (int j=0; j<M; j++) {
    int a, b;
    cin >> a >> b;
    for (int i=0; i<N; i++) {
      if (a==i+1 || b==i+1) {
        d.at(i) += 1;
      }
    }
  }
  for (int i=0; i<N; i++) {
    cout << d.at(i) << endl;
  }
}

Measured memory_bytes: 3500
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    int mod = 1e9 + 7;
    scanf("%d", &n);
    vector<int>a[n];
    int x;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            scanf("%d",&x);
            if(x == 1){
                a[i].push_back(j);
            }
        }
    }
    int m = (1 << n);
    int dp[m];
    memset(dp, 0,sizeof(dp));
    for(int i = 0; i < a[0].size(); i++){
        dp[(1 << a[0][i])] = 1;
    }
    for(int i = 1; i < n; i++){
        for(int j = m - 1; j > 0; j--){
            if(__builtin_popcount(j) == i + 1){
                for(int k = 0; k < a[i].size(); k++){
                    if(j & (1 << a[i][k])){
                        dp[j] = (dp[j] + dp[j - (1 << a[i][k])]) % mod;
                    }
                }
            }
        }
    }
    printf("%d\n",dp[m - 1]);
    return 0;
}  

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

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

#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
#define ALL(v) (v).begin(), (v).end()
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
 
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
 
#if 1
//-------------
// DUMPマクロ
// https://www.creativ.xyz/dump-cpp-652/

#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)

// vector
template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    for (T& x : vec) is >> x;
    return is;
}
// pair
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
// vector
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
// map
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
    os << "{";
    repi(itr, map_var) {
        os << *itr;
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
    os << "{";
    repi(itr, set_var) {
        os << *itr;
        itr++;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
 
#define DUMPOUT cerr
 
void dump_func() {
    DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&& ... tail) {
    DUMPOUT << head;
    if (sizeof...(Tail) > 0) {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}
#ifdef DEBUG
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif


template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

#endif

#define mod 1000000007
typedef pair<int, int> P;
#define INF (1LL<<60)

void solve(){
    int A[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    
    int k ;
    cin >> k;
    
    cout << A[k-1] << endl;
    
    
}

signed main(){
    cout << fixed << setprecision(18);
    cerr << fixed << setprecision(18);
    solve();
}


Measured memory_bytes: 256
#include<stdio.h> 
#define NINE 10 

int main(void) 
{
	int i,j; 
	int mt[10]; 
	
	for(i=1;i<NINE;i++){
		 for(j=1;j<NINE;j++){
		 	 printf("%dx%d=%d\n",i,j,i*j); 
		 } 
	}

return 0; 
}

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

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

	long long ma = 0;
	long long ans = 0;
	for( int i = 0; i < N; i++ ) {
		if( A[i] > ma ) ma = A[i];
		ans += ma - A[i];
	}

	cout << ans << endl;
}


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

int h, w;
string s[12];
vector<vector<int> > cnt(12, vector<int>(26, 0));

bool check(vector<int> ord) {
  string t[w];
  for ( int i = 0; i < h; i++ ) {
    for ( int j = 0; j < w; j++ ) t[j].push_back(s[ord[i]][j]);
  }

  bool flag = false;
  int cnt = 0;
  int bit = 0;
  for ( int i = 0; i < w; i++ ) {
    if ( (1 << i) & bit ) continue;
    bool flag2 = false;
    for ( int j = 0; j < w; j++ ) {
      if ( ((1 << j) & bit) || i == j ) continue;
      reverse(t[i].begin(), t[i].end());
      if ( t[i] == t[j] ) {
	cnt += 2;
	bit |= (1<<i)+(1<<j);
	reverse(t[i].begin(), t[i].end());
	flag2 = true;
	break;	
      }
      reverse(t[i].begin(), t[i].end());      
    }
    if ( !flag2 ) {      
      if ( flag || w%2 == 0 ) return false;
      string u = t[i];
      reverse(u.begin(), u.end());
      if ( u == t[i] ) flag = true, cnt++, bit |= 1<<i;
      else return false;
    }
  }

  cout << "YES" << endl;
  exit(0);
  return true;
}

bool select(vector<int> ord, int bit, int num) {
  if ( h - num <= 1 ) {
    if ( h % 2 == 0 ) return check(ord);
    else {
      for ( int i = 0; i < h; i++ ) {
	if ( (1 << i) & bit ) continue;
	ord[h/2] = i;
	break;
      }
      return check(ord);
    }
  } else {
    int ret = 0;
    for ( int i = 0; i < h; i++ ) {
      if ( (1 << i) & bit ) continue;      
      ord[num/2] = i;
      int nbit = bit | 1<<i;
      for ( int j = 0; j < h; j++ ) {
	if ( ((1 << j) & bit) || cnt[i] != cnt[j] || i == j ) continue;      
	ord[h-num/2-1] = j;
	ret |= select(ord, nbit | 1<<j, num+2);
      }
    }
    return ret;
  }
}

int main() {
  cin >> h >> w;
  for ( int i = 0; i < h; i++ ) cin >> s[i];

  for ( int i = 0; i < h; i++ ) {
    for ( int j = 0; j < w; j++ ) cnt[i][s[i][j]-'a']++;
  }
 
  select(vector<int>(h), 0, 0);  
  cout << "NO" << endl;
  
  return 0;
}


Measured memory_bytes: 256
int main(void){
  int n;
  long d;
  scanf("%d%ld", &n, &d);
  d=d*d;
  int ans=0;
  for(int i=0; i<n; i++){
    long x, y;
    scanf("%ld%ld", &x, &y);
    ans+=(x*x+y*y<=d);
  }
  printf("%d\n", ans);
}

Measured memory_bytes: 1696
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(a); i++)
typedef long long ll;
template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

/////////////////////////////////////////////////////////////////////
const ll inf = 1LL<<60;

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

map<ll, ll> prime_factor(ll n)
{
  map<ll, ll> res;
  for (ll i=2; i*i<=n; i++) {
    while (n%i == 0) {
      ++res[i];
      n /= i;
    }
  }
  if (n != 1) res[n] = 1;
  return res;
}

int main()
{
  ll a,b; cin>>a>>b;
  ll g = gcd(a,b);
  map<ll, ll> mp = prime_factor(g);

  ll ans = 1;
  for (auto v:mp) {
    if (v.second > 0) ans++;
  }
  cout << ans << endl;

  return 0;
}


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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

ll f(ll n){
	if(n==1) return 1;
	else return 1+2*f(n/2);
}

int main(){
	ll h;
	cin >> h;
	cout << f(h) << endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = [int(input()) for _ in range(n)]

ans = 0
visited = set([0])
next_visit_idx = 0
while True:
  next_visit_idx = a[next_visit_idx] -1
  ans += 1
  if next_visit_idx == 1:
    print(ans)
    break
  if next_visit_idx in visited:
    print(-1)
    break
    
  visited.add(next_visit_idx)

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

int main() {
  int N;
  cin >> N;
  for (int i = 1; i < 10; i++) {
    if (111 * i >= N) {
      cout << 111 * i << endl;
      break;
    }
  }
}


Measured memory_bytes: 3544
#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string> 
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <list>
#include <cstring>
#include <stack>
   
using namespace std;

int main()
{
    for(int i = 1; i < 10; i++){
        for(int j = 1; j < 10; j++){
            cout << i << "x" << j << "=" << i * j << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1116
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n>> k;
    vi a(n+1);
    rep(i, n) {
        cin >> a[i];
    }
    a[n] = 0;
    vi a_(n+1);
    rep(vv, k) {
        rep(i, n) {
            int b = i-a[i];
            int f = i+a[i]+1;
            if(b < 0) b = 0;
            if(f > n) f = n;
            a_[b]++;
            a_[f]--;
        }
        bool x = true;
        rep(i, n) {
            a[i] = a_[i];
            if(i) a[i] += a[i-1];
            a_[i] = 0;
            if(a[i] != n) x = false;
        }
        if(x) break;
    }

    rep(i, n) {
        cout << a[i] << (i == n-1 ? '\n':' ');
    }
}

Measured memory_bytes: 4744
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pii pair<int,int>
#define pli pair<long long int,int>
#define pbi pair<bool,int>
#define pob pop_back
#define all(a) a.begin(),a.end()
#define fio ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define i64 long long int
#define mem(x,y) memset(x,y,sizeof(x))
#define fill(arr,b) fill(arr, arr+sizeof(arr)/sizeof(arr[0]), b)
#define maxarr(n,arr,m) m =-1e9;for(int i=0;i<n;i++)if(arr[i]>m) m=arr[i];
#define read freopen("input.txt","r",stdin);

const double pi = acos(-1.0);
const int maxn = (i64)2e9+5;

int main()
{
   int n,m,a,sum=0;
   cin >> n >> m;
   while(m--)
   {
       cin >> a;
       sum += a;
   }
   if(sum > n) cout << "-1";
   else cout << n-sum;
   return 0;
}


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

int main(){
    int ans=0,sum=0;
    int n,m;
    
    cin >>n;
    int a[n],b[n],c[n];
    int dp[n][3];

    for (int i = 0; i < n; i++){
        cin >>a[i]>> b[i]>> c[i];
    }
    
    dp[0][0]=a[0];
    dp[0][1]=b[0];
    dp[0][2]=c[0];

    for (int i = 1; i < n; i++){
        
        dp[i][0]= max(dp[i-1][1] + a[i] , dp[i-1][2] + a[i]);
        dp[i][1]= max(dp[i-1][0] + b[i] , dp[i-1][2] + b[i]);
        dp[i][2]= max(dp[i-1][0] + c[i] , dp[i-1][1] + c[i]);
    }
    


    //cout <<fixed<<setprecision(16)<< << endl;
    cout << max(max(dp[n-1][0],dp[n-1][1]),dp[n-1][2]) << endl;

    //if(flag==1)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 2560
import math

# input
K = int(input())

# initialization
ans = 0

# count
for a in range(1, K+1):
    for b in range(1, K+1):
        tmp = math.gcd(a, b)
        for c in range(1, K+1):
            tmp_1 = math.gcd(tmp, c)
            ans += tmp_1

# output
print(ans)


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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x, y) CPP_CAT_I(x, y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x, y) x##y

#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;
// }}}

constexpr i64 INF = 1'010'000'000'000'000'017LL;

constexpr i64 MOD = 1'000'000'007LL;

constexpr f64 EPS = 1e-12;

constexpr f64 PI = 3.14159265358979323846;

#define M5 100007
#define M9 1000000000

// util {{{
#define FOR(i, start, end) for (i64 i = (start), CPP_CAT(i, xxxx_end) = (end); i < CPP_CAT(i, xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)

#define ALL(f, c, ...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ##__VA_ARGS__); })(c))
#define ll long long int
#define VI vector<int>
template <typename C>
i64 SIZE(const C &c)
{
    return static_cast<i64>(c.size());
}

template <typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }

template <typename T, typename U, typename Comp = less<>>
bool chmax(T &xmax, const U &x, Comp comp = {})
{
    if (comp(xmax, x))
    {
        xmax = x;
        return true;
    }
    return false;
}

template <typename T, typename U, typename Comp = less<>>
bool chmin(T &xmin, const U &x, Comp comp = {})
{
    if (comp(x, xmin))
    {
        xmin = x;
        return true;
    }
    return false;
}
// }}}

// init {{{
struct ProconInit
{
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit()
    {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if (AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;
// }}}

//--------------------------------------------------------------------

bool isOK(int mid, double key)
{
}

int binary_search(double key)
{
    int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
    int right = 2000000000;
    /* どんな二分探索でもここの書き方を変えずにできる！ */
    while (right - left > 1)
    {
        int mid = left + (right - left) / 2;

        if (isOK(mid, key))
            right = mid;
        else
            left = mid;
    }

    /* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
    return right;
}

bool isKaibun(string st)
{
    bool ans = true;
    int n = st.length();
    REP(i, n / 2)
    {
        if (st[i] != st[n - i - 1])
        {
            return false;
        }
    }
    return true;
}

int toInt(char a)
{
    return a - '0';
}

int gcd(int a, int b)
{
    if (a % b == 0)
    {
        return (b);
    }
    else
    {
        return (gcd(b, a % b));
    }
}

int lcm(int a, int b)
{
    return a * b / gcd(a, b);
}

void solve()
{
    string S;
    cin >> S;
    if (S == "ABC")
    {
        cout << "ARC";
    }
    else
    {
        cout << "ABC";
    }
}

signed main()
{

    solve();

    return 0;
}


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

using namespace std;

typedef struct
{
	long long attack;
	long long hp;
} monster;

int main()
{
	monster t, a;
	cin >> t.hp >> t.attack >> a.hp >> a.attack;
	while (true)
	{
		if ((a.hp -= t.attack) <= 0)
		{
			cout << "Yes" << endl;
			return 0;
		}
		else if ((t.hp -= a.attack) <= 0)
		{
			cout << "No" << endl;
			return 0;
		}
	}
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mit map<int,int>::iterator
#define sit set<int>::iterator
#define itrm(g,x) for(mit g=x.begin();g!=x.end();g++)
#define itrs(g,x) for(sit g=x.begin();g!=x.end();g++)
#define ltype int
#define rep(i,j,k) for(ltype (i)=(j);(i)<=(k);(i)++)
#define rap(i,j,k) for(ltype (i)=(j);(i)<(k);(i)++)
#define per(i,j,k) for(ltype (i)=(j);(i)>=(k);(i)--)
#define pii pair<int,int>
#define fi first
#define se second
#define mpr make_pair
#define pb push_back
#define fastio ios::sync_with_stdio(false)
const int inf=0x3f3f3f3f,
mod=1000000007;
const double pi=3.1415926535897932,
eps=1e-6;
int n,x,num[200005],pre,ans;char s[200005];bool flg=1,g[200005];
int main()
{
    scanf("%d%s",&n,s+1);x=1;
    rep(i,1,n) x=(ll)x*i%mod;
    g[1]=0;
    rep(i,2,2*n)
    if(s[i]==s[i-1]) g[i]=!g[i-1];else g[i]=g[i-1];
    ans=x;pre=0;
    rep(i,1,2*n) {
        if(g[i]) pre--;
        else pre++,ans=((ll)ans*pre)%mod;
    }
    if(s[1]=='W'||pre!=0) printf("0");
    else printf("%d",ans);
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (a + b == c + d)
    {
        cout << "Balanced" << endl;
    }
    else if (a + b > c + d)
    {
        cout << "Left" << endl;
    }
    else if (a + b < c + d)
    {
        cout << "Right" << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<string> vstring;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;
#define Pi 3.1415926535897932384626
#define mod llint(1e9+7)

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long& x, long long& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

bool check(pllint a, pllint b) {
	return a > b;
}

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//aCbを1000000007で割った余りを求める
llint convination(llint a, llint b) {
	llint ans = 1;
	for (llint i = 0; i < b; i++) {
		ans *= a - i;
		ans %= 1000000007;
	}
	for (llint i = 1; i <= b; i++) {
		ans *= modinv(i, 1000000007);
		ans %= 1000000007;
	}
	return ans;
}

//aのb乗をmodで割った余りを求める
llint power(llint a, llint b) {
	if (b == 1)return a;
	if (b == 0)return 1;
	llint tmp = power(a, (llint)b / 2);
	tmp *= tmp;
	tmp %= mod;
	if (b % 2 == 1) {
		tmp *= a;
		tmp %= mod;
	}
	return tmp;
}

int main() {
	int a, b;
	cin >> a >> b;
	if (a > b)swap(a, b);
	if (b == 2)cout << 3 << endl;
	else if (a == 1)cout << 2 << endl;
	else cout << 1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, i, mochi=0, r=0;
  cin >> N;
  vector<int> d(N);
  
  for(i=0; i<N; i++)
    cin >> d.at(i);
  sort(d.begin(), d.end());
  
  for(i=0; i<N; i++) {
    if(mochi != d.at(i))
      r++;
    mochi = d.at(i);
  }
  cout << r << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 200100
using namespace std;
vector<int> g[N];
int to_leaf[N];
long long p3sz[N],nume[N][3];
const int Q=998244353;
int find_c(int u,int p){
	int mx[2]={u,u},ans=0;
	for(int i=0;i<g[u].size();i++){
		int v=g[u][i];
		if(v==p) continue;
		ans=max(ans,find_c(v,u));
		if(to_leaf[v]>to_leaf[mx[0]]){
			mx[1]=mx[0];
			mx[0]=v;
		}
		else if(to_leaf[v]>to_leaf[mx[1]]){
			mx[1]=v;
		}
	}
	ans=max(ans,to_leaf[mx[0]]+to_leaf[mx[1]]);
	to_leaf[u]=to_leaf[mx[0]]+1;
	return ans;
}
void build(int u,int p){
	to_leaf[u]=0;
	for(int i=0;i<g[u].size();i++){
		int v=g[u][i];
		if(v==p) continue;
		build(v,u);
		to_leaf[u]=max(to_leaf[u],to_leaf[v]+1);
	}
}
void solve(int u,int p){
	p3sz[u]=1;
	if(!to_leaf[u]){
		nume[u][1]=1;
		return;
	}
	nume[u][0]=1;
	for(int i=0;i<g[u].size();i++){
		int v=g[u][i];
		if(v==p) continue;
		solve(v,u);
		if(to_leaf[v]+1==to_leaf[u]){
			for(int j=2;j>=0;j--){
				if(p) nume[u][j]*=nume[v][0]+2*p3sz[v];
				else nume[u][j]*=2*nume[v][0]+p3sz[v];
				if(j) nume[u][j]+=nume[u][j-1]*nume[v][1];
				nume[u][j]%=Q;
			}
		}
		else{
			for(int j=0;j<3;j++){
				nume[u][j]=3*p3sz[v]*nume[u][j]%Q;
			}
		}
		p3sz[u]=3*p3sz[v]*p3sz[u]%Q;
	}
}
int main(){
	int n,x,y;
	scanf("%d",&n);
	for(int i=1;i<n;i++){
		scanf("%d%d",&x,&y);
		g[x].push_back(y);
		g[y].push_back(x);
	}
	int l,p=0,c=1;
	l=find_c(1,0);
	bool flag=true;
	while(flag){
		flag=false;
		for(int i=0;i<g[c].size();i++){
			if(g[c][i]!=p && to_leaf[g[c][i]]>(l+1)/2){
				p=c;
				c=g[c][i];
				flag=true;
				break;
			}
		}
	}
	//printf("diameter=%d\n",l);
	if(l&1){
		int d=-1;
		for(int i=0;i<g[c].size();i++){
			if(to_leaf[g[c][i]]==(l+1)/2){
				d=g[c][i];
				break;
			}
		}
		//printf("center: %d %d\n",c,d);
		assert(d>0);
		build(c,d);
		solve(c,d);
		build(d,c);
		solve(d,c);
		printf("%lld\n",1LL*nume[c][1]*nume[d][1]%Q);
	}
	else{
		//printf("center: %d\n",c);
		build(c,0);
		solve(c,0);
		printf("%lld\n",nume[c][2]);
	}
	return 0;
}

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

using namespace std;

#define LOG(...) fprintf(stderr, __VA_ARGS__)
//#define LOG(...)
#define FOR(i, a, b) for(int i=(int)(a); i<(int)(b); ++i)
#define REP(i, n) for(int i=0; i<(int)(n); ++i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SQ(n) (n) * (n)

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main() {
  int N, m;
  cin >> N >> m;
  vi shop(N+10);
  REP(i, m){
    int c, d;
    cin >> c >> d;
    shop[c-1]++;
    shop[d-1]--;
  }
  int res = N + 1;
  int cnt = 0;
  int start = -1;
  REP(i, N){
    if(shop[i] == 0) continue;
    cnt += shop[i];
    if(start == -1) start = i;
    if(cnt == 0) {
      res += (i - start) * 2;
      start = -1;
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 3104
def digitlen n
  i = 1
  while n != 0
    n /= 10
    i += 1
  end
  i - 1
end

n = gets.to_i
min = digitlen n
i = 2
while i * i <= n
  if n % i == 0
    min = [min, [digitlen(i), digitlen(n / i)].max].min
  end
  i += 1
end
puts min


Measured memory_bytes: 1788
#include<stdio.h>
int sub(int a)
{
	int i=0;
	while(a!=0)
	{
		a/=10;
		i++;
	}
	return i;
}

int main(void)
{
	int N,i,x=0;
	
	scanf("%d",&N);
	for(i=1;i<=N;i++)
	{
		if(sub(i)%2==1)
		{
			x++;
		}
	}
	printf("%d",x);
	
	return 0;
}

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

#define ll long long
#define ld long double
#define pi 3.14159265359
int main(){
    double L; cin >> L;
    double a = L / 3;
    double ans = pow(a, 3);
    cout << fixed << setprecision(6);
    cout << ans << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,rpta=0,val=1;
  cin>>n;
  for (int i=0;i<n;i++){
    int aux; cin>>aux;
    (aux==val)?val++:rpta++;}
  (val>1)?cout<<rpta:cout<<"-1";
  return 0;}

Measured memory_bytes: 256
// 3500なのに872 1012974 1539173474040とはいかに...と思ったが「保証されている」ってだけだった
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)
	for h := 1; h <= 3500; h++ {
		for n := 1; n <= 3500; n++ {
			if 4*n*h > N*h+N*n && N*h*n%(4*n*h-N*h-N*n) == 0 {
				w := N * h * n / (4*n*h - N*h - N*n)
				if w > 0 {
					fmt.Println(h, n, w)
					return
				}
			}
		}
	}
}


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

const int N=1e5+1e3+7;

int n,a[N],mx,mn=N*2;

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]),mx=max(mx,a[i]),mn=min(mn,a[i]);
	if(mx-mn>=2)
	{
		cout<<"No";
		return 0;
	}
	if(mn>n/2&&mx==mn)
	{
		if(mx==n-1)
		{
			cout<<"Yes";
			return 0;
		}
		else
		{
			cout<<"No";
			return 0;
		}
	}
	else
	if(mx==mn)
	{
		cout<<"Yes";
		return 0;
	}
	int k=0;
	for(int i=1;i<=n;i++)
		if(a[i]==mx)
			k++;
	if(2*(mx-(n-k))>k||mx-(n-k)<=0)
	{
		cout<<"No";
		return 0;
	}
	cout<<"Yes";
}

Measured memory_bytes: 640
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
#include <functional>
 
using namespace std;
typedef long long ll;
// const ll INF = 1e18;

# define rep(i, n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(ll i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(ll i=((int)(n)); i>0; --i)
# define all(x) (x).begin(), (x).end()
# define pb push_back
 
ll X;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    cin >> X;
    
    ll shou = X / 500;
    ll amari = X % 500;
    
    ll hoge = amari / 5;
    
    ll ans = shou * 1000 + hoge * 5;
    
    cout << ans << endl;
    return 0;
}


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


int main() {
    int N; cin >> N;
    string S; cin >> S;
    bool ans = true;
    if (S.size() % 2 != 0) {
        ans = false;
    } else {
        for (int i = 0; i < S.size() / 2; ++i) {
            if (S[i] != S[i + S.size() / 2]) {
                ans = false;
            }
        }
    }
    if (ans) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
using namespace std;
struct UnionFind {
  int *data;
  UnionFind(int *_data, int size) : data(_data) {
    for(int i = 0; i < size; i++) data[i] = -1;
  }
  bool unionSet(int x, int y) {
    x = find(x); y = find(y);
    if (x != y) {
      if (data[y] < data[x]) std::swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  int find(int x) {
    return data[x] < 0 ? x : data[x] = find(data[x]);
  }
  int size(int x) {
    return -data[find(x)];
  }
};
int main(int argc, char *argv[])
{
  // kruskal with x being unused.
  // assumption: es is sorted
  auto kruskal = [](int n, const vector<pair<int,pair<int,int>>> &es, int x, vector<bool> &used) {
    vector<int> ufdata(n);
    UnionFind uf(&(ufdata[0]), n);
    int sum = 0;
    for(int i = 0; i < es.size(); i++) {
      if(i == x) continue;
      const int u = es[i].second.first;
      const int v = es[i].second.second;
      if(uf.find(u) != uf.find(v)) {
        used[i] = true;
        uf.unionSet(u, v);
        sum += es[i].first;
      }
    }
    return sum;
  };
  int n, m;
  vector<pair<int,pair<int,int>>> es;
  cin >> n >> m;
  for(int i = 0; i < m; i++) {
    int s, d, c;
    cin >> s >> d >> c;
    es.push_back(make_pair(c, make_pair(s-1, d-1)));
  }
  sort(es.begin(), es.end());
  vector<bool> used(m, false);
  vector<bool> used2(m, false);
  int mn = kruskal(n, es, -1, used);
  int sum = 0;
  int cnt = 0;
  for(int i = 0; i < m; i++) {
    if(!used[i]) continue;
    int mni = kruskal(n, es, i, used2);
    if(mni != mn) {
      cnt ++;
      sum += es[i].first;
    }
  }
  cout << cnt << " " << sum << endl;
  return 0;
}




Measured memory_bytes: 3816
import java.util.*;

public class Main {

  static int N;
  static int M;
  static boolean[][] graph;
  static boolean[] visited;

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);

    N = sc.nextInt();
    M = sc.nextInt();
    graph = new boolean[N][N];

    for (int i = 0; i < M; i++) {
      int a = sc.nextInt() - 1;
      int b = sc.nextInt() - 1;
      graph[a][b] = true;
      graph[b][a] = true;
    }

    sc.close();

    visited = new boolean[N];

    visited[0] = true;

    int count = dfs(0);

    System.out.println(count);

  }

  static int dfs(int v) {
    
    boolean all = true;

    for (int i = 0; i < N; i++) {
      if (visited[i] == false) {
        all = false;
        break;
      }
    }

    if (all) {
      return 1;
    }

    int count = 0;

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

      if (graph[v][i] == false) {
        continue;
      }

      if (visited[i]) {
        continue;
      }

      visited[i] = true;

      count += dfs(i);

      visited[i] = false;

    }

    return count;

  }
}

Measured memory_bytes: 23892