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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n)-1; i >= 0; i--)

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

ll f(string s) {
  ll cnt = 0;
  for (int i = 0; i < s.length() - 1; ++i) {
    if (s[i] == s[i + 1] && s[i] == s[i + 2] && s[i] == s[i + 3] &&
        i + 3 < s.length())
      cnt += 2, i += 3;
    else if (s[i] == s[i + 1] && s[i] == s[i + 2] && i + 2 < s.length())
      cnt++, i += 2;
    else if (s[i] == s[i + 1] && i + 1 < s.length())
      cnt++, i += 1;
  }
  return cnt;
}

int main() {
  string s = "", ss;
  ll k;
  cin >> ss >> k;
  bool flg = true;
  for (auto st : ss)
    if (ss[0] != st) flg = false;

  if (flg) {
    cout << (ll)ss.length() * k / 2 << endl;
  } else {
    ll cnt1 = f(ss);
    ll cnt2 = f(ss + ss);
    cout << ((2 * cnt1 == cnt2) ? (ll)cnt1 * k : (ll)(cnt1 * k + (k - 1)))
         << endl;
  }
  return 0;
}

Measured memory_bytes: 256
Program PanasonicA
   Implicit none
   Integer::k
   Integer,Dimension(32)::A=(/1,1,1,2,1,2,1,5, &
                              2,2,1,5,1,2,1,14, &
                              1,5,1,5,2,2,1,15, &
                              2,2,5,4,1,4,1,51/)

      Read(*,*) k
      Write(*,*) A(k)
      Stop

   End Program PanasonicA

Measured memory_bytes: 256
//package atcoder.beginner178;

import java.io.*;
import java.util.*;

public class Main {
    static InputReader in;
    static PrintWriter out;

    public static void main(String[] args) {
        //initReaderPrinter(true);
        initReaderPrinter(false);
        //solve(in.nextInt());
        solve(1);
    }

    static void solve(int testCnt) {
        for (int testNumber = 0; testNumber < testCnt; testNumber++) {
            int S = in.nextInt();
            long mod = (long)1e9 + 7;
            long[] dp = new long[S + 1];

            for(int i = 3; i <= S; i++) {
                dp[i] = 1L;
                for(int j = 3; j < i; j++) {
                    dp[i] = (dp[i] + dp[i - j]) % mod;
                }
            }
            out.println(dp[S]);
        }
        out.close();
    }

    static void initReaderPrinter(boolean test) {
        if (test) {
            try {
                in = new InputReader(new FileInputStream("src/input.in"));
                out = new PrintWriter(new FileOutputStream("src/output.out"));
            } catch (IOException e) {
                e.printStackTrace();
            }
        } else {
            in = new InputReader(System.in);
            out = new PrintWriter(System.out);
        }
    }

    static class InputReader {
        BufferedReader br;
        StringTokenizer st;

        InputReader(InputStream stream) {
            try {
                br = new BufferedReader(new InputStreamReader(stream), 32768);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

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

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        Integer[] nextIntArray(int n) {
            Integer[] a = new Integer[n];
            for (int i = 0; i < n; i++) {
                a[i] = nextInt();
            }
            return a;
        }

        Long[] nextLongArray(int n) {
            Long[] a = new Long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nextLong();
            }
            return a;
        }
    }
}




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

using namespace std; 
#define REP(i, n) for (int i = 0; i < (n); i++)

typedef long long ll;
// ll mod_pow(ll x, ll n, ll mod){//x^n % mod
//     if (n == 0)
//         return 1;
//     ll res = mod_pow(x * x % mod, n / 2, mod);
//     if (n & 1)
//         res = res * x % mod;
//     return res;
// }
int main(int argc, char const *argv[])
{
    cin.tie(0);
   	ios::sync_with_stdio(false);
    string S; cin >> S; 
    int f = stoi(S.substr(0,2));
    int l = stoi(S.substr(2,2));
    int num_of_01_12 = 0;
    string ans = "MMYY";
    if (0 < f && f < 13) num_of_01_12++;
    if (0 < l && l < 13) num_of_01_12++;
    if (num_of_01_12 == 0) ans = "NA";
    else if (num_of_01_12 == 2) ans = "AMBIGUOUS";
    else if (0 < l && l < 13) {
        ans = "YYMM";
    }
    cout << ans << endl; 
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

d, n = map(int, input().split())

if d==0:
    if n<100:
        print(n)
    elif n==100:
        print(n+1)
if d==1:
    if n<100:
        sub=n*100
    elif n==100:
        sub=(n+1)*100
    print(sub)
if d==2:
    if n<100:
        sub2=n*10000
    elif n==100:
        sub2=(n+1)*10000
    print(sub2)

Measured memory_bytes: 3316
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
using namespace std;

int main()
{
    int a,b;
    cin >> a >> b;
    int ans;
    ans=max(a+b, a-b);
    ans=max(ans, a*b);
    cout << ans;
    return 0;
}

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

Int a, b, c, d;
Int gcd(Int x, Int y){
	while(x % y != 0){
		Int r = x % y;
		x = y;
		y = r;
	}
	return y;
}
Int lcm(Int x, Int y){
	return x / gcd(x, y) * y;
}

Int f(Int n, Int d){
	return n / d;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> a >> b >> c >> d;
	Int ans = b-a+1 - (f(b, c) - f(a-1, c)) - (f(b, d) - f(a-1, d)) + (f(b, lcm(c, d)) - f(a-1, lcm(c, d)));
	cout << ans << "\n";
}

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

int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if(abs(a-c)<=d or (abs(a-b)<=d and abs(b-c)<=d)) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast,inline,unroll-loops,fast-math")
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <sstream>
#include <bitset>
#include <memory>
#include <string>
#include <vector>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <deque>
#include <algorithm>
#include <random>
#include <iomanip>
using namespace std;

int main(int argc, char *argv[]) {

	string s;
	cin >> s;
	cout << string((int)s.size(), 'x') << endl;
}









Measured memory_bytes: 256
h,w = map(int,input().split())
s = []
for i in range(h):
    s.append(list(input()))
ans = 0
for i in range(h):
    for j in range(w):
        if s[i][j] == "#":
            ans += 1
if ans == h+w-1:
    print("Possible")
else:
    print("Impossible")

Measured memory_bytes: 9076
N, K, Q = map(int,input().split())
As = [int(input()) for _ in range(Q)]
success_counts = [0 for _ in range(N)]


for e in As:
    success_counts[e-1] += 1

for i in range(N):
    if K - Q + success_counts[i] > 0:
        print('Yes')
    else:
        print('No')





Measured memory_bytes: 8640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define INF = numeric_limits<long long>::max();
#define intf int_fast64_t
int main(){
    intf a,b;
    cin >>a>>b;
    cout << (a+b+1)/2 <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n;
	while(cin>>n,n){
		string str;
		bool right=0,left=0;
		int ans=0;
		for(int i=0,now=1;i<n;i++){
			cin>>str;
			if(str=="lu")left=1;
			else if(str=="ru")right=1;
			else if(str=="ld")left=0;
			else right=0;
			if(now==right&&right==left){
				ans++;
				now=(now+1)%2;
			}
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 1208
#include<cstdio>
using namespace std;
int a[10];
int abs(int a){
	return a>0?a:-a;
}
int main(){
	int n=3,ans=10000;
	for (int i=1;i<=n;i++)
	scanf("%d",&a[i]);
	for (int i=1;i<=n;i++){
		int sum=0;
		for (int j=1;j<=n;j++)
		if (i!=j) sum+=abs(a[i]-a[j]);
		if (sum<ans) ans=sum;
	}
	printf("%d",ans);
	return 0;
} 

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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()

int sol(vector<int> a, int n, int pos) {
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (i) a[i] += a[i - 1];
    if (pos == 1 && a[i] <= 0) ans += 1 - a[i], a[i] = 1;
    if (pos == 0 && a[i] >= 0) ans += a[i] + 1, a[i] = -1;
    pos = 1 - pos;
  }
  return ans;
}

void solve() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (auto &i : a) cin >> i;
  cout << min(sol(a, n, 0), sol(a, n, 1)) << '\n';
}

signed main() {
#ifdef _DEBUG
  freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) solve();
}


Measured memory_bytes: 5520
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
using namespace std;

struct Node {
  Node *right;
  Node *left;
  Node *parent;
  int key;
};

Node *root;
Node *NIL;

void insert(int a){
  Node *y = NIL;
  Node *x = root;
  Node *z;
  z = (Node *)malloc(sizeof(Node));
  z->key = a;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key){
      x = x->left;
    }
    else{
      x = x->right;
    }
  }
  z->parent = y;
  if(y == NIL){
    root = z;
  }
  else{
    if(z->key <y->key){
      y->left = z;
    }
    else{
      y->right = z;
    }
  }
}
void inorder(Node *b){
  if(b == NIL)return;
  inorder(b->left);
  printf(" %d",b->key);
  inorder(b->right);
}

void preorder(Node *b){
  if(b == NIL)return;
  printf(" %d",b->key);
  preorder(b->left);
  preorder(b->right);
}

int main(){
  int n, i, x;
  string com;
  scanf("%d",&n);
  for(i=0; i<n; i++){
    cin>>com;
    if(com == "insert"){
      scanf("%d",&x);
      insert(x);
    }
    else if(com == "print"){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}
  
  



Measured memory_bytes: 26608
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <math.h>
#include <bitset>

using namespace std;

void solve() {
    int n;
    cin >> n;
    vector<int> p(n);
    vector<int> q(n);
    for(int i = 0; i < n; i++){
        cin >> p[i];
    }
    for(int i = 0; i < n; i++){
        cin >> q[i];
    }

    vector<int> d(n);
    for(int i = 0; i < n; i++){
        d[i] = i+1;
    }

    int a, b;
    bool af = false, bf = false;
    int count = 1;
    do {
        if(!af){
            bool flag = true;
            for(int i = 0; i < n; i++){
                if(p[i] != d[i]){
                    flag = false;
                    break;
                }
            }
            if(flag){
                af = true;
                a = count;
            }
        }
        if(!bf){
            bool flag = true;
            for(int i = 0; i < n; i++){
                if(q[i] != d[i]){
                    flag = false;
                    break;
                }
            }
            if(flag){
                bf = true;
                b = count;
            }
        }
        if(af && bf) break;
        count++;

    } while (next_permutation(d.begin(), d.end()));

    cout << abs(a-b);

}

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vi;
typedef vector<bool> vb;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define sq(x) ((x)*(x))
#define fo(i,n) for(int i=0;i<n;i++)
#define fp(i,k,n) for(int i=k;i<n;i++)
#define Fo(i,n) for(int i=1;i<=n;i++)
#define all(x) x.begin(),x.end()
#define deb(x) cout<<#x<<"="<<x<<"\n"
#define deb2(x,y) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<"\n"
#define fi first
#define se second
const double pi = 3.14159265358979323846;
#define uni(c) (c).resize(unique(all(c))-(c).begin())
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL)
//pair <int, int> w[4] = {mp(-1, 0), mp(0, -1), mp(1, 0), mp(0, 1)};   // for matrix movement:
void cp()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE
}
void solve()
{

	ll n, k; cin >> n;
	string ans;
	while (n > 0)
	{
		ans.pb(((((n % 26) - 1) + 26) % 26) + 'a');
		//deb2(n, ans);
		n--;
		n /= 26;
		//n--;
	}
	reverse(all(ans));
	cout << ans;


}
int main()
{
	fast;
	//cp();
	ll t = 1;
	//cin >> t;
	while (t--)
		solve();


	return 0;
}


Measured memory_bytes: 3656
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e9 + 7;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second

const int N = 1001;
int v, d;
int f[100100];

struct UnionFind{
	int par[201000];
	int rank[201000];

	void init(int n){
		for (int i = 0; i < 201000; i++){
			par[i] = i;
			rank[i] = 1;
		}
	}

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

	void unite(int x, int y){
		x = find(x);
		y = find(y);
		if (x == y)return;
		if (rank[x] < rank[y]){
			par[x] = y;
		}
		else{
			par[y] = x;
			if (rank[y] == rank[x])rank[x]++;
		}
	}

	bool same(int x, int y){
		return find(x) == find(y);
	}
};

UnionFind uf;

int main(){
	f[0] = 1, f[1] = 2;
	FOR(i,2, 10000){
		f[i] = f[i - 1] + f[i - 2];
		f[i] %= N;
	}
	while (cin >> v >> d){
		set<int> si;
		uf.init(v);
		REP(i, v){
			REP(j, v){
				if (abs(f[i + 1] - f[j + 1]) < d)uf.unite(i + 1, j + 1);
			}
		}
		REP(i, v){
			si.insert(uf.find(i + 1));
		}
		cout << si.size() << endl;
	}
}

Measured memory_bytes: 4620
#include<iostream>
#include<cstdio>
#include<set>
#include<algorithm>
using namespace std;
set <int> qy;
 int main ()
 {
 	int n,k;
 	while(scanf("%d",&n)!=EOF)
 	{
 		qy.clear();
 		int i,tmp,max=1,bj=0;
	 	scanf("%d",&k);
	 	set<int>::iterator it;
		for(i=0;i<n;i++)
		{
			scanf("%d",&tmp);
			if(tmp>bj)
				bj=tmp;
			qy.insert(tmp);
		}	
		for(i=*qy.begin();i>1;i--)
		{
			for(it=qy.begin();it!=qy.end();it++)
				if(*it%i!=0)
					break;
			if(it==qy.end())
				break;
		}
		//cout<<i;	
		if(bj<k)
		{
			printf("IMPOSSIBLE\n");
			continue;
		}		
		if(k%i==0)
			printf("POSSIBLE\n");
		else
			printf("IMPOSSIBLE\n");		 	
	}
 }

Measured memory_bytes: 4992
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
const int INF = 1 << 30;
const ll INFll = 1ll << 60;

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> A(h);
  for (int i = 0; i < h; i++) {
    cin >> A[i];
  }
  string pd = "";
  for (int i = 0; i < w + 2; i++) {
    pd += '#';
  }
  cout << pd << endl;
  for (int i = 0; i < h; i++) {
    cout << '#';
    cout << A[i];
    cout << '#' << endl;
  }

  cout << pd << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
	int n;
	int a[100000];
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	int ans=0;
	for (int i=1;i<=n;i++)
		for (int j=1;j<=n;j++)
			if (a[i]-a[j]>ans)ans=a[i]-a[j];
	printf("%d",ans);
	return(0);
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		X -= A;
		while ((X -= B) >= 0)
			;
		System.out.println(X + B);
	}

}


Measured memory_bytes: 21844
#include <stdio.h>
int main(){
  int x1,x2,y1,y2,x3,x4,y3,y4,diffx,diffy;
  scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
  diffx=x1-x2;
  diffy=y1-y2;
  x3=x2+diffy;
  y3=y2-diffx;
  x4=x1+diffy;
  y4=y1-diffx;
  printf("%d %d %d %d\n",x3,y3,x4,y4);
  return 0;
}


Measured memory_bytes: 128
import std.stdio, std.conv, std.string, std.bigint;
import std.math, std.random, std.datetime;
import std.array, std.range, std.algorithm, std.container, std.format;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }

void main(){
	int n = read.to!int;
	int[] ls = readln.chomp.split.map!(to!int).array;
	
	int sum;
	foreach(l; ls) sum += l;
	
	string ans = "Yes";
	foreach(l; ls) if(sum - l <= l) ans = "No";
	
	ans.writeln;
}


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

namespace Contest
{
    class Program
    {
        static int Main(string[] args)
        {
            new Program().Process();

            return 0;
        }

        private CommonInput cin;

        private void Process()
        {
            this.cin = new CommonInput();

            int x;
            x = cin.GetInt();

            Console.WriteLine("{0}:{1}:{2}", x / 3600, (x % 3600) / 60, x % 60);

            Console.ReadKey();
        }
    }

    public class CommonInput
    {
        public CommonInput()
        {
            this._s = new string[0];
            this._i = 0;
        }

        private string[] _s;
        private int _i;
        private char[] _sep = { ' ' };

        public string GetLine()
        {
            if (this._i < this._s.Length)
                return this._s[this._i++];

            string line;
            this._i = 0;
            do
            {
                line = Console.ReadLine();
            } while (line == "");

            this._s = line.Split(this._sep, StringSplitOptions.RemoveEmptyEntries);

            return this._s[this._i++];
        }

        public int GetInt()
        {
            return int.Parse(this.GetLine());
        }

        public long GetLong()
        {
            return long.Parse(this.GetLine());
        }

        public double GetDouble()
        {
            return double.Parse(this.GetLine());
        }
    }
}

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

#define INF 100000

int n, W;
int r[12];
double bitDP[12][(1<<12)]; // [??????????????£???] , [?????£?????±?????????bit??§??????]

bool inputData() {
	string str;
	getline(cin, str);
	if(cin.eof()) {
		return false;
	}
	
	str += ' ';
	
	int i, tmp = 0;
	for(i = 0; i < str.size(); i++) {
		if('0' <= str[i] && str[i] <= '9') {
			tmp  = tmp * 10 + str[i] - '0';
		} else {
			W = tmp;
			i++;
			break;
		}
	}
	
	n = tmp = 0;
	while(i < str.size()) {
		if('0' <= str[i] && str[i] <= '9') {
			tmp  = tmp * 10 + str[i] - '0';
		} else {
			r[n++] = tmp;
			tmp = 0;
		}
		
		i++;
	}
	
	return true;
}

int main()
{
	while(inputData()) {
		for(int i = 0; i < n; i++) {
			for(int bit = 0; bit < (1 << n); bit++) {
				bitDP[i][bit] = INF;
			}
			bitDP[i][0] = 0;
		}
		
		for(int bit = 0; bit < (1 << n); bit++) {
			for(int i = 0; i < n ; i++) { // i ????????????????????¨??????????????±??????
				if((1 << i) & bit) {
					continue;
				}
				
				int next = (1 << i) | bit;
				for(int j = 0; j < n; j++) { // ???????????????????????±??????
					double distance_r = r[i] + r[j];
					double distance_y = (r[i] - r[j] >= 0)? r[i] - r[j]: r[j] - r[i];
					double cost = distance_r * cos(asin(distance_y / distance_r));
					if(bit == 0) {
						cost = r[i];
					}
					if(next == (1 << n)-1) {
						cost += r[i];
					}
					bitDP[i][next] = min(bitDP[i][next], bitDP[j][bit] + cost);
				}
			}
		}
		/*
		for(int i = 0; i < n ; i++) {
			for(int bit = 0; bit < (1 << n); bit++) {
				if(bitDP[i][bit] == INF) cout << -1 << " ";
				else cout << bitDP[i][bit] << " ";
			}cout << endl;
		}*/
		
		double ans = INF;
		for(int i = 0; i < n; i++) {
			ans = min(ans, bitDP[i][(1 << n)-1]);
		}
		//cout << ans << " " << W << endl;
		cout << ((ans <= W)? "OK": "NA") << endl;
		
	}
	
	return 0;
}

Measured memory_bytes: 1600
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ld long double
#define dd double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
typedef long long ll;
typedef unsigned long long ull;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;
typedef vector<pll> vplll;
ll mod = 1e9+7;
const ld PI = 2 * acos(0.0);
const vector<ll> dx = {1, -1, 0, 0};
const vector<ll> dy = {0, 0, 1, -1};
#define round(x, y) ((x + y - 1) / y)
#define ce(x, y) ((x + y - 1) / y)
#define amax(x, y) \
    if (y > x)     \
        x = y;
#define amin(x, y) \
    if (y < x)     \
        x = y;
#define lcm(x, y) ((x) * (y) / __gcd(x, y))
#define len(x) (ll) x.length()
#define sq(x) ((x) * (x))
#define cb(x) ((x) * (x) * (x))
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b,c,t,n,m,k,q; 
    t = 1;
    // cin>>t;
    while(t--)
    {
    	cin>>n>>m;
    	ll sum = 0 ;
    	for(int i=0;i<m;i++)
    	{
    		cin>>a;
    		sum+=a;
    	}
    	if(n>=sum)
    	cout<<n-sum<<endl;
    else
    	cout<<-1<<endl;
    }
    return 0;
}

Measured memory_bytes: 3664
#include <cstdio>
#include <cctype>

int main() {
  int sum;
  char line[1002];

  while (true) {
    sum = 0;
    scanf("%s", line);
    for (int i = 0; isdigit(line[i]); i++) {
      sum += line[i] - '0';
    }

    if (sum == 0) {
      break;
    }

    printf("%d\n", sum);
  }

  return 0;
}



Measured memory_bytes: 2696
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            Solve();
        }
        private const long MOD = 1000000007;

        static void Solve()
        {
            var o = ReadAndParseIntArr();
            int a = o[0];
            int b = o[1];
            int c = o[2];

            string ans = b - a == c - b ? "YES" : "NO";
            Console.WriteLine(ans);
        }
        #region よく使う便利関数
        private static bool isPrime(long x)
        {
            if (x == 2) { return true; }
            if (x < 2 || x % 2 == 0) { return false; }
            long i = 3;
            while (i * i <= x)
            {
                if (x % i == 0) { return false; }
                i = i + 2;
            }
            return true;
        }
        private static long lcm(long x, long y)
        {
            return x / gcd(x, y) * y;
        }
        private static long gcd(long x, long y)
        {
            return y > 0 ? gcd(y, x % y) : x;
        }
        private static long pow(long x, long n)
        {
            if (n == 0) { return 1; }
            long res = pow(x * x % MOD, n / 2);
            if (n % 2 == 1)
            {
                res = res * x % MOD;
            }
            return res;
        }
        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        #endregion
    }
}

Measured memory_bytes: 13140
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x->left!=NIL){
    x=x->left;
  }
  return x;
}
Node treeSearch(Node u, int k){
  if(u==NIL || k==u->key)return u;
  if(k<u->key) return treeSearch(u->left,k);
  else return treeSearch(u->right,k);
}
Node treeSuccessor(Node x){
  Node y;
  if(x->right!=NIL)return treeMinimum(x->right);
  y=x->parent;
  while(y!=NIL && x==y->right){
    x=y;
    y=y->parent;
  }
  return y;
}
void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
  if(z->left==NIL || z->right==NIL) y=z;
  else y=treeSuccessor(z);
  if(y->left!=NIL)x=y->left;
  else x=y->right;
  if(x!=NIL)x->parent=y->parent;
  if(y->parent==NIL)root=x;
  else if(y==y->parent->left)y->parent->left=x;
  else y->parent->right=x;
  if(y!=z) z->key=y->key;
}
void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  while(x!=NIL){
    y=x;
    if(z->key<x->key)x=x->left;
    else x=x->right;
  }
  z->parent=y;
  if(y==NIL) root=z;
  else if(z->key<y->key) y->left=z;
  else y->right=z;
}
void inorder(Node u){
  if(u!=NIL){
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
  }
}
void preorder(Node u){
  if(u!=NIL){
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
  }
}
int main(){
  int n, i, x;
  char com[20];
  //root=NIL;
  scanf("%d", &n);

  for(i=0;i<n;i++){
    scanf("%s",com);
    if(com[0]=='f'){
      scanf("%d",&x);
      Node t = treeSearch(root,x);
      if(t!=NIL)printf("yes\n");
      else printf("no\n");

    } else if(com[0]=='i'){
      scanf("%d",&x);
      insert(x);
    } else if(com[0]=='p'){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }else if(com[0]=='d'){
      scanf("%d",&x);
      treeDelete(treeSearch(root,x));
    }
  } 
  return 0;
}

Measured memory_bytes: 19364
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;

inline int read()
{
	int f=1,x=0;
	char ch=getchar();
	while(!isdigit(ch)) {if(ch=='-') f=-1; ch=getchar();}
	while(isdigit(ch)) {x=x*10+ch-'0'; ch=getchar();}
	return x*f;
}

int a,b,c;

int main()
{
	a=read(); b=read(); c=read();
	if((c>=a && c<=b) || (c>=b && c<=a)) printf("Yes");
	else printf("No");
	return 0;
}


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

int main()
{
    int N, W;
    cin >> N >> W;
    vector<int> w(N);
    vector<int> v(N);

    rep(i, N) cin >> w.at(i) >> v.at(i);

    vector<vector<long>> dp(N + 1, vector<long>(W + 1, 0));
    rep(i, N)
    {
        for (int j = 0; j <= W; j++)
        {
            if (w.at(i) <= j)
            {
                dp.at(i + 1).at(j) = max(dp.at(i).at(j - w.at(i)) + v.at(i), dp.at(i).at(j));
            }
            else
            {
                dp.at(i + 1).at(j) = dp.at(i).at(j);
            }
        }
    }

    cout << dp.at(N).at(W) << endl;
    return 0;
}

Measured memory_bytes: 83060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2000 + 10;
const ll mod = 1e9 + 7;
ll fac[maxn], inv[maxn], facinv[maxn], bin[maxn];
ll f[maxn][maxn];
void pre()
{
	fac[0] = 1; for(int i = 1; i < maxn; ++i) fac[i] = fac[i - 1] * i % mod;
	inv[1] = 1; for(int i = 2; i < maxn; ++i) inv[i] = (mod - mod / i) * inv[mod % i] % mod;
	facinv[0] = 1; for(int i = 1; i < maxn; ++i) facinv[i] = facinv[i - 1] * inv[i] % mod;
	bin[0] = 1; for(int i = 1; i < maxn; ++i) bin[i] = bin[i - 1] * 2 % mod;
}
ll C(int n, int m) { return n < m ? 0 : fac[n] * facinv[m] % mod * facinv[n - m] % mod;}
int main()
{
	pre();
	int n, k;
	scanf("%d%d", &n, &k);
	for(int j = 1; j <= n; ++j) f[1][j] = 1;
	for(int i = 2; i < k; ++i)
	{
		ll sum = 0;
		for(int j = n; j; --j)
		{
			if(n - j + 1 > i - 1) f[i][j] = f[i - 1][j];
			f[i][j] = (f[i][j] + sum) % mod;
			sum = (sum + f[i - 1][j]) % mod;
		}
	}
	ll ans = 0;
	if(k > 1) for(int j = 2; j <= n; ++j) ans = (ans + f[k - 1][j]) % mod;
	else ans = 1;
	if(k < n) ans = ans * bin[n - k - 1] % mod;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 34988
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(i = 0; i < n; i++)
//2D::rep(i,j)rep(j,j)cin>>bin[i][j];
//vector<int> a(n)
#define Graph vector<vector<int>>
#define A1 cout<<"No"<<endl
#define A2 cout<<"Yes"<<endl
#define A3 cout<<ans<<
#define AA(i) cout<<i<<endl;
const int U=2e5+5;
const ll MOD=1000000007;
const int INF = 1001001001;

int main(){
    int N; cin >> N;
    AA(N+N*N+N*N*N);
    return 0;
}

Measured memory_bytes: 3632
import math

while(True):
    n = int(input())
    if n == 0:
        break
    
    s = []
    s = [int(i) for i in input().split()]
    average = sum(s) / n
    a = 0
    for i in range(n):
        a += pow(s[i] - average,2)
    se = math.sqrt(a/n)  
    print('{:.10f}'.format(se))



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

int main(){
    string a,b; cin >> a >> b; a += b;
    int num = stoi(a);
    for(int i = 1; i * i <= num; i++){
        if(i * i == num){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
/**
    why I'm too lazy?
**/
#include <bits/stdc++.h>

#define fr first
#define sc second
#define mk make_pair
#define pb emplace_back
#define pp pop_back()
#define ll long long
#define ld long double
#define OK puts("OK");
#define sz(s) (int)s.size()
#define all(s) s.begin(), s.end()

using namespace std;

const int N = 1e6 + 10;
const int inf = 1e9 + 7;
const ll linf = 1e18 + 7;

ll n, dp[N], sum;

int main() {
    cin >> n;
    dp[1] = n;
    dp[2] = n * n % inf;
    for(int i = 3; i <= n; i++) {
        if(i > 3)
            sum = (sum + dp[i - 3]) % inf;
        dp[i] = (dp[i - 1] + (n - 1) * (n - 1) % inf + sum + (n - i + 2)) % inf;
    }
    cout << dp[n] << endl;
}


Measured memory_bytes: 8064
#include <stdio.h>

int main(){
    int n, i, cnt=0;
    long int a[200];

    scanf("%d", &n);

    for(i=0; i<n; i++)
        scanf("%ld", &a[i]);
    
    while(1){
        for(i=0; i<n; i++){
            if(a[i] % 2 == 0){
                a[i] /= 2;
            }
            else{
                printf("%d\n", cnt);
                return 0;
            }
        }
        cnt++;
    }

}

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

using namespace std;
typedef long long LL;

int main(){
	int H, W, K;
	cin >> H >> W >> K;
	string S[15];
	rep(i,H) cin >> S[i];
  	int ans=100000;
	int num[15];
	rep(bit,1<<(H-1)){
      rep(i,H) num[i]=0;
      int res=0, cut=0;
      rep(i,H) if(bit&(1<<i)) res++;
		rep(i,W){
			if(cut>W){
              res=100000;
              break;
            }
			int now=0;
			rep(j,H){
				if(S[j][i]=='1') num[now]++;
				if(bit&(1<<j)) now++;
			}
			rep(j,H){
				if(num[j]>K){
					res++;
					rep(k,H) num[k]=0;
          			i--;
                    cut++;
          			break;
				}
			}
		}
        ans=min(ans,res);
	}
    cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <atcoder/all>
#define rep(i, n) for (int i = 0; i < (n); ++i)
// using namespace atcoder;
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
//マクロ
// forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
// Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
// xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end()  // sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())       // sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))    //最大値を求める
#define MIN(x) *min_element(ALL(x))    //最小値を求める
//定数
#define INF 1000000000000  // 10^12:極めて大きい値,∞
#define inf 2147483647     // int値の最大値
#define MOD 1000000007     // 10^9+7:合同式の法
#define MAXR 100000        // 10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back                             // vectorヘの挿入
#define MP make_pair                             // pairのコンストラクタ
#define F first                                  // pairの一つ目の要素
#define S second                                 // pairの二つ目の要素
#define CST(x) cout << fixed << setprecision(x)  //小数点以下の桁数指定
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 gcd(int a, int b) {
    if (b == 0)
        return a;
    else
        return gcd(b, a % b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
//各桁の和
int sumDight(int x) {
    int sum = 0;
    while (x > 0) {
        sum += (x % 10);
        x /= 10;
    }
    return sum;
}
//回文数
int divideReverse(int x) {
    int reverse = 0;
    int r;
    while (x > 0) {
        r = x % 10;
        reverse = reverse * 10 + r;
        x /= 10;
    }
    return reverse;
}


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

    int n, k;
    vector<int> l(101);
    cin >> n >> k;
    rep(i, n) cin >> l[i];

    sort(ALL(l));
   reverse(ALL(l));
   int sum = 0;
   rep(i, k)sum += l[i]; 

   // rep(i, n) cout << l[i] << endl;
   cout << sum << endl;
}


Measured memory_bytes: 3624
#include<cstdio>
#include<vector>
#include<algorithm>
#include<iostream>
using namespace std;
int n;
vector<int> dp;
vector<int> a;

void solve()
{
  int length=0;
  for(int i=0; i<a.size(); i++)
  {
    if(a[i] > dp[length])
    {
      dp.push_back(a[i]);
      length++;
    }
    else
    {
      *lower_bound(dp.begin(), dp.end(), a[i]) = a[i];
    }
  }
  printf("%d\n", length+1);
}
int main()
{
  int temp;
  scanf("%d", &n);
  for(int i=0; i<n; i++)
  {
    scanf("%d", &temp);
    a.push_back(temp);
  }
  dp.push_back(a[0]);
  solve();
  return 0;
}



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

int plus_minus(int i){
  if(i%2==0)return -1;
  else return 1;
}

int main(){
  int N;
  cin >> N;
  ll A[N];
  rep(i,N)cin >> A[i];
  ll cross_sum[N];
  cross_sum[0] = A[0];
  for(int i=1;i<N;i++){
    if(i%2==0)cross_sum[i] = cross_sum[i-1]+A[i];
    else cross_sum[i] = cross_sum[i-1]-A[i];
  }
  //rep(i,N)cout << cross_sum[i] << endl;
  cout << cross_sum[N-1] << endl;
  for(int i=1;i<N;i++){
    cout << (-1)*plus_minus(i)*cross_sum[N-1] + plus_minus(i)*2*cross_sum[i-1] << endl;
  }
  return 0;
}


Measured memory_bytes: 2816
use std::io::*;
use std::str::FromStr;

//https://qiita.com/tubo28/items/e6076e9040da57368845
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let R:i64 = read();
    let G:i64 = read();
    let B:i64 = read();
    let N:i64 = read();

    let mut ans = 0;
    
    for r in 0..3001{
        for g in 0..3001{
            if (N - (R * r) - (G * g)) % B == 0 && (N - (R * r) - (G * g)) >= 0{
                ans += 1;
            }
        }
    }   
    println!("{}",ans);
}


Measured memory_bytes: 2168
#include <iostream>
#include <vector>
#include <algorithm>
#include <chrono>
using namespace std;
using namespace chrono;

//  https://ja.wikipedia.org/wiki/Xorshift
int xor64(void) {
    static unsigned long long x = 88172645463325252ULL;
    x ^= x<<13;
    x ^= x>> 7;
    x ^= x<<17;
    return int(x&0x7fffffff);
}

int main()
{
    //  入力
    int D;
    cin>>D;
    vector<int> C(26);
    for (int &c: C)
        cin>>c;
    vector<vector<int>> S(D, vector<int>(26));
    for (auto &s: S)
        for (auto &x: s)
            cin>>x;

    auto start = system_clock::now();

    //  選んだコンテスト
    vector<int> T(D, -1);

    int score = 0;
    for (int t=0; t<26; t++)
        score -= C[t]*D*(D+1)/2;

    //  d日目にコンテストtを開く
    auto add = [&](int d, int t)
    {
        int d0 = d;
        while (d0>=0 && T[d0]!=t)
            d0--;
        int d1 = d;
        while (d1<D && T[d1]!=t)
            d1++;
        score += C[t]*(d-d0)*(d1-d);
        score += S[d][t];
        T[d] = t;
    };

    //  d日目のコンテストを止める
    auto remove = [&](int d)
    {
        int t = T[d];
        T[d] = -1;
        int d0 = d;
        while (d0>=0 && T[d0]!=t)
            d0--;
        int d1 = d;
        while (d1<D && T[d1]!=t)
            d1++;
        score -= C[t]*(d-d0)*(d1-d);
        score -= S[d][t];
    };

    for (int d=0; d<D; d++)
        add(d, d%26);

    double time = 0.0;
    double limit = 1.8;

    int step;
    for (step=0; time<limit; step++)
    {
        if (step%10000==0)
            time = duration_cast<microseconds>(system_clock::now()-start).count() * 1e-6;

        if (step%2==0)
        {
            //  1日のコンテストの種類を変えてみる
            int d = xor64()%D;
            int t = xor64()%26;
            int old_score = score;
            int old_t = T[d];            
            remove(d);            
            add(d, t);

            //  悪くなったら戻す
            if (score < old_score)
            {
                remove(d);
                add(d, old_t);
            }
        }
        else
        {
            //  1週間以内のコンテストを交換してみる
            int d0 = xor64()%D;
            int d1 = d0 + xor64()%15 - 7;
            if (d1!=d0 && 0<=d1 && d1<D)
            {
                int old_score = score;
                int t0 = T[d0];
                int t1 = T[d1];
                remove(d0);
                remove(d1);
                add(d0, t1);
                add(d1, t0);

                //  悪くなったら戻す
                //  ただし、ある程度までは許容する
                //  許容範囲は時間とともに狭める（焼きなまし）
                if (score < old_score - int(10000*(limit-time)/limit))
                {
                    remove(d0);
                    remove(d1);
                    add(d0, t0);
                    add(d1, t1);
                }
            }
        }
    }

    for (int t: T)
        cout<<t+1<<endl;

    cerr<<"score: "<<max(0, score+1000000)<<endl;
    cerr<<"step: "<<step<<endl;
}


Measured memory_bytes: 3208
#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 M1, D1, M2, D2;
    cin >> M1 >> D1 >> M2 >> D2;
    if (M1 != M2) cout << 1 << endl;
    else cout << 0 << endl;
}



Measured memory_bytes: 3604
from fractions import gcd

N = int(input())
A = list(map(int,input().split()))

L = [0] * (N + 1)
R = [0] * (N + 1)

for i in range(N):
  L[i+1] = gcd(L[i], A[i])
  R[N-i-1] = gcd(R[N-i], A[N-1-i])

ans = 0
for i in range(N):
  ans = max(ans, gcd(L[i], R[i+1]))

print(ans)

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

void swap(int &x, int &y) {
    int tmp = y;
    y = x;
    x = tmp;
}

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

    vector<int> nums;
    for(int i=0; i<n; ++i) {
        int x;
        cin >> x;
        nums.push_back(x);
    }

    bool flag = true;
    int count = 0;
    int index = 0;
    while(flag) {
        flag = false;
        for(int i=n-1; i>index; --i) {
            if(nums[i-1] > nums[i]) {
                swap(nums[i-1], nums[i]);
                count++;
                flag = true;
            }
        }
        index++;
    }
    for(int i=0; i<n-1; ++i) {
        cout << nums[i] << " ";
    }
    cout << nums[n-1] << endl;
    cout << count << endl;

    return 0;
}

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

#define ll long long

#define reps(i, S, E) for (ll i = (S); i <= (E); i++)
#define rep(i, N) reps(i, 0, N-1)
int main(){
    int n;
    cin >> n;
    vector<int> adj[n+1];
    ll result = 0;

    // Connected components = Total no of vertices - Total no of edges
    
    // Total no of vertices
    for(ll i=1; i<=n; i++)
	result += i * (i+1)/2;

    // Total no of edges
    for(ll i=1; i<n; i++){
	ll  a, b;
	cin >> a >> b;
	if(a > b)
	    swap(a, b);
	ll edges = a * (n - b + 1);
	result -= edges;
    }
    cout << result << "\n";
    return 0;
}


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

int main() {
  string o, e;
  cin >> o;
  cin >> e;

  for (string::const_iterator o_it = o.begin(), e_it = e.begin(); e_it != e.end(); o_it++, e_it++) {
    cout << *o_it << *e_it;
  }
  if (o.size() != e.size()) {
    cout << o[o.size() - 1];
  }
  cout << endl;

  return 0;
}


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

vector<ll> lun;

void lunlun(){
    queue<ll> que;
    vector<vector<int>> num(10);
    num[0].push_back(0);
    num[0].push_back(1);
    for(int i=1; i<9; i++){
        for(int j=-1; j<2; j++){
            num[i].push_back(i+j);
        }
    } 
    num[9].push_back(8);
    num[9].push_back(9);
    for(int i=1; i<=9; i++){
        que.push(i);
    }
    while(lun.size()<100005){
        ll sam=que.front();que.pop();
        int a=sam%10;
        sam*=10;
        for(ll p:num[a]){
            ll tmp=sam;
            tmp+=p;
            que.push(tmp);
            lun.push_back(tmp);
        }
    }
}

int main(){
    int k;
    cin >> k;
    for(int i=1; i<10; i++){
        lun.push_back(i);
    }
    lunlun();
    cout << lun[k-1] << endl;
}

Measured memory_bytes: 1620
#include<stdio.h>
#include<stdlib.h>

typedef long long ll;

int max(int a, int b){
  if(a > b) return a;
  else return b;
}
int min(int a, int b){
  if(a < b) return a;
  else return b;
}

int sort(const void*a, const void* b){
  return *(int*)a - *(int*)b;
}

int main(){

  int n;
  scanf("%d",&n);

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

  qsort(a,n,sizeof(int),sort);

  int count = 0;
  int i = 0;
  int res = 0;
  while(i < n){
    int cc = a[i];
    int f = 0;
    while(i<n &&a[i] == cc)f++,i++;
    res += f%2;
  }

  printf("%d",res);

  return 0;

}


Measured memory_bytes: 892
from heapq import *

n,m,s,t=map(int,input().split())
s-=1
t-=1
INF=float("inf")
Gyen=[[]for i in range(n)]
Gsnu=[[]for i in range(n)]
for i in range(m):
  u,v,a,b=map(int,input().split())
  u-=1
  v-=1
  Gyen[u].append([v,a])
  Gyen[v].append([u,a])
  Gsnu[u].append([v,b])
  Gsnu[v].append([u,b])

def dijkstra(G,s):
  d=[INF]*n
  d[s]=0
  visited={s}
  que=[(0,s)]
  while(que):
    p=heappop(que)
    v=p[1]
    visited.add(v)
    for node,cost in G[v]:
      if (node not in visited) and d[node]>d[v]+cost:
        d[node]=d[v]+cost
        heappush(que,(d[node],node))
  return d

yen=dijkstra(Gyen,s)
snu=dijkstra(Gsnu,t)
ans=10**15
ans_list=[]
for i in reversed(range(n)):
  ans=min(ans,yen[i]+snu[i])
  ans_list.append(10**15-ans)
print(*ans_list[::-1], sep='\n')


Measured memory_bytes: 136524
B = input()
order = True
F = ""
for q in range(int(input())):
    T = input().rstrip().split()
    if T[0] == "1":
        order ^= True
    else:
        f,c = T[1],T[2]
        if not((f == "1") ^ order):
            F += c
        else:
            B += c
    #print(F,B)
F = F[::-1]+B
if not order:
    F = F[::-1]
print(F)

Measured memory_bytes: 4304
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <stdio.h>
#include <string>
using namespace std;
#define ll long long
#define mod 1000000007;


int main() {
	int n;
	cin >> n;
	cout << n * n * n << endl;
	return 0;
}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

int main()
{
    int x;
    cin >> x;

    int n = x / 100;

    if (100 * n <= x && x <= 105 * n)
    {
        cout << 1 << '\n';
    }
    else
    {
        cout << 0 << '\n';
    }

    return 0;
}


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

int main()
{
  int n;
  cin >> n;
  vector<int> p(n);
  rep(i, n)
    cin >> p[i];
  vector<int> q(n);
  rep(i, n)
    cin >> q[i];
  if (p == q)
  {
    cout << '0' << endl;
    return 0;
  }
  else if (p > q)
    swap(p, q);
  
  int ans = 0;
  while (next_permutation(p.begin(), p.end()))
  {
    ans++;
    bool check = true;
    rep(i, n)
      if (p[i] != q[i])
      {
        check = false;
        break;
      }
    if (check)
      break;
  }
  cout << ans << endl;
}

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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set
#define pll pair<ll, ll>
#define vll vector<ll>
#define mll map<ll, ll>

using namespace std;

const ll MOD = 1000000007LL;
const ll INF = (1LL << 60LL);

pll digit(ll n) {
  ll base;

  ll k = 1;
  ll ksum = 1;
  ll dg = 1;
  for (ll i = 1; i <= 15; i++) {
    k *= 26;
    if (n < (ksum + k)) {
      dg = i;
      base = n - ksum;
      break;
    }
    ksum += k;
  }
  return make_pair(dg, base);
}

string calc(ll n) {
  string ans = "";

  auto p = digit(n);

  ll dg = p.first;
  ll base = p.second;

  ll k = 1;
  for (ll i = dg; i >= 1; i--) {
    k = 1;
    for (ll j = 0; j < i - 1; j++) {
      k *= 26;
    }

    ll c = base / k;
    ll ch = 'a' + c;
    ans += ch;

    base -= k * c;
  }

  return ans;
}

int main() {
  ll N;
  scanf("%lld", &N);

  cout << calc(N) << endl;
}


Measured memory_bytes: 3688
#define ONLINE_JUDGE
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) for(ll i=0;i<(n);++i)
#define _rep3(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2)(__VA_ARGS__)
#define _repe2(i,n) for(ll i=0;i<=(n);++i)
#define _repe3(i,a,b) for(ll i=(a);i<=(b);++i)
#define repe(...) _overload3(__VA_ARGS__,_repe3,_repe2)(__VA_ARGS__)
#define _rrep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define _rrep3(i,a,b) for(ll i=(b)-1;i>=(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
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(b<a){a=b;return 1;}return 0;}
template<class T>
using pq=priority_queue<T,vector<T>,greater<T>>;

string S;

void solve();

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cin >> S;
    solve();
}

// 1 ≤ |S| ≤ 200000
// S は 1 から 9 までの数字のみからなる文字列

// ll S
// 条件を満たす整数の組 (i,j) (1 ≤ i ≤ j ≤ |S|) の総数を出力せよ。
void solve(){
    ll n=S.size();

    vl cnt(2019);
    ++cnt[0];
    ll t=0;
    ll base=1;
    rrep(i,n){
        t+=base*(S[i]-'0');
        t%=2019;
        ++cnt[t];
        (base*=10)%=2019;
    }

    ll ans=0;
    rep(i,2019)ans+=cnt[i]*(cnt[i]-1)/2;
    cout<<ans<<endl;
}


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

int main(int argc, char *argv[]) {
  int n;
  std::cin >> n;
  std::vector<int> a(n);
  for (int i = 0; i < n; ++i)
    std::cin >> a.at(i);

  for (int i = 0; i < n; ++i) {
    int v = a.at(i);
    if (!(v % 2 == 0))
      continue;
    if (!(v % 3 == 0 || v % 5 == 0)) {
      std::cout << "DENIED" << std::endl;
      return 0;
    }
  }
  std::cout << "APPROVED" << std::endl;
}


Measured memory_bytes: 256