akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vll = vector<vl>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const ll INF = 2e15;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

int main(){
  ll n;
  cin>>n;
  vl a(n);
  vl L(200007,0);
  vl R(200007,0);
  rep(i,n){
      cin>>a[i];
      ll x=i+1+a[i],y=i+1-a[i];
      if(0<x&&x<200007){
          L[x]++;
      }
      if(0<y&&y<200007){
          R[y]++;
      }
  }
  ll ans=0;
  for(ll i=1;i<=n;i++){
      ans+=L[i]*R[i];
  }
  print(ans);
}


Measured memory_bytes: 8012
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

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

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

    int ans = 1;
    rep(i, n) {
        ans = min(ans + k, ans * 2);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 100100100
#define MOD 1000000007

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

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

struct edge{ll to,cost;};

int main(int argc, char const* argv[]){
   ios::sync_with_stdio(false);
   cin.tie(0); 
   int N;
   string S;
   cin >> N >> S;
   int MAX = -1;
   for(int i=0;i<N;i++){
      int count = 0;
      vector<bool>check(26,false);
      for(int j=0;j<i;j++){
         for(int k=i;k<N;k++){
            if(S[j] == S[k] && !check[S[j]-'a']){
               count++;
               check[S[j]-'a'] = true;
            }
         }
      }
      MAX = max(MAX,count);
   }
   cout << MAX << endl;
   return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;

class User {
public:
	int k = 0, t = 0, g = -1;
	vector<int> f;
};

int E[100000], e1 = 0, e2 = 0, T[100000];
User u[100000];

void Serch(int s, int a) {
	for (int i = 0; i < u[s].k; i++) {
		if (u[u[s].f[i]].g < 0) {
			E[e1] = u[s].f[i]; e1++;
			u[u[s].f[i]].g = a;
		}
	}
	if (e2 < e1) { e2++; Serch(E[e2], a); }
}

int main() {
	int n, m, q, s, t, a = 0;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		cin >> s >> t;
		u[s].f.push_back(t); u[s].k++;
		u[t].f.push_back(s); u[t].k++;
	}

	for (int i = 0; i < n; i++) {
		if (u[i].g < 0) {
			a++; e1 = 1; e2 = 0; E[0] = i; u[i].g = a;
			Serch(i, a);
		}
	}

	cin >> q;
	for (int i = 0; i < q; i++) {
		e1 = 0; e2 = 0;
		for (int i = 0; i < n; i++) T[i] = 0;
		cin >> s >> t;
		if (u[s].g == u[t].g) cout << "yes" << endl;
		else cout << "no" << endl;
	}
}


Measured memory_bytes: 10872
#include <cstdio>
#include <algorithm>
#include <complex>
using namespace std;

int main() {
  for(int tci = 0; ; tci++) {
    double x1,y1,x2,y2,x3,y3,xp,yp;
    if(scanf("%lf%lf%lf%lf%lf%lf%lf%lf", &x1,&y1,&x2,&y2,&x3,&y3,&xp,&yp)<8) break;
    complex<double> ps[3];
    ps[0] = complex<double>(x1,y1);
    ps[1] = complex<double>(x2,y2);
    ps[2] = complex<double>(x3,y3);
    complex<double> pp(xp,yp);
    bool ok = true;
    for(int i = 0; i < 3; i++) {
      complex<double> v0 = ps[(i+1)%3]-ps[i];
      complex<double> v1 = ps[(i+2)%3]-ps[i];
      complex<double> vp = pp-ps[i];
      double det1 = (v0*conj(v1)).imag();
      double det2 = (v0*conj(vp)).imag();
      ok = ok & (det1 * det2 > 1e-9);
    }
    printf("%s\n", ok ? "YES" : "NO");
  }
  return 0;
}

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

using namespace std;

int v[200010];
int vis[200010];

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

    for (int i = 1; i <= n; ++i)
        cin >> v[i];

    int p = 1;
    
    vector<int> a,b;
    int cnt = 0;
    while(!vis[p]) {
        vis[p]++;
        p = v[p];
    }
    
    vis[p] = 2;
    p = 1;
    while(vis[p] != 2) {
        b.push_back(p);
        cnt++;
        p = v[p];
    }
    memset(vis, 0, sizeof vis);
    
    while(!vis[p]) {
        vis[p]++;
        a.push_back(p);
        p = v[p];
    }
    
    if(k < cnt) {
        cout << b[k] << "\n";
        return 0;
    }

    k -= cnt;
    long long mod = a.size();
    cout << a[(k % mod)] << "\n";
    return 0;
}


Measured memory_bytes: 5824
import java.util.Scanner;

/**
 * A - Circle
 */
public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner( System.in );
        // 半径
        int r = sc.nextInt();
        // 入力された半径の円の面積
        double radiusArea = r * r * Math.PI;
        // 半径1の円の面積
        double area1 = 1 * 1 * Math.PI;

        System.out.println( String.format( "%.0f", radiusArea / area1 ) );

        sc.close();
    }
}

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

int main(){
  int n;
  cin>>n;
  vector<ll> a(n);
  rep(i,n){
    ll A; cin>>A;
    A-=(i+1);
    a[i]=A;
  }
  sort(a.begin(),a.end());
  ll b = a[n/2];
  ll ans=0;
  rep(i,n){
    ans+=abs(a[i]-b);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 4812
# -*- coding: utf-8 -*-
import collections
N, K=map(int,input().split())
A=list(map(int,input().split()))
C=collections.Counter(A)
KEY=list(C.keys())
count=0
if len(KEY)>K:
    D=len(KEY)-K
    L=C.most_common()[::-1]
    for ii in range(D):
        count+=L[ii][1]

print(count)
    


Measured memory_bytes: 45720
#include<bits/stdc++.h>
#define rep(a,b,c) for(int a=b;a<=c;a++)
#define per(a,b,c) for(int a=b;a>=c;a--)
#define ios; ios::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define mk make_pair
#define fi first
#define se second
#define mem(a,b) memset(a,b,sizeof(a))
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
#define ls(x) (x<<1)
#define rs(x) (ls(x)|1)
#define eps 1e-11
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<int> VI;
typedef double db;
mt19937 rnd(random_device{}());
const int mod = 1e9 + 7;
const int N = 1e3 + 5;
const int M = 1e3 + 5;
inline ll gcd(ll a,ll b){ return b?gcd(b,a%b):a; }
inline ll lcm(ll a,ll b){ return a*b/gcd(a,b); }
inline ll ksm(ll x,ll y){ ll res=1; while(y){if(y&1) res=res*x%mod;
x=x*x%mod; y>>=1;} return res; }
int n,m,k;
string s;

int main(){
    ios;
    cin>>s;
    int ans=0;
    rep(i,0,2){
        if(s[i]=='R') ++ans;
    }
    if(ans==2){
        if(s[1]=='S') --ans;
    }
    cout<<ans;
    return 0;
}
/*
1
14 12
*/
//
//                            _ooOoo_
//                           o8888888o
//                           88" . "88
//                           (| -_- |)
//                           O\  =  /O
//                        ____/`---'\____
//                      .'  \|     |//  `.
//                     /  \|||  :  |||//  \
//                    /  _||||| -:- |||||-  \
//                    |   | \  -  /// |   |
//                    | \_|  ''\---/''  |   |
//                    \  .-\__  `-`  ___/-. /
//                  ___`. .'  /--.--\  `. . __
//               ."" '<  `.___\_<|>_/___.'  >'"".
//              | | :  `- \`.;`\ _ /`;.`/ - ` : | |
//              \  \ `-.   \_ __\ /__ _/   .-` /  /
//         ======`-.____`-.___\_____/___.-`____.-'======
//                            `=---='
//        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
//                     佛祖保佑      永无BUG


Measured memory_bytes: 3648
// yukicoder@csharp

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Runtime.CompilerServices;
//using System.Web.UI;
using Debug = System.Diagnostics.Debug;
// using System.Drawing.Primitives;
//using System.Drawing;
using System.Windows;
using System.Numerics;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            new Solver().Solve();
        }
    }

    //class Cout {
    //    public static Cout operator >>(
    //        Cout a, int b)
    //    {
    //        Console.WriteLine(b);
    //        return a;
    //    }
    //    //public void Cout(long a) { Console.WriteLine(a); }
    //    //public void Cout(double a) { Console.WriteLine(a); }
    //}

    class GeneralPurposeClass {
        //public const double inf = double.PositiveInfinity;
        public const long inf = 1L << 50;
        public static readonly TextWriter error = Console.Error;

        public void Rep(long n_, Action<int> action)
        {
            for (int i = 0; i < n_; i++)
            {
                action(i);
            }
        }

        public void Rep2(int a, long n_, Action<int> action)
        {
            for (int i = a; i < n_; i++)
            {
                action(i);
            }
        }

        public string ReadLine()
        {
            return Console.ReadLine();
        }

        public string ReadNext()
        {
            var s = "";
            while (true)
            {
                var c = Console.Read();
                if (c != ' ' && c != '\n' && c != '\r')
                {
                    s += (char)c;
                    break;
                }
            }
            while (true)
            {
                var c = Console.Read();
                if (c == ' ' || c == '\n' || c == '\r') break;
                s += (char)c;
            }
            return s;
        }

        public long ReadLong()
        {
            return Stol(ReadNext());
        }

        public long Stol(string s)
        {
            return long.Parse(s);
        }

        public static void Write<T>(T a)
            where T : IComparable
        { Console.Write(a); }

        public static void WriteL<T>(T a)
            where T : IComparable
        { Console.WriteLine(a); }

        public static void Dump<T>(string s, T a)
            where T : IComparable
        {
            error.WriteLine(s + ": " + a.ToString());
        }
    }

    class Solver : GeneralPurposeClass
    {
        public void Solve()
        {
            var n = ReadLong();
            Dump("n", n);

            var a = 0;
            Rep2(1, 10, (i) =>
            {
                if (n % i == 0) a = i;
            });
            var b = n / a;
            //WriteL("a: " + a);
            //WriteL("b: " + b);
            var c = 1 <= a && a <= 9 
                && 1 <= b && b <= 9;
            WriteL(c ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <cstdlib>

using namespace std;

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

    int h, w, d;
    cin >> h >> w >> d;
    int n = h * w;
    int x[n], y[n];
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            int a;
            cin >> a;
            a--;
            x[a] = i;
            y[a] = j;
        }
    }

    int ps[n];
    for (int i = 0; i < n; i++) {
        ps[i] = i < d ? 0 : ps[i-d] + abs(x[i] - x[i-d]) + abs(y[i] - y[i-d]);
    }

    int q;
    cin >> q;
    while (q--) {
        int l, r;
        cin >> l >> r;
        l--, r--;
        cout << ps[r] - ps[l] << endl;
    }

    return 0;
}


Measured memory_bytes: 2176
// 素因数分解

#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>;

/// Sieve of Eratosthenes　エラトステネスの篩
// https://youtu.be/UTVg7wzMWQc?t=2774
struct Sieve {
  int n;
  vector<int> f, primes;
  Sieve(int n=1):n(n), f(n+1) {
    f[0] = f[1] = -1;
    for (ll i = 2; i <= n; ++i) {
      if (f[i]) continue;
      primes.push_back(i);
      f[i] = i;
      for (ll j = i*i; j <= n; j += i) {
        if (!f[j]) f[j] = i;
      }
    }
  }
  bool isPrime(int x) { return f[x] == x;}
  vector<int> factorList(int x) {
    vector<int> res;
    while (x != 1) {
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }
  vector<P> factor(int x) {
    vector<int> fl = factorList(x);
    if (fl.size() == 0) return {};
    vector<P> res(1, P(fl[0], 0));
    for (int p : fl) {
      if (res.back().first == p) {
        res.back().second++;
      } else {
        res.emplace_back(p, 1);
      }
    }
    return res;
  }
  vector<pair<ll,int>> factor(ll x) {
    vector<pair<ll,int>> res;
    for (int p : primes) {
      int y = 0;
      while (x%p == 0) x /= p, ++y;
      if (y != 0) res.emplace_back(p,y);
    }
    if (x != 1) res.emplace_back(x,1);
    return res;
  }
};

int main(){
    ll n;       // 調べたい数
    cin>>n;
    Sieve s(1000005); // 使う素数の最大　大きすぎると遅い(10^７くらいまで)
    auto fs = s.factor(n);
    int ans=0;
    for(auto p : fs){
        int x = p.second; // 個数
        int b=1;
        while(b<=x){
            x-=b;
            b++;
            ++ans;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 7796
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;

ll rep_pow(ll a, ll b){//繰り返し2乗法
    if(b==0) return 1;
    else if(b%2==0){
        ll memo = rep_pow(a, b/2);
        return memo*memo%mod;
    }else{
        return rep_pow(a, b-1)*a%mod;
    }
}

ll nCr(ll n, ll r){//mod逆元使ったnCr
    ll ret=1;
    rep(i,r){
        ret *= n-i;//分子
        ret %= mod;
        ret *=rep_pow(r-i, mod-2);//mod逆元によりr!で割ると同値
        ret %= mod;
    }
    return ret;
}
ll gcd(ll a, ll b){ if(b==0) return a; return gcd(b, a%b);}

int counter(int x){
    if(x==0) return 0;
    return counter(x>>1)+(x&1);
}


int main(){
    fast_io

    string s;
    cin>>s;
    rep(i,s.size()-8){
        cout<<s[i];
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; i++)

int main()
{
	int N, A, B, C, X;
	while (cin >> N >> A >> B >> C >> X, N || A || B || C || X) {
		vector<int> Y;
		REP(i, 0, N) {
			int y;
			cin >> y;
			Y.push_back(y);
		}

		int cnt = 0, frame = 0;
		int next = (A*X + B) % C;
		
		if (X == Y[0]) cnt++;
		while (cnt < N) {
			if (next == Y[cnt]) cnt++;

			frame++;
			next = (A*next + B) % C;

			if (frame > 10000) {
				frame = -1;
				break;
			}
		}

		cout << frame << endl;
	}
	return 0;
}

Measured memory_bytes: 3048
import sys
from math import pi, cos, sin, sqrt
input = sys.stdin.readline
A, B, H, M = map(int, input().split())
H += M / 60
a = (A * cos(pi / 2 - H / 6 * pi), A * sin(pi / 2 - H / 6 * pi))
b = (B * cos(pi / 2 - M / 30 * pi), B * sin(pi / 2 - M / 30 * pi))
#print(a, b)
print(sqrt(abs(a[0] - b[0]) ** 2 + abs(a[1] - b[1]) ** 2))

Measured memory_bytes: 62408
#include <iostream>

int main()
{
	int R,G,B,N;

	scanf("%d %d %d %d" ,&R, &G, &B, &N);
	
	int r, g, b, cnt;

	for (r = 0; R*r <= N; r++) {
		for (g = 0; R*r + G*g <= N ; g++) {
				if ( (N - (R * r + G * g) ) % B == 0) {
					cnt++;
				}
		}
	}

	printf("%d", cnt);

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
using namespace std;
int main(void){
    int n,m;
    cin >> n >> m;
    int A[n][m],b[m],c[100]={};
    
    for(int i=0;i<n;i=i+1){
        for(int j=0;j<m;j=j+1){
         cin >> A[i][j];
        }
    }
   
    for(int j=0;j<m;j=j+1){
         cin >> b[j];
        }
    
    
    for(int i=0;i<n;i=i+1){
        for(int j=0;j<m;j=j+1){
            c[i]=A[i][j]*b[j]+c[i];
        }
        
        cout << c[i] << endl;
        
    }
    
    
    
    
}



Measured memory_bytes: 3124
#include <iostream>
using namespace std;
int main(void){
    int a, b;
    char op;
    while (1) {
        cin >> a >> op >> b;
        switch (op) {
        case '+':
            cout << a + b << endl;
            break;
        case '-':
            cout << a - b << endl;
            break;
        case '*':
            cout << a * b << endl;
            break;
        case '/':
            cout << a / b << endl;
            break;
        default:
            goto OUT;
        }
    }
    OUT:
    return 0;
}

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

int main() {
    int N;
    string S;
    cin >>N>>S;
    long long a = 0;
    long long b = 0;
    long long c = 0;
    for(int i = 0; i<N; i++) {
        if(S[i] == 'R') a++;
        if(S[i] == 'G') b++;
        if(S[i] == 'B') c++;
    }
    long long tmp_res = 0;
    tmp_res = a*b*c;
    long long check = 0;
    for(int j = 1; j<N; j++) {
        for(int i = 0; i<j; i++) {
            int k = 2 * j - i;
            if(k < N && S[i] != S[j] && S[i] != S[k] && S[j] != S[k]) {
                check++;
            }
        }
    }
    cout << tmp_res - check << endl;
}

Measured memory_bytes: 3640
n,m,k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

rui_a=[]
rui_b=[]

sm=0
for tmp in b:
    rui_b.append(sm)
    sm+=tmp
rui_b.append(sm)

sm=0
for tmp in a:
    rui_a.append(sm)
    sm+=tmp
rui_a.append(sm)


import bisect

ans=0
for a_num in range(n+1):
    nokori=k-rui_a[a_num]
    if nokori < 0:
        continue
    b_num = bisect.bisect_right(rui_b,nokori) -1

    ans=max(ans,a_num+b_num)
print(ans)

Measured memory_bytes: 132548
#define rep(i, a, b) for(int i = a; i < (int)(b); i++)
#include <bits/stdc++.h>

typedef long long ll;
using namespace std;
template<class T> inline void chmax(T &a, const T &b) {if(a < b) a = b;}
template<class T> inline void chmin(T &a, const T &b) {if(a > b) a = b;}
const long long INF = 1LL<<60;
const long long MOD = (ll)1e9+7;
const long long MAX = (ll)170 * 80;

vector<ll> vId;
class Node {
   public:
   // long vertex;
   vector<long> to;
   // vector<long> length;
   // int grp;
   bool seen = false;
   bool finish = false;
   Node(){;};
};
vector<Node*> vGr;

void dfs(int vertex) {
   auto thisv = vGr[vertex];
   if (thisv->seen) return;
   vId.push_back(vertex);
   thisv->seen = true;
   for (auto el : thisv->to) {
      dfs(el);
   }
   thisv->finish = true;
   return;
};


int main(void) {
   ll N;
   cin>>N;
   rep(i,0,N) vGr.push_back(new Node());
   rep(i,0,N-1) {
      ll a,b;
      cin>>a>>b;
      vGr[a-1]->to.push_back(b-1);
      vGr[b-1]->to.push_back(a-1);
   }
   vector<ll> C(N);
   rep(i,0,N) cin>>C[i];
   sort(C.begin(),C.end());

   dfs(0);
   // for (auto el: vId) cout<<el<<endl;

   vector<ll> ans(N);
   ll ansA = 0;

   rep(i,0,N) {
      ans[vId[i]] = C[N-1-i];
      if (i!=0) ansA+= C[N-1-i];
   }
   cout<<ansA<<endl;
   for (auto el: ans) cout<<el<<" ";
   cout<<endl;

   return 0;
}

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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll n,k,q;
  cin >> n >> k >> q;

  vl a(n,k-q);

  REP(i,q){
    ll ai;
    cin >> ai;
    ai --;
    a[ai]++;
  }
  REP(i,n){
    if(a[i]>0){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }
  
  //cout << fixed << setprecision(10);
  return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;
using LL = long long;
int main()
{
	LL x;
	scanf("%lld", &x);

	int cnt1 = x / 500;
	x -= cnt1 * 500;
	int cnt2 = x / 5;
	printf("%lld\n", cnt1 * 1000 + cnt2 * 5);


	return 0;
}

Measured memory_bytes: 256
sx,sy,tx,ty=map(int,raw_input().split())

x =tx-sx
y =ty-sy

ans=""
ans+=x*"R"
ans+=y*"U"
ans+=x*"L"
ans+=y*"D"

ans+="L"
ans+="U"*(y+1)
ans+="R"*(x+1)
ans+="D"
ans+="R"
ans+="D"*(y+1)
ans+="L"*(x+1)
ans+="U"

print ans

Measured memory_bytes: 2692
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const int INF = 2e9;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
  ll n;
  cin >> n;
  bool is_prime = true;
  ll ans = 0;
  for (ll i = 2; i < 1000007; i++){
    ll num = 0;
    while(n % i == 0){
      num++;
      n /= i;
    }
    for (ll j = 1; num - j >= 0;j++){
      ans++;
      num -= j;
    }
  }
  if(n>=1000007)ans++;
  print(ans);
}

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

int n;

int main(void){
  cin >> n;
  vector<int> c(100001, 0);
  for(int i = 0; i < n; i++){
    int a;
    cin >> a;
    for(int j = -1; j <= 1; j++){
      if(a+j >= 0) c[a+j]++;
    }
  }
  int res = *max_element(c.begin(), c.end());
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 3736
a,b,c,d,e,f=map(int,input().split())
w=set()
for i in range(0,f,100*a):
    for j in range(0,f,100*b):
        if i+j<=f:
            w.add(i+j)
        else:
            break
s=set()
for i in range(0,f,c):
    for j in range(0,f,d):
        if i+j<=f:
            s.add(i+j)
        else:
            break
n=100*a
m=0
l=0
for x in w:
    for t in s:
        if x+t!=0 and x+t<=f and 100*t<=e*x and t/(x+t)>l:
            n=x+t
            m=t
            l=t/(x+t)
print(n,m)

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

int main() {
    int A;
    int B;
    std::cin >> A >> B;

    for (int i = 1; i <= 10000; ++i) {
        int price_a = static_cast<double>(i) * 0.08;
        int price_b = static_cast<double>(i) * 0.10;
        // std::cout << i << " " << price_a << " " << price_b << std::endl;
        if (A == price_a && B == price_b) {
            std::cout << i << std::endl;
            return 0;
        }
    }
    std::cout << -1 << std::endl;
    return 0;
}

Measured memory_bytes: 256
X, Y, A, B, C = gets.chomp.split.map(&:to_i)
p = gets.chomp.split.map(&:to_i)
q = gets.chomp.split.map(&:to_i)
r = gets.chomp.split.map(&:to_i)

p.sort!.reverse!
q.sort!.reverse!

pp = p[0..X-1]
qq = q[0..Y-1]

all = r + pp + qq
all.sort!.reverse!

all_a = all[0..X+Y-1]
p all_a.inject(:+)


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

#define pb push_back
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define REP(i,n) for(int _n=n, i=0;i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)
#define FORD(i,a,b) for(int i=(a),_b=(b);i>=_b;--i)
#define trav(a, x) for (auto& a : x)
using ull = uint64_t;
using ll = int64_t;
using PII = pair<int, int>;
using VI = vector<int>;
#define INF (1ll<<60)

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B> string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A> string to_string(A v) {
bool first = true; string res = "{";
for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); }
res += "}"; return res; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H); debug_out(T...); }
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    int N;
    cin >> N;
    vector<PII> R(N), B(N);
    REP(i, N) cin >> R[i].first >> R[i].second;
    REP(i, N) cin >> B[i].first >> B[i].second;
    sort(all(R), less<PII>());
    sort(all(B), less<PII>());
    vector<bool> V(N, false);
    REP(i, N) {
        int idx = -1, mx = -1;
        REP(j, N) {
            if (V[j]) continue;
            if (R[j].first > B[i].first) break;
            if (R[j].first < B[i].first && R[j].second < B[i].second) {
                if (R[j].second > mx) {
                    mx = R[j].second;
                    idx = j;
                }
            }
        }
        if (idx != -1) {
            V[idx] = true;
        }
    }
    int cnt = 0;
    REP(i, N) {
        cnt += V[i];
    }
    cout << cnt << endl;
}

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

int main(){
    string s; cin >> s;
    int n = s.length();
    bool c[256];
    for(int j=0;j<256;j++) c[j] = false;
    int count = 0;
    vector<int> v[256];
    for(int i=0;i<n;i++) v[s[i]].push_back(i);
    vector<int> k;
    for(int i=n-1;i>=0;i--){
        if(c[s[i]]==false){
            c[s[i]] = true; count++;
            if(count == 26){
                for(char j='a';j<='z';j++) c[j] = false;
                k.push_back(i);
                //cout << "Enter" << endl;
                count = 0;
            }
        }
    }
    if(k.size() == 0) for(char j='a';j<='z';j++) if(!c[j]){cout << j <<endl; return 0;} 
    for(char j='a';j<='z';j++) v[j].push_back(n);
    reverse(k.begin(), k.end());
    //for(auto i: k) cout << i << endl;
    int l = k.size() + 1;
    string a;
    int cur_pos = -1;
    k.push_back(n-1);
    for(int i=0;i<l;i++){
        for(char j='a'; j<='z'; j++){
            int next = upper_bound(v[j].begin(), v[j].end(), cur_pos) - v[j].begin();
            //cout << j << ":" << next << endl;
            if(v[j][next] >= k[i]){
                a.push_back(j);
                cur_pos = v[j][next];
                j = 'z';
            }
        }
    }
    cout << a << endl;
    return 0;
}

Measured memory_bytes: 1412
#include<bits/stdc++.h>
using namespace std ;
typedef long long ll ;
int main () {
  
  ll N ;
  cin >> N ;
  int a[N] ;
  for(int i =0 ; i < N ;i++){
    cin >> a[i] ;
  }
  vector<int> pos ;

    for(int i = 0 ; i < N ;i++){
    if(a[i] != (i + 1)) pos.push_back(i) ;
  }
  if(pos.size() <= 2) cout<<"YES\n" ;
  else cout<<"NO\n" ;
  return 0 ;
}

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

const int maxn = 2e5 + 10;
typedef long long int ll;
ll a[maxn];
void solved(){
	int n;cin>>n;
	for(int i = 1; i <= n; i++)cin>>a[i];
	ll cnt = 0;
	map<ll,ll>mp; 
	for(int i = 1; i <= n; i++){
		mp[a[i] + i] ++;
	}
	for(int i = 1; i <= n; i++){
		cnt += mp[i - a[i]];
	} 
	cout<<cnt<<endl;
}
int main(){
	solved();
	return 0;
} 

Measured memory_bytes: 27828
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

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

int main(){
    ll h,w;
    cin >> h >> w;
    ll ans = 0;
    if(h == 1 ||w== 1){
         cout << 1 << endl;
         return 0;
    }
    if((h%2) == 0 ||(w%2) == 0 ){
        ans = (h*w)/2;
    }else{
        ans = (h*w)/2 + 1;
    }
    cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		String s = sc.next();

		System.out.println(a>=3200 ? s: "red");

//		if (a >= 3200) {
//			System.out.println(s);
//		} else {
//			System.out.println("red");
//		}
	}
}

Measured memory_bytes: 22612
#include<stdio.h>
#define MAX 100

int main(){
  int Graf[MAX+1][MAX+1];
  int n,i,j,k,num;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){

      Graf[i][j]=0;
    }
  }
  while(1){
    scanf("%d%d",&i,&num);
  for(k=0;k<num;k++){
    scanf("%d",&j);
    Graf[i][j]=1;
  }
     if(i==n)break;
  }
  for(i=1;i<=n;i++){
    for(j=1;j<n;j++){
      printf("%d ",Graf[i][j]);
    }
    printf("%d\n",Graf[i][n]);
  }
  return 0;
}

Measured memory_bytes: 632
#include <iostream>
#include<math.h>
#include<list>
#include <algorithm>
#include<vector>
#include<math.h>
#include<map>
using namespace std;
using ll = long long;
using vll = vector<long long>;

#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(long i=s;i<e;i++)
#define repeq(i,s,e) for(long i=s;i<=e;i++)

int main() {
	ll n,ans=0;

	in(n);
	vll d(n);
	rep(i, 0, n) {
		in(d[i]);
	}

	sort(d.begin(), d.end());

	repeq(i, d[n / 2 - 1] + 1, d[n / 2]) {
		ans++;
	}
	out(ans);

	return 0;
}



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

#define ll long long
#define pb push_back
#define iter std::vector<int>::iterator

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

	long double r; cin >> r;
	const long double pi =  3.1415926;

	cout << 2 * pi * r;

	return 0;
}



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

int main(void){
    int k,x;
    cin >> k >> x;
    if(500*k >= x) cout << "Yes"<< endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
main :: IO ()
main = do
  [p, q] <- map read . words <$> getLine
  let a = [1,3,5,7,8,10,12]
      b = [4,6,9,11]
      c = [2]
      str = if (p `elem` a && q `elem` a)
            || (p `elem` b && q `elem` b)
            || (p `elem` c && q `elem` c) then "Yes"
                                          else "No"
  putStrLn str


Measured memory_bytes: 508
from collections import deque
n = int(input())
l = map(int, input().split())
ans = deque()
for idx, v in enumerate(l):
  if idx % 2 == 0:
    ans.append(v)
  else:
    ans.appendleft(v)
if len(ans) % 2 == 1:
  ans.reverse()
            
print(*ans)

Measured memory_bytes: 25540
#include<bits/stdc++.h>
using namespace std;
#define int long  long
#define double long double
int t,n,m,k,a[200005],pnt,cnt,b[200005],ans;
int bs(int b[],int l,int r,int s)
{
    int ls=0;
    while(1)
    {
        if(r-l==1)
        {
            if(b[r]<=s && b[l]<=s) return r;
            else if(b[r]>s && b[l]>s) return ls;
            return l;
        }
        if(l==r)
        {
            if(b[r]<=s) return r;
            return ls;
        }
        if(b[(l+r)/2]<=s)
        {
            ls=(l+r)/2;
            l+=(r-l+1)/2;
        }
        else
        {
            r-=(r-l+1)/2;
        }
    }
    return ls;
}
signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    t=1;
  //  cin>>t;
    while(t--)
    {
        cin>>n>>m>>k;
        a[0]=0;b[0]=0;ans=0;
        for(int i=1;i<=n;i++)
        {
            cin>>a[i];a[i]+=a[i-1];
        }
        for(int i=1;i<=m;i++)
        {
            cin>>b[i];b[i]+=b[i-1];
        }
        for(int i=0;i<=n;i++)
        {
            if(a[i]>k) break;
            ans=max(i+bs(b,1,m,k-a[i]),ans);
        }
        cout<<ans<<endl;
    }
}


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

int main()
{
    ll N;
    vector<ll> tra(5);

    cin >> N;

    for(ll i = 0; i < 5; i++)
    {
        cin >> tra[i];
    }

    ll count = 0;
    sort(tra.begin(),tra.end());
    if(N % tra[0] == 0)count += N / tra[0];
    else count += N / tra[0] + 1;
    
    count += 4;

    cout << count << endl;
}

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

int main() {
  int N;
  long long total = 0;
  cin >> N;
  vector<long long>A(N);
  vector<long long>B(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
    B.at(A.at(i)-1) += 1;
  }
  for (int i = 0; i < N; i++) {
    if (B.at(i) > 1) {
      total += B.at(i) * (B.at(i) - 1) / 2;
    }
  }
  for (int i = 0; i < N; i++) {
    if (B.at(A.at(i)-1) > 1) {
      cout << total - B.at(A.at(i)-1) + 1 << endl;
    }
    else {
      cout << total << endl;
    }
  }
}


Measured memory_bytes: 5760
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
char s[105], t[105];
bool cmp(char a, char b){
	return a>b;
}
int main(){
	scanf("%s %s", s+1, t+1);
	sort(s+1, s+1+strlen(s+1));
	sort(t+1, t+1+strlen(t+1), cmp);
	if(strcmp(s+1, t+1)<0)
		printf("Yes");
	else
		printf("No");
	return 0;
} 

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define pb push_back
#define eb emplace_back
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

int main(){
    ll n,k; cin >> n >> k;
    ll ret = 0;
    if(k == 2){
        ll odd = (n+1)/2;
        ll even = n/2;
        ret = odd * odd * odd + even * even * even;
    }
    else{
        ll t;
        if(k % 2 ){
            t = n / k;
            ret = t*t*t;
        }
        else {
            t = n / (k / 2);
            ll odd = (t+1)/2;
            ll even = t/2;
            ret = odd * odd * odd + even * even * even;
            
        }
    }
    cout << ret << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s,w[3]={"Sunny","Cloudy","Rainy"};
    cin>>s;
    for(int i=0;i<3;i++)
    {
        if(s=="Rainy")
        {
          cout<<"Sunny";
            break;
        }
        else if(s==w[i])
        {
            cout<<w[i+1];
            break;
        }
    }
}



Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}

import           Control.Applicative
import           Control.Monad

data Dict
    = Empty
    | Node !Bool !Dict !Dict !Dict !Dict -- End, A, C, G, T
    deriving (Eq, Show)

node :: Dict
node = Node False Empty Empty Empty Empty

dinsert :: String -> Dict -> Dict
dinsert [] (Node _ a c g t) = Node True a c g t
dinsert ('A':xs) (Node e a c g t)
    | a == Empty = Node e (dinsert xs node) c g t
    | otherwise  = Node e (dinsert xs a) c g t
dinsert ('C':xs) (Node e a c g t)
    | c == Empty = Node e a (dinsert xs node) g t
    | otherwise  = Node e a (dinsert xs c) g t
dinsert ('G':xs) (Node e a c g t)
    | g == Empty = Node e a c (dinsert xs node) t
    | otherwise  = Node e a c (dinsert xs g) t
dinsert ('T':xs) (Node e a c g t)
    | t == Empty = Node e a c g (dinsert xs node)
    | otherwise  = Node e a c g (dinsert xs t)

dfind :: String -> Dict -> Bool
dfind [] (Node e _ _ _ _) = e
dfind ('A':xs) (Node _ a _ _ _)
    | a == Empty = False
    | otherwise  = dfind xs a
dfind ('C':xs) (Node _ _ c _ _)
    | c == Empty = False
    | otherwise  = dfind xs c
dfind ('G':xs) (Node _ _ _ g _)
    | g == Empty = False
    | otherwise  = dfind xs g
dfind ('T':xs) (Node _ _ _ _ t)
    | t == Empty = False
    | otherwise  = dfind xs t

solve :: [(Char, String)] -> IO ()
solve xs = go node xs
  where
    go _ [] = return ()
    go !d ((a, b):ys)
        | a == 'i' = go (dinsert b d) ys
        | a == 'f' = do
            if dfind b d
                then putStrLn "yes"
                else putStrLn "no"
            go d ys

main :: IO ()
main = do
    getLine
    xs <- fmap ((\[a, b] -> (head a, b)) . words) . lines <$> getContents
    solve xs



Measured memory_bytes: 53252
import Control.Applicative
import Control.Monad
import System.IO.Unsafe
import Control.Monad.ST
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import Data.Foldable (foldMap)
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
import Data.Array
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
 
readInt = read :: String -> Int
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getDouble = readLn :: IO Double
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
fnBin :: (b -> c -> d) -> (a -> b) -> (a -> c) -> a -> d
fnBin op f g x = op (f x) $ g x
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
modifyArray :: (Ix i, MArray a e m) => a i e -> i -> (e -> e) -> m ()
modifyArray arr ix f = readArray arr ix >>= writeArray arr ix . f
-- end of templete

f (a, b) [] = show a ++ " " ++ show b
f (a, b) ([x,y]:s) = f (na, nb) s
  where
    (na, nb)
      | x>y  = (a+x+y, b)
      | x==y = (a+x, b+y)
      | x<y  = (a, b+x+y)

main = do
    n <- getInt
    when (n/=0) $ replicateM n getInts >>= putStrLn . f (0, 0) >> main

Measured memory_bytes: 9228
#include<stdio.h>
#include<cmath>
int main(){
	int A,B,C,D;
	scanf("%d%d%d%d",&A,&B,&C,&D);
	int are1,are2;
	are1=A*B;
	are2=C*D;
	if(are1>=are2){
		printf("%d\n",are1);}
		else{
			printf("%d\n",are2);}
			return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;

int main(void){
  int month[] = {31,29,31,30,31,30,31,31,30,31,30,31};
  string day[7] = {"Thursday", "Friday", "Saturday", "Sunday", "Monday", 
		   "Tuesday", "Wednesday"};

  int x, y, m, d, c;

  while(cin >> x >> y , x != 0){
    m = d = 1;
    c = 0;
    while(x !=m || y != d){
      d++;
      if(d > month[m - 1]){
	m++;
	d = 1;
      }
      c++;
      if(c == 7)
	c = 0;
    }
    cout << day[c] << endl;
  }

  return 0;
}

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

typedef long long i64;

i64 n, m;

i64 after(i64 join) {
    return min(n + join / 2, (m - join) / 2); }

bool rise(i64 join) {
    if (join > m)
        return false;
    return after(join - 1) < after(join); }

int main() {
   // freopen("dat.in", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    i64 ant = 0;

    cin >> n >> m;
    for (i64 pas = 1LL << 60; pas; pas>>= 1)
    if (rise(ant + pas))
        ant+= pas;

    cout << after(ant) << '\n';

    return 0; }


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int a;
    int b = -1000000;
    int c = 1000000;
    long long int d = 0;
    int e;
    int i;

    scanf("%d",&a);
    for(i=0;i<a;i++)
    {
        scanf("%d",&e);
        if(e<c) c = e;
        if(e>b) b = e;
        d = d + e;
    }
    printf("%d %d %lld\n",c,b,d);
    return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
int n,m,a[100100];

int fa[100100],ans;

int find(int x)
{
    if(fa[x]==x) return x;
    fa[x]=find(fa[x]);
    return fa[x];
}

void he(int qq,int ww)
{
    int fq=find(qq);
    int fw=find(ww);
    if (fq!=fw)
    fa[fq]=fw;
}


int main()
{
    cin>>n>>m;
    for (int i=1;i<=n;i++) cin>>a[i],fa[i]=i;
    for (int i=1;i<=m;i++)
    {
        int qq,ww;
        cin>>qq>>ww;
        he(qq,ww);
    }
    for (int i=1;i<=n;i++) find(i);
    for (int i=1;i<=n;i++) if (fa[i]==fa[a[i]]) ans++;
    
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

ll k;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    cin>>k;
    queue<ll> q;
    rep(i,10){
        if(i==0)continue;
        q.push(i);
    }
    ll ct = 0;
    while(1){
        ct++;
        ll now = q.front();
        q.pop();
        if(ct==k){
            print(now);
            break;
        }
        if(now%10 != 0)q.push(now*10 + now%10 -1);
        q.push(now*10 + now%10);
        if(now%10 != 9)q.push(now*10 + now%10 +1);
    }
    return 0;
}

Measured memory_bytes: 1792
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int n,q,lt,rt,mid,i,w1,w2;
char s[200005],ch1[200005][2],ch2[200005][2];
bool workl(int x)
{
	for(int i=1;i<=q;++i)
		if(s[x]==ch1[i][0])
		{
			if(ch2[i][0]=='L')
				--x;
			else
				++x;
			if(x<1)
				return true;
			if(x>n)
				return false;
		}
	return false;
}
bool workr(int x)
{
	for(int i=1;i<=q;++i)
		if(s[x]==ch1[i][0])
		{
			if(ch2[i][0]=='L')
				--x;
			else
				++x;
			if(x<1)
				return false;
			if(x>n)
				return true;
		}
	return false;
}
int main()
{
	scanf("%d%d",&n,&q);
	scanf("%s",s+1);
	for(i=1;i<=q;++i)
		scanf("%s%s",ch1[i],ch2[i]);
	if(!workl(1))
		w1=0;
	else
	{
		lt=1,rt=n;
		while(lt<rt)
		{
			mid=lt+rt+1>>1;
			if(workl(mid))
				lt=mid;
			else
				rt=mid-1;
		}
		w1=lt;
	}
	if(!workr(n))
		w2=0;
	else
	{
		lt=1,rt=n;
		while(lt<rt)
		{
			mid=lt+rt>>1;
			if(workr(mid))
				rt=mid;
			else
				lt=mid+1;
		}
		w2=n-lt+1;
	}
	printf("%d",n-min(n,w1+w2));
	return 0;
}


Measured memory_bytes: 1152
#import math

a,b=map(int,input().split())
#x=int(a/0.08)
#y=int(b/0.1)
for i in range(1,1001):
#for i in range(y,x+1):
  if int(i*0.08)==a and int(i*0.1)==b:
    print(i)
    break
else:
  print(-1)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000000;
#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);++i)
#define rep(i,n) REP(i, 0, n)
typedef long long int i64;
typedef pair<int, int> pint;
int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    int H, W; cin >> H >> W;
    vector<string> fld(H);
    rep(i, H) cin >> fld[i];
    auto red = fld, blue = fld;
    {
        string k = string(W - 1, '#') + '.';
        rep(i, H) {
            red[i][0] = '#';
            if(i % 2 == 0)
              red[i] = k;
        }
    }

    {
        string k = '.' + string(W - 1, '#');
        rep(i, H) {
            blue[i][W - 1] = '#';
            if(i % 2)
              blue[i] = k;
        }
    }

    rep(i, H) cout << red[i] << '\n';
    cout << '\n';
    rep(i, H) cout << blue[i] << '\n';
    return 0;
}

Measured memory_bytes: 1280
#include<iostream>

using namespace std;

int main() {
  int a,b,c,x,y=0;
      cin >> a >> b >> c;
      for(int x=a;x<=b;x++){
	
	if(c%x==0)y++;
      }    
	  cout << y << endl;
	
	       
     
   return 0;
    }



Measured memory_bytes: 3076
n = int(input())
restaurant = []
for i in range(n):
    s, p = input().split()
    restaurant.append((s, int(p), i+1))

restaurant = sorted(restaurant, key=lambda x: x[1], reverse=True)
restaurant = sorted(restaurant, key=lambda x: x[0])

for i in range(n):
    print(restaurant[i][2])


Measured memory_bytes: 3060
def main():
    N = int(input())
    D, X = map(int, input().split())
    chocolate = 0
    for i in range(N):
        A = int(input())
        if A == 1:
            chocolate += D
            continue
        for j in range(1, D + 1):
            if j % A == 1:
                chocolate += 1
    print(X + chocolate)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38640
#include <bits/stdc++.h>
#define FOR(i,n) for(int i=0;i<(int)(n);i++)
#define FORR(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define pb(a) push_back(a)
#define mp(x,y) make_pair(x,y)
#define ALL(a) a.begin(),a.end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,-1,sizeof(a))
#define len(a) sizeof(a)
#define ll long long
#define pii pair<int,int>
#define INF 1<<29
#define MAX 
using namespace std;

int n,m,dp[2020][2020][2];
string s,t;

int dfs(int o,int d,int odd){
 if(dp[o][d][odd]>=0) return dp[o][d][odd];
 int ma=0;
 if(odd){
  if(o<n&&s[o]=='O') ma=max(ma,dfs(o+1,d,odd^1)+1);
  if(d<m&&t[d]=='O') ma=max(ma,dfs(o,d+1,odd^1)+1);
 }
 else{
  if(o<n&&s[o]!='O') ma=max(ma,dfs(o+1,d,odd^1)+1);
  if(d<m&&t[d]!='O') ma=max(ma,dfs(o,d+1,odd^1)+1);
 }
 return dp[o][d][odd]=ma;
}

void solve(){
 cin>>n>>m>>s>>t;
 FOR(i,n+1) FOR(j,m+1) FOR(k,2) dp[i][j][k]=-1;
 int ma=0;
 FOR(i,n+1) FOR(j,m+1) ma=max(ma,dfs(i,j,0));
 if(!ma||(ma&1)) cout<<ma<<endl;
 else cout<<ma-1<<endl;
}

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

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

int main()
{
	int n, m, i, l, r, count=0;
	cin >> n >> m;
	int a[n+2];
	memset(a, 0, sizeof(a));
	for(i=0; i<m; i+=1)
	{
		cin >> l >> r;
		a[l]+=1;
		a[r+1]-=1;
	}
	for(i=1; i<=n+1; i+=1)
		a[i]+=a[i-1];
	for(i=1; i<=n; i+=1)
		if(a[i]==m)
			count+=1;
	cout << count << endl;
}

Measured memory_bytes: 640