akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <vector>
#include <stack>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define link(x) for(edge *j=h[x];j;j=j->next)
#define inc(i,l,r) for(int i=l;i<=r;i++)
#define dec(i,r,l) for(int i=r;i>=l;i--)
const int MAXN=3e5+10;
const double eps=1e-8;
const int mod=1e9+9;
#define ll long long
using namespace std;
struct edge{int t,v;edge*next;}e[MAXN<<1],*h[MAXN],*o=e;
void add(int x,int y,int vul){o->t=y;o->v=vul;o->next=h[x];h[x]=o++;}
ll read(){
    ll x=0,f=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
    while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
    return x*f;
}



int n,m;
pii ans[MAXN];
set<pii>s;
map<pii,int>ma;
int main(){
    n=read();m=read();
    int l;int r;
    if(n%2==1){
	l=1,r=n-1;
    inc(i,1,m){
	printf("%d %d\n",l,r);
	ans[i]=mp(l,r);
	l++;r--;
    }    
    }
    else {
	int x=(m+1)/2;
	inc(i,1,x)cout<<i<<" "<<n-i+1<<endl;
	inc(i,x+1,m)cout<<i<<" "<<n-i<<endl;
    }
    /*int cnt=1e9;
    dec(i,n,1)s.insert(mp(cnt,i)),cnt--;
    inc(i,1,n){
	inc(j,1,m){
	    int t1=ans[j].first;int t2=ans[j].second;
	    int num=1;
	    int q1,q2;
	    for(auto ite=s.begin();ite!=s.end();ite++){
		if(num==t1){
		    q1=(*ite).second;
		    break;
		}
		num++;
	    }
	    num=1;
	    for(auto ite=s.begin();ite!=s.end();ite++){
		if(num==t2){
		    q2=(*ite).second;
		    break;
		}
		num++;
	    }
	    if(q1>q2)swap(q1,q2);
	    if(ma.count(mp(q1,q2))){
		cout<<i<<":::: "<<q1<<" "<<q2<<endl;
		printf("WA\n");
		return 0;
	    }
	    ma[mp(q1,q2)]=1;
	}
	auto ite=s.end();ite--;
	int x=(*ite).second;
	s.erase(ite);
	s.insert(mp(cnt,x));cnt--;
    }
    printf("AC\n");*/
    return 0;
}


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

int op(int a,int b) {return max(a,b);}
int e() {return 0;}
const int MAX_A = 300005;

int main() {
	int n,k;
	cin >> n >> k;
	vector<int> a(n);
	rep(i,n) cin >> a[i];

	segtree<int,op,e> dp(MAX_A);
	// 初期化 e() でなされる
	rep(i,n) {
		int x=a[i];
		int l=x-k;
		int r=x+k+1;
		l = max(l,0);
		r = min(r, MAX_A);
		int now = dp.prod(l,r)+1;
		// 演算子は可換でない
		dp.set(x, now);
        // dp.set(x,max(dp.get(x),now));
		// dp.get(x) は now 以下なので取らなくても平気
	}
	int ans = dp.prod(0,MAX_A);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 9512
import sys
N, M = map(int, input().split())
A = [int(_) for _ in input().split()]
A.sort()
#print(A)
BC = [0] * M
for m in range(M):
    BC[m] = list(map(int, input().split()))
BC.sort(key=lambda x: x[1], reverse=True)
#print(BC)
c = 0
for m in range(M):
    for t in range(BC[m][0]):
        if BC[m][1] > A[c]:
            A[c] = BC[m][1]
        c += 1
        if c == N:
            print(sum(A))
            sys.exit()
print(sum(A))

Measured memory_bytes: 32888
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int[] h = new int[n];
		for(int i = 0; i < n; i++){
		    h[i] = sc.nextInt();
		}
		
		// 計算
		int result = 0;
		int[] dp = new int[n];
		Arrays.fill(dp, 1000000000);
		dp[0] = 0;
		for(int i = 0; i < n; i++){
		    if(i+1 < n) dp[i+1] = min(dp[i+1], dp[i] + abs(h[i] - h[i+1]));
		    if(i+2 < n) dp[i+2] = min(dp[i+2], dp[i] + abs(h[i] - h[i+2]));
		}
		result = dp[n-1];
		
		// 出力
		System.out.println(result);
	}
}


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

int dp[178000], N, M, power3[12]; char c[130][11];
vector<int>vec[178000];

void init() {
	for (int i = 0; i < 178000; i++) { dp[i] = -1; vec[i].clear(); }
	for (int i = 0; i < 130; i++) { for (int j = 0; j < 11; j++) c[i][j] = 0; }
}

int solve(int mask) {
	if (vec[mask].size() <= 1) return 0;
	if (dp[mask] != -1) return dp[mask];

	int bit[11];
	for (int i = 0; i < M; i++) bit[i] = (mask / power3[i]) % 3;

	int minx = (1 << 30);
	for (int i = 0; i < M; i++) {
		if (bit[i] != 0) continue;

		int v1 = solve(mask + power3[i] * 1);
		int v2 = solve(mask + power3[i] * 2);
		minx = min(minx, max(v1, v2) + 1);
	}
	dp[mask] = minx;
	return minx;
}

int main() {
	power3[0] = 1; for (int i = 1; i <= 11; i++) power3[i] = (power3[i - 1] * 3);
	while (true) {
		init();
		cin >> M >> N; if (M == 0 && N == 0) break;
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < M; j++) cin >> c[i][j];
		}

		for (int i = 0; i < (1 << M); i++) {
			vector<int>V;
			for (int j = 0; j < M; j++) { if ((i / (1 << j)) % 2 == 1) V.push_back(j); }

			for (int j = 0; j < N; j++) {
				int bit[11]; for (int k = 0; k < 11; k++) bit[k] = 0;
				for (int k = 0; k < V.size(); k++) {
					if (c[j][V[k]] == '0') bit[V[k]] = 1; else bit[V[k]] = 2;
				}
				int rem = 0;
				for (int k = 0; k < M; k++) rem += power3[k] * bit[k];
				vec[rem].push_back(j);
			}
		}
		cout << solve(0) << endl;
	}
	return 0;
}


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

using namespace std;

int a[5];

int main() {
    for (int i = 0; i < 5; ++i) scanf("%d", a + i);
    int del = 0, maxVal = 0, ans = 0;
    for (int i = 0; i < 5; ++i) {
        int t = a[i];
        while (t % 10 != 0) ++t;
        if (t - a[i] > maxVal) {
            maxVal = t - a[i];
        }
        ans += t;
    }
    printf("%d\n", ans - maxVal);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define si(a) scanf("%d",&a)
#define fore(i,a,b) for(int i=a;i<b;++i)
#define sorte(a) sort(a.begin(), a.end())
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
int main(){
	int n,l;
	int x;
	si(n); si(l);
	vi v(n);
	int sum=0;
	int mini = INT_MAX;
	bool sw = true;
	fore(i,0,n){
		x = l+i;
		sum+=x;
		v[i]=x;
		if(abs(x)<mini){
			mini=min(mini,abs(x));
			if(x>=0)
				sw=true;
			else
				sw=false;
		}
	}
	if(sw==false)
		mini=-mini;
	sum-=mini;
	printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <stack>
#include <queue>
#include <cctype>
#include <complex>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <cassert>
#include <iomanip>

using namespace std;

#define pb push_back
typedef long long ll;
typedef complex<int> P;
typedef pair<int, int> Pii;


int f(int n){
	//cout<< n<< endl;
	if(n==1) return 0;
	n = (n + (n%3==0 ? 0 : (n%3==1 ? 2 : 1))) /3;
	return f(n) + 1;
}

bool solve(){
	int n;
	cin>> n;
	cout<< f(n)<< endl;
	return true;
}

int main(){
	cout.setf(ios::fixed);
	cout.precision(10);
	
	solve();

	return 0;
}

 

Measured memory_bytes: 1160
/* You got a dream , you gotta protect it . */
/* You got a dream , you gotta protect it . */
/* You got a dream , you gotta protect it . */
#include <bits/stdc++.h>
#define lp(i , N) for(ll i = 0; i < ll (N) ; i++)
#define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define debug(x) cout<<" [ " << #x << " is: " << x << " ] "<<endl;
using namespace std;
typedef long long ll;
typedef long double ld;
const long double EPS = 1e-6;
const long double pi = acos(-1);
const long long MOD = 1e9 + 7;
int main(){
    FAST
    ld a , b;
    cin >> a >> b;
    for(ll i = 1; i <= 1000; i++){
        bool b1 = false , b2 = false;
        for(ld c = 0.8 , g = 1; g <= 100; g++ , c/=10){
        ll res = c * i;
        if(res == a) b1 = true;
        }
        for(ld c = 0.1 , g = 1; g <= 100; g++ , c/=10){
        ll res = c * i;
        if(res == b) b2 = true;
        }
        if(b1 && b2){
            cout << i << endl;
            return 0;
        }
    }
    cout << "-1" << endl;
    return 0;
}
/*
[#]=============================================================[#]
         ___    ____              ____          ___ _
        |_ _|  / ___|__ _ _ __   |  _ \  ___   |_ _| |_
         | |  | |   / _` | '_ \  | | | |/ _ \   | || __|
         | |  | |__| (_| | | | | | |_| | (_) |  | || |_
        |___|  \____\__,_|_| |_| |____/ \___/  |___|\__|
                     it's just about time

[#]=============================================================[#]
*/


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

int main(){
  int N;
  cin >> N;
  
  vector<int> count(N,0);
  int max=0,break_num;
  
  for(int i=0;i<N;i++){
    int a=i+1;
    
    while(a%2==0){
      a/=2;
      count.at(i)++;
    }
    
    if(count.at(i)>=max){
      max=count.at(i);
      break_num=i+1;
    }
    
  }
  cout << break_num << endl;
}

Measured memory_bytes: 3608
#include<iostream>
#include<string>
#include<iomanip>
using namespace std;
int main(){
	double r;
	cin >> r;
	cout << fixed <<setprecision(10) << r*r*3.141592653589 << " " << 2 * r*3.141592653589 << endl;
	return 0;
}


Measured memory_bytes: 3276
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const string ln = "\n";
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

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

  ll x, y;
  cin >> x >> y;
  priority_queue<ll, vector<ll>, greater<ll>> pq;
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < 2; j++) {
      ll nx = i ? -x : x;
      ll ny = j ? -y : y;
      if (nx <= ny) {
        pq.push(i + j + (ny - nx));
      }
    }
  }

  cout << pq.top() << ln;

  return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
	public static void main (String[] args) {
    	Scanner sc = new Scanner(System.in);
      	int N = sc.nextInt();
      	int[] A = new int[N];
      	for (int i=0; i<N ; i++) {A[i] = sc.nextInt();}
      
      	int c = 0;//counter
      	for (int j=0; j<N; j+=2) {
        	if (A[j] % 2 == 1) {c++;}
        }
      
      	System.out.println(c);
    }
}

Measured memory_bytes: 35852
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
#define MOD 1000000007
ll powll(ll a,ll b){ll r=1;rep(i,b){r*=a;}return r;}
#define swap(a,b) do{ll w=(a);(a)=(b);(b)=w;}while(0)
#define swapd(a,b) do{double w=(a);(a)=(b);(b)=w}while(0)
#define in(a) scanf("%lld", &(a))
#define in2(a,b) scanf("%lld %lld",&(a),&(b))
#define in3(a,b,c) scanf("%lld %lld %lld",&(a),&(b),&(c))
#define ind(a) scanf("%lf", &(a))
#define ins(a) scanf("%s", (a))
#define inc(a) scanf("%c", &(a))
#define put(a) printf("%lld\n", (a))
#define putd(a) printf("%.15f\n", (a))
//      puts(a) printf("%s\n", a) 文字はこっち
//your code here!
ll N, P, A, odd, even;
/*ll dfs(ll i, ll sum){
    if(i==N){
        if((sum%2)==P) return 1;
        else return 0;
    }
    return dfs(i+1, sum) + dfs(i+1, sum+A[i]);
}*/
int main(void){
    in2(N, P);
    rep(i, N){
        in(A);
        if(A%2) odd++;
    }
    if(!odd) {
        if(P) puts("0");
        else put(powll(2, N));
    }
    else put(powll(2, N-1));
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<iomanip>
#include<queue>
#include<cmath>
#include<stack>
#include <map>
#define ll long long int
#define skip cin>>ws;
#define vll vector<ll> 
#define vb vector<bool>
#define vpll vector<pair<ll,ll>>
#define vvll vector<vector<ll>>
#define pll pair<ll,ll>
#define vs vector<string>
#define vvpll vector<vector<pair<ll, ll>>>
#define pb push_back
#define pob pop_back()
#define MOD (ll)(1e9 + 7)
#define test ll t; cin>>t; while(t--)

using namespace std;

void enter(vll &ar)
{
    ll n = ar.size();

    for(ll i=0;i<n;i++)
    {
        cin>>ar[i];
    }
}

void show(vll &a)
{
    ll n = a.size();

    for(ll i=0;i<n;i++)
    {
        cout<<a[i]<<" ";
    }
    cout<<"\n";
}

void SieveOfErat1sthenes(int n, vll &pri) 
{ 
    vb prime(n+1, true); 
   
    for (int p=2; p*p<=n; p++) 
    { 
        
        if (prime[p] == true) 
        { 
            pri.pb(p);
            
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
}

ll mo(ll a)
{
    return a%MOD;
}

bool compare(pll a, pll b)
{
    return a.first>b.first;
}


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

    ll n, W;
    cin>>n>>W;

    vll v(n), w(n);

    for(ll i=0;i<n;i++)
    {
        cin>>w[i]>>v[i];
    }

    vvll mat(1e5+1, vll(n+1, 1e10));

    for(ll i=0;i<=1e5;i++) mat[i][0] = 1e10;
    for(ll i=0;i<=n;i++) mat[0][i] = 0;
   
    for(ll i=1;i<=1e5;i++)
    {
        for(ll j=1;j<=n;j++)
        {
            if(v[j-1]>i)
            {
                mat[i][j] = mat[i][j-1];
            }
            else
            {
                // if(v[j-1]==i)
                // mat[i][j] = min(mat[i][j-1], i + w[j-1]);
                // else
                // {
                    
                    mat[i][j] = min(mat[i][j-1], mat[i-v[j-1]][j-1] + w[j-1]);
                
                //}
                
            }
        }
    }

    ll ans = 0;

    for(ll i=1;i<=1e5;i++)
    {
        if(mat[i][n]<=W) ans = max(ans, i);
    } 

    // for(ll i=0;i<=90;i++)
    // {
    //     for(ll j=0;j<=n;j++)
    //     {
    //         cout<<mat[i][j]<<" ";
    //     }
    //     cout<<"\n";
    // }

    cout<<ans<<"\n";

    return 0;
}


Measured memory_bytes: 85300
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
 
using namespace std;

int main()
{
	long long int r,x,D;
	cin>>r>>D>>x;
	for(int i = 0; i < 10; i++){
		x = r*x - D;
		cout<<x<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class B123Triangle {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n; cin >> n;
      vector<int> a(n);
      rep(i, n) {
        char c; cin >> c;
        a[i] = c - '1';
      }

      int cnt2 = 0;
      vector<bool> ok(n);
      ok[0] = ok[n-1] = true;
      for(int i=1; i<n-1; i++) {
        int p = n-i;
        int q = i;
        while(p%2==0) {
          cnt2++;
          p/=2;
        }
        while(q%2==0) {
          cnt2--;
          q/=2;
        }
        if (cnt2 == 0) {
          ok[i] = true;
        }
      }

      int ans = 0;
      rep(i, n) {
        if (ok[i] && (a[i]==1)) {
          ans ^= 1;
        }
      }
      if (ans == 1) {
        cout << 1 << endl;
        return;
      }

      rep(i, n) {
        if (a[i] == 1) {
          cout << 0 << endl;
          return;
        }
      }

      rep(i, n) {
        a[i] /= 2;
      }

      ans = 0;
      rep(i, n) {
        if (ok[i] && (a[i]==1)) {
          ans ^= 2;
        }
      }
      cout << ans << endl;
    }
};

signed main() {
  B123Triangle solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 4352
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(auto i=0;i<n;++i)
#define REPR(i,n) for(auto i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(auto i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define ll long long
#define INF 999999999
#define MOD 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(n,v) {int tmp;for(int i=0;i<n;++i){scanf("%d",&tmp);v.push_back(tmp);}}

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

using namespace std;

typedef pair<int,int> pii;

int main(){

  int k, a, b;
  cin >> k >> a >>b;

  for(int i = a; i <= b; ++i){
    if(i % k == 0){
      cout << "OK\n";
      return 0;
    }
  }
  cout << "NG\n";
  return 0;

}





Measured memory_bytes: 3116
N = int(input())
erat = [True for i in range(55556)]
erat[0], erat[1] = False, False
i = 2
while i*i<55556:
    if erat[i]:
        j = 2
        while i*j<55556:
            erat[i*j] = False
            j += 1
    i += 1
    
##
ans = []
for i in range(len(erat)):
    if len(ans)==N:
        break
    if erat[i]:
        if i%5==1:
            ans.append(i)

print(*ans)

Measured memory_bytes: 3608
import java.util.Scanner;

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 xmax = -999;
        for (int i = 0; i < n; i++) {
            xmax = Math.max(xmax, sc.nextInt());
        }

        int ymin = 999;
        for (int i = 0; i < m; i++) {
            ymin = Math.min(ymin, sc.nextInt());
        }

        String ans = "War";
        for (int z = x + 1; z <= y; z++) {
            if (xmax < z && ymin >= z) {
                ans = "No War";
                break;
            }
        }

        System.out.println(ans);
    }

}



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

#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);++i)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;i>=(int)(m);--i)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
//constexpr long long MOD = (ll) 1e9 + 7;
constexpr long long MOD = 998244353LL;
using ld=long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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

struct Edge {
	ll to, rev;
    long double cap;
	Edge(ll _to, long double _cap, ll _rev) {
	to = _to; cap = _cap; rev = _rev;
	}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph& G, ll from, ll to, long double cap, bool revFlag, long double revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}



void solve(){
    string s;
    cin>>s;
    ll n=s.size();
    REP(i,n) if(s[i]=='?') s[i]='D';
    cout<<s<<en;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	
	solve();
	//ll t;cin>>t;REP(i,t) solve();

    return 0;
}


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

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> a(m+1, 0);
    for (int i=0; i<n; i++) {
        int k;
        cin >> k;

        for (int j=0; j<k; j++) {
            int ai;
            cin >> ai;
            a[ai]++;
        }
    }
    
    cout << remove_if(a.begin(), a.end(), [&](auto e){ return e != n; }) - a.begin() << endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main
{

    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int l = sc.nextInt();
        int hl = sc.nextInt();
        int hituyou = sc.nextInt();
        
        int a = hituyou / 1000;
        int n = hituyou % 1000;
        
        int hn = hituyou / 500;
        
        int an = Math.min(2 * hl * a, l * a) +  Math.min( (n+999)/1000*l , (n+499)/500*hl );

        System.out.println(an);
    }
}



Measured memory_bytes: 26292
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>


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

const long long MAX = 5100000;
const long long INF = 1LL << 60;
const long long MOD = 1'000'000'007LL;
const long long mod = 998244353LL;

using namespace std;
typedef unsigned long long ull;
typedef long long ll;

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

	ll N; scanf("%lld", &N);
	vector<ll>a(N); for (ll i = 0; i < N; i++) scanf("%lld", &a[i]);

	ll res = 0;
	for (ll i = 1; i < N; i++) {
		res += (a[i] > a[i - 1]);
	}
	cout << res << endl;
	return 0;

}



Measured memory_bytes: 3632
import collections
from collections import deque
import sys
input = sys.stdin.readline

def bfs(s):
    d = deque()
    d.append(s)
    dis[s]=0
    flag=True
    while len(d):
        x = d.popleft()
        for i,j in vec[x]:
            if dis[i] == INF:
                dis[i]=dis[x]+j
                d.append(i)

            else:
                if dis[i]==dis[x]+j:
                    continue
                else:
                    print('No')
                    exit()
    return flag


n,m = map(int, input().split())
a = [list(map(int, input().split())) for i in range(m)]
vec= [[] for i in range(n)]

for i in range(m):
    vec[a[i][0]-1].append((a[i][1]-1,a[i][2]))
    vec[a[i][1]-1].append((a[i][0]-1,-a[i][2]))

INF=float('inf')
dis=[INF]*n

for i in range(n):
    if dis[i]==INF:
        bfs(i)
print('Yes')

Measured memory_bytes: 104796
#include <stdio.h>

int n, l_n;

int dfs(int a, int l, int t, int f, int s) {
	int ret0, ret3, ret5, ret7;
	if (l == l_n) return (t && f && s && a <= n) ? 1 : 0;
	ret0 = t && f && s;
	ret3 = dfs(10 * a + 3, l + 1, 1, f, s);
	ret5 = dfs(10 * a + 5, l + 1, t, 1, s);
	ret7 = dfs(10 * a + 7, l + 1, t, f, 1);
	return ret0 + ret3 + ret5 + ret7;
}

int len(int a) {
	return a > 9 ? len(a / 10) + 1 : 1;
}

int main(void) {
	scanf("%d", &n);
	l_n = len(n);
	printf("%d", dfs(0, 0, 0, 0, 0));
	return 0;
}

Measured memory_bytes: 128
# -*- coding: utf-8 -*-
import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

A,B,C,D,E,F = map(int, readline().split())
ans = (100*A,0)
max_con = 0

for a in range(31):
    for b in range(31):
        for c in range(50):
            for d in range(50):
                W = a * 100 * A + b * 100 * B
                S = c*C + d*D
                SW = S + W 
                e = W // 100
                if F < SW or SW == 0:
                    continue
                if e * E < S:
                    continue
                tmp = 100 * S / SW
                if tmp > max_con:
                    max_con = tmp
                    ans = (SW,S)
print(' '.join(str(a) for a in ans))

Measured memory_bytes: 67564
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
AC = Counter(A)
S = sum(A)
Q = int(input())
for _ in range(Q):
  B,C = map(int, input().split())
  if B not in AC:
    pass
  else:
    count = AC[B]
    AC[B] = 0
    S = S + (C-B)*count
    if C in AC:
      AC[C] += count
    else:
      AC[C] = count
  print(S)
  


Measured memory_bytes: 94320
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    string s;

    cin >> s;

    bool ok[30];
    for (int i = 0; i < 26; i++)
        ok[i] = false;
    ok['A' - 'A'] = true;
    ok['C' - 'A'] = true;
    ok['G' - 'A'] = true;
    ok['T' - 'A'] = true;

    string res = "";

    for (int i = 0; i < s.size(); i++)
    {
        if (!ok[s[i] - 'A'])
            continue;

        string tmp = ""s + (s[i]);

        int j = i + 1;
        while (j < s.size() && ok[s[j] - 'A'])
        {
            tmp += (s[j]);
            j++;
        }

        if (tmp.size() > res.size())
            res = tmp;
    }

    cout << res.size() << endl;

    return 0;
}

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

using namespace std;
typedef unsigned long ul;
typedef pair<ul, ul> P;

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

int a,b;

int main(){
  cin >> a >> b;
  cout << max(max(a+b,a*b),max(a*b,a-b)) << endl;

  return 0;
}


Measured memory_bytes: 256
# /usr/bin/python
# -*- coding: utf-8 -*-
import sys


# [x,y,z] is even*3 or odd*3
def solve(x,y,z):
  mx = max([x,y,z])
  return (mx*3-x-y-z)//2


a,b,c = map(int, input().split())
if a%2 == b%2 == c%2:
  print(solve(a,b,c))
elif a%2 == b%2:
  print(solve(a+1,b+1,c)+1)
elif b%2 == c%2:
  print(solve(a,b+1,c+1)+1)
elif a%2 == c%2:
  print(solve(a+1,b,c+1)+1)


Measured memory_bytes: 3060
use std::io::Read;

struct Edge {
    from: usize,
    to: usize,
    cost: i64,
}
impl Ord for Edge {
    fn cmp(&self, other: &Self) -> std::cmp::Ordering {
        self.cost.cmp(&other.cost)
    }
}
impl PartialOrd for Edge {
    fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
        Some(self.cost.cmp(&other.cost))
    }
}
impl Eq for Edge {}
impl PartialEq for Edge {
    fn eq(&self, other: &Self) -> bool {
        self.cost == other.cost
    }
}

struct DisjointSet {
    parent: Vec<usize>,
    size: Vec<usize>,
}

impl DisjointSet {
    fn new(n: usize) -> DisjointSet {
        DisjointSet {
            parent: (0..n).collect(),
            size: vec![1; n],
        }
    }
    fn root(&mut self, x: usize) -> usize {
        if x == self.parent[x] {
            x
        } else {
            let tmp = self.parent[x];
            // 根に直接繋ぐ
            self.parent[x] = self.root(tmp);
            self.parent[x]
        }
    }
    fn merge(&mut self, x: usize, y: usize) {
        let x = self.root(x);
        let y = self.root(y);
        if x == y {
            return;
        }
        if self.size[x] > self.size[y] {
            self.size[x] += self.size[y];
            self.parent[y] = x;
        } else {
            self.size[y] += self.size[x];
            self.parent[x] = y;
        }
    }
    fn same(&mut self, x: usize, y: usize) -> bool {
        self.root(x) == self.root(y)
    }

    // fn size(&mut self, x: usize) -> usize {
    //     let x = self.root(x);
    //     self.size[x]
    // }
}

fn kruskal(edges: &mut Vec<Edge>) -> i64 {
    let n: usize = edges.len();

    edges.sort();

    let mut ds = DisjointSet::new(n);
    let mut res: i64 = 0;
    for e in edges.iter() {
        if ds.same(e.from, e.to) {
            continue;
        }
        ds.merge(e.from, e.to);
        res += e.cost;
    }
    res
}

fn main() {
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let mut xy: Vec<(i64, i64, usize)> = vec![];
    for i in 0..n {
        let x: i64 = itr.next().unwrap().parse().unwrap();
        let y: i64 = itr.next().unwrap().parse().unwrap();
        xy.push((x, y, i));
    }

    let mut edges: Vec<Edge> = Vec::new();
    xy.sort_by(|a, b| a.0.cmp(&b.0));
    for i in 1..n {
        let (from_x, from_y, from_id) = xy[i - 1];
        let (to_x, to_y, to_id) = xy[i];
        let edge = Edge {
            from: from_id,
            to: to_id,
            cost: std::cmp::min((to_x - from_x).abs(), (to_y - from_y).abs()),
        };
        edges.push(edge);
    }

    xy.sort_by(|a, b| a.1.cmp(&b.1));
    for i in 1..n {
        let (from_x, from_y, from_id) = xy[i - 1];
        let (to_x, to_y, to_id) = xy[i];
        let edge = Edge {
            from: from_id,
            to: to_id,
            cost: std::cmp::min((to_x - from_x).abs(), (to_y - from_y).abs()),
        };
        edges.push(edge);
    }
    println!("{}", kruskal(&mut edges));
}

Measured memory_bytes: 19944
s=input()+'#'
n=len(s)
i=0
while i<n:
  if s[i]=='#':
    i=n
  elif s[i:i+11]=='dreameraser':
    i+=11
  elif s[i:i+10]=='dreamerase':
    i+=10
  elif s[i:i+7]=='dreamer':
    i+=7
  elif s[i:i+6]=='eraser':
    i+=6
  elif s[i:i+5]=='dream' or s[i:i+5]=='erase':
    i+=5
  else:
    print('NO')
    exit()
print('YES')

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

inline ll gsc(ll a,ll b,ll p)
{
    ll ans=0;
    while(b)
    {
        if(b&1) ans=(ans+a)%p;
        a=(a+a)%p;
        b>>=1;
    }
    return ans%p;
}

inline ll qp(ll a,ll b,ll p)
{
    ll res=1;
    while(b)
    {
        if(b&1) { res=gsc(res,a,p); }
        a=gsc(a,a,p);
        b>>=1;
    }
    return res%p;
}

inline ll ol(ll x)
{
    ll res=x;
    for(ll i=2;i*i<=x;i++)
    {
        if(x%i==0)
        {
            res=res/i*(i-1);
            while(x%i==0) x/=i;
        }
    }
    if(x!=1) res=res/x*(x-1);
    return res;
}

int main()
{
    ll l;
    ll ans;
    scanf("%lld",&l);
    ll t=__gcd(7ll,l);
    ll c=9ll*l/t;
        if(__gcd(c,10ll)!=1)
        {
            printf("-1\n");
        }
        else
        {
            ll cnt=ol(c);
            ll ans=cnt;
            for(ll i=1;i*i<=cnt;i++)
            {
                if(cnt%i==0)
                {
                    if(qp(10ll,i,c)==1)     ans=min(ans,i);
                    if(qp(10ll,cnt/i,c)==1) ans=min(ans,cnt/i);
                }
            }
            printf("%lld\n",ans);
        }
    return 0;
}


Measured memory_bytes: 3804
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
#include <tuple>

using namespace std;

int wa(int n){
    int sum = 0;
    while(n > 0){
        sum += n%10;
        n /= 10;
    }
    return sum;
}

int main()
{  
 int N;
 cin >> N;
 if(N % wa(N) == 0){
     cout << "Yes" << endl;
 }else{
     cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
typedef long long ll;

int main(){
    int N, K;
    cin >> N >> K;
    int h[N];
    int ans=0;
    rep(i,N) cin >> h[i];
    for(int i=0; i<N; i++){
        if(K<=h[i]){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>

const int N = 100000;
const int NIL = -1;

struct Node
{
	int parent, left, right;
};

Node T[N];
int d[N];

void getDepth(int u, int p)
{
	d[u] = p;
	if (T[u].left != NIL)
		getDepth(T[u].left, p + 1);
	if (T[u].right != NIL)
		getDepth(T[u].right, p);
}

void print(int u)
{
	printf("node %d: parent = %d, depth = %d, ",
			u, T[u].parent, d[u]);
	if (T[u].parent == NIL)
		printf("root, ");
	else if (T[u].left == NIL)
		printf("leaf, ");
	else
		printf("internal node, ");
	printf("[");
	/*
	if (T[u].left != NIL)
	{
		printf("%d", T[u].left);
		int c = T[T[u].left].right;
		while (c != NIL)
		{
			printf(", %d", c);
			c = T[c].right;
		}
	}
	*/
	// 更简洁的写法
	for (int i = 0, c = T[u].left; c != NIL; i++, c = T[c].right)
	{
		if (i > 0)
			printf(", ");
		printf("%d", c);
	}

	printf("]\n");
}

int main()
{
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		T[i].parent = T[i].left = T[i].right = NIL;

	for (int i = 0; i < n; i++)
	{
		int v, d, l;
		scanf("%d%d", &v, &d);
		for (int j = 0; j < d; j++)
		{
			int c;
			scanf("%d", &c);
			if (j == 0)
				T[v].left = c;
			else
				T[l].right = c;
			T[c].parent = v;
			l = c;
		}
	}
	int r;
	for (int i = 0; i < n; i++)
		if (T[i].parent == NIL)
			r = i;

	getDepth(r, 0);

	for (int i = 0; i < n; i++)
		print(i);

	return 0;
}



Measured memory_bytes: 4160
#include<stdio.h>
#include<string.h>
const int N = 1300;
const int M = 256;
int main()
{
	char str[N];
	int ary[M] = {0};
	while(fgets(str, 1300, stdin))
	{
		for(int i = 0; i < strlen(str) - 1; i++)
		{
		 	if(str[i] >= 'A' && str[i] <= 'Z')
		 	{
		 		ary[str[i] + 32]++;
			}
			else
			{
				ary[str[i]]++;
			}
		}
		
	}
	for(int i = 'a'; i <= 'z'; i++)
	{
		printf("%c : %d\n", i, ary[i]);
	}
	return 0;
} 


Measured memory_bytes: 2712
for _ in range(int(input())):
    x1, y1, x2, y2, x3, y3, x4, y4 = map(float, input().split())
    ab = [x2 - x1, y2 - y1]
    cd = [x4 - x3, y4 - y3]
    if abs(ab[0] * cd[1] - ab[1] * cd[0]) > 0.00000000001:
        print('NO')
    else:
        print('YES')

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

long long g(long long x) {
  int r = x % 4;
  if (r == 0)  return x;
  if (r == 1)  return 1;
  if (r == 2)  return x+1;
  /* r == 3 */ return 0;
}

int main() {
  long long a, b;
  cin >> a >> b;
  cout << (g(a-1) ^ g(b)) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
using namespace std;
#define ll long long int
#define F(i,n) for(long long int i=0;i<n;i++)
#define REF(i,a,b) for(int i=a;i<=b;i++)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ln "\n"
#define milli 1000000
#define M 1000000007
#define fastio ios::sync_with_stdio(0);cin.tie(0);

const ll N=1e7+1;
int p[N];

bool prime(ll n)
{
    if(n<2)return false;
    for(ll x=2;x*x<=n;x++)
    {
        if(n%x==0)
            return false;
    }
    return true;
}

ll largestDigit(ll n)
{
    ll largest=0;
    while(n)
    {
        ll r=n%10;
        largest=max(r,largest);
        n=n/10;
    }
    return largest;
}

ll smallestDigit(ll n)
{
    ll smallest=10;
    while(n)
    {
        ll r=n%10;
        smallest=min(r,smallest);
        n=n/10;
    }
    return smallest;
}

int numOfFactors(ll n)
{
    int ans=1;
    while(n > 1){
            int prime = p[n],cnt = 1;
            while(n % prime == 0)cnt++, n/=prime;
            ans*=cnt;
        }
    return ans;
}




int main()
{
   for(int i=2;i<N;i++)
    {
        if(p[i])
            continue;
        for(int j=i;j<N;j+=i)
            p[j]=i;
    }
    fast;
    fastio;
    ll n;
    cin>>n;
    if(n==0)
        cout<<"1\n";
    else
        cout<<"0\n";
    return 0;
}


Measured memory_bytes: 42716
import collections

n=int(input())
a=list(map(int,input().split()))

c=collections.Counter(a)

MAX1=0
MAX2=0

for i,m in c.items():
    if m>=2 and m<4:
        if i>MAX1 and i>MAX2:
            if MAX1>MAX2:
                MAX2=i
            else:
                MAX1=i
        elif MAX1>i and i>MAX2:
            MAX2=i
        elif MAX2>i and i>MAX1:
            MAX1=i
    elif m>=4:
        if i>MAX1 and i>MAX2:
            MAX1=i
            MAX2=i
        elif MAX1>i and i>MAX2:
            MAX2=i
        elif MAX2>i and i>MAX1:
            MAX1=i

print(MAX1*MAX2)

Measured memory_bytes: 68760
/*----------------by syr----------------*/
/*

         iii                  ii
     rBQBBBBBBE       BBR iBBBBQBBL     XBBBBBBQBBBBB
   iBBQJ    7BBB      BBsSBBr   BBQ      i      cBBB
  rBBU       iBBw     BBBQi     HBBi           KBBi
  BBH         BB5    iBBB       isL          wBB5
 GBB         iBBi    6BB                   iBBB
 BBQ         BQB     BBD                  QBBi
 BBB        BQB     iQBi                1BBv
 sBBg     wBBB      QBB               iBBB
  7BBBBBBBBBi       BBR              wBBBBBBBBBBBBB
     irvi           ii               ii    i i iii
                i5U
               BBB
               BB7
              1BB
      iPBBBBBKBBR    JBR1       rQBO   BR  UBQP  iBBQi
    7BBBGs7sXBBBi     QBBr     gBBE   rBB BB2BB7HBZQBB
   QBBi      sBQ       BBB   iBBB     SQBBR  BBBB  cBQ
  gBQ        BBg        BBB KBBi      MBBH   BBB   BBs
 iBBv       iBBi         QBBBL        BBR   pBB   iBB
 pBB        BBB         iBBBB        iBB    BBL   KBB
 MBB       BBBR        BBB JBBi      DBR   iBQ    BBL
 GBB     7BBBB2      PBBH   BBBi     BQr   DBB   iBB
  BQBXwgBBP BB7    1BBB      BBQ7   1BB    BBc   BBB
   2BBBBw   BB    EBBS        QBBi  HBa   iBB    BB7
*/
#include<bits/stdc++.h>

using namespace std;

#define PH push
#define MP make_pair
#define PB push_back
#define fst first
#define snd second
#define FOR(i, x, y) for(int i = (x); i < (y); ++i)
#define REP(i, x, y) for(int i = (x); i <= (y); ++i)
#define x0 x0123456789
#define y0 y0123456789
#define x1 x1234567890
#define y1 y1234567890
#define x2 x2345678901
#define y2 y2345678901
typedef double db;
typedef long long ll;
typedef long double ldb;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1e9 + 7;
const int maxn = 2e5 + 5;
const int inv_2 = 500000004;

int b, w, ans, cur, totb, totw;
int fac[maxn], ifac[maxn];

inline int add(int a, int b){return (a + b) % INF;}
inline int sub(int a, int b){return (a - b + INF) % INF;}
inline int mul(int a, int b){return 1ll * a * b % INF;}

inline int qpow(int a, int b = INF - 2){
	int ret = 1;
	for(; b; b >>= 1){
		if(b & 1)
			ret = mul(ret, a);
		a = mul(a, a);
	}
	return ret;
}

inline int dvd(int a, int b){return mul(a, qpow(b));}

inline int C(int n, int k){
	if(n < k)
		return 0;
	return mul(fac[n], mul(ifac[k], ifac[n - k]));
}

int main(){
	scanf("%d%d", &b, &w);
	fac[0] = 1;
	FOR(i, 1, maxn)
		fac[i] = mul(fac[i - 1], i);
	FOR(i, 0, maxn)
		ifac[i] = qpow(fac[i]);
	cur = 2, ans = 1;
	REP(i, 1, b + w){
		//printf("cur = %d ans = %d totb = %d totw = %d\n", cur, ans, totb, totw);
		printf("%d\n", mul(add(ans, totw), qpow(qpow(2, i))));
		ans = cur;
		ans = sub(ans, sub(C(i, b), C(i - 1, b)));
		ans = sub(ans, sub(C(i, w), C(i - 1, w)));
		cur = sub(cur, sub(C(i, b), C(i - 1, b)));
		//printf("i = %d cur = %d\n", i, cur);
		cur = sub(cur, sub(C(i, w), C(i - 1, w)));
		//printf("i = %d cur = %d\n", i, cur);
		cur = mul(cur, 2);
		totb = mul(add(totb, sub(C(i, b), C(i - 1, b))), 2);
		totw = mul(add(totw, sub(C(i, w), C(i - 1, w))), 2);
	}
	return 0;
}

Measured memory_bytes: 3712
#include <iostream>
#include <string>
#include <vector>
#include <cstring>
#include <climits>
#include <algorithm>
#include <map>
using namespace std;

const int dx[4] = {1, -1, 0, 0};
const int dy[4] = {0, 0, 1, -1};

int X, Y;
int bd[10][10];

inline bool valid(int x, int y) {
	return 0 <= x && x < X && 0 <= y && y < Y;
}

bool ok() {
	for (int i=0; i<Y; ++i) {
		for (int j=0; j<X; ++j) {
			if (bd[0][0] != bd[i][j]) return false;
		}
	}
	return true;
}

bool paint(int color, int x, int y) {
	bool ret = false;
	int orig = bd[y][x];
	bd[y][x] = color;
	for (int i=0; i<4; ++i) {
		if (valid(x+dx[i], y+dy[i])) {
			if (bd[y+dy[i]][x+dx[i]] == orig) {
				ret |= paint(color, x+dx[i], y+dy[i]);
			} else {
				ret = true;
			}
		}
	}
	return ret;
}

int dfs(int cnt, int &mn) {
	if (ok()) {
		mn = min(mn, cnt);
		return cnt;
	}
	if (20 < cnt || mn <= cnt) return INT_MAX;

	int ret = INT_MAX;
	int tmp[10][10];
	memcpy(tmp, bd, sizeof tmp);

	if (paint((bd[0][0] + 1) % 3, 0, 0)) ret = min(ret, dfs(cnt + 1, mn));
	memcpy(bd, tmp, sizeof bd);

	if (paint((bd[0][0] + 2) % 3, 0, 0)) ret = min(ret, dfs(cnt + 1, mn));
	memcpy(bd, tmp, sizeof bd);

	return ret;
}

int main() {
	while (cin >> X >> Y, X) {
		char c;
		for (int i=0; i<Y; ++i) {
			for (int j=0; j<X; ++j) {
				cin >> c;
				bd[i][j] = (c == 'R' ? 0 : (c == 'G' ? 1 : 2));
			}
		}
		int mn = INT_MAX;
		cout << dfs(0, mn) << endl;
	}
	return 0;
}

Measured memory_bytes: 1172
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


class point_t {
public:
  bool operator<(const point_t& p) const {
    if (x == p.x)
      return y < p.y;

    return x < p.x;
  };
                                          
public:
  int x;
  int y;
};


#define MAX_V 222

int V;
std::vector<int> G[MAX_V];
int match[MAX_V];
int used[MAX_V];

void add_edge(int u, int v) {
  G[u].push_back(v);
  G[v].push_back(u);
}


bool dfs(int v) {
  used[v] = true;

  for (int i = 0; i < G[v].size(); i ++) {
    int u = G[v][i], w = match[u];

    if (w < 0 || ! used[w] && dfs(w)) {
      match[v] = u;
      match[u] = v;

      return true;
    }
  }

  return false;
}

int bipartite_matching() {
  int res = 0;

  memset(match, -1, sizeof(match));

  for (int v = 0; v < V; v ++) {
    if (match[v] < 0) {
      memset(used, 0, sizeof(used));

      if (dfs(v))
	res ++;
    }
  }
  return res;
}


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);

  int N, c = 0;

  std::cin >> N;

  std::vector<point_t> reds(N), blues(N);

  for (auto& p : reds)
    std::cin >> p.x >> p.y;

  for (auto& p : blues)
    std::cin >> p.x >> p.y;

  std::sort(ALL(reds));
  std::sort(ALL(blues));

  for (int i = 0; i < N; i ++) {
    const auto& p = reds[i];
    
    for (int j = 0; j < N; j ++) {
      const auto& q = blues[j];

      if (p.x < q.x && p.y < q.y)
        add_edge(i, j + N);
    }
  }

  V = N + N;

  std::cout << bipartite_matching() << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll long long int
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define INF 0x3f3f3f3f

using namespace std;
using namespace __gnu_pbds;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef tree<pair<int,int>,null_type, less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update>   ordered_set;
const int N=1e5+100, mod=1e9+7;

int main(){
	ios_base::sync_with_stdio(0);	cin.tie(0);
	int a,b;
	cin>>a>>b;
	cout<<ceil(1.0*(b-1)/(a-1));
}




Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <bitset>
#include <iterator>
#include <cmath>
#include <stack>
#include <random>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

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

using namespace std;
using ll = long long;
using P = pair<ll, ll>;

constexpr ll mod = 1e9+7;
const double PI = acos(-1.0);
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

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

  string s; cin >> s;
  int zero = 0;
  int one = 0;
  for(auto e: s) {
    if (e == '0') {
      zero++;
    } else {
      one++;
    }
  }

  cout << s.size() - abs(zero-one) << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <complex>
#include <climits>

using namespace std;

int main() {
    int x, y ,z; cin >> x >> y >> z;

    swap(x, y);
    swap(x, z);

    cout << x << " " << y << " " << z << endl;
}


Measured memory_bytes: 256
N=int(input())
s=[int(input())for i in range(N)]
sum_s=sum(s)
if sum_s%10!=0:
    print(sum_s)
    exit()
else:
    ss=sorted(s)
    for i in range(N):
        if (sum_s-ss[i])%10!=0:
            print(sum_s-ss[i])
            exit()
print(0)

Measured memory_bytes: 9056
#include <iostream>
#define rep(i,n) for (int i = 0; i < (n); ++i)

using namespace std;

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

  int h, w, a, b;
  cin >> h >> w >> a >> b;

  int g[1003][1003] = {0};

  rep(i, h) {
    rep(j, w) {
      g[i][j] = 1;
    }
  }
 
  rep(i, h) {
    rep(j, w) {
      if (j < a && i < b) {
        g[i][j] = 0;
      }
      if (j >= a && i >= b) {
        g[i][j] = 0;
      }
    }
  }

  rep(i, h) {
    rep(j, w) {
      cout << g[i][j];
      cout << ((j == w-1) ? "\n" : "");
    }
  }

  return 0;
}

Measured memory_bytes: 5120
#include <stdio.h>
#include <stdlib.h>
 
long int compare_int(const void *a, const void *b)
{
    return *(long int*)a - *(long int*)b;
}
 
long int binary_search_right(long int list[], long int list_size, long int x){
    long int left, right, mid;
    left = 0;
    right = list_size - 1;
 
    while (left <= right) {
        mid = (left + right)/2;
        if(list[left] < x && x <= list[right] && right - left == 1){
            return left;
        }else if(list[mid] < x){
            left = mid;
        }
        else{
            right = mid;
        }
    }
    while(1){
        printf("error");
    }
}
 
long int binary_search_left(long int list[], long int list_size, long int x){
    long int left, right, mid;
    left = 0;
    right = list_size - 1;
 
    while (left <= right) {
        mid = (left + right)/2;
        if(list[left] <= x && x < list[right]&& right - left == 1){
            return right;
        }else if(list[mid] <= x){
            left = mid;
        }
        else{
            right = mid;
        }
    }
    while(1){
        printf("error");
    }
}
 
int main(void){
    long int n, i;
    scanf("%d", &n);
    long int a[1000000], b[1000000], c[1000000];
    for(i = 0; i < n; i++){scanf("%d", &a[i]);}
    for(i = 0; i < n; i++){scanf("%d", &b[i]);}
    for(i = 0; i < n; i++){scanf("%d", &c[i]);}
 
    qsort(a, n, sizeof(long int), compare_int);
    qsort(c, n, sizeof(long int), compare_int);
 
    long int a_b, b_c, k;
    long int tmp;
    long int ans = 0;
    if(n == 1){
        if(a[0] < b[0] && b[0] < c[0]){
            printf("1\n");
            return 0;
        }else{
            printf("0\n");
            return 0;
        }
    }
 
    for(i = 0; i < n; i++){
        if(b[i] > a[n - 1]){
            a_b = n;
        }else if(b[i] <= a[0]){
            a_b = 0;
        }else{
            a_b = binary_search_right(a, n, b[i]) + 1;//(条件を満たす最大の配置番号＋１)通りがある
        }
 
        if(b[i] >= c[n - 1]){
            b_c = 0;
        }else if(b[i] < c[0]){
            b_c = n;
        }else{
            b_c = n - binary_search_left(c, n, b[i]);
        }
        ans = ans +  a_b * b_c;
        //printf("%d %d %d\n", i, a_b, b_c);
    }
    printf("%ld\n", ans);
    return 0;
}

Measured memory_bytes: 4844