akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long
using namespace std;
#define REP(i, n) for (long long i = 0, max_i = (n); i < max_i; i++)
template <class T>
ostream& operator<<(ostream& s, vector<T>& d) {
    REP(i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : " ");
    return s;
}
using Int = long long;

struct Dinic {
    struct edge {
        int to, cap, rev;
    };

    int n;
    vector<vector<edge>> G;
    vector<int> level;
    vector<int> iter;

    void bfs(int s) {
        level.assign(n, -1);
        queue<int> que;
        que.push(s);
        level[s] = 0;
        while (que.size()) {
            int v = que.front();
            que.pop();
            for (int i = 0; i < G[v].size(); i++) {
                edge& e = G[v][i];
                if (e.cap > 0 && level[e.to] < 0) {
                    level[e.to] = level[v] + 1;
                    que.push(e.to);
                }
            }
        }
    }

    int dfs(int v, int t, int f) {
        if (v == t) return f;
        for (int i = iter[v]; i < G[v].size(); i++) {
            edge& e = G[v][i];
            if (e.cap > 0 && level[v] < level[e.to]) {
                int d = dfs(e.to, t, min(f, e.cap));
                if (d > 0) {
                    e.cap -= d;
                    G[e.to][e.rev].cap += d;
                    return d;
                }
            }
        }
        return 0;
    }

    Dinic(int n) : n(n), G(n), level(n), iter(n) {}

    void add_edge(int from, int to, int cap) {
        G[from].push_back({to, cap, (int)G[to].size()});
        G[to].push_back({from, 0, (int)G[from].size() - 1});
    }

    int max_flow(int s, int t) {
        int flow = 0;
        while (1) {
            bfs(s);
            if (level[t] < 0) return flow;
            iter.assign(n, 0);
            int f;
            while ((f = dfs(s, t, 1e9)) > 0) {
                flow += f;
            }
        }
    }
};

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

    int n, m;
    cin >> n >> m;

    Dinic hoge(n), fuga(n);

    for (int i = 0; i < m; i++) {
        int a, b, c;
        cin >> a >> b >> c;

        hoge.add_edge(a, b, 2 * c);
        hoge.add_edge(b, a, 2 * c);
        fuga.add_edge(a, b, c == 1 ? 1 : 2 * c);
        fuga.add_edge(b, a, c == 1 ? 1 : 2 * c);
    }

    int h = hoge.max_flow(0, n - 1);
    int f = fuga.max_flow(0, n - 1);
    int ans = h == f ? h / 2 : h / 2 - 1;
    if (ans > 10000) {
        cout << -1 << endl;
        return 0;
    }
    cout << ans << endl;
}



Measured memory_bytes: 4640
#include <bits/stdc++.h>
#define int long long
#define double long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define pii pair<int,int>
#define ff first
#define ss second
#define frr(i,n) for(int i=0;i<n;i++)
#define td(v) v.begin(),v.end()
#define inf 1000000000 // 1e9
#define M   1000000007 // 1e9 + 7
using namespace std;
inline int mod(int n, int m){ int ret = n%m; if(ret < 0) ret += m; return ret; }
int gcd(int a, int b){return (b == 0 ? a : gcd(b, a%b));}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
int exp(int a,int b,int m){
    if(b==0) return 1;
    if(b==1) return mod(a,m);
    int k = mod(exp(a,b/2,m),m);
    if(b&1){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);
}
int32_t main(){
    fastio;
    int r,d,x;
    cin >> r >> d >> x;
    for(int i=0;i<10;i++){
        cout << r*x - d << endl;
        x =  r*x - d;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<utility>
#include<queue>
#define rep(i, n) for(int i=0;i<n;i++)
using namespace std;
int main(){
	int h, n;
	cin>>h>>n;
	int a, b=0;
	rep(i, n){
		cin>>a;
		b+=a;
	}
	if(h<=b)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define Fst first
#define Snd second
#define RG register
#define mp make_pair
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long LL;
typedef long double LD;
typedef unsigned int UI;
typedef unsigned long long ULL;
template<typename T> inline void read(T& x) {
	char c = getchar();
	bool f = false;
	for (x = 0; !isdigit(c); c = getchar()) {
		if (c == '-') {
			f = true;
		}
	}
	for (; isdigit(c); c = getchar()) {
		x = x * 10 + c - '0';
	}
	if (f) {
		x = -x;
	}
}
template<typename T, typename... U> inline void read(T& x, U& ... y) {
	read(x), read(y...);
}
int n,K;
LL A[100010],L[100010],R[100010],S[100010];
//#define rua
int main() {
//	ios::sync_with_stdio(false);
#ifdef rua
	freopen("GG.in","r",stdin);
#endif
  read(n,K);
  for(int i=1;i<=n;++i) read(A[i]),S[i]=S[i-1]+A[i];
  for(int i=1;i<=n;++i) {
    L[i]=L[i-1];
    if(A[i]>0) L[i]+=A[i];
  }
  for(int i=n;i;--i) {
    R[i]=R[i+1];
    if(A[i]>0) R[i]+=A[i];
  }
  LL res=0;
  for(int i=1;i<=n-K+1;++i) res=max(res,L[i-1]+R[i+K]+max(0ll,S[i+K-1]-S[i-1]));
  printf("%lld\n",res);
  return 0;
}


Measured memory_bytes: 3328
#include <stdio.h>

int main(){
	
	int H1, M1;
	int H2, M2;
	int K;
	
	scanf("%d %d %d %d %d", &H1, &M1, &H2, &M2, &K);
	
	int time1 = H1 * 60 + M1;
	int time2 = H2 * 60 + M2;
	int total = (time2 - K) - time1;
	
	printf("%d\n", total);
	
	return 0;
}

Measured memory_bytes: 1680
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

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

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

const int N = 200;
int dp[N][4][4][4];
int A[4][4];
int B[4][4][4];

void add(int& x, int y) {
  x = (x + y) % MOD;
}

int main() {
  memset(A, 255, sizeof(A));
  memset(B, 255, sizeof(B));
  A[0][2] = 1;
  A[0][1] = 2;
  A[2][0] = 1;
  for (int i = 0; i < 4; ++i) {
    B[0][i][2] = 1;
    B[0][2][i] = 1;
  }
  for (int i = 0; i < 4; ++i) {
    for (int j = 0; j < 4; ++j) {
      for (int k = 0; k < 4; ++k) {
        if (A[i][j] == k) continue;
        dp[3][i][j][k] = 1;
      }
    }
  }
  int n;
  cin >> n;
  for (int len = 3; len < n; ++len) {
    for (int i = 0; i < 4; ++i) {
      for (int j = 0; j < 4; ++j) {
        for (int k = 0; k < 4; ++k) {
          for (int u = 0; u < 4; ++u) {
            if (u == A[j][k]) continue;
            if (u == B[i][j][k]) continue;
            add(dp[len + 1][j][k][u], dp[len][i][j][k]);
          }
        }
      }
    }
  }
  int ret = 0;
  for (int i = 0; i < 4; ++i) {
    for (int j = 0; j < 4; ++j) {
      for (int k = 0; k < 4; ++k) {
        add(ret, dp[n][i][j][k]);
      }
    }
  }
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<map>
#include<set>
#include<queue>
#include<cmath>

using namespace std;

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(a) (a).begin(),(a).end()
#define PI 3.141592653589793238
#define INF 1050000000
#define INFL (long long)(4e18)

using vi = vector<int>;

template<class T>
struct Edge {
    int to;
    T cost;
    Edge() {};
    Edge(int to, T cost) : to(to), cost(cost) {};
};

template<class T>
class Graph {
    int n;
    bool directed;
    vector<vector<Edge<T>>> edges;
public:

    Graph(int n, bool directed) :n(n), directed(directed), edges(vector<vector<Edge<T>>>(n)){};
    Graph() {};

    void add(int to, T cost) {
        emplace_back(to, cost);
    }

    int size() {
        return n;
    }
};


int main() {

    double H;

    cin >> H;

    long long ans = pow(2,floor(log2(H)+1))-1;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <vector>
using namespace std;

#define REP(i, a, b) for(int i = (a); i < int(b); ++i)
#define rep(i, n) REP(i, 0, n)

struct union_find {
	vector<int> uf;
	vector<int> num;

	union_find(int n):uf(2 * n, -1), num(2 * n, 0) {
		fill(num.begin(), num.begin() + n, 1);
	}

	inline bool root(int x) const {
		return uf[x] < 0;
	}

	inline int find(int x) {
		return root(x) ? x : uf[x] = find(uf[x]);
	}

	inline void unite(int x, int y) {
		x = find(x);
		y = find(y);

		if(x == y) return;

		if(uf[x] > uf[y]) {
			swap(x, y);
		}

		num[x] += num[y];
		uf[x] += uf[y];
		uf[y] = x;
	}

	inline int number_of_sets() const {
		return count_if(uf.begin(), uf.begin() + uf.size() / 2, [](int x) { return x < 0; });
	}
};

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

	for(int n, p1, p2; cin >> n >> p1 >> p2 && (n | p1 | p2);) {
		const int V = p1 + p2;
		union_find uf(V);

		bool has_no = false;
		rep(i, n) {
			int x, y;
			string s;
			cin >> x >> y >> s;
			--x; --y;

			if(s[0] == 'n') { // no
				y += V;
				has_no = true;
			}

			uf.unite(x, y);
			uf.unite(x + V, (y + V) % (2 * V));
		}

		if(p1 == 0) {
			cout << (has_no ? "no" : "end") << endl;
			continue;
		}

		if(p2 == 0) {
			if(has_no) {
				cout << "no" << endl;
				continue;
			}

			rep(i, V) {
				cout << i + 1 << endl;
			}
			cout << "end" << endl;
			continue;
		}

		const int m = uf.number_of_sets();

		vector<int> idx, a, b;
		idx.reserve(m);
		a.reserve(m);
		b.reserve(m);

		rep(i, V) {
			if(uf.root(i) || uf.root(i + V)) {
				idx.emplace_back(i);
				a.emplace_back(uf.num[i]);
				b.emplace_back(uf.num[i + V]);
			}
		}

		vector<vector<int>> dp(m + 1, vector<int>(V + 1, 0));
		dp[0][0] = 1;

		rep(i, m) {
			rep(j, V - a[i]) {
				dp[i + 1][j + a[i]] += dp[i][j];
			}

			rep(j, V - b[i]) {
				dp[i + 1][j + b[i]] += dp[i][j];
			}
		}

		if(dp[m][p1] != 1) {
			cout << "no" << endl;
			continue;
		}

		int sum = p1;
		vector<bool> which(m);
		for(int i = m - 1; i >= 0; --i) {
			if(dp[i][sum - a[i]] == 1) {
				which[i] = true;
				sum -= a[i];
			}
			else {
				which[i] = false;
				sum -= b[i];
			}
		}

		vector<int> ans;
		ans.reserve(p1);

		rep(i, V) {
			bool T = true;
			int r = uf.find(i);

			if(r >= V) {
				r = uf.find(r - V);
				T = false;
			}

			const int id = lower_bound(idx.begin(), idx.end(), r) - idx.begin();

			if(which[id]) {
				if(T) ans.emplace_back(i + 1);
			}
			else {
				if(!T) ans.emplace_back(i + 1);
			}
		}

		for(const auto &e : ans) {
			cout << e << endl;
		}
		cout << "end" << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1368
hash = Hash.new(nil)
c="a"
(1..6).each{|i|
  (1..5).each{|j|
    hash["#{i}#{j}"]=c
    c=c.succ
  }
}
hash["62"]="."
hash["63"]="?"
hash["64"]="!"
hash["65"]=" "
while gets
  $_.gsub!(/(\d\d)/,'\1\2 ')
  out = ""
  naflag = false
  $_.split.each{|s|
    if hash[s]
      out << hash[s]
    else naflag =true
    end
  }
  puts naflag ? "NA" : out
end

Measured memory_bytes: 2500
#include <bits/stdc++.h>
using namespace std;
#define PI 3.14159265358979323
#define ll long long int
#define vi vector <int>
#define vl vector <ll>
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define MOD 1000000007
ll power(ll a, ll b) { //a^b
	ll res = 1;
	while (b > 0) {
		if (b & 1) {res = (res * a); b--;}
		a = (a * a);
		b >>= 1;
	}
	return res;
}
ll n;
ll gcd(ll a, ll b) {return (b == 0) ? a : gcd(b, a % b);}


int main() {
	ll n,k;
	cin>>n>>k;
	vector <ll> a(n+1);
	for(ll i=1;i<=n;i++)
		cin>>a[i];
	vector < vector <ll> > dp(n+1, vector <ll> (k+1));
	
	for(ll j=0;j<=k;j++)
		dp[0][j]=0;
	dp[0][0]=1;
	for(ll i=1;i<=n;i++){
		vector <ll> pre(k+1);
		pre[0]=dp[i-1][0];
		for(ll j=1;j<=k;j++)
			pre[j]=(pre[j-1]+dp[i-1][j])%MOD;
		for(ll j=0;j<=k;j++){
			if(j<=a[i])
				dp[i][j]=pre[j];
			else{
				ll non=j-a[i]-1;
				dp[i][j]=(pre[j]-pre[non]+MOD)%MOD;
			}
		}
	}
	cout<<dp[n][k]<<"\n";
}


Measured memory_bytes: 83180
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>

typedef long long  ll;
typedef long double ld;

using namespace std;

int main()
{
    ld W, H, x, y;

    std::cin >> W >> H >> x >> y;

    std::cout << (W*H)/2 << " " << (x+x==W && y+y==H) << std::endl;

    return 0;
}


Measured memory_bytes: 256
#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(){
    ll n,k;
    cin >> n >> k;
    int a,b;
    double ans=0,ans2=0;
    //ans=(n-k+1)/double(n);

    rep(i,n){
        a=0;
        b=i+1;
        while(b<k){
            ++a;
            b*=2;
        }
        ans2+=pow(0.5,a)/double(n);
    }

    ans+=ans2/double(n);

    //cout << ans << endl;

    printf("%.10f",ans2);
    

    return 0;
}

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

int main()
{
  int n;
  cin >> n;
  vector<int> t(n);
  int i, j;
  for(i = 0; i < n; i++)
  {
    cin >> t.at(i);
  }
  int m;
  cin >> m;
  vector<int> p(m);
  vector<int> x(m);
  for(i = 0; i < m; i++)
  {
    cin >> p.at(i);
    cin >> x.at(i);
  }
  int ans = 0;
  for(i = 0; i < m; i++)
  {
    for(j = 0; j < n; j++)
    {
      if(p.at(i)-1==j)
      {
        ans += x.at(i);
      }
      else
      {
        ans += t.at(j);
      }
    }
    cout << ans << endl;
    ans = 0;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <limits>
#include <climits>
#include <utility>
#include <algorithm>
#include <numeric>

using namespace std;

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

int digit(int x) {
    int d = 0;

    while (x) {
        ++d;
        x /= 10;
    }

    return d;
}

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

    int p = pow(10, digit(b));
    int x = a * p + b;

    for (int i = 0; i*i <= x; ++i) {
        if (i*i == x) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;

    return 0;
}


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

const int INF = 1 << 30;

struct Dinic
{
  struct edge
  {
    int to, cap, rev;
    bool alive;
  };
 
  vector< vector< edge > > graph;
  vector< int > used;

  Dinic(int n)
  {
    graph.resize(n);
  }
 
  void add_edge(int from, int to, int cap)
  {
    graph[from].push_back((edge){to, cap, (int)graph[to].size(), true});
    graph[to].push_back((edge){from, cap, (int)graph[from].size() - 1, true});
  }

  int dfs(int idx, const int t, int flow)
  {
    if(idx == t) return(flow);
    used[idx] = true;
    for(int i = 0; i < graph[idx].size(); i++) {
      edge& e = graph[idx][i];
      if(!e.alive) continue;
      if(e.cap > 0 && !used[e.to]) {
        int d = dfs(e.to, t, min(flow, e.cap));
        if(d > 0) {
          e.cap -= d;
          graph[e.to][e.rev].cap += d;
          return(d);
        }
      }
    }
    return(0);
  }

  int max_flow(int s, int t, int lim)
  {
    int flow = 0;
    while(lim > 0) {
      used.assign(graph.size(), 0);
      int f = dfs(s, t, lim);
      if(f == 0) break;
      flow += f;
      lim -= f;
    }
    return(flow);
  }

  bool back_edge(int from, int to)
  {
    for(edge& e : graph[from]) {
      if(e.to == to && e.alive) {
        e.alive = false;
        if(e.cap == 0 && max_flow(from, to, 1) == 0) {
          max_flow(from, 0, 1);
          max_flow(graph.size() - 1, to, 1);
          return(1);
        } else {
          return(0);
        }
      }
    }
  }

};


int main()
{
  int N, E, Q;
  cin >> N >> E >> Q;
  Dinic graph(N);
  while(E--) {
    int F, T;
    cin >> F >> T;
    --F, --T;
    graph.add_edge(F, T, 1);
  }
  int flow = graph.max_flow(0, N - 1, INF);
  while(Q--) {
    int M, A, B;
    cin >> M >> A >> B;
    --A, --B;
    if(M == 1) {
      graph.add_edge(A, B, 1);
      flow += graph.max_flow(0, N - 1, 1);
    } else {
      flow -= graph.back_edge(A, B);
      flow -= graph.back_edge(B, A);
    }
    cout << flow << endl;
  }
}

Measured memory_bytes: 3924
a, b, c, x, y = map(int, input().split())
min_sum = pow(10, 10)

for i in range(0, max(x, y) * 2 + 1, 2):
    d = x - i // 2
    e = y - i // 2
    if d < 0 :
        d = 0
    if e < 0:
        e = 0
    sum = a * d + b * e + c * i
    
    if min_sum > sum :
        min_sum = sum

print(min_sum)

Measured memory_bytes: 9100
#include <stdio.h>

int main(){
	int cup[3] = {1,0,0},tmp;
	char a,b;
	while(scanf("%c,%c",&a,&b) != EOF){
		tmp = cup[a - 'A'];
		cup[a - 'A'] = cup[b - 'A'];
		cup[b - 'A'] = tmp;
	}
	for(tmp = 0;tmp < 3;tmp++){
		if(cup[tmp]) printf("%c\n",tmp + 'A');
	}
	return 0;
}

Measured memory_bytes: 972
#include <iostream>
#include <set>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <map>
using namespace std;

vector<bool> prime;
map<long,long> mp;

void sieve(long max){
    prime.resize(sqrt(max)+1,true);
    prime[0]=false;
    prime[1]=false;
    for(long i=2; i*i<=sqrt(max); ++i) // 0からsqrt(max)まで調べる
        if(prime[i]==true){ // iが素数ならば
            for(long j=2; i*j<=sqrt(max); ++j){ // (max以下の)iの倍数は
                prime[i*j] = false;// 素数ではない
            }
        }
}
int main(){
    long n,p;
    cin >> n >> p;
    long ans = 1;
    sieve(p);
    for(long i=2;i<prime.size();i++){
        mp[i]=0;
        long x=p;
        if(prime[i]==true){
            for(long j=0;pow(i,j)<p;j++){
                if(x%i==0){
                    mp[i]++;
                    x/=i;
                }else break;
            }
            if(mp[i]>=n && mp[i]/n>1){
                ans=ans*pow(i,mp[i]/n);
            }else if(mp[i]>=n){
                ans=ans*i;
            }
        }
    }
    if(n==1)ans=p;
    cout << ans;
}

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

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

    int n;
    cin >> n;

    map<string,int> mp;

    for(int i = 0; i < n; i++){
        string s;
        cin >> s;
        sort(s.begin(),s.end());
        mp[s]++;
    }

    ll ans = 0;

    for(auto & i : mp){
        ll a = i.second;
        ans += a * (a - 1) / 2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 11264
n = int(input().strip())
a,b = map(int,input().strip().split())
c,d = map(int,input().strip().split())
flag = 0
for i in range(n-2):
  e,f = map(int,input().strip().split())
  if a == b and c == d and e == f:
    flag = 1
  a,b = c,d
  c,d = e,f
if flag == 0:
  print("No")
else:
  print("Yes")

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

using namespace std;

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

	char ans = 'x';
	if (a + b == 15) {
		ans = '+';
	} else if (a * b == 15) {
		ans = '*';
	}

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


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
#include<numeric>
using namespace std;
using ll = long long;
int main(){
  int l, r, d;
  cin >> l >> r >> d;
  int ans = 0;
  for(int i = l; i <= r; i++){
    if(i % d == 0){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

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

typedef long long ll;

#define REP(i, n) for (int i = 0; i < (n); i++)
#define INF (1<<30)

int main() {
	ll N, M;
	cin >> N >> M;
	vector<pair<ll,ll> > A(N);
	for (ll i = 0; i < N; i++) {
		ll a, b;
		cin >> a >> b;
		A[i].first = a;
		A[i].second = b;
	}
	sort(A.begin(), A.end());

	ll ans=0;
	for (ll i = 0; i < N; i++) {
		if (M - A[i].second > 0) {
			M -= A[i].second;
			ans += A[i].first * A[i].second;
		}
		else {
			ans += A[i].first * M;
			break;
		}
	}

	cout << ans << endl;

}


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

int main() {
	int H,W;
	cin>>H>>W;
	vector<string> S(H);
	rep(i,H)cin>>S[i];

	rep(i,H)rep(j,W){
		if(S[i][j] == '.'){
			S[i][j]='0';
			for (int dx = -1; dx <= 1; ++dx){
				for (int dy = -1; dy <= 1; ++dy){
					int nx = i+dx,ny = j+dy;
					if(0<=nx&&nx<H&&0<=ny&&ny<W){
						if(S[nx][ny]=='#')S[i][j]++;
					}
				}
			}
		}
	}
rep(i,H)cout<<S[i]<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repit(it, li) for(auto it=li.begin(); it!=li.end(); it++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){
   int n, m;
   cin>>n>>m;
   vector<int> e[200000];
   rep(i, m){
      int a, b;
      cin>>a>>b; a--; b--;
      e[a].push_back(b);
      e[b].push_back(a);
   }

   int mx=0;
   vector<bool> mita(n);
   rep(i, n){
      int c=0;
      queue<int> q;
      mita[i]=true;
      q.push(i);
      while(!q.empty()){
         int v=q.front(); q.pop();
         for(int u : e[v]) if(!mita[u]){
            mita[u]=true;
            q.push(u);
         }
         c++;
      }
      mx=max(mx, c);
   }

   cout<<mx<<endl;
   return 0;
}


Measured memory_bytes: 15092
#include <bits/stdc++.h>
using namespace std;
long long a,b,c,a1,b1,c1;
long long k;
int main()
{
	scanf("%lld%lld%lld%lld",&a,&b,&c,&k);
	k%=2;
	while (k--)
	{
		a1=b+c;
		b1=a+c;
		c1=a+b;
		a=0,b=b1-a1,c=c1-a1;
		if (abs(a-b)>1e18)
		{
			printf("Unfair\n");
			return 0;
		}
		if (a==0&&b==0&&c==0)
		{
			printf("%d\n",0);
			return 0;
		}
	}
	printf("%lld\n",a-b);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  string s;
  cin >> s;
  
  int counter;
  counter = 0;
  string result;

  for(int i = 0; i < N; i++){
    if(s.at(i) == 'R'){
      counter += 1;
    }
  }

  N /= 2;

  if(counter >= N+1){
    result = "Yes";
  }

  else{
    result = "No";
  }

  cout << result << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
const long long INF = 1e15;

int main(){
  int h,w;
  cin >> h >> w;
  int k;
  cin >> k;

  string s[h];
  for(int i = 0; i < h; i++) cin >> s[i];

  vector<vector<int>> ans(h,vector<int>(w,-1));
  map<int,bool> emp;
  vector<int> cnt(w,0);

  for(int i = 0; i < w; i++){
    bool zero = true;
    for(int j = 0; j < h; j++){
      if(s[j][i] == '#'){
        zero = false;
        cnt[i]++;
      }
    }
    emp[i] = zero;
  }
  
  int num = 1;
  for(int i = 0; i < w; i++){
    if(emp[i]) continue;
    for(int j = 0; j < h; j++){
      ans[j][i] = num;
      if(s[j][i] == '#' && cnt[i] > 1){
        num++;
        cnt[i]--;
      }
    }
    num++;
  }

  for(int i = 0; i < h; i++){
    int now = -1;
    for(int j = 0; j < w; j++){
      if(ans[i][j] == -1) ans[i][j] = now;
      else now = ans[i][j];
    }
    now = -1;
    for(int j = w; j >= 0; j--){
      if(ans[i][j] == -1) ans[i][j] = now;
      else now = ans[i][j];
    }
  }

  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      cout << ans[i][j] << " ";
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 4128
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#ifdef LOCAL
#include "Template.cpp"
#else
#define t(...)
#endif
#define endl "\n"

void solve()
{
    int k; cin >> k;
    while(k -- ) cout << "ACL";
    cout << endl;
}

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    // cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3648
#include<iostream>
#include<string>
using namespace std;
static const int MAX_SIZE=3000;
struct P{
	int size,ij;//size=文字列長 , ij=前の(i,j)
	char in;//入れる文字
};
P dp[MAX_SIZE+10][MAX_SIZE+10];
int main(void){
	string s,t,ans;
		cin >> s >> t;
	int ss=s.size(),ts=t.size();
	
	for(int i=ss-1;i>=0;i--){
		for(int j=ts-1;j>=0;j--){
			if(s[i]==t[j]){
				dp[i][j].size=dp[i+1][j+1].size+1;
				dp[i][j].ij=((i+1<ss)&&(j+1<ts)?(ss-(i+1)-1)*ts+(ts-(j+1)-1):-1);
				dp[i][j].in=s[i];
			}
			else{
				if(dp[i][j+1].size>dp[i+1][j].size){
					dp[i][j].size=dp[i][j+1].size;
					dp[i][j].ij=(j+1<ts)?(ss-i-1)*ts+(ts-(j+1)-1):-1;
				}else{
					dp[i][j].size=dp[i+1][j].size;
					dp[i][j].ij=(i+1<ss)?(ss-(i+1)-1)*ts+(ts-j-1):-1;
				}
				dp[i][j].in='@';
			}
		}
	}
	int i=0,j=0;
	while(1){
		if(dp[i][j].in!='@')
			cout << dp[i][j].in;
		if(dp[i][j].ij<0)
			break;
		int fi=i;
		i=ss-(dp[i][j].ij/ts)-1;
		j=ts-(dp[fi][j].ij%ts)-1;
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 106112
def p(u):
 if u+1:print(s,u,end=s);p(T[u]);p(T[u+N])
def i(u):
 if u+1:i(T[u]);print(s,u,end=s);i(T[u+N])
def o(u):
 if u+1:o(T[u]);o(T[u+N]);print(s,u,end=s)
s=''
N=int(input())
T=[0,0]*N
for _ in[0]*N:
 a,b,c=map(int,input().split())
 T[a],T[a+N]=b,c
r=(set(range(N))-set(T)).pop()
print('Preorder')
p(r)
print('\nInorder')
i(r)
print('\nPostorder')
o(r)
print()


Measured memory_bytes: 5624
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>

typedef long long ll;
const ll LL_MAX (1LL<<60);

#define rep(i,s,e) for(ll i=(s); i<(e); i++) 

using namespace std;

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

    ll a, b;
    cin >>a>>b;

    if (a-b*2 > 0)
        cout << a-b*2 << endl;
    else
        cout << 0 << endl;

    return 0;
}


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

#define REP(i,num) for(ll i=0;i<(num);++i)
#define FOR(i,c,num) for(ll (i)=(c);(i)<(num);++(i))
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=ll>
T in(){T x; cin >> x; return (x);}
template<typename T=ll,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return x;}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	auto S=in<string>(),T=in<string>();
	int N=S.size(),K=0;
	REP(i,N){
		if(S[i]==T[i]) K++;
	}
	
	out(N-K);
	return 0;
}


Measured memory_bytes: 3808
n, m = map(int, input().split())
s = list(map(int, input().split()))
t = list(map(int, input().split()))
MOD = 10**9 + 7

dp = [[0]*(m+1) for i in range(n+1)]
for si in range(n+1):
    dp[si][0] = 1
for ti in range(m+1):
    dp[0][ti] = 1

for si in range(n):
    for ti in range(m):
        if s[si] == t[ti]:
            dp[si+1][ti+1] = dp[si][ti+1] + dp[si+1][ti]
            dp[si+1][ti+1] %= MOD 
        else:
            dp[si+1][ti+1] = dp[si][ti+1] + dp[si+1][ti] - dp[si][ti] 
            dp[si+1][ti+1] %= MOD

print(dp[-1][-1] % MOD)

Measured memory_bytes: 72668
#include <iostream>
#include <cstdio>
#include <map>
#include <set>
#include <queue>
#include <vector>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#define rep(i,a,b) for(int i = a; i <= b; i++)
#define dep(i,a,b) for(int i = a; i >= b; i--) 
#define Rep(i,a) for(int i = 0; i < a; i++)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define ab(x) ((x) < 0 ? -(x) : (x))
using namespace std;
typedef long long LL;
typedef map<int, int>::iterator mit;
typedef set<int>::iterator sit;
const int N = 100010;
int cnt[N];
int main() {
	int n; scanf("%d",&n);
	rep(i,1,n) { int a; scanf("%d",&a); cnt[a]++; }
	int tot = 0;
	rep(i,1,N - 10) if (cnt[i] >= 2) tot += cnt[i] - 1;
	if (!tot) cout <<n<<endl;
	else if (tot & 1) cout <<n - tot - 1<<endl;
	else cout <<n - tot<<endl;
}

Measured memory_bytes: 768
#include <stdio.h>

int main(void)
{
	int n;
	double money = 100000;
	int i;
	
	scanf("%d", &n);
	
	for(i = 0; i < n; i++){
		money += (money * 0.05);
		if(((int)money % 1000) != 0){
			money -= ((int)money % 1000);
			money += 1000;
		}
	}
	
	printf("%.0f\n", money);
	
	return 0;
}

Measured memory_bytes: 624
#include <iostream>

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


    if (a > b) {
        int var = a;
        a = b;
        b = var;
    }

    if (a < c) {
        if (c < b) {
            std::cout << "Yes" << std::endl;
            return 0;
        } else {

        }


    }
    std::cout << "No" << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<algorithm>
#include<vector>
#include<math.h>

using namespace std;
int main(){
    string str;
    int p, a, b;
    string command, alt;
    
    string abb ; 
    cin >> str >> p;
    for(int i = 0; i < p; i++){
        cin >> command;
        if(command == "replace"){
            cin >> a >> b >> alt;
            str.replace(a, b-a+1, alt);
            }
        
        if(command == "reverse"){
            cin >> a >> b;
            string rev;
            abb = str.substr(0, a);
            alt = str.substr(b + 1, str.size() - 1);
            
            for(int i = b; i >= a; i--){
                rev += str[i];
            }
            str = abb + rev + alt;
        }
        if(command == "print"){
            cin >> a >> b;
            for(int i = a; i <= b; i++){
                cout << str[i];
            }
            cout << endl;
        } 
    }
    return 0;
    }

    

           

Measured memory_bytes: 3180
#include <iostream>
#include <vector>
#include <algorithm>
#include <ctime>
#include <cmath>
#include <string>
#include <stdlib.h>
#include <fstream>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <iterator>
#include <iomanip>
using namespace std;

vector<vector<pair<long long, long long> > > g;
vector<long long> a;
vector<char> used;

void dfs(long long v){
    used[v] = true;
    for(auto to : g[v]){
        if(a[to.first] == 1e18){
            a[to.first] = a[v] + to.second;
            dfs(to.first);
        }
        else{
            if(a[to.first] != a[v] + to.second){
                cout << "No\n";
                exit(0);
            }
        }
    }
}

int main(){
    long long n, m, l, r, d;
    cin >> n >> m;
    g.resize(n);
    a.assign(n, 1e18);
    for(int i = 0; i < m; ++i){
        cin >> l >> r >> d;
        l--, r--;
        g[r].push_back({l, -d});
        g[l].push_back({r, d});
    }
    used.assign(n, false);
    for(int i = 0; i < n; ++i){
        if(!used[i]){
            a[i] = 0;
            dfs(i);
        }
    }
    cout << "Yes\n";
}

Measured memory_bytes: 19576
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
signed main(){
	int n,a;
	cin>>n>>a;
	if(n%500>a)puts("No");
	else puts("Yes");
	return 0;
}


Measured memory_bytes: 256
from itertools import count
with open(0) as f:
    N, *p = map(int, f.read().split())
p.append(N+1)
ans = 0
for i in count(0):
    if i == N:
        break
    if p[i] == i+1:
        p[i] = p[i+1]
        p[i+1] = i+1
        ans += 1
print(ans)

Measured memory_bytes: 21072
#include <bits/stdc++.h>
using namespace std;
#define mt make_tuple
#define mp make_pair
#define int long long

main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int x;
	cin >> x;
	int k = x / 500, v = k * 1000;
	x -= k * 500;
	k = x / 5;
	v += k * 5;
	cout << v << '\n';
}


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

const ll mod = 1000000007;
const ll INF = 1001001001;
vector<int> dx = {-1, 0, 1, 0};
vector<int> dy = {0, 1, 0, -1};


int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	int h, w; cin >> h >> w;
	vector<vector<char>> map(h, vector<char>(w));
	rep(i,h) rep(j,w) cin >> map.at(i).at(j);
	int ans = 0;
	rep(i,h){
		rep(j,w){
			if(map.at(i).at(j) == '#') continue;
			queue<PI> que;
			vector<vector<int>> seen(h, vector<int>(w));
			rep(l,h) rep(m,w) seen.at(l).at(m) = INF;
			que.push(make_pair(i,j));
			seen.at(i).at(j) = 0;
			while(!que.empty()){
				PI p = que.front(); que.pop();
				int y = p.first; int x = p.second;
				for(int p = 0; p < 4; p++){
					if(y + dy.at(p) < 0 || y + dy.at(p) >= h || x + dx.at(p) < 0 || x + dx.at(p) >= w || map.at(y + dy.at(p)).at(x + dx.at(p)) == '#') continue;
					if(seen.at(y + dy.at(p)).at(x + dx.at(p)) != INF) continue;
					seen.at(y + dy.at(p)).at(x + dx.at(p)) = seen.at(y).at(x) + 1;
					ans = max(ans, seen.at(y + dy.at(p)).at(x + dx.at(p)));
					que.push(make_pair(y + dy.at(p), x + dx.at(p)));
				}
			}
		}
	}
	cout << ans << endl;
} 

Measured memory_bytes: 256
from sys import stdin, setrecursionlimit
from collections import Counter, deque, defaultdict
from math import floor, ceil
from bisect import bisect_left
from itertools import combinations
setrecursionlimit(100000)

INF = int(1e10)
MOD = int(1e9 + 7)

def main():
    from builtins import int, map
    x = int(input())
    if x == 0:
        print(1)
    else:
        print(0)

if __name__ == '__main__':
    main()


Measured memory_bytes: 65384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define i_7 (ll)(1E9+7)
#define i_5 (ll)(1E9+5)
//#define i_7 998244353
//#define i_5 998244351
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
long double EPS=1E-8;
////////////////////////////////////////

#define N 100005
#define M 61
ll dp[N][M];

ll cal(ll pos,ll k){
    for(ll x=M-1;x>=0;x--){
        if((k>>x)&1LL){
            pos=dp[pos][x];
        }
    }
    return pos;
}

int main(){
    ll n;cin>>n;
    ll x[n];rep(i,0,n-1)cin>>x[i];
    ll m,k;cin>>m>>k;
    ll a[m];rep(i,0,m-1){cin>>a[i];a[i]--;}
    ll b[n-1];rep(i,0,n-2)b[i]=x[i+1]-x[i];
    ll c[n-1];rep(i,0,n-2)c[i]=i;
    rep(i,0,m-1){
        swap(c[a[i]-1],c[a[i]]);
    }
    rep(i,0,n-2){
        dp[i][0]=c[i];
    }
    rep(j,1,M-1){
        rep(i,0,n-2){
            dp[i][j]=dp[dp[i][j-1]][j-1];
        }
    }
    ll d[n-1];rep(i,0,n-2)d[i]=i;
    rep(i,0,n-2){
        d[i]=cal(i,k);
    }
    ll dis[n-1];
    rep(i,0,n-2){
        dis[i]=b[d[i]];
    }
    ll ans=x[0];
    cout<<ans<<endl;
    rep(i,1,n-1){
        ans+=dis[i-1];
        cout<<ans<<endl;
    }
    
    return 0;
}



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

long long int n, a[10000];
long long int sum, m = 100000000, M = -100000000;

int main()
{
    cin >> n;
    for(int i = 0;i < n;i++)
    {
        cin >> a[i];
        sum += a[i];
        m = min(a[i], m);
        M = max(a[i], M);
    }
    cout << m << ' ' << M << ' ' << sum << endl;
    return 0;
}


Measured memory_bytes: 3136
#include<bits/stdc++.h>
using namespace std;
int main(){
    int k;
    string str;
    cin>>k;
    cin>>str;
    int n= str.length();
    if(n <=k){
        cout<<str;
    }
    else if(n>k){
        for (int i = 0; i <k; i++)
        {
            cout<<str[i];
        }
        cout<<"...";
        
    }
    
    return 0;
}

Measured memory_bytes: 3632
#include<cstdio>
#include<vector>
const int N=1e5+6;int rt1,n,rt2,a[N];std::vector<int>G[N];
void addedge(int u,int v){G[u].push_back(v),G[v].push_back(u);}
struct Tr{
	std::vector<int>G[N];bool p[N];
	int dfs(int now,int pre=0){
		p[now]=1;int pr=0;
		for(int to:G[now])if(to!=pre){p[now]^=1;int x=dfs(to,now);if(pr)addedge(pr,x),pr=0;else pr=x;}
		return pr?pr:now;
	}
}_0,_1;
void dfs(int u,int c){a[u]=c;for(int to:G[u])if(!a[to])dfs(to,-c);}
int main(){
	scanf("%d",&n);
	for(int i=1,x;i<=n;++i){scanf("%d",&x);if(x==-1)rt1=i;else _0.G[x].push_back(i),_0.G[i].push_back(x);}
	for(int i=1,x;i<=n;++i){scanf("%d",&x);if(x==-1)rt2=i;else _1.G[x].push_back(i),_1.G[i].push_back(x);}
	_0.dfs(rt1),_1.dfs(rt2);
	for(int i=1;i<=n;++i)if(_0.p[i]!=_1.p[i]){puts("IMPOSSIBLE");return 0;}puts("POSSIBLE");
	for(int i=1;i<=n;++i){if(_0.p[i]&&!a[i])dfs(i,1);printf("%d ",a[i]);}
	return 0;
}

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

void Main()
{
    int64_t K;
    cin >> K;
    int64_t A, B;
    cin >> A >> B;
    int64_t temp = K * (A % K == 0 ? A / K : A / K + 1);
    cout << (temp >= A && temp <= B ? "OK" : "NG") << endl;
}

int main()
{
    Main();
}


Measured memory_bytes: 3632
# util functions

# debug
$debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if $debugFlag

def pd(str)
  p str if $debugFlag
end

# input
inputs = []
lc = 0
while l = $stdin.gets do
  if true
    inputs << l.chomp.split(" ").map(&:to_s)
  else
    inputs << l.chomp.split(" ").map(&:to_i)
  end
  lc += 1
end

ss = inputs[1][0]

# input check
if $debugFlag
  p "--- INPUT (begin) ---"
  inputs.each do |l_i|
    p l_i
  end
  p "--- INPUT (end) ---"
  print "\n"
end

# body
if $debugFlag
end

rc = 0
bc = 0
ss.length.times do |i|
  if ss[i..i] == "R"
    rc += 1
  else
    bc += 1
  end
end

if rc > bc
  puts "Yes"
else
  puts "No"
end


Measured memory_bytes: 1788
function Main(input) {
	var InLength = input.length-1;
  	var flag="Yes";
	for(i=0;i<InLength/2;i++){
      if(input[i]!==input[InLength-i-1]){
        flag = "No";
      }
    }
  console.log(flag);
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
with Ada.Text_IO;
with Ada.Integer_Text_IO;

procedure main is

   s : String (1 .. 3);
   last : Natural;

begin

   Ada.Text_IO.Get_Line(s, last);
   
   if(s = "ABC")then
     Ada.Text_IO.Put_Line("ARC");
   else
     Ada.Text_IO.Put_Line("ABC");
   end if;

end main;


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

using namespace std;

int main()
{
    int L, A, B, C, D;
    cin >> L >> A >> B >> C >> D;
    int cnt = 0;
    while (A > 0 || B > 0) {
        A -= C;
        B -= D;
        cnt++;
    }
    cout << L - cnt << endl;
    return 0;
}

Measured memory_bytes: 3088
w, h, n = map(int, input().split())
a1, a2, a3, a4 = [0], [w], [0], [h]
for _ in range(n):
    x, y, a = map(int, input().split())
    if a == 1:
        a1.append(x)
    if a == 2:
        a2.append(x)
    if a == 3:
        a3.append(y)
    if a == 4:
        a4.append(y)
print(max(min(a2) - max(a1), 0) * max(min(a4) - max(a3), 0))

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

int main()
{
    string s;
    while (cin >> s) {
        if (s == "0") break;
        int sum = 0;
        for (unsigned int i = 0; i < s.size(); i++) sum += s[i] - 0x30;
        cout << sum << endl;
    }
}



Measured memory_bytes: 3172
import java.util.*;
import java.math.BigDecimal;

class Main{
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		int q = stdIn.nextInt();
		for(int i=0;i<q;i++){
			double x0 = stdIn.nextDouble();
			double y0 = stdIn.nextDouble();
			double x1 = stdIn.nextDouble();
			double y1 = stdIn.nextDouble();
			double x2 = stdIn.nextDouble();
			double y2 = stdIn.nextDouble();
			double x3 = stdIn.nextDouble();
			double y3 = stdIn.nextDouble();
			Vector v1 = new Vector(x0,y0,x1,y1);
			Vector v2 = new Vector(x2,y2,x3,y3);
			if(v1.judgeisOrthogonal(v2)){
				System.out.println(1);
			}
			else if(v1.judgeisParallel(v2)){
				System.out.println(2);
			}
			else{
				System.out.println(0);
			}

		}

	}	
}

class Vector{
	public final double EPS = Math.pow(10,-8);
	public double x,y;
	final int cutoff = 9;

	Vector( double x1 , double y1 , double x2 , double y2 ){
		this.x = x2 - x1;
		this.y = y2 - y1;
	}

	double dot( Vector a ){	
		return rounding(this.x * a.x + this.y * a.y);
	}
	double cross( Vector a ){	
		return rounding(this.x * a.y - this.y * a.x);
	}

	void add( Vector a ){
		this.x = rounding(this.x + a.x);
		this.y = rounding(this.y + a.y);
	}
	void sub( Vector a ){
		this.x = rounding(this.x - a.x);
		this.y = rounding(this.y - a.y);
	}
	void mul( double z ){
		this.x = rounding(this.x * z);
		this.y = rounding(this.y * z);
	}
	void div( double z ){
		this.x = rounding(this.x / z);
		this.y = rounding(this.y / z);
	}

	double abs(){
		return Math.sqrt(norm());
	}
	double norm(){
		return rounding(this.x * this.x + this.y * this.y);
	}

	void projection( Vector a ){
		if(judge(a.norm())){
			this.x = 0;
			this.y = 0;
		}
		else{
			double cos = dot(a)/(abs() * a.abs());
			double frac = a.abs() * cos/abs();
			mul(frac);
		}
	}
	Vector reflection( Vector a ){
		projection(a);
		return new Vector(a.x,a.y,this.x,this.y);
	}

	boolean judgeisOrthogonal( Vector a ){	
		return judge(dot(a)) ? true : false;
	}  
	boolean judgeisParallel( Vector a ){	
		return judge(cross(a)) ? true : false;
	}

	boolean judge( double a ){		
		return Math.abs(a)<EPS ? true : false;
	}
	double rounding(double a){
		BigDecimal bi = new BigDecimal(String.valueOf(a));
		return bi.setScale(cutoff,BigDecimal.ROUND_HALF_UP).doubleValue();
	}
} 

Measured memory_bytes: 50684
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;

int main() {
	int n;
	cin >> n;
	string a, b;
	cin >> a >> b;
	int ans = 0;
	for (int i = 0; i <= n; i++) {
		string s = b.substr(0, i), t = a.substr(n - i, i);
		if (s == t)ans = i;
	}
	cout << n*2-ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#define MAX_N 200005
#define int long long

using namespace std;

int n;
int a[MAX_N];

signed main()
{
	scanf("%lld",&n);
	for(int i=1;i<=n;i++) scanf("%lld",&a[i]),a[i]-=i;
	sort(a+1,a+1+n);
	int ans=0;
	for(int i=1;i<=n;i++) ans+=abs(a[i]-a[(n+1)>>1]);
	printf("%lld\n",ans);
}


Measured memory_bytes: 1792
#include <stdio.h>

int main()
{
	int K, A, B;
	scanf("%d", &K);
	scanf("%d %d", &A, &B);
	if (B / K > (A - 1) / K) printf("OK\n");
	else printf("NG\n");
	fflush(stdout);
	return 0;
}

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



#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)

using namespace std;

template <class T>
using vec = std::vector<T>;
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const long long INF = 1LL<<60;

const double PI = acos(-1.0);

int lcm(int a,int b){
    //最小公倍数
    return a/__gcd(a,b) * b;
}

struct edge{int from, to,cost;};

// int型の2次元配列(3×4要素の)の宣言
// vector<vector<int>> data(3, vector<int>(4));


vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}

ll score;

int main() {
    long long N;
    cin >> N;
    const auto &res = prime_factorize(N);
    for (auto p : res) {
        int i=1;
        while(p.second>=i){
            p.second-=i;
            i++;
            score++;
        }
        
    }
    cout << score<<endl;
}




Measured memory_bytes: 3632
#include <iostream>

using namespace std;

int gcd(int n, int m){
    if(n < m) swap(n, m);
    while(m!=0){
        int tmp = m;
        m = n%m;
        n = tmp;
    }
    return n;
}

int main(){
    int N;
    cin >> N;
    int ans;
    cin >> ans;
    for(int i = 1; i < N; i++){
        int A;
        cin >> A;
        ans = gcd(ans, A);
    }
    cout << ans << endl;
}

Measured memory_bytes: 888
#include <iostream>
#include <string>

using namespace std;
int main() {
	int a, b, sum = 0;
	cin >> a >> b;
	if (a < b)
	{
		sum += b;
		b--;
	}else
	{
		sum += a;
		a--;
	}
	if (a < b)
	{
		sum += b;
		b--;
	}
	else
	{
		sum += a;
		a--;
	}
	cout << sum << endl;
	
	return 0;
}

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

using namespace std;

using ll = long long;

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

    int n;

    cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        a[i] -= (i + 1);
    }

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

    ll sum = 0, b;
    if (n % 2 == 1)
        b = a[(n - 1) / 2];
    else
        b = (a[n / 2] + a[(n / 2) - 1]) / 2;

    for (auto x : a) sum += abs(x - b);
    cout << sum << endl;

    return 0;
}


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

int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    vector<int> D(N);
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
        D[i]=A[i];
    }

    sort(A.begin(), A.end(), greater<int>());

    for(int i=0;i<N;i++){
        if(D[i]==A[0])cout<<A[1]<<endl;
        else cout<<A[0]<<endl;
    }
    //デカイのが前(降順)

    return 0;
}

Measured memory_bytes: 3200
#include<iostream>
#include<cstring>
#include<algorithm>
#include<map>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef pair<int,int> pii;

int n,s;
int l[555],r[555];
int w[555][555];
pii p[555];
int t[555];

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

  cin >> n >> s; s--;
  rep(i,n){
    cin >> l[i] >> r[i];
    p[i] = pii(r[i],i);
  }
  rep(i,n)rep(j,n)cin >> w[i][j];
  rep(k,n)rep(i,n)rep(j,n)w[i][j] = min(w[i][j],w[i][k]+w[k][j]);

  sort(p,p+n);
  rep(i,n)t[i] = min(r[i]-l[i], r[i]-w[s][i]);

  rep(i,n){
    int v = p[i].second;
    if(t[v]<0)continue;

    rep(j,n){
      if(r[v]+w[v][j] <= r[j]){
	t[j] = max(t[j], t[v] + min(r[j]-w[v][j]-r[v], r[j]-l[j]) );
      }
    }
  }

  cout << *max_element(t,t+n) << endl;
}  

Measured memory_bytes: 2304
#include <bits/stdc++.h>
#define ll long long
const long double PI=acos(-1);
using namespace std;
ll gcd(ll a,ll b)
{
    if(b==0)
        return a;
    else
        return gcd(b,a%b);
}
bool prime(ll x)
{
    if(x==2)
    {
        return true;
    }
    else if(x<2||x%2==0)
    {
        return false;
    }
    else
    {
        for(int i=3;i*i<=x;i+=2) {
            if (x % i == 0) {
                return false;
            }
        }
        return true;
    }
}
int main()
{
   ll a,b,q=0;
   cin>>a>>b;
   while(a--)
   {
       ll x,y;
       cin>>x>>y;
       double z=sqrt((pow(x,2))+(pow(y,2)));
       if(z<=b)
           q++;
   }
   cout<<q<<endl;

}


Measured memory_bytes: 3628