akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/hash_map>
#include <ext/numeric>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define REP(i,n) for( (i)=0 ; (i)<(n) ; (i)++ )
#define rep(i,x,n) for( (i)=(x) ; (i)<(n) ; (i)++ )
#define REV(i,n) for( (i)=(n) ; (i)>=0 ; (i)-- )
#define FORIT(it,x) for( (it)=(x).begin() ; (it)!=(x).end() ; (it)++ )
#define foreach(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define rforeach(it,c) for(__typeof((c).rbegin()) it=(c).rbegin();it!=(c).rend();++it)
#define foreach2d(i, j, v) foreach(i,v) foreach(j,*i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define SZ(x) ((int)(x).size())
#define MMS(x,n) memset(x,n,sizeof(x))
#define mms(x,n,s) memset(x,n,sizeof(x)*s)
#define pb push_back
#define mp make_pair
#define NX next_permutation
#define UN(x) sort(all(x)),x.erase(unique(all(x)),x.end())
#define CV(x,n) count(all(x),(n))
#define FIND(x,n) find(all(x),(n))-(x).begin()
#define ACC(x) accumulate(all(x),0)
#define PPC(x) __builtin_popcountll(x)
#define LZ(x) __builtin_clz(x)
#define TZ(x) __builtin_ctz(x)
#define mxe(x) *max_element(all(x))
#define mne(x) *min_element(all(x))
#define low(x,i) lower_bound(all(x),i)
#define upp(x,i) upper_bound(all(x),i)
#define NXPOW2(x) (1ll << ((int)log2(x)+1))
#define PR(x) cout << #x << " = " << (x) << endl ;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> pii;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int OO = (int) 2e9;
const double eps = 1e-9;

const int N = 1e7 + 7;

int n;
int a[N];
ll v[N];
bool p[N];

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
//	freopen("in.txt", "rt", stdin);
//	freopen("out.txt", "wt", stdout);
#endif
	cin >> n;
	n++;
	for (int i = 0; i < n; i++) {
		a[i] = i;
		v[i] = 1;
		p[i] = 1;
	}
	p[0] = p[1] = 0;
	for (int i = 2; i < n; i++) {
		if (p[i]) {
			v[i] = 2;
			for (int j = i * 2; j < n; j += i) {
				int cur = 1;
				while (a[j] % i == 0) {
					a[j] /= i;
					cur++;
				}
				v[j] *= cur;
				p[j] = 0;
			}
		}
	}
	ll res = 0;
	for (int i = 1; i < n; i++) {
		res += i * v[i];
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 130620
#include <bits/stdc++.h>
using namespace std;
using in6 = int64_t;
using ind = double;
using vi = vector<in6>;
using vii = vector<vi>;
using vs = vector<string>;
using pii = pair<in6,in6>;
using psi = pair<string,in6>;
using vpi = vector<pii>;
using vps = vector<psi>;
#define rep(i, n) for (in6 i = 0; i < (in6)(n); i++)
#define repa(i,a,n) for(in6 i = a; i < (in6)(n); i++)
#define repdown(i,n) for(in6 i = n; i > 0; i--)
#define kyun ios::sync_with_stdio(false)
#define hinata cout << "\n"
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define inf 2147483647
#define dset(n) cout << fixed << setprecision(n)
#define mod 1000000007

void yes() {
  cout << "Yes";
}

void no() {
  cout << "No";
}

int main() {
  kyun;
  in6 n,m;
  cin >> n >> m;
  vi ans(n+1);
  ans[0] = 1;
  vector<bool> data(n+1,true);
  in6 a;
  while(cin >> a) data[a] = false;
  repa(i,1,n+1) {
    if(data[i]) ans[i] += (ans[i-1]%mod);
    if(i != n && data[i+1]) ans[i+1] += (ans[i-1]%mod);
  }
  cout << ans[n]%mod;
  hinata;
}

Measured memory_bytes: 1024
def main():
    N = int(input())
    H = [int(i) for i in input().split()]
    for i in range(N-1)[::-1]:
        if H[i] > H[i+1]:
            H[i] -= 1
            if H[i] > H[i+1]:
                return print("No")
    print("Yes")


if __name__ == '__main__':
    main()


Measured memory_bytes: 63984
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e5+7;
ll mod=1e9+7;
ll n,k;
ll sum;
int main()
{
    cin>>n>>k;
    for(int i=k;i<=n+1;i++){
        sum=(sum+i*(n+1-i)+1)%mod;
       // cout<<sum<<endl;
    }
    cout<<sum<<endl;
    return 0;
}


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

int main()
{
  string s;
  cin >> s;
  auto a = std::count(s.begin(), s.end(), s[0]);
  auto b = std::count(s.begin(), s.end(), s[1]);
  auto c = std::count(s.begin(), s.end(), s[2]);
  auto d = std::count(s.begin(), s.end(), s[3]);
  if (a == b && c == d && d == a && b == 2) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


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

using namespace std;

int main() {
	int n, a[106];
	int Max = -1;
	int Min = 1e9;
	cin >> n;
	for (int i = 0; i < n; ++i){
		cin >> a[i];
		Max = max(Max, a[i]);
		Min = min(Min, a[i]);
	}
	cout << Max - Min;
	return 0;
}

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

int main(){
  int n;cin>>n;
  vector<int>h(n+1);
  vector<int>p(n+1);
  for(int i=1;i<=n;i++)
    cin>>h.at(i);
  for(int i=1;i<=n;i++)
    p.at(h.at(i))=i;
  for(int i=1;i<=n;i++)
    cout<<p.at(i)<<" ";
  
}

Measured memory_bytes: 1536
# ABC079c
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)

n = input()[:-1]


def dfs(pos, formula):
    if (pos > 3):
        # print(formula)
        return formula if eval(formula) == 7 else False
    #print(pos, n[pos])
    f = dfs(pos + 1, formula + '+'+n[pos])
    if (not f):
        return dfs(pos + 1, formula + '-'+n[pos])
    else:
        return f


print(dfs(1, n[0])+'=7')

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;

bool bipartite_matching_dfs(
	int v, const vector< vector<int> > &conn,
	vector<bool> &used, vector<int> &match)
{
	used[v] = true;
	for(int i = 0; i < conn[v].size(); ++i){
		int u = conn[v][i], w = match[u];
		if(w < 0 || !used[w] && bipartite_matching_dfs(w, conn, used, match)){
			match[v] = u;
			match[u] = v;
			return true;
		}
	}
	return false;
}
int bipartite_matching(const vector< vector<int> > &conn){
	int res = 0;
	vector<int> match(conn.size(), -1);
	vector<bool> used(conn.size(), false);
	for(int v = 0; v < conn.size(); ++v){
		if(match[v] < 0){
			fill(used.begin(), used.end(), false);
			if(bipartite_matching_dfs(v, conn, used, match)){ ++res; }
		}
	}
	return res;
}

int main(){
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> w(n), h(n);
	for(int i = 0; i < n; ++i){ cin >> w[i] >> h[i]; }
	vector< vector<int> > conn(2 * n);
	for(int i = 0; i < n; ++i){
		for(int j = 0; j < n; ++j){
			if((w[j] < w[i] && h[j] < h[i]) || (h[j] < w[i] && w[j] < h[i])){
				conn[i].push_back(n + j);
			}
		}
	}
	cout << n - bipartite_matching(conn) << endl;
	return 0;
}


Measured memory_bytes: 1248
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define FOR(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v),end(v)
#define debug(x) std::cerr<<#x<<": "<<x<<"\n"
#define debug2(x,y) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<"\n"
#define debug3(x,y,z) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<", "<<#z<<": "<<z<<"\n"

using ll=long long;
using vi=std::vector<int>;
using vvi=std::vector<vi>;
using vll=std::vector<ll>;
using vvll=std::vector<vll>;
template<typename T> using vvec=std::vector<std::vector<T>>;
template<typename T>
auto make_v(size_t sz){return std::vector<T>(sz);}
template<typename T,typename... Ts>
auto make_v(size_t sz,Ts...ts){return std::vector<decltype(make_v<T>(ts...))>(sz,make_v<T>(ts...));}
template<typename T>
void fill_v(T&var,const T&x){var=x;}
template<typename V,typename T>
void fill_v(V&v,const T&x){for(auto&& w:v){fill_v(w,x);}}

template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<std::vector<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<std::deque<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s, const std::set<T>&v){
  s<<"\n";for(auto&& elm:v){s<<elm<<"\t";}s<<"\n";return s;}

inline void scan(int&a){scanf("%d",&a);}
inline void scan(ll&a){scanf("%lld",&a);}
inline void scan(char&a){scanf(" %c",&a);}
inline void scan(double&a){scanf("%lf",&a);}
inline void scan(std::string&s){char BUF[3000000];scanf(" %s",BUF);s=std::string(BUF);}
template<typename T>
inline void scan(std::vector<T>&v){for(auto&& sv:v){scan(sv);}}
template<typename First,typename...Args>
inline void scan(First&f,Args&...args){scan(f);scan(args...);}
inline void print(int a){printf("%d\n",a);}
inline void print(ll a){printf("%lld\n",a);}
inline void print(double a){printf("%.12f\n",a);}
inline void print(std::string s){std::cout<<s<<"\n";}

using namespace std;

int main() {
  ll w, h, x, y;
  scan(w, h, x, y);
  printf("%.2f ", (double)w * h / 2.0);

  int cond = 0;
  if (x * 2 == w && y * 2 == h) {
    cond = 1;
  }
  print(cond);

  return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  string s; cin >> s;
  string str = "ACGT";
  int n = s.size();
  int res = 0;
  for (int l = 0; l < n; ++l) {
    for (int r = l + 1; r <= n; ++r) {
      auto t = s.substr(l, r - l);
      if (all_of(begin(t), end(t), [&](char c) { return str.find(c) != string::npos; })) {
        res = max(res, r - l);
      }
    }
  }
  cout << res << '\n';
}

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

using namespace std;

#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define cl(x,v) memset((x), (v), sizeof(x))
#define db(x) cerr << #x << " == " << x << endl
#define dbs(x) cerr << x << endl
#define _ << ", " <<

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<int, pii> piii;
typedef pair<ll,ll> pll;
typedef pair<ll, pll> plll;
typedef vector<int> vi;
typedef vector <vi> vii;

const ld EPS = 1e-9, PI = acos(-1.);
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const int INF = 0x3f3f3f3f, MOD = 1e9+7;
const int M = 1e5+5, N = 105;

ll w[N],v[N],dp[N][M],n,s;

void call_dp(){
    //percorrendo os n elementos candidatos a ser colocados na bolsa
    for(int i=0;i<n;i++){
        //para cada tamanho de bolsa, verificando a condição da dp
        for(int j=0;j<=s;j++){
            if(i == 0) {if(w[i] <= j) dp[i][j] = v[i];}
            else{
                //carrega o resultado da dp usando os i-1 primeiros elementos
                dp[i][j] = dp[i-1][j];
                // se o elemento couber na bolsa, verifica a condição da dp
                if(w[i] <= j) dp[i][j] = max(dp[i][j], v[i] + dp[i-1][j-w[i]]);
            }
        }
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> s;
    for(int i=0;i<n;i++){
        cin >> w[i] >> v[i];
    }
    call_dp();
    ll ans = 0;
    for(int i=0;i<=s;i++){
        ans = max({ans,dp[n-1][i]});
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 80128
#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 n;
  cin >> n;
  auto f = [&](ll x){
    return x * (x + 1) / 2;
  };

  ll ans = 0;
  for (ll i = 1; i <= n; i++) {
    ans += i * f(n / i);
  }

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

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define RREP0(i, n) for (int i = (n)-1; i >= 0; --i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define RREP1(i, n) for (int i = (n); i >= 1; --i)
#define pow10(n) int(1e##n + n)

typedef long long LL;
typedef pair<int, int> P;

const int INTINF = int(1e9) + 1;
const LL LLINF = LL(1e18) + 1;
long double eps = 1.0E-14;

void solve()
{
    LL X;
    cin >> X;
    LL money = 100;
    LL year = 0;
    while (money < X)
    {
        money += (money / 100);
        year++;
    }
    std::cout << year << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(20);
    solve();
    return 0;
}


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

#ifndef DEBUG
#define dump(...)
#endif

signed main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);

    size_t N;
    std::cin >> N;

    std::vector<int> a(N + 1);
    for (size_t i = 1; i <= N; ++i) {
        std::cin >> a[i];
    }

    std::vector<int> buff;
    std::vector<int> x(N + 1);
    for (size_t i = N; i >= 1; --i) {
        int cnt = 0;
        for (size_t j = i; j <= N; j += i) {
            cnt += x[j];
        }
        if (cnt % 2 != a[i]) {
            x[i] = 1;
            buff.emplace_back(i);
        }
    }

    std::cout << buff.size() << "\n";
    for (auto &bi : buff) {
        std::cout << bi << (&bi == &buff.back())[" \n"];
    }

    return 0;
}


Measured memory_bytes: 3192
#include <bits/stdc++.h>
#define ll long long int
#define mod 1000000007
#define mls 100000
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
int main(){
	fast
	
	double a,b,n;
	cin>>a>>b>>n;
	int ans=ceil(n/max(a,b));
	cout<<ans<<endl;
}
	
	
	
	
	
	
	


Measured memory_bytes: 256
from collections import deque


MOD = 10 ** 9 + 7

def main():
    n = int(input())
    ds = [input(), input()]

    total = 1
    i = 0

    while i < n:
        if ds[0][i] == ds[1][i]: # vertical segment
            if i == 0: # first element, 3 colors
                x = 3
            else:
                if ds[0][i - 1] == ds[1][i - 1]: # previous segment vertical, 2 colors
                    x = 2
                else:
                    x = 1
        else: # horizontal segment
            if i == 0: # first element, 3 * 2 = 6 colorings
                x = 6 
            else:
                if ds[0][i - 1] == ds[1][i - 1]: # previous segment vertical, 2 colors
                    x = 2
                else:
                    x = 3

            i += 1

        total = (total * x) % MOD

        i += 1

    print(total)


if __name__ == "__main__":
    main()

Measured memory_bytes: 38408
/* C - Replacing Integer */

#include <stdio.h>

long long absolute(long long a, long long b){
  if(a >= b) return a - b;
  else return b - a;
}

long long Replace(long long n, long long k){
  if(n == k){
    return 0;
  }else if(n > k){
    return Replace(n % k, k);
  }else{
    if(n <= absolute(n, k)) return n;
    else return absolute(n, k);
  }
}

int main(void){
  long long N, K;
  scanf("%lld %lld", &N, &K);
  printf("%lld", Replace(N, K));
}


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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0); 
  string s;
  cin >> s;
  int ans = 0;
  int cnt = 0;
  for (int i = 0 ; i < 3; i++) {
    if (s[i] == 'R') cnt++;
    else cnt = 0;
    ans = max(ans, cnt);
  }
  cout << ans << "\n";
}

Measured memory_bytes: 3612
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>

#pragma GCC optimize("Ofast")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "inposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0

using ll = long long;

const int INF = 1073741823;
const int MINF = -1073741823;
const ll LINF = ll(4661686018427387903);
const ll MOD = 1000000007;
const double PI = acos(-1);

using namespace std;

void scans(string& str) {
	char c;
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

/*-----------------------------------------ここからコード-----------------------------------------*/

int main() {

	int n;
	scanf("%d", &n);
	string s;
	scans(s);
	printyn(s.substr(0, n / 2) == s.substr(n / 2 , n - 1) && n % 2 == 0);

	Please AC;
}


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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))
#define each(i, map) for (auto& i : map)

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

    reverse(S.begin(), S.end());
    long long ten = 1, now = 0;
    map<long long, long long> mp;
    mp[0] = 1;
    for (long long i = 0; i < S.size(); i++) {
        now += ((S.at(i) - '0') * ten);
        now %= 2019;
        ten *= 10;
        ten %= 2019;
        ++mp[now];
    }

    long long ans = 0;
    for (auto& m : mp) {
        ans += (m.second * (m.second - 1)) / 2;
    }
    cout << ans << endl;
}

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

int main() {
  int N,K,X,Y;
  cin >> N >> K >> X >> Y;
  
  if (K >= N) {
    cout << N * X << endl ;
  } else {
    cout << K * X + (N - K) * Y << endl ;
  }
  
  return 0;
}

Measured memory_bytes: 3556
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <utility>
#include <tuple>
#define ll long long int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()
#define DMAX 1000000000
#define NMAX 100003
using namespace std;
vector<pair<int,int>> Range[NMAX];
int C[NMAX];

bool dfs(int x){
	rep(i,0,Range[x].size()){
		if(C[Range[x][i].first] == DMAX){
			C[Range[x][i].first] = C[x] + Range[x][i].second;
			if(!dfs(Range[x][i].first)) return false;
		}else if(C[Range[x][i].first] != C[x] + Range[x][i].second){
			return false;
		}
	}
	return true;
}

int main(){
	int N,M;
	cin >> N >> M;
	int l,r,d;
	rep(i,0,M){
		cin >> l >> r >> d;
		Range[l-1].push_back(make_pair(r-1,d));
		Range[r-1].push_back(make_pair(l-1,-d));
	}

	rep(i,0,N) C[i] = DMAX;

	rep(i,0,N){
		if(C[i] == DMAX){
			C[i] = 0;
			if(!dfs(i)){
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 12032
// $%U%$ $%Y%$-$%M%$-$%D%$ $%h%$:$%m%$

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	int n;
	cin>>n;
	bool a=1;
	int t;
	while(n--){
		cin>>t;
		if(t%2==0){
			if((t%3!=0) && (t%5!=0))a=0;
		}
	}
	cout<<(a?"APPROVED":"DENIED")<<endl;
	return 0;
}



Measured memory_bytes: 256
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def main():
    a, b, c = MI()
    k = I()
    res = k
    flag = True
    if b <= a:
        for i in range(k):
            b *= 2
            res -= 1
            if b > a:
                break
        else:
            flag = False
    if c <= b:
        for i in range(res):
            c *= 2
            res -= 1
            if c > b:
                break
        else:
            flag = False
    if flag:
        print('Yes')
    else:
        print('No')



if __name__ == '__main__':
    main()

Measured memory_bytes: 9208
#include<stdio.h>
#include<stdlib.h>
int isEmpty();
int isFull();
void push(int x);
int pop();
int top;
int S[10000];
#define MAX 10000
void initialize(){
	top=0;
}
int isEmpty(){
	return top==0;
}
int isFull(){
	return top >=MAX-1;
}
void push(int x){
	if(isFull()){
		printf("The queue is full");
	}else{
		top++;
		S[top]=x;
	}
}
int pop(){
	if(isEmpty()){
		printf("The quque is Empty");
	}
	top--;
	return S[top+1];
}

int main(){
	char S[100];
	int a,b,n;
	initialize();
	while(scanf("%s",S)!=EOF){
		if(S[0]=='+'){
			a=pop();
			b=pop();
			push(a+b);
		}else if(S[0]=='-'){
			a=pop();
			b=pop();
			push(b-a);
		}else if(S[0]=='*'){
			a=pop();
			b=pop();
			push(a*b);
		}else{
			n=atoi(S);
			push(n);
		}
	}
	printf("%d\n",pop());
	return 0;
}

Measured memory_bytes: 548
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int st,ed;
  int count=0;
  
  string num;
  int len;
  
  cin >> st >> ed;
  
  for (int i = st; i <= ed; i++) {
    num = std::to_string(i);
    len = num.length();

    if(num[0] == num[len-1]){
      if(num[1] == num[len-2]){
        count++;
      }
    }
  }
  
  cout << count << endl;
  return 0;
}

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

using namespace std;

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

    vector<long long> divs;
    for(long long i = 1; i * i <= N; ++i){
        if(N % i == 0){
            divs.emplace_back(i);
            if(i * i != N){
                divs.emplace_back(N/i);
            }
        }
    }
    sort(divs.begin(), divs.end());
    // for(int i = 0; i < divs.size(); ++i){
    //     cout << divs[i] << " ";
    // }
    // cout << "\n";
    vector<long long> ans;
    // cout << divs.size() << endl;
    for(long long i = 0; i < divs.size(); ++i){
        ans.emplace_back((divs[i]+(N/divs[i])-2)); 
        // cout << ans[i] << " ";
    }
    // cout << endl;
    auto min = min_element(ans.begin(), ans.end());
    cout << *min << endl; 

    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
#include<math.h>
int main()
{
    int x,y;
    scanf("%d",&x);
    while(1)
    {
        y=0;
        if(x!=2&&x%2==0)
            y=1;
        else
            for(int i=3;i<=sqrt(x);i=i+2)
                if(x%i==0)
                {
                    y=1;
                    break;
                }
        if(y==0)
            break;
        x++;
    }
    printf("%d",x);
}

Measured memory_bytes: 2144
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int main() {
    int n;
    cin >> n;
    vint d(n);
    rep(i, n) cin >> d[i];

    ll ans = 0;
    rep(i, n) {
        srep(j, n, i+1) {
            ans += d[i] * d[j];
        }
    }

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

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

using namespace std;

int main(){
	double x1,y1,x2,y2;
	scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
	printf("%.8lf\n",sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)));
}


Measured memory_bytes: 2712
#include <iostream>

using namespace std;

int main()
{
    int n;
    while(true){
        cin >> n;
        if(n==0) break;
        int a=0, b=0;
        for(int i=0; i<n; ++i){
            int temp_a, temp_b;
            cin >> temp_a >> temp_b;
            if(temp_a>temp_b) {
                a+=temp_a+temp_b;
            } else if(temp_a<temp_b) {
                b+=temp_a+temp_b;
            } else {
                a+=temp_a;
                b+=temp_b;
            }
        }
        cout << a << " " << b << endl;
    }
    return 0;
}



Measured memory_bytes: 3092
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <utility>
#include <functional>

using namespace std;

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

	cout << (((a * 100 + b * 10 + c) % 4) == 0 ? "YES" : "NO") << endl;

	return 0;
}

Measured memory_bytes: 256
#include<vector>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <cmath>
#include<queue>
#include <sstream>

const long long INF = 1LL << 60;
using namespace std;
typedef long long llong;

//int isalpha(char ch): ch がアルファベットなら true を返す
//int isdigit(char ch): ch が数字なら true を返す
//int islower(char ch): ch が小文字なら true を返す
//int isupper(char ch): ch が大文字なら true を返す
//int tolower(char ch): ch の小文字を返す
//int toupper(char ch): ch の大文字を返す

//string型
//size()	文字数を返す
//Insert()	（指定した場所に）文字・文字列を挿入する
//erase()	（指定した場所の）文字・文字列を削除する
//clear()	すべての文字を削除する
//substr()	文字列の（指定した）部分文字列を返す
//replace()	（指定した）部分文字列を新しい文字列に置換する
//c_str()変換
//文字列の比較は、<=や==などを使え
//replace関数を使い、簡単に文字列を置換
//リバース関数：reverse(str.begin(), str.end());
//map<type, type> dict;で宣言
//グラフ理論用変数
//vector<vector<llong> > graph(N);

//ソート
//降順sort(v.begin(), v.end(), std::greater<Type>());

//大文字から小文字へんかん
//w[i] = w[i]-'A'+'a';

//vector
//assignメソッド　引数：サイズ、値
//与えられたサイズと値でvectorを初期化する

//queueクラス
//find()次に取り出す値の表示をする。
//pop()値を取り出す。戻り値はなし
//push()キューに値をプッシュする

//priority_queueクラス

//切り上げ
//ceil
//floor

llong dfs(int n, vector<llong> &dp, vector<llong> &h, llong k){

    if(dp[n]!=-1){
        return dp[n];
    }
    llong ans = INF;
    for(int i=1; i<=k; i++){  
        if(n-i<0){
            break;
        }
        ans = min(ans, dfs(n-i, dp, h, k)+abs(h[n]-h[n-i]));
    }
    dp[n] = ans;
    return ans;
}

int main(){
    llong n, k;
    cin >> n >> k;
    vector<llong> dp(n,-1);
    vector<llong> h(n,0);
    for(int i=0; i<h.size(); i++){
        cin >> h[i];
    }
    dp[0] = 0;
    
    cout << dfs(n-1, dp, h, k) << endl;
    return 0;
}





Measured memory_bytes: 10800
#include <cstdio>
#define my_abs(x) ((x) < 0 ? -(x) : (x))
int arr[3][100005], nxt[100005], rev[100005];
bool vis[100005];
int main()
try
{
	// freopen("AGC006-E.in", "r", stdin);
	int n;
	scanf("%d", &n);
	for (int i = 0; i < 3; i++)
	{
		for (int j = 0; j < n; j++)
			scanf("%d", arr[i] + j);
	}
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < 2; j++)
		{
			if (my_abs(arr[j][i] - arr[j + 1][i]) != 1)
				throw false;
		}
		nxt[i] = (arr[1][i] + 1) / 3 - 1;
		if ((nxt[i] ^ i) & 1)
			throw false;
		rev[i & 1] ^= arr[0][i] > arr[2][i];
	}
	for (int i = 0; i < n; i++)
	{
		if (vis[i])
			continue;
		rev[i & 1 ^ 1] ^= 1;
		int x = i;
		while (!vis[x])
		{
			vis[x] = true;
			rev[i & 1 ^ 1] ^= 1;
			x = nxt[x];
		}
	}
	if (rev[0] || rev[1])
		throw false;
	puts("Yes");
	return 0;
}
catch (bool)
{
	puts("No");
	return 0;
}


Measured memory_bytes: 1920
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define RFOR(i, a, b) for(int i=(b-1);i>=(a);i--)
#define REP(i, n) for(int i=0; i<(n); i++)
#define RREP(i, n) for(int i=(n-1); i>=0; i--)
#define REP1(i, n) for(int i=1; i<=(n); i++)
#define RREP1(i, n) for(int i=(n); i>=1; i--)
#define ALL(a) (a).begin(),(a).end()
#define UNIQUE_SORT(l) sort(ALL(l)); l.erase(unique(ALL(l)), l.end());
#define CONTAIN(a, b) find(ALL(a), (b)) != (a).end()
#define out(...) printf(__VA_ARGS__)

int dxy[] = {0, 1, 0, -1, 0};

void solve();
signed main()
{
#if DEBUG
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

/*================================*/
#if DEBUG
#define SIZE 2123450
#else
#define SIZE 2123450
#endif

int N;
int A[SIZE];

void solve() {
    cin>>N;
    REP1(i,N)cin>>A[i];
    vector<int> ans;
    vector<int> B(N + 1, 0);
    RREP1(i, N) {
        int sum = 0;
        for (int j = i; j <= N; j += i) sum += B[j];
        
        if ((sum + A[i]) % 2 == 1) {
            B[i]++;
            ans.push_back(i);
        }
    }
    cout << ans.size() << endl;
    for(auto x: ans) cout << x << " ";
    cout << endl;
}

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

using namespace std;

int main() {

    int a,b,c;
    int board[3][3];
    for (int i = 0; i < 3; i++) {
        cin >> a >> b >> c;
        board[i][0] = a;
        board[i][1] = b;
        board[i][2] = c;
    }

    int count, num;
    cin >> count;

    for (int i = 0; i < count; i++) {
        cin >> num;
        for (int x = 0; x < 3; x++) {
            for (int y = 0; y < 3; y++) {
                if (board[x][y] == num) {
                    board[x][y] = -1;
                }
            }
        }
    }

    bool bingo = false;
    //check horizontals
    for (int x = 0; x < 3; x++) {
        if (board[x][0] + board[x][1] + board[x][2] == -3) {
            bingo = true;
        }
    }
    //check verticals
    for (int x = 0; x < 3; x++) {
        if (board[0][x] + board[1][x] + board[2][x] == -3) {
            bingo = true;
        }
    }

    //check diagonals
    if (board[0][0] + board[1][1] + board[2][2] == -3) {
        bingo = true;
    }

    if (board[0][2] + board[1][1] + board[2][0] == -3) {
        bingo = true;
    }

    if (bingo) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
    
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int a,b;
	scanf("%d %d", &a, &b);
	if(a<b){
		printf("a < b\n");
	}else if(a>b){
		printf("a > b\n");
	}else if(a==b){
		printf("a == b\n");
	}
	return 0;
}

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

using namespace std;

#define int long long
#define all(v) begin(v), end(v)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

// ??£???????¬?????¨????????§£???
typedef vector<int> nvector;
typedef vector<nvector> matrix;
const double eps = 1e-9;
bool gauss_jordan(const matrix& A, const nvector& b)
{
  int n = A.size();
  // ?????§?????°??????
  matrix Ab(n, nvector(n + 1));
  for(int i = 0; i < n; i++) {
    for(int j = 0; j < n; j++) Ab[i][j] = A[i][j];
  }
  for(int i = 0; i < n; i++) Ab[i][n] = b[i];

  // ?§£???
  for(int i = 0; i < n; i++) {
    int pivot = i;
    for(int j = i; j < n; j++) {
      if(abs(Ab[pivot][i]) < abs(Ab[j][i])) pivot = j;
    }
    swap(Ab[i], Ab[pivot]);
    if(abs(Ab[i][i]) <= 0) continue;//return nvector();
    // ?????????????????°??§??????
    // for(int j = i+1; j < n+1; j++) Ab[i][j] /= Ab[i][i];
    // ????????????
    for(int j = 0; j < n; j++) {
      if(i != j && Ab[j][i] == 1) {
	for(int k = i; k < n+1; k++) Ab[j][k] = (Ab[j][k] + Ab[i][k]) % 2;
      }
    }
  }

  // ?§£
  //nvector x(n);
  for(int i = 0; i < n; i++) {
    //x[i] = Ab[i][n];
    if(Ab[i][i] == 0 && Ab[i][n] == 1) return false;
  }

  return true;
}

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int m, n, d;
  int S[30][30];
  while(cin >> m >> n >> d, m) {
    rep(i, n) rep(j, m) cin >> S[i][j];

    matrix A(m*n, nvector(m*n, 0));
    rep(i, n) rep(j, m) {
      A[i*m+j][i*m+j] = 1;
      rep(k, n) rep(l, m) {
	int dist = abs(j - l) + abs(i - k);
	if(dist == d) A[i*m+j][k*m+l] = 1;
      }
    }

    nvector b(m*n, 0);
    rep(i, n) rep(j, m) b[i*m+j] = S[i][j];

    cout << (int)gauss_jordan(A, b) << endl;
  }
  return 0;
}

Measured memory_bytes: 8784
package main

import (
	"fmt"
	"strconv"
)

func main() {

	var N int

	fmt.Scan(&N)


	cnt :=0

	for i:=1;i<=N;i++{

		temp := strconv.Itoa(i)

		if len(temp)%2!=0{

			cnt++
		}

	}

	fmt.Println(cnt)
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define int int64_t
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
#define REPP(i, n) for (int i = 1; (i) < (int)(n+1); ++ (i))
#define REPR(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i=(m)-1; i>=(n); i--)
#define ALL(v) v.begin(), v.end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define SORTR(c) sort((c).begin(),(c).end(),greater<int>());
#define BIT(n) (1LL<<(n))
#define PCNT(x) __builtin_popcountll(x)
#define GCD(x,y) __gcd(x,y)
#define LCM(x,y) x/__gcd(x,y)*y
#define PB push_back
#define MP make_pair
#define endl "\n"
#define pa cout << ans << endl
#define p(x) cout << x << endl
#define pall(x) for(auto iter : x) p(iter)
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
#define yn(x) cout << (x ? "Yes" : "No") << endl
using namespace std;
using Graph = vector<vector<int> >;
using WeightedGraph = vector<vector<pair<int, int> > >;
typedef long double LD;
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
const int INF = 2000000000;
const long double PI = acosl(-1);
const int MOD = 1000000007;
void print() {cout << endl;}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head; if (sizeof...(tail) != 0) cout << " ";print(forward<Tail>(tail)...);}
template <class T> void print(vector<T> &vec) {for (auto& a : vec) {cout << a; if (&a != &vec.back()) cout << " ";} cout << endl;}
template <class T> void print(vector<vector<T>> &df) { for (auto& vec : df) { print(vec);}}


signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int ans = 0;
    
    int X;
    cin >> X;

    int now = X;

    while (now % 360 != 0) {
        now+=X;
        ans++;
    }
    ans++;

    pa;
    
    
    
    return 0;
}

/*
cd ~/Desktop/Programming/AtCoder/contest/agc046/agc046_a && sh shellscripts/test_cpp.sh
cd ~/Desktop/Programming/AtCoder/contest/agc046/agc046_a && sh shellscripts/etest_cpp.sh
cd ~/Desktop/Programming/AtCoder/contest/agc046/agc046_a && sh shellscripts/submit_cpp.sh
*/


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
int H,W;
vector<vector<char>> field;

vector<vector<int>> cost;

int bfs(){
    int dx[] = {0,1,-1,0}, dy[] = {1,0,0,-1};

    queue<pair<int,int>> que;
    que.push(make_pair(0,0));
    cost[0][0] = 0;

    while(!que.empty()){
        pair<int,int> p = que.front();
        que.pop();
        if(p == make_pair(H-1,W-1)){
            return cost[p.first][p.second];
        }

        for(int i = 0; i < 4; i++){
            int ny = p.first + dy[i], nx = p.second + dx[i];

            if(nx < 0 || ny < 0 || nx >= W || ny >= H) continue;
            if(field[ny][nx] == '#') continue;
            if(cost[ny][nx] != -1) continue;

            cost[ny][nx] = cost[p.first][p.second] + 1;

            que.push(make_pair(ny,nx));
        }
    }
    return -1;
}

int main(){
    cin >> H >> W;
    int white = 0;
    field = vector<vector<char>>(H, vector<char>(W));
    for (int i = 0; i < H; i++){
        for (int j=0; j < W; j++){
            cin >> field[i][j];
            if(field[i][j] == '.') white++;
        }
    }
    cost = vector<vector<int>>(H, vector<int>(W, -1));
    int min_cost = bfs();
    if(min_cost == -1) cout << -1 << endl;
    else cout << white - (min_cost+1) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Weight=long long int;
struct Edge {
    int src,dest;
    Edge(int s,int d){
        src=s,dest=d;
    }
};
using Edges=vector<Edge>;
using Graph=vector<Edges>;

int SCC(Graph& g,vector<int> &cmp){
    int n=g.size();
    Graph rg(n);
    cmp.assign(n,-1);
    for(int i=0;i<n;i++){
        for(auto e:g[i]){
            rg[e.dest].push_back(Edge(e.dest,e.src));
        }
    }
    vector<int> vs;
    vector<int> used(n,0);
    function<void(int)> dfs=[&](int v){
        if(used[v]) return;
        used[v]=true;
        for(auto e:g[v]){
            dfs(e.dest);
        }
        vs.push_back(v);      
        return;
    };
    for(int i=0;i<n;i++){
        if(!used[i]) dfs(i);
    }
    used.assign(n,0);
    function<void(int,int)> rdfs=[&](int v,int k){
        if(used[v]) return;
        used[v]=true;
        cmp[v]=k;
        for(auto e:rg[v]){
            rdfs(e.dest,k);
        }
    };
    int k=0;
    for(int i=n-1;i>=0;i--){
        if(!used[vs[i]]) rdfs(vs[i],k++);
    }
    return k;
}

int main(){
    int v,e;
    cin>>v>>e;
    Graph g(v);
    for(int i=0;i<e;i++){
        int s,t;
        cin>>s>>t;
        g[s].push_back(Edge(s,t));
    }
    vector<int> cmp;
    SCC(g,cmp);
    int q;
    cin>>q;
    for(int i=0;i<q;i++){
        int u,v;
        cin>>u>>v;
        cout<<(cmp[u]==cmp[v])<<endl;
    }
    return 0;
}

Measured memory_bytes: 4848
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int a[5];
int cnt=0;
int main()
{
    for(int i=1;i<=3;i++)
        scanf("%d",&a[i]);
    int cnt=0;
    int f=1;
    while(f)
    {
        if(a[1]==a[2]&&a[2]==a[3]) break;
        sort(a+1,a+1+3);
        while(a[1]+2<=a[3])a[1]+=2,cnt++;
        if(a[1]==a[2]&&a[2]==a[3]) break;
        while(a[2]+2<=a[3])a[2]+=2,cnt++;
        if(a[1]==a[2]&&a[2]==a[3]) break;
        if(a[2]==a[3]&&a[1]!=a[2]) a[1]+=2,a[2]+=1,a[3]+=1,cnt+=2;\
        if(a[1]==a[2]&&a[2]==a[3]) break;
        if((a[1]+1<=a[3]&&a[2]+1<=a[3]))a[1]+=1,a[2]+=1,cnt++;
    }
    printf("%d",cnt);
}

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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef vector<P> vp;

const ll mod = 1e9+7;
const ll inf = 1e16;

#define loop(i,m,n) for(ll i=m;i<n;i++)
#define vloop(it,x) for(auto it=x.begin(); it!=x.begin(); it++)
#define all(x) x.begin(),x.end()
#define debug(x) cout << #x <<":"<< x <<endl	
#define showll(x) printf("%lld\n",x)
#define test(t) ll t;cin >> t;while(t--)
#define showc(x) printf("%c\n",x)
#define read(x) cin >> x
#define yes printf("YES\n")
#define no printf("NO\n")
#define pb push_back

void fast()
{
ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
}

//////////////////////////////// - _ - \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

ll n;

int main()
{
	fast();
	// debug(n);
	// showll(a);
	string s,t,ans="";
	ll i,j,w,n,tmp;
	read(s);read(t);
	ll dp[s.size()+1][t.size()+1];
	loop(i,0,s.size()+1)
	{
		loop(j,0,t.size()+1)
		{
			dp[i][j] = 0;
		}
	}
	loop(i,0,s.size())
	{
		loop(j,0,t.size())
		{
			if(s[i]==t[j])
			{
				dp[i+1][j+1] = max(dp[i+1][j+1],dp[i][j]+1);
				//ans += s[i];
			}
			dp[i+1][j+1] = max(dp[i+1][j],dp[i+1][j+1]);
			dp[i+1][j+1] = max(dp[i][j+1],dp[i+1][j+1]);

		}
	}
	i = (ll)s.size();
	j = (ll)t.size();
	while(i>0 && j>0)
	{	
		if(dp[i][j]==dp[i-1][j])
		{
			i--;
		}
		else if (dp[i][j]==dp[i][j-1])
		{
			j--;
		}
		else
		{
			ans = s[i-1] + ans;
			i--;
			j--; 
		}
	}
	cout << ans << endl;
//	debug(n);debug(w);
}


Measured memory_bytes: 70656
def Ave_tmp(Hi):
    return T-Hi*0.006

n = int(input())
T, A = map(int, input().split())
H_list = list(map(int, input().split()))

Ave_tmp_list = list(map(Ave_tmp, H_list))

min = 1000000000
ans = 0
for i, Ave_tmp in enumerate(Ave_tmp_list):
    if(abs(Ave_tmp - A) < min):
        min = abs(Ave_tmp - A)
        ans = i+1

print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#include<queue>
#define ll long long
#define itn int
#define co(ans) cout<<ans<<endl;
#define COYE cout<<"YES"<<endl;
#define COYe cout<<"Yes"<<endl;
#define COye cout<<"yes"<<endl;
#define CONO cout<<"NO"<<endl;
#define CONo cout<<"No"<<endl;
#define COno cout<<"no"<<endl;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
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; }
using namespace std;


int main(){
  string S;
  cin>>S;
  int K;
  cin>>K;
  ll ans=0;
  
  
  long long dp[101][2][5];
  // dp[決めた桁数][未満フラグ][0でない数を使った回数]
  
  int L=S.size();
  fill((long long*)dp,(long long*)dp+sizeof(dp)/sizeof(long long),0);
  dp[0][0][0]=1;
  
  for(int i=0; i<L; ++i){
  int D=S[i]-'0';
    for(int j=0; j<2; ++j){
	  for(int k=0; k<5; ++k){
		for(int d=0; d<=(j?9:D); ++d){
		  if(d>0 && k<=3) dp[i+1][j||(d<D)][k+1]+=dp[i][j][k];
          if(d==0 && k<=3) dp[i+1][j||(d<D)][k]+=dp[i][j][k];
        }
      }
    }
  }
  
  cout<<dp[L][0][K]+dp[L][1][K]<<endl;
  return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"os"
)

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	var n int
	fmt.Fscan(fp, &n)

	aList := make([]int, n)
	dp := make([][]int64, n)
	for index := 0; index < n; index++ {
		fmt.Fscan(fp, &aList[index])
		dp[index] = make([]int64, n)
	}
	fmt.Println(chokudai(0, n-1, aList, dp))
}
func chokudai(l int, r int, alist []int, dp [][]int64) int64 {
	if l >= r {
		return 0
	}
	if dp[l][r] > 0 {
		return dp[l][r]
	}
	cost := int64(0)
	for index := l; index <= r; index++ {
		cost += int64(alist[index])
	}
	if r-l == 1 {
		dp[l][r] = cost
		return dp[l][r]
	}

	for index := l; index <= r; index++ {
		lPart := chokudai(l, index, alist, dp)
		rPart := chokudai(index+1, r, alist, dp)
		if dp[l][r] == 0 {
			dp[l][r] = cost + lPart + rPart
			continue
		}
		if dp[l][r] > cost+lPart+rPart {
			dp[l][r] = cost + lPart + rPart
		}
	}

	return dp[l][r]
}

Measured memory_bytes: 2048
#include <iostream>
using namespace std;
int main(){
  int x, y;
  int z=0;
  cin >> x >> y;
  if (x <= 3)
  {
    z+= ((3-x)%3+1)*100000;
  }
  if (y <= 3)
  {
    z+= ((3-y)%3+1)*100000;
  }
  if (x==1 && y==1)
  {
    z+=400000;
  }
  cout << z << endl;
  return 0;
}

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


int main() {
  int itiban= 0;
  int niban = 0;
  char a;
while(cin >> a){
    if(a == 'A' ||a == 'C' ||a == 'G' ||a == 'T'){
      niban++;
    }else{
      if(itiban < niban){
        itiban = niban;
        niban = 0;
      }else{
        niban = 0;
      }
    }
  }
  if(itiban < niban){
    itiban = niban;
    niban = 0;
  }else{
    niban = 0;
  }
  cout << itiban << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int) (n); i++)
using namespace std;
using namespace std;
typedef long long ll;
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  map<int, int> rest_count;
  REP(i, N) {
    scanf("%d", &A[i]);
    rest_count[A[i]]++;
  }
  sort(A.begin(), A.end(), greater<int>());
  int res = 0;
  REP(i, N) {
    if (rest_count[A[i]] == 0) {
      continue;
    }
    for (int t = 30; t >= 0; t--) {
      int target = (1 << t) - A[i];
      if (target <= 0) break;
      if ((target != A[i] && rest_count[target] > 0 ) || rest_count[target] > 1) {
        res++;
        rest_count[target]--;
        rest_count[A[i]]--;
        break;
      }
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 29824
N, x = map(int, input().split())
A = [int(i) for i in input().split()]

A = sorted(A)

i = 0
while i < N:
    if A[i] <= x:
        x -= A[i]
        i += 1
    else:
        break

if i == N and x > 0:
    i -= 1

print(i)


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


int main(){
	int H,N;
	cin >> H >> N;
	vector<int> attacks;
	for(int x = 0; x<N; x++){
		int in;
		cin >> in;
		attacks.push_back(in);
	}
	sort(attacks.begin(), attacks.end());
	for(int x = 0; x<N; x++){
		H = H - attacks[x];
		if(H<=0){
			cout << "Yes";
			return 0;
		}
	}
	cout << "No";



}
	



Measured memory_bytes: 892
import java.io.BufferedReader
import java.util.*
import kotlin.math.max

fun main() = arc062c()

@OptIn(ExperimentalStdlibApi::class)
fun arc062c() = SimpleFastIOWithToken_arc062c().exec {
    val n = readInt()
    val pollRates = List(n) { readLong() to readLong() }

    var a = 1L
    var b = 1L

    for ((x, y) in pollRates) {
        val multiply = max((a + x - 1) / x, (b + y - 1) / y)
        a = x * multiply
        b = y * multiply
    }

    val answer = a + b

    println(answer)
}

// region kokokara template dayo (^o^)
@Suppress("unused", "HasPlatformType", "MemberVisibilityCanBePrivate", "ClassName")
private class SimpleFastIOWithToken_arc062c(private val separator: String = System.lineSeparator()) {
    private val br: BufferedReader = System.`in`.bufferedReader()
    private var st: StringTokenizer = StringTokenizer("")
    private val sb: StringBuilder = StringBuilder()
    private fun prepareNext() = run { if (!st.hasMoreTokens()) st = StringTokenizer(br.readLine()) }

    fun readString(): String = run { prepareNext() }.run { st.nextToken() }
    fun readInt(): Int = Integer.valueOf(readString())
    fun readLong(): Long = java.lang.Long.valueOf(readString())

    fun println(): Unit = run { sb.append(separator) }
    fun print(any: Any): Unit = run { sb.append(any) }
    fun println(any: Any): Unit = run { sb.append(any.toString() + separator) }

    fun exec(action: SimpleFastIOWithToken_arc062c.() -> Unit) {
        var t: Throwable? = null
        Thread(null, { action() }, "solve", 128 * 1024 * 1024)
            .apply { setUncaughtExceptionHandler { _, t1 -> t = t1 } }
            .apply { start() }.join()
        t?.let { throw it }
        kotlin.io.print(sb)
    }

    fun readLine(): Nothing = error("readLine is disabled.")
}
// endregion kokomade template dayo (^o^)


Measured memory_bytes: 35028