akhauriyash/Code-Regression huggingface dataset:
import sys
rs = lambda: sys.stdin.readline().rstrip()
ri = lambda: int(rs())
rf = lambda: float(rs())
rs_ = lambda: [_ for _ in rs().split()]
ri_ = lambda: [int(_) for _ in rs().split()]
rf_ = lambda: [float(_) for _ in rs().split()]

N = ri()
m = len(str(N))
ans = 0
for i in range(0, 10, 2):
    if i == m - 1:
        ans += N - (10 ** i) + 1
        break
    elif i >= m:
        break
    else:
        ans += 9 * (10 ** i)
print(ans)

Measured memory_bytes: 38256
N = int(input())
S = input()
cnt = 0

for i in range(10):
    for j in range(10):
        for k in range(10):
            idx = S.find(str(k))
            if idx != -1:
                idx = S.find(str(j),idx+1)
                if idx != -1:
                    idx = S.find(str(i),idx+1)
                    if idx != -1:
                        cnt += 1

print(cnt)

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

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

    int n;
    cin >> n;
    vector<int> v(n);

    for (int i = 0; i < n; i++)
    {
        cin >> v[i];
    }
    int cnt = 0;
    for (int i = 0; i < n; i++)
    {
        if (v[i] % 2)
        {
            cnt++;
        }
    }

    cout << ((cnt % 2) ? "NO" : "YES") << '\n';
    return (0);
}


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

int main() {

    int n; cin >> n;

    int ans = 0;
    for (int i = 0; i < n; i++) {
        int l, r; cin >> l >> r;
        ans += r - l + 1;
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n;
int main() {
    cin >> n;
    if(n == 1){
        cout << "Hello World" << endl;
        return 0;
    }
    int a, b;
    cin >> a >> b;
    cout << a + b << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N,T;
    int m=1001;
    int c,t;
    cin>>N>>T;
    for(int i=0;i<N;i++){
        cin>>c>>t;
        if(t<=T){m=min(m,c);}
    }
    if(m==1001){cout<<"TLE"<<endl;}
    else{cout<<m<<endl;}
}

Measured memory_bytes: 256
N,K = map(int,input().split(" "))
x = list(map(int,input().split(" ")))

ans = float('inf')
for i in range(N-K+1):
    if x[i] >= 0 and x[i+K-1] >= 0:
        ans = min(ans,x[i+K-1])
    elif x[i] < 0 and x[i+K-1] < 0:
        ans = min(ans,-x[i])
    else:
        l = -x[i]
        r = x[i+K-1]
        mi = min(l,r)
        mx = max(l,r)
        ans = min(ans,mi*2+mx)

print(ans)

Measured memory_bytes: 14844
if __name__ == '__main__':

    N, A, B = [int(x) for x in input().split()]

    ans = 0
    for i in range(1, N+1):
        tmp = list(map(int, list(str(i))))
        tmp = sum(tmp)
        if A <= tmp <= B:
            ans += i

    print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
string s,t;
long long f[3005][3005];
long long a[3005];
vector <int> b;
main()
{
    cin>>s>>t;
    s=' '+s;
    t=' '+t;
    for(int i=1; i<s.size(); i++)
        for(int j=1; j<t.size(); j++)
        {
            if(s[i]==t[j])
            {
                f[i][j]=f[i-1][j-1]+1;


            }
            else
                f[i][j]=max(f[i-1][j],f[i][j-1]);
        }
    int i=s.size()-1,j=t.size()-1;
    while(i>=1&&j>=1)
    {
        if(s[i]==t[j])
        {

            b.push_back(i);
            i--;
            j--;
        }
        else if(f[i][j]==f[i-1][j])
            i--;
        else if(f[i][j]==f[i][j-1])
            j--;
    }
    for(int i=b.size()-1; i>=0; i--)
        cout<<s[b[i]];
}


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

using namespace std;

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

  vector<int> cd = {1};
  for (int i = 2, minv = min(A, B); i <= minv; ++i) {
    if (A % i == 0 and B % i == 0) cd.insert(cd.begin(), i);
  }

  cout << cd[K-1] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <limits>
#include <cfenv>
#include <cmath>
#include <algorithm>
#include <array>
#include <bitset>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <tuple>
#include <queue>
#include <vector>
#include <cmath>
#include <random>
#include <math.h>
#include <list>
#include <random>
#include <functional>


#define FOR(i, a, b) for(int (i) = (a); (i) < (b); ++(i))
#define REP(i, n) FOR(i, 0, n)
#define rREP(i, n) for(int (i) = (n) - 1; (i) >= 0; --(i))
#define ALL(TheArray) TheArray.begin(), TheArray.end()

using lli = long long int;
using pii = std::pair<int, int>;

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



// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~







// constexpr version : N が clang++ : 3e5くらいまでok,  g++ : 2e6くらいまでok
template <int N, long long int mod>
struct CombinationMod{
private:
    using lli = long long int;
public:
    lli Power[N+1], Inverse[N+1], powInverse[N+1];
    /* A*Co*erは 古いので, arrayがconstexprとして使えない
    std::array<lli, N+1> Power{};
    std::array<lli, N+1> Inverse{};
    std::array<lli, N+1> powInverse{};
    */

    constexpr CombinationMod():Power(), Inverse(), powInverse(){
        Power[0] = 1; Inverse[0] = 1; powInverse[0] = 1;
        for(int x = 1; x <= N; ++x) Power[x] = (Power[x-1] * x) % mod;
        powInverse[N] = inverse(Power[N]);
        for(int x = N; x > 0; --x) powInverse[x-1] = (powInverse[x] * x) % mod;
        for(int x = 1; x <= N; ++x) Inverse[x] = (Power[x-1] * powInverse[x]) % mod;
    }
    constexpr void swap(lli &a, lli &b) const {
        a ^= b; b ^= a; a ^= b;
    }
    constexpr lli inverse(lli a) const noexcept{
        lli b = mod, u = 1, v = 0;
        while (b != 0) { 
            lli t = a / b; a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        u %= mod; if (u < 0) u += mod;
        return u;
    }
    // nCkを求める関数 : n < k の入力に注意せよ
    inline lli combination(int n, int k) const noexcept{
        if(n < k or k < 0) return 0;
        return ((Power[n] * powInverse[k] % mod) * powInverse[n-k]) % mod;
    }
};

constexpr int N = 1e6;
constexpr int mod = 1e9 + 7;
constexpr CombinationMod<N, mod> Cmb;

int main(void){
    int x, y; scanf("%d%d", &x, &y);
    int d = x + y;
    if(d % 3 != 0) puts("0");
    else{
        d /= 3;
        if(d > x or d > y) puts("0");
        else printf("%lld\n", Cmb.combination(d, x-d));
    }
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<cmath>
#include<cstring>
#include<set>
#include<climits>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define all(a) a.begin(),a.end()
//#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define size(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
const int mod=1e9+7;
/* 
UnionFind：素集合系管理の構造体(union by size)
isSame(x, y): x と y が同じ集合にいるか。 計算量はならし O(α(n))
unite(x, y): x と y を同じ集合にする。計算量はならし O(α(n))
treeSize(x): x を含む集合の要素数。
*/
struct UnionFind{
 vector<int>size,parents;
 UnionFind(){}
 UnionFind(int n){//make n trees.
  size.resize(n,0);
  parents.resize(n,0);
  for(int i=0;i<n;i++)makeTree(i);
 }
 void makeTree(int x){
   parents[x]=x;//the parent of x is x
   size[x]=1;
  }
 bool isSame(int x,int y){return findRoot(x)==findRoot(y);}
 bool unite(int x,int y){
  x = findRoot(x);
  y = findRoot(y);
  if(x==y)return false;
  if(size[x]>size[y]){
   parents[y]=x;
   size[x]+=size[y];
  } 
  else{
   parents[x]=y;
   size[y]+=size[x];
  }
  return true;
 }
 int findRoot(int x){//木の根を探す,計算量削減のため低く
  if(x!=parents[x])parents[x]=findRoot(parents[x]);
  return parents[x];
 }
 int treeSize(int x){return size[findRoot(x)];}
};
/*pi*/const double pi=acos(-1);
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
/*Fibonacci数列*/ll fib(ll x){ll i,fibo[x+10];fibo[0]=1;fibo[1]=1;fibo[2]=1;rep(i,3,x+1)fibo[i]=fibo[i-1]+fibo[i-2];return fibo[x];}
/*桁数*/ll dig(ll n){ll d=0,i=0;while(n/10>0){i++;d++;}return d;}
/*迷路移動*/const int dx[4]={1,0,-1,0};const int dy[4]={0,1,0,-1};
llfor;//ll ans=0;////////////////////////////////////////////////////////////
int main(){
 ll n;
 cin>>n;
 if(n%2==0){
  cout<<n<<" "<<n<<" "<<n/2<<endl;
  return 0;
 }
  
 if(n%3==0){
  cout<<n/3<<" "<<n*2<<" "<<n*2<<endl;
  return 0;
 }
 ll st=cei(n,4);
 for(ll i=st;i<=3500;++i){
  for(ll j=i;j<=3500;++j){
   for(ll k=j;k<=3500;++k){
    if(4*i*j*k==n*(i*j+j*k+k*i)){
     cout<<i<<" "<<j<<" "<<k<<endl;
     return 0;
    }
   }
  }
 }
 return 0;}

Measured memory_bytes: 3660
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[]k = new int[5];
		int N = sc.nextInt();
		for(int i = 0; i < N; i++) {
			char c = sc.next().charAt(0);
			if(c == 'M') k[0]++;
			else if(c == 'A') k[1]++;
			else if(c == 'R') k[2]++;
			else if(c == 'C') k[3]++;
			else if(c == 'H') k[4]++;
		}
		sc.close();
		long sum = 0;
		for(int i = 0; i < 3; i++) {
			for(int j = i + 1; j < 4; j++) {
				for(int l = j + 1; l < 5; l++) {
					sum += (long)k[i] * k[j] * k[l];
				}
			}
		}
		System.out.println(sum);
	}
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  int a;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a;
    if (a & 1) continue;
    if (a % 3 != 0 && a % 5 != 0) {
      cout << "DENIED" << endl;
      return 0;
    }
  }
  cout << "APPROVED" << endl;
}

Measured memory_bytes: 256
// 6/26 解き直し → 6/30
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
using ll = long long;
using P = pair<int, int>;
const int INF = 1000000007;

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
} comb(10000);

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

    for (int i = 1; i <= K; i++) {
        // mint ans = comb(N-K+i, i) * comb(K+i-1, K);
        mint ans = comb(N-K+1, i) * comb(K-1, i-1);
        cout << ans.x << endl;
    }

}

Measured memory_bytes: 3792
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long& x, long long& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

bool check(pair<int,int>a, pair<int,int>b) {
	if (a.first == b.first) {
		return a.second > b.second;
	}
	else {
		return a.first < b.first;
	}
}

int main() {
	int a, b;
	cin >> a >> b;
	if (a == b) {
		cout << a + b << endl;
	}
	else {
		cout << max(a, b) * 2 - 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
n = int(input())

def helper(x):
    if x == 0:
        return []
    r = x % (-2)
    return [r] + helper((x - r) // (-2))


tmp = helper(n)

ans = ''
carry = 0
for x in tmp:
    xx = x + carry
    if xx == -1:
        ans += '1'
        carry = 1
    elif xx == 0:
        ans += '0'
        carry = 0
    elif xx == 1:
        ans += '1'
        carry = 0
if carry:
    ans += '1'

if n == 0:
    print(0)
else:
    ans = str(int(ans[::-1]))
    print(ans)


Measured memory_bytes: 38384
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
#include <numeric>
#include <fstream>
#include <iomanip>

typedef long double ld;
typedef long long ll;

// Output
template<class T, class S> std::ostream& operator <<(std::ostream& os, std::pair<T, S> p)
{
  return os << "(" << p.first << " " << p.second << ")";
}

template<class T> std::ostream& operator <<(std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 9) os << std::endl; }
  //os << v[0]; for (ll i = 1; i < (ll)v.size(); i++){ os << " " << v[i]; }
  return os;
}

template<class T, class S> std::ostream& operator <<(std::ostream& os, std::map< T, S > m)
{
  ll i = 0; for (auto p : m){ os << " [" << i << "]" << p.first << "->" << p.second; i++;}
  return os;
}

template<class T> std::ostream& operator <<(std::ostream& os, std::vector< std::vector<T> > vv)
{
  for (auto& vec : vv){ os << vec << std::endl; }
  os << "--------" << std::endl;
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H&& head){ std::cout << head << std::endl; }
template<typename H, typename... T> void print(H&& head, T&&... tail){
  std::cout << head << " ", print(std::forward<T>(tail)...);
}

// GCD, LCM
ll gcd(ll a, ll b) {
  while (b != 0) { a %= b; std::swap(a, b); }
  return a;
}
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }

// DIGNUM
std::vector<ll> dignum(ll x) {
  if (x == 0) return {0};
  std::vector<ll> res;
  while (x) {
    res.push_back(x % 10);
    x /= 10;
  }
  std::reverse(res.begin(), res.end());
  return res;
}

// FAIL
void fail(){ print(-1); std::exit(0); }
//void fail(){ print("No"); std::exit(0); }

void solve()
{
  ll N;
  std::cin >> N;
  std::vector< ll > vb(N+1, 0LL);
  for (ll i = 1; i <= N; i++) {
    std::cin >> vb[i];
  }

  std::vector< ll > vans;
  for (ll i = N; i >= 1; i--) {
    ll j = i;
    for (; j >= 1; j--) {
      if (j == vb[j]) {
        vb.erase(vb.begin()+j);
        vans.push_back(j);
        break;
      }
    }
    if (j == 0) return fail();
  }

  std::reverse(vans.begin(), vans.end());
  for (auto ans : vans) {
    print(ans);
  }

  return;
}

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

  solve();
  return 0;
}



Measured memory_bytes: 256
#include "iostream"
#include "vector"
#include "array"
#include "string"
#include "algorithm"
#include "functional"
#include <math.h>
#include "regex"



using namespace std;
#define rep(p,q) for(int i = p;i < q;i++)

//C

int main(void) {
	int num = 0;
	long long total = 0;
	long long minus = 0;
	int count = 0;
	cin >> num;
	vector<int> a = vector<int>(); vector<long long int> diff = vector<long long int>();
	rep(0, num) {
		int input = 0;
		cin >> input;
		a.push_back(input);
	}
	rep(0, num) {
		int input = 0;
		cin >> input;
		int need = a[i] - input;
		diff.push_back(need);
		if (need < 0) {
			minus += need;
			count++;
		}
	}
	sort(diff.begin(), diff.end(), greater<long long int>());
	int index = 0;
	while (minus < 0) {
		if (diff[index] < 0) {
			count = -1;
			break;
		}
		else {
			minus += diff[index];
			count++;
			index++;
		}
	}
	cout << count << endl;
}

Measured memory_bytes: 1784
n, A, B, C = (int(i) for i in input().split())  #a=1, b=3, c=5, d=7
l = [int(input()) for i in range(n)]
INF = 10 ** 9

def dfs(cur, a, b, c):
    if cur == n:
        return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF
    ret0 = dfs(cur + 1, a, b, c)
    ret1 = dfs(cur + 1, a + l[cur], b, c) + 10
    ret2 = dfs(cur + 1, a, b + l[cur], c) + 10
    ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10
    return min(ret0, ret1, ret2, ret3)
    
print(dfs(0, 0, 0, 0))

Measured memory_bytes: 3064
import java.util.Scanner;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    while(sc.hasNext()) {
      int key = 0;
      String str = sc.nextLine();
      String[] strArr = str.split(" ");
      searchKey:
      for (int i = 0; i < strArr.length; i++) {
        for (int j = 1; j < 27; j++) {
          String strTemp = "";
          for (int k = 0; k < strArr[i].length(); k++) {
            char charTemp = (char)(strArr[i].charAt(k) + j);
            if (charTemp > 'z') {
              charTemp = (char)(charTemp - 26);
            }
            strTemp += String.valueOf(charTemp);
          }
          if (strTemp.equals("the") || strTemp.equals("this") || strTemp.equals("that")) {
            key = j;
            break searchKey;
          }
        }
      }
      String strResult = "";
      for (int i = 0; i < str.length(); i++) {
        char charResult = (char)(str.charAt(i) + key);
        if (charResult > 'z') {
          charResult = (char)(charResult - 26);
        }
        if (charResult < 'a' || charResult > 'z') {
          charResult = str.charAt(i);
        }
        strResult += String.valueOf(charResult);
      }
      System.out.println(strResult);
    }
  }
}

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

using namespace std;
const int OO = 0x3f3f3f3f;
//const long long OO = (long long) 5e18+7;
//const unsigned long long UOO = (long long) 10e18+7;
#define lp(i,a,n) for(long long i = a ; i < n ; ++i)
#define lpr(i,a,n) for(long long i = a ; i >= n ; --i)
#define rep(i,vec) for(ll i = 0 ; i < vec.size() ; ++i)
#define reprv(i,vec) for(ll i = vec.size()-1; i >=0 ; --i)
#define eps (1e-5)
#define pb(i) push_back(i)
#define EPS 1e-9
#define sz(x) int((x).size())
#define all(x) (x).begin(), (x).end()
#define ff first
#define ss second
#define debug(x) cout<<(#x)<<": \""<<x<<"\""<<endl
#define debugVec(vec) cout<<(#vec)<<": "; for (auto& i: vec) cout<<i<<" "; cout<<endl

typedef vector<int> vi ;
typedef   long long ll;
typedef   unsigned long long ull;
typedef vector<ll> vll ;
typedef pair<int,int> pii ;
typedef vector< pair<int,int> >  vpii;
typedef vector<pair<long long,long long>> vpll;
typedef vector<vector<int> > vvi ;
typedef complex<double> point;
typedef pair<ll,ll> pll;

using namespace std;
ll  inv(ll a, ll b) {return 1 < a ? b - inv(b % a, a) * b / a : 1;}
ll  Pow(ll  B,ll  P){ll  R=1; while(P>0)  {if(P&1) R=(R*B);P/=2;B=(B*B);}return R;} //compute b^p
ll  GCD(ll  a,ll  b){ while(b){b ^= a ^=b ^= a %=b;}  return a;}
ll  LCM(ll  a,ll  b) { return (a / GCD(a,b)*b); }
ll  BigMod(ll  B,ll  P,ll  M){ ll  R=1; while(P>0)  {if(P&1){R=(R*B)%M;}P/=2;B=(B*B)%M;} return (ll )R;} //compute b^p%m
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//int i=uniform_int_distribution<int>(1,n)(rng);


int N;
int v[100005][3];
int mem[100005][3];




int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
//    cout.tie(0);
//#ifndef ONLINE_JUDGE
//   freopen( "output.txt" , "w" , stdout ) ;
//   freopen( "input.txt" , "r" , stdin ) ;
//#endif

    cin >> N ;
    lp(i,0,N)lp(j,0,3) cin >> v[i][j];

    lp(i,0,3) mem[N-1][i] = v[N-1][i];

    lpr(i,N-1,1)lp(j,0,3){

        lp(k,0,3)if(j!=k){
            mem[i-1][k] = max(mem[i-1][k],mem[i][j]+v[i-1][k]);
        }
    }
    cout << max(mem[0][0],max(mem[0][1],mem[0][2]));

    return 0;
}


Measured memory_bytes: 5948
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, x, n) for (int i = (x); i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define int long long
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 1e10;
template<typename T> void cmax(T &a, T b) { a = max(a, b); }
template<typename T> void cmin(T &a, T b) { a = min(a, b); }
int h, w;
int dy[4] = {0, 1, 0, -1};
int dx[4] = {1, 0, -1, 0};
char d[500][500] = {};
int used[500][500];
int ans = 0;
int bla, whi;

int f(int y, int x, bool black) {
  used[y][x] = 1;
  black ? bla++ : whi++;
  rep(i, 4) {
    int ny = y + dy[i];
    int nx = x + dx[i];
    if (black) {
      if (0 <= ny && ny < h && 0 <= nx && nx < w && d[ny][nx] == '.' && used[ny][nx] == 0) {
        f(ny, nx, false);
      }
    } else {
      if (0 <= ny && ny < h && 0 <= nx && nx < w && d[ny][nx] == '#' && used[ny][nx] == 0) {
        f(ny, nx, true);
      }
    }
  }
  return bla * whi;
}

signed main() {
  cin >> h >> w;
  rep(i, h) {
    string s;
    cin >> s;
    rep(j, w) d[i][j] = s[j];
  }
  rep(i, h) rep(j, w) {
    bla = 0;
    whi = 0;
    if (d[i][j] == '#' && used[i][j] == 0) ans += f(i, j, true);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 9472
n_V, n_E = map(int, input().split())

G = [[] for i in range(n_V)]

# 読み込み
for i in range(n_E):
    v, e = map(int, input().split())
    G[v].append(e)

#
flag = False

for i in range(n_V):
    stack = [i]
    visited = set()

    while stack != []:
        current = stack.pop()

        for e in G[current]:
            if e == i:
                flag = True
                break

            if e not in stack and e not in visited:
                stack.append(e)

        visited.add(current)

#
print(int(flag))



Measured memory_bytes: 5612
#pragma GCC optimize "O3"

#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <vector>

using namespace std;

int main() {
  int n;
  cin >> n;
  int a[9];
  for (int i = 0; i < 9; i++) {
    a[i] = 0;
  }
  int target = 0;

  for (int i = 0; i < n; i++) {
    int tmp;
    cin >> tmp;
    if (tmp / 400 < 8) {
      a[tmp / 400] = 1;
    } else {
      a[8]++;
    }
  }
  int ans_l = 0;

  for (int i = 0; i < 8; i++) {
    ans_l += a[i];
  }
  int ans_h = ans_l + a[8];

  if (ans_l == 0) ans_l++;
	
  cout << ans_l << " " << ans_h << endl;

  return 0;
}


Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    x, a = LI()
    if x < a:
        print(0)
    else:
        print(10)
    return

#B
def B():
    n, x = LI()
    L = LI()
    ans = 0
    c = 1
    for i in L:
        ans += i
        if ans <= x:
            c += 1
            continue
        break
    print(c)
    return

#C
def C():
    W, H, x, y = LI()
    a = W * H / 2
    b = 0
    if W/2 == x and H/2 == y:
        b = 1
    print(a,b)
    return

#D
def D():
    n, k = LI()
    a = LI()
    dp = [0] * (n)
    for i in range(n):
        dp[i] += dp[i - 1] + a[i]
    ans = 0
    dp.insert(0, 0)
    #print(dp)
    for i in range(1,n+1):
        ai = bisect_left(dp, k + dp[i-1])
        ans += n+1 - ai
        #print(ai, i, k + dp[i-1])
    print(ans)

    return

#E
def E():
    n, m = LI()
    s = LI()
    t = LI()
    dp = [[0] * (m+1) for i in range(n+1)]
    for i in range(n+1):
        dp[i][0] = 1
    for k in range(m + 1):
        dp[0][k] = 1
    for i in range(1, n + 1):
        for j in range(1, m + 1):
            if s[i - 1] == t[j - 1]:
                dp[i][j] += (dp[i-1][j]+dp[i][j-1])%mod
            else:
                dp[i][j] += (dp[i-1][j]+dp[i][j-1]-dp[i-1][j-1])%mod
    print(dp[n][m])
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    E()


Measured memory_bytes: 74204
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC138A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a;
            string s;

            a= int.Parse(Console.ReadLine());
            s = Console.ReadLine();

            if (a >= 3200)
                Console.WriteLine(s);

            else
                Console.WriteLine("red");

            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 11092
#include <stdio.h>

using namespace std;

struct Node{
	Node(){
		left_child = right_child = parent = -1;
	}
	int left_child,right_child,parent;
};

class Heap{
public:
	Heap(int H){
		index = 0;
		array = new long long[H];
		struct_array = new Node[H];
	}
	~Heap(){
		delete[] array;
		delete[] struct_array;
	}
	void push(long long data){
		array[index] = data;
		if(index != 0){
			if(index%2 == 0){
				struct_array[(index-1)/2].right_child = index;
				struct_array[index].parent = (index-1)/2;
			}else{
				struct_array[index/2].left_child = index;
				struct_array[index].parent = index/2;
			}
		}
		index++;
	}

	void print(){
		for(int i = 0; i < index; i++){
			printf("node %d: key = %d, ",i+1,array[i]);
			if(struct_array[i].parent != -1) printf("parent key = %lld, ",array[struct_array[i].parent]);
			if(struct_array[i].left_child != -1) printf("left key = %lld, ",array[struct_array[i].left_child]);
			if(struct_array[i].right_child != -1) printf("right key = %lld, ",array[struct_array[i].right_child]);
			printf("\n");
		}
	}

private:
	long long* array;
	Node* struct_array;
	int index;
};

int main(){
	int H;
	long long tmp;
	scanf("%d",&H);
	Heap heap(H);

	for(int i = 0; i < H; i++){
		scanf("%lld",&tmp);
		heap.push(tmp);
	}
	heap.print();
}

Measured memory_bytes: 1036
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
int main() {
	int N;
	cin >> N;
	string S;
	cin >> S;
	map<int, int> cnt1, cnt2;
	for (int i = 0; i < N; i++) cnt2[S[i]]++;
	int ans = 0;
	for (int i = 0; i < N; i++) {
		cnt1[S[i]]++;
		cnt2[S[i]]--;
		int sum = 0;
		for (int j = 0; j < 26; j++) {
			if (cnt1['a' + j] > 0 && cnt2['a' + j] > 0) sum++;
		}
		ans = max(ans, sum);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mo 1000000007
using namespace std;
long long read(){
    long long xx=0,flagg=1;
    char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-')
        ch=getchar();
    if(ch=='-'){
        flagg=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        xx=xx*10+ch-'0';
        ch=getchar();
    }
    return xx*flagg;
}
void pus(long long xx,long long flagg){
    if(xx<0){
        putchar('-');
        xx=-xx;
    }
    if(xx>=10)
        pus(xx/10,0);
    putchar(xx%10+'0');
    if(flagg==1)
        putchar(' ');
    if(flagg==2)
        putchar('\n');
    return;
}
long long n,m,i,j,f[5005][5005],sum;
int main(){
	n=read();m=read();
	f[0][m]=1;
	for(i=1;i<=n;i++){
		sum=0;
		for(j=m;j>=1;j--){
			f[i][j]=(sum*j+f[i-1][j]*(j+1))%mo;
			sum=(sum*2+f[i-1][j])%mo;
		}
	}
	sum=0;
	for(i=1;i<=m;i++)
		sum=(sum+f[n][i])%mo;
	pus(sum,2);
    return 0;
}


Measured memory_bytes: 199108
#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;
const int MAX_V=100000;
#define int long long
struct edge{int to,cost;};
int V,E;
vector<edge> G[MAX_V];
int d[MAX_V];

signed main(){
  int N;
  int s[100001]={};
  int cnt=0;
  int a;
  cin >> N;
  int ma=0;
  LOOP(i,N){
    cin >> a;
    if(a>100000)cnt++;
    else{
      s[a]++;
      ma = ma<a ? a : ma;
    }
  }
  LOOP1(i,100000){
    if(s[i]!=0){
      if(s[i]>i)cnt+=s[i]-i;
      if(s[i]<i)cnt+=s[i];
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 3456
function gets(str){
  this._s = str.split("\n");
  this._y = 0;
};
gets.prototype = {
  a: function(f){
    var s = this._s, y = this._y, r;
    if(typeof s[y] === "string")s[y] = s[y].split(" ").reverse();
    r = s[y].pop();
    if(!s[y].length)this._y++;
    return f?r:+r;
  },
  l: function(f){
    var s = this._s[this._y++].split(" ");
    return f?s:s.map(a=>+a);
  },
  m: function(n,f){
    var s = this._s, y = this._y, r = [], i = 0;
    if(f)for(;i < n; i++)r[i] = s[y+i].split(" ");
    else for(;i < n; i++)r[i] = s[y+i].split(" ").map(a=>+a);
    this._y += n;
    return r;
  },
};
var o=new gets(require("fs").readFileSync("/dev/stdin","utf8"));

console.log(main());
function main(){
  var n = o.a();
  if(n === 1)return "Yes\n2\n1 1\n1 1"
  var m = Math.sqrt(n*2)|0;
  if(m * (m+1) / 2 !== n)return "No";
  var ans = Array(m+1).fill(0).map(a=>[]);
  var a = Array(m+1).fill(0).map(a=>[]);
  ans[0][0] = m;
  var k = 1;
  for(var i = 1; i <= m; i++){ans[0][i] = k; a[0].push(k++)}
  for(var i = 1; i <= m; i++){
    ans[i][0] = m;
    for(var j = 0; j < i; j++){
      ans[i][j+1] = a[j].pop();
    }
    for(; j < m; j++){
      ans[i][j+1] = k;
      a[i].push(k++);
    }
  }
  console.log("Yes");
  console.log(m+1);
  return ans.map(a=>a.join(" ")).join("\n");
}

Measured memory_bytes: 28876
package main

import (
"bufio"
"fmt"
"os"
"strconv"
"strings"
)

type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextFloat() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) PrintLn(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *Io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func intMin(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func intMax(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func solve(io *Io) {
	n := io.NextInt()
	var ans string
	if n < 1000 {
		ans = "ABC"
	} else {
		ans = "ABD"
	}

	io.PrintLn(ans)
}

func main() {
	io := NewIo()
	defer io.Flush()

	solve(io)
}

Measured memory_bytes: 640
// Sky's the limit :)
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    int t = 1; 
    // cin >> t; 
    while (t--) {
        int a, b, c, k;
        cin >> a >> b >> c >> k;

        if(k <= a + b)
            cout << min(a, k) << '\n';
        else 
            cout << 2 * a + b - k << '\n';
    } 
    
    return 0;
}



Measured memory_bytes: 3588
# coding: utf-8
from math import ceil
from bisect import bisect_left
S = input()
L = []
r, l = 0, 0
cnt = 0
tl = 0
ans = [1 for _ in range(len(S))]
for i in range(len(S)-1):
    if S[i] == "R" and S[i+1] == "L":
        r, l = i, i+1
    if S[i] == "L" and S[i+1] == "R":
        if cnt != 0:
            tl += 1
        for j in range(tl, i+1):
            if j == r or j == l:
                continue
            if (j - r) % 2 == 0:
                ans[r] += 1
            else:
                ans[l] += 1
            ans[j] -= 1
        cnt += 1
        tl = i
    if i == len(S) - 2:
        if cnt != 0:
            tl += 1
        for j in range(tl, i+2):
            if j == r or j == l:
                continue
            if (j-r-1) % 2 == 0:
                ans[l] += 1
            else:
                ans[r] += 1
            ans[j] -= 1
print(*ans)

Measured memory_bytes: 6408
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    string s;
    cin >> s;

    if (s[0] == s[1] && s[2] == s[3] && s[0] != s[2]) {
        cout << "Yes\n";
    } else if (s[0] == s[2] && s[1] == s[3] && s[0] != s[1]) {
        cout << "Yes\n";
    } else if (s[0] == s[3] && s[1] == s[2] && s[0] != s[1]) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }

    return 0;
}

Measured memory_bytes: 760
#include<bits/stdc++.h>
#define MAX 200000
using namespace std;
int A[MAX] = {0};
int dp[MAX] = {0};
int K,N,ans;
int main () {
    ios_base::sync_with_stdio(false);
    cin>>K>>N;
    for(int n=0;n<N;n++) {
        cin>>A[n];
    }
    ans = A[N-1]-A[0];
    for(int i=1;i<N;i++) {
        ans = min(ans,K-(A[i]-A[i-1]));
    }
    cout<<ans<<"\n";
    return 0; 
}

Measured memory_bytes: 1024
n = int(input())
a, b = map(int, input().split())

p = list(map(int, input().split()))

first = list(filter(lambda x: x <= a, p))
second = list(filter(lambda x: x > a and x <= b, p))
third = list(filter(lambda x: x > b, p))

if first == 0 or second == 0 or third == 0:
    print(0)
    exit(0)



print(min(min(len(first), len(second)), len(third)))


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

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

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const double PI = 3.1415926535;
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;

vector<vector<pii>>graph;
int n;

// v: 頂点、p: 親、pc: 親から来た辺の色、res: 色
void dfs(int v, int p, int pc, vector<int> &res){
    int color = 1;
    if(color==pc)color++;
    for(auto i:graph[v]){
        // (隣接頂点, 辺番号)
        if(i.first==p)continue;
        res[i.second] = color;
        dfs(i.first, v, color, res);
        color++;
        if(color == pc)color++;
    }
}
int main(){
    cin >> n;
    graph.assign(n, vector<pii>());
    vector<int>ans(n-1, 1);
    rep(i, 0, n-1){
        int p, q;
        cin >> p >> q;
        p--,q--;
        graph[p].push_back({q, i});
        graph[q].push_back({p, i});
    }
    int ans2=-1;
    rep(i, 0, n)ans2=max(ans2,(int)graph[i].size());
    dfs(0, -1, -1, ans);
    cout << ans2 << endl;
    for(auto i:ans){
        cout << i << endl;
    }
}

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

int main() {
  int N;
  cin >> N;
  
  vector<int> count(N, 0);
  for(int i = 0; i < N-1; i++) {
    int x;
    cin >> x;
    count.at(x-1)++;
  }
  
  for(int i = 0; i < N; i++) {
    cout << count.at(i) << endl;
  }
}


Measured memory_bytes: 4052
import java.util.Scanner;

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

	int N = sc.nextInt();
	String S[] = new String[N];
	int P[] = new int[N];
	int x[] = new int[N];
	for (int i = 0; i < N; i++) {
	    S[i] = sc.next();
	    P[i] = sc.nextInt();
	    x[i] = i;
	}

	for (int i = 0; i < N - 1; i++) {
            for (int j = N - 1; j > i; j--) {
		if (S[j - 1].compareTo(S[j]) > 0) {
		    String tmp_s1 = S[j - 1];
		    S[j - 1] = S[j];
		    S[j] = tmp_s1;

		    int tmp_p1 = P[j - 1];
		    P[j - 1] = P[j];
		    P[j] = tmp_p1;

		    int tmp_x1 = x[j - 1];
		    x[j - 1] = x[j];
		    x[j] = tmp_x1;
		} else if (S[j - 1].compareTo(S[j]) == 0) {
		    if (P[j - 1] < P[j]) {
			String tmp_s2 = S[j - 1];
			S[j - 1] = S[j];
			S[j] = tmp_s2;

			int tmp_p2 = P[j - 1];
			P[j - 1] = P[j];
			P[j] = tmp_p2;

			int tmp_x2 = x[j - 1];
			x[j - 1] = x[j];
			x[j] = tmp_x2;
		    }
		}
	    }
	}

	for (int i = 0; i < N; i++)
	    System.out.println(x[i] + 1);
    }
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define mp make_pair
#define INF 1e9

void init()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
}

int main()
{
    init();
    int a,b,c,d,e;
    cin>>a>>b>>c>>d>>e;
    if (a == 0)
        cout << "1" << endl;
    if (b == 0)
        cout << "2" << endl;
    if (c == 0)
        cout << "3" << endl;
    if (d == 0)
        cout << "4" << endl;
    if (e == 0)
        cout << "5" << endl;
}

Measured memory_bytes: 3608
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;



int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n,a,b;
  cin >> n >> a >> b;
  cout << min(a * n, b ) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb emplace_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define F first
#define E endl
#define S second
#define fast ios:: sync_with_stdio(false),cin.tie(0);
        
int main()
{
	ll a,b,k;
	cin>>a>>b>>k;
	if(a+b<=k)
	{
		a=0;
		b=0;
	}
	else 
	{
	  if(a>=1 && a>=k)
	  a=a-k;
	  else if(a>=1 && a<k)
	  {
	  	k=k-a;
	    a=0;
	    if(b>=1 && b>=k)
	    b=b-k;
	    else if(b>=1 && b<k)
	    b=0;
	  }
	}
	cout<<a<<" "<<b;
}
	
	


Measured memory_bytes: 256
// include
#include <cstdint>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <array>

// ============================================
int main() {
  int N;
  std::cin >> N;
  std::vector<int> a(N);
  
  for (int i = 0; i < N; ++i) {
    
	std::cin >> a[i];
 
  }
  
  
  constexpr int MAXARRAY = 1000001;
  std::vector<int> judge(MAXARRAY);
  for (int x : a) {
	if (judge[x] != 0) {
      judge[x] = 2;
      continue;
    }
    
    for (int i = x; i < MAXARRAY; i += x) {
      judge[i] += 1;
    }
  }
  int result = 0;
  for (int x : a) {
    if (judge[x] == 1) {
      result++;
    }
  }
  
  
  std::cout << result << std::endl << std::endl;

//  for (int i = 0; i < 120; ++i) {
//    std::cout << i << ":" << judge[i] << std::endl;
//  }
  
  return 0;
}


Measured memory_bytes: 7972
//** aman**/
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define dl          double
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b) for(int i=a;i<b;i++)
#define lb lower_bound
#define ub upper_bound
#define bs          binary_search
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
int main(){
	int n;cin>>n;
	string s;
	set<string> ss;
	cin>>s;
	ss.insert(s);
	int f=0;
	for(int i=1;i<n;i++){
		int nn=s.size();
		char x=s[nn-1];
		cin>>s;
		ss.insert(s);
		char y=s[0];
		if(x==y);
		else f=1;
	}
	if(ss.size()!=n||f)cout<<"No";
	else cout<<"Yes"<<endl;
}

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

L, R = map(int, input().split())

min = 2019

if R - L > 2019:
    R = L + 2019

for i in range(L, R+1):
    for j in range(i+1, R+1):
        mod = (i*j) % 2019
        if mod < min:
            min = mod

print(min)

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

using namespace std;

#define boost ios::sync_with_stdio(0);cin.tie(0);
#define forn(i,n) for ( int i=0 ; i < n ; i++ )
#define all(a) (a).begin(), (a).end()
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define ll long long
#define endl '\n'
#define mod 1000000007

#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void ZZ(const char* name, Arg1&& arg1){std::cerr << name << " = " << arg1 << endl;}
template <typename Arg1, typename... Args>void ZZ(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}

int main()
{
	//freopen ("f.in","r",stdin);
 	//freopen ("f.out","w",stdout);
	boost
	//code
	int n;
	cin >> n;
	vector<int> v(n);
	forn(i,n) cin >> v[i];
	int odd = 0;
	forn(i,n){
		if(v[i]%2) odd++;
	}
	if(odd) cout << "first\n";
	else cout << "second\n";
	return 0;
}

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

int main() {
  char c;
  cin >> c;

  if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
    cout << "vowel" << endl;
  }
  else {
    cout << "consonant" << endl;
  }
}

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

using namespace std;

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

  if (N%2 != 0) {
      cout << "No" << endl;
      return 0;
    }

  for (int i = 0; i < N/2; i++) {
    if (S[i] != S[i+(N/2)]) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Random;
import java.util.StringTokenizer;

class Main {

	static long mod=(long)1e9+7;
	public static void main(String[] args)
	{
		FastScanner in=new FastScanner();
	    int h=in.nextInt();
		int w=in.nextInt();
		char[][] grid=new char[h][w];
		long dp[][]=new long[h][w];
		for(int i=0;i<h;i++) {
			String x=in.next();
			for(int j=0;j<w;j++) {
				grid[i][j]=x.charAt(j);
			}
		}
		dp[0][0]=1;
		for(int i=0;i<h;i++)
		{
			for(int j=0;j<w;j++)
			{
				for(int row=i;row<=i+1;row++)
				{
					int col=j;
					if(row==i)
						col=j+1;
					if(row<h && col<w && grid[row][col]=='.') {
						dp[row][col]+=dp[i][j];
						dp[row][col]=dp[row][col]%mod;
					}
				}
			}
		}
		System.out.println(dp[h-1][w-1]);
	}
static final Random random=new Random();
	
	static void ruffleSort(int[] a) {
		int n=a.length;//shuffle, then sort 
		for (int i=0; i<n; i++) {
			int oi=random.nextInt(n), temp=a[oi];
			a[oi]=a[i]; a[i]=temp;
		}
		Arrays.sort(a);
	}
	
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		long nextLong() {
			return Long.parseLong(next());
		}
	}
}


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

int main()
{
    int x, y;
    cin >> x >> y;
    int leg;
    bool flug = false;
    rep(i, x + 1) {
        leg = 2*x+2*i;
        if (leg == y) {
            flug = true;
        }
    }
    if (flug) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3616
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <math.h>

int main(void) {

	int   i,N,cnt=0;

	scanf("%d",&N);
	char  S[N+1],tmp=0x00;

	scanf("%s",S);
	for(i=0;i<N;i++) {
		if(tmp==S[i]) continue;
	    tmp=S[i];cnt++;
	}
printf("%d",cnt);
return 0;
}


Measured memory_bytes: 256