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

#define rep(i,x,y) for(ll i=(x);i<(y);i++)
#define rrep(i,x,y) for(ll i=(ll)(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
#ifdef LOCAL
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define itrdebug(x) cerr << #x << " "; for (auto & el : (x)) {cerr << (el) << " ";} cerr << endl
#define dassert(...) assert(__VA_ARGS__)
#else
#define debug(x)
#define itrdebug(x)
#define dassert(...)
#endif
//#define int long long

typedef long long ll;
const ll MOD = 1e9 + 7;
const long double EPS = 1e-8;

long long getGcd(long long a, long long b) {
    if (a < b) swap(a, b);
    long long r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

class Sieve {
    long long n_;
    vector<long long> sieve_, primes_;

public:
    explicit Sieve(long long n=1): n_(n), sieve_(n + 1) {
        sieve_[0] = sieve_[1] = -1;
        for (long long i = 2; i <= n; ++i) {
            if (sieve_[i]) continue;
            primes_.push_back(i);
            sieve_[i] = i;
            for (long long j = i*i; j <= n; j += i) {
                if (!sieve_[j]) sieve_[j] = i;
            }
        }
    }
    bool isPrime(long long x) {
        assert (n_ * n_ >= x);
        if (n_ >= x) {
            return sieve_[x] == x;
        } else {
            for (const auto prime : primes_) {
                if (x % prime == 0) return false;
            }
            return true;
        }
    }
    vector<long long> getPrimes() {
        return primes_;
    }
    vector<pair<long long, int>> getPrimeFactorList(long long x) {
        assert (n_ * n_ >= x);
        vector<long long> factorList;
        for (int i=(int)primes_.size()-1; i>=0; i--) {
            if (x <= n_) break;
            while (x % primes_[i] == 0) {
                x /= primes_[i];
                factorList.emplace_back(primes_[i]);
            }
        }
        if (isPrime(x)) {
            factorList.emplace_back(x);
            x /= x;
        }
        assert (n_ >= x);
        while (x != 1) {
            factorList.push_back(sieve_[x]);
            x /= sieve_[x];
        }
        if (factorList.empty()) return {};
        vector<pair<long long, int>> res(1, pair<long long, int>(factorList[0], 0));
        for (long long p : factorList) {
            if (res.back().first == p) {
                res.back().second++;
            } else {
                res.emplace_back(p, 1);
            }
        }
        return res;
    }
};


void solve(long long A, long long B){
    Sieve sieve(1e6+1);
    cout << sieve.getPrimeFactorList(getGcd(A, B)).size() + 1 << endl;
}

signed main(){
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


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

using T = tuple<int, int, int>;

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

  set<T> left, right;
  vector<int> ans(N*N + 1);
  for(auto i=1; i<=N; ++i) {
    int x;
    cin >> x;
    ans[x] = i;
    left.emplace(x-1, i-1, i);
    right.emplace(x+1, (N-1)-(i-1), i);
  }

  auto ng = []() {
    cout << "No" << endl;
    exit(0);
  };

  for(auto i=1; i<=N*N; ++i) if(!ans[i]) {
    while(!left.empty()) {
      int x, n, a;
      tie(x, n, a) = *begin(left);
      left.erase(begin(left));
      if(n == 0) continue;
      if(x < i) ng();
      ans[i] = a;
      left.emplace(x, n-1, a);
      break;
    }
    while(!right.empty()) {
      if(ans[i]) break;
      int x, n, a;
      tie(x, n, a) = *begin(right);
      right.erase(begin(right));
      if(n == 0) continue;
      if(i < x) ng();
      ans[i] = a;
      right.emplace(x, n-1, a);
      break;
    }
    if(!ans[i]) ng();
  }

  cout << "Yes" << endl;
  for(auto i=1; i<=N*N; ++i) cout << (i!=1 ? " " : "") << ans[i];
  cout << endl;
}


Measured memory_bytes: 2176
#define _DEBUG 1
#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>
using namespace std;

using ll = long long;

#ifdef _DEBUG
#define dump(x) cerr << #x << "=" << x << endl
#define dump2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define dump3(x, y, z)                                                         \
  cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z     \
       << endl
#define check(s) cerr << s << endl
#else
#define dump(x)
#define dump2(x, y)
#define dump3(x, y, z)
#define check(s)
#endif

#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());

void solve(ll X) {
  ll a = X / 500;
  ll b = (X % 500) / 5;
  cout << a * 1000 + b * 5 << endl;
}

int main() {
  ll X;
  scanf("%lld", &X);
  solve(X);
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int n,sum,i;
main(){
	cin>>n;
	sum=n;
	for(i=2;i*i<=n;i++){
		if(n%i==0){
			sum=sum/i*(i-1);
			while(n%i==0){n/=i;}
		}
	}
	if (n!=1) {sum=sum/n*(n-1);}
	cout<<sum<<endl;
}

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

int main() {
    int N; cin >> N;
    vector<int> A(N);
    rep(i, N){
        cin >> A[i];
    }
    int S = A[0];
    for (int i = 1; i < N; i++){
        S = S^A[i];
    }

    rep(i, N){
        int ans = S^A[i];
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 4000
package main
 
import(
  "fmt"
	"bufio"
	"os"
	"strings"
	"sort"
	"strconv"
	"log"
)
 
var sc = bufio.NewScanner(os.Stdin)
 
func Rr() []string {
  sc.Scan()
  slice := strings.Split(sc.Text(), " ")
  return slice
}
 
 
func main(){
	N := 0
	fmt.Scan(&N)
	scanner := word_spliter()
	strong_list := make([]int, 3*N, 3*N)
	for i := 0; i < len(strong_list); i++{
		strong_list[i] = eGetInt(scanner)
	}
	ans := 0
	sort.Ints(strong_list)
	for i := N; i < len(strong_list); i+=2 {
		ans += strong_list[i]
	}
	fmt.Println(ans)
}


//入力関係ライブラリ(yamanobori_oldさんのもの)
func make_liner(maxByte int) *bufio.Scanner {
	liner := bufio.NewScanner(os.Stdin)
	liner.Buffer(make([]uint8, 0, 8192), maxByte)
	return liner
}
func word_spliter() *bufio.Scanner {
	words := make_liner(8192) 
	words.Split(bufio.ScanWords)
	return words
}

func eGetLine(r *bufio.Scanner) string {
	if r.Scan() {
		return r.Text()
	}
	err := r.Err()
	if err != nil {
		log.Fatal(err)
	}
	// EOF
	return ""
}

func eGetInt(r *bufio.Scanner) int {
	line := eGetLine(r)
	return eAtoi(line)
}

func eAtoi(s string) int {
	n, err := strconv.Atoi(s)
	if err != nil {
		log.Fatal(err)
	}
	return n
}

Measured memory_bytes: 5376
import java.util.*;
import java.util.Collections;
import java.util.stream.Collectors;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    String A = sc.next();
    String ans = "No";
    for (int i = 0; i < S.length(); i++) {
      if (S.equals(A)) {
        ans = "Yes";
        break;
      } else {
        S = S.substring(1, A.length()) + S.substring(0, 1);
      }
    }
    System.out.println(ans);

  }
}


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

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    sort(a, a + n);
    int m = a[n - 1];
    int b[m + 1];
    
    for (int i = 0; i < m + 1; i++)
    {
        b[i] = 0;
    }
    for (int i = 0; i < n; i++)
    {
        if (b[a[i]] == 0)
        {
            b[a[i]] = -1;
            for (int j = 2*a[i]; j <= a[n - 1]; j += a[i])
            {
                b[j] = 1;
            }
        }
        else
        {
            b[a[i]] = 1;
        }
    }
    int c = 0;
    for (int i = 0; i < m+1; i++)
    {
        if (b[i] == -1)
        {
            c++;
        }
    }
    cout << c;
    return 0;
}


Measured memory_bytes: 8236
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#define INF 1000000000
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;

#define MAN 200000

int main(){
  int x;
  cin >> x;
  if(x==3 || x==5 || x==7){
    cout << "YES";
  }else{
    cout << "NO";
  }
}


Measured memory_bytes: 256
//SD
#include<iostream>
#include<iomanip>
#include<cmath>
using namespace std;

int main()
{
	int n, S[1000], sum;
	double hei, hsum;
	while(1){
		sum = 0;
		hsum = 0;
		cin >> n;
		if( n == 0)
			break;
		for(int i = 0; i < n; i++){
			cin >> S[i];
			sum += S[i];
		}
		hei = (double)sum / n;
		for(int i = 0; i < n; i++){
			hsum += pow(hei - S[i], 2);
			S[i] = 0;
		}
		cout << fixed << setprecision(6) << sqrt(hsum/n) << endl;
	}
	return 0;
}


Measured memory_bytes: 3228
#include <string>
#include <iostream>
using namespace std;
int main() {
	int H, W, N, sx, sy;
	cin >> H >> W >> N >> sx >> sy; --sx, --sy;
	string S, T;
	cin >> S >> T;
	int lx = sx, ly = sy, rx = sx, ry = sy;
	bool win = false;
	for (int i = 0; i < N; ++i) {
		if (S[i] == 'U') --lx;
		if (S[i] == 'D') ++rx;
		if (S[i] == 'L') --ly;
		if (S[i] == 'R') ++ry;
		if (lx < 0 || rx >= H || ly < 0 || ry >= W) {
			win = true;
			break;
		}
		if (T[i] == 'U' && rx >= 1) --rx;
		if (T[i] == 'D' && lx <= H - 2) ++lx;
		if (T[i] == 'L' && ry >= 1) --ry;
		if (T[i] == 'R' && ly <= W - 2) ++ly;
	}
	cout << (!win ? "YES" : "NO") << endl;
	return 0;
}

Measured memory_bytes: 776
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
using namespace std;
typedef long long ll;
const ll MOD = 998244353;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
typedef unsigned int ui;
#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 long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
//'+','_','*'
int a[3];
bool mark(char t) {
	if (t == '+' || t == '_' || t == '*')return true;
	else return false;
}
string trans(string x) {
	int l = x.length();
	rep(j, 3) {
		rep(i, l) {
			if (x[i] == '+'&&a[0] == j) {
				int le = i-1; int ri = i+1;
				while (le >= 0 && (!mark(x[le])))le--; le++;
				while (ri < l && (!mark(x[ri])))ri++; ri--;
				int d = ri - le + 1;
				string u1 = x.substr(le, i - le);
				string u2 = x.substr(i + 1, ri - i);
				string u = to_string(stoll(u1) + stoll(u2));
				int d2 = u.length();
				x.erase(x.begin() + le, x.begin() + ri + 1);
				x.insert(le, u);
				i = le - 1; l = l - d + d2;
			}
			else if (x[i] == '_'&&a[1] == j) {
				int le = i-1; int ri = i+1;
				while (le >= 0 && (!mark(x[le])))le--; le++;
				while (ri < l && (!mark(x[ri])))ri++; ri--;
				int d = ri - le + 1;
				string u1 = x.substr(le, i - le);
				string u2 = x.substr(i + 1, ri - i);
				string u = to_string(stoll(u1) - stoll(u2));
				int d2 = u.length();
				x.erase(x.begin() + le, x.begin() + ri + 1);
				x.insert(le, u);
				i = le - 1; l = l - d + d2;

			}
			else if (x[i] == '*'&&a[2] == j) {
				int le = i-1; int ri = i+1;
				while (le >= 0 && (!mark(x[le])))le--; le++;
				while (ri < l && (!mark(x[ri])))ri++; ri--;
				int d = ri - le + 1;
				string u1 = x.substr(le, i - le);
				string u2 = x.substr(i + 1, ri - i);
				string u = to_string(stoll(u1) * stoll(u2));
				int d2 = u.length();
				x.erase(x.begin() + le, x.begin() + ri + 1);
				x.insert(le, u);
				i = le - 1; l = l - d + d2;
			}
		}
	}
	return x;
}
ll ord(string x) {
	int l = x.length();
	rep(i, l) {
		if (x[i] == ')') {
			int le = i-1;
			while (x[le] != '(')le--;
			string u = x.substr(le + 1, i - le - 1);
			int d = i - le + 1;
			string nu = trans(u);
			int d2 = nu.length();
			x.erase(x.begin() + le, x.begin() + i + 1);
			x.insert(le, nu);
			i = le - 1;
			l = l - d + d2;
		}
	}
	ll res = stoll(trans(x));
	return res;
}
int main() {
	string s; cin >> s;
	int len = s.length();
	rep(i, len) {
		if (s[i] == '-')s[i] = '_';
	}
	ll ma;
	rep(x, 3) {
		rep(y, 3) {
			rep(z, 3) {
				a[0] = x; a[1] = y; a[2] = z;
				if (x == 0 &&y == 0 && z == 0) {
					ma = ord(s);
				}
				ma = max(ma, ord(s));
			}
		}
	}
	cout << ma << endl;
	return 0;
}


Measured memory_bytes: 3220
import Control.Applicative
import Data.List
import Data.Array

main = do
    n <- read <$> getLine
    a <- map read . words <$> getLine
    mapM_ print (solve n a)

solve :: Int -> [Int] -> [Int]
solve n a = map (calc arA arC s) [1..n]
    where s = sum cost
          arA = array (0,n+1) (zip [0..n+1] (0:(a ++ [0])))
          arC = array (0,n+1) (zip [0..n+1] cost)
          cost = 0:(zipWith (\x y -> abs (x-y)) a' (tail a'))
          a' = (0:a) ++ [0]

calc :: Array Int Int -> Array Int Int -> Int -> Int -> Int
calc arA arC s index = s - (arC ! index) - (arC ! (index+1)) + abs ((arA ! (index+1))- (arA ! (index-1)))


Measured memory_bytes: 36092
#include <bits/stdc++.h>
typedef long long ll;
const int INF=1e9,MOD=1e9+7,ohara=1e6;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(ll (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(ll i=(a);i<(b);i++)
#define rrrep(i,a,b) for(ll i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

ll n,cnt=0,ans=0,a,b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(0);
      
    cin>>n>>x;
    Cout(3*(n-__gcd(n,x)));
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
#define ALL(x) begin(x), end(x)
#define dump(x) cerr << #x " = " << x << endl
using ll = long long;
using namespace std;
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
template <class T, class U> inline void chmax(T & a, U const & b) { a = max<T>(a, b); }
template <class T, class U> inline void chmin(T & a, U const & b) { a = min<T>(a, b); }
template <typename X, typename T> auto make_vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto make_vectors(X x, Y y, Z z, Zs... zs) { auto cont = make_vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }
template <typename T> ostream & operator << (ostream & out, vector<T> const & xs) { REP (i, (int)xs.size() - 1) out << xs[i] << ' '; if (not xs.empty()) out << xs.back(); return out; }

ll get_score(int n, const vector<vector<int> > & g, const vector<ll> & c) {
    ll score = 0;
    REP (i, n) {
        for (int j : g[i]) if (i < j) {
            score += min(c[i], c[j]);
        }
    }
    return score;
}

pair<ll, vector<ll> > solve(int n, const vector<vector<int> > & g, vector<ll> c) {
    sort(ALL(c));
    reverse(ALL(c));
    auto it = c.begin();
    vector<ll> d(n, -1);

    function<void (int, int)> go = [&](int i, int parent) {
        d[i] = *(it ++);
        for (int j : g[i]) if (j != parent) {
            go(j, i);
        }
    };

    go(0, -1);
    return make_pair(get_score(n, g, d), d);
}

int main() {
    int n; cin >> n;
    vector<vector<int> > g(n);
    REP (i, n - 1) {
        int a, b; cin >> a >> b;
        -- a; -- b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    vector<ll> c(n);
    REP (i, n) {
        cin >> c[i];
    }
    auto ans = solve(n, g, c);
    cout << ans.first << endl;
    cout << ans.second << endl;
    return 0;
}


Measured memory_bytes: 1792
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
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; }

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class ELexicographicalDisorder {
public:

    vector<vector<P>> graph;
    vector<vector<vector<int>>> dp;
    vector<int> bonus;

    void dfs(string& s, int node, int pos) {
      if (pos >= s.size()) {
        graph[node][26].second++;
        return;
      }
      int p = s[pos]-'a';
      if (graph[node][p].first == 0) {
        graph.push_back(vector<P>(27));
        graph[node][p].first = graph.size()-1;
      }
      graph[node][p].second++;
      dfs(s, graph[node][p].first, pos+1);
    }

    void dfs2(int k, string& s, int node, int pos) {
      if (pos >= s.size()) return;
      int p = s[pos] - 'a';
      rep(i, 26) {
        if (i==p) continue;
        dp[k][i][p] += graph[node][i].second;
      }
      bonus[k] += graph[node][26].second;
      dfs2(k, s, graph[node][p].first, pos+1);
    }

    void solve(istream& cin, ostream& cout) {
      SPEED;
      graph.push_back(vector<P>(27));
      int n; cin >> n;
      dp.resize(n, vector<vector<int>>(26, vector<int>(26, 0)));
      bonus.resize(n);
      vector<string> s(n);
      rep(i, n) {
        cin >> s[i];
        dfs(s[i], 0, 0);
      }

      rep(i, n) {
        dfs2(i, s[i], 0, 0);
      }

      int q; cin >> q;
      while(q--) {
        int k; cin >> k; k--;
        string p; cin >> p;
        int ret = bonus[k]+1;
        for(int i=0; i<26; i++) {
          int u = p[i]-'a';
          for(int j=i+1; j<26; j++) {
            int v = p[j]-'a';
            ret += dp[k][u][v];
          }
        }
        cout << ret << '\n';

      }

    }
};

signed main() {
  ELexicographicalDisorder solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

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

#[allow(dead_code)]
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 n = read::<usize>();
    let mut aseq = vec![0; n];
    for i in 0..n {
        aseq[i] = read::<i32>();
    }
    aseq.sort();
    println!("{}", aseq[n - 1] - aseq[0]);
}


Measured memory_bytes: 4352
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int N;
    cin >> N;
    vector<pair<int, int>> A(N), B(N);
    rep(i, N){
        cin >> A[i].first >> A[i].second;
    }
    rep(i, N) {
        cin >> B[i].second >> B[i].first;
    }
    sort(all(A));
    sort(all(B));
    reverse(all(A));
    int ret = 0;
    vector<int> used(N, 0);
    rep(i, N) {
        rep(j, N){
            if(!used[j] && A[i].first < B[j].second && A[i].second < B[j].first){
                used[j] = 1;
                ret++;
                break;
            }
        }
    }
    output(ret);
    
    
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int N,i,j,a,minj,A[100],c=0;

  scanf("%d",&N);

  for(i=0; i < N; i++){
    scanf("%d",&A[i]);
  }

  for(i=0; i < N; i++){  
    minj = i;  
    for(j=i; j < N; j++){    
      if(A[j] < A[minj]){
	minj = j;
      }  
    }
    if(minj != i){
      c++;
    }
    a = A[i];
    A[i] = A[minj];
    A[minj] = a;
  }
  
  for(i=0; i < N; i++){
    printf("%d",A[i]);
    if(i != N-1){
      printf(" ");
    }
  }
  printf("\n");
  printf("%d\n",c);
  
  return 0;
}



Measured memory_bytes: 2140
const int N = 400005;
const int LG = 21;
const long long MOD = 1e9 + 7;
const long long INF = 1e9;
const long long INFLL = 1e18;

#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <time.h>
#include <unordered_set>
#include <bitset>
#include <deque>

using namespace std;

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

#define forn(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define fi first
#define se second
#define re return
#define uniq(x) sort(all(x)); (x).resize(unique(all(x)) - (x).begin())

#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " " << #x << " " << x << endl
#define ln cerr << __LINE__ << endl
#else
#define dbg(x) void(0)
#define ln void(0)
#endif // LOCAL

int cx[4] = {-1, 0, 1, 0};
int cy[4] = {0, -1, 0, 1};

ll inq(ll x, ll y)
{
    if (!y) re 1 % MOD;
    ll l = inq(x, y / 2);
    if (y % 2) re l * l % MOD * x % MOD;
    re l * l % MOD;
}

ll rev(ll x)
{
    return inq(x, MOD - 2);
}

bool __precomputed_combinatorics = 0;
vector<ll> __fact, __ufact, __rev;

void __precompute_combinatorics()
{
    __precomputed_combinatorics = 1;
    __fact.resize(N);
    __ufact.resize(N);
    __rev.resize(N);
    __rev[1] = 1;
    for (int i = 2; i < N; i++) __rev[i] = MOD - __rev[MOD % i] * (MOD / i) % MOD;
    __fact[0] = 1, __ufact[0] = 1;
    for (int i = 1; i < N; i++) __fact[i] = __fact[i - 1] * i % MOD, __ufact[i] = __ufact[i - 1] * __rev[i] % MOD;
}

ll fact(int x)
{
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[x];
}

ll cnk(int n, int k)
{
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[n] * __ufact[n - k] % MOD * __ufact[k] % MOD;
}

ll a, b, n;
ll ans = 0;

signed main()
{
    srand(time(NULL));
    #ifdef ONLINE_JUDGE
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
    #endif // ONLINE_JUDGE
    cin >> a >> b >> n;
    n = min(n, b - 1);
    for (long long r = n; r <= n; r++) ans = max(ans, a * r / b);
    cout << ans;
}

/* Note:
Check constants at the beginning of the code.
N is set to 4e5 but be careful in problems with large constant factor.
Check corner cases.
No def int long long for now.
*/


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

int main()
{
  string sss;
  int tem0 = 0;
  int tem1 = 0;
  cin >> sss;
  int ans;
  for(int i = 0; i < sss.size(); i++) {
    if(sss.at(i) == '0') {
      tem0++;
    }
    else {
      tem1++;
    }
  }
  if(tem0 * tem1 == 0) {
    ans = 0;
  }
  else {
    ans = min(tem0, tem1);
  }
  
  cout << ans * 2 << endl;
  
  return 0;
}

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

const long long INF = 1000000007ll*1000000007ll;

long long n , m;
long long ans[200005];
long long l, r, d;
vector< pair< long long , long long > > g[200005];
bool used[200005];

void dfs(int x)
{
	used[x] = true;
	for (int i = 0; i < g[x].size(); i++)
	{
		int to = g[x][i].first, len = g[x][i].second;
		if (ans[to] == INF) ans[to] = ans[x] + len;
		if (ans[to] != ans[x] + len)
		{
			printf("No\n");
			exit(0);
		}
		if (!used[to]) dfs(to);
	}
} 

int main()
{
	fill(ans, ans+200005, INF);
	scanf("%lld%lld",&n,&m);
	for (int i = 0; i < m; i++)
	{
		scanf("%lld%lld%lld", &l, &r, &d);
		g[l].push_back({r, d});
		g[r].push_back({l, -d});
	}
	for (int i = 1; i <= n; i++)
	{
		if (!used[i])
		{
			ans[i] = 0;
			dfs(i);
		}
	}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 19712
#include <cstdio>  
using namespace std;  
int main() { 	
	int a,b,c,d,e; 	
	scanf("%d %d", &a, &b);
	if((a+b)%2==0){
		printf("%d", (a+b)/2);
	}
	else{
		printf("%d", 1+(a+b)/2);
	}
	
} 


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define abs(x) ((x>0)?x:(-(x))) 
int H,W,D,A; int Q,L,R; int px[90001],py[90001]; int d[90001]; int main() { scanf("%d%d%d",&H,&W,&D); for(int i=0;i<H;i++) { for(int j=0;j<W;j++) { scanf("%d",&A); px[A]=i,py[A]=j; } } for(int i=D+1;i<=H*W;i++) d[i]=d[i-D]+abs(px[i]-px[i-D])+abs(py[i]-py[i-D]); scanf("%d",&Q); while(Q--) { scanf("%d%d",&L,&R); printf("%d\n",d[R]-d[L]); } }

Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
typedef long long int lli;
typedef long long ll; 
typedef pair<ll, ll> pll; 
typedef pair<string, string> pss;   
typedef vector<pll> vop; 
typedef vector<ll> vl; 
typedef vector<vl> vvl;
#define REP(i,a,b) for(long long int i=a;i<b;i++)
#define REPR(i,a,b) for(long long int i=a;i>=b;i--)
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define endl "\n"
#define mem(a,b) memset(a,b,sizeof(a))
#define mod 1000000007


int main()
{
	fastIO;
	ll t,b=0;
	//cin>>t;
	t=1;
	while(t--)
	{
		string s;
 		cin>>s;
  		int flag=0;
  		for(int i=0;i<s.size();i++)
  		{
    		if(s[i]=='7')
    		{
    		  flag=1;
    		  break;
    		}
  		}
  		if(flag)
    		cout<<"Yes"<<endl;
  		else
    		cout<<"No"<<endl;

	}
	return 0;
}



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

int main() {
	int N;
	std::cin >> N;

	std::vector<int> x(N), y(N), h(N);
	for(int i = 0; i < N; i++) {
		int xx, yy, hh;
		std::cin >> xx >> yy >> hh;
		x[i] = xx;
		y[i] = yy;
		h[i] = hh;
	}

	for(int cx = 0; cx <= 100; cx++) {
		for(int cy = 0; cy <= 100; cy++) {
			int ch = 0;
			for(int i = 0; i < N; i++) {
				if(h[i] > 0) {
					ch = h[i] + std::abs(cx - x[i]) + std::abs(cy - y[i]);
				}
			}
			if(ch <= 0) {
				continue;
			}

			bool ok = true;
			for(int i = 0; i < N; i++) {
				int hh = ch - (std::abs(cx - x[i]) + std::abs(cy - y[i]));
				if(hh <= 0 && h[i] == 0 || hh == h[i]) {
				} else {
					ok = false;
					break;
				}
			}
			if(ok) {
				std::cout << cx << " " << cy << " " << ch << std::endl;
				return 0;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 256
import sys

# sys.stdin = open('a1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()


def main():
    n = read_int()
    l = [9, 19, 29, 39, 49, 59, 69, 79, 89, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90]
    if n in l:
        print('Yes')
    else:
        print('No')


main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
//    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);


long long int arr[87];
long long int fib(long long int n){
	if(arr[n]>0)return arr[n];
	if(n<0)return 0;
	if(n==0){arr[0]=2;return 2;}
	if(n==1){arr[1]=1;return 1;}
	arr[n]=fib(n-1)+fib(n-2);
	return arr[n];
}
int main(){ 
	cin.sync_with_stdio(0); cout.tie(0);
	long long int n;
	cin>>n;
	for (long long int i = 0; i < 86; i++)
	{
		arr[i]=-1;
	}
	fib(n);
	cout<<arr[n]<<endl;




} 

Measured memory_bytes: 256
#include <stdio.h>
int x[10000];
int y[10000];
int temp[10000];
int i,j;
int main(void) {
  for(i=0;i<10000;i++) {
    scanf("%d %d",&x[i],&y[i]);
    if(x[i]==0 && y[i]==0) break;
  }
  for(j=0;j<i;j++) {
    if(x[j] > y[j]){
      temp[j] = x[j];
      x[j] = y[j];
      y[j] = temp[j];
    }
    printf("%d %d\n",x[j],y[j]);
  }
return 0;
}

Measured memory_bytes: 632
ans = [0] * 3

loop do
  arr = gets.split.map(&:to_i).sort
  
  break if arr[0] + arr[1] <= arr[2]
  
  case arr[0] ** 2 + arr[1] ** 2
  when (0...arr[2] ** 2)
    ans[2] += 1
  when arr[2] ** 2
    ans[0] += 1
  else
    ans[1] += 1
  end
end

puts "%d %d %d %d" % ans.unshift(ans.inject(:+))

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

int cnt[26];
string v[200010];
int nxt[1000010][26];
bool ok[1000010];
int num;
ll ans = 0;
string s;

void buildtree(int node, int k) {
    if (k == s.size()) {
        ok[node] = 1;
        return;
    }
    if (nxt[node][s[k]-'a'] == 0) {
        nxt[node][s[k]-'a'] = ++num;
    }
    buildtree(nxt[node][s[k]-'a'], k+1);
}

void dfs(int node, int k) {
    // cout << s << " " << node << " " << k << endl;
    if (k == s.size() - 1) {
        cnt[s[k] - 'a']--;
        return;
    }

    for (int i = 0; i < 26; i++) {
        if (cnt[i] == 0) continue;
        if (ok[nxt[node][i]]) {
            ans++;
            // cout << s << " " << node << " " << k << endl;
        }
    }

    cnt[s[k] - 'a']--;
    dfs(nxt[node][s[k]-'a'], k+1);
}



int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        string ss;
        cin >> ss;
        reverse(ss.begin(), ss.end());
        v[i] = ss;
    }

    sort(v, v+n);

    for (int i = 0; i < n; i++) {
        s = v[i];
        buildtree(0,0);
    }

    for (int i = 0; i < n; i++) {
        s = v[i];
        for (int j = 0; j < s.size(); j++) {
            cnt[s[j]-'a']++;
        }
        dfs(0,0);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 113068
# -*- coding: utf-8 -*-
"""
https://beta.atcoder.jp/contests/abc081/tasks/arc086_b

"""
import sys
from sys import stdin
input = stdin.readline


def solve(A, N):
    steps = []

    min_A = min(A)
    min_pos = A.index(min_A) + 1
    max_A = max(A)
    max_pos = A.index(max_A) + 1

    if min_A >= 0:
        steps.append([max_pos, 1])
        for i in range(2, N+1):
            steps.append([i-1, i])
    else:
       if (abs(min_A) < abs(max_A)):
           for i in range(1, N+1):
               steps.append([max_pos, i])
           steps.append([max_pos, 1])
           for i in range(2, N+1):
               steps.append([i-1, i])
       else:
           for i in range(1, N+1):
               steps.append([min_pos, i])
           steps.append([min_pos, N])
           for i in range(N, 1, -1):
               steps.append([i, i-1])
    return steps


def main(args):
    N = int(input())
    A = [int(x) for x in input().split()]
    ans = solve(A, N)
    print(len(ans))
    for x, y in ans:
        print(x, y)
#        A[y-1] += A[x-1]
#    print(*A)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 3064
s = gets.chomp
t = gets.chomp

s_index = Hash.new{|h,k| h[k]=[]}
s.each_char.with_index do |sn,i|
	s_index[sn] << i
end

def error;puts "-1";exit;end

s_count = 0

(prev_index = s_index[t[0]][0]) || error
t[1..-1].each_char do |tc|
	prev_index = (index = s_index[tc].bsearch {|x| x > prev_index}) ? index : (s_index[tc][0] || error)
	s_count+=1 if !index
end

p (s.length * s_count + prev_index + 1)

Measured memory_bytes: 3324
#include <stdio.h>
int main(){
 
  int i=0,j=0,x=0;
  char ch,p[101]={},s[101]={};
 
  //input p
  while(1){
 
    scanf("%c",&ch);
 
    if(ch != '\n'){
 
      p[i]=ch;
 
      i++;
 
    } else {
 
      break;
 
    }
 
  }
 
  i=0;
 
  //input s
  while(1){
 
    scanf("%c",&ch);
     
    if(ch != '\n'){
 
      s[i]=ch;
 
      i++;
 
    } else {
 
      break;
 
    }
 
  }
 
  i=0;
   
  //search
  while(1){
 
    if(s[j] != '\0'){
       
      if(p[i] != '\0'){
     
    if(p[i] == s[j]){
       
      i++;
      j++;
       
    } else {
 
      if(i == 0 && j != 0){
 
        printf("No\n");
 
        break;
 
      } else {
 
      x++;
      i=x;
      j=0;
 
      }
       
    }   
     
      } else {
 
    if(j != 0){
 
      i=0;
 
    } else {
 
      printf("No\n");
 
      break;
 
    }
 
      }
       
    } else {
 
      printf("Yes\n");
 
      break;
 
    }
 
  }
 
  return 0;
   
}


Measured memory_bytes: 2148
def calc_point(t, a, h):
        min_diff = float('inf')
        min_diff_point = None
        for i, h_v in enumerate(h):
                diff = abs(a - (t - h_v * 0.006))
                if diff < min_diff:
                        min_diff = diff
                        min_diff_point = i
        return min_diff_point


input()
t, a = [int(v) for v in input().split()]
h = [int(v) for v in input().split()]
print(calc_point(t, a, h) + 1)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std ;
#define ll long long
void FastInputOutput(){
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}

inline int D(){
    int t ;
    scanf( "%d" , &t ) ;
    return t ;
}
inline ll LLD(){
    ll t ;
    scanf( "%lld" , &t ) ;
    return t ;
}

ll power(ll x, ll p, ll m){
    ll res = 1;
    while(p){
        if(p&1)    res = (res * x)%m;
        x = (x * x)%m;
        p >>= 1;
    }
    return res;
}


const int N = 1e5 + 5, MX = 1e9;
int a[N];
int main(){
    int E = D(), ans = 0;
    for(int n = 1; n <= E; n += 2){
        int cnt = 0;
        for(int i = 1; i <= n / i; ++i)
            if(n % i == 0){
                ++cnt;
                if(n / i != i)
                    ++cnt;
            }
        ans += cnt == 8;
    }
    printf("%d", ans);
    return 0;
}


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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;

int m[100][100];

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

    rep(i, n) rep(j, n) m[i][j] = 0;

    rep(i, n)
    {
        int u, k;
        cin >> u >> k;
        --u;
        rep(j, k)
        {
            int v;
            cin >> v;
            m[u][--v] = 1;
        }
    }

    rep(i, n) rep(j, n) j != n - 1 ? cout << m[i][j] << " " : OP(m[i][j]);

    return 0;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
#define ld double
#define mp make_pair
#define pb push_back
#define mod 1000000007
#define ff first
#define ss second
#define pll pair <ll,ll>
#define nl "\n"
ll dp[102][100005];
int main()
{
	ios_base::sync_with_stdio(false);
	ll n,wt,i,j,ans;	
	cin>>n>>wt;
	ll w[n+2],v[n+2];
	for(i=0;i<n;i++)
		cin>>w[i]>>v[i];
	if(n==1)
	{
		cout<<v[0]<<nl;
		return 0;
	}
	for(i=0;i<n;i++)
	{
		for(j=0;j<=100005;j++)
			dp[i][j]=1e10;
	}
	dp[n-1][v[n-1]]=w[n-1];
	dp[n-1][0]=0;
	for(i=n-2;i>=0;i--)
	{
		for(j=0;j<100005;j++)
		{
			dp[i][j] = dp[i+1][j];
			if(j>=v[i])
			{
				dp[i][j] = min(dp[i][j], dp[i+1][j-v[i]] + w[i]);
			}
		}
	}

	for(i=0;i<100005;i++)
	{
		if(dp[0][i] <= wt)
			ans = i;
	}
	cout<<ans<<nl;
	return 0;
}

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


int main() {
    int ans = 7;
    vector<char> _num(4);
    rep(i,4) cin >> _num.at(i);
    vector<int> num(4);
    rep(i,4) num.at(i) = _num.at(i) - '0';
    char op[3];
    for (int tmp = 0; tmp < (1 << 4); ++tmp) {
        bitset<4> s(tmp);
        int sum = num.at(0);
        for (int i = 1; i < 4; ++i) {
            if (s.test(i)) {
                sum += num.at(i);
                op[i-1] = '+';
            }else{
                sum -= num.at(i);
                op[i-1] = '-';
            }
        }
        if (sum == ans) {
            cout << num[0];
            cout << op[0];
            cout << num[1];
            cout << op[1];
            cout << num[2];
            cout << op[2];
            cout << num[3];
            cout << "=7" << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import math
import collections
#sys.setrecursionlimit(100000)

n=int(input())
tmp = input().split()
s = list(map(lambda a: int(a), tmp))

ind=0
for i in range(n):
	if(s[i]==ind+1):
		ind+=1

if(ind==0):
	print(-1)
else:
	print(n-ind)




Measured memory_bytes: 26772
#include <iostream>

using namespace std;
typedef long long ll;
ll dp[2000010],mod = 1000000007;
int main(){
    ll i,n,h,d,x = 1,y = 0;
    cin >> n >> h >> d;
    for(i=1;i<=n;i++){
        (x *= i) %= mod;
        (y += x) %= mod;
    }
    dp[0] = x;
    for(i=0;i<=h;i++){
        if(i==0){
            (dp[i + 1] += dp[i]) %= mod;
            (dp[i + d + 1] += mod - dp[i]) %= mod;
        }else{
            (dp[i + 1] += dp[i]) %= mod;
            (dp[i + 1] += y*dp[i]%mod) %= mod;
            (dp[i + d + 1] += (mod - y*dp[i]%mod)) %= mod;
        }
    }
    cout << dp[h] << endl;
}

Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define P pair<int, int>
#define F first
//#define S second
#define mod 1000000007
#define MOD 998244353
#define INF 40000000000000000
int dx8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int dy8[8] = {1, 1, 1, 0, -1, -1, -1, 0};
int dx4[4] = {-1, 0, 1, 0};
int dy4[4] = {0, -1, 0, 1};
template <class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
int gcd(int a, int b) {
    if(b == 0) return a;
    return gcd(b, a % b);
}
int judge(char a) {
    if(a == 'R') return 1;
    if(a == 'G') return 2;
    if(a == 'B') return 3;
}
signed main() {
    int N;
    cin >> N;
    string S;
    cin >> S;
    //j,k決め打ち
    vector<vector<int>> V(3, vector<int>(N + 1, 0));
    rep(i, N) {
        if(S[i] == 'R') V[0][i + 1]++;
        if(S[i] == 'G') V[1][i + 1]++;
        if(S[i] == 'B') V[2][i + 1]++;
        rep(j, 3) V[j][i + 1] += V[j][i];
    }
    int ans = 0;
    for(int k = N - 1; k >= 2; k--) {
        for(int j = k - 1; j > 0; j--) {
            int a = judge(S[k]), b = judge(S[j]);
            if(a == b) continue;
            int c = 6 / a / b;
            ans += V[c - 1][j];
            if(j - (k - j) >= 0 && judge(S[j - (k - j)]) == c) ans--;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3736
#include <bits/stdc++.h>
#define FASTIO ios::sync_with_stdio(false);cin.tie(0);
#define ADD +
#define SUBTRACT -
#define MULTIPLY *
#define DIVIDE /
#define MOD %
#define INCREMENT(x) ++x
#define DECREMENT(x) --x
#define in(a,b) cin>>a>>b;
#define out(a,b) cout<<a<<endl<<b<<endl;
#define scan(a) scanf("%d",&a);
#define print(a) printf("%d\n",a);
#define scanii(a,b) scanf("%d %d",&a,&b);
#define printii(a,b) printf("%d\n%d\n",a,b);
#define scaniii(a,b,c) scanf("%d %d %d",&a,&b,&c);
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define ll long long
#define ull unsigned long long
#define sll signed long long
#define f1(i,a) for(int i=0;i<a;++i)
#define f2(i,a) for(int i=a-1;i>=0;--i)
#define pi acos(-1)
#define mod 1000000007
#define TRUE 1
#define FALSE 0
#define ZERO 0
#define MP make_pair
#define F first
#define S second
#define en puts("");
#define elif else if
typedef ll int lli;
typedef sll int slli;
typedef ull int ulli;
const int sz=10000;
using namespace std;

int clue();
int result();
void show();
bool check();

int div(lli n) {
    int count=0;
    for(int i=1;i*i<=n;++i) {
        if(n%i==0) {
            if(n/i==i) {
                ++count;
            }
            else {
                count+=2;
            }
        }
    }
    // cout<<count<<endl;

    return count;
}
int main() {
    
    char c;
    cin>>c;
    (c>='A' && c<='Z')?cout<<"A"<<endl:cout<<"a"<<endl;
    return 0;
}

Measured memory_bytes: 3600
R, G, B, N = [int(_) for _ in input().split()]
cnt = 0

for i in range(0, N//R+1):
    for j in range(0, (N-R*i)//G + 1):
        if (N-R*i-G*j) % B == 0:
            cnt += 1
print(cnt)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
 
using namespace std;
int main()
{
    char s[5];
   scanf("%s",s);
    int x=0;
    for(int i=0; s[i]; i++)
    {
        if(s[i]=='+')
            x++;
        else if(s[i]=='-')
            x--;
    }
    printf("%d\n",x);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ggdem=b;i<ggdem;++i)
#define SZ(x) ((int)x.size())
#define ALL(x) x.begin(),x.end()
#define mset(a,v) memset((a),(v),sizeof(a))
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;

const ll MOD=1000000007;
string s; ll k;

ll dp[10004][105][2];

ll f(ll x, ll y, ll z){
	ll &r=dp[x][y][z];
	if(r>=0)return r;
	if(x==SZ(s)){
		r=(y==0); return r;
	}
	if(z==0){
		r=0;
		fore(i,0,10){
			r+=f(x+1,(y+i)%k,0);
			if(r>MOD)r-=MOD;
		}
		return r;
	}
	r=0;
	fore(i,0,10){
		if(i<s[x]-'0')r+=f(x+1,(y+i)%k,0);
		if(i==s[x]-'0')r+=f(x+1,(y+i)%k,1);
		if(r>MOD)r-=MOD;
	}
	return r;
}

int main(){FIN;
	cin>>s>>k;
	mset(dp,-1);
	cout<<(f(0,0,1)+MOD-1)%MOD;
	return 0;
}

Measured memory_bytes: 17408
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <stack>
#define ll long long
#define PI = acos(-1.0);
//#define local

using namespace std;

const int MOD = 1e9+7;
const int inf = 0x3f3f3f3f;
const int maxn = 2e5 + 5;

char s[maxn], t[maxn];

int main() {
#ifdef local
    if(freopen("/Users/Andrew/Desktop/data.txt", "r", stdin) == NULL) printf("can't open this file!\n");
#endif
    scanf("%s", s);
    scanf("%s", t);
    int flag = 1;
    char ch = 'a';
    for ( ; ch <= 'z'; ++ch) {
        char tmp = 'A';
        for (int j = 0; j < int(strlen(s)); ++j) {
            if (t[j] == ch) {
                if (tmp == 'A') tmp = s[j];
                if (tmp != s[j]) {
                    flag = 0;
                    break;
                }
            }
        }
        if (!flag) break;
    }
    ch = 'a';
    if (flag == 1)
        for ( ; ch <= 'z'; ++ch) {
            char tmp = 'A';
            for (int j = 0; j < int(strlen(s)); ++j) {
                if (s[j] == ch) {
                    if (tmp == 'A') tmp = t[j];
                    if (tmp != t[j]) {
                        flag = 0;
                        break;
                    }
                }
            }
            if (!flag) break;
        }
    if (flag) printf("Yes\n");
    else printf("No\n");
#ifdef local
    fclose(stdin);
#endif
    return 0;
}












Measured memory_bytes: 640
n,k = map(int,input().split())
d = list(map(str,input().split()))
flg = True
while flg:
    l = list()
    n_s = str(n)

    for i in n_s:
        if i in d:
            break
    else:
        print(n)
        flg = False
        break
    n = n +1
else:
    print(n)


Measured memory_bytes: 2940
/* Author - thiolhub */

#include <bits/stdc++.h>

using namespace std;

#define ll              long long int
#define ld              long double
#define db              double
#define pi              3.1415926535897932384626
#define PI              acos(-1.0)
#define endl            "\n"
#define mod             1000000007
#define mk              make_pair
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(t)            ll t; cin>>t; while(t--)
#define sc(a)	        scanf("%lld",&a);
#define pr(a)	        printf("%lld\n",a)
#define f(i,a,n)		for(ll i=a;i<n;i++)
#define m(a)		    memset(a,0,sizeof(a))
#define FastIO          ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)



int main(){ FastIO;

ll n,ans,i,k=0;cin>>n;
vector<ll> v;
for(i=1;i<10;i++) v.pb(i);
i=0;
while(k!=n)
{
	ans=v[i];
	if(ans%10!=0) v.pb(10*ans+ans%10-1);
	v.pb(10*ans+ans%10);
	if(ans%10!=9) v.pb(10*ans+ans%10+1);
	k++;i++;
}
cout<<ans;

return 0;
}


Measured memory_bytes: 6512
#include <iostream>
using namespace std;
int main()
{
    int a ;
    int b ;
    cin >> a ;
    cin >> b ;
    int ans ;
    if(a == b){
        ans = a + b ;    
    }
    else if(a > b){
        ans = 2 * a - 1 ;
    }
    else if(a < b){
        ans = 2 * b - 1 ;
    }
    cout << ans ;
    return 0;
    

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m;
int a[10];
int main(){
	cin>>n>>m;
	memset(a,-1,sizeof a);
	int f=1;
	while(m--){
		int pos,c;
		cin>>pos>>c;
		if(a[pos]!=-1&&c!=a[pos]){
			f=0;
			break;
		}
		else a[pos]=c;
	}
	if(n==1){
		if(a[1]==-1)a[1]=0;
	}
	else{
		if(a[1]==0){
			f=0;
		}
		if(a[1]==-1)a[1]=1;
		for(int i=2;i<=n;i++){
			if(a[i]==-1)a[i]=0;
		}
	}
	if(!f)cout<<"-1"<<endl;
	else{
		for(int i=1;i<=n;i++)cout<<a[i];
		cout<<endl;
	}
	return 0;
} 

Measured memory_bytes: 256
#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--)
#define MAX(a,b) a=a>b?a:b
#define MIN(a,b) a=a<b?a:b
#define REP(i,x,n) for(int i=x;i<n;i++)
#define REPR(i,x,n) for(int i=n-1;i>=x;i--)
#define pb  push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLr(obj) (obj).rbegin(), (obj).rend()
#define endl "\n"
#define F first
#define S second
#define EN cout<<endl;
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
 ll dp[2000][2000];



int main(){
   ll n,k,a[201010],ans[201010];
   pair<ll,bool> f[201010]={};
   cin>>n>>k;
   rep(i,n){
       cin>>a[i];
       a[i]--;
   }
   ll now=0,c=0,x;
   f[0].F=0;
   f[0].S=1;
   ans[0]=0;
   rep(i,n){
       c++;
       if(f[a[now]].S==1){
           x=f[a[now]].F;
           break;

       }
       //cout<<"a"<<endl;
       f[a[now]].S=1;
       f[a[now]].F=c;
       ans[c]=a[now];
       now=a[now];
   }
   ll i=0;
   while(i!=x){
       i++;
       if(i==k){
           cout<<ans[i]+1<<endl;
           return 0;
       }
       
       
   }
   k-=i;
   c-=i;
   
   cout<<ans[i+(k%c)]+1<<endl;;
}


Measured memory_bytes: 9836
#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>;
const int INF = 1001001001;

int main() {
  int n;
  cin >> n;
  vector<int> res(n + 1);
  ll now;
  int m = (int)sqrt(2*n) + 1; 
  for(int i = 1; i <= m; ++i) {
    for(int j = 1; j <= m; ++j) {
      for(int k = 1; k <= m; ++k) {
        now = (i + j) * (i + j) + (i + k) * (i + k) + (k + j) * (k + j);
        if(!(now & 1) && now / 2 <= n) {
          res[now / 2]++;
        }
      }
    }
  }
  for(int i = 1; i <= n; ++i) {
    cout << res[i] << endl;
  }
   return 0;
}

Measured memory_bytes: 3648