akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;
// const int mod = 998244353;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


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

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
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...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

int main() {
  string S;
  cin >> S;
  auto dp = make_v< int64 >(2019);
  int64 ret = 0;
  for(auto &c : S) {
    auto dp2 = make_v< int64 >(2019);
    for(int i = 0; i < 2019; i++) {
      dp2[(i * 10 + (c - '0')) % 2019] += dp[i];
    }
    dp2[c - '0']++;
    ret += dp2[0];
    dp.swap(dp2);
  }
  cout << ret << endl;
}

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

int main() {
  long long n;
  cin >> n;
  string ans = "";
  while (n) {
    ans += (n - 1) % 26 + 'a';
    n = (n - 1) / 26;
  }
  reverse(ans.begin(), ans.end());
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <functional>

using namespace std;

int main(){

  long long n;
  cin >> n;
  vector<long long> a(n);
  vector<long long> as(n+1);
  vector<long long> asb(n+1);
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  as[0] = a[0];
  for(int i = 0; i < n - 1; i++){
    as[i + 1] = as[i] + a[i + 1];
  }


  asb=as;
  long long op = 0;
  long long bal = 0;
  long long diff = 0;
  
  for(int i = 0; i < n; i++){
    if(i%2==0){
      if(as[i] + bal <= 0){
        diff = abs(as[i] + bal) + 1;
        op += diff;
        bal += diff;
        as[i] += diff;
      }
    }else{
      if(as[i] + bal >= 0){
        diff = as[i] + bal + 1;
        op += diff;
        bal -= diff;
        as[i] -= diff;
      }
    }
  }
  long long ans = op;
  as = asb;
  op = 0;
  bal = 0;
  for(int i = 0; i < n; i++){
    if(i%2==1){
      if(as[i] + bal <= 0){
        diff = abs(as[i] + bal) + 1;
        op += diff;
        bal += diff;
        as[i] += diff;
      }
    }else{
      if(as[i] + bal >= 0){
        diff = as[i] + bal + 1;
        op += diff;
        bal -= diff;
        as[i] -= diff;
      }
    }
  }
  ans = min(op, ans);
  cout <<ans << endl;
  return 0;
} 


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

using namespace std;

const int MAX_N=7.4*1e6;
int primes[MAX_N+1];//i????´???°??????true

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

  while(true){
      int m,n;cin>>m>>n;
      if(m==0&&n==0) break;
      for(int i=0;i<MAX_N;i++) primes[i]=true;
      int count=0;
      primes[0]=primes[1]=false;
      for(int i=m;i<=MAX_N;i++){
          if(primes[i]){
              for(int j=2*i;j<=MAX_N;j+=i) primes[j]=false;
              count++;
              if(count>n){
                  cout<<i<<endl;
                  break;
              }
          }
      }
  }
}

Measured memory_bytes: 31992
#include<stdio.h>

int main()
{
    char word[5];
    scanf("%s", word);
    int counta=1, countb=0, flag;
    for(int i=1; i<4; i++)
    {
        if(word[0]==word[i])
            counta++;
    }
    for(int i=0; i<4; i++)
    {
        if(word[0] != word[i])
            flag=i;
    }
    for(int i=0; i<4; i++)
    {
        if(word[i]==word[flag])
            countb++;
    }
    //printf("%d %d", counta, countb);
    if(counta==2 && countb==2)
        printf("Yes");
    else
        printf("No");
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <complex>
#include <vector>
#include <functional>
#include <algorithm>
using namespace std;

bool second_small(const pair<int, int> &p1, const pair<int, int> &p2) {
	if (p1.second < p2.second) {
		return true;
	} else if (p1.second == p2.second && p1.first < p2.first) {
		return true;
	} else {
		return false;
	}
}

int main() {
	int N;
	cin >> N;
	vector<pair<int, int> > v;
	for (int i = 0; i < N; i++) {
		int a, b;
		cin >> a >> b;
		v.push_back(make_pair(a, b));
	}
	sort(v.begin(), v.end(), second_small);

	int time = 0;
	int f = true;
	for (int i = 0; i < N; i++) {
		int s = v[i].first, limit = v[i].second;
		time += s;
		if (time > limit) {
			f = false;
			break;
		}
	}
	if (f) {
		cout << "Yes\n";
	} else {
		cout << "No\n";
	}
}


Measured memory_bytes: 2420
#include <iostream>
using namespace std;
void swap_(int* a,int* b){
	int temp=*a;*a=*b;*b=temp;
}
int main(){
	char ch[4];int cup[3]={1,0,0};
	while(cin >> ch){
		int temp[2];
		for(int i=0; i<=2;i+=2){
		if(ch[i]=='A') temp[i/2]=0;
			else if(ch[i]=='B') temp[i/2]=1;
			else if(ch[i]=='C') temp[i/2]=2;
		};
		swap_(&cup[temp[0]],&cup[temp[1]]);
	};
	if(cup[0]==1) cout << "A\n" ;
	else if(cup[1]==1) cout << "B\n" ;
	else if(cup[2]==1) cout << "C\n" ;
}

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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

ll n;
vl a,s;
ll solve(bool b){
  ll res = 0;
  if(a[0] == 0){
      if(b)s[1] = 1;
      else s[1] = -1;
      res++;
  }
  else if(a[0] > 0){
      if(b)s[1] = a[0];
      else{
          s[1] = -1;
          res += abs(a[0])+1;
      } 
  }
  else{
      if(b){
          s[1] = 1;
          res += abs(a[0])+1;
      }
      else s[1] = a[0];
  }
  rep1(i,n){
      if(s[i] < 0){
          if(a[i] < 0){
              res+=abs(a[i])+abs(s[i])+1;
              s[i+1] = 1;
          }
          else{
              s[i+1] = s[i]+a[i];
              if(s[i+1] <= 0){
                  res+=abs(s[i+1])+1;
                  s[i+1]=1;
              }
          }
      }
      else{
          if(a[i] <= 0){
              s[i+1] = s[i] + a[i];
              if(s[i+1] >= 0){
                  res+=s[i+1]+1;
                  s[i+1] = -1;
              }
          }
          else{
              res+=abs(a[i])+abs(s[i])+1;
              s[i+1] = -1;
          }
      }
  }
  return res;
}
signed main()
{   
  gearup;
  cin >> n;
  a.resize(n);
  s.resize(n+1);
  rep(i,n)cin>>a[i];

  ll ans = solve(false);
  ans = min(solve(true),ans);

  out(ans);
}


Measured memory_bytes: 1792
a = input().split()
#print(a)
x = a[0]
y = a[1]
def h(x,y):
    d = dict()
    d = {'1':300000,'2':200000,'3':100000}
    if x=='1' and y =='1':
        print(1000000)
        return
    res = 0
    res = d.get(x,0) + d.get(y,0)
    print(int(res))
h(x,y)

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

#define rep(i,n) for(ll i = 0; i < n; i++)
#define per(i,n) for(ll i = n-1; i >= 0; i--)
#define REP(i,n) for(ll i = 1; i < n; i++)
#define PER(i,n) for(ll i = n; i >= 1; i--)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
using vP = vector<P>;
using vPP = vector<vP>;
using vPl = vector<Pl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



int main(){
  int m, d;
  cin >> m >> d;
  int ans = 0;
  REP(i,m+1) {
    for(int j = 10; j <= d; j++) {
      int a = j / 10;
      int b = j % 10;
      if(a < 2 || b < 2) continue;
      if(a * b == i) {
        ans++;
      }
    }
  }
  cout << ans << endl;
}

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

int main()
{
	string s;
	while (true){
		getline(cin, s);
		if (s == ".")return 0;
		bool flag = true;
		stack<char> sta;
		for (int i = 0; flag && i < s.length(); ++i){
			if (s[i] == '(' || s[i] == '['){
				sta.push(s[i]);
			}
			else if (s[i] == ')'){
				if (sta.empty() || sta.top() != '(')flag = false;
				else sta.pop();
			}
			else if (s[i] == ']'){
				if (sta.empty() || sta.top() != '[')flag = false;
				else sta.pop();
			}
		}
		if (!sta.empty())flag = false;
		if (flag)cout << "yes" << endl;
		else cout << "no" << endl;
	}
}


Measured memory_bytes: 3160
#include <iostream>
using namespace std;
int main(){
  int H,W,num = 0;
  cin >> H >> W;
  char str[H * W];
  for(int i = 0; H * W > i; i++){
    cin >> str[i];
  }
  for(int k = -1; H + 1 > k; k++){
    for(int l = -1; W + 1 > l; l++){
      if(k == -1 || k == H || l == -1 || l == W){
        cout << "#";
      } else {
        cout << str[num];
        num++;
      }
    }
    cout << endl;
  }
}

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

using namespace std;

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

int main(){
    int n;
    cin >> n;
    int t[n];
    rep(i, n) cin >> t[i];
    int m;
    cin >> m;
    int p[m], x[m];
    rep(i, m) {
        cin >> p[i] >> x[i];
        p[i]--;
    }
    int T = 0;
    rep(i, n) T += t[i];
    rep(i, m){
        int ans = T;
        ans -= t[p[i]];
        ans += x[i];
        cout << ans << endl;
    }

}

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

using namespace std;

#define REP(i,last) for (int i=0;i<last;i++)
#define MAX(x,y) (x > y ? x : y)
#define MIN(x,y) (x < y ? x : y)
#define prints(str) cout << str << " ";
#define printn(str) cout << str << endl;

int main(){
  long N;
  cin >> N;

  int s_n = sqrt(N);
  
  int smaller = 1;
  for (int i=s_n;2<=i;--i) {
    if (N % i == 0) {
      smaller = i;
      break;
    }
  }

  cout<< to_string(N / smaller).size() <<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
inline ll read() {
    ll x=0,f=1; char ch=getchar();
    for(;ch<'0'||ch>'9';ch=getchar())
        if(ch=='-')f=-f;
    for(;ch>='0'&&ch<='9';ch=getchar())
        x=x*10+ch-'0';
    return x*f;
}
inline void chkmin( ll &a,ll b ) { if(a>b) a=b; }
inline void chkmax( ll &a,ll b ) { if(a<b) a=b; }
#define _ read()
const int N=1e5+5;
int a,b,q;
ll A[N],B[N];
inline pair< ll,ll >  find( ll x ) {
	ll resa=9e18,resb=9e18;
    int pos=upper_bound(A+1,A+a+1,x)-A;
    if(pos>1)  resa=A[pos-1];
    if(pos<=a) resb=A[pos];
   	return make_pair(resa,resb);
}
inline pair< ll,ll > find2 ( ll x ) {
	ll resa=9e18,resb=9e18;
    int pos=upper_bound(B+1,B+b+1,x)-B;
    if(pos>1)  resa=B[pos-1];
    if(pos<=b) resb=B[pos];
    return make_pair(resa,resb);
}
inline ll solve( ll x,ll a,ll b ) {
	if(a>b) swap(a,b);
	if(b<x) return abs(x-a);
	else if(a>x) return abs(b-x);
	else return b-a+min(abs(x-a),abs(b-x));
}
inline ll calc( ll x ) {
	pair< ll ,ll > p=find(x);
	pair< ll ,ll > w=find2(p.first),ww=find2(p.second);
	ll resa=min(solve(x,p.first,w.first),solve(x,p.first,w.second));
	ll resb=min(solve(x,p.second,ww.first),solve(x,p.second,ww.second));
	return min(resa,resb);
}
inline ll calc2( ll x ) {
	pair< ll ,ll > p=find2(x);
	pair< ll ,ll > w=find(p.first),ww=find(p.second);
	ll resa=min(solve(x,p.first,w.first),solve(x,p.first,w.second));
	ll resb=min(solve(x,p.second,ww.first),solve(x,p.second,ww.second));
	return min(resa,resb);
}
int main() {
	a=_; b=_; q=_;
	for( int i=1;i<=a;i++ ) A[i]=_;
		sort(A+1,A+a+1);
	for( int i=1;i<=b;i++ ) B[i]=_;
		sort(B+1,B+b+1);
	for( int i=1;i<=q;i++ ) {
		ll x=_;
		cout<<min(calc(x),calc2(x))<<"\n";
	}
}

Measured memory_bytes: 2816
#include<bits/stdc++.h>
using namespace std;
template <typename T> using vec = vector<T>;

int main()
{
    char c;
    int n,w,s,e;
    n=s=w=e=0;
    while (cin >> c)
    {
        if (c == 'N')
        {
            n++;
        }
        else if (c == 'S')
        {
            s++;
        }
        else if (c == 'W')
        {
            w++;
        }
        else
        {
            e++;
        }
    }
    if (!(!!n xor !!s)and!(!!w xor !!e))
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<functional>
#include<algorithm>
#include<string>
#include<map>
#include<queue>

using namespace std;

int main(void){

    int n, k;
    cin >> n >> k;

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

    cout << ((n-1)+(k-1)-1)/(k-1) << endl;

    return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
int main(){
  int h, w, i, j;
  while(1){
    scanf("%d %d",&h,&w);
    if(h==0 && w==0) break;

    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
	printf("#");
      }
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}



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

int main(){
    int a, x, y, n, i, r, l = 0, u, d = 0;
    cin >> r >> u >> n;
    for(i=0; i<n; i++){
        cin >> x >> y >> a;
        if(a == 1){
            l = max(l, x);
        }else if(a == 2){
            r = min(r, x);
        }else if(a == 3){
            d = max(d, y);
        }else{
            u = min(u, y);
        }
    }
    cout << max(0, u-d)*max(0, r-l);
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <map>
#include <stdint.h>
#include <vector>
using namespace std;

int main()
{
    cin.tie(0);
    int n;
    int64_t k;
    cin >> n >> k;

    vector<pair<int64_t, int64_t>> vs(n);
    for (auto& p : vs) {
        cin >> p.first >> p.second;
    }

    int64_t ans = 0;
    for (int i = 0; i <= 31; i++) {
        int mask = k;
        int lo = 0;

        if (k & (1 << i)) {
            mask = k & ~((1 << i) - 1);
            mask -= 1 << i;
            lo = (1 << i) - 1;
        }

        int64_t sum = 0;
        for (int j = 0; j < n; j++) {
            int c = vs[j].first & ~lo;
            if ((c & ~mask) == 0) {
                sum += vs[j].second;
            }
        }
        // cout << i << ", " << sum << endl;
        ans = max(ans, sum);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
#!/usr/bin python3
# -*- coding: utf-8 -*-

def main():
    N = int(input())
    B = list(map(int,input().split()))
    ret = []
    while len(B)>0:
        for j in range(len(B)-1,-1,-1):
            if B[j]==j+1:
                ret.append(j+1)
                B.pop(j)
                break
            if j==0 and B[j]!=(j+1):
                print(-1)
                exit()
    print('\n'.join(map(str,ret[::-1])))


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
// マクロ
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
// 型エイリアス
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vvs = vector<vs>;

int main() {
    int n, d, x;
    cin >> n >> d >> x;
    int sum = n;
    for(int i = 0; i < n; i++) {
        int a;
        cin >> a;
        sum += (d-1) / a;
    }
    cout << sum + x << endl;
}

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

void solve(){
	int n,k;
	cin>>n>>k;
	priority_queue<ll>pq;
	for(int i=0;i<n;i++){
		ll a;
		cin>>a;
		pq.push(a);
	}
	while(k--){
		ll x=pq.top();
		pq.pop();
		x>>=1;
		pq.push(x);
	}
	ll ans=0;
	while(not pq.empty()){
		ans+=pq.top();
		pq.pop();
	}
	cout<<ans<<endl;
}

int main(){
	// int t;
	// cin>>t;
	// while(t--){
		solve();
	// }
	return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
typedef long long int lld;
typedef vector<lld> vll;
#define pb push_back
#define rep(i,a,b) for(i=a;i<b;i++)
#define srt(v) sort(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())
#define mod 1000000007
#define pi 3.1415926535
lld a,b,c,d,e,f,g,h,i,j,k=0,l=0,m=1,n=1,o,q=0,r=0,u,v,w,x,y,z,s,t,p=0;
lld temp=0,ans=0;
double f1,f2,f3,f4,f5,f6;
char c2,c3,c4,c5,c6;
vll v11;
pair<lld,lld>p1,p2,p3;
map<lld,lld>mv;bool a12[200005],a13[200005];
bool b11[500006],c11[500006];lld a11[500006];
lld gcd(lld a, lld b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
}
void dfs(lld i,vector<lld>vg[])
{
    if(b11[i]==true)    return;
    v11.pb(i);
    p++;
    b11[i]=true;
    for(auto x11:vg[i])
    {
        if(b11[x11]==false)
        {
            dfs(x11,vg);
        }
    }
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  t=1;
  //cin>>t;
  while(t--)
  {
    string s3,s1,s2;
    cin>>n>>k>>m;
    //lld p1,q1,a1,b1,c1,d1;
    //lld a1[n+1]={0},b1[n],c1[n+1];vector<lld>vg[n+1];
    map<lld,lld>m1,m2;queue<lld>q2;vll v1,v2;
    if((n%k)==0)
    {
        cout<<(n*m)/k;
    }
    else
    {
        cout<<((n/k)+1)*m;
    }
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 3596
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    n = readline() |> parseInt
    f = 0
    for i in 1:9
        for j in 1:9
            if i*j==n
                f = 1
            end
        end
    end
    println(f==1?"Yes":"No")
end

main()

Measured memory_bytes: 109548
from math import *

N, M = map(int, input().split())
special_value = M//N
divisor_set = set(i for i in range(1, (int(sqrt(M)) + 1)) if (M % i == 0))
divisor_set = divisor_set.union(M//j for j in divisor_set)
print(int(max(divisor_set, key=lambda x: x if special_value >= x else -1)))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n), b(n);
  rep(i,n) cin >> a[i] >> b[i];
  vector<int> c(m), d(m);
  rep(i,m) cin >> c[i] >> d[i];
  rep(i,n) {
    int ans = INF;
    int p = -1;
    rep(j,m) {
      int t = abs(a[i] - c[j]) + abs(b[i] - d[j]);
      if (t < ans) {
        ans = t;
        p = j + 1;
      }
    }
    cout << p << endl;
  }
}

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

Measured memory_bytes: 3608
#include<stdio.h>
#include<math.h>

int main()
{
	double n;
	double i;
	scanf("%lf", &n);
	for (i = 0; i < 100; i++) {
		if (pow(2,i+1) > n) {
			break;
		}
	}
	printf("%.0f", pow(2,i));
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0;i < n;i++)
#define rev(i, n) for(int i = n;i >= 0;i--)
#define Rep(i, m, n) for(int i = m;i < n;i++)
#define repeatrev(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define itn int

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
typedef priority_queue<int> Pr;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b, c;
    cin >> a >> b >> c;
    if(c - (a - b) >= 0)cout << c - (a - b) << endl;
    else cout << 0 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

int main() {
  i64 N, K;
  cin >> N >> K;
  double ans = 0;
  for(int i = 1;i <= N;i++) {
    double res = 1;
    i64 now = i;
    while(now < K) {
      res *= 0.5;
      now *= 2;
    }
    ans += res;
  }
  cout << fixed << setprecision(10) << ans / N << endl;
}


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

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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

//INT_MAX	2,147,483,647 = 2*1.0e9

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int c[3][3];

    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            cin >> c[i][j];
        }
    }
    
    int sum=c[0][0] + c[1][1] + c[2][2];
    bool ans = true;
        
    if(sum != c[0][1] + c[1][2] + c[2][0]) ans = false;
    if(sum != c[0][2] + c[1][0] + c[2][1]) ans = false;
    if(sum != c[0][2] + c[1][1] + c[2][0]) ans = false;
    if(sum != c[0][1] + c[1][0] + c[2][2]) ans = false;
    if(sum != c[0][0] + c[1][2] + c[2][1]) ans = false;
        
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		int ll = 0;
		Scanner scan = new Scanner(System.in);
		String S = scan.next();
		String[] str = S.split("");
		ll = str.length - 2;
		System.out.println(str[0] + ll +str[str.length - 1]);
		scan.close();
	}

}

Measured memory_bytes: 21972
from copy import deepcopy
N = int(input())
A = [list(map(int, input().split())) for _ in range(N)]
B = deepcopy(A)

s = 0
for i in range(N):
    via = A[i]
    for j in range(N):
        start = A[j]
        for k in range(N):
            if start[k] > start[i]+via[k]:
                print(-1)
                exit()

for j in range(N):
    for k in range(j):
        a = A[j][k]
        for i in range(N):
            if i in {j, k}:
                continue
            if a == A[j][i]+A[i][k]:
                break
        else:
            s += a
            # print(j,k,a)
print(s)

Measured memory_bytes: 71920
#include <stdio.h>
#include <math.h>
int main(){
  int i,n;
  double xa,ya,xb,yb,ra,rb;

  scanf("%d",&n);
  for (i=0;i<n;i++){
    scanf("%lf %lf %lf %lf %lf %lf",&xa,&ya,&ra,&xb,&yb,&rb);
    double d=sqrt(pow((xa-xb),2)+pow((ya-yb),2));
    if (d>ra+rb)
      printf("0\n");
    else if (d==ra==rb)
        printf("1\n");
    else if ((d<ra-rb) && (ra>rb))
      printf("2\n");
    else if ((d<rb-ra) && (ra<rb))
      printf("-2\n");
    else
      printf("1\n");
  }
  return 0;
}

Measured memory_bytes: 620
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};
int main() {
    int H,W,A,B;
    mint answer;
    cin >> H >> W >> A >> B;
    combination x(H+W);
    for (int i = 1; i <= H-A; i++) {
        answer += x(B-1+i-1,i-1)*x(W-B-1+H-i,H-i);
    }
    cout << answer.x;
}

Measured memory_bytes: 3328
# from math import factorial,sqrt
# from itertools import permutations as permus
# from fractions import gcd
# from collections import deque,Counter
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

import numpy as np
# import scipy as scp

# 盤面の受け取り
h,w = map(int,input().split())
board = [[] for _ in range(h)]
for i in range(h):
    board[i] = list(input())

moves = [(-1,-1),(-1, 0), (-1, 1), (0, -1), (0, 1), (1, -1), (1, 0),(1,1)]
for ih in range(h):
    for iw in range(w):
        # print(ih,iw)
        if board[ih][iw] == "#":
            continue
        else:
            board[ih][iw] = 0
            for move in moves:
                mh = ih+move[0]
                mw = iw+move[1]
                if mh>=0 and mh<h and mw>=0 and mw<w:
                    if board[mh][mw] == "#":
                        board[ih][iw] += 1
                    else:
                        continue
                else:
                    continue
            continue

for row in board:
    print("".join(map(str,row)))

# print(ans)
# print("{:.10f}".format(ans))


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

int main()
{
  int K, A, B;

  cin >> K;
  cin >> A >> B;

  if (K == 1 || A % K == 0 || B % K == 0 || int(B / K) - int(A / K) >= 1)
  {
    cout << "OK" << endl;
  }
  else
  {
    cout << "NG" << endl;
  }
  return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define int long long
using namespace std;
int n,k,d[9];
signed main(){
    cin>>n>>k;
    for(int i=0;i<k;i++)cin>>d[i];
    while(1){
        int m=n;
        while(m){
            int o=m%10;
            for(int i=0;i<k;i++){
                if(d[i]==o)goto ioi;
            }
            m/=10;
        }
        cout<<n<<endl;
        system("PAUSE");
        return 0;
        ioi:;
        n++;
    }
}

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

namespace _2185
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            for (int i = 0; i < n; i++)
            {
                int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
                int m = int.Parse(Console.ReadLine());
                int ret = 0;
                for (int j = 0; j < m; j++)
                {
                    int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
                    if (x[0] <= a[0] && a[0] <= x[0] + x[2] &&
                        x[1] <= a[1] && a[1] <= x[1] + x[3]) ret++;
                }
                Console.WriteLine(ret);
            }
        }
    }
}


Measured memory_bytes: 9872
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define SQ(x) ((x)*(x))
#define Mod(x, mod) (((x)+(mod)%(mod))
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define INF 1 << 29
#define EPS 1e-10
#define MOD 1000000007

typedef pair<int, int> P;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

vector<P> G[5001];
vector<int>g[5001];
int d[5001];
int N, K;
int C[5001], R[5001];

void bfs(int n, int r){
  queue<P>q;
  map<int, int>m;
  m[n] = 0;
  q.push(P(0, n));
  while(!q.empty()){
    P p = q.front(); q.pop();
    if(p.first >= r) continue;
    int cur = p.second;
    rep(i, g[cur].size()){
      int tar = g[cur][i];
      if(m.find(tar) == m.end() || m[tar] > p.first+1){
	q.push(P(p.first+1, tar));
	m[tar] = p.first+1;
      }
    }
  }
  map<int, int>::iterator it;
  for(it = m.begin(); it != m.end(); it++) if(it->first != n) G[n].push_back(P(it->first, C[n]));
}

void dijkstra(int s){
  fill(d, d+N, INF);
  d[s] = 0;
  priority_queue<P, vector<P>, greater<P> >q;
  q.push(P(0, s));

  while(!q.empty()){
    int cur = q.top().second, v = q.top().first; q.pop();
    if(v > d[cur]) continue;
    rep(i, G[cur].size()){
      P p = G[cur][i];
      if(d[p.first] > v + p.second){
	d[p.first] = v + p.second;
	q.push(P(d[p.first], p.first));
      }
    }
  }
}

int main(){
  scanf("%d%d", &N, &K);
  rep(i,N) scanf("%d%d", C+i, R+i);
  rep(i, 5001) g[i].clear();
  rep(i, 5001) G[i].clear();
  int a, b;
  rep(i, K){
    scanf("%d%d", &a, &b); a--; b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  rep(i, N) bfs(i, R[i]);

  dijkstra(0);
  printf("%d\n", d[N-1]);
  
  return 0;
}

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

int main() {
  // Nは偶数
  int N;
  cin >> N;
  vector<int> D(N);
  rep(i, N) cin >> D[i];
  sort(D.begin(), D.end());
  int diff = D[N/2] - D[N/2 - 1];
  cout << diff << '\n';
  return 0;
}

Measured memory_bytes: 3768
#include<cstdio>
#define abs(a) ((a)>=0?(a):(-(a)))
#define min(a,b) ((a)<(b)?(a):(b)) 
#define maxn 100050
using namespace std;
int dp[maxn],a[maxn];
int main(){
	int n,k=2;
	scanf("%d%d",&n,&k);
	for (int i=1;i<=n;i++)
	scanf("%d",&a[i]),dp[i]=1e9;
	dp[1]=0;
	for (int i=2;i<=n;i++){
		for (int j=1;j<=k;j++)
		if (i-j>0) dp[i]=min(dp[i],dp[i-j]+abs(a[i-j]-a[i]));
	}
	printf("%d\n",dp[n]);
	return 0;
}

Measured memory_bytes: 896
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)















int main() {
	ll n, k, s;
	cin >> n >> k >> s;
	vector<ll> a(n, (s == 1e9) ? 1e9 - 1 : 1e9);
	REP(i, k) a[i] = s;
	REP(i, n) cout << a[i] << " \n"[i == n - 1];
}

Measured memory_bytes: 2048
k=int(input())
def gcd(a,b):
    while a%b!=0:
        c=a%b
        a=b
        b=c
    return b
ans=0
for l in range(k):
    for m in range(l,k):
        x=gcd(m+1,l+1)
        for n in range(m,k):
            ai=gcd(n+1,x)
            if l<m and m<n:
                ans+=6*ai
            elif l==m and m==n:
                ans+=ai
            else:
                ans+=ai*3
            
print(ans)


Measured memory_bytes: 68556
#include<iostream>
#include<cmath>
using namespace std;

int main()
{
    long long int n,d,ans=0;
    cin>>n>>d;
    while(n--)
    {
        long long int x,y;
        cin>>x>>y;
        double k=sqrt(pow(x,2)+pow(y,2));
        if(k<=d)
        {
            ans++;
        }
    }
    cout<<ans;
}


Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> P;

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

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << endl;}

//GCD(最大公約数)
ll gcd(ll a, ll b) {
    return b ? gcd(b, a % b) : a;
}

//LCM(最小公倍数)
ll lcm(ll a, ll b) {
   return a / gcd(a, b) * b;  //オーバーフローする場合など 必要に応じて
}

int main() {
    ll a, b;
    cin >> a >> b;
    
    cout << lcm(a, b) << endl;
    
    return 0;
}


Measured memory_bytes: 256
use proconio::input;

fn main() {
  input! {
    n: usize,
    x: usize,
    t: usize,
  }
  
  let v = n / x;
  if n % x == 0 {
    println!("{}", v * t);
  } else {
  	println!("{}", v * t + t);
  };
}

Measured memory_bytes: 2148
#include <cstdio>
typedef long long ll;
ll q, h, s, d, n;
ll ans;
inline ll re() {
	ll x = 0; char ch = getchar(); bool f = 0;
	for(; ch>'9'||ch<'0'; ch = getchar())if(ch == '-') f = 1;
	for(; ch>='0'&&ch<='9'; ch = getchar()) x = (x<<1)+(x<<3)+ch-48;
	if(f) return -x;
	return x;
}
int main() {
	q = re(); h = re(); s = re(); d = re();
	n = re();
	if((q<<1) < h) h = q<<1;
	if((h<<1) < s) s = h<<1;
	if((s<<1) < d) d = s<<1;
	ans += (n>>1)*d; n %= 2;
	ans += n*s;
	printf("%lld",ans);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define int long long int
#define double long double
#define mod 1000000007
#define w(t) \
   int t;    \
   cin >> t; \
   while (t--)
#define f(i, a, n) for (int i = a; i < n; i++)
#define pb push_back
#define pob pop_back
#define mk make_pair
#define ARMY                         \
   ios_base::sync_with_stdio(false); \
   cin.tie(NULL);                    \
   cout.tie(NULL);
using namespace std;
vector<string> v;
int dp[3001][3001];
int len(string &s, string &t,int i,int j)
{
    if(i>=s.length() or j>=t.length())
      return 0;
      if(dp[i][j]!=-1)
        return dp[i][j];
      if(s[i]==t[j])
        { return dp[i][j]=1+len(s,t,i+1,j+1);}
     else
      {
         return dp[i][j]=max(len(s,t,i+1,j),len(s,t,i,j+1));
      }
}
string LCS(string &s,string &t,int le)
{   string ans;
   int i=0,j=0;
   while(le>0)
    {
       if(s[i]==t[j])
        {
           ans.push_back(s[i]);
           le--;
           i++;
           j++;
          
        }
        else
        {
           if(dp[i+1][j]>dp[i][j+1])
              i++;
            else
            {
               j++;
            }
            
        }        
    }
    return ans;
}
string solve(string s, string t)
{
   memset(dp,-1,sizeof dp);
   int le = len(s, t,0,0);
   return LCS(s,t,le);
}
int32_t main()
{
   ARMY
     
   
      string s,t;
      cin>>s>>t;
      cout << solve(s,t);
   
}

Measured memory_bytes: 74364
#define mod 1000000007
#include<time.h>
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<map>
#include<queue>
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
const ll INF=0x7fffffffffffffff;
const int inf=0x7fffffff;
const int N=1e4+5;
clock_t start,finish;
void time_in(){start=clock();}
void time_out(){finish=clock();double tim=(double)(finish-start)/CLOCKS_PER_SEC;printf("Running time is %lf\n",tim);}
ll mul(ll a,ll b){ll s=0;while(b){if(b&1)s=(s+a)%mod;a=(a<<1)%mod;b>>=1;}return s%mod;}
ll pow_mul(ll a,ll b){ll s=1;while(b){if(b&1)s=mul(s,a);a=mul(a,a);b>>=1;}return s;}
ll poww(ll a,ll b){ll s=1;while(b){if(b&1)s=(s*a)%mod;a=(a*a)%mod;b>>=1;}return s%mod;}
int t,cas;
int n,m;
int main()
{
	int a[N],sum[N];
	while(~scanf("%d",&n))
	{
		sum[n+1]=0;
		for(int i=1;i<=n;i++)
			scanf("%d",&a[i]);
		for(int i=n;i>=1;i--)
			sum[i]=sum[i+1]+a[i];
		ll ans=0;
		for(int i=1;i<n;i++)
			ans=ans+a[i]*sum[i+1];
		printf("%lld\n",ans);
	}
}


Measured memory_bytes: 888
x,k,d = map(int,input().split())

a = abs(x) - k*d

if a>0:
    print(a)
elif a==0:
    print(0)
else:
    ap = int(abs(x) / d)
    if (k-ap) % 2 == 0:
        print(abs(x)-ap*d)
    else:
        print((ap+1)*d-abs(x))
exit()

Measured memory_bytes: 9088
#include <stdio.h>
 
int main(){
  int i,k;
  int s[5];
  for(i=0;i<5;i++){
    scanf("%d",&s[i]);
  }
  scanf("%d", &k);
  
  if((s[4]-s[0])<=k){
    printf("Yay!");
  }else{
    printf(":(");
  }
  return 0;
}

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

const int N = 307;

double dp[N][N][N];
int n, vis[N][N][N];

double solve(int x, int y, int z){
	
	if(vis[x][y][z]) return dp[x][y][z];

	vis[x][y][z] = 1;

	if(x == 0 && y == 0 && z == 0)
		return dp[x][y][z] = 0;

	int sum = x + y + z;
	double c = (double) sum;
	double tot = (n - sum)/c;

	if(x != 0) tot += x*((solve(x-1, y, z) + 1)/c);
	if(y != 0) tot += y*((solve(x+1,y-1,z) + 1)/c);
	if(z != 0) tot += z*((solve(x,y+1,z-1) + 1)/c);

	return dp[x][y][z] = tot;

}

int main(){
	//freopen("t.in", "r", stdin);
	//freopen("t.out", "w", stdout);

	int a[4] = {0, 0, 0, 0};

	cin >> n;

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

	printf("%.9lf\n", solve(a[1], a[2], a[3]));

	return 0;
}

Measured memory_bytes: 334080
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        String x ="";
        for(int a=1; 1<=a && a<=9; a++) {
            for(int b=1; 1<=b && b<=9; b++) {
                if(a*b == n) {
                  x = "Yes";  
                    break;
                }
            }
        }
        if(x != "Yes") {
            x = "No";
        }
        System.out.println(x);
    }
}

Measured memory_bytes: 22740
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	ans := ""
	for n > 0 {
		m := n % 26
		if m == 0 {
			ans = "z" + ans
			n--
		} else {
			m--
			ans = string('a'+m) + ans
		}
		n /= 26
	}

	fmt.Println(ans)
}


Measured memory_bytes: 1772
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int mod = 1e9 + 7;

int add(int a, int b)
{
    return (a % mod + b % mod) % mod;
}
int pw(int x, int y)
{
    int p = mod;
    int res = 1;
    x = x % p;
    if (x == 0)
        return 0;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}

int32_t main()
{
    int n;
    cin >> n;
    cout << (add((add(pw(10, n), -(2 * pw(9, n) % mod)) + mod) % mod, pw(8, n)) + mod) % mod;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
int f(int k){
	if(k==0)return 1;
	else return 2*f(k-1);
}
int main() {
	int n;cin>>n;
	switch (n){
		case  1: cout<<"1\n";   break;
		case  2: cout<<"2\n";   break;
		case  3: cout<<"4\n";   break;
		case  4: cout<<"6\n";   break;
		case  5: cout<<"16\n";  break;
		case  6: cout<<"12\n";  break;
		case  7: cout<<"64\n";  break;
		case  8: cout<<"24\n";  break;
		case  9: cout<<"36\n";  break;
		case 10: cout<<"48\n";  break;
		case 11: cout<<"1024\n";break;
		case 12: cout<<"60\n";  break;
		default:                break;
	}
	return 0;
}


Measured memory_bytes: 3080
S = input()
T = input()
trans_dict = dict()
trans_dict_ = dict()
flg = 0
for s, t in zip(S, T):
    if trans_dict.get(s) is None:
        trans_dict[s] = t
    elif trans_dict.get(s) == t:
        continue
    else:
        flg = 1
        break
    if trans_dict_.get(t) is None:
        trans_dict_[t] = s
    elif trans_dict.get(t) == s:
        continue
    else:
        flg = 1
        break
if flg == 1:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Vec2(T, n, m, xs, x0) vector<vector<T>> xs(n, vector<T>(m, x0))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs, 0); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")

// constexpr int MOD = 1e9+7;
#include <deque>

int main(void){
    Cin(int, h, w, n, sr, sc);
    Cin(string, s, t);
    Reverse(s);
    Reverse(t);
    int l = 0, r = 0, u = 0, d = 0;
    int ml = 0, mr = 0, mu = 0, md = 0;

    For(i, n){
        switch(t[i]){
            case 'L': if(r > 0) r --; break;
            case 'R': if(l > 0) l --; break;
            case 'U': if(d > 0) d --; break;
            case 'D': if(u > 0) u --; break;
        }
        switch(s[i]){
            case 'L': l ++; break;
            case 'R': r ++; break;
            case 'U': u ++; break;
            case 'D': d ++; break;
        }
        ml = max(ml, l);
        mr = max(mr, r);
        mu = max(mu, u);
        md = max(md, d);
    }
    //Cout(l, " ", r, " ", u, " ", d);
    if(ml >= w || mr >= w || mu >= h || md >= h){
        Cout("NO");
    }
    else{
        CoutYN(u < sr && sr <= h-d && l < sc && sc <= w-r);
    }
}   

Measured memory_bytes: 776
n,w = gets.chomp.split(" ").map(&:to_i)
dp = []
for i in 1..n
  wei,val = gets.chomp.split(" ").map(&:to_i)
  inst = [[wei,val]]
  if dp.length > 0
    for i in 0..dp.length - 1
      if dp[i][0]+wei <= w
        inst.push([dp[i][0]+wei,dp[i][1]+val])
      end
    end
  end
  for j in 0..inst.length - 1
    dp.push(inst[j])
  end
  dp.sort!
  count = 0
  while count != dp.length - 1
    if dp[count][1] >= dp[count+1][1]
       dp.delete_at(count+1)
    else
       count += 1
    end       
  end
end
puts dp[-1][1]


Measured memory_bytes: 2936
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if(a < b){ a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if(a > b){ a = b; return 1; } return 0; }
using pi = pair<int,int>;
vector<int> dx = {1, 0, -1, 0};
vector<int> dy = {0, 1, 0, -1};
vector<pi> mov(int x, int y, int n) {
  vector<pi> res;
  rep(j,4) {
    int nx = x + dx[j];
    int ny = y + dy[j];
    if(0 < nx && nx <= n && 0 < ny && ny <= n) {
      res.push_back({nx, ny});
    }
  }
  return res;
}
int main()
{
  int n; cin >> n;
  vector<int> p(n*n);
  rep(i,n*n) {
    cin >> p[i];
  }

  vector<vector<int>> c(n+1, vector<int>(n+1));
  rep1(i,n) rep1(j,n) {
    c[i][j] = min({i-1, n-i, j-1, n-j});
  }

  auto show = [&]()-> void{
		rep1(i,n) {
		  rep1(j,n) cout << c[i][j] << " ";
		  cout << "\n";
		}  
	      };
  
  vector<vector<bool>> f(n+1, vector<bool>(n+1, true));


  int res = 0;
  rep(i,n*n) {
    int x = (p[i] + n - 1)/n;
    int y = (p[i] % n == 0 ? n : p[i] % n);
    res += c[x][y];
    f[x][y] = false;
    queue<pi> q;
    q.push({x, y});
    while( !q.empty() ) {
      pi pp = q.front(); q.pop();
      int xx = pp.first, yy = pp.second;
      vector<pi> buf = mov(xx, yy, n);
      rep(j,buf.size()) {
	int nx = buf[j].first;
	int ny = buf[j].second;	
	if(chmin(c[nx][ny], c[xx][yy] + f[xx][yy])) {
	  q.push({nx, ny});
	}
      }
    }
  }
  cout << res << "\n";
  return 0;
}


Measured memory_bytes: 5372
#include<bits/stdc++.h>
#define mx 100005
using namespace std;

int main(){
  int n, s, m[2][2], v[2][mx];
  scanf("%d", &n);
  for(int i = 0; i < mx; i++) v[0][i] = v[1][i] = 0;
  for(int i = 0; i < n; i++){
    scanf("%d", &s);
    v[i&1][s]++;
  }
  for(int i = 0; i < 4; i++) m[i&1][i>>1] = !(i>>1);
  for(int i = 2; i < mx; i++){
    for(int j = 0; j < 2; j++){
      if(v[j][m[j][0]] < v[j][i]){
        m[j][1] = m[j][0];
        m[j][0] = i;
      }else if(v[j][m[j][1]] < v[j][i]) m[j][1] = i;
    }
  }
  int t = (m[0][0] == m[1][0] ? max(v[0][m[0][1]] + v[1][m[1][0]], v[1][m[1][1]] + v[0][m[0][0]]) : v[0][m[0][0]] + v[1][m[1][0]]); 
  printf("%d\n", n-t);
}


Measured memory_bytes: 1024