akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <algorithm>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>

using namespace std;

int gcd(int c,int d) {

    int a = c, b = d, r, tmp;

    /* 自然数 a > b を確認・入替 */
    if (a < b) {
        tmp = a;
        a = b;
        b = tmp;
    }

    /* ユークリッドの互除法 */
    r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }

    return b;
}

int main() {
    int N=0, X=0;
    int x[100000];
    int sa[100000];
    cin>> N>>X;

    for(int i=0; i<N; i++){
        cin >> x[i];
        sa[i] = abs(x[i]-X);
    }
    int min = 1000000000;
    int t;
    if(N>1) {
        for (int i = 0; i < N; i++) {
            if (min > (t = gcd(sa[0], sa[i]))) {
                min = t;
            }
        }
        printf("%d",min);
    }else{
        printf("%d", abs(X-x[0]));
    }



    return 0;

}


Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main(int argc, const char * argv[]) {
    string a;
    int i,c,b;
    c=0;
    b=0;
    cin>>a;
    
    if ((a[0]-'0')*10+a[1]-'0'<=12&&(a[0]-'0')*10+a[1]-'0'>0){
        c=1;
    }
    if ((a[2]-'0')*10+a[3]-'0'<=12&&(a[2]-'0')*10+a[3]-'0'>0){
        b=1;
    }
    if (c==1&&b==1)
        cout<<"AMBIGUOUS";
    else if (c!=1&&b!=1)
        cout<<"NA";
    else if (c==1){
        cout<<"MMYY";
    }
    else if (b==1){
        cout<<"YYMM";
    }
    return 0;
}

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

namespace c
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split().Select(i => int.Parse(i)).ToArray();

            var d = new Dictionary<int, int>();
            for(var i = 0; i < n; i++){
                d.Add(i + 1, a[i]);
            }

            var sorted = d.OrderBy(k => k.Value);
            Console.WriteLine(string.Join(" ",sorted.Select(v => v.Key.ToString())));
        }
    }
}


Measured memory_bytes: 34400
c = [[]]*3

for i in range(3):
    c[i] = list(map(int, input().split()))
ans = 0
for i in range(3):
    ans += sum(c[i])

if ans % 3 == 0:
    

    arr = [0]*3
    sum = 0
    for i in range(3):
        arr[0] += c[i][i]
    for i in range(3):
        if i + 1 < 3:
            arr[1] += c[i][i+1]
        else:
            arr[1] += c[i][0]
    for i in range(3):
        if i + 2 < 3:
            arr[2] += c[i][i+2]
        else:
            arr[2] += c[i][i-1]
    
    if arr[0] != arr[1] or arr[0] != arr[2]:
        print("No")
        exit(0)

    print("Yes")
    exit(0)

print("No")

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <map>
#include <cmath>
#include <vector>
#include<cstdio>
#include <iterator>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <stack>
#include <queue>
using namespace std;
typedef long long ll;
#define len(str) (int)(str.length())
int main() {
	string A, B;
	cin >> A >> B;
	string ans;
	if (len(A)==len(B)) {
		for (int a = 0; a < len(A); a++)
		{
			if (A[a] * 1 - '0' * 1 < B[a] * 1 - '0' * 1) {
				cout << "LESS" << endl;
				return 0;
			}
			else if (A[a] * 1 - '0' * 1 > B[a] * 1 - '0' * 1) {
				cout << "GREATER" << endl;
				return 0;
			}
		}
		cout <<"EQUAL"<< endl;
	}
	else {
		cout <<(len(A) < len(B) ?"LESS" : "GREATER")<< endl;
	}

	
}

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

using namespace std;

#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);i++)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;i>=(int)(m);i--)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll) 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;
constexpr int loose = 0;
constexpr int tight = 1;


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

struct Edge {
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
	to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

ll dp1[101010];
ll dp2[101010];

ll rec(ll s){
	if(dp2[s]!=-1) return dp2[s];
	ll ret = dp1[s];
	for(ll i=(s-1)&s; i>0; i=(i-1)&s){
		chmax(ret, rec(i)+rec(i^s));
	}
	return dp2[s]=ret;
}

void solve(){
	ll n;
	cin>>n;
	Matrix a(n,Array(n));
	REP(i,n) REP(j,n) cin>>a[i][j];

	REP(bit,(1LL<<n)){
		Array as;
		REP(i,n) if(bit&(1LL<<i)) as.push_back(i);
		REP(i,as.size()) rep(j,i+1,as.size()) dp1[bit]+=a[as[i]][as[j]];
	}

	REP(i,(1LL<<n)) dp2[i]=-1;

	cout<<rec((1LL<<n)-1)<<en;
}

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

    solve();
    return 0;
}

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

int main(){
char n[19],eq='\0';
cin >> n;
if(n[1]==n[2]){
eq=n[1];
}
if((n[0]==eq)||(n[3]==eq)){
cout << "Yes";
}
else{
cout << "No";
}

return 0;
}


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

int main()
{ int n;
 cin>>n;
 string s;
 int ac= 0, tle = 0, wa= 0, re = 0;
 vector<string> arr;
 for(int i =0; i<n; i++)
 { cin>>s;
  arr.push_back(s);}
 for(int i = 0; i<n; i++)
 {if (arr[i] =="AC")
   ac += 1;
  if (arr[i] =="RE")
   re += 1;
  if (arr[i] =="WA")
   wa += 1;
  if (arr[i] =="TLE")
   tle += 1;}

 cout<<"AC "<<"x "<<ac<<endl;

  cout<<"WA "<<"x "<<wa<<endl;

  cout<<"TLE "<<"x "<<tle<<endl;

  cout<<"RE "<<"x "<<re<<endl;
 return 0;}


Measured memory_bytes: 7464
n = int(input())
s = int(input())
lst = []

for i in range(n):
     lst.append(s%10)
     s //= 10
lst.reverse()

ten = [-1]*10
hun = [-1]*100
tho = [-1]*1000

for i in range(len(lst)):
    l = lst[i]
    for j in range(100):
        if not hun[j] == -1:
            idx = j*10 + l
            tho[idx] = 1
    for j in range(10):
        if not ten[j] == -1:
            idx = j*10 + l
            hun[idx] = 1
    ten[l] = 1

ans = 0
for i in range(1000):
    if tho[i] == 1:
        ans += 1
print(ans)


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

vector<long> a;
int main(){
  long N, x, c;
  long ans;
  
  cin >> N;
  for(int i = 0; i < N; ++i){
    long t;
    cin >> t;
    a.push_back(t);
  }
  sort(a.begin(), a.end());

  ans = 0;
  x = N;
  c = 0;
  for(int i = 0; i < N; ++i){
    if(i > 1 && a[i] == a[i - 1]){
      ++c;
    }else{
      x -= c;
      c = 1;
      int j;
      for(j = i > 1? a[i - 1]: 0; j < a[i]; ++j){
        ans ^= x;
      }
    }
  }
  if(ans == 0){
    cout << "second" << endl;
  }else{
    cout << "first" << endl;
  }
  return 0;
}

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

int main(){
  int N,A;
  cin>>N;
  A=0;
  for (int i=0;i<N;i++){
    int a,b;
    cin>>a>>b;
    A+=(b-a+1);
  }
  cout<<A<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
#else
#define show(x) true
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);
	
	int N;
	cin >> N;
	V<int> a(N);
	rep(i,N) cin >> a[i];
	int S = 0;
	rep(i,N) S += a[i];
	int ans = 1e9;
	int s = 0;
	rep(i,N){
		s += a[i];
		chmin(ans,abs(s-(S-s)));
	}
	cout << ans << endl;
}


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

int main() {
  int a, b, c, k;
  cin >> a >> b >> c >> k;

  priority_queue<int> p;
  p.push(a);
  p.push(b);
  p.push(c);

  for (int i = 0; i < k; i++) {
    int tmp = p.top() * 2;
    p.pop();
    p.push(tmp);
  }
  int ans = 0;
  for (int i = 0; i < 3; i++) {
    ans += p.top();
    p.pop();
  }

  cout << ans << endl;
}

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

#define REP(i,n) for(int i=0;i<n;i++)
typedef long long int lli;
typedef pair<int, int> P;

int main() {
    lli x;
    cin >> x;
    lli count = (x/11)*2 ;
    double remain = x % 11;
    if (remain > 0){
        count += 1;
    }
    if (remain > 6){
        count += 1;
    }
    cout << count << endl;
}


// 17 =>  6,5,6


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

int main(){
  int n;
  cin >> n;
  
  int ans = 0;
  for (int i=1 ; i<10 ; i++){
    if (n%i == 0){
      if (n/i < 10){
        ans = 1;
        break;
      }
    }
  }
  
  if (ans == 1)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 3616
def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)

def prime_factorize(n):
    res = []
    for i in range(2, int(n**(1/2))+1):
        if n % i != 0: continue
        num = 0
        while n % i == 0:
            num += 1
            n /= i
        res.append((i, num))
    if n != 1:
        res.append((n, 1))
    
    return res

A, B = map(int, input().split())

gcdAB = gcd(A, B)
pf = prime_factorize(gcdAB)

print(len(pf)+1)


Measured memory_bytes: 3064
S = input()
s = len(S)

if s % 2 != 0:
    S = S[:-1]
    s = len(S)
else:
    S = S[:-2]
    s = len(S)

for i in range(s // 2):
    s = len(S)
    if S[:s // 2] == S[s // 2:]:
        print(s)
        exit()
    else:
        S = S[:-2]

Measured memory_bytes: 3060
function main()
	readline()
	cnt=zeros(Int,10^6)
	for a=map(x->parse(Int,x),split(readline()))
		cnt[a]+=1
	end
	ans=0
	for i=1:10^6
		if cnt[i]>0
			if cnt[i]==1
				ans+=1
			end
			for j=i+i:i:10^6
				cnt[j]=0
			end
		end
	end
	println(ans)
end
main()


Measured memory_bytes: 200368
def rpn()
  stack = []
  a = gets.split(' ')
  for i in 0..a.length-1
    if a[i] == '+'
      b = stack.shift
      c = stack.shift
      stack.unshift(b+c)
    elsif a[i] == '-'
      b = stack.shift
      c = stack.shift
      stack.unshift(c-b)
    elsif a[i] == '*'
      b = stack.shift
      c = stack.shift
      stack.unshift(b*c)
    elsif
      stack.unshift(a[i].to_i)
    end
  end
  puts stack.shift
end

rpn() 

Measured memory_bytes: 8680
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>

int main() {
  uint32_t N = 0;
  std::cin >> N;
  uint32_t count = 0;
  for (size_t i = 0; i < N; i++)
  {
    uint32_t a = 0;
    std::cin >> a;
    if(i%2) continue;
    if(a%2) count++;
  }
  std::cout << count << std::endl;

  return 0;
}

Measured memory_bytes: 3592
#include<iostream>
#include<string>
#include<cstdio>
#include <cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define int long long

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
    int N; cin >> N;
    vector<string> S;
    rep(i, N) {
        char s[10];
        rep(j, 10) {
            cin >> s[j];
        }
        sort(s, s + 10);
        string t;
        rep(j, 10) {
            t += s[j];
        }
        S.pb(t);
    }
    sort(all(S));
    int ans = 0;
    int cnt = 1;
    string u = S[0];
    rep1(i, N - 1) {
        if(u == S[i]) {
            cnt ++;
        }
        if(u != S[i] || i == N - 1) {
            ans += cnt * (cnt - 1) / 2;
            cnt = 1;
            u = S[i];
        }
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 7284
#include <iostream>

using namespace std;

int main()
{
    int n,W;
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> W;
    long long F[n+1][W+1], v[n+1], w[n+1];
    for (int i=1; i<=n; i++)
    {
        cin >> w[i] >> v[i];
    }
    for (long long i=0; i<=n; i++) F[i][0]=0;
    for (long long j=0; j<=W; j++) F[0][j]=0;
    for (long long i=1; i<=n; i++)
    {
        for (long long j=1; j<=W; j++)
        {
            if (w[i]>j) F[i][j]=F[i-1][j];
            else F[i][j]=max(F[i-1][j], F[i-1][j-w[i]]+v[i]);
        }
    }
    cout << F[n][W];
    return 0;
}


Measured memory_bytes: 79232
/* ex3_3
   masaaki52	*/
#include <stdio.h>
int main(void){
  int number,kisuu,ruijou,keta;
  scanf("%d %d",&number,&kisuu);
  ruijou = kisuu;
  keta = 1;
  while(number >= ruijou){
    ruijou = ruijou * kisuu;
    keta += 1;
  }
  printf("%d\n",keta);
  return 0;
}


Measured memory_bytes: 128
#coding: utf-8
import sys
def f(n):
    if n % 2 == 0:
        return n / 2
    else:
        return 3*n + 1
s = int(input())
l = [s]
while True:
    l.append(f(l[-1]))
    for i in range(len(l)):
        for j in range(i+1, len(l)):
            if l[i] == l[j]:
                print(j+1)
                sys.exit()

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int g,t,re=0,wq[25][5];
    scanf("%d",&t);
    for(g=0;g<t;g++)
        scanf("%d",&wq[g][0]);
    for(g=0;g<t;g++)
        scanf("%d",&wq[g][1]);
    for(g=1;g<t;g++)
        scanf("%d",&wq[g][2]);
    for(g=0;g<t;g++){
        re+=wq[wq[g][0]-1][1];
        if(g>0&&wq[wq[g][0]-1]==wq[wq[g-1][0]])
            re+=wq[wq[g][0]-1][2];
    }
    printf("%d\n",re);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int N, K;
  scanf("%d %d", &N, &K);

  char S[N + 1];
  scanf("%s", S);
  S[K - 1] = S[K - 1] + 'a' - 'A';
  printf("%s", S);
  return 0;
}

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

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

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

	int plus = 1;
	int ans = 1;
	if (D == 1) {
		plus = 100;
		ans = 100;
	}
	else if (D == 2) {
		plus = 10000;
		ans = 10000;
	}

	for (int i = 1; i < N; ++i) {
		ans += plus;
	}

	if (N == 100) {
		ans += plus;
	}

	cout << ans << endl;
	return 0;
}

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

        int main() {
          ll N, M;
          cin >> N >> M;
          ll answer=0; 
          
          for(ll g=1; g*g<=M ; g++ ){
              if( (M%g)==0 ){
                  if( g*N <= M ) answer = max(answer, g);
                  ll D = M/g; 
                  if( D*N <= M ) answer = max(answer, D);
              }
              
          }
          
          if(N==1){
              cout<< M << endl;
          }else{
              cout<< answer << endl;
          }

        }

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  int n;cin>>n;
  long ans=0;
  vector<int>a(n);
  for(int i=0;i<n;i++)cin>>a[i];
  sort(a.begin(),a.end());
  for(int i=n-1;i>0;i--){
    if(a[i-1]==a[i]){
      if(ans){cout<<ans*a[i]<<endl;return 0;}
      ans=a[i--];
    }
  }
  cout<<0<<endl;
  return 0;
}

Measured memory_bytes: 640
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<vector>
using namespace std;
const int maxn = 1000000 + 10;
const int N = maxn << 1;
const int maxE = 3000000;
const int INF = 0x3f3f3f3f;

int n, h[N], ecnt, tot, S, T;
struct enode{
	int v, n, w, op;
	enode() {}
	enode(int _v, int _n, int _w, int _op):v(_v), n(_n), w(_w), op(_op) {}
}e[maxE << 1];

inline void addedge(int u, int v, int w) {
	ecnt ++; e[ecnt] = enode(v,h[u],w,ecnt + 1); h[u] = ecnt;
	ecnt ++; e[ecnt] = enode(u,h[v],0,ecnt - 1); h[v] = ecnt;
}

int level[N], q[N << 1], cur[N];
inline bool bfs() {
	memset(level,0,sizeof(level));
	int head = 1, tail = 0;
	level[S] = 1; q[++ tail] = S;
	for(int i = S;i <= tot;i ++) cur[i] = h[i];
	while(head <= tail) {
		int u = q[head]; head ++;
		for(int i = h[u];~ i;i = e[i].n) {
			int v = e[i].v;
			if(!level[v] && e[i].w > 0) {
				level[v] = level[u] + 1;
				q[++ tail] = v;
				if(v == T) return 1;
			}
		}
	}
	return 0;
}

int dfs(int u, int c) {
	if(u == T || c == 0) return c;
	int tmp = 0;
	for(int &i = cur[u];~ i;i = e[i].n) {
		int v = e[i].v;
		if(level[v] == level[u] + 1) {
			int x = dfs(v,min(c,e[i].w));
			if(x) {
				e[i].w -= x; e[e[i].op].w += x;
				tmp += x; c -= x;
				if(!c) break;
			}
		}
	}
	if(!tmp) level[u] = -1;
	return tmp;
}

int pre[maxn], used[maxn], lis[maxn];
vector<int> g[maxn], from[maxn];

int main() {
	scanf("%d", &n); tot = n;
	S = 0; T = ++ tot; ecnt = 0;
	memset(h,-1,sizeof(h));
	for(int i = 2;i <= n;i ++) addedge(i,T,1);
	for(int i = 1;i < n;i ++) {
		int p = ++ tot;
		addedge(S,p,1);
		int k; scanf("%d", &k);
		for(int j = 1;j <= k;j ++) {
			int x; scanf("%d", &x);
			g[i].push_back(x);
			from[x].push_back(i);
			addedge(p,x,INF);
		}
	}
	int flow = 0;
	while(bfs())
		flow += dfs(S,INF);
	if(flow < n - 1) {
		puts("-1");
		return 0;
	}
	for(int u = 2;u <= n;u ++) {
		for(int i = h[u];~ i;i = e[i].n) {
			int v = e[i].v;
			if(v != T && e[i].w) lis[v - n - 1] = u;
		}
	}
	int head = 1, tail = 0;
	q[++ tail] = 1; pre[1] = -1;
	while(head <= tail) {
		int u = q[head]; head ++;
		for(int i = 0, Sz = from[u].size();i < Sz;i ++) {
			int id = from[u][i];
			if(used[id]) continue;
			used[id] = 1;
			int v = lis[id];
			pre[v] = u;
			q[++ tail] = v;
		}
	}
	for(int i = 2;i <= n;i ++) {
		int u = lis[i - 1], v = pre[u];
		printf("%d %d\n", u, v);
	}
	return 0;
}


Measured memory_bytes: 95104
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        String ans = "No";

        for (int i = 0; i < x + 1; i++) {
            if (2 * (x - i) + 4 * i == y) {
                ans = "Yes";
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 35784
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	string a;
	cin>>n;
	cin>>a;
	int len=a.length();
	for(int i=0;i<len;i++)
	{
		a[i]+=n;
		if(a[i]>'Z')
		{
			a[i]-=26;
		}
		cout<<a[i];
	}
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
 
int d, g;
int p[105], c[105];
int res;
 
 
int cache[12][10550005];
 
int foo(int now, int score) {
    if(now >= d) {
        if(score >= g) return 0;
        return 1e8;
    }
    if(score >= g) return 0;
    int &ret = cache[now][score];
    if(~ret) return ret;
    ret = 1e9;

    ret = foo(now + 1, score);

    for(int i = 0; i < p[now] - 1; i++) {
        int x = foo(now + 1, score + (i + 1) * (now + 1) * 100);
        ret = min(ret, x + i + 1);
    }

    ret = min(ret, p[now] + foo(now + 1, score + p[now] * (now + 1) * 100 + c[now]));
    return ret;
}
 
int main() {
    cin >> d >> g;
    for (int i = 0; i < d; ++i) {
        scanf("%d %d", &p[i], &c[i]);
    }
 
    memset(cache, -1, sizeof cache);
    res = 1e9;
    res = foo(0, 0);
    cout << res << endl;
}

Measured memory_bytes: 494720
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
  string S;
  cin>>S;
  set<char> A;
  for(ll i=0;i<S.size();i++) {
if(A.count(S[i])) {
cout<<"no"<<endl;
  return 0;
}
   A.insert(S[i]);
   }
   
   cout<<"yes"<<endl;
   }


Measured memory_bytes: 3620
x=int(input())
dig=[]
for i in range(1,4):
  dig.append(x%(10))
  x=x//10
dig.append(x)

d,c,b,a=dig

if (a+b+c+d)==7:
  print(str(a)+"+"+str(b)+"+"+str(c)+"+"+str(d)+"=7")
elif (a+b+c-d)==7:
  print(str(a)+"+"+str(b)+"+"+str(c)+"-"+str(d)+"=7")
elif (a+b-c+d)==7:
  print(str(a)+"+"+str(b)+"-"+str(c)+"+"+str(d)+"=7")
elif (a+b-c-d)==7:
  print(str(a)+"+"+str(b)+"-"+str(c)+"-"+str(d)+"=7")
elif (a-b+c+d)==7:
  print(str(a)+"-"+str(b)+"+"+str(c)+"+"+str(d)+"=7")
elif (a-b-c+d)==7:
  print(str(a)+"-"+str(b)+"-"+str(c)+"+"+str(d)+"=7")
elif (a-b+c-d)==7:
  print(str(a)+"-"+str(b)+"+"+str(c)+"-"+str(d)+"=7")
elif (a-b-c-d)==7:
  print(str(a)+"-"+str(b)+"-"+str(c)+"-"+str(d)+"=7")

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

int main(){

  int ans,a,b;

  cin >> a >> b;

  if(a==b){
    ans = a+b;
  }
  else if(a>b){
    ans = 2*a-1;
  }
  else{
    ans = 2*b-1;
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define ll int
#define bits_count __builtin_popcountll
#define endl '\n'
#define double long double
#define ld double
#define FOR(i,a,n) for (ll i=(a);i<=(n);++i)
#define RFOR(i,a,n) for (ll i=(n);i>=(a);--i)
#define ZERO(a) memset((a),0,sizeof((a)))
#define MINUS(a) memset((a),-1,sizeof((a)))
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define all(g) g.begin(),g.end()
#define sz(x) (ll)x.size()
#define pr pair<int,int>
int fastMax(int x, int y) { return (((y-x)>>(32-1))&(x^y))^y; }
int fastMin(int x, int y) { return (((y-x)>>(32-1))&(x^y))^x; }
    
// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_updat
// using namespace __gnu_pbds;
// typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// const int RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
// struct chash { int operator()(int x) const { return x ^ RANDOM; }};
// cc_hash_table<int, int, hash<int>> cnt;

int power(int x,int y){
    int res = 1;
    while(y){
        if(y&1) res = (res*x);
        x = x*x; y>>=1;
    }
    return res;
}

void solve(){
    int n; cin>>n;

    int len = 1,s_cnt = 1,e_cnt = 26;

    while(1){
        if(s_cnt <= n && n <= e_cnt) break;
        len++;
        s_cnt = e_cnt + 1;
        e_cnt = e_cnt + power(26,len);
    }

    int val = s_cnt;

    FOR(i,1,len){
        int t_a = 1;

        FOR(a,1,26){
            int smalls = (a-1)*power(26,len-i);
            if(val + smalls <= n) t_a = a; 
            else break;
        }
        cout<<char('a' + t_a-1);
        val = val + (t_a-1)*power(26,len-i);
    }
}
    
signed main(){
    
    FastRead;     
    
    int t = 1; 
    // cin>>t;
    FOR(i,1,t){
        // cout<<"Case #"<<i<<": ";
        solve();
    }
}
    




Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
 
int main() {
  lint L,R;
  cin >> L >> R;
  
  if(R-L>2019)cout << 0 << endl;
  else{
    lint ans=2019;
    for(lint i=L;i<R;i++){
      for(lint j=i+1;j<=R;j++){
        ans=min(ans,i*j%2019);
      }
    }
    cout << ans << endl;
  }
}



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

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

using ll = long long;
using P = pair<int,int>;

const int MOD = 1e9 + 7;
const int INF = 1001001001;

map<int, int> factor(int n){
    map<int, int> res;

    for (int i = 2; i*i <= n; ++i) {
        while(n % i == 0){
            res[i]++;
            n /= i;
        }
    }
    if(n != 1) res[n] = 1;

    return res;
}

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

    int n;
    cin >> n;

    vector<int> a(n);
    int m = 0;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        m = max(m, a[i]);
    }
    sort(all(a));

    if(n == 1){
        cout << 1 << "\n";
        return 0;
    }

    if(a[0] == a[n-1]){
        cout << 0 << "\n";
        return 0;
    }

    vector<int> b(m+1);
    b[0] = false;
    for (int i = 0; i < n; ++i) {
//        int x = 1;
//        for (int j = a[i]; j <= m; j*=x) {
//            b[j] = false;
//            x++;
//        }

        int j = a[i], x = 1;
        while(j <= m){
            b[j]++;
            x++;
            j = a[i] * x;
        }
    }

    int ans = 0;
    for (int i = 0; i < n; ++i) {
        if(b[a[i]] > 1){
            ans++;
        }
    }

    ans = n - ans;
    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 7868
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
	int x, y, s;
	
	while (cin>>x>>y>>s, x||y||s) {		
		int ans = -1;
		
		for (int i=1; i<s; i++) {
			for (int j=1; j<s; j++) {
				if (i*(100+x)/100 + j*(100+x)/100 == s) {
					ans = max(ans, i*(100+y)/100+j*(100+y)/100);
				}
			}
		}
		
		cout << ans << endl;
	}
}

Measured memory_bytes: 1160
#include<iostream>
#include<algorithm>
using namespace std;
#include<stdio.h>
int main(){
	int i;
	double a[10];
	while(cin >> a[0]){
		double s=a[0];
		for(i=1;i<10;i++){
			if(i%2==1){
				a[i] = a[i-1]*2;
			}else{
				a[i] = a[i-1]/3;
			}
			s += a[i];
		}
		printf("%.8f\n",s);
	}
	return 0;
}

Measured memory_bytes: 1236
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define p 3165
#define mx 10000005
ll divi[mx];
void divisor(){
    ll i,j;
   for( i=1;i<=mx;i++){
    for( j=i;j<=mx;j+=i)divi[j]++;
   }
}
int main(){
    divisor();
    int n;
    cin>>n;
    ll sum=0;
    for(ll i=1;i<=n;i++){
        sum+=(i*divi[i]);
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 81744
//____________________________________________________________________
  //________________________________NAMAN_______________________________
 //________________________________TALAYCHA______________________________
//__________________________________________________________________________

#include <bits/stdc++.h>
#define ll              long long
#define int             long long
#define pmin            priority_queue < ll, vector<ll>, greater<ll> >
#define pmax            priority_queue <ll>
#define endl            '\n'
#define mii             map<ll , ll >
#define pii             pair< ll, ll >
#define vi              vector<ll>
#define all(a)          (a).begin(), (a).end()
#define DEBUG           cerr<<"/n>>>I'm Here<<</n"<<endl;
#define rep(i, a, b )   for (ll i = a; i < b; i++)
#define rrep(i, a, b)   for (ll i = a; i >= b; i--)
#define bs              binary_search
#define present(c, x)   ((c).find(x) != (c).end())
#define cpresent(c, x)  (find(all(c), x) != (c).end())
#define p1(i)           cout<<i<<endl;
#define p2(i,j)         cout<<i<<" "<<j<<endl;
#define line            cout<<endl;
#define prt(s,b,n)      rep(i,(b),(n)) { cout<<(s)[i]<<" ";} line
#define lower(u)        transform(u.begin(), u.end(), u.begin(), ::tolower);  //convert string u to lowercase;
#define upper(u)        transform(u.begin(), u.end(), u.begin(), ::toupper);
#define tr(container, it) \
for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define hell 1e6+3
#define mod 998244353

  using namespace std;

//_________________________________________________________________________________________________________
//__________________________________________START____________________________________________________________

//................EVERY COIN HAS TWO SIDES...............................................................................................................

void solve()
{
  ll n,w; 
  //ll m=0 , mx=0 , mn=0 , k=0 , ans=0 , flag=0 , res=0 ;
  cin>>n>>w;
  //for(ll i=0;i<n;i++)
  //string s;  cin>>s;
 vi a(n);
  vi b(n);
    rep(i,0,n){ cin>>a[i]>>b[i];}

  ll d1[w+1][n+1];
  rep(i,0,n+1) d1[0][i]=0;
  rep(i,0,w+1) d1[i][0]=0;

 /*   ll d2[n+1];
  rep(i,0,n+1) d2[i]=INT_MIN;
  d2[0]=0;
  d2[1]=b[0];

    ll d3[n+1];
  rep(i,0,n+1) d3[i]=INT_MIN;
  d3[0]=0;
  d3[1]=c[0];
*/
  rep(i,1,w+1)
  {  
   rep(j,1,n+1)
   { 
    d1[i][j]=0;
     if(a[j-1]<=i)
     {
      d1[i][j]=max( d1[i][j-1] , d1[i-a[j-1]][j-1]+ b[j-1] );
     }
     else
      d1[i][j]= d1[i][j-1];
   }
  }
 // prt(d1,1,n+1)
 // prt(d2,1,n+1)
 // prt(d3,1,n+1)
  cout<<d1[w][n]<<endl;
  return;
}

//__________________________________________________________________________________________________________
//__________________________________________END______________________________________________________________

signed main() 
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);

  #ifndef ONLINE_JUDGE 
  freopen("input.txt" , "r", stdin);
  freopen("out12.txt" , "w", stdout);
  #endif  
//sieve();
  ll TESTS = 1;
  //cin>>TESTS;
  while (TESTS--) 
  {
    solve();
  }
  return 0;
}


Measured memory_bytes: 82468
#include <bits/stdc++.h>
using namespace std;
 
long long LCM(int a, int b) {
    return a * 1ll * b / __gcd(a, b);
}
 
int main() {
    int n, m;
    cin >> n >> m;
    long long lcm = 1;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        lcm = LCM(lcm, a[i] / 2);
    }
   for (int i = 0; i < n; ++i) {
        if ((2 * lcm / a[i]) % 2 == 0) {
            return cout << 0, 0;
        }
    }
  int ans=0;
  long long c=lcm;
  int p=1;
  while(lcm<=m){
  	ans++;
  	p=p+2;
  	lcm=p*c;
  	
  }
  cout<<ans;
}

Measured memory_bytes: 640
def insertion_sort(A, n, g):
    global cnt
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j + g] = A[j]
            j -= g
            cnt += 1
        A[j + g] = v


def shell_sort(A, n):
    G = []
    i = 1
    while i <= n:
        G[0:0] = [i]
        i = i * 3 + 1
    for g in G:
        insertion_sort(A, n, g)
    return len(G), G

N = int(input())
a = [int(input()) for i in range(N)]
cnt = 0
m, Gl = shell_sort(a, N)
print(m, ' '.join(str(g) for g in Gl), cnt, '\n'.join(str(e) for e in a), sep='\n')

Measured memory_bytes: 127972
#include <bits/stdc++.h>
using namespace std;using ll=long long;using uint=unsigned int;using pii=pair<int,int>;using pll=pair<ll,ll>;using ull = unsigned long long;using ld=long double;template<typename T>void _(const char*s,T h){cerr<<s<<" = "<<h<<"\n";}template<typename T,typename...Ts>void _(const char*s,T h,Ts...t){int b=0;while(((b+=*s=='(')-=*s==')')!=0||*s!=',')cerr<<*s++;cerr<<" = "<<h<<",";_(s+1,t...);}// break continue pop_back 998244353
#define int ll
#define pii pll
#define f first
#define s second
#define pb emplace_back
#define forn(i,n) for(int i=0;i<(n);++i)
#define sz(a)((int)(a).size())
#define sqr(x) ((x)*(x))
struct init{init(){cin.tie(0);iostream::sync_with_stdio(0);cout<<fixed<<setprecision(10);cerr<<fixed<<setprecision(5);}~init(){
#ifdef LOCAL
#define dbg(...) _(#__VA_ARGS__,__VA_ARGS__)
cerr<<"Time elapsed: "<<(double)clock()/CLOCKS_PER_SEC<<"s.\n";
#else
#define dbg(...) 
#endif
}}init;template<typename T,typename U>void upx(T&x,U y){if(x<y)x=y;}template<typename T,typename U>void upn(T&x,U y){if(x>y)x=y;}mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());const int D=4,dx[]={+1,0,-1,0},dy[]={0,+1,0,-1};
 
const int N=2e5+5;
int a[N],z=0,s[N];
int cnt[N],u[N];
set<int> cs[N];
int n;
int le[N],ri[N];
void del(int v){
    assert(!u[v]);
    u[v]=1;
    le[ri[v]]=le[v];
    ri[le[v]]=ri[v];
}
void ret(int v){
    assert(u[v]);
    u[v]=0;
    le[ri[v]]=v;
    ri[le[v]]=v;
}
void f(int v){
    // dbg("put",v);
    assert(a[s[z]]!=v);
    cs[cnt[v]].erase(v);
    if(!u[a[v]]){
        cs[cnt[a[v]]].erase(a[v]);
        --cnt[a[v]];
        cs[cnt[a[v]]].insert(a[v]);
    }
    del(v);
    s[++z]=v;
}
void b(){
    // dbg("del");
    if(z){
        int v=s[z--];
        // dbg("del",v);
        cs[cnt[v]].insert(v);
        if(!u[a[v]]){
            cs[cnt[a[v]]].erase(a[v]);
            ++cnt[a[v]];
            cs[cnt[a[v]]].insert(a[v]);
        }
        ret(v);
    }
}
void rec(){
    int r=n-z;
    dbg(z,r);
    if(!r){
        for(int i=1;i<=n;++i)
            cout<<s[i]<<' ';
        cout<<'\n';
        exit(0);
    }
    // for(int i=0;i<=n;++i){
    //     if(sz(cs[i])){
    //         cerr<<"cnt "<<i<<": ";for(int j:cs[i])cerr<<j<<' ';cerr<<'\n';
    //     }
    // }
    if(sz(cs[r-1])>1)b();
    else if(sz(cs[r-1])==1){
        int v=*cs[r-1].begin();
        f(v);
        rec();
    }else{
        int i=ri[0];
        while(i!=n+1){
            if(a[s[z]]!=i){
                f(i);
                rec();
            }
            i=ri[i];
        }
    }
}
int32_t main(){
    cin>>n;
    for(int i=1;i<=n;++i){
        cin>>a[i];
        cnt[a[i]]++;
    }
    ri[0]=1;le[n+1]=n;
    for(int i=1;i<=n;++i){
        cs[cnt[i]].insert(i);
        le[i]=i-1;
        ri[i]=i+1;
    }
    rec();
    cout<<"-1\n";
    return 0;
}

Measured memory_bytes: 28596
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000, boost::int128_type>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

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; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }
template<class T> inline bool isSosuu(const T& n) { if (n == T(1)) { return false; } for (T i = 2; i*i <= n; ++i) { if (n % i == 0) { return false; } } return true; }
template<class T> vector<vector<T>> split (const vector<T>& S, T delim) { vector<vector<T>> ret{}; vector<T> buff{}; for (auto c : S) { if (c == delim) { if (!buff.empty()) ret.push_back(buff); buff.clear(); } else { buff.push_back(c); } } if (!buff.empty()) ret.push_back(buff); return ret; }
template<class T> inline void printYesNo(const T& t) { cout << (t ? "Yes" : "No") << CRLF; }
template<class T = int64_t> T modpow(T N, T P, T M) { T ret{1}; N %= M; while (P) { if (P & 0x01) { ret *= N; ret %= M; } P >>= 1; N *= N; N %= M; } return ret; }

/** code for assert debug begin */
int gErr = 0;
#define ASSERT(p) if(!(p)){ gErr = 1; }else{ ; }
/** code for assert debug end */

struct Tmp
{
public:
  int N;
  Tmp(int N)
  : N(N)
  {}
};

void solve(void)
{
  string A, B, C; cin >> A >> B >> C;
  
  auto ans = "A" + B.substr(0, 1) + "C";
  cout << ans << CRLF;
  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T,c=0;
    string s;
    cin>>s;
    for (size_t i = 0; i < 3; i++) {
      if(s[i]=='a')
        c+=1;
      else if(s[i]=='b')
        c+=2;
      else if(s[i]=='c')
        c+=4;
    }

    if(c==7)
      std::cout << "Yes" << '\n';
    else
      std::cout << "No" << '\n';


    return 0;
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

void solve()
{
    int a, b;
  cin >> a >> b;
  cout << ((b % a) ? b - a : a + b);
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<(n);i++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
const int mod =1000000007;
const double PI = acos(-1);

int main(){
	 ll n, m;
  bool prime = true;
  cin >> n;
 
  if ( n== 1 ){
    cout << 0 << endl;
    return 0;
  }
 
  ll ans = 0;
  for (ll i=2; i*i <= n; i++){
    if (n % i != 0) continue;
 
    prime = false;
    ll expo = 0;
    while (n % i == 0){
      n /= i;
      expo ++;
    }
    ll j = 1;
    while ( expo >= j*(j+1)/2 ) j++;
    ans += j-1;
  }
  if (n!=1) ans += 1;
  if (prime) ans = 1;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MAX 2000000
#define MOD 1000000007



int main(){
  int N,M;
  cin>>N>>M;
  vector<int> A(M);
  for(int i=0;i<M;i++){
    cin>>A.at(i);
  }
  sort(A.begin(),A.end());
  reverse(A.begin(),A.end());
  int match[9]={2,5,5,4,5,6,3,7,6};
  vector<int> dp(N+1,-10000000);
  dp.at(0)=0;
  for(int i=1;i<=N;i++){
    for(int j=0;j<M;j++){
      if(i-match[A.at(j)-1]<0){
        continue;
      }
      dp.at(i)=max(dp.at(i),dp.at(i-match[A.at(j)-1])+1);
    }
  }
  int i=N;
  while(i>0){
    for(int j=0;j<M;j++){
      if(i-match[A.at(j)-1]<0){
        continue;
      }
      if(dp.at(i-match[A.at(j)-1])==dp.at(i)-1){
        cout<<A.at(j);
        i=i-match[A.at(j)-1];
        break;
      }
    }
  }
  cout<<endl;
}


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

struct card {
    char suit;
    int value;
};

void bubbleSort(card A[], const int N)
{
    int flag = 1;

    for( int i = 0; flag; ++i ){
        flag = 0;

        for( int j = N-1; i < j; --j )
            if( A[j].value < A[j-1].value ){
                swap(A[j], A[j-1]);
                flag = 1;
            }
    }
}

void selectionSort(card A[], const int N)
{
    for( int i = 0; i < N; ++i ){
        int min = i;
      
        //iより後でA[i]より最も小さい値の添字を求める
        for( int j = i; j < N; ++j )
            if( A[j].value < A[min].value )
                min = j;
       
        //iとminが異なれば交換
        if( i != min ) swap(A[i], A[min]);
    }
}

int main()
{
    //入力
    int N;
    scanf("%d%*c", &N);
    card A[N], B[N]; //A:bubbleSort, B:selectionSort
    for( int i = 0; i < N; ++i ){
        scanf("%c%d%*c", &A[i].suit, &A[i].value);
        B[i] = A[i];
    }


    bubbleSort(A, N);
    selectionSort(B, N);


    //バブルソートの結果を出力
    for( int i = 0; i < N; ++i ){
        if( 0 < i ) printf(" ");
        printf("%c%d", A[i].suit, A[i].value);
    }
    printf("\n");
    printf("Stable\n");

    //選択ソートの結果を出力
    int flag = 1;
    for( int i = 0; i < N; ++i ){
        if( 0 < i ) printf(" ");
        printf("%c%d", B[i].suit, B[i].value);
        if( !(B[i].suit == A[i].suit && B[i].value == A[i].value) ) flag = 0;
    }
    printf("\n");
    if( flag ) printf("Stable\n");
    else printf("Not stable\n");

    return 0;
}


Measured memory_bytes: 3212
#include<bits/stdc++.h>
#define ll long long
#define rgi register int
#define rgl register ll
#define int ll
#define maxn 1000005
#define mod 10007LL
#define inf 1000000007LL
namespace lib
{
	using namespace std;
	class fastio
	{
		private:
			#define _NUMLEN 111
			char _num[_NUMLEN],_ch;
			int _f,_head;
			bool _useSTD;
		public:
			inline void ioSTD()
			{
				_useSTD=1;
				ios::sync_with_stdio(false);
				cin.tie(0),cout.tie(0);
			}
			inline void gc(char & _c)
			{
				if(_useSTD)cin>>_c;
				else _c=getchar();
			}
			inline void pc(char _c)
			{
				if(_useSTD)cout<<_c;
				else putchar(_c);
			}
			template<typename _T> inline fastio & operator - (_T & _x)
			{
				if(_useSTD)cin>>_x;
				else
				{
					_x=0;
					while(!isdigit(_ch)) _f|=_ch=='-',gc(_ch);
					while(isdigit(_ch)) _x=(_x<<1)+(_x<<3)+(_ch^48),gc(_ch);
					_f&&(_x=-_x,_f=0);
				}
				return *this; 
			}
			template<typename _T> inline fastio & operator + (_T _x)
			{
				if(_useSTD)cin>>_x;
				else
				{
					_T _k;
					if(_x==0) {pc('0'),pc(' ');return *this;}
					if(_x<0) pc('-'),_x=-_x;
					while(_x>0) _k=_x/10,++_head,_num[_head]=(_x-(_k<<1)-(_k<<3))^48,_x=_k;
					while(_head>0) pc(_num[_head]),--_head;
					pc(' ');
				}
				return *this; 
			}
			template<typename _T> inline fastio & operator >> (_T & _x) {cin>>_x;return *this;}
			template<typename _T> inline fastio & operator << (_T _x) {cout<<_x;return *this;}
			#define endln pc('\n')
		fastio() {_f=0,_head=0,_useSTD=0,_ch=' ';}
	}io;
	inline void fileio(string _r,string _w)
	{
		if(_r[0]!='-')freopen(_r.c_str(),"r",stdin);
		if(_w[0]!='-')freopen(_w.c_str(),"w",stdout);
	}
	#define mem(_x,_set) memset(_x,_set,sizeof(_x))
}using namespace lib;

signed main()
{
//	fileio("tt.in","tt.out");
//	io.ioSTD();
	ll n,a,b;
	io-n-a-b;
	if((b-a)%2==0)
		io+(b-a)/2;
	else
		io+min((a+b-1)/2,(n-a+n-b+1)/2);
	return 0;
}


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


int main()
{
    int a,b,c;
int t;
    cin>>a>>b>>c;
    if(a>b) {t=a;a=b;b=t;}
    if(b>c) {t=b;b=c;c=t;}
    if(a>b) {t=a;a=b;b=t;}

    cout<<a<<" "<<b<<" "<<c<<endl;
    return 0;
}

Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;

int main(){

  int A, B, Q; cin >> A >> B >> Q;
  vector<long long> s(A+2);
  vector<long long> t(B+2);
  for(int i=1; i<=A; i++) cin >> s.at(i);
  for(int i=1; i<=B; i++) cin >> t.at(i);

  s.at(0) = -INF; t.at(0) = -INF; s.at(A+1) = INF; t.at(B+1) = INF;
  
  for(int i=0; i<Q; i++){
    long long x; cin >> x;
    
    auto it_s = lower_bound(s.begin(), s.end(), x);
    auto it_t = lower_bound(t.begin(), t.end(), x);
    
    long long result = 1e18;
    for(int j=0; j<2; j++){
      for(int k=0; k<2; k++){
       result = min({result,
                      abs( x-*(it_s-j) ) + abs( *(it_s-j) - *(it_t-k) ),
                      abs( x-*(it_t-j) ) + abs( *(it_t-j) - *(it_s-k) )
                     });
      }
    }
    cout << result << endl;
  }
}

Measured memory_bytes: 2944
import math
import fractions

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

def ValueToBits(x,digit):
    res = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        res[i]=now%2
        now = now >> 1
    return res

def BitsToValue(arr):
    n = len(arr)
    ans = 0
    for i in range(n):
        ans+= arr[i] * 2**i
    return ans

def ValueToArray10(x, digit):
    ans = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        ans[digit-i-1] = now%10
        now = now //10
    return ans

#a = list(map(int, input().split()))

n = int(input())
k = int(input())

arr = ValueToArray10(n,100)
nonzero = [0 for i in range(101)]


for i in range(100):
    if(arr[i]!=0):
        nonzero[i+1] = nonzero[i]+1
    else:
        nonzero[i+1] = nonzero[i]
        
#print(arr,nonzero)

ans = 0

def c2(n):
    if(n<=1):
        return 0
    else:
        return n*(n-1)//2

def c3(n):
    if(n<=2):
        return 0
    else:
        return n*(n-1)*(n-2)//6

if(nonzero[100]==k):
    ans += 1

for ii in range(100):

    i = 99 - ii
    #print(ii,ans,arr[i])
    if(nonzero[i]>=k+1):
        continue
    else:
        if(arr[i]==0):
            continue
        else:
            rem = ii
            if(nonzero[i]==k):
                ans += 1
            elif(nonzero[i] == k-1):
                ans +=  rem * 9 + (arr[i]-1)
            elif(nonzero[i] == k-2):
                ans +=  c2(rem) * 81 + (arr[i]-1) * rem * 9
            elif(nonzero[i] == k-3):
                ans += c3(rem) * 729 + (arr[i]-1) * c2(rem) * 81
            

print(ans)





























Measured memory_bytes: 64620
#include <iostream>

using namespace std;
long a[(int)(2e+5)+1];
long MIN[(int)(2e+5) + 1];
long MAX[(int)(2e+5) + 1];

long max(long a, long b){
	return a > b ? a : b;
}
int main(){
	int n; cin >> n;
	for (int i = 0; i < n; ++i) cin >> a[i];
	long tmp = a[0]; MIN[0] = a[0];
	for (int i = 1; i <= n-2; ++i){
		if (a[i] < tmp) tmp = a[i];
		MIN[i] = tmp;
	}
	tmp = MAX[n - 1] = a[n - 1];
	for (int i = n - 2; i >= 0; --i){
		MAX[i] = tmp;
		if (a[i] > tmp) tmp = a[i];
	}
	tmp = MAX[0] - MIN[0];
	for (int i = 1; i <= n-2; ++i){
		tmp = max(tmp, MAX[i] - MIN[i]);
	}
	cout << tmp << '\n';
}

Measured memory_bytes: 5848