akhauriyash/Code-Regression huggingface dataset:
# AtCoder Beginner Contest 135
# B - 0 or 1 Swap

'''
解説見て書き直し、
数列の要素と順番(i+1)が一致していない個数を数える。
これが3以上であれば"NO"
3未満(0か2)であれば"YES"
'''


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

count = 0

for i in range (N) :
    if p[i] != i+1 :
        count += 1
    else :
        pass

if count < 3 :
    print('YES')
else :
    print('NO')

Measured memory_bytes: 9160
#include <bits/stdc++.h>
#include <climits>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define srep(i, begin, end) for (__typeof(end) i = begin; i != end; i++)
#define si(x) int x = scanInt();
#define sll(x) LL x = scanLong();
#define sci(x) int x; scanf("%d", &x);
#define scll(x) LL x; scanf("%lld", &x);
#define pi(x) printf("%d ", x)
#define pll(x) printf("%lld ", x)
#define nl printf("\n")
#define clr(a) memset(a, 0, sizeof(a))
#define PB push_back
#define MP make_pair
using namespace std;
typedef unsigned int UI; // 32 bit integer
typedef long int LI; // 32 bit integer
typedef unsigned long int ULI; // 32 bit unsigned integer
typedef long long int LL; // 64 bit integer
typedef unsigned long long int ULL; // 64 bit unsigned integer
typedef long double LD;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef deque<int> DI;
typedef deque<LL> DLL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
const LL MOD = 1e9+7;

/* Fast I/O */
inline int scanInt() {
	int n = 0;
	char ch = getchar();
	int sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(int)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

inline LL scanLong() {
	LL n = 0;
	char ch = getchar();
	LL sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(LL)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

int main() {
	string s; cin >> s;
	LL won = 0, remaining = 15 - s.length();
	rep(i, 0, s.length())	if(s[i] == 'o')	won++;
	if(won + remaining >= 8)	puts("YES");
	else	puts("NO");
}


Measured memory_bytes: 256
def dist(x,y,p):
    tmp = 0
    for k,j in zip(x,y):
        k,j = sorted((k,j))
        tmp += (j-k)**p
    print tmp**(1/float(p))

def cheb(x,y):
    maxjk = None
    for k,j in zip(x,y):
        k,j = sorted((k,j))
        if maxjk is None:
            maxjk = j-k
        elif j-k > maxjk:
            maxjk = j-k
    print float(maxjk)

n = int(raw_input())
x = map(int,raw_input().split())
y = map(int,raw_input().split())

dist(x,y,1)
dist(x,y,2)
dist(x,y,3)
cheb(x,y)

Measured memory_bytes: 4312
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
ans = 0
for i in range(len(B)):
    cB = B[i]
    if A[i] > cB:
        ans += cB
    else:
        ans += A[i]
        cB -= A[i]
        if cB > A[i+1]:
            ans += A[i+1]
        else:
            ans += cB
        A[i+1] = max(0, A[i+1]-cB)
print (ans)

Measured memory_bytes: 97720
/*
 * 	Heart beats fast
 * 		Colors and promises
 * 			How to be brave
 * 				How can I love when I am afraid to fall...
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
// #include<boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
using namespace __gnu_pbds;
using namespace std;
#define int long long
#define mod 1000000007
#define FAST ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define f(i,n) for(int i=0;i<n;i++)
#define fp(i,k,n) for(int i=k;i<=n;i++)
#define fr(i,k,n) for(int i=k;i>=n;i--)
#define pb push_back
#define F first
#define S second
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
 
 
void solve()
{
  int n;
  cin >> n;
  int ans=1000*(n/500);
  n%=500;
  ans+=(5*(n/5));
  cout << ans << '\n';
  return ;
}

signed main()
{
   FAST;
	int T=1;
	// cin >> T;
	while(T--)
	{
		solve();
	}
    return 0;
}

Measured memory_bytes: 256
N = int(input())
list = []
y = 0
while N - 7*y >=0:
    if (N - 7*y)%4 == 0:
        x = (N - 7*y)%4
        list.append(x)
        y +=1
    else:
        y +=1
        continue
        
if list == []:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 3060
//g++ -std=c++14 test.cpp -o test.out
//問題URL
//https://atcoder.jp/contests/panasonic2020/tasks/panasonic2020_e
//「選ぶネタの種類が x 種類以上になる場合についての、美味しさ」
//の総和の最大値を求め、x*x を足したもの
//を各 x について求めて、その最大値を求める
//参考
//https://drken1215.hatenablog.com/entry/2019/05/15/002400
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (LL)(1e18)+1;
const int INF_INT = 2147483647-1e6;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL N,K;
vector<priority_queue<LL>> dish;//種類iの美味しさを持つ寿司の集合をdish[i]とおく

LL ans = 0;

void solve(){
    priority_queue<LL> best, remain;
    // best: 各種類で一番美味しいやつを集めたもの
    // remain : bestの余り
    for (int i = 0; i < N; ++i) {//種類iの寿司の集合を見ていく
        if (!dish[i].empty()) {//種類iの寿司がまだ1個以上あるなら
            best.push(dish[i].top());//種類iで一番美味しい寿司は優先度付きキューの頭にある
            dish[i].pop();

            while (!dish[i].empty()) {//残りは全部remain行き
                remain.push(dish[i].top());
                dish[i].pop();
            }
        }
    }
    //best,remainはpriority_queueなので勝手に降順にソートされる

    vector<LL> bsum = {0};
    // bestの累積和 (bsum[i] = bestの先頭からi個の総和)
    while (!best.empty()) {
        bsum.push_back(bsum.back() + best.top());
        best.pop();
    }

    vector<LL> rsum = {0};
    // remainの累積和
    while (!remain.empty()) {
        rsum.push_back(rsum.back() + remain.top());
        remain.pop();
    }

    for (LL x = 1; x <= K; ++x) {
        // 種類が多すぎるケース
        if (x >= bsum.size()) break;

        // 種類が少なすぎて、余り物が足りないケース
        if (K - x >= rsum.size()) continue;

        // bestからx個、remainからK-x個貪欲に選ぶ
        ans = max(ans, bsum[x] + rsum[K - x] + x * x);
    }

}
 
int main(){
	cin >> N >> K;
	dish = vector<priority_queue<LL>>(N);
	for(int i=0;i<N;i++){
		int t,d;
		cin >> t >> d;
		t--;
		dish[t].push(d);
	}
 
	solve();

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

Measured memory_bytes: 8820
def s(n):
    ls=[]
    for i in range(1,n+1):
        if n%i==0:
            ls.append(i)
    return ls

ans=[]
a,b,k=map(int,input().split())
for i in s(a):
    if i in s(b):
        ans.append(i)

print(ans[-k])


Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <unordered_map>
#include <map>
#include <numeric>
#include <limits>
#include <utility>
#include <queue>
#include <random>
using namespace std;
typedef long long LL;
/*
cout << = printf()
cin >> = scanf()

char = string
*/
/*
int main() {
	int n=0;
	string a;
	cin >> a;
	n = a[0];
	cout << n;//a[0]<<a[1]<<a[2];

	return 0;
}*/
/*
int main() {
	int m, n;
	cin >> m >> n;
	cout << (m - 1)*(n - 1);
	return 0;
}
*/

int main() {
	string s;
	cin >> s;
	s.erase(s.begin() + 5);
	s.insert(s.begin() + 5, ' ');
	s.erase(s.begin() + 13);
	s.insert(s.begin() + 13, ' ');
	cout << s<<"\n";
	return 0;
}

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

int main() {
  int h,n;
  cin >> h >> n;
  int a;
  rep(i,n) {
    cin >> a;
    h -= a;
  }
  string result = h <= 0 ? "Yes" : "No";
  cout << result;
  return 0;
}

Measured memory_bytes: 256
from collections import deque
import sys


def dfs(adj, start, visited, cost):
    que = deque()
    que.append(start)
    cost_list = []
    while que:
        v = que.pop()
        visited[v] = 1
        cost_list.append(cost[v])
        for u in adj[v]:
            if visited[u] == 0:
                que.append(u)
    visited_ret = visited
    return sorted(cost_list), visited_ret


N, M = map(int, input().split())
cost = list(map(int, input().split()))
adj = [[] for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    adj[a].append(b)
    adj[b].append(a)

visited = [0] * N
cost_lists = []
for i in range(N):
    if visited[i] == 0:
        cost_list, visited = dfs(adj, i, visited, cost)
        cost_lists.append(cost_list)

if len(cost_lists) == 1:
    print(0)
    sys.exit()

ans = 0
pool = []
for i, cost_list in enumerate(cost_lists):
    for j, cost in enumerate(cost_list):
        if j == 0:
            ans += cost
        else:
            pool.append(cost)
pool.sort()
for i in range(len(cost_lists) - 2):
    if i < len(pool):
        ans += pool[i]
    else:
        print('Impossible')
        sys.exit()
print(ans)


Measured memory_bytes: 84504
#ifndef VS
#include<bits/stdc++.h>
#endif

using namespace std;
typedef long long LL;

#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {cww() {CIN_ONLY{ios::sync_with_stdio(false); cin.tie(0);}}
}star;
#define DEBUG if(0)
#endif

#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; return a;}
template <typename T>inline bool chmax(T &l, T r){bool a = l<r; if (a)l = r; return a;}
template <typename T>istream& operator>>(istream &is, vector<T> &v){for (auto &it : v)is >> it;return is;}

class range {private: struct I { int x; int operator*() { return x; }bool operator!=(I& lhs) { return x<lhs.x; }void operator++() { ++x; } }; I i, n;public:range(int n) :i({ 0 }), n({ n }) {}range(int i, int n) :i({ i }), n({ n }) {}I& begin() { return i; }I& end() { return n; }};

using namespace std;
#define pb push_back

using FLOW = int;
namespace flow {
	constexpr FLOW INF = 1e7;
	struct edge {
		FLOW flow;
		int to, rev;
	};
	typedef vector<edge> E;
	typedef vector<E> Graph;
	void addedge(Graph&g, int from, int to, FLOW f) {
		int x = g[from].size();
		int y = g[to].size();
		g[from].pb(edge{ f,to,y });
		g[to].pb(edge{ (FLOW)0,from,x });
	}

	vector<int> bfs(Graph& G, int s) {
		int N = G.size();
		queue<int> que;
		vector<int> dist(N, -1);
		dist[s] = 0;
		que.push(s);
		for (; !que.empty(); que.pop()) {
			auto v = que.front();
			for (auto& e : G[v])
				if (e.flow>0 && dist[e.to] == -1) {
					dist[e.to] = dist[v] + 1;
					que.push(e.to);
				}
		}
		return dist;
	}
}
FLOW maxflow(flow::Graph& G, int s, int t) {
	using namespace flow;
	FLOW res = 0;
	int N = G.size();
	while (true) {
		auto dist = bfs(G, s);
		if (dist[t] < 0)break;
		vector<unsigned> iter(N, 0);
		std::function<FLOW(int, FLOW)> dfs = [&](int v, FLOW f) {
			if (v == s)return f;
			for (auto &i = iter[v]; i < G[v].size(); i++) {
				edge &e = G[v][i];
				edge &re = G[e.to][e.rev];
				if (re.flow>0 && dist[v] >dist[e.to]) {
					FLOW d = dfs(e.to, min(f, re.flow));
					if (d>0) { e.flow += d; re.flow -= d; return d; }
				}
			}
			return (FLOW)0;
		};
		FLOW f;
		while ((f = dfs(t, INF))> 0)res += f;
	}
	return res;
}

int main() {
	int N;
	cin >> N;
	vector<int> a(N), b(N), c(N), d(N);
	for (int i : range(N)) {
		cin >> a[i] >> b[i];
	}
	for (int i : range(N)) {
		cin >> c[i] >> d[i];
	}
	flow::Graph g(2 * N+2);
	const int S = 2 * N;
	const int T = S + 1;
	for (int i : range(N)) {
		flow::addedge(g, S, i, 1);
		flow::addedge(g, N + i, T, 1);
	}
	for (int i : range(N)) {
		for (int j : range(N)) {
			if (a[i] < c[j] && b[i] < d[j])
				flow::addedge(g, i, N + j, 1);
		}
	}
	cout << maxflow(g, S, T) << endl;
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
pair<long long, long long> p[100010];
int main() {
	long long n, k;
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		long long a, b;
		cin >> a >> b;
		p[i] = make_pair(a, b);
	}
	sort(p, p + n);
	long long v = 0;
	for (int j = 0; j < n; j++) {
		v += p[j].second;
		if (v >= k) {
			cout << p[j].first;
			return 0;
		}
	}
}

Measured memory_bytes: 1792
#include<iostream>
#include<iomanip>
#include<functional>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<utility>
#include<map>
#include<queue>

using namespace std;

#define LL long long
#define Linf (LL)1e18
const int dx[4] = { 1,-1,0,0 };
const int dy[4] = { 0,0,1,-1 };

string date[7]={"SUN","MON","TUE","WED","THU","FRI","SAT"};

int main(){
	int n;
	string s;
	cin >> n >> s;
	for(int i=0; i<s.size(); i++){
		cout << (char)('A'+(s[i]-'A'+n)%26);
	}
	cout << endl;
	return 0;
}

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: 1740
#include <stdio.h>

int main(void){
        int i,sum;
        char x[1001];
        while(1){
                sum=0;
                i=0;
                scanf("%s",x);
                if(x[0]=='0')
                        break;
                while(x[i]){
                        sum+=(x[i]-'0');
                        i++;
                }
                printf("%d\n",sum);
        }
        return 0;
}

Measured memory_bytes: 536
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define fi first
#define se second
#define inf (INT_MAX/2-1)
#define infl (1LL<<60)
#define vi vector<int>
#define pb push_back
#define sz(a) (int)(a).size()
#define all(a) begin(a),end(a)
#define y0 y5656
#define y1 y7878
#define aaa system("pause");
#define dbg(x) cerr<<(#x)<<": "<<(x)<<'\n',aaa
#define dbga(x,n) cerr<<(#x)<<"[]: ";for(int _=0;_<n;_++)cerr<<x[_]<<' ';cerr<<'\n',aaa
#define dbgs(x) cerr<<(#x)<<"[stl]: ";for(int _:x)cerr<<_<<' ';cerr<<'\n',aaa
#define dbgp(x) cerr<<(#x)<<": "<<x.fi<<' '<<x.se<<'\n',aaa
#define P pair<int,pii>
#define maxn 1000

using namespace std;

string g[maxn+7];
int d[maxn+5][maxn+5];
priority_queue<P,vector<P>,greater<P> > pq;

int main () {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int n, m; cin >> n >> m;
  int a, b, c, e; cin >> a >> b >> c >> e;
  int i, j, z;
  a += 1; b += 1;
  c += 1; e += 1;
  for (i = 2; i <= n+1; i++) {
    cin >> g[i];
    g[i] = "##" + g[i] + "##";
  }
  for (j = 0; j <= m+3; j++) {
    g[0] += '#';
    g[1] += '#';
    g[n+2] += '#';
    g[n+3] += '#';
  }
  for (i = 2; i <= n+1; i++)
    for (j = 2; j <= m+1; j++) d[i][j] = inf;
  d[a][b] = 0;
  pq.push(make_pair(0,pii(a,b)));
  int dx[4] = {-1, 1, 0, 0}, dy[4] = {0, 0, -1, 1};
  while (!pq.empty()) {
    P now = pq.top(); pq.pop();
    int cost = now.fi, x = now.se.fi, y = now.se.se; ///nr jumpuri, coordonate
    if (cost != d[x][y]) continue;
    ///normal
    for (z = 0; z < 4; z++) {
      int nx = x + dx[z], ny = y + dy[z];
      if (g[nx][ny] == '#') continue;
      if (d[nx][ny] > d[x][y]) {
        d[nx][ny] = d[x][y];
        pq.push(make_pair(d[nx][ny], pii(nx,ny)));
      }
    }
    ///jump
    for (int px: {-2, -1, 0, 1, 2})
      for (int py: {-2, -1, 0, 1, 2}) {
        int nx = x + px, ny = y + py;
        if (g[nx][ny] == '#') continue;
        if (d[nx][ny] > d[x][y]+1) {
          d[nx][ny] = d[x][y] + 1;
          pq.push(make_pair(d[nx][ny], pii(nx,ny)));
        }
      }
  }
  if (d[c][e] == inf) cout << -1;
  else cout << d[c][e];
  return 0;
}

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

using namespace std;
const int maxn = 1e5 + 30;
int num[maxn];
bool red[maxn];

int main(){
  red[1] = true;
  int n; cin >> n;
  for(int i=1;i<=n;i++) num[i] = 1;
  int m; cin >> m;
  for(int ee=0;ee<m;ee++){
    int x,y; scanf("%d%d", &x, &y);
    if(red[x]) red[y] = true;
    num[x]--;
    num[y]++;
    if(num[x] == 0) red[x] = false;
  }
  int ans = 0;
  for(int i=1;i<=n;i++){
    if(red[i]) ans++;
  }
  cout << ans << "\n";
}


Measured memory_bytes: 768
#include <cstdio>

int main()
{
	int n, m, i, sum, t[101], p, x;
	scanf("%d", &n);
	for (sum = i = 0; i < n; i++)
	{
		scanf("%d", t + i);
		sum += t[i];
	}
	for (scanf("%d", &m); m--;)
	{
		scanf("%d %d", &p, &x);
		printf("%d\n", sum - t[p - 1] + x);
	}
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
    set<int>s;
    long long x;
    cin>>x;
    vector<long long>v;
    for(long long i=1;i<=9;i++)v.push_back(i);
    while(1){
    	if(x<=v.size()){
    		cout<<v[x-1]<<"\n";
    		return 0;
		}
		x-=v.size();
		vector<long long>v1;
		swap(v1,v);
		for(long long p:v1){
		
		for(long long int i=-1;i<=1;i++){
			long long int d=p%10+i;
			if(d<0||d>9)continue;
			long long int n=p*10+d;
			v.push_back(n);
		}
			
		}
	}
	return 0;
}

Measured memory_bytes: 1712
#include <stdio.h>

#define N 8
#define NOT_FREE 1
#define FREE -1

int row[N],col[N],dpos[2*N-1],dneg[2*N-1],buf[N][N];
int flag=0;
void putQueen(int);
void printBoard();

int main(){
  int a,b,i,n,j;
  for(i=0;i<N;i++){
    row[i]=FREE;
    col[i] = FREE;
  }
  for(i = 0;i<2*N;i++){
    dpos[i] = FREE;
    dneg[i] =FREE;
  }
  for(i = 0;i<N;i++){
    for(j = 0;j<N;j++){
      buf[i][j] =0;
    }
  }
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d %d",&a,&b);
    buf[a][b]  = 1;
  }
  putQueen(0);
  return 0;
}


void putQueen(int i){
  int j,k;
  if(i ==N ){
    printBoard();
    return;
  }
  for(j = 0;j<=N-1;j++){
    if(col[j] == NOT_FREE || dpos[i+j] ==NOT_FREE || dneg[i-j+N-1] ==NOT_FREE){
      continue;
    }
    row[i] = j;
    col[j] = dpos[j+i] = dneg[i-j+N-1] = NOT_FREE;
    putQueen(i+1);
    col[j] = dpos[i+j] = dneg[i-j+N-1] =FREE;
  }   
}
void printBoard(){
  int i,j;
  for(i=0;i<N;i++){
    for(j = 0;j<N;j++){
      if(buf[i][j]==1){
	if(row[i]!= j) return;
      }
    }
  }
  for(i=0;i<N;i++){
    for(j = 0;j<N;j++){
      if(row[i] ==j) printf("Q");
      else printf(".");
	
    }
    printf("\n");
  }
}



Measured memory_bytes: 2060
#include <iostream>
using namespace std;
 
int main() {
	int A, B, C;
	cin>>A>>B>>C;
	if(A>=B && A>=C) {
		cout<<B+C;
	} else if(C>=B && C>=A){
		cout<<A+B;
	} else if(B>=A && B>=C){
		cout<<C+A;
	}
	return 0;
}

Measured memory_bytes: 3592
#include <cstdio>
#include <unordered_map>
#include <deque>
#include <algorithm>
using namespace std;
typedef int key;

int main(){
	int r,c,n;
	scanf("%d%d%d",&r,&c,&n);
	unordered_map<key,deque<pair<key,long long>>>m;
	for(;n;n--){
		int s1,s2,d;
		scanf("%d%d%d",&s1,&s2,&d);
		m[s1].emplace_back(s2+r,d);
		m[s2+r].emplace_back(s1,-d);
	}
	for(;!m.empty();){
		long long a=-1LL<<61,b=1LL<<61;
		auto s=m.begin()->first;
		deque<pair<key,long long>>st={{s,0}};
		unordered_map<key,long long>memo={{s,0}};
		for(;!st.empty();){
			auto p=*st.rbegin();st.pop_back();
			auto cur=p.first;long long d=p.second;
			for(auto &e:m[cur]){
				if(memo.find(e.first)==memo.end()){
					st.emplace_back(e.first,d+e.second);
					memo[e.first]=d+e.second;
				}else if(memo[e.first]!=d+e.second){
					puts("No");
					return 0;
				}
			}
			if(cur<=r)a=max(a,d);
			else b=min(b,d);
		}
		if(a>b){
			puts("No");
			return 0;
		}
		for(auto &e:memo)m.erase(m.find(e.first));
	}
	puts("Yes");
}

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

using namespace std;
using ll = long long int;
using ullong = unsigned long long;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i, a, b)  for(int i = (a); i < (b) ; i++)
#define pb push_back
#define SORT(v,n) sort(v, v+n)
#define ALL(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << ": " << x << '\n'
#define int ll
const int INF = 1e9;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
const int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };

signed main() {
	ios::sync_with_stdio(true);
	int a, b, k;
	cin >> a >> b >> k;
	if (a >= k) {
		a -= k;
	}
	else if (a < k) {
		auto x = k - a;
		a = 0;
		b -= x;
		if (b < 0) {
			b = 0;
		}
	}
	else if(a == b){
		a = b = 0;
	}
	cout << a << " " << b << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
bool g[8][8];
int dfs(int now,int n,bool visited[]){
    bool flag=true;
    for(int i=0;i<n;i++){
        if(visited[i]==false)   flag = false;
    }
    if(flag)    return 1;
    int ret = 0;
    for(int i=0;i<n;i++){
        if(g[now][i]&&!visited[i]){
            visited[i] = true;
            ret+=dfs(i,n,visited);
            visited[i] = false;
        }
    }
    return ret;
}

int main(){
    int n,m,a,b;
    cin >> n >> m;
    for(int i=0;i<m;i++){
        cin >> a >> b;
        g[a-1][b-1]=g[b-1][a-1]=true;
    }
    bool visited[8];
    visited[0]=true;
    for(int i=1;i<n;i++)    visited[i]=false;
    cout << dfs(0,n,visited) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


int main(){
    ll X, A, B;
    cin >> X >> A >> B;

    cout << (X - A) % B << endl;
    
    return 0;
}

Measured memory_bytes: 3604
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
vector<ll> tree[100010];
ll parent[100010] = {};
ll next_val[25][100010] = {};
ll logN = 0;
ll N = 0;
ll depth[100010] = {};
void dfs(ll cur, ll par, ll d){
    parent[cur] = par;
    depth[cur] = d;
    for(auto &e: tree[cur]){
        if(e == par) continue;
        dfs(e, cur, d+1);
    }
}

ll get_parent(ll cur, ll num) {
    ll p = cur;
    rrep(k,logN-1, 0){
        if(p == -1){
            break;
        }
        if((num >> k) & 1){
            p = next_val[k][p];
        }
    }
    return p;
}

ll get_LCA(ll va, ll vb){
	if(depth[va] > depth[vb]){
		va = get_parent(va, depth[va] - depth[vb]);
	}else if(depth[va] < depth[vb]){
		vb = get_parent(vb, depth[vb] - depth[va]);
	}
	ll lv = -1, rv = N+1;
	while(rv - lv > 1){
		ll mid = (rv + lv) / 2;
		ll ta = get_parent(va, mid);
		ll tb = get_parent(vb, mid);
		if(ta == -1 || tb == -1){
			rv = mid;
		}else if(ta != tb){
			lv = mid;
		}else{
			rv = mid;
		}
	}
	return get_parent(va, rv);
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll u,v;
    cin >> N >> u >> v;
    u--; v--;
    ll A[100010], B[100010];
    rep(i,0,N-1){
        cin >> A[i] >> B[i];
        A[i]--; B[i]--;
        tree[A[i]].push_back(B[i]);
        tree[B[i]].push_back(A[i]);
    }
    dfs(v, -1, 0);
    rep(i,0,N){
        next_val[0][i] = parent[i];
    }
    logN = floor(log2(N)) + 1;
    rep(k,0,logN){
        rep(i,0,N){
            if(next_val[k][i] == -1){
                next_val[k+1][i] = -1;
            }else{
                next_val[k+1][i] = next_val[k][next_val[k][i]];
            }
        }
    }

    ll ans = 0;
    ll depth_takahashi = depth[u];
    // printa(depth, N);
    rep(i,0,N){
        if(tree[i].size() == 1 && i != v){
            ll pp = get_LCA(u, i);
            // print(i, pp);
            ll dist_takahashi = depth[u] - depth[pp];
            ll dist_aoki = depth[pp];
            if(dist_takahashi < dist_aoki){
                ans = max(ans, depth[i]-1);
            }


        }
    }
    print(ans);
    

}

Measured memory_bytes: 30336
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 17, MAXS = 32775;

int n, m, N, g[MAXN][MAXN], val[MAXS], dp[MAXS][MAXN];

inline void update(int &a, int b){if(a < b) a = b;}
int main(){
	int i, j, k, r, rest, u, v, w, sum = 0;
	scanf("%d%d", &n, &m);
	N = 1 << n;
	for(i = 1; i <= m; ++ i){
		scanf("%d%d%d", &u, &v, &w);
		-- u, -- v;
		g[u][v] = g[v][u] = w;
		sum += w;
	} memset(dp, -1, sizeof(dp));
	for(i = 1; i < N; ++ i){
		for(j = 0; j < n; ++ j)
			if(i & (1 << j)) break;
		val[i] = val[i ^ (1 << j)];
		for(k = j + 1; k < n; ++ k)
			if(i & (1 << k))
				val[i] += g[j][k];
		if(j == 0) dp[i][0] = val[i];
	}
	for(i = 1; i < N; ++ i)
		for(j = 0; j < n; ++ j){
			if((v = dp[i][j]) < 0) continue;
			for(k = 0; k < n; ++ k){
				if(i & (1 << k)) continue;
				if(g[j][k] == 0) continue;
				update(dp[i ^ (1 << k)][k], v + g[j][k]);
				for(rest = r = (N - 1) ^ i ^ (1 << k); r; r = (r - 1) & rest)
					update(dp[i ^ r ^ (1 << k)][k], v + val[r ^ (1 << k)] + g[j][k]);
			}
		}
	cout << sum - dp[N - 1][n - 1] << endl;
	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)

const ll MOD = (ll)1e9 + 7;
const ll HIGHINF = (ll)1e18;

int main() {
  ll n; cin >> n;
  vll s(n);
  REP(i, n) cin >> s.at(i);
  ll q; cin >> q;
  vll t(q);
  REP(i, q) cin >> t.at(i);
  ll ans = 0;
  REP(i, q) {
    REP(j, n) {
      if (s.at(j) == t.at(i)) {
        ans++; break;
      }
    }
  }
  cout << ans << endl;
  return 0;
}



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


int main(){
  string S;
  cin >> S;
  
  int num = S.size();
  
  string s;
  for (int i=0; i<num;i++){
    s+="x";
  }
  cout << s << endl;
  
 return 0;
}
  
  

      
  


Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=9223372036854775807;
ll dp[410][410];
ll b[410][410];

int main(){
    int n;
    cin>>n;
    vector<ll> a(n);
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=0;i<n;i++){
        dp[i][i+1]=0; 
        b[i][i+1]=a[i];
    }
    for(int w=2;w<=n;w++){
        for(int i=0;i<=n-w;i++){
            b[i][i+w]=b[i][i+w-1]+a[i+w-1];
        }
    }
    for(int wide=2;wide<=n;wide++){
        for(int i=0;i<=n-wide;i++){
            int j=i+wide;
            dp[i][j]=INF;
            for(int k=i+1;k<=j-1;k++){
                dp[i][j]=min(dp[i][j],dp[i][k]+dp[k][j]+b[i][j]);
            }
            //cout<<"i="<<i<<" "<<"j="<<j<<" "<<dp[i][j]<<endl;
        }
    }
    cout<<dp[0][n]<<endl;
    return 0;
}

Measured memory_bytes: 2816
#include <iostream>

using namespace std;

int main()
{
    int n;
    int card[210], tmp[210], tmp2[210];    
    int m, k;

    cin >> n;

    for (int i = 1; i <= 2 * n; i++)
        card[i] = i;

    cin >> m;
    while (m--) {
        cin >> k;

        if (k == 0) { // リフルシャッフル
            for (int i = 1; i <= 2 * n; i++)
                tmp[i] = card[i];
            for (int i = 1; i <= n; i++)
                card[2 * i - 1] = tmp[i];
            for (int i = 1; i <= n; i++)
                card[2 * i] = tmp[n + i];
        }
        else { // kでカット
            for (int i = 1; i <= k; i++) 
                tmp[i] = card[i];
            for (int i = 1; i + k <= 2 * n; i++) 
                card[i] = card[k + i];
            for (int i = 1; i <= k; i++)
                card[2 * n - k + i] = tmp[i];
        }

    }
    for (int i = 1; i <= 2 * n; i++)
        cout << card[i] << endl;

    return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define ll long long
#define For(i,a,b) for (int i=a;i<=b;i++)
#define Rep(i,a,b) for (int i=b;i>=a;i--)
using namespace std;
ll ans;
ll n,x,y;
ll a[100100],b[100100],c[100100];
inline ll read()
{
    ll x=0,f=1;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 main()
{
	n=read();
	For(i,1,n)a[i]=read();
	For(i,1,n)b[i]=read();
	For(i,1,n)c[i]=-read();
	sort(a+1,a+n+1);
	sort(b+1,b+n+1);
	sort(c+1,c+n+1);
	For(i,1,n)c[i]=-c[i];
	x=0;y=n;
	For(i,1,n)
	{
		while(a[x+1]<b[i]&&x<n)x++;
		while(c[y]<=b[i]&&y>0)y--;
		ans+=(x*y);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
int a[1005][1005];
int main(){
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++){
        printf("x");
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<pair<ll, ll>> pll;
 
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define popcount(x) __builtin_popcountll(x)
 
const long double PI = acos(-1);
 
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;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}

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

  ll n, a, b, c, d;
  string s;
  cin >> n >> a >> b >> c >> d >> s;

  if(c < d){
    string iwa = s.substr(a-1, d-a+1);
    if(iwa.find("##") == -1) cout << "Yes" << endl;
    else cout << "No" << endl;
  }else{
    string iwa = s.substr(a-1, c-a+1);
    string tmp = s.substr(b-2, d-b+3);
    if(iwa.find("##") == -1 && tmp.find("...") != -1) cout << "Yes" << endl;
    else cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 720
from collections import deque
from sys import stdin

N = int(stdin.readline().rstrip())
A = [int(_) for _ in stdin.readline().rstrip().split()]
B = [int(_) for _ in stdin.readline().rstrip().split()]

ans = 0

for i, b in enumerate(B):
    ans += min(A[i], b)
    b -= min(A[i], b)
    ans += min(A[i+1], b)
    A[i+1] -= min(b, A[i+1])

print(ans)

Measured memory_bytes: 19008
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, x, n) for (int i = x; i < (int)(n); i++)
#define sc(x) scanf("%d",&x)
#define scll(x) scanf("%lld",&x)

vector<vector<int> > edge;
vector<int> cost;

void dfs(int now, int past){
    for (int x : edge[now]) if (x != past){
        cost[x] += cost[now];
        dfs(x, now);
    }
}

int main(){
    int n, q, a, b, p, x; sc(n), sc(q);
    edge.resize(n), cost.resize(n,0);
    rep(i, 0, n-1){
        sc(a), sc(b);
        a--, b--;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    rep(i, 0, q) sc(p), sc(x), cost[p-1]+=x;
    dfs(0, 0);
    for (int x : cost) cout << x << " ";
    return 0;
}

Measured memory_bytes: 23424
n=int(input())
a=list(map(int,input().split()))
cnt1=0
cnt2=0
for i in range(n):
  if a[i]%4==0:
    cnt1+=1
  else:
    if a[i]%2==0:
      cnt2+=1
if cnt2%2==0:
  pass
else:
  cnt2-=1
num=n-cnt2
if num%2==0:
  if cnt1>=num//2:
    print('Yes')
  else:
    print('No')
else:
  if cnt1>=(num-1)//2:
    print('Yes')
  else:
    print('No')

Measured memory_bytes: 62576
from collections import defaultdict

N, K = map(int, input().split())
A = list(map(int, input().split()))
dict = defaultdict(int)
ans = 0
for i in A:
    dict[i] += 1
dict = list(dict.items())
dict = sorted(dict, key=lambda x: x[1])
for i in range(len(set(A)) - K):
    ans += dict[i][1]
print(ans)


Measured memory_bytes: 41380
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int k,n;
  cin>>k>>n;
  int a[n];
  for(int i=0;i<n;++i)
    cin>>a[i];
  int ans=99999999;
  for(int i=0;i<n-1;++i)
    ans=min(ans,k-(a[i+1]-a[i]));
  ans=min(ans,a[n-1]-a[0]);
  cout<<ans;
  return 0;
}
  


Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;

#define ll long long
#define rep(i,n) for(int i = 0;i < (n); i++)
#define LM 1000000000000000000

int main() {
	int n;
	ll ans = 1;
	int chk = 0;
	ll buf;
	cin >> n;
	vector<ll> a(n);
	rep(i, n) {
		cin >> a[i];
		if (a[i] == 0)chk = 1;
	}
	if (chk == 0) {
		rep(i, n) {
			if (a[i] > LM / ans) {
				ans = -1;
				break;
			}
			ans *= a[i];
		}
	}
	else ans = 0;
	
	if (ans > LM)ans = -1;
	cout << ans << endl;
	return 0;
}

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

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse::<T>().ok().expect("failed to parse token")
}

fn main() {
    let a: u32 = read();
    let b = read::<u32>();
    let ans = if (a * b) % 2 == 0 { "Even" } else { "Odd" };
    println!("{}", ans);
}

Measured memory_bytes: 4352
#include <cstdio>
#define N 100005
int n;
struct edge{
    int to,next;
}e[N<<1];
int head[N],cnt;
void add(int u,int v){
    e[++cnt]=(edge){v,head[u]};
    head[u]=cnt;
}
int son[N];
int path[N],len;
bool dfs(int x,int fa){
    bool p=x==n;
    for(int i=head[x];i;i=e[i].next){
        int v=e[i].to;
        if(v==fa)continue;
        p|=dfs(v,x);
    }
    son[fa]+=son[x]+1;
    if(p){
        path[++len]=x;
        return true;
    }
    return false;
}
int main(){
    scanf("%d",&n);
    for(int i=1,u,v;i<n;++i){
        scanf("%d%d",&u,&v);
        add(u,v);add(v,u);
    }
    dfs(1,0);
    int ans=0;
    for(int i=len;i>len/2;--i)
        ans+=son[path[i]]-son[path[i-1]];
        printf("%s\n",ans*2>n?"Fennec":"Snuke");
    return 0;
}
        


Measured memory_bytes: 7552
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

long long func(long long x)
{
    if (x % 2 == 0)
    {
        long long t = x / 2;
        if (t % 2 == 0)
        {
            return x;
        }
        else
        {
            return 1 ^ x;
        }
    }
    else
    {
        long long t = x / 2;
        if (t % 2 == 0)
        {
            return 1;
        }
        else
        {
            return 0;
        }
    }
}

int main(void)
{
    long long a, b;
    cin >> a >> b;
    if (a == 0 && b == 0)
    {
        cout << "0" << endl;
    }
    else if (a == 0)
    {
        cout << b << endl;
    }
    else
    {
        a--;
        long long ans = func(a) ^ func(b);
        cout << ans << endl;
    }
}

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

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  int d[3]={a,b,c};
  sort(d,d+3);
  if((d[2]-d[0]+d[2]-d[1])%2==0){
    cout<<(d[2]-d[0]+d[2]-d[1])/2<<endl;
  }
  else{
    cout<<(d[2]-d[0]+d[2]-d[1]+3)/2<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string S; cin >> S;
  int k=S.size();
  vector<char> MY(k);
  for(int i=0;i<k;i++){
    MY.at(i)=S.at(i);
  }
  if(MY.at(0)!='A'){
    cout << "WA" << endl;
    return 0;
  }
  int check=0;
  for(int i=2;i<k-1;i++){
    if(MY.at(i)=='C'){ check++;}
  }
  if(check!=1){
    cout << "WA" << endl;
    return 0;
  }
  MY.push_back('a');
  sort(MY.begin(), MY.end());
  if(MY.at(2)!='a'){
    cout << "WA" << endl;
    return 0;
  }
  cout << "AC" << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int X = sc.nextInt();
        int Y = sc.nextInt();
        int[] x = new int[n];
        int[] y = new int[m];
        int maxX = -100;
        for (int i = 0; i < n; i++) {
            x[i] = sc.nextInt();
            maxX = Math.max(maxX, x[i]);
        }
        int minY = 100;
        for (int i = 0; i < m; i++) {
            y[i] = sc.nextInt();
            minY = Math.min(minY, y[i]);
        }

        if (Y <= X) {
            System.out.println("War");
            return;
        }
        if (minY <= maxX) {
            System.out.println("War");
            return;
        }

        Set<Integer> can = new HashSet<>();
        for (int i = X+1; i < Y; i++) {
            can.add(i);
        }
        
        for (int i = maxX+1; i <= minY; i++) {
            if (can.contains(i)) {
                System.out.println("No War");
                return;
            }
        }
        System.out.println("War");
    }
}


Measured memory_bytes: 21972
n = int(raw_input())
 
INFTY = float('inf')
 
color = [0 for i in range(n)]
M = [[INFTY for i in range(n)] for j in range(n)]
d = [INFTY for i in range(n)]
p = [-1 for i in range(n)]
 
def MST():
  d[0] = 0
 
  while True:
    cost = INFTY
    for i in range(n):
      if color[i] != 2 and d[i] < cost:
        cost = d[i]
        u = i
 
    if cost == INFTY:
      break
     
    color[u] = 2
 
    for v in range(n):
      if color[v] != 2 and M[u][v] != INFTY and M[u][v] < d[v]:
        d[v] = M[u][v]
        p[v] = u
        color[v] = 1
 
  sum = 0
  for i in range(n):
    if p[i] != -1:
      sum += M[i][p[i]]
  return sum
 
for i in range(n):
  G = map(int, raw_input().split())
  for j in range(n):
   if G[j] != -1:
     M[i][j] = G[j]
 
print MST()

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

int main()
{
    string s;
    string t;
    cin >> s >> t;
    int ans = 0;
    for (int i = 0; i < 3; ++i)
    {
        if(s[i] == t[i]){
            ++ans;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
a,b,c,d = map(int,input().split())
ta = 0
aok = 0
while True:
    ta = c-b
    c = ta

    if c <=0:
        print("Yes")
        break
    aok = a - d
    a = aok
    if a <=0:
        print("No")
        break

Measured memory_bytes: 8940
package main

import "fmt"

func main() {
	var a, b string
	fmt.Scan(&a, &b)
	switch a {
	case "H":
		switch b {
		case "H":
			fmt.Println("H")
		case "D":
			fmt.Println("D")
		}
	case "D":
		switch b {
		case "H":
			fmt.Println("D")
		case "D":
			fmt.Println("H")
		}
	}
}


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

#define int long long
//typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)
 
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
 
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
 
#if 1
//-------------
// DUMPマクロ
// https://www.creativ.xyz/dump-cpp-652/
 
// vector
template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    for (T& x : vec) is >> x;
    return is;
}
// pair
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
// vector
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
// map
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
    os << "{";
    repi(itr, map_var) {
        os << *itr;
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
    os << "{";
    repi(itr, set_var) {
        os << *itr;
        itr++;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
 
#define DUMPOUT cerr
 
void dump_func() {
    DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&& ... tail) {
    DUMPOUT << head;
    if (sizeof...(Tail) > 0) {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}
#ifdef DEBUG
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif
#endif


signed main() {

    int X;
    cin >> X;
    bool can[100201]={false};
    can[0] = true;
    
    rep(i,100001){
        if(can[i]){
            can[i+100] = true;
            can[i+101] = true;
            can[i+102] = true;
            can[i+103] = true;
            can[i+104] = true;
            can[i+105] = true;
        }
    }
    if(can[X]) cout << 1 << endl;
    else cout << 0 << endl;
        
    
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
using ll = long long;
const ll INF = 1000000000000;

std::vector<std::pair<int,int>> dir{{0,1},{1,0},{-1,0},{0,-1}};
int main()
{
    int h,w;
    std::cin >> h >> w;
    std::vector<std::vector<bool>> map(h,std::vector<bool>(w));
    std::vector<std::vector<int>> dist(h,std::vector<int>(w));
    std::queue<std::pair<int,int>> queue;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            char t;
            std::cin >> t;
            dist[i][j] = (t == '#' ? 0 : 100000000);
            map[i][j] = (t == '#');
            if(map[i][j])queue.push({i,j});
        }
    }
    int ans = 0;
    while(queue.size()){
        auto cur = queue.front();
        queue.pop();
        for(auto i : dir){
            if(cur.first + i.first < 0 || cur.first + i.first >= h || cur.second + i.second < 0 || cur.second + i.second >= w)continue;
            if(dist[cur.first + i.first][cur.second + i.second] != 100000000)continue;
            queue.push({cur.first + i.first,cur.second + i.second});
            dist[cur.first + i.first][cur.second + i.second] = dist[cur.first][cur.second] + 1;
            //seen[cur.first + i.first][ur.second + i.second] = true;
        }
    }
    for(int i = 0; i < h; i++){
        int cur = *std::max_element(dist[i].begin(), dist[i].end());
        ans = std::max(cur,ans);
    }
    std::cout << ans << std::endl;
}

Measured memory_bytes: 12560
#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 K, A, B;
  cin >> K >> A >> B;
  
  for(int i=A; i<=B; i++){
   if(i%K == 0){
    cout << "OK" << endl;
     return 0;
   }
  }
  cout << "NG" << endl;
  return 0;
}

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

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

  vector<unsigned int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }

  int c = 0;

  while (true) {
    for (int i = 0; i < N; i++) {
      if (A.at(i) % 2) {
        goto END;
      }
      A.at(i) /= 2;
    }
    c++;
  }

 END:
  cout << c << endl;
}


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

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

int main()
{
    int a, b;
    cin >> a >> b;
    string s;
    cin >> s;

    bool flag = 0;
    rep(i, s.size())
    {
        if (i == a)
        {
            if (s[i] != '-')
                flag = 1;
        }
        else
        {
            if (!isdigit(s[i]))
                flag = 1;
        }
    }

    flag == 0 ? OP("Yes") : OP("No");
    return 0;
}

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

using namespace std;

void solve()
{
	int N;
	cin >> N;
	vector<int> sum(N);
	int n = N * (N - 1) / 2;
	for(int i = 0; i < n; ++i)
	{
		int t1, t2;
		cin >> t1 >> t2;
		int p1, p2;
		cin >> p1 >> p2;
		if(p1 > p2)
		{
			sum[t1 - 1] += 3;
		}
		else if(p1 < p2)
		{
			sum[t2 - 1] += 3;
		}
		else
		{
			++sum[t1 - 1];
			++sum[t2 - 1];
		}
	}
	vector<int> ans(N);
	set<int> kind;
	for(int i = 0; i < N; ++i)
	{
		kind.insert(sum[i]);
	}
	int rank = 1;
	set<int>::reverse_iterator rit = kind.rbegin();
	while(rit != kind.rend())
	{
		int count = 0;
		for(int i = 0; i < N; ++i)
		{
			if(*rit == sum[i])
			{
				ans[i] = rank;
				++count;
			}
		}
		rank += count;
		++rit;
	}
	for(int i = 0; i < N; ++i)
	{
		cout << ans[i] << endl;
	}
}

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

Measured memory_bytes: 1196
#include <iostream>

int main(){
	int a,b;
	std::cin >> a >> b;
	if(a < b){
		std::cout << "a < b" << std::endl;
	}
	else if(a > b){
		std::cout << "a > b" << std::endl;
	}
	else{
		std::cout << "a == b" << std::endl;
	}
}



Measured memory_bytes: 3068
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
const int N = 1e5 + 5, MOD = 1e9 + 7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());



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

    int a, b;
    cin>>a>>b;
    if(b == 1){
        cout<<0;
        return 0;
    }
    b -= a;
    int cnt = 1;
    a--;
    while(1){
        if(b <= 0){
            cout<<cnt;
            return 0;
        }
        b -= a;
        cnt++;
    }
    cout<<cnt;


    return 0;
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
 
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
 
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
 
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}
 
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
 
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
 
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
 
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
 
 
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    /*     input! {
        n: usize,
        mut plan: [(i32, i32, i32); n],  // Vec<(i32, i32, i32)>
    }
 */
    input! {
        n: u64,
        m: u64,
        abs:[(isize,isize);n],
        cds:[(isize,isize);m],
    }

    for &(a,b) in abs.iter(){
        let mut min_kyori = std::isize::MAX;
        let mut ans = 0;
        for (j,&(c,d)) in cds.iter().enumerate(){
            let kyori = (a - c).abs() + (b - d).abs();
            if min_kyori > kyori {
                min_kyori = kyori;
                ans = j;
            }
        }
        println!("{}",ans + 1);
    }



}  


Measured memory_bytes: 4352