akhauriyash/Code-Regression huggingface dataset:
h,w=map(int,input().split())
flag = False
ans = []
for i in range(h):
    A=list(map(int,input().split()))
    if i%2==0:
        r=range(w)
    else:
        r=range(w-1,-1,-1)
    for j in r:
        a=A[j]
        if (i>0 or j>0) and flag:
            ans.append(f"{prev_i+1} {prev_j+1} {i+1} {j+1}")
        if flag:
            if a%2==0:
                flag = True
            else:
                flag = False
        else:
            if a%2==0:
                flag = False
            else:
                flag = True
        prev_i = i
        prev_j = j
print(len(ans))
print("\n".join(ans))

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

int main() {
  string S;
  cin >> S;
  vector<char>s(S.size());
  for(int i=0; i<S.size(); i++)s.at(i)=S.at(i);
  
  sort(s.begin(), s.end());
  
  string ans = "yes";
  for(int i=0; i<S.size()-1; i++){
    if(s.at(i)==s.at(i+1))ans = "no";
  }
  
  cout << ans << endl;
}

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

int main(void){
	int N;
	int i,k;
	int ans=0;
	int ctr=0;
	string S;

	cin >> N >> S;

	vector<char> gv(S.length());
	rep(i,S.length()) gv[i]=S[i]-'A';

	rep(i,S.length()){
		printf("%c",((gv[i]+N)%26)+'A');
	}
	printf("\n");

	return 0;
}



Measured memory_bytes: 3636
#include <string>
#include <algorithm>
#include <vector> 
#include <math.h>
#include <iostream>
using namespace std;
long long mod = 1000000000 + 7;


int main()
{
	string s;
	cin >> s ;
	
	int ans = 0;

	int ansz = 0;
	int anso = 0;
	bool a = true;
	bool b = false;
	char zero = '0';
	char one = '1';

	for (int i = 0; i < s.size(); i++) {
		char a1 = zero;
		char b1 = zero;
		if (a) {
			a1 = one;
		}
		else {
			b1 = one;
		}
		

		if (s[i] == a1) {
			ansz++;
		}
		else {
			anso++;
		}
		a = !a;
		b = !b;
	}

	ans = min(ansz, anso);
	cout << ans << endl;
	return 0;

}


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

using ll = long long;
using Pi = pair < int, int >;

constexpr int INF = (1 << 30) - 1;
constexpr int dy[] = { 1, 0, -1, 0, 1, -1, -1, 1 };
constexpr int dx[] = { 0, 1, 0, -1, 1, 1, -1, -1 };

int H, W;
string S[405];
ll ans = 0;

Pi dfs ( int y, int x )
{
	Pi ret = Pi(0, 0);
	char save = S[y][x];

	if ( S[y][x] == '#' ) ret.first++;
	else ret.second++;

	S[y][x] = 'N';

	for ( int i = 0; i < 4; i++ ) {
		int ny = y + dy[i], nx = x + dx[i];	
		if ( 0 <= ny && 0 <= nx && ny < H && nx < W && S[ny][nx] != 'N' ) {
			if ( save != S[ny][nx] ) {
				auto data = dfs(ny, nx);
				ret.first += data.first;
				ret.second += data.second;
			}
		}
	}

	return ( ret );
}

int main()
{
	cin >> H >> W;

	for ( int i = 0; i < H; i++ ) {
		cin >> S[i];
	}

	for ( int i = 0; i < H; i++ ) {
		for ( int j = 0; j < W; j++ ) {
			if ( S[i][j] != 'N' ) {
				auto data = dfs(i, j);
				ans += (ll)data.first * data.second;
			}
		}
	}
	
	cout << ans << endl;

	return ( 0 );
}


Measured memory_bytes: 20480
a1,b1 = map(int,input().split())
a2,b2 = map(int,input().split())
a3,b3 = map(int,input().split())
a4,b4 = map(int,input().split())
a5,b5 = map(int,input().split())
a6,b6 = map(int,input().split())
a7,b7 = map(int,input().split())
ai = [a1,a2,a3,a4,a5,a6,a7,"fin"]
bi = [b1,b2,b3,b4,b5,b6,b7]
i = 0
while ai[i] != "fin":
    print(ai[i]-bi[i])
    i += 1


Measured memory_bytes: 5600
#[allow(unused_macros)]
macro_rules! input_byline {
    ($($r:tt)* ) => {
        let stdin = std::io::stdin();
        let mut q = std::collections::VecDeque::new();
        let mut next = || {
            if q.is_empty() {
                let mut s = String::new();
                stdin.read_line(&mut s);
                for v in s.split_whitespace() {
                    q.push_back(v.to_string());
                }
            }
            q.pop_front().unwrap()
        };
        input_inner!{next, $($r)*}
    };

}

#[allow(unused_macros)]
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

trait Printable {
    fn p(&self);
}

impl<T: std::fmt::Display> Printable for T {
    fn p(&self) {
        println!("{}", self);
    }
}

impl<T: std::fmt::Display> Printable for [T] {
    fn p(&self) {
        for i in 0..self.len() {
            if i != 0 {
                print!(" ");
            }
            print!("{}", self[i]);
        }
        println!("");
    }
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap};

#[allow(dead_code)]
type Graph = Vec<Vec<usize>>;

fn main() {
    input! {
        n: usize,
    }
    println!("{}", n * n * n);
}


Measured memory_bytes: 4352
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>

using ll = long long;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, x) for(int i=1;i<=(int)(x);i++)
#define rrep(i, x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i, x) for(int i=(int)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007

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;
/* 1..10
 * rep:   0 1 2 3 4 5 6 7 8 9
 * reps:  1 2 3 4 5 6 7 8 9 10
 * rrep:  9 8 7 6 5 4 3 2 1 0
 * rreps: 10 9 8 7 6 5 4 3 2 1
 */

int main() {
    vector<int> a(3);
    rep(i, 3) cin >> a[i];
    sort(all(a));
    cout << a[0] + a[1] << endl;

}




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

int main() {
  ll A; // <= 10^15
  double B; // < 10
  cin >> A >> B;

  // double から long long への暗黙の型変換
  // 切り捨てで壊れないように、0.5 などを行う
  //
  // 例: 100 2.51
  ll C = B * 100 + 0.5;
  ll D = A * C;
  ll E = D / 100;

  cout << E << endl;
  return 0;
}


Measured memory_bytes: 3704
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
using ll = long long;

int main(){
    int n; cin >> n;
    if(n == 3) {
        cout << 2 << endl;
        cout << "1 3" << endl;
        cout << "2 3" << endl;
    }else{
        if(n%2) cout << (n-1)*(n-1)/2 << endl;
        else cout << n*(n-2)/2 << endl;
        int m = n-n%2;
        for(int i = 1;i < m/2;++i){
            for(int j = i+1;j <= m/2;++j){
                cout << i << " " << j << endl;
                cout << i << " " << m+1-j << endl;
                cout << m+1-i << " " << j << endl;
                cout << m+1-i << " " << m+1-j << endl;
            }
        }
        if(n%2){
            for(int i = 1;i < n;++i) cout << n << " " << i << endl;
        }
    }
}

Measured memory_bytes: 256
import itertools

#n桁のm値のbitを生成
def bit(n, m):
    bit_list = list(itertools.product([i for i in range(m)], repeat=n))
    return bit_list

N, M = map(int, input().split())
L = [list(map(int, input().split())) for _ in range(M)]
P = list(map(int, input().split()))

patterns = bit(N, 2)

res = 0
for pattern in patterns:
    flag = True
    
    for i in range(M):
        count = 0
        
        for j in range(L[i][0]):
            if pattern[L[i][j+1] - 1] == 1:
                count += 1
                
        if count%2 != P[i]:
            flag = False
            
    if flag:
        res += 1
        
print(res)

Measured memory_bytes: 3188
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int par[1000];

void init(int n){
    REP(i,n){
        par[i] = i;
    }
}

int find(int x){
    if (par[x] == x){
        return x;
    }else{
        return par[x] = find(par[x]);
    }
}

bool same(int x, int y){
    return find(x) == find(y);
}

void merge(int x, int y){
    x = find(x);
    y = find(y);
    if (x==y) return;
    par[x] = y;
}

struct edge{ int u, v, cost; };

vector<edge> es;
int n;

bool comp(const edge &e1, const edge &e2){
    return e1.cost < e2.cost;
}

int kruskal(){
    sort(es.begin(), es.end(), comp);
    init(n);
    VI e_used;
    REP(i,es.size()){
        edge e = es[i];
        if (!same(e.u, e.v)){
            merge(e.u, e.v);
            e_used.push_back(e.cost);
        }
    }
    return e_used[n/2-1];
}

int main() {
    int m;
    while (cin >> n >> m && n){
        es.clear();
        while (m--){
            edge e;
            cin >> e.u >> e.v >> e.cost;
            e.u--;
            e.v--;
            es.push_back(e);
        }
        cout << kruskal() << endl;
    }

    return 0;
}

Measured memory_bytes: 3160
program attack_survival
  implicit none
  integer :: n, k, q, a, i, p(100000) = 0
  read(*,*) n, k, q
  p(1:n) = k-q
  do i = 1, q
    read(*,*) a
    p(a) = p(a)+1
  end do
  do i = 1, n
    if (p(i) > 0) then
      write(*,'(a)') "Yes"
    else
      write(*,'(a)') "No"
    end if
  end do
end program attack_survival

Measured memory_bytes: 1024
h, w = gets.chomp.split(" ").map(&:to_i)
a = []
h.times do
  a << gets.chomp.split(" ").map(&:to_i)
end

ans = []
h.times do |i|
  w.times do |j|
    if (a[i][j]).odd?
      if j < w - 1
        a[i][j] -= 1
        a[i][j+1] += 1
        ans << [i+1, j+1, i+1, j+2]
      else
        if i < h - 1
          a[i][j] -= 1
          a[i+1][j] += 1
          ans << [i+1, j+1, i+2, j+1]
        end
      end
    end
  end
end

puts ans.length
ans.each{|line| puts line.join(" ")}

Measured memory_bytes: 26364
#include<bits/stdc++.h>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
typedef pair<int,int>P;
typedef pair<int,P>PP;
string s1,s2,stt,goo;
int n,m,x,c1;
int dp[6009][2009];
vector<P>v[6001];
int main(){
  while(cin>>n>>m>>x,n){
    r(i,6001)v[i].clear();
    r(i,6009)r(j,2009)dp[i][j]=1e9;
    x*=10;
    int c=1;
    map<string,int>M;
    set<int>s;
    cin>>stt>>goo;
    r(i,n){
      cin>>s1>>s2>>c1;
      if(!M[s1])M[s1]=c++;
      if(!M[s2])M[s2]=c++;
      v[M[s1]].push_back(P(M[s2],c1));
      v[M[s2]].push_back(P(M[s1],c1));
      //cout<<c<<endl;
    }
    int st=M[stt],go=M[goo];
    r(i,m){
      cin>>s1;
      s.insert(M[s1]);
    }
    //cout<<c<<endl;
    dp[st][x]=0;
    priority_queue<P,vector<PP>,greater<PP> >q;
    q.push(PP(0,P(st,x)));
    while(!q.empty()){
      PP p=q.top();q.pop();
      int now=p.second.first;
      int cost=p.first;
      int cap=p.second.second;
      if(dp[now][cap]<cost)continue;
      r(i,v[now].size()){
        int dis=v[now][i].second;
        int next=v[now][i].first;
        int cost2=cost+dis;
        int cap2=cap-dis;
        if(cap2<0)continue;
        if(s.count(next))cap2=x;
        if(dp[next][cap2]>cost2){//cout<<next<<' '<<cost2<<endl;
          dp[next][cap2]=cost2;
          q.push(PP(cost2,P(next,cap2)));
        }
      }
    }
    int ans=1e9;
    r(i,2009)ans=min(dp[go][i],ans);
    if(ans==1e9)cout<<-1<<endl;
    else cout<<ans<<endl;
  }
}

Measured memory_bytes: 75720
def popcount(x):
    return bin(x).count("1")

n=int(input())
s=input()
X=int(s,2)

one_cnt=popcount(X)

modp=X%(one_cnt+1)
modm=X%(one_cnt-1) if one_cnt-1!=0 else 0

for i in range(n):
    if s[i]=="1":
        if one_cnt-1==0:
            print(0)
            continue
        else:
            num=(modm-pow(2,n-i-1,one_cnt-1))%(one_cnt-1)
    else:
        num=(modp+pow(2,n-i-1,one_cnt+1))%(one_cnt+1)

    #print(i,"num",num)
    cnt=1
    while num!=0:
        num=num%popcount(num)
        cnt+=1
    print(cnt)












Measured memory_bytes: 79688
import sys
def input(): return sys.stdin.readline().rstrip()
from bisect import bisect
def main():
    n,d,a=map(int,input().split())
    XH=[list(map(int,input().split())) for i in range(n)]
    XH.sort()
    X,H=zip(*XH)
    right=[0]*n
    for i,x in enumerate(X):
        right[i]=bisect(X,x+2*d)
    damage=[0]*(n+1)
    ans=0
    for i,(x,h) in enumerate(XH):
        if i!=0:
            damage[i]+=damage[i-1]
        h-=damage[i]
        if h>0:
            cunt=-(-h//a)
            ans+=cunt
            damage[i]+=a*cunt
            damage[right[i]]-=a*cunt
    print(ans)


if __name__=='__main__':
    main()

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

typedef pair<int, int> pii;
typedef long long ll;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

#ifdef LOCAL
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else 
#define dump(x) true
#endif

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U> void chmin(T& t, const U& u) { if (t > u) t = u; }
template<class T, class U> void chmax(T& t, const U& u) { if (t < u) t = u; }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

V<int> cyc(V<int> &a) {
	VV<int> cand;
	rep(j, 4) {
		V<int> vec;
		rep(k, 4) {
			vec.pb(a[(j+k)%4]);
		}
		cand.pb(vec);
	}
	return *min_element(ALL(cand));
}

int com(V<int>& v) {
	int cnt = 0;
	rep(j, 4) {
		V<int> vec;
		rep(k, 4) {
			vec.pb(v[(j+k)%4]);
		}
		if (vec == v) {
			++cnt;
		}
	}
	return cnt;
}

int main() {
	int N; cin >> N;
	VV<int> vf;

	map<V<int>, int> T, coef;

	rep(i, N) {
		V<int> a(4);
		rep(j, 4) cin >> a[j];

		auto vec = cyc(a);
		vf.pb(vec);
		++T[vec];
		dump(vec);
		coef[vec] = com(vec);
	}

	ll ans = 0;

	rep(i, N) {
		rep(j, i) {
			--T[vf[i]];
			--T[vf[j]];

			rep(k, 4) {
				int up[4], dw[4];
				rep(l, 4) {
					up[l] = vf[i][l];
					dw[l] = vf[j][(k-l+4)%4];
				}

				ll t = 1;

				VV<int> use;
				rep(l, 4) {
					V<int> vec{up[l],up[(l+3)%4],dw[(l+3)%4],dw[l]};
					vec = cyc(vec);
					use.pb(vec);
					t *= T[vec] * coef[vec];
					if (--T[vec] < 0) break;
				}
				ans += t;
				for (auto &v : use) {
					++T[v];
				}
			}

			++T[vf[i]];
			++T[vf[j]];			
		}
	}
	dump(ans);

	cout << ans / 3 << endl;

	return 0;
}

Measured memory_bytes: 70144
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 10e9;
void Widespread(){
	int n;
	cin >> n;
	ll a, b;
	cin >> a >> b;
	ll t[100010];
	for (size_t i = 0; i < n; i++)
	{
		cin >> t[i];
	}
	ll row = 0;
	ll high = 1000000000;

	while (row < high - 1)
	{
		ll mid = (row + high) / 2;
		ll bd = mid * b;
		ll add = a - b;
		ll count = 0;
		for (size_t i = 0; i < n; i++)
		{
			if (bd < t[i]) {
				count += (ll)ceil((t[i] - bd) / (double)add);
			}
		}
		if (count <= mid) {
			high = mid;
		}
		else {
			row = mid;
		}
	}

	cout << high << endl;
}

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



Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i <= (n); i++)
#define repm(i,m,n) for (int i = m; i < (n); i++)
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;

int main() {
  int N, K;
  cin >> N >> K;
  
  cout << (N%K != 0) << endl;
}

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

using namespace std;

/*

        Bismillahir Rahmanir Rahim
        Problem :
        Problem Link :
        Topics :
        Solver : Masud Parves
        I Love Code More than Sharks Love Blood <3
*/


#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define SZ(a)           (int)a.size()
#define all(a)  a.begin(), a.end()
#define allr(a)  a.rbegin(), a.rend()


#define sf(a)           scanf("%d",&a)
#define sff(a,b)        scanf("%d %d",&a,&b)
#define sfff(a,b,c)     scanf("%d %d %d",&a,&b,&c)

#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define fr(i,b,a) for(int i=(b);i>=(a);i--)

#define CIN ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define TEST_CASE(t) for(int zz=1 ; zz<=t ; zz++)
#define PRINT_CASE printf("Case %d: ",zz)
#define Debug(x)            cout<<#x " = "<<(x)<<endl
#define NOT_VISITED 0
#define IS_VISITED 1
#define WHITE 0
#define GRAY 1
#define BLACK 2



int fx[4]= {1,-1,0,0};
int fy[4]= {0,0,1,-1};

/*-----------------------Bitmask------------------*/
//int Set(int N,int pos){return N=N  (1<<pos);}
//int Reset(int N,int pos){return N= N & ~(1<<pos);}
//bool Check(int N,int pos){return (bool)(N & (1<<pos));}
/*------------------------------------------------*/


const double PI = acos(-1.0);
const double EPS = 1e-6;
const int MOD = (int)1e9+7;
const int maxn = (int)2e5+5;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<ll, int> plli;
typedef pair<int, ll> pill;


int f[30];
int main() {
    CIN
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    string s;
    cin >> s;

    for(int i=0 ; i<4 ; i++){
        f[s[i]-'A']++;
    }
    f0(i,4){
        if(f[s[i]-'A']!=2){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
const int MOD = 1000000007;
const ll INF = 1LL << 60;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    map<string, int> m;
    for (int i = 0; i < n; i++)
    {
        string s;
        cin >> s;
        m[s]++;
    }
    cout << "AC x " << m["AC"] << endl;
    cout << "WA x " << m["WA"] << endl;
    cout << "TLE x " << m["TLE"] << endl;
    cout << "RE x " << m["RE"] << endl;
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
 
#define pb push_back 
#define x first 
#define y second 
#define MOD 1000081
 
using namespace std;
typedef long long ll;
typedef pair< int , int > PII;

int n, m, x, y;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> m >> x;
    if (n % 2 == 0)
		cout << ((x - m) % 2 == 0 ? "Alice" : "Borys");
    else cout << ((x - m) % 2 == 0 ? "Alice" : "Borys");
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return map(int,input().split())
def LI(): return list(map(int,input().split()))

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
        
    def find(self, x): # 根を探す
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        
        if x == y:
            return
        
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        
        self.parents[x] += self.parents[y]
        self.parents[y] = x
    
    def size(self, x):
        return -self.parents[self.find(x)]
        
    def same(self, x, y):
        return self.find(x) == self.find(y)
    
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
    
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())
    
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}
    
    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

def main():
    N,M=MAP()
    
    edges = []
    for _ in range(M):
        a,b = MAP()
        edges.append((a-1,b-1))

    # グループ数C2が
    answer = [0]*M
    answer[M-1] = N*(N-1)//2
    uf = UnionFind(N)

    for i in range(M-1,0,-1):
        a,b = edges[i]
        if uf.same(a,b):
            answer[i-1] = answer[i]
            continue

        answer[i-1] = answer[i]-uf.size(a)*uf.size(b)
        uf.union(a,b)
    
    for i in range(M):
        print(answer[i])
    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 22524
#[derive(Default)]
//NOTE
//declare variables to reduce the number of parameters for dp and dfs etc.
struct Solver {}

impl Solver {
    fn solve(&mut self) {
        let stdin = std::io::stdin();
        let mut scn = Scanner {
            stdin: stdin.lock(),
        };
        let n: usize = scn.read();
        let result = if n % 1000 == 0 {
            0
        } else {
            1000 - n % 1000
        };
        println!("{}", result);
    }
}

fn main() {
    std::thread::Builder::new()
        .stack_size(64 * 1024 * 1024) // 64MB
        .spawn(|| {
            let mut solver = Solver::default();
            solver.solve()
        })
        .unwrap()
        .join()
        .unwrap();
}
pub mod utils {
    const DYX: [(isize, isize); 8] = [
        (0, 1),   //right
        (1, 0),   //down
        (0, -1),  //left
        (-1, 0),  //top
        (1, 1),   //down right
        (-1, 1),  //top right
        (1, -1),  //down left
        (-1, -1), //top left
    ];

    pub fn try_adj(y: usize, x: usize, dir: usize, h: usize, w: usize) -> Option<(usize, usize)> {
        let ny = y as isize + DYX[dir].0;
        let nx = x as isize + DYX[dir].1;
        if ny >= 0 && nx >= 0 {
            let ny = ny as usize;
            let nx = nx as usize;
            if ny < h && nx < w {
                Some((ny, nx))
            } else {
                None
            }
        } else {
            None
        }
    }
}

//snippet from kenkoooo
pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_line(&mut self) -> String {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b'\n' || b == b'\r')
            .take_while(|&b| b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


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

const int INF = 1e18+10;
int w[101],v[101];

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

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

  int V = 100*1000;
  vector<int> dp(V+1,INF);
  dp[0] = 0;
  for(int i = 0; i < n; i++){
    for(int j = V; j > 0; j--){
      if(j - v[i] >= 0){
        dp[j] = min(dp[j],dp[j-v[i]] + w[i]);
      }
    }
  }

  for(int j = V; j > 0; j--){
    if(dp[j] <= W){
      cout << j << endl;
      return 0;
    }
  }

  return 0;
}


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

#define int long long
#define ll long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<(int)n ; i++)
#define rf(i,n,a) for(int i=n ; i>=a ; i--)
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()
#define fill(a,v) memset(a,v,sizeof(a))
#define d1(a) cout << a << "\n"
#define d2(a,b) cout << a << " " << b << "\n"
#define d3(a,b,c) cout << a << " " << b << " " << c << "\n"
#define d4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << "\n"
#define fast ios:: sync_with_stdio(false),cin.tie(nullptr);

typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;
int pal(string s)
{
	for(int i=0 ; i<sz(s) ; i++)
	{
		if(s[i] != s[sz(s) - 1 -i])
			return 0;
	}
	return 1;
}
int32_t main(){
	fast;
	string s;
	cin >> s;
	int n = sz(s);
	string a = s.substr(0,(n-1)/2);
	string b = s.substr((n+3)/2 - 1);
	if(pal(s) && pal(a) && pal(b))
		cout << "Yes";
	else
		cout << "No";
}

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

int main() {
  int n, m, counter;
  cin >> n;
  vector<string> blue(n);
  counter = 0;
  
  for (int i = 0; i < n; i++){
    cin >> blue.at(i);
  }
  cin >> m;
  vector<string> red(m);
  
  for (int i = 0; i < m; i++){
    cin >> red.at(i);
  }
  
  for (int i = 0; i < n; i++){
    int c = counter;
    counter = 0;
    for (int j = 0; j < n; j++){
      if (blue.at (i) == blue.at(j)){
        counter++;
      }
    }
    for (int j = 0; j < m; j++){
      if (blue.at (i) == red.at(j)){
        counter--;
      }
    }
    if (c > counter){
      counter = c;
    }
  }
  cout << counter << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll> ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <string> vs;
ll subseq(string &s,string &t,ll index1,ll index2)//index1->t
{
    vv e(26,vi ());
    for(ll i=0;i<s.size();i++)
    {
        e[s[i]-'a'].pb(i);
    }
    ll ans=0;
    ll curr=0;
    for(ll i=0;i<t.size();i++)
    {
        ll letter=t[i]-'a';
        if(e[letter].size()==0)
        {
            return -1;
        }
        ll index=lower_bound(e[letter].begin(),e[letter].end(),curr)-e[letter].begin();
        if(index==e[letter].size())
        {
            ans+=s.size();
            curr=e[letter][0]+1;
        }
        else
        {
            curr=e[letter][index]+1;
        }
    }
    return ans+curr;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s,t;
    cin>>s;
    cin>>t;
    cout<<subseq(s,t,0,0)<<endl;
}


Measured memory_bytes: 1736
N, L = map(int, input().split())
A = list(map(int, input().split()))

for i in range(1, N):
    if A[i-1] + A[i] >= L:
        X = i
        break
else:
    print("Impossible")
    exit()

ans = []
for i in range(1, X):
    ans.append(i)
for i in range(N-1, X, -1):
    ans.append(i)
ans.append(X)
print("Possible")
print(*ans, sep="\n")


Measured memory_bytes: 14060
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int mod=1e9+7;

int main(){
	ll n,m;
  	cin>>n>>m;
	char a[n][m];
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			cin>>a[i][j];
		}
	}
	ll dp[n][m];
	memset(dp,0,sizeof(dp));
	for(int i=0;i<n;i++){
		if(a[i][0]=='#') {
			dp[i][0]=0;
			break;
		}
		else
		dp[i][0]=1;
	}
	for(int i=0;i<m;i++){
		if(a[0][i]=='#'){
			dp[0][i]=0;
			break;
		}
		else
		dp[0][i]=1;
	}
	for(int i=1;i<n;i++){
		for(int j=1;j<m;j++){
			if(a[i][j]=='#') dp[i][j]=0;
			else
			dp[i][j]=(dp[i-1][j]%mod+dp[i][j-1]%mod)%mod;
		}
	}
	cout<<dp[n-1][m-1]<<endl;
	return 0;
}

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

int main(){
    vector<int> cnt(26,0);
    char ch;
    while(cin >> ch){
        if('A'<=ch && ch<='Z') cnt[ch-'A']++;
        else if('a'<=ch && ch<='z') cnt[ch-'a']++;
    }
    for(int i=0; i<cnt.size(); i++){
        char c='a'+i;
        cout << c << " : " << cnt[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define eps 1e-9
#define maxp 1000400
#define mod 1000000007
#define pi 3.141592653589793238
#define sin(s) scanf("%lld",&s);
#define sout(s) printf("%lld\n",s);
#define in(s) cin>>s
#define in2(a,b) cin>>a>>b
#define in3(a,b,c) cin>>a>>b>>c
#define vll vector<ll>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define endl '\n'
#define sp ' '
#define gear_change ios_base::sync_with_stdio(false),cin.tie(0)
#define nfl(i,n) for(i=0;i<n;i++)
#define sfl(i,s,e) for(i=s;i<e;i++)
#define ufl(i,n) for(i=n-1;i>=0;i--)
ll power(ll x,ll y){
    ll ret=1;
    while(y>0){
        if(y&1)
            ret=(ret*x);
        y/=2;
        x=(x*x);
    }
    return ret;
}
ll hdiv(ll n){
	ll ret=0;
	while(n%100==0){
		ret++;
		n/=100;
	}
	return ret;
}
void solve(){
	ll d,n;
	cin>>d>>n;
	ll cnt=0,val=1;
	while(true){
		if(hdiv(val)==d){
			cnt++;
		}
		if(cnt==n){
			cout<<val<<endl;
			return;
		}
		val++;
	}

}	
int main(){
	gear_change;
	ll test=1;
	// in(test);
	while(test--){
		solve();
	}
}	


Measured memory_bytes: 256
#include<bits/stdc++.h>
        #define ll long long
        #define rep(i,a,b) for(i=a;i<b;i++)
        #define pb push_back
        #define all(v) v.begin(),v.end()
        #define F first
        #define S second
        #define vi vector < ll  int >
        #define CLR(a) memset((a),0,sizeof(a))
        #define mp make_pair
        #define hell 1000000007`
using namespace std;

void solve() {
    ll n,m,i,j,k,f1=1,f2=2,y=0,k1=0,k2=0,k3=0,x;
    cin>>n>>k;
    n--;
    for(i=k-n;i<=k+n;i++) cout<<i<<" ";
}



    signed main()
        {
            ios::sync_with_stdio(false);
            cin.tie(0);
            cout.tie(0);
            int t=1;
            //cin>>t;
            while(t--)
            solve();
        }


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
 
int main(void){
    int i, j, k;
    char s[81];
    while (fgets(s, 81, stdin) != 0){
        char t[3][5] = { "the", "this", "that" };
        for (i = 1; i<27; i++){
            for (j = 0; j<3; j++){
                for (k = 0; k<strlen(t[j]); k++)
                    t[j][k] = (t[j][k] - 'a' + 1) % 26 + 'a';
                if (strstr(s, t[j]) != 0){
                    for (j = 0; j<strlen(s); j++)
                        if ('a' <= s[j] && s[j] <= 'z')
                            for (k = 0; k<i; k++)
                                s[j] += 26 * (s[j] - 'a' - 1<0) - 1;
                    printf("%s", s);
                    break;
                }
            }
            if (j != 3)
                break;
        }
    }
    return 0;
}

Measured memory_bytes: 960
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
const ll INF = 1LL<<60;
/////////////////////////////////
int main(){
    int x, y;
    cin >> x >> y;
    int turu,kame;
    turu = x * 2;
    kame = x * 4;
    if(y%2==1)
        cout << "No" << endl;
    else{
        if(y<=kame && y>=turu)cout<<"Yes"<<endl;
        else
            cout << "No" << endl;
    }
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 9223372036854775807;
const ll MOD = 1000000007;
#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define o0(a) cout<<a<<" "
#define o1(a) cout<<a<<"\n"
#define o2(a, b) cout<<a<<" "<<b<<"\n"
#define o3(a, b, c) cout<<a<<" "<<b<<" "<<c<<"\n"
#define i1(a) cin>>a
#define i2(a, b) cin>>a>>b
#define i3(a, b, c) cin>>a>>b>>c
#define fi first
#define se second

ll power(ll a, ll b, ll z = MOD)
{
	ll res = 1;
	a = (a%z);
	while(b)
	{
		if(b&1)
			res = (res*a)%z;
		a = (a*a)%z;
		b = b>>1;
	}
	return res;
}

ll inverse(ll a, ll z = MOD)
{
	return power(a, z-2, z);
}

ll gcd(ll a, ll b)
{
	ll temp;
	if(a < b)
	{
		temp = a;
		a = b;
		b = temp;
	}
	while(b)
	{
		temp = b;
		b = a - b;
		a = temp;
	}
	return a;
}

ll extend(ll a, ll b, ll &x, ll &y)
{
	if(b == 0)
	{
		x = 1;
		y = 0;
		return a;
	}
	ll x1, y1;
	ll g = extend(b, a%b, x1, y1);
	x = y1;
	y = x1- (a/b)*y1;
	return g;
}

ll mat_power(ll a, ll b, ll c, ll d, ll n, ll z = MOD)
{
	ll a0 = 1, b0 = 0, c0 = 0, d0 = 1;
	while(n)
	{
		if(n&1)
		{
			ll a1 = a0, b1 = b0, c1 = c0, d1 = d0;
			a0 = (a1*a + b1*c)%z;
			b0 = (a1*b + b1*d)%z;
			c0 = (c1*a + d1*c)%z;
			d0 = (c1*b + d1*d)%z;
		}
		ll a1 = a, b1 = b, c1 = c, d1 = d;
		a = (a1*a1 + b1*c1)%z;
		b = (a1*b1 + b1*d1)%z;
		c = (c1*a1 + d1*c1)%z;
		d = (c1*b1 + d1*d1)%z;
		n = n>>1;
	}
	return c0;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t = 1;
	// i1(t);
	while(t--)
	{
		int n;
		i1(n);
		int aray[n];
		for(int i=0;i<n;i++)
			cin>>aray[i];
		map<int, int> m;
		ll sum = 0;
		for(int i=0;i<n;i++)
		{
			if(m.count(aray[i]))
				m[aray[i]]++;
			else
				m[aray[i]]=1;
			sum += aray[i];
		}
		int q;
		cin>>q;
		while(q--)
		{
			int b, c;
			i2(b, c);
			sum += (m[b]*c-m[b]*b);
			o1(sum);
			m[c] += m[b];
			m[b] = 0;
		}
	}
	return 0;
}

Measured memory_bytes: 8408
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<cmath>
#include<iterator>
#include<algorithm>
using namespace std;
using ll = long long;
map<ll,ll> mp;
void solve(ll n)  
{  
    while (n % 2 == 0)  
    {  
        //cout << 2 << " ";
        mp[2]++;
        n = n/2;  
    }  
  	for (ll i = 3; i <= sqrt(n); i = i + 2)  
    {  
        while (n % i == 0)  
        {  
            //cout << i << " "; 
            mp[i]++; 
            n = n/i;  
        }  
    }  
  
    if (n > 2) {
    	mp[n]++;
        //cout << n << " ";  
    }
} 
int main()
{
	using ll = long long;
	ll n;
	cin>>n;
	solve(n);
	ll total = 0;
	for(auto e : mp){
		ll ans;
		ll target = e.second;
		target *= 2;
		for(ll i = 0; true; i++){
			if(i * (i + 1) <= target){
				ans = i;
			}
			else
				break;
		}
		total += ans;
	}
	cout << total << endl;
	return 0;
}

Measured memory_bytes: 3704
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll,ll>
#define vpll vector <pll>
#define pb push_back
#define f(i,a,n) for(ll i=a;i<n;i++)
const ll N=2e5;

int main()
{
    ll n;
    cin>>n;
    ll k=n%10;
    if(k==2||k==4||k==5||k==7||k==9)
        cout<<"hon";
    else if(k==0||k==1||k==6||k==8)
        cout<<"pon";
    else if(k==3)
        cout<<"bon";
    return 0;
}



Measured memory_bytes: 3636
# include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
template<typename T>vector<T> make_v(size_t a){ return vector<T>(a); }
template<typename T,typename... Ts>auto make_v(size_t a, Ts... ts){ return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }
template<typename T,typename V>typename enable_if<is_class<T>::value==0>::type fill_v(T &t, const V &v){ t = v; }
template<typename T,typename V>typename enable_if<is_class<T>::value!=0>::type fill_v(T &t, const V &v){ for(auto &e : t) fill_v(e, v); }
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int n, k;

int main(){
    cin >> n >> k;
    cout << ((n - 1)/2 >= k - 1 ? "YES" : "NO") << endl;
}

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

#define REP(i,num) for(int i=0;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;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(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)...);}

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

	string S=in<string>();
	map<char,int> M;
	REP(i,3) M[S[i]]++;
	if(M['A']==3 || M['B']==3) out("No");
	else out("Yes");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define f(i,x,n) for(int i=x;i<(int)(n);++i)
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=200005,INF=1<<30;
int dp[13][203];

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    while(1){
        int N,M;cin>>N>>M;
        if(N+M==0) break;
        
        vector<int> T(M),A(M),B(M),id(M),state(N+1);
        state[1]=1;
        for(int i=0;i<M;i++){
            cin>>T[i]>>A[i]>>B[i];
        }
        iota(all(id),0);
        
        sort(all(id),[&](int a,int b){
            return T[a]<T[b];
        });
        
        for(int i=0;i<M;i++){
            if(state[A[id[i]]]){
                state[B[id[i]]]=1;
            }
        }
        
        int ans=0;
        
        for(int i=1;i<=N;i++) ans+=state[i];
        
        cout<<ans<<endl;
        
    }
}



Measured memory_bytes: 3376
import java.util.Scanner;

public class Main {

    private static final String[] words = {"eraser", "erase", "dreamer", "dream"};

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();

        for (int i = 0; i < words.length; i++) {
            s = s.replaceAll(words[i], "");
        }
        if (s.equals("")) {
            System.out.println("YES");
            return;
        }
        System.out.println("NO");
    }

}


Measured memory_bytes: 28048
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n, k;
    cin >> n >> k;
    
    vector<int> p(n);
    
    for(int i = 0;i < n;i++){
        cin >> p[i];
    }
    
    sort(p.begin(), p.end());
    
    int sum = 0;
    for(int i = 0;i < k;i++){
        sum += p[i];
    }
    
    cout << sum;
    
    return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <set>
#include <queue>
#include <cctype>
#include <climits>
#include <stack>
using namespace std;
 
int n,m,r;
const int INF=1e7;
int d[2][200][200];
int dp[1001][200];
typedef pair<int,int> P;
 
int main(){
 
 
    while(scanf("%d %d",&n,&m),n){
	    
	   for(int i=0;i<n;i++){
		  for(int j=0;j<n;j++) d[0][i][j]=d[1][i][j]=INF;
		  d[0][i][i]=d[1][i][i]=0;
	   }
	    
	   for(int i=0;i<m;i++){
		  int x,y,t;
		  char c;
		  scanf("%d %d %d %c",&x,&y,&t,&c);
		  x--; y--;
		  
		  d[c=='L'][x][y]=min(d[c=='L'][x][y],t);
		  d[c=='L'][y][x]=min(d[c=='L'][y][x],t);
	   }
	    
	   for(int k=0;k<n;k++){
		  for(int i=0;i<n;i++){
			 for(int j=0;j<n;j++){
				d[0][i][j]=min(d[0][i][j],d[0][i][k]+d[0][k][j]);
				d[1][i][j]=min(d[1][i][j],d[1][i][k]+d[1][k][j]);
			 }
		  }
	   }
	   
	   int now,z;
	   scanf("%d",&r);
	   scanf("%d",&now); now--;

	   fill(dp[0],dp[1001],INF);
	   dp[0][now]=0;
	    
	   for(int i=0;i<r-1;i++){
		   scanf("%d",&z); z--;
		   
		   for(int j=0;j<n;j++){
			   dp[i+1][j]=min(dp[i+1][j],dp[i][j]+d[1][now][z]);
			   for(int k=0;k<n;k++){
				   // 
				   dp[i+1][k]=min(dp[i+1][k],dp[i][j]+d[1][now][j]+d[0][j][k]+d[1][k][z]);
			   }
			   
			   
		   }
		   now=z;
	   }


/*
	   //int res=INF;
	   for(int i=1;i<r;i++){
		  for(int j=0;j<n;j++){
						    
			 for(int k=0;k<n;k++){
				dp[i][k]=min(dp[i][k],dp[i-1][j]+d[1][z[i-1]][j]+d[0][j][k]+d[1][k][z[i]]);
				//if(i==r-1 && res>dp[i][k]) res=dp[i][k];
			 }
			 dp[i][j]=min(dp[i][j],dp[i-1][j]+d[1][z[i-1]][z[i]]);
			 //if(i==r-1 && res>dp[i][j]) res=dp[i][j];
		  }
	   }
*/
	   printf("%d\n",*min_element(dp[r-1],dp[r]));
	    
    }
}

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

constexpr char NL = '\n';
constexpr int MOD = 1e9 + 7;

struct safe_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

void solve()
{
    int n, W; cin >> n >> W;
    vector<vector<ll>> dp(n + 1, vector<ll>(W + 1, 0));
    for (int i = 1; i <= n; ++i) {
        int w, v; cin >> w >> v;
        for (int j = 1; j <= W; ++j) {
            dp[i][j] = w > j ? dp[i - 1][j] : max(dp[i - 1][j], v + dp[i - 1][j - w]);
        }
    }
    cout << dp[n][W] << '\n';
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
    return 0;
}

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

using namespace std;
#define ll long long
#define ld long double
const int N = 2e5 + 5;
bool vis[N];
int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int x, n;
    cin >> x >> n;
    for(int i = 1 ; i <= n ; i++) {
        int y;
        cin >> y;
        vis[y + 200] = 1;
    }
    int mn = 1e9, ans;
    for(int i = -100 ; i <= 105 ; i++) {
        if (vis[i + 200]) continue;
        if (abs(i - x) < mn) {
            mn = abs(i - x);
            ans = i;
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
int main (){
  int x1,x2,y1,y2;
  cin>>x1>>y1>>x2>>y2;
  int x,y;
  x=-1*(x2-x1);
  y=-1*(y2-y1);
  cout<<x2+y<<endl;
  cout<<y2-x<<endl;
  cout<<x2+y+x<<endl;
  cout<<y2-x+y<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int n,i;
  double v,x,y;
  priority_queue<double,vector<double>,greater<double>> que;
  cin >> n;
  for (i=0;i<n;i++){
    cin >> v;
    que.push(v);
  }
  while (que.size()>1){
    x=que.top();
    que.pop();
    y=que.top();
    que.pop();
    que.push((x+y)/2);
  }
  printf("%.12lf\n",que.top());
  return 0;
}

Measured memory_bytes: 256
S = input()
N = len(S)
P = 0
for i in range (N-1//2):
    if S[i] == S[N-1-i]:
        for k in range((N-1)//2):
            if S[k] == S[((N-1)//2)-k-1] and S[((N+1)//2)+k] == S[N-1-k]:
                P = P
            else:
                P += 1
    else:
        P += 1

if P == 0:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
typedef pair<long long ,long long> pll;
//aを始点とする、v頂点e辺の全ての点に対する最短経路(dijkstra法)
vector<long long> dijkstra(long long v,long long a,vector<vector<pll>> edge){
    const long long INF = 1e15;
    //vector<vector<pll>> edge=makedata(v,e);// first:B second:cost
    priority_queue<pll,vector<pll>,greater<pll>> que;//first:distance second:A
    vector<long long> dist(v+1,INF);
    dist[a] = 0;
    que.push(make_pair(0,a));
    while(!que.empty()){
        pll pr = que.top();
        que.pop();
        if(pr.first>dist[pr.second]) continue;
        for(long i = 0;i<edge[pr.second].size();i++){
            if(dist[edge[pr.second][i].first] > dist[pr.second]+edge[pr.second][i].second){
                que.push(make_pair(dist[pr.second]+edge[pr.second][i].second,edge[pr.second][i].first));
                dist[edge[pr.second][i].first]=dist[pr.second]+edge[pr.second][i].second;
            }
        }
    }
    return dist;
}
int main(){
    int n,m,s,t;
    cin >> n >> m >> s >> t;
    vector<vector<pll>> edge[2];//0:yen 1:snuuk
    rep(i,2) rep(j,n+1) edge[i].push_back({});
    long long u,v;
    long long a[2];
    rep(i,m){
        cin >> u >> v >> a[0] >> a[1];
        u--;v--;
        rep(j,2){
            edge[j][u].push_back(make_pair(v,a[j]));
            edge[j][v].push_back(make_pair(u,a[j]));
        }
    }
    vector<long long> yendict = dijkstra(n,s-1,edge[0]);
    vector<long long> snudict = dijkstra(n,t-1,edge[1]);
    vector<pair<long long,int>> data;
    long long money = 1e15;
    rep(i,n) data.push_back({yendict[i]+snudict[i],i+1});
    sort(data.begin(),data.end());
    int year = 0;
    int cnt = 0;
    rep(i,n){
        long long cost = data[i].first;
        int cnum = data[i].second;
        while(year<cnum){
            cout << money - cost << endl;
            cnt++;
            if(cnt==n) break;
            year++;
        }
        if(cnt==n) break;
    }
}

Measured memory_bytes: 26992