akhauriyash/Code-Regression huggingface dataset:
M=1e9+7,D[101][64];
i,j,k,t,T;
main(n){
for(D[0][63]=scanf("%d",&n);T=i++<n;)for(j=0;k<4?:(k=0,++j<64);D[i][T]%=M)t=j*4+k++,D[i][T=t%64]+=T-9&&T-33&&T-6&&t-25&&t-41&&t-57&&t-37&&t-45?D[i-1][j]:0;
for(;j--;T%=M)T+=D[n][j];
printf("%d",T);
}
/////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
using namespace std;

typedef long long ll;
typedef unsigned long long llu;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<string, int> psi;
typedef pair<char, int> pci;
typedef pair<int, char> pic;
const ll MOD = (ll)1e9 + 7;
const long double PI = 3.141592653589793238462643383279502884197;

ll fac[1] = {1}, inv[1] = {1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll mp(ll a,ll b){ll ret=1;while(b){if(b&1)ret=ret*a%MOD;a=a*a%MOD;b>>=1;}return ret;}
ll cmb(ll r, ll c) {return fac[r] * inv[c] % MOD * inv[r - c] % MOD;}

int n,m,k;
int mat[3000][3000];
ll dp[3001][3001][4];

// 여깄는 아이템을 먹고간다 아니다.
ll go(int x, int y, int p) {
    if (x==n-1 && y==m-1) {
        if (p!=3) return mat[x][y];
        return 0;
    }
    if (dp[x][y][p] != -1) return dp[x][y][p];

    ll mav = 0;
    if (x!=n-1) {
        if (p!=3) mav = max(mav, go(x + 1, y, 0) + mat[x][y]);
        mav = max(mav, go(x+1,y,0));
    }
    if (y!=m-1) {
        if (p!=3) mav = max(mav, go(x, y+1, p+1) + mat[x][y]);
        mav = max(mav, go(x,y+1,p));
    }

    return dp[x][y][p] = mav;
}

int main() {
    memset(dp, -1, sizeof(dp));
    scanf("%d %d %d", &n, &m, &k);

    for (int i = 0; i < k; i++) {
        int a,b,c;
        scanf("%d %d %d", &a, &b, &c);
        a--; b--;
        mat[a][b] = c;
    }

    printf("%lld", go(0,0,0));
}

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

#define DATE_NUM 100

void readDate(int date[]) {
  int i, m, di;
  scanf("%d", &m);
  for (i=0; i<m; i++) {
    scanf("%d", &di);
    date[di]++;
  }
}

int getConvDate(int date[], int q){
  int i;
  int buf = 0, cdi = 0;
  for (i=DATE_NUM-1; i>=0; i--)
    if (date[i] >= buf && date[i] >= q) {
      buf = date[i];
      cdi = i;
    }
  return cdi;
}

void solve() {
  int n, q, m, cdi;
  int date[DATE_NUM];
  int i;

  while (1) {
    scanf("%d %d", &n, &q);
    if (n == 0 && q == 0) break;

    for (i=0; i<DATE_NUM; i++)
      date[i] = 0;
    while (--n >= 0) {
      readDate(date);
    }
    cdi = getConvDate(date, q);
    printf("%d\n", cdi);
  }
}

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

Measured memory_bytes: 600
s = input().split()
N = int(s[0])
A = int(s[1])
B = int(s[2])
k = 0
for i in range(1,N+1):
  S = 0
  p = str(i)
  q = [str(c) for c in p]
  q = list(map(int,q))
  for j in range(len(q)):
    S = S + q[j]
  if A <= S <= B:
    k = k + i
print(k)
    

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

long long int CC(long long int n)
{
	if(n<2)
	return 0;
	else
	return n*(n-1)/2;
}

int main()
{
	long long int N,x,c,y,sum;
	
	cin>>N;
	
	vector <long long int> A(N+1),B(N+1,0),C;
	
	for(int i=1;i<=N;i++)
	{
		cin>>x;
		A[i]=x;
	}
	
	for(int i=1;i<=N;i++)
	{
		B[A[i]]++;
	}
	
	sum=0;
	for(int i=1;i<=N;i++)
	{
		if(B[i]!=0 && B[i]!=1)
		{
			if(B[i]==2)
			sum++;
			else
			sum=sum+(B[i]*(B[i]-1))/2;
		}
	}
	
	for(int k=1;k<=N;k++)
	{
		x=B[A[k]];
		y=sum-CC(x)+CC(x-1);
		cout<<y<<"\n";
	}
	
	return 0;
}



Measured memory_bytes: 5760
#include "iostream"
#include "algorithm"
#include "vector"
#include "string"
#include "cmath"
typedef long long ll;
using namespace std;

int main(int argc, char const *argv[]) {
  ll NN;

  std::cin >> NN;

  ll AA, BB;
  std::cin >> AA >> BB;

  ll P[NN];
  for (size_t i = 0; i < NN; i++) {
    std::cin >> P[i];
  }

  ll under_A=0, under_B=0, other=0;

  for (size_t i = 0; i < NN; i++) {
    if (P[i] <= AA) {
      under_A++;
    }else{
      if (P[i] <= BB) {
        under_B++;
      }else{
        other++;
      }
    }
  }

  std::cout << min(under_A, min(under_B, other)) << '\n';


  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
using namespace std;
inline LL read()
{
	LL f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stack[20];
inline void write(int x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
inline void pr1(int x){write(x);putchar(' ');}
inline void pr2(int x){write(x);putchar('\n');}
int main()
{
	int a=read(),b=read(),c=read();
	if(a==b&&b==c)puts("Yes");
	else puts("No");
}



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

namespace AtCoder.Heuristics
{
    class Introduction
    {
        private static int DayN;

        private static int ContestN = 26;

        private static int[] c;

        private static int[][] s;

        private static int sumC;

        public static void Score(int[] t, int[] v)
        {
            var last = new int[DayN + 1];
            var sum = c.Sum();
            var dec = 0;
            v[0] = 0;
            for (int i = 1; i <= DayN; i++)
            {
                dec += sum - (c[t[i]] * (i - last[t[i]]));
                last[t[i]] = i;
                v[i] = v[i-1] - dec + s[i][t[i]];
            }
        }

        public static void Main()
        {
            DayN = int.Parse(Console.ReadLine());
            c = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            sumC = c.Sum();

            s = new int[DayN + 1][];

            List<int[]> gene = new List<int[]>();
            var t0 = new int[DayN + 1];
            var t1 = new int[DayN + 1];

            for (int i = 1; i <= DayN; i++)
            {
                s[i] = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
                for (int j = 0; j < ContestN; j++)
                {
                    if (s[i][t0[i]] < s[i][j])
                        t0[i] = j;
                    t1[i] = (i - 1) % ContestN;
                }
            }


            for (int i = 1; i <= DayN; i++)
                Console.WriteLine(t1[i] + 1);
        }
    }
}


Measured memory_bytes: 28860
n = int(input())
s = input()
flag = 0
if n%2 == 0:
    m = int(n/2)
    for i in range(m):
        if s[i] != s[m+i]:
            flag = 1

    if flag == 1:
        print("No")
    else:
        print("Yes")

else:
    print("No")

Measured memory_bytes: 3060
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <ctime>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <deque>
#include <complex>
#include <string>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <valarray>
#include <iterator>
using namespace std;
typedef long long int lli;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RREP(i,x) for(int i=(x);i>=0;i--)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) container.begin(), container.end()
#define SZ(container) ((int)container.size())

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

int d;

int check(vector<double> &v, int t, int s, double eps){
	double sum = 0;
	REP(j, v.size()){
		if(j==t||j==s) continue;
		double tmp = 1;
		REP(i, v.size()){
			if(i==t||i==s||i==j) continue;
			tmp*=(double)(s-i)/(j-i);
		}
		sum += v[j] * tmp;
	}
	return abs(v[s] - sum) < eps;
}

main(){
	int i,j;
	while(cin >> d, d){
		vector<double> v(d+3);
		REP(i, d+3) cin >> v[i];
		double l = 1e-9, r=1;
		while(1){
			double eps = sqrt(r/l)*l;
			int ans = -1;
			REP(i, d+3){
				if(check(v, i, i?0:1, eps)){
					if(ans == -1) ans = i;
					else ans = -2;
				}
			}
			if(ans >= 0){
				cout << ans << endl;
				break;
			}else if(ans == -1) l = eps;
			else r = eps;
		}
	}
	return 0;
}

Measured memory_bytes: 1232
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;

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

	vector<int> a(n);
	for (int i = 0; i < n; i++)
	{
		cin >> a.at(i);
	}

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

	int ans = a.at(n / 2) - a.at(n / 2 - 1);

	cout << ans << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

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

int main () {
  int n;
  cin >> n;
  
  bool ok = true;
  int tp = 0, xp = 0, yp = 0;
  rep(i,n) {
    int t, x, y;
    cin >> t >> x >> y;
    int dt = t - tp;
    int d = abs(x-xp) + abs(y-yp);
    if (dt < d) ok = false;
    if (dt%2 != d%2) ok = false;
  }

  puts(ok ? "Yes" : "No"); 
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define yn(x, ok, ng) cout << ((x)?(ok):(ng)) << endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int const INF = 1001001001;


// modint: mod 計算を int を扱うように扱える構造体
template<int MOD> struct Fp {
long long val;
constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
if (val < 0) val += MOD;
}
constexpr int getmod() { return MOD; }
constexpr Fp operator - () const noexcept {
return val ? MOD - val : 0;
}
constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
constexpr Fp& operator += (const Fp& r) noexcept {
val += r.val;
if (val >= MOD) val -= MOD;
return *this;
}
constexpr Fp& operator -= (const Fp& r) noexcept {
val -= r.val;
if (val < 0) val += MOD;
return *this;
}
constexpr Fp& operator *= (const Fp& r) noexcept {
val = val * r.val % MOD;
return *this;
}
constexpr Fp& operator /= (const Fp& r) noexcept {
long long a = r.val, b = MOD, u = 1, v = 0;
while (b) {
long long t = a / b;
a -= t * b; swap(a, b);
u -= t * v; swap(u, v);
}
val = val * u % MOD;
if (val < 0) val += MOD;
return *this;
}
constexpr bool operator == (const Fp& r) const noexcept {
return this->val == r.val;
}
constexpr bool operator != (const Fp& r) const noexcept {
return this->val != r.val;
}
friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
return os << x.val;
}
friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
if (n == 0) return 1;
auto t = modpow(a, n / 2);
t = t * t;
if (n & 1) t = t * a;
return t;
}
};

const int MOD = 998244353;
using mint = Fp<MOD>;

int main() {
int n,s;
cin >> n >> s;
vi a(n);
rep(i,n) cin >> a[i];

vector<vector<mint>> dp(3010,vector<mint>(3010,0));
dp[0][0] = 1;
rep(i,n) {
    rep(j,s+1) {
        dp[i+1][j] += (mint)2*dp[i][j];
        if(j + a[i] > s) continue;
        dp[i+1][j+a[i]] += dp[i][j];
    }
}
cout << dp[n][s] << endl;
return 0;
}

Measured memory_bytes: 74288
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    ll a,b,c,d,ans=-1e18;
    cin>>a>>b>>c>>d;
    ll x=a*c;
    ans=max(ans,x);
    x=a*d;
    ans=max(ans,x);
    x=b*c;
    ans=max(ans,x);
    x=b*d;
    ans=max(ans,x);
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 3660
# https://onlinejudge.u-aizu.ac.jp/problems/ALDS1_11_C

from collections import deque


class Data:
    def __init__(self, index, depth):
        super().__init__()
        self.index = index
        self.depth = depth


if __name__ == "__main__":
    n = int(input())
    d = {}
    for _ in range(n):
        u, k, *li = list(map(int, input().split()))
        d[u] = li

    queue = deque()

    result = {}
    for i in range(n):
        result[i+1] = -1

    depth = 0
    queue = deque()
    queue.appendleft(Data(index=1, depth=0))
    while queue:
        data = queue.pop()
        index = data.index
        depth = data.depth
        if result[index] != -1:
            continue
        result[index] = depth

        for child in d[index]:
            queue.appendleft(Data(index=child, depth=depth+1))

    for k, v in result.items():
        print(k, v)



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

#define pb push_back
#define mp make_pair
#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define sf(a) scanf("%d",&a);
#define sfl(a) scanf("%lld",&a);

bool vis[200005];
vector<int> v[200001];
int l[200001],p[200001];

void edge(int a, int b)
{
    v[a].pb(b);
    v[b].pb(a);
}
void bfs(int u)
{
    queue<int> q;
    q.push(u);
    vis[u] = true;
    int x;
    while (!q.empty()) {

        int f = q.front();
        q.pop();

        for (int i = 0; i < v[f].size(); i++){
            x = v[f][i];
            if(!vis[x]){
                q.push(x);
                l[x] = l[f] + 1;
                p[x] = f;
                vis[x] = true;
            }
        }
    }

}
void init(){
  for(int i = 0 ; i <= 2000; i++)
  l[i] = 0;

  for(int i = 0 ; i <= 2000 ; i++)
     v[i].clear();

}
int main(){
    ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
     int node, edg, a, b;
     cin >> node >> edg;
     for(int i = 0 ; i < edg; i++){
         cin >> a >> b;
         edge(a,b);
     }
     l[1] = 1;
     bfs(1);
     int c = 0;
     for(int i = 1 ; i <= node ; i++){
       if(vis[i])
          c++;
     }
     if(c == node){
      cout << "Yes" << endl;
      for(int i = 2 ; i <= node ; i++) cout << p[i] << endl;
     }
     else cout << "No" << endl;


    return 0;
}


Measured memory_bytes: 13372
def main():
    n = int(input())
    a = list(map(int, input().split(" ")))
    total_a = sum(a)
    total = 0
    for i in range(n):
        total_a-=a[i]
        total+=(a[i] * total_a)%(10**9+7)
    print(total%(10**9+7))

if __name__=="__main__":
    main()


Measured memory_bytes: 31748
#include <bits/stdc++.h>
#define ll long long int

using namespace std;

int main ()
{
	int a, b, ans = 0;
	cin >> a >> b;
	int cek = 1;
	while(cek < b){
		cek--;
		cek += a;
		ans++;
	}
	cout << ans << endl;
}

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

using namespace std;

int main()
{
	int n;
	cin >>n;
	vector<long long> a(n);

	for(int i = 0; i < n; ++i)
		cin >>a[i];

	bool st = true;
	int dir = 0, cnt = 0;
	for(int i = 0; i < n; ++i){
		if(st){
			++cnt;
			st = false;
			if(i + 1 < n){
				if(a[i + 1] > a[i])
					dir = 1;
				else if(a[i + 1] < a[i])
					dir = 2;
				else
					dir = 0;
				continue;
			}
		}
		
		if(i + 1 == n)
			continue;

		if(dir == 1){
			if(a[i + 1] < a[i])
				st = true;
		}
		else if(dir == 2){
			if(a[i + 1] > a[i])
				st = true;
		}
		else{
			if(a[i + 1] > a[i])
				dir = 1;
			else if(a[i + 1] < a[i])
				dir = 2;
			else
				dir = 0;
		}
	}
	cout <<cnt <<'\n';
	return 0;
}


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

int main(){
    int n,m,c;cin >> n >> m >> c;
    vector<int> b(m);
    rep(i,m) cin >> b[i];


    int res;
    int ans = 0;
    rep(i,n){
        res = c;
        rep(j,m){
        int a;cin >> a;
        res += a*b[j];
        }
        if(res>0)ans++;
    }

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

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

using namespace std;

typedef long long ll;

int main()

{
   ll a;
   cin>>a;



   ll ans = 0;

    ans += a/500 * 1000;

    a = a%500;

    ans += a/5 * 5;

    a = a%5;





   cout<<ans<<endl;




    return 0;
}


Measured memory_bytes: 256
using System;

public class S
{



    public static void Main()
	{
        var input = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        solver(input[0],input[1],input[2]);
    }

    public static void solver(int A, int B, int K){

        int cnt = 0;
        for(int i = (A > B ? B : A); i >=1 ; i--){
            if(A%i ==0 && B%i ==0){
                cnt++;
                if(cnt ==K){
                    Console.WriteLine(i);
                    return;
                }
            }
        }

    }

    public static long lower_bound(long[] array, long input){
        var left = 0;
        var right = array.Length-1;
        var mid =0;
        while(right >= left){
            mid = left + (right - left)/2;
            if(array[mid] == input){
                return mid;
            }
            if(array[mid] > input){
                right = mid-1;
            }else{
                left = mid+1;
            }
        }

        return right;
    }

}

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

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(((a<c)&&(c<b))||((b<c)&&(c<a))){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
	double debt = 100000.0;
	int n, r;
	cin >> n;
	while ( n-- > 0 ){
		debt *= 1.05;
		r = (int)debt % 1000;
		if ( r != 0 ){
			debt = debt - r + 1000;
		}
	}
	cout << (int)debt << endl;
	
	return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>
#include <string.h>

int main(void){
  char str[110];
  int i,j,k;
  while(scanf("%s",str)!=EOF){
    for(i=0;i<strlen(str);i++){
      if(str[i]=='@'){
	j=str[i+1]-48;
	for(k=0;k<j;k++){
	  printf("%c",str[i+2]);
	}
	i=i+2;
      }else{
	printf("%c",str[i]);
      }
    }
    printf("\n");
  }
  return 0;
}

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

int main(){
  int i,j,count=0,n,minj,x;
  int *A;

  scanf("%d",&n);

  if(n<1 || n>100)return 0;

  A = (int *)malloc(sizeof(int) * n);

for(i = 0;i < n;i++){
  scanf("%d",&A[i]);
    if(A[i]<0|| A[i]>100)return 0;
}

for(i = 0;i<n-1;i++){
     minj = i;
     for (j=i;j<n;j++){
       if(A[j] < A[minj]){
         minj = j;
       }
   }
   if(minj!=i){
   x=A[i];
  A[i] = A[minj];
  A[minj] = x;
  count++;
}
   }

   printf("%d",A[0]);
 for(i=1;i<n;i++){
   printf(" %d",A[i]);
 }
 printf("\n");
 printf("%d\n",count);

 return 0;

}



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

int main(){
  string s,key="keyence";
  cin >> s;
  int st=0,skp=s.size()-7;
  bool isky=false;
  for(int i=0;i<s.size();i++){
    string n="";
    for(int k=0;k<s.size();k++){
      if(k<st||k>=st+skp)
        n+=s.at(k);
      //cout << n << endl;
    }
    if(n=="keyence")
      isky=true;
    st++;
  }
  cout << (isky?"YES":"NO") << endl;
  return 0;
}

Measured memory_bytes: 3604
//DP.
//Refering to exp.
#include<iostream>
#include<string>
#include<vector>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;

int main(){
	int n;
	string s;
	cin>>n>>s;
	
	vvvi dp(n+1,vvi(4,vi(1000,0)));//0 or 1. dp[i][j][k]:最後に見た桁i,採用桁数j,文字列kのとき,この状態にできるかどうか.
	dp[0][0][0]=1;//point.
	REP(i,n)REP(j,4)REP(k,1000){
		if(dp[i][j][k]==0) continue;//REP(k).
		dp[i+1][j][k]=1;
		if(j<3) dp[i+1][j+1][10*k+s[i]-'0']=1;
	}
	
	int ans=0;
	REP(i,1000){
		if(dp[n][3][i]) ans++;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 474880
#include<stdio.h>

int main()
{
	int num[3], count[2]= {}, i;	//0: sum, 1: japanese, 2: foreigner
	char participant[100001];

	scanf("%d%d%d", &num[0], &num[1], &num[2]);
	scanf("%s", participant);

	for(i= 0; i< num[0]; i++)
	{
		switch(participant[i])
		{
			case 'a':
				if(count[0]< num[1]+ num[2])
				{
					printf("Yes\n");
					count[0]++;
				}
				else
					printf("No\n");

				break;

			case 'b':
				if(count[0]< num[1]+ num[2] && count[1]< num[2])
				{
					printf("Yes\n");
					count[0]++;
					count[1]++;
				}
				else
					printf("No\n");

				break;

			default:
				printf("No\n");
		}
	}

	return 0;
}

Measured memory_bytes: 640
n=gets.to_i
s=gets.chomp.split('')
t=s.count('E')
ans=1e6.to_i
n.times{|i|
  t+=1 if 0<i&&s[i-1]=='W'
  t-=1 if s[i]=='E'
  ans=[ans,t].min
}
p ans


Measured memory_bytes: 27396
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int max = 0;
		int min = 0;
		int N = scan.nextInt();
		int a[] = new int [N];
		for(int i = 0; i < N; i++) {
			a[i] = scan.nextInt();
		}
		max = a[0];
		min = a[0];
		for(int k = 1; k < N; k++) {
			if(max < a[k]) max = a[k];
			if(min > a[k]) min = a[k];
		}
		System.out.println(max - min);
		scan.close();
	}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
long long arr[1000000];
int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);   
    long long n,i,j,k,x,y,z;
    cin>>n;
    for (i=1;i<=100;i++)
    {
    	for (j=1;j<=100;j++)
    	{
    		for (k=1;k<=100;k++)
    		{
    			arr[i*i+j*j+k*k+i*j+j*k+k*i]++;
			}
		}
	}
	for (i=1;i<=n;i++)
	{
		cout<<arr[i]<<endl;
	}
}

Measured memory_bytes: 4032
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
int main(){
    string s,t;
    cin>>s>>t;
    string p=t.substr(0,t.length()-1);
    if(p==s){
        cout<<"Yes"<<endl;

    }
    else cout<<"No"<<endl;
}

Measured memory_bytes: 3628
package main

import (
	"fmt"
)

func main() {
	var n int
	var t, a float64
	fmt.Scan(&n, &t, &a)
	ans := 0
	var min float64 = 99999999
	for i := 1; i <= n; i++ {
		var v float64
		fmt.Scan(&v)
		diff := a - (t - v*0.006)
		if diff < 0.0 {
			diff *= -1.0
		}
		if diff < min {
			min = diff
			ans = i
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define R(i,a,n) for(int i=a;i<n;i++)
#define re(i,n) for(int i=n-1;i>=0;i--)
using namespace std;
#define INF 1<<29
int main(){
  int n;cin>>n;int s=0,i;
  for(i=0;i<=n;i++){
    if(i+1<=n+i||n-i==0){
      n-=i;
      //s++;
    }
    if(!n)break;
  }
  cout<<i<<endl;
}

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

int main() {
  string S;
  cin >> S;
  
  if (S == "Sunny") {
    cout << "Cloudy" << endl;
  }
  
  else if (S == "Cloudy") {
    cout << "Rainy" << endl;
  }
  else {
    
    cout << "Sunny" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    int A,B;
    cin >> A >> B;
    if (A == B){
        cout << "Draw" << endl;
    }
    else if (A == 1){
        cout << "Alice" << endl;
    }
    else if (B == 1){
        cout << "Bob" << endl;
    }
    else{
        if (A < B){
            cout << "Bob" << endl;
        }
        else{
            cout << "Alice" << endl;
        }
    }
}

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

int main()
{
    int k,s;
    while(cin >> k >> s)
    {
        int count = 0;
        int x,y,z;
        for(int i = 0;i <= k;i++)
        {
            for(int j = 0;j <= k;j++)
            {
                if(s - i - j >= 0 && s - i - j <= k)
                count++;
            }
        }
        cout << count << endl;
    }
    return 0;
}


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

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        var vs = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();

        const int size = 1 + (int)1e5;
        var bucket = new [] { new int[size], new int[size] };
        for (int i = 0; i < vs.Length; i++)
        {
            bucket[i % 2][vs[i]]++;
        }
        var vss = new [] { new int[2], new int[2] };
        var kss = new [] { new int[2], new int[2] };
        for (int i = 0; i < bucket.Length; i++)
        {
            for (int j = 0; j < bucket[i].Length; j++)
            {
                if (bucket[i][j] <= kss[i][1])
                {
                    continue;
                }

                int k = 1;
                if (bucket[i][j] > kss[i][0])
                {
                    vss[i][1] = vss[i][0];
                    kss[i][1] = kss[i][0];
                    k = 0;
                }
                vss[i][k] = j;
                kss[i][k] = bucket[i][j];
            }
        }
        if (vss[0][0] == vss[1][0])
        {
            int i = kss[0][1] < kss[1][1] ? 1 : 0;
            kss[i][0] = kss[i][1];
        }
        Console.WriteLine(n - kss[0][0] - kss[1][0]);
    }
}

Measured memory_bytes: 20960
# 参考: https://qiita.com/y-tsutsu/items/aa7e8e809d6ac167d6a1

import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

# 多次元配列
# dp = [[0] * 3 for _ in range(5)]

# 入力を受け取る
s = input()

l = len(s)

w = len(list(filter(lambda c: c == 'o', s)))

print('YES' if 15 - l + w >= 8 else 'NO')


Measured memory_bytes: 3956
import java.util.*;
 
public class Main { //クラス名はMain
    public static void main(String[] args) {
      //整数の入力
      Scanner sc = new Scanner(System.in);
	  String n = sc.next();
      String a = "a";
      int goodCount = 0;
      for(int i=0; i<4; i++){
        //一緒だったらカウントする
      	if(a.equals(n.substring(i,i+1))) {
          goodCount++;
        }else if(i>1){
          break;
        }
        //文字確認する値を一つズラす
        a = n.substring(i,i+1);
      }
      if(goodCount >= 2){
        System.out.println("Yes");
      }else{
        System.out.println("No");
      }
    }     
}

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

int main(){
  int N;
  cin >> N;
  vector<int> C;
  vector<int> S;
  vector<int> F;
  for(int i = 0;i < N-1;i++){
    int c,s,f;
    cin >> c >> s >> f;
    C.push_back(c);
    S.push_back(s);
    F.push_back(f);
  }


  for(int i = 0;i < N;i++){
    int now_t = 0;

    for(int j = i;j < N - 1;j++){

      if(now_t >= S[j]){
        now_t += (now_t % F[j] == 0 ? 0 : F[j] - now_t % F[j]);
      }
      else now_t = S[j];

      now_t += C[j];
    }

    cout << now_t << endl;
  }

  
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/abc178/tasks/abc178_c

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

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DEBUG 0
#if DEBUG
  #define _GLIBCXX_DEBUG
  #define DUMP(a) REP(_i, a.size()) cout << a[_i] << (_i + 1 == a.size() ? "\n" : " ")
  #define DUMP2D(b) REP(_j, b.size()) DUMP(b[_j]); cout << endl
#else
  #define DUMP(a)
  #define DUMP2D(b)
#endif

const int N_MAX = 1e6;
const ll MOD = 1e9+7;

int N;

int main() {
  cin >> N;

  vector<vector<ll>> dp = vector<vector<ll>>(N + 1, vector<ll>(3, 0));

  dp[0][0] = 1;
  REP(i, N) {
    dp[i + 1][0] = dp[i][0] * 8 % MOD;
    dp[i + 1][1] = (dp[i][0] * 2 + dp[i][1] * 9) % MOD;
    dp[i + 1][2] = (dp[i][1] + dp[i][2] * 10) % MOD;
  }

  DUMP2D(dp);

  cout << dp[N][2] << endl;
}


Measured memory_bytes: 57752
#include<cstdio>
#include<iostream>
using namespace std;
char str[20];
int main()
{
	scanf("%s",str);
	for(int i=0;i<19;i++)
	{
		if(i==5||i==13)
		 cout<<" ";
		 else
		 cout<<str[i];
	}
	return 0;
}

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

int main() {
    //
    int num;
    int bin;
    cin >> num >> bin;

    map<int, int> m;

    for (int i = 0; i < bin; i++) {
        int tmp1, tmp2;
        cin >> tmp1 >> tmp2;

        if (tmp1 == 1) {
            m[tmp2]++;
        } else if (tmp2 == num) {
            m[tmp1]++;
        }
    }

    for (auto itr : m) {
        if (itr.second >= 2) {
            cout << "POSSIBLE";
            return 0;
        }
    }

    cout << "IMPOSSIBLE";
}

Measured memory_bytes: 12816
#include "bits/stdc++.h"

using namespace std;


int n;
int res = 0;
int x;
int cur = 1;

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

    for (int i = 0; i < n; ++i) {
        scanf("%d",&x);
        if (x == cur) {
            ++cur;
        }
        else ++res;
    }
    if (res == n) res = -1;
    printf("%d\n", res);
    return 0;


}

Measured memory_bytes: 256
d = [0 for _ in range(4)]

for i in range(3):
    a, b = map(int, input().split())
    d[a-1] += 1
    d[b-1] += 1

count = 0
for i in range(4):
    if d[i] % 2 == 1:
        count += 1

if count > 2:
    print('NO')
else:
    print('YES')

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

int main(){
  int n; cin >> n;
  string s; cin >> s;
  for (int i = 0; i < s.size(); i++){
    if (s.at(i) + n > 'Z') s.at(i) = 'A' + s.at(i) + n - 'Z' - 1;
    else s.at(i) = s.at(i) + n;
  }
  cout << s << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define itn int
#define For(a,b,c,t)  for(ri a=b;a<=c;a+=t)
#define Memset(a,b)  memset(a,b,sizeof(a))
#define ri register int
#define il inline long long
#define li long long
using namespace std;
string a;
int main()
{
	cin>>a;
	int len=a.size();
	int flag=0;
	For(i,0,len-1,1)
	{
		if(a[i]=='C'&&flag==0)
		  flag=1;
		if(a[i]=='F'&&flag==1)
		  flag=2;
		if(flag==2)
		{
			printf("Yes");
			exit(0);
		}
	}
	printf("No");
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(void)
{
    string s;

    cin >>s;

    int mlength = 0;

    string acgt = "ACGT";

    for(int i = 0; i < s.size(); i++){
        int clength = 0;
        for(int j = i; j < s.size(); j++){
            bool isAcgt = false;
            for(int k = 0; k < 4; k++){
                if(s[j] == acgt[k]){
                    isAcgt = true;
                }
            }
            if(isAcgt){
                clength++;
                mlength = max(mlength, clength);
            }else{
                break;
            }
        }
    }
    printf("%d\n", mlength);

    return 0;
}

Measured memory_bytes: 256
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;


int main(){
    ll n;
    cin>>n;
    vector<ll> A(n);
    for(auto &I:A){cin>>I;}
    vector<vector<ll>> dp(n);
    for(ll i=1;i<n;i++){
        dp[i].push_back(0);
        for(ll t=1;i*t<n;t++){
            ll x=dp[i].back();
            dp[i].push_back(x+A[n-1-i*t]);
        }
    }
    ll sum;
    ll ans=0;
    for(ll i=1;i<n;i++){
        sum=0;
        for(ll t=1;i*t<n;t++){
            sum+=A[i*t];
            ll a=(n-1-i*t);
            if(a<=i){continue;}
            if(a%i!=0 || i*t<a){
                ans=max(ans,sum+dp[i][t]);
            }
        }
    }
    cout<<ans<<endl;
    
    
    return 0;
}


Measured memory_bytes: 17440
import java.util.*;

public class Main {
	static boolean[] visited;
	static HashSet<Integer> used = new HashSet<>();
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
	    ArrayList<HashMap<Integer, Integer>> graph = new ArrayList<>();
		for (int i = 0; i < n; i++) {
		    graph.add(new HashMap<>());
		}
		for (int i = 0; i < n - 1; i++) {
		    int a = sc.nextInt();
		    int b = sc.nextInt();
		    int c = sc.nextInt();
		    graph.get(a).put(b, c);
		    graph.get(b).put(a, c);
		}
		PriorityQueue<Path> queue = new PriorityQueue<>();
		int[] costsA = new int[n];
		queue.add(new Path(0, 0));
		search(costsA, queue, graph);
		int maxA = 0;
		int maxIdxA = 0;
		for (int i = 0; i < n; i++) {
		    if (maxA < costsA[i]) {
		        maxA = costsA[i];
		        maxIdxA = i;
		    }
		}
		queue.add(new Path(maxIdxA, 0));
		int[] costsB = new int[n];
		search(costsB, queue, graph);
		Arrays.sort(costsB);
		System.out.println(costsB[n - 1]);
	}
	
	static void search(int[] costs, PriorityQueue<Path> queue, ArrayList<HashMap<Integer, Integer>> graph) {
	    Arrays.fill(costs, Integer.MAX_VALUE);
	    while (queue.size() > 0) {
	        Path p = queue.poll();
	        if (costs[p.idx] <= p.value) {
	            continue;
	        }
	        costs[p.idx] = p.value;
	        for (Map.Entry<Integer, Integer> entry : graph.get(p.idx).entrySet()) {
	            queue.add(new Path(entry.getKey(), entry.getValue() + p.value));
	        }
	    }
	}
	
	static class Path implements Comparable<Path> {
	    int idx;
	    int value;
	    
	    public Path (int idx, int value) {
	        this.idx = idx;
	        this.value = value;
	    }
	    
	    public int compareTo(Path another) {
	        return value - another.value;
	    }
	}
}



Measured memory_bytes: 131508
# -*- coding: utf-8 -*-
"""
Prime Quadruplet
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0222

"""
import sys

from bisect import bisect_right

limit = 10**7
sieve = [True] * limit
sieve[0] = sieve[1] = False
for i in range(4, limit, 2):
    sieve[i] = False
for i in range(3, int(len(sieve)**0.5)+1, 2):
    if sieve[i]:
        for i in range(i**2, limit, i):
            sieve[i] = False
primes = [i for i, x in enumerate(sieve) if x]
s_primes = set(primes)

quadruplet_primes = [13]
for p in primes:
    if p % 10 == 1 and p+2 in s_primes and p+6 in s_primes and p+8 in s_primes:
        quadruplet_primes.append(p + 8)


def main(args):
    while True:
        n = int(input())
        if n == 0:
            break
        print(quadruplet_primes[bisect_right(quadruplet_primes, n) - 1])


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


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

int main() {
  int x1, x2, x3, x4, x5, ans;
  cin >> x1 >> x2 >> x3 >> x4 >> x5;
  if(x1 == 0) {
    ans = 1;
  } else if(x2 == 0) {
    ans = 2;
  } else if(x3 == 0) {
    ans = 3;
  } else if(x4 == 0) {
    ans = 4;
  } else {
    ans = 5;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
long long f[101][100001]={0};
int w[101],v[101];
int main()
{
	int n,W,i,j;
	scanf("%d %d",&n,&W);
	for(i=1;i<=n;i++)
		scanf("%d %d",&w[i],&v[i]);
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=W;j++)
		{
			if(j<w[i])
				f[i][j]=f[i-1][j];
			else
				f[i][j]=max(f[i-1][j],f[i-1][j-w[i]]+v[i]);
		}
	}
	printf("%lld",f[n][W]);
	return 0;
}

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

const int N = 1e5 + 5;

int n, a[N];
long long L, R;

long long get(long long val) {
	for (int i = 1; i <= n; ++i) {
		val = val - val % a[i];
	}
	return val;
}

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

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

	long long low = 1, high = 1e18;
	while(low < high) {
		long long mid = ((low + high + 1) >> 1);
		if (get(mid) <= 2) low = mid; else high = mid - 1;
	}

	if (get(low) == 2) R = low; else return cout << -1 << endl, 0;

	low = 1, high = R;
	while(low < high) {
		long long mid = ((low + high) >> 1);
		if (get(mid) >= 2) high = mid; else low = mid + 1;
	}

	L = low;

	cout << L << ' ' << R << endl;
}

Measured memory_bytes: 768
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cmath>
#include <numeric>
#include <utility>
#include <iomanip>

using namespace std;
using int64 = long long;
using TP = tuple<int, int, int>;

struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;

int main() {
    int h, w, ch, cw, dh, dw;
    cin >> h >> w >> ch >> cw >> dh >> dw;
    ch--; cw--; dh--; dw--;
    vector<string> s(h);
    for (int i=0; i<h; i++) cin >> s[i];

    vector cnt(h, vector(w, INT_MAX));
    cnt[ch][cw] = 0;
    priority_queue<TP, vector<TP>, greater<>> que;
    que.emplace(0, ch, cw);

    vector vy = {-1, 1, 0, 0};
    vector vx = { 0, 0,-1, 1};
    while (!que.empty()) {
        auto [c, y, x] = que.top();
        que.pop();

        // if (y == dh && x == dw) break;
        
        for (int i=0; i<4; i++) {
            int yy = y + vy[i];
            int xx = x + vx[i];
            if (yy<0 || h<=yy || xx<0 || w<=xx) continue;
            if (s[yy][xx] == '#') continue;
            if (cnt[yy][xx] <= c) continue;

            cnt[yy][xx] = c;
            que.emplace(c, yy, xx);
        }

        for (int i=-2; i<=2; i++) {
            for (int j=-2; j<=2; j++) {
                if (abs(i)+abs(j) <= 1) continue;
                int yy = y + i;
                int xx = x + j;
                if (yy<0 || h<=yy || xx<0 || w<=xx) continue;
                if (s[yy][xx] == '#') continue;
                if (cnt[yy][xx] <= c+1) continue;

                cnt[yy][xx] = c+1;
                que.emplace(c+1, yy, xx);
            }
        }
    }

    if (cnt[dh][dw] == INT_MAX)
        cout << -1 << endl;
    else
        cout << cnt[dh][dw] << endl;
}


Measured memory_bytes: 8612
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  if ((s[0]==s[1])||(s[1]==s[2])||(s[2]==s[3])){
    cout << "Bad" << endl;
    return 0;
  }
  cout << "Good" << endl;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/agc017/tasks/agc017_a
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(size_t i = 0; i < (n); ++i)

int main()
{
    int N, P;
    cin >> N >> P;
    vector<ll> A(N);
    int even = 0;
    REP(i, N)
    {
        cin >> A[i];
        if (A[i] % 2 == 0) ++even;
    }
    if (even == N)
    {
        if (0 == P)
        {
            ll ans = 1;
            REP(i, N)
            {
                ans *= 2;
            }
            printf("%lld\n", ans);
            return 0;
        }
        else
        {
            printf("0\n");
            return 0;
        }
    }

    ll ans = 1;
    for (int i = 1; i <= N - 1; ++i)
    {
        ans *= 2;
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 3692
#include <bits/stdc++.h>
using namespace std;
#define quick ios::sync_with_stdio(false);cin.tie();

int main() 
{
  cout << fixed << setprecision(15);
  int64_t n;
  cin >> n;
  int64_t a = 100;
  for (int i = 1; 1; i++) 
  {
    a *= 1.01;
    if (a >= n) {
      cout << i << "\n";
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 3636
while True:
    n, x = map(int, input().split())
    if n == x == 0:
        break
    else:
        counter = 0

        for i in range(1, n-1):
            for j in range(i+1, n):
                if j<x-i-j<=n:
                    counter += 1
        
        print(counter)


Measured memory_bytes: 5596
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <string>
#include <cmath>
#include <iomanip>
#include <cstdio>
using namespace std;

int a,b,c;

int main(){
	cin>>a>>b>>c;
	int cum = 0;
	int res = 0;
	for(int i= min(a,b);i>=1;i--){
		if(a%i==0&&b%i==0){
			cum++;
			if(cum==c){
				res = i;
				cout<<res<<endl;
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for (int i = 0; i < (n); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=1<<30;
const int mod=1e9+7;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m,l;cin >> n >> m >> l;
    vector<vector<ll>> d(n,vector<ll>(n,INF));
    rep(i,n){
        d[i][i]=0;
    }
    rep(i,m){
        int a,b,c;cin >> a >> b >> c;
        a--,b--;
        d[a][b]=d[b][a]=c;
    }
    rep(i,n){
        rep(j,n){
            rep(k,n){
                chmin(d[j][k],d[j][i]+d[i][k]);
            }
        }
    }
    vector<vector<ll>> e(n,vector<ll>(n,INF));
    rep(i,n){
        e[i][i]=0;
    }
    rep(i,n){
        rep(j,n){
            if(d[i][j]<=l){
                e[i][j]=1;
            }
        }
    }
    rep(i,n){
        rep(j,n){
            rep(k,n){
                chmin(e[j][k],e[j][i]+e[i][k]);
            }
        }
    }
    int q;cin >> q;
    while(q--){
        int s,t;cin >> s >> t;
        s--,t--;
        cout << (e[s][t]!=INF?e[s][t]-1:-1) << endl;
    }
}

Measured memory_bytes: 1920
#include<iostream>
#include<algorithm>
using namespace std;
int main(void){
    int N,w;
    long long W,v;
    cin>>N>>W;
    long long A[N+1][W+1];

    for(int i=0;i<=W+1;i++){
        A[0][i]=0;
    }
    

    for(int i=1;i<=N;i++){
        cin>>w>>v;
        for(int j=0;j<=W+1;j++){
            if(w>j){
                A[i][j]=A[i-1][j];
            }else{
                A[i][j]=max(A[i-1][j],v+A[i-1][j-w]);

            }
            

        }
    }
    
    
    cout<<A[N][W]<<endl;


    return 0;
}

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

using namespace std;

int main()
{
    long long n,m,a,b,i,j=0;
    cin>>n>>m;
    vector < pair<int,int> > ab;
    for(i=0; i<n; i++)
    {
        cin>>a>>b;
        ab.push_back(make_pair(a,b));
    }
    priority_queue <long long> pq;
    sort(ab.begin(),ab.end());
    long long count=0;
    for(i=1; i<=m; i++)
    {
        for(; ab[j].first==i; j++)
        {
            pq.push(ab[j].second);
        }
        if(pq.size())
        {
            count+=pq.top();
            pq.pop();
        }
    }
    cout<<count;
}


Measured memory_bytes: 2548
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define vll vector<long long int> 
#define pb push_back
#define f(i,x,n) for (i=x;i<n;i++)


void solve(){
    string s;
    cin >> s;
    if(s[s.size()-1]!='s'){
        s+="s";
        cout << s;
        return;
    }
    else{
   
    s+="es";
    cout << s;}
}
int main(){
	ios_base::sync_with_stdio(false); 
     	cin.tie(NULL);
	int t=1;;

	while(t--)
	solve();	
	
}

Measured memory_bytes: 3640