akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>
#include <iomanip>
#include <functional>

#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define MAXMIN(a,b,c) std::max(a,min(b,c))
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

lli mod197 = 1000000007LL;
lli INF = 10000000000000;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}

int a[20][20], b[20];

int main(void) {


	int n, m, c;
	cin >> n >> m >> c;
	int count = 0;

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

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> a[i][j];
		}
	}


	for (int i = 0; i < n; i++) {
		int sum = 0;
		for (int j = 0; j < m; j++) {
			sum += a[i][j] * b[j];
		}
		if (sum + c > 0)
			count++;
	}

	COUT(count);

	return 0;
}


Measured memory_bytes: 256
/*
		@Author :- Gaurav Bharti
		National Institute of Technology, Jamshedpur.
*/
 
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define empb emplace_back
#define mp make_pair
#define F first
#define S second
#define endl "\n"
#define vii vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define vpii vector<pii>
#define mapii map<int,int> 
#define mapll map<ll,ll>
#define all(a) a.begin(),a.end()
#define test ll t; cin>>t; while(t--)
#define prec(n) fixed<<setprecision(n)
#define jaldibazi ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mod 1000000007
const int N=1e5+10;


int main(){
	jaldibazi;

	char c; cin >> c;
	if( c<='z' && c>='a') cout <<"a\n";
	else if(c<='Z' && c>='A') cout <<"A\n";

    return 0;
}

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

const long long P5_MAX = 3982;
long long pos[P5_MAX], neg[P5_MAX];

int main(){
    long long x;
    cin >> x;
    unordered_map<long long, long long> m;
    for(long long i = 0; i < P5_MAX; i++){
        pos[i] = i*i*i*i*i;
        neg[i] = -pos[i];
        m[neg[i]] = -i;
        m[pos[i]] = i;
    }
    if(x == 0){
        cout << "0 0\n";
        return 0;
    }
    if(m.count(x)){
        cout << m[x] << " 0\n";
        return 0;
    }
    if(m.count(-x)){
        cout << "0 " << m[-x] << '\n';
        return 0;
    }
    for(long long i = 0; i < P5_MAX; i++){
        if(m.count(x+pos[i])){
            cout << m[x+pos[i]] << ' ' << i << '\n';
            return 0;
        }
        if(m.count(x+neg[i])){
            cout << m[x+neg[i]] << ' ' << (-i) << '\n';
            return 0;
        }
    }
}


Measured memory_bytes: 3952
#include <iostream>
#include <stack>
#include <queue>
using namespace std;

int main()
{
	int N;
	stack<int> train;
	queue<int> leave;
	while (cin >> N) {
		if (N == 0) {
			leave.push(train.top());
			train.pop();
		}
		else {
			train.push(N);
		}
	}
	for (; leave.empty() == 0;) {
		cout << leave.front() << endl;
		leave.pop();
	}
	return 0;
}

Measured memory_bytes: 3004
#include<bits/stdc++.h>
#define pb emplace_back
using namespace std;
using ll = long long;
const int maxn = 300010;
int a[maxn], n;
signed main(){
	ios_base::sync_with_stdio(0), cin.tie(0);
	cin >> n;
	for(int i = 1;i <= n;++i)cin >> a[i];
	int now = 1, res = 0;
	for(int i = 1;i <= n;++i){
		if(a[i] != now)++res;
		else ++now;
	}
	if(res == n)cout << -1 << '\n';
	else cout << res << '\n';
}



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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = long long;
constexpr ll INF = (1LL<<60);
constexpr ll MOD = (1e9+7);
template<class T>inline bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
inline void dump(){cout<<endl;}
template<class Head,class... Tail>inline void dump(Head&& head, Tail&&... tail){cout<<head<<", ";dump(forward<Tail>(tail)...);}
template<typename T>inline istream &operator>>(istream&input,vector<T>&v){for(auto &elemnt:v)input>>elemnt;return input;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
using T3 = tuple<ll,ll,ll>;
using T4 = tuple<ll,ll,ll,ll>;

template<class T>
class segtree {
private:
  ll n=1;
  T unit;
  std::vector<T> dat;
  std::function<T(T,T)> func;
public:
  segtree(){}
  segtree(std::vector<T>& a,T v,std::function<T(T,T)> f){
    build(a,v,f);
  }
  void build(std::vector<T>& a,T v,std::function<T(T,T)> f){
    ll sz=a.size();
    unit=v;
    func=f;
    while(n<sz)n<<=1LL;
    dat.resize(2*n-1,unit);
    for(int i=0;i<sz;++i)dat[i+n-1]=a[i];
    for(int i=n-2;i>=0;--i){
      dat[i]=func(dat[i*2+1],dat[i*2+2]);
    }
  }
  void update(ll idx,ll val){
    idx+=n-1;
    dat[idx]=val;
    while(idx){
      idx--;idx>>=1LL;
      dat[idx]=func(dat[idx*2+1],dat[idx*2+2]);
    }
  }
  T query(ll a,ll b,ll k=0,ll l=0,ll r=-1){
    if(r<0)r=n;
    if( b<=l || r<=a )return unit;
    if( a<=l && r<=b )return dat[k];
    else{
      auto left=query(a,b,2*k+1,l,(l+r)/2);
      auto right=query(a,b,2*k+2,(l+r)/2,r);
      return func(left,right);
    }
  }
  T operator[](ll i)const{
    return dat[i+n-1];
  }
};

main(){
  ll n,m;
  cin>>n>>m;
  vector<T3> a(m);
  rep(i,m){
    ll l,r,c;
    cin>>l>>r>>c;
    l--,r--;
    a[i]=make_tuple(r,l,c);
  }
  sort(a.begin(),a.end());

  vector<ll> infv(n,INF);
  segtree<ll> dist(infv,INF,[](auto a,auto b){return min(a,b);});
  dist.update(0,0);
  for(auto const& x:a){
    ll r,l,c;
    tie(r,l,c) = x;
    ll mn = dist.query(l,r+1);
    if(dist[r]>mn+c)dist.update(r,mn+c);
  }
  cout<<(dist[n-1]==INF?-1:dist[n-1])<<endl;

}

Measured memory_bytes: 5376
#include "bits/stdc++.h"
using namespace std;
#define fst first
#define scd second
int main()
{
	int n;
	bool f = false, s = false;
	scanf("%d", &n);
	if(100 <= n && n < 1300)
	{
		f = true;
	}
	if(1 <= n % 100 && n % 100 < 13)
	{
		s = true;
	}
	if(f)
	{
		if(s)
		{
			printf("AMBIGUOUS\n");
		}
		else
		{
			printf("MMYY\n");
		}
	}
	else
	{
		if(s)
		{
			printf("YYMM\n");
		}
		else
		{
			printf("NA\n");
		}
	}
}

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

#define ll long long
#define vi vector<int>
#define pi pair<int, int>

using namespace std;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	int n;
	cin >> n;
	string s;
	cin >> s;
	int k = 1;
	for(int i = 0;i<s.size();i++){
		if(s[i] + n > 90){
			s[i] = s[i] + n - 26;
		}
		else s[i] += n;
	}
	cout << s;
}

Measured memory_bytes: 256
r, g, b, n = map(int, input().split())
conb = 0
for i in range(n+1):
    for j in range(n+1):
        k = (n-(i*r)-(j*g))
        if ((i*r) + (j*g) + k) == n and k % b == 0 and k >= 0:
            conb += 1
print(conb)

Measured memory_bytes: 41836
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<utility>
#include<algorithm>
using namespace std;
#define ll int64_t
#define REP(i, n) for (int i=0; i<n; i++)

ll f(ll n);

ll f(ll n){
    if(n % 4 == 0){
        return n;
    }else if(n % 4 == 1){
        return 1;
    }else if(n % 4 == 2){
        return 1^n;
    }else{
        return 0;
    }
}

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

    ll A, B;
    cin >> A >> B;

    ll c = A ^ B;

    if(A == 0){
        cout << (f(A) ^ f(B)) << endl;
    } else {
        cout << (f(A-1) ^ f(B)) << endl;
    }
}

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

int main() {
	long long int x, y;
	std::cin >> x >> y;
	int nSum = 0;
	long long int a = x;
	if (x == y) {
		std::cout << 1 << std::endl;
	}
	else {
		while (true) {
			if (a > y) {
				break;
			}
			else {
				nSum += 1;
			}
			a = a * 2;
		}
		std::cout << nSum << std::endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }


struct SuffixArray {
	int n, k;
	string s;
	vector<int> ord, tmp, left;
	SuffixArray(const string &s) :s(s), n(s.size()), ord(n + 1), tmp(n + 1), left(n + 1) {
		for (int i = 0; i <= n; i++) {
			left[i] = i;
			ord[i] = i < n ? s[i] : -1;
		}
		auto compare = [&](int i, int j) {
			if (ord[i] != ord[j])return ord[i] < ord[j];
			else {
				int ri = i + k <= n ? ord[i + k] : -1;
				int rj = j + k <= n ? ord[j + k] : -1;
				return ri < rj;
			}
		};
		for (k = 1; k <= n; k *= 2) {
			sort(left.begin(), left.end(), compare);
			tmp[left[0]] = 0;
			for (int i = 1; i <= n; i++) {
				tmp[left[i]] = tmp[left[i - 1]] + (compare(left[i - 1], left[i]) ? 1 : 0);
			}
			ord = tmp;
		}
	}
	int search(const string &pattern) {
		int ng = 0, ok = n + 1;
		while (ng + 1 < ok) {
			int m = (ng + ok) / 2;
			if (s.compare(left[m], pattern.size(), pattern) >= 0)
				ok = m;
			else
				ng = m;
		}
		if (ok == n + 1)
			return -1;
		else
			return s.compare(left[ok], pattern.size(), pattern) == 0 ? ok : -1;
	}
};

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string T; cin >> T;
	int Q; cin >> Q;
	SuffixArray sa(T);
	rep(i, 0, Q) {
		string P; cin >> P;
		cout << (sa.search(P) != -1) << endl;
	}
	return 0;
}

Measured memory_bytes: 15824
#include <iostream>
#define min(a, b) (a) > (b) ? (b) : (a)

using namespace std;

int a[30] = { 0 };
void square(int n, int top, int idx){
	if (top == 1){
		for (int i = 0; i < idx; i++){
			cout << a[i] << " ";
		}
		for (int i = 0; i < n - top; i++){
			cout << "1 ";
		}
		cout << "1" << endl;
	} else if (!(n - top)){
		for (int i = 0; i < idx; i++){
			cout << a[i] << " ";
		}
		cout << top << endl;
	} else{
		for (int i = min(top, n - top); i >= 1; i--){
			a[idx] = top;
			square(n - top, i, idx + 1);
		}
	}
}
int main(){
	int n;
	while (cin >> n, n){
		for (int i = n; i >= 1; i--){
			square(n, i, 0);
		}
	}
	return 0;
}

Measured memory_bytes: 1160
import bisect

while(1):
    N=int(raw_input())
    if N==0: break
    D={}
    for i in range(N):
        inp=raw_input().split()
        inp[1:]=map(int, inp[1:])
        stt=inp[1]*24*60+inp[2]/100*60+inp[2]%100
        D[inp[0]]=stt
    P=int(raw_input())
    Tlist=[-99999999,999999999]
    for i in range(P):
        f=raw_input()
        Tlist.append(D.pop(f))
    Tlist.sort()
    for i in range(P+1):
        if Tlist[i+1]<Tlist[i]+30:
            print -1
            break
    else:
        ans=P
        E=sorted(D.values())
        for st in E:
            if (st - Tlist[ bisect.bisect(Tlist, st)-1])>= 30 and (Tlist[ bisect.bisect(Tlist, st)] - st ) >= 30:
                ans+=1
                bisect.insort(Tlist, st)
        print ans

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

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

    int A, res = 100000;
    rep(i, N)
    {
        cin >> A;
        int _res = 0;
        while (A > 0)
        {
            if (A % 2 == 0)
            {
                A = A / 2;
                _res++;
            }
            else
            {
                break;
            }
        }
        res = min(res, _res);
    }

    cout << res << endl;
}


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

int main() {
  int n;
  cin >> n;
  vector<vector<int>> T(n);
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    T[a].push_back(b);
    T[b].push_back(a);
  }

  vector<int> color(n);
  queue<pair<int, int>> Qb, Qw;
  Qb.push({0, 0});
  Qw.push({n - 1, 0});

  int black = 1, white = 1;
  int cost = 0;

  while (!Qb.empty() || !Qw.empty()) {
    while (!Qb.empty() && Qb.front().second == cost) {
      int x = Qb.front().first;
      Qb.pop();

      if (color[x] == -1) continue;

      color[x] = 1;
      black++;
      for (auto node: T[x]) {
        if (color[node] == 0) {
          Qb.push({node, cost + 1});
        }
      }
    }

    while(!Qw.empty() && Qw.front().second == cost) {
      int x = Qw.front().first;
      Qw.pop();

      if (color[x] == 1) continue;

      color[x] = -1;
      white++;
      for (auto node: T[x]) {
        if (color[node] == 0) {
          Qw.push({node, cost + 1});
        }
      }
    }
    cost++;
  }

  if (black > white) cout << "Fennec" << endl;
  else cout << "Snuke" << endl;

  return 0;
}

Measured memory_bytes: 6272
#include "bits/stdc++.h"
//#define int long long
#define loop(i, a, b) for(int i = a; i < b; i++)
#define rep(i, a) loop(i, 0, a)
#define all(a) (a).begin(),(a).end()
using namespace std;
const int MOD = 1e9 + 7, INF = 1e9;
using vi = vector <int>;
using vvi = vector <vi>;
//g++ -std==c++14
#define MAX_V (110)

signed main(){
	int n, m;
	cin >> n >> m;
	int will_record_time[m][100002] = {};
	rep(i, n){
		int s, t, c;
		cin >> s >> t >> c;
		c--;
		will_record_time[c][s]++;
		will_record_time[c][t]--;
	}
	vi s, t;
	rep(i, m){
		queue <int> que;
		rep(j, 100002){
			if(will_record_time[i][j] > 0)
				rep(k, will_record_time[i][j]){
					que.push(j);
				}
			if(will_record_time[i][j] < 0)
				rep(k, abs(will_record_time[i][j])){
					s.push_back(que.front());
					t.push_back(j);
					que.pop();
				}
		}
	}
	int imos[100000 * 2 + 2] = {};
	rep(i, s.size()){
		imos[s[i] * 2 - 1]++;
		imos[t[i] * 2 + 1]--;
	}
	int ans = -INF;
	rep(i, 100000 * 2 + 1){
		imos[i + 1] += imos[i];
		ans = max(ans, imos[i]);
	}
	cout << ans << endl;
}


Measured memory_bytes: 13644
#include <iostream>
#include <map>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
int main()
{
    char a[4],b[4];
    cin>>a>>b;
    reverse(b,b+3);
    if(!strcmp(a,b))cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}


Measured memory_bytes: 256
while True:
    L=input().split( )
    a=int(L[0])
    b=int(L[2])
    op=L[1]
    if op =="?":
        break
    elif op =="+":
            print(f"{a+b}")

    elif op =="-":
        print(f"{a-b}")
    elif op =="*":
        print(f"{a*b}")

    elif op =="/":
        print(f"{int(a/b)}")
    elif op =="?":
        print(f"{a+b}")



Measured memory_bytes: 5600
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <utility>
#include <bitset>

#define REP(i,A) for(int i=0;i<A;i++)

using namespace std;
using ll = long long int;
using ld = long double;
using vl = vector<ll>;
using vd = vector<ld>;

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

	int N;
	cin >> N;
	ld pi = acos(-1.);
	vd x(N), y(N);
	REP(i, N) {
		cin >> x[i] >> y[i];
	}
	REP(i, N) {
		vd kari(N);
		REP(j, N) {
			if (i != j) {
				kari[j] = atan2(y[j] - y[i], x[j] - x[i]);
			}
		}
		kari[i] = -100;
		sort(kari.begin(), kari.end());
		kari[0] = kari[N-1] - 2.*pi;
		ld ans = 0;
		REP(j, N) {
			ans = max(ans, kari[j + 1] - kari[j] - pi);
		}
		cout << ans / 2. / pi << endl;
	}
	return 0;
}

Measured memory_bytes: 512
S = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(S[int(input()) - 1])


Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
int main(){
  long N;
  cin>>N;
  vector<long> A,B,C;
  for(int x=0;x<N;x++){
    long val;
    cin>>val;
    A.push_back(val);
  }
  sort(A.begin(),A.end());
  //reverse(A.begin(),A.end());
  for(int x=0;x<N;x++){
    long val2;
    cin>>val2;
    B.push_back(val2);
  }
  sort(B.begin(),B.end());
  //reverse(B.begin(),B.end());
  for(int x=0;x<N;x++){
    long val3;
    cin>>val3;
    C.push_back(val3);
  }
  sort(C.begin(),C.end());
  //reverse(C.begin(),C.end());
  long B2[N]={},C2[N]={};
  int i=0,j=0,k=0;
  while(true){
    if(A[i]<B[j]){
      if(i!=N-1){
        B2[j]+=1;
        i+=1;
      }else{
        B2[j]+=1;
        j+=1;
        B2[j]+=B2[j-1]-1;
      }
    }else{
      j+=1;
      B2[j]+=B2[j-1];
    }
    if(j>N-1) break;
  }

  i=0,j=0;

  while(true){
    if(B[i]<C[j]){
      if(i!=N-1){
        C2[j]+=B2[i];
        i+=1;
      }else{
        C2[j]+=B2[i];
        j+=1;
        C2[j]+=C2[j-1]-B2[i];
      }
    }else{
      j+=1;
      C2[j]+=C2[j-1];
    }
    if(j>N-1) break;
  }
 long long ans=0;
 for(int i=0;i<N;i++){
   ans+=C2[i];
 }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 4340
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {
        try {
            // 標準入力
            InputStreamReader isr = new InputStreamReader(System.in);
            BufferedReader br = new BufferedReader(isr);
            String str[] = br.readLine().split(" ");
            int a = Integer.parseInt(str[0]);
            if (a == 1) {
                a = 14;
            }
            int b = Integer.parseInt(str[1]);
            if (b == 1) {
                b = 14;
            }
            if (a == b) {
                System.out.println("Draw");
            } else if (a > b) {
                System.out.println("Alice");
            } else {
                System.out.println("Bob");
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
using namespace std;
typedef long long ll;

ll a[3005][3005], dp[3005][3005][4];

int main() {
  ll R, C, n, ans = 0, r, c, v;
  cin >> R >> C >> n;
  rep(i, n) cin >> r >> c >> v, a[r - 1][c - 1] = v;

  rep(i, R) rep(j, C) {
    for (int k = 2; k >= 0; --k) chmax(dp[i][j][k + 1], dp[i][j][k] + a[i][j]);
    rep(k, 4) {
      chmax(dp[i + 1][j][0], dp[i][j][k]);
      chmax(dp[i][j + 1][k], dp[i][j][k]);
    }
  }
  rep(k, 4) chmax(ans, dp[R - 1][C - 1][k]);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 355828
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var (N, K) = ReadLine().Split(' ').Select(int.Parse).ToArray();
        var A = ReadLine().Split(' ').Select(int.Parse).ToArray();

        var ans = MathExt.DivideAndRoundUp(N - 1, K - 1);

        WriteLine(ans);
    }
}
static partial class MathExt
{
    public static int DivideAndRoundUp(int x, int y) => (int)DivideAndRoundUp((long)x, y);
    public static long DivideAndRoundUp(long x, long y) => (x + y - 1) / y; // (long)Math.Ceiling((double)x / (double)y);
}

static class ArrayDeconstructExtensions
{
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2) => (i1, i2) = (a[0], a[1]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3) => (i1, i2, i3) = (a[0], a[1], a[2]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3, out T i4) => (i1, i2, i3, i4) = (a[0], a[1], a[2], a[3]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3, out T i4, out T i5) => (i1, i2, i3, i4, i5) = (a[0], a[1], a[2], a[3], a[4]);
}


Measured memory_bytes: 35548
N=int(input())

#S = [[0 for j in range(3)] for i in range(2)]　2行3列の場合
S = [[0 for j in range(2)] for i in range(N)]

for i in range(N):
    X,L=map(int,input().split())
    S[i][0]=X-L
    S[i][1]=X+L


T=sorted(S,key=lambda x:x[1])
#U=sorted(T,key=lambda x:x[1])
if N==1:
    print(1)
    exit()


count=1
last=T[0][1]
for i in range(1,N):
    if T[i][0]>=last:
        count+=1
        last=T[i][1]
print(count)



Measured memory_bytes: 27868
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int n,i,j,ans=INT_MIN;
   cin>>n;
   int a[n][3];
   for(i=0;i<n;i++)
   {
       for(j=0;j<3;j++)
       cin>>a[i][j];
   }
   int dp[n][3];
   dp[0][0]=a[0][0];
   dp[0][1]=a[0][1];
   dp[0][2]=a[0][2];
   for(i=1;i<n;i++)
   {
       dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i][0];
       dp[i][1]=max(dp[i-1][0],dp[i-1][2])+a[i][1];
       dp[i][2]=max(dp[i-1][1],dp[i-1][0])+a[i][2];
   }
   for(i=0;i<3;i++)
   ans=max(ans,dp[n-1][i]);
   cout<<ans;
}

Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()
#define all(v) (v).begin(), (v).end()
#define sz(v) (int)(v).size()


using namespace std;

typedef long long ll;

static const long long MOD = 1000000007;

int a, b, ans;

int main(void) {
    cin >> a >> b;
    int sum = 1;
    while (sum<b) {
        sum = sum + a - 1;
        ans++;
    }
    
    
    
    cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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

int main() {

    ll N, K;
    cin >> N >> K;
    vector<ll> A(N);
    REP(i, N) {
        cin >> A[i];
        A[i]--;
    }
    if (K <= N){
        ll target = 0;
        REP(i, K){
            target = A[target];
        }
        cout << (target + 1) << endl;
        return 0;
    }
    vector<ll> num(N, -1);
    ll target = 0;
    ll i = 0;
    while(num[target] < 0){
        num[target] = i++;
        target = A[target];
    }
    ll r = i - num[target];
    K = (K - num[target]) % r;
    REP(i, K){
        target = A[target];
    }
    cout << (target + 1) << endl;

    

    return 0;
}

Measured memory_bytes: 5972
from collections import deque
ss = [0,1,0,-1]
dd = [1,0,-1,0]
while True:
    w,h = map(int ,input().split())
    if w == h == 0:
        break
    ll = []
    for i in range(h):
        ll.append(list(map(int, input().split())))
    cnt = 0
    passed = [[False]*w for i in range(h)]
    q = deque()
    for i in range(h):
        for j in range(w):
            if passed[i][j]:
                continue
            if ll[i][j] == 1:
                passed[i][j] = True
                q.append([i,j])
                cnt += 1
                while q:
                    l = q.popleft()
                    a,b = l[0], l[1]
                    for s in ss:
                        for d in dd:
                            if s == d == 0:
                                continue
                            ta = a + s
                            tb = b + d
                            if 0 <= ta <= h-1 and 0 <= tb <= w-1 and ll[ta][tb] == 1 and not passed[ta][tb]:
                                passed[ta][tb] = True
                                q.append([ta,tb])
    print(cnt)


Measured memory_bytes: 6040
#include<bits/stdc++.h>
using namespace std;
#define f(i,a,b) for(int(i)=int (a);i<=int (b);i++)
#define ff(i,a,b) for(int(i)=int (a);i<int (b);i++)
#define F(i,a,b) for(int(i)=int (a);i>=int (b);i--)
#define foreach(i,x) for(typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define vt vector
#define ll long long
#define lower(p,x) lower_bound(all(p),x)
#define upper(p,x) upper_bound(all(p),x)
#define ms(a,x) memset(a,x,sizeof a)
#define minn(a,b,c,d) min(a,min(b,min(c,d))) 
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
const double pi=acos(-1.0);//NOTE:PI
const double eps=1e-5;
const int INF=1e9,mod=1e9+7,N=1e6+6;
int a[N];
ll sum=0;
int main(){
	int n;
	cin>>n;long double v=0;
	f(i,1,n) cin>>a[i],v+=a[i];
	int t=round(v/n);
	f(i,1,n){
		sum+=(ll)(a[i]-t)*(a[i]-t);
	}
	cout<<sum;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

int h, w;
int d[10][10];
int a[210][210];
int n = 10;

void warshall_floyd(){
   rep(k, 0, n){
       rep(i, 0, n){
           rep(j, 0, n){
               d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
           }
       }
   }
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> h >> w;
    rep(i, 0, 10){
        rep(j, 0, 10){
            cin >> d[i][j];
        }
    }
    warshall_floyd();
    int ans = 0;
    int cnt[10] = {};
    rep(i, 0, h){
        rep(j, 0, w){
            cin >> a[i][j];
            if(a[i][j] != 1) cnt[a[i][j]]++;
        }
    }
    rep(i, 0, 10){
        ans += d[i][1] * cnt[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

//Util
func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func minInt(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

func absInt(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func absFloat64(a float64) float64 {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func maxFloat64(a, b float64) float64 {
	if a > b {
		return a
	} else {
		return b
	}
}

func minFloat64(a, b float64) float64 {
	if a > b {
		return b
	} else {
		return a
	}
}

func str2Int(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func powInt(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func isPrime(x int) bool {
	if x == 1 {
		return false
	}
	if x == 2 {
		return true
	}
	if x%2 == 0 {
		return false
	}

	b := true
	rootx := int(math.Sqrt(float64(x)))
	i := 3
	for i <= rootx {
		if x%i == 0 {
			b = false
			break
		}
		i += 2
	}
	return b
}

func PrimeFactors(n int) (pfs []int) {
	// Get the number of 2s that divide n
	for n%2 == 0 {
		pfs = append(pfs, 2)
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			pfs = append(pfs, i)
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs = append(pfs, n)
	}

	return
}

func sumInts(x []int) int {

	total := 0
	for _, v := range x {
		total += v
	}

	return total
}

//Main
const (
	initialBufSize = 10000
	maxBufSize     = 1000000
	mod            = 1e9 + 7
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		return sc
	}()
)

var s string

func main() {
	sc.Split(bufio.ScanWords)

	s = nextStr()
	m := make([]int, 4)

	for i := 0; i < len(s); i++ {
		if string(s[i]) == "E" {
			m[0]++
		} else if string(s[i]) == "W" {
			m[1]++
		} else if string(s[i]) == "N" {
			m[2]++
		} else if string(s[i]) == "S" {
			m[3]++
		}
	}

	if (m[0] == 0 && m[1] == 0 || m[0] > 0 && m[1] > 0) && (m[2] == 0 && m[3] == 0 || m[2] > 0 && m[3] > 0) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 640
/*****/

#include <iostream>
#include <array>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <iomanip>	//cout << fixed << setprecision(桁数);
#include <stdexcept>

//#define int long long

using namespace std;
using ll = long long;
using ld = long double;
using vecll = vector<ll>;

#define nextline() (std::cerr << "\n")
#define debug(x) (#x " : " + (x))
#define debug_cout(x) (std::cerr << #x << " : " <<  (x) << "\n")
#define debug_tabcout(n, x) (std::cerr << strMulti("\t",n) << #x << " : " <<  (x) << "\n")
#define debug_headcout(h, x) (std::cerr << h << " : " <<  (x) << "\n")
#define debug_tabheadcout(n, h, x) (std::cerr << strMulti("\t",n) << h << " : " <<  (x) << "\n")

#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; i++)
#define rep1(i, n) for(int i=1, i##_len=(n); i<=i##_len; i++)
#define rrep(i, n) for(int i=(n)-1; i >= 0; i--)
#define rrep1(i, n) for(int i=(n); i > 0; i--)
#define all(x) (x).begin(), (x).end()
#define pair(a, b) make_pair(a, b);
constexpr int INF = 2000000100;
constexpr ll DIV = 1000000007;	// 10e9+7
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> T divUp(T a, T b) { if (a % b == 0) { return a / b; } return a / b + 1; }
std::string strMulti(std::string t, int n) { std::string out = ""; for (int i = 0; i < n; i++) { out += t; } return out; }
template<class T> T math_P(T m, T n) { T ret = 1; for (T i = m; i > m - n; i--) { ret *= i; } return ret; }
template<class T> T math_C(T m, T n) { T ret = mathP(m, n); for (T i = 2; i <= n; i++) { ret /= i; } return ret; }
template<class T> bool compare_by_b(pair<T, T> a, pair<T, T> b) { if (a.second != b.second) { return a.second < b.second; } return a.first < b.first; }
template<class T> T math_gcd(T a, T b) { a = abs(a); b = abs(b); if (a < b) { std::swap(a, b); } T tmp; while (b != 0) { tmp = b; b = a % b; a = tmp; } return a; }
template<class T> T math_lcm(T a, T b) { a = abs(a); b = abs(b); if (a > b) { std::swap(a, b); } if (a == 1) { return b; } T i = a; while (i % b != 0) { i += a; } return i; }

/*****/

void Main()
{
	int r;
	cin >> r;
	cout << r * r;
}

/*****/

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

	//std::cout << std::fixed << std::setprecision(10);


	/*
	while (true)
	{
		Main();
		cout << endl;
	}
	//*/


	Main();

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
  int n;
  vector<int> N;
  for(int i=0;i<4;i++){
    cin >> n;
    N.push_back(n);
  }
  sort(N.begin(),N.end());
  if(N[0] == 1 && N[1]==4 && N[2]==7 && N[3]==9){
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
  return 0;

}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)

int main(){
  int N; cin >> N;
  int A[N];
  rep(i, N) cin >> A[i];
  //ここまで入力

  //すべてのダム水の合計
  int sum = 0;
  rep(i, N) sum += A[i];

  //最後のダムを除いた水の合計
  int sum_l = 0;
  for(int i=0; i<N-1; i+=2)
    sum_l += (2*A[i]);

  //山に降る水
  int mou[N];

  mou[N-1] = sum - sum_l;

  for(int i=N-1; i>0; i--)
    mou[i-1] = 2*A[i-1] - mou[i];

  rep(i, N)
    cout << mou[i] << " ";
  cout << endl;
    
  
  return 0;
}


Measured memory_bytes: 2048
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=1e9+7;
const ll MAX=100005;
ll n,m;
vector<ll>G[MAX];
vector<ll>dp[MAX];

ll preDFS(ll u,ll p){
    ll ret=1;
    rep(i,G[u].size()){
        ll to=G[u][i];
        if(to!=p){
            dp[u][i]=preDFS(to,u);
            ret=ret*(1+dp[u][i])%m;
        }
    }
    return ret;
}
//親に対する辺の値処理
void DFS(ll u,ll p,ll d){
    rep(i,G[u].size()){
        ll to=G[u][i];
        if(to==p)dp[u][i]=d;
    }
    vector<ll>L(G[u].size()),R(G[u].size());
    rep(i,G[u].size()){
        L[i]=(i?L[i-1]:1)*(dp[u][i]+1)%m;
    }
    for(int i=G[u].size()-1;i>=0;i--){
        R[i]=((i<G[u].size()-1)?(R[i+1]):1)*(dp[u][i]+1)%m;
    }
    rep(i,G[u].size()){
        if(G[u][i]!=p){
            ll sum=(i?L[i-1]:1)*((i<G[u].size()-1)?R[i+1]:1)%m;
            DFS(G[u][i],u,sum);
        }
    }
}

int main(){
    cin>>n>>m;
    rep(i,n-1){
        ll x,y;cin>>x>>y;
        x--;y--;
        G[x].pb(y);
        G[y].pb(x);
    }
    rep(i,n)dp[i].resize(G[i].size());
    preDFS(0,-1);
    DFS(0,-1,0);

    rep(i,n){
        ll sum=1;
        for(auto e:dp[i])sum=sum%m*(e+1)%m;
        cout<<sum<<endl;
    }
}

Measured memory_bytes: 22400
package main

import (
	"fmt"
	"strings"
)

func main() {
	var n int
	fmt.Scan(&n)
	var s string
	fmt.Scan(&s)
	rgb := strings.Split(s, "")
	var r, g, b []int
	ans := 0
	var max, min, div int

	for i := 0; i < n; i++ {
		if rgb[i] == "R" {
			r = append(r, i)
		} else if rgb[i] == "G" {
			g = append(g, i)
		} else {
			b = append(b, i)
		}
	}
	for i := range r {
		for j := range g {
			ans = ans + len(b)
			if r[i]-g[j] < 0 {
				max = g[j]
				min = r[i]
			} else {
				max = r[i]
				min = g[j]
			}
			div = max - min
			//			fmt.Println(max, min, div)
			if div%2 == 0 {
				if rgb[min+div/2] == "B" {
					ans--
				}
			}
			if min-div >= 0 {
				if rgb[min-div] == "B" {
					ans--
				}
			}
			if max+div <= n-1 {
				if rgb[max+div] == "B" {
					ans--
				}
			}
		}
	}

	//	for i := range r {
	//		for j := range g {
	//			for k := range b {
	//				tmp := []int{r[i], g[j], b[k]}
	//				sort.Sort(sort.IntSlice(tmp))
	//				if tmp[1]-tmp[0] != tmp[2]-tmp[1] {
	//					ans++
	//				}
	//			}
	//		}
	//	}
	//	fmt.Println("r", r)
	//	fmt.Println("g", g)
	//	fmt.Println("b", b)
	//	fmt.Println("rgb", rgb)
	fmt.Println(ans)
}


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

int main()
{
	int N;
	cin >> N;
	int m1 = 0;
	int m2 = 0;
	int m4 = 0;
	for( int i = 0; i < N; i++ ) {
		long long A;
		cin >> A;
		if( A % 4 == 0 ) m4++;
		else if( A % 2 == 0 ) m2++;
		else m1++;
	}

	string ans = "No";
	if( m4 >= N / 2 || m1 == 0 ) ans = "Yes";
	if( m2 > 1 ) {
		if( m4 >= m1 ) ans = "Yes";
	}

	cout << ans << endl;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define debug(a) cout << "["; rep(i,a.size()) cout << a.at(i) << ", "; cout<<"]"<< endl;

const ll mod = 1000000007;

int main() {
    ll n; cin >> n;
    ll ans = 0;
    rep(i,n){
        ll x = i + 1;
        ll y = n / x;
        ans += y*(x + x * y) / 2;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3636
# define _CRT_SECURE_NO_WARNINGS 1
# include <iostream>
# include <string>
# include <bitset>
# include <vector>
# include <algorithm>
# include <cstdlib>
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <iomanip>
# include <queue>
# include <sstream>
# include <climits>
# include <cmath>
# include <list>
# include <functional>
# include <string>
# include <ctime>
# include <set>
# include <map>
# include <stack>
using namespace std;
# define M_PI 3.141592
# define FOR(i,n) for(int i=0;i<(int)n;i++)
# define FORI(i,k,n) for(int i=k;i<(int)n;i++)
# define toRad 2.0*M_PI/360.0
# define inin(x) int x;cin>>x;
# define all(x) x.begin(),x.end()
# define debug(x) cout<<#x<<" :"<<x<<endl;
# define rep(i,n) for(int i=0;i<(int)n;i++)
# define EPS 1e-12
# define CHECK(i,a) FOR(i,a.size())cout<<#a<<"["<<i<<"] : "<<a[i]<<endl; 

int main()
{
	int n;
	int a[200];
	cin >> n;
	for (int i = 0; i < 2 * n; i++)
	{
		cin >> a[i];
	}
	sort(begin(a), begin(a)+2*n);
	int ans = 0;
	for (int i = 0; i < 2 * n; i += 2)
	{
		ans += a[i];
	}
	cout << ans << endl;
}

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

typedef long long ll;
typedef pair<ll, ll> pll;

#define m0(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
#define rep(i, n) for(int i = 0; i < (n); i++)
#define asort(x) sort(all(x));
#define dsort(x, t) sort(x.begin(), x.end(), greater<t>());
#define vuni(v) v.erase(unique(v.begin(), v.end()), v.end());
#define mins(m, s) m.insert(make_pair(s, 1));
#define mfin(m, s) m.find(s) != m.end()

#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl

const int INF = 1e9;
const ll LINF = 1e18;
const int mod = 1e9 + 7;

int main() {
    int d, t, s;
    cin >> d >> t >> s;
    int ans = t * s;
    if(d <= ans) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3544
import collections

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

d = collections.Counter(a)
ans = sum(a)

for i in range(q):
    b, c = map(int, input().split())
    num = (c-b)*d[b]
    ans += num
    print(ans)
    d[c] += d[b]
    d[b] = 0

Measured memory_bytes: 24000
/*  -*- coding: utf-8 -*-
 *
 * b.cc: B - Even Degrees
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100000;
const int MAX_M = 100000;

/* typedef */

typedef long long ll;
typedef vector<int> vi;
typedef queue<int> qi;
typedef pair<int,int> pii;
typedef vector<pii> vpii;

/* global variables */

int ps[MAX_N], pes[MAX_N], cns[MAX_N];
vpii nbrs[MAX_N];
pii es[MAX_M];
bool vused[MAX_N], eused[MAX_M], ens[MAX_N];

/* subroutines */

/* main */

int main() {
  int n, m;
  scanf("%d%d", &n, &m);

  if (m & 1) {
    puts("-1");
    return 0;
  }

  for (int i = 0; i < m; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    a--, b--;
    nbrs[a].push_back(pii(b, i));
    nbrs[b].push_back(pii(a, i));
    es[i] = pii(a, b);
  }

  ps[0] = pes[0] = -1;
  vused[0] = true;
  qi q;
  q.push(0);

  while (! q.empty()) {
    int u = q.front(); q.pop();
    int &up = ps[u];
    vpii &nbru = nbrs[u];

    for (vpii::iterator vit = nbru.begin(); vit != nbru.end(); vit++) {
      int &v = vit->first, &ei = vit->second;
      if (v != up) {
	if (vused[v]) {
	  if (! eused[ei]) {
	    //printf(" %d(%d,%d)\n", ei, es[ei].first, es[ei].second);
	    ens[es[ei].first] ^= 1;
	    eused[ei] = true;
	  }
	}
	else {
	  cns[u]++;
	  ps[v] = u;
	  pes[v] = ei;
	  vused[v] = true;
	  q.push(v);
	}
      }
    }
  }

  //for (int u = 0; u < n; u++)
  //printf("%d %d %d %d\n", u, ps[u], pes[u], ens[u]);
  
  for (int u = 0; u < n; u++)
    if (cns[u] == 0) q.push(u);

  while (! q.empty()) {
    int u = q.front(); q.pop();
    int &up = ps[u], &ep = pes[u];

    if (up >= 0) {
      if (ens[u])
	es[ep] = pii(u, up), ens[u] ^= 1;
      else
	es[ep] = pii(up, u), ens[up] ^= 1;

      if (--cns[up] == 0) q.push(up);
    }
  }  

  for (int i = 0; i < m; i++)
    printf("%d %d\n", es[i].first + 1, es[i].second + 1);
  return 0;
}


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



int main(){
	int d,t, s;
	cin >> d >> t >> s;
	int a;
	 a = s * t;
	 if(a<d) cout << "No" << endl;
	 else cout << "Yes" << endl;
	return 0;
}


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

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;
const int MOD = 1e9 + 7;
int dp[3011][3011][2];

void add(int &a, int b)
{
	a+=b;
	while(a>=MOD) a-=MOD;
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	ll n, m; cin>>n>>m;
	for(int i=0;i<=n;i++) 
	{
		dp[0][i][i==0] = 1;
	}
	for(int i=0;i<m;i++)
	{
		for(int j=0;j<=n;j++)
		{
			for(int k=0;k<2;k++)
			{
				int v=dp[i][j][k];
				if(v==0) continue;
				//RR
				if(j>=1)
				{
					add(dp[i+1][j-1][k|(j-1==0)],v);
				}
				//BB
				if(j+1<=n)
				{
					add(dp[i+1][j+1][k|(j==0)],v);
				}
				//RB
				if(j-1>=0)
				{
					add(dp[i+1][j][k|(j-1==0)],v);
				}
				//BR
				if(j+1<=n)
				{
					add(dp[i+1][j][k|(j==0)],v);
				}
			}
		}
	}
	int ans=0;
	for(int i=0;i<=n;i++)
	{
		add(ans,dp[m][i][1]);
	}
	cout<<ans<<'\n';
}


Measured memory_bytes: 70912
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstdint>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <utility>
#include <limits>
#include <list>
#include <type_traits>

/* template start */
 
#define rep(i, a, b) for (long long i = (a); (i) < (b); (i)++)
#define all(i) i.begin(), i.end()

#ifdef LOCAL
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  if(sizeof...(t)>0)std::cout<<" :";
  debug_out(t...);
}
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}

template<typename Num>
constexpr Num mypow(Num a, long long b) {
  if(b==0)return 1;
  if (a==0)return 0;
  Num x = 1;
  while (b > 0) {
    if(b & 1)x*=a;
    a*=a;
    b >>= 1;
  }
  return x;
}

/* template end */

using ll = long long;

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

  std::string ans;

  ll n;
  std::cin>>n;

  while(n>0){
    ll mod=(n-1)%26;
    ans.push_back((char)('a'+mod));
    n=(n-1)/26;
  }

  std::reverse(all(ans));

  std::cout<<ans<<"\n";

  return 0;
}

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

int main(){
  int64_t a, b, x;
  cin >> a >> b >> x;
  int64_t m=a%x;
  if(m==0LL){
    cout << (b-a)/x + 1LL << endl;
  }
  if(m!=0LL){
    cout << (b-a+m)/x << endl;
  }
}
    

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i,x) for(int i=0;i<(int)(x);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()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

ll dp[101][100001] = {};
int main() {
	int N,W;
	cin >> N;
	cin >> W;
	int w[N], v[N];
	REP(i, N) {
		cin >> w[i];
		cin >> v[i];
	}
	REPS(i, N){
		REP(j, W+1){
			if (j - w[i-1] >= 0) {
				chmax(dp[i][j], dp[i-1][j-w[i-1]]+v[i-1]);
			}
			chmax(dp[i][j], dp[i-1][j]);
		}
	}
	ll res = 0;
	REP(i, W+1) {
		chmax(res, dp[N][i]);
		}
	cout << res;
}


Measured memory_bytes: 78336
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  ll n,i,ans=0;
  cin>>n;
  ll arr[n]={0};
  for(i=0;i<n;i++){
    cin>>arr[i];  
  }
  ll maxi=arr[0];
  for(i=0;i<n;i++){
    if(arr[i]>maxi)maxi=arr[i];
    ans+=abs(maxi-arr[i]);
  }
  cout<<ans<<"\n";
  
}

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

int main() {
  int n;
  cin >> n;
  vector<int> data(n);
  for (int i = 0; i < n; i++) {
      cin >> data.at(i);
      cout << data[i];
      if (i != n - 1) {
          cout << " ";
      }
  }
  cout << endl;

  for (int i = 1; i < n; i++) {
      int v = data[i];
      int j = i - 1;
      while(j >= 0 && data[j] > v) {
          data[j + 1] = data[j];
          j--;
      }
      data[j + 1] = v;

    for (int k = 0; k < n; k++) {
      cout << data[k];
      if (k != n - 1) {
          cout << " ";
      }
    }
    cout << endl;
  }
}


Measured memory_bytes: 3096
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
int a, b;
bool ask(int x, int y) {
    cout << "? " << x << " " << y << endl;
    char c;
    cin >> c;
    return c == 'Y';
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    //freopen("input.txt", "r", stdin);
    cin >> a >> b;
    if (a <= b) {
        cout << "Impossible"<<endl;
        return 0;
    }
    int n = a + b;
    vector < int > p;
    for (int i = 0; i < n; i++) {
        if (p.empty()) {
            p.emplace_back(i);
            continue;
        }
        bool f = ask(p.back(), i);
        if (!f) {
            p.pop_back();
            continue;
        }
        else {
            p.emplace_back(i);
        }
    }
    int tr = p.back();
    string ans;
    for (int i = 0; i < n; i++) {
        if (tr == i) {
            ans += "1";
        }
        else {
            bool c = ask(tr, i);
            if (c) ans += "1";
            else ans += "0";
        }
    }
    cout << "! ";
    cout << ans;
    cout << endl;
    return 0;
}

Measured memory_bytes: 724
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%lld",&x)
#define pi(x) printf("%d",x)
#define pl(x) printf("%lld",x)
#define pb push_back
#define mkp make_pair
#define fi first
#define se second
#define re register
#define rep(i,m,n) for(int i=m;i<=n;i++)
#define per(i,n,m) for(int i=m;i>=n;i--)
#define rrep(i,m,n) for(register int i=m;i<=n;i++)
#define rper(i,n,m) for(register int i=m;i>=n;i--)
const int N = 3e3 + 10;
const ll mod = 1e9 + 7;
ll cnt[60][N];
int x[N];
signed main(){
   ios_base::sync_with_stdio(false);
   cin.tie(0);cout.tie(0);
   string s;
   cin>>s;
   int l=s.length();
   int num=1<<(l-1);
   ll sum=0,tmp;
   rep(i,0,num-1){
       tmp=s[0]-'0';
       rep(j,0,l-1){
           if(j==l-1||i&(1<<j)){
               sum+=tmp;
               tmp=0;
               if(j==l-1)break;
           }
           tmp=tmp*10+s[j+1]-'0';
       }
   }
   pl(sum);
   return 0;
}

Measured memory_bytes: 3732