akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long ll;
template<typename T> bool chmax(T &a, T b) {if(a <= b){a = b; return true;}return false;}
template<typename T> bool chmin(T &a, T b) {if(a >= b){a = b; return true;}return false;}


int main(void){
    int k;
    string s;
    cin >> k >> s;
    if(s.length() <= k){
        cout << s << endl;
    }else{
        string str = s.substr(0, k);
        str += "...";
        cout << str << endl;
    }
}

Measured memory_bytes: 3632
//url:
//problem name:

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    int A,B; cin >> A >> B;
    cout << max(max(A+(A-1), B+(B-1)),A+B) << endl;
}

Measured memory_bytes: 3592
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#define rep(index,num) for(int index=0;index<num;index++)
#define eps 1e-15
typedef long long ll;
int main(){
	int N;
	scanf("%d",&N);
	printf("%d\n",N*(N+1)/2);
	return 0;
}


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

int A[51][51];
int member[51][51];
int count = 0;

void check_member(int i,int j,int h, int w){
    if(member[i][j] == 0 && A[i][j] == 1 && i <= h && j <= w){
        member[i][j] = count;
        check_member(  i,  j+1 , h , w);
        check_member(i+1 , j+1 , h , w);
        check_member(i+1 ,   j , h , w);
        check_member(i+1 , j-1 , h , w);
        check_member(  i , j-1 , h , w);
        check_member(i-1 , j-1 , h , w);
        check_member(i-1 ,   j , h , w);
        check_member(i-1 , j+1 , h , w);
    }else{
        return;
    }
}


int main(){
    vector<int> result;
    int h,w;
    while(cin >> w >> h){
        if(h == 0 && w == 0) break;
        count = 0;
        for(int i = 0; i <= h; i++){
            for(int j = 0; j <= w; j++){
                if(i > 0 && j > 0){
                    cin >> A[i][j];
                }else{
                    A[i][j] = 0;
                }
                member[i][j] = 0;
            }
        }
        for(int i = 1; i <= h; i++){
            for(int j = 1; j <= w; j++){
                if(A[i][j]==1 && member[i][j] == 0){
                    count++;
                    check_member(i,j,h,w);
                }
            }
        }
        result.push_back(count);
    }
    for(int i = 0; i < result.size(); i++){
        cout << result[i] << endl;
    }
}


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

using namespace std;

int main()
{
    string T;
    string S;
    string Y;

    cin>>S;
    cin>>T;



    T.pop_back();
    //cout<<T<<endl;

        if(S==T)
        {
            cout<<"Yes"<<endl;
        }
        else
        {
            cout<<"No"<<endl;
        }


    return 0;
}


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

const int maxn = 1e5 + 10;
int n, x, g, mx, arr[maxn];

int main(){
    ios_base::sync_with_stdio(false);

    cin >> n >> x;

    for(int i = 0; i < n; i++){
        cin >> arr[i];
        if(i){
            g = __gcd(g, arr[i]);
        }else{
            g = arr[i];
        }

        mx = max(mx, arr[i]);
    }

    if(x > mx){
        cout << "IMPOSSIBLE\n";
    }else if(x % g == 0){
        cout << "POSSIBLE\n";
    }else{
        cout << "IMPOSSIBLE\n";
    }

    return 0;
}


Measured memory_bytes: 640
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
const ll MOD = 1000000007;
using namespace std;

int main(){
    string s; cin >> s;
    int a=s[0]-'0', b=s[1]-'0', c=s[2]-'0', d=s[3]-'0';
    string ans = "aobocod=7";
    ans[0] = s[0]; ans[2] = s[1]; ans[4] = s[2]; ans[6] = s[3];
    if(a+b+c+d==7){ans[1]='+'; ans[3]='+'; ans[5]='+';}
    else if(a-b+c+d==7){ans[1]='-'; ans[3]='+'; ans[5]='+';}
    else if(a+b-c+d==7){ans[1]='+'; ans[3]='-'; ans[5]='+';}
    else if(a+b+c-d==7){ans[1]='+'; ans[3]='+'; ans[5]='-';}
    else if(a-b-c+d==7){ans[1]='-'; ans[3]='-'; ans[5]='+';}
    else if(a-b+c-d==7){ans[1]='-'; ans[3]='+'; ans[5]='-';}
    else if(a+b-c-d==7){ans[1]='+'; ans[3]='-'; ans[5]='-';}
    else if(a-b-c-d==7){ans[1]='-'; ans[3]='-'; ans[5]='-';}
    cout << ans << endl;
    return 0;
}

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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)

using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;

constexpr int MOD = 1000000007;

void print(const vvi& G) {
    rep(i, 0, 8) {
        rep(j, 0, 8) { cout << (G[i][j] == 1 ? 'Q' : '.'); }
        cout << endl;
    }
}

vvi put(vvi G, int i, int j) {
    G[i][j] = 1;
    rep(k, 0, 8) {
        if (G[i][k] != 1) { G[i][k] = -1; }
        if (G[k][j] != 1) { G[k][j] = -1; }
        if (k + j - i >= 0 && k + j - i < 8 && G[k][k + j - i] != 1) { G[k][k + j - i] = -1; }
        if (j + i - k >= 0 && j + i - k < 8 && G[k][j + i - k] != 1) { G[k][j + i - k] = -1; }
    }
    return G;
}

int check_row(const vvi& G) {
    rep(i, 0, 8) {
        bool ans = false;
        rep(j, 0, 8) {
            if (G[i][j] == 1) {
                ans = true;
                break;
            }
        }
        if (!ans) { return i; }
    }
    return -1;
}

vi calc(const vvi& G, int i) {
    vi ans;
    rep(j, 0, 8) {
        if (G[i][j] == 0) { ans.push_back(j); }
    }
    return ans;
}

vvi backtrack(const vvi& G) {
    stack<vvi> st;
    st.push(G);

    while (!st.empty()) {
        vvi g = st.top();
        st.pop();

        // print(g);

        int row = check_row(g);
        if (row == -1) { return g; }

        vi cols = calc(g, row);
        for (int col : cols) { st.push(put(g, row, col)); }
    }

    return G;
}

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

    int k;
    cin >> k;

    vvi G(8, vi(8, 0));
    rep(i, 0, k) {
        int r, c;
        cin >> r >> c;
        G = put(G, r, c);
    }

    G = backtrack(G);
    print(G);

    return 0;
}


Measured memory_bytes: 3220
#include <cmath>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
using namespace std;

int calcDigitOfNum(int num)
{
    if(num % 10 == 0)
        return num;

    int num2  = num / 10;
    return (num2 + 1) * 10;
}

int main(void)
{
    int A[5];
    for(int i = 0; i < 5; i++)
    {
        cin >> A[i];
    }

    sort(A, A + 5);
    
    int min_time = INT32_MAX;
    int time = 0;
    do
    {
        for(int i = 0; i < 5; i++)
        {
            if(i == 4)
                time += A[i];
            else
                time += calcDigitOfNum(A[i]);
        }
        min_time = min(min_time, time);
        time = 0;
    }while(next_permutation(A, A + 5));

    cout << min_time << endl; 
    return 0;
}

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

using namespace std;

int32_t main() {
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    long long c1 = a * x + b * y;
    int minn = min(x, y);
    long long c2 = c * 2 * minn + a * (x - minn) + b * (y - minn);
    long long c3 = c * 2 * max(x, y);

    cout << min(c1, min(c2, c3)) << endl;

    return 0;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
a = list(map(int, input().split()))
f = list(map(int, input().split()))
a.sort()
f.sort(reverse=True)

def solve(x):
    lk = k
    for i, j in zip(a, f):
        if i*j<=x:
            continue
        lk -= (j*(i+1)-x-1)//j
        if lk<0:
            return False
    return True

ok = 10**12
ng = -1
while abs(ok-ng)>1:
    mid = (ok+ng)//2
    if solve(mid):
        ok = mid
    else:
        ng = mid

print(ok)


Measured memory_bytes: 119500
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <inttypes.h>
#include <string.h>
#include <math.h>

int main (int argc, char const *argv[])
{
    int64_t N;
    char W[100][11];
    int64_t ans = 0;

    scanf("%"PRId64, &N);
    for (int i = 0; i < N; i++) {
        scanf("%s", W[i]);
    }

    for (int i = 0; i < N; i++) {
        for (int j = 0; j < i; j++) {
            if (strcmp(W[i], W[j]) == 0) {
                puts("No");
                return 0;
            }
        }
    }

    for (int i = 0; i < (N - 1); i++) {
        size_t len;
        len = strlen(W[i]);
        if (W[i][len - 1] != W[i + 1][0]) {
            puts("No");
            return 0;
        }
    }

    puts("Yes");
    return 0;
}


Measured memory_bytes: 128
from collections import deque

S = input()
Q = int(input())

is_reversed = False

S = deque(S)

for _ in range(Q):
    q = input().split(" ")
    if q[0] == "1":
        is_reversed = not is_reversed
    else:
        if q[1] == "1":
            if is_reversed:
                S.append(q[2])
            else:
                S.appendleft(q[2])
        else:
            if is_reversed:
                S.appendleft(q[2])
            else:
                S.append(q[2])

S = list(S)
if is_reversed:
    S = ''.join(list(reversed(S)))
else:
    S = ''.join((S))

print(S)

Measured memory_bytes: 10100
program double_helix
  implicit none
  character(1) :: b
  read(*,*) b
  write(*,'(a)') achar(pair(ichar(b)-65)+65)
contains
  integer function pair(n)
    integer, intent(in) :: n
    pair = 12*(19-n)/(11*n+12)
  end
end program double_helix

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long int64;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
const int MAX_NUM = 999999999;
void solve() {
	int N, M, X, Y; cin >> N >> M >> X >> Y;
	vector<int> x(N), y(M);
	for (int i = 0; i < N; ++i) cin >> x[i];
	for (int i = 0; i < M; ++i) cin >> y[i];
	sort(x.begin(), x.end());
	sort(y.begin(), y.end());
	for (int i = X + 1; i <= Y; ++i) {
		if (x[N - 1] < i && i <= y[0]) {
			cout << "No War" << endl;
			return;
		}
	}
	cout << "War" << endl;
	return;
}
int main() {
	solve();
	return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int
const int INF = 2147483647;

using namespace std;
const ll MOD = 1000000007;
ll modpow(ll a, ll n, ll mod)
{
  ll res = 1;
  while (n > 0)
  {
    if (n & 1)
      res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

ll modinv(ll a, ll mod)
{
  return modpow(a, mod - 2, mod);
}

ll modnCr(ll n, ll r, ll mod)
{
  ll ans = 1;
  FOR(i, 1, n + 1)
  {
    ans = (ans * i) % mod;
  }
  ll inv = 1;
  FOR(i, 1, r + 1)
  {
    inv = (inv * i) % mod;
  }
  FOR(i, 1, n - r + 1)
  {
    inv = (inv * i) % mod;
  }
  ans = (ans * modinv(inv, mod)) % mod;
  return ans;
}

int main()
{
  int n;
  string s;
  cin >> n >> s;
  if (s[0] == 'W' || s[2 * n - 1] == 'W')
  {
    cout << 0 << endl;
    return 0;
  }

  // l:1, r:-1
  int lr[200000] = {};
  ll cumr[200000] = {};
  ll cuml[200000] = {};
  cumr[0] = 0;
  cuml[0] = 1;
  lr[0] = 1;

  FOR(i, 1, 2 * n)
  {
    cumr[i] = cumr[i - 1];
    cuml[i] = cuml[i - 1];
    if (s[i - 1] == s[i])
    {
      lr[i] = -1 * lr[i - 1];
    }
    else
    {
      lr[i] = lr[i - 1];
    }

    if (lr[i] == 1)
    {
      cuml[i]++;
    }
    else
    {
      cumr[i]++;
    }
  }
  if (cumr[2 * n - 1] != cuml[2 * n - 1])
  {
    cout << 0 << endl;
    return 0;
  }

  ll ans = 1;
  REP(i, 2 * n)
  {
    if (lr[i] == 1)
      continue;
    ans = (ans * (cuml[i - 1] - cumr[i - 1])) % MOD;
  }

  FOR(i, 1, n + 1)
  {
    ans = (ans * i) % MOD;
  }

  cout << ans << endl;
}


Measured memory_bytes: 4484
S = input()
a = int(S[:2])
b = int(S[2:])
judge = [0,0,0]
# in case of YYMM
if 1<=b<=12:
    judge[0] = 1
# in case of MMYY
if 1<=a<=12:
    judge[1] = 1

if sum(judge) == 2:
    print("AMBIGUOUS")
elif sum(judge) == 0:
    print("NA")
elif judge[0] == 1:
    print("YYMM")
else:
    print("MMYY")


Measured memory_bytes: 3060
N, K = gets.split.map(&:to_i)
MOD = 10**9 + 7

def mpow(x, n)
  ret = 1
  while n > 0
    if n.even?
      x = x * x % MOD
      n >>= 1
    else
      ret = ret * x % MOD
      n -= 1
    end
  end
  ret
end

def inv(x)
  mpow(x, MOD - 2)
end

def f(i) # K-1 C i
  return 0 if i > K - 1
  @f ||= [1]
  @f[i] ||= @f[i - 1] * (K - i) * inv(i) % MOD
end

def g(i) # N-K+1 C i
  return 0 if i > N - K + 1
  @g ||= [1]
  @g[i] ||= @g[i - 1] * (N - K - i + 2) * inv(i) % MOD
end

(1 .. K).each{|i| puts f(i - 1) * g(i) % MOD}

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
int cmp(int x,int y){
	return x>y;
}
int main(){
	int n,a[100005],i;
	long long ansc=0,ansk=0;
	bool use[100005]={0};
	cin>>n;
	for(i=1;i<=n;i++)
		cin>>a[i];
	sort(a+1,a+1+n,cmp);
	for(i=1;i<=n;i++){
		if(a[i]==a[i-1]&&use[i-1]==0){
			if(ansc!=0){
				ansk=a[i];
				cout<<ansc*ansk;
				return 0;
			}
			else {
				use[i-1]=1;
				use[i]=1;
				ansc=a[i];
			}
		}
	}
	cout<<ansk*ansc;
	return 0;
}

Measured memory_bytes: 768
n, k = map(int, input().split())
l = [int(i) for i in range(n + 1)]
lr = l[::-1]

if k == n + 1:
    print(1)
else:
    ans = 1
    mod = 10**9 + 7
    left = sum(l[:k])
    right = sum(lr[:k])
    # print(left)
    # print(right)
    for i in range(n - k + 1):
        ans += right - left + 1
        ans %= mod
        left += l[k + i]
        right += lr[k + i]
    print(ans)


Measured memory_bytes: 18612
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include <string.h>

using namespace std;

vector<int> books[10],realprice[10];
int dp[15][2005]={0};
int main(){
	int N,K;
	int c,g;
	cin>>N>>K;
	for(int i=0;i<N;i++){
		cin>>c>>g;
		books[--g].push_back(c);
	}
	for(int i=0;i<10;i++){//??§??????????????????????????????????????\????????????
		sort(books[i].begin(),books[i].end());
		reverse(books[i].begin(),books[i].end());
		int sum=0;
		realprice[i].push_back(0);
		for(int j=0;j<books[i].size();j++){
			sum=sum+books[i][j];
			realprice[i].push_back(sum+j*(j+1));
		}
	}
	/*for(int i=0;i<10;i++){
		for(int j=0;j<realprice[i].size();j++){
			cout<<realprice[i][j]<<" ";
		}
		cout<<endl;
	}*/
	//????????§DP?????§??????
	for(int i=0;i<realprice[0].size();i++){
		dp[0][i]=realprice[0][i];				
	}
	for(int i=1;i<10;i++){
		
		for(int j=0;j<realprice[i].size();j++){//i??????j???????????????
			for(int k=j;k<=K;k++){
				dp[i][k]=max(dp[i][k],dp[i-1][k-j]+realprice[i][j]);
			}
		}
	}
	cout<<dp[9][K]<<endl;
		
	return 0;
}

Measured memory_bytes: 1324
N,K=map(int,input().split())
A=list(map(int,input().split()))

max_digit = K.bit_length()

def bi(x,max_d=max_digit):
  b = bin(x)[2:]
  if len(b) < max_d:
    return '0'*(max_d-len(b))+b
  else:
    return b[-max_digit:]
  
def f(x):
    return sum(map(lambda a:a^x, A))

B = list(map(bi,A))

count = [0]*max_digit
ans=0
for j in range(max_digit):
  for i in range(N):
    if B[i][j]=='1':count[j]+=1
  if count[j]<N/2:
    if ans + 2**(max_digit-j-1) <= K:
      ans += 2**(max_digit-j-1)
    else:
      continue

print(f(ans))

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

int main() {
  int N;
  cin >> N;
  int n, r, q, sum;
  sum = 0;
  n = N;
  
  r = n % 100;
  q = (n - r)/100;
  sum = q;
  n = r;
  
  r = n % 10;
  q = (n - r)/10;
  sum = sum + q + r;
  
  cout << sum << endl;
}


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

double a, b, c, d, e, f;

int main(){
    double max = -1;
    double water = 0;
    double sugar = 0;
    cin >> a >> b >> c >> d >> e >> f;
    for(double i = 0; i < f / (a * 100); ++i)
    for(double j = 0; j < f / (b * 100); ++j)
    for(double k = 0; k < f / c; ++k)
    for(double l = 0; l < f / d; ++l){
        if(100*(a*i+b*j)+c*k+d*l > f) continue;
        double tmp = (double)(100 * (c*k+d*l) / (100*(a*i+b*j) + (c*k+d*l)));
        if(tmp > 100* e / (100+e)) continue;
        if(max < tmp){
            max = tmp;
            water = (a*i+b*j)*100;
            sugar = c*k+d*l;
            
        }
    }

    cout << water + sugar << " " <<  sugar << endl;

    return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <utility>
#define EPS 1e-10
using namespace std;
typedef long long ll;
struct Point{
	double x,y;
	Point(double x = 0.0,double y = 0.0): x(x),y(y) {}
	Point operator + (Point p){
		return Point(x + p.x,y + p.y);
	}
	Point operator - (Point p){
		return Point(x - p.x,y - p.y);
	}
	Point operator * (double lambda){
		return Point(x * lambda,y * lambda);
	}
	Point operator / (double lambda){
		return Point(x / lambda,y / lambda);
	}
	Point operator - (){
		return Point(-x,-y);
	}
	double norm(){
		return x * x + y * y;
	}
	double abs_(){
		return sqrt(norm());
	}
	bool operator == (const Point &p)const
	{
		return abs(x - p.x) < EPS && abs(y - p.y) < EPS;
	}
	bool operator < (const Point &p)const
	{
		if(abs(x - p.x) < EPS) return y < p.y;
		else return x < p.x;
	}
};
typedef Point Vector;
struct Segment{
	Point p1,p2;
	Segment(Point p1 = Point(),Point p2 = Point()): p1(p1),p2(p2) {}
};
typedef Segment Line;
struct Circle{
	Point c;
	double r;
	Circle(Point c = Point(),double r = 0.0): c(c),r(r) {}
};
typedef vector<Point> Polygon;
double dot(Vector a,Vector b){ return a.x * b.x + a.y * b.y; }
double det(Vector a,Vector b){ return a.x * b.y - a.y * b.x; }
Point p,q;
double D;
int main(){
	while(~scanf("%lf",&D) && D > 0.0){
		scanf("%lf%lf%lf%lf",&p.x,&p.y,&q.x,&q.y);
		Point O = Point();
		if(abs(det(q,O - p)) > EPS) puts("impossible");
		else{
			double dis = 0.0;
			if(dot(q,O - p) < -EPS) dis = 2 * 1.0 - p.abs_();
			else dis = p.abs_();
			if(dis > D - EPS) puts("impossible");
			else printf("%.10f\n",dis);
		}
	}
	return 0;
}



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

const int limit = 100010;
using edge = struct {
  int to;
  ll cost;
};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d) {
  depth[v] = d;
  for (auto &e : tree[v]) {
    if (e.to == p) continue;
    dfs(e.to, v, d + e.cost);
  }
}

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

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

  int q, k;
  cin >> q >> k;
  k--;

  dfs(k, -1, 0);
  for (int i = 0; i < q; ++i) {
    int x, y;
    cin >> x >> y;
    x--, y--;
    cout << depth[x] + depth[y] << endl;
  }

  return 0;
}


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

struct items
{
    int wt;
    int val;
};
long long solution(vector<items> a,int n,int W)
{
    long long dp[n+1][W+1];
    for(int w=0;w<=W;w++)
    {
        dp[1][w]=0;
    }
    dp[1][a[1].wt]=a[1].val;
    for(int i=2;i<=n;i++)
    {
        for(int w=0;w<=W;w++)
        {
            dp[i][w]=dp[i-1][w];
            if(a[i].wt>w)
            {
                continue;
            }
            dp[i][w]=max(dp[i][w],a[i].val+dp[i-1][w-a[i].wt]);
        }
    }
    return *max_element(dp[n],dp[n]+W+1);
}
int main()
{
   int n,w;
   cin>>n>>w;
   vector<items>a(n+1);
   for(int i=1;i<=n;i++)
   {
       cin>>a[i].wt>>a[i].val;
   }
   cout<<solution(a,n,w);

    return 0;
}


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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    int a, b, c;cin >> a >> b >> c;
    string ans = "Yes";
    if(a+b < c) ans = "No";
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <list>
#include <tuple>
#include <bitset>

using namespace std;

inline bool cheak(int x, int y, int xMax, int yMax){ return x >= 0 && y >= 0 && xMax > x && yMax > y; }
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
template<class T> inline T sqr(T x) { return x*x; }

typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef long long ll;
typedef unsigned long long ull;

#define For(i,a,b)	for(int (i) = (a);i < (b);(i)++)
#define rep(i,n)	For(i,0,n)
#define clr(a)		memset((a), 0 ,sizeof(a))
#define mclr(a)		memset((a), -1 ,sizeof(a))
#define all(a)		(a).begin(),(a).end()
#define sz(a)		(sizeof(a))
#define Fill(a,v)	fill((int*)a,(int*)(a+(sz(a)/sz(*(a)))),v)

const int dx[8] = { 1, 0, -1, 0, 1, 1, -1, -1 }, dy[8] = { 0, -1, 0, 1, -1, 1, -1, 1 };
const int mod = 1000000007;
const int INF = 1e9;

int main()
{
	ll n;
	cin >> n;

	int c = 0;

	while (n != 1){
		c++;
		if (n % 3)n = n / 3 + 1;
		else      n = n / 3;
	}

	cout << c << endl;

	return 0;
}

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

using ll=long long;

set<ll> pf(ll n) {
  set<ll> r;
  for(ll i=2; i*i<=n; i++) {
    if(n%i == 0)
      r.insert(n);
    while(n%i == 0)
      n /= i;
  }
  if(n != 1)
    r.insert(n);
  return r;
}

int main() {
  ll A,B;
  cin >> A >> B;
  ll g = __gcd(A,B);
  cout << pf(g).size()+1 << endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int k=sc.nextInt();
    int ans=0;
    while(n>0){
      n/=k;
      ans++;
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
using namespace std;

#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(ll (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define opf(i) cout<<fixed<<setprecision(10)<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define matC(name,fnum,snum); vector<vector<char>> name((fnum),vector<char>((snum),0));
#define debugP int debug_point; cin>>debug_point;
#define FI first
#define SE second
const ll MOD= 1e9 + 7;

//
void solve(long long N, std::vector<long long> v){
    sort(all(v));
    double tmp=v[0];
    repf(i,1,N){
        tmp+=(double)v[i];
        tmp/=2;
    }
    opf(tmp);
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> v(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&v[i]);
    }
    solve(N, std::move(v));
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        final int N = sc.nextInt();
        
        long count = 0;
        for (int i = 1; i <= N - 1; i++) {
            int div = (N - 1) / i;
            count += div;
        }
        
        System.out.println(count);
    }
}


Measured memory_bytes: 35640
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int N=sc.nextInt();
    int K=sc.nextInt();
    int DIGIT=0;
    int DIV=1;
    
    while(N>=DIV){
      DIV*=K;
      DIGIT++;
    }
    
    System.out.println(DIGIT);
  }
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()
#define INF ((int)(1e9))

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

int a[1000], b[1000], c[1000];
int dist[1000][1000];

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, m; cin >> n >> m;
	rep (i, m){
		cin >> a[i] >> b[i] >> c[i];
		--a[i], --b[i];
	} // end rep

	rep (i, n){
		rep (j, n){
			if (i == j){
				dist[i][j] = 0;
			}else{
				dist[i][j] = INF;
			} // end if
		} // end rep
	} // end rep

	rep (i, m){
		dist[a[i]][b[i]] = min(dist[a[i]][b[i]], c[i]);
		dist[b[i]][a[i]] = min(dist[b[i]][a[i]], c[i]);
	} // end rep

	rep (k, n){
		rep (i, n){
			rep (j, n){
				dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
			} // end rep
		} // end rep
	} // end rep

	int ans = m;
	rep (i, m){
		bool shortest = false;
		rep (j, n){
			if (dist[j][a[i]] + c[i] == dist[j][b[i]]){
				shortest |= true;
			} // end if
		} // end rep
		if (shortest == true){
			--ans;
		} // end if
	} // end rep

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

Measured memory_bytes: 640
#include <stdio.h>
 
int main(void) {
int cnt, a,b,tmp;
//cnt=0;
scanf("%d %d\n",&a,&b);
while((a!=0)||(b!=0)){
//cnt++;
if(a<b){
printf("%d %d\n", a,b);
}else{
printf("%d %d\n", b,a);
}
scanf("%d %d\n",&a,&b);
}
return 0;
}

Measured memory_bytes: 604
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int main(void) {

	string s;

	cin >> s;

	sort(s.begin(),s.begin()+3);

	if (s == "abc")cout << "Yes\n";
	else cout << "No\n";

	

	return 0;
}

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

const int mnx = 3e5 + 9;
const int mod = 1e9 + 7;

ll a, b, c;

int main() {

cin >> a >> b >> c;

if(a % 2 == 0 || b % 2 == 0 || c % 2 == 0){ cout << 0 << '\n'; }
else{ cout << min(a * b, min(b * c, a * c)); }

return 0;

}


Measured memory_bytes: 256
// doot diddly donger cuckerino Hahahahahah

#include <bits/stdc++.h>

using namespace std;

typedef long long LL;
typedef long double LD;
typedef unsigned int UINT;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
typedef pair<string, int> PSI;
typedef pair<LL, LL> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<PII> VPII;
typedef vector<PLL> VPLL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef tuple<int, int, int> TPL;
typedef priority_queue<int> pqueue;
typedef priority_queue<int, VI, greater<>> pdqueue;

#define sim template<class T
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<T>(0) x 1, debug&>::type operator<<(T i) {
sim > struct rge { T b, e; };
sim > rge<T> range(T i, T j) { return rge<T>{i, j}; }
sim > auto dud(T* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, T > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<T> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const T&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define UNIQUE(X) sort(ALL(X)); (X).erase(unique(ALL(X)),(X).end())
#define F first
#define S second
#define SZ(x)           (int)(x).size()
#define ALL(a)         std::begin(a), std::end(a)
#define Fill(n, x)      memset(n,x,sizeof(n))
#define IN_REP         int _t; cin >> _t ; while(_t--)
#define IOS            ios::sync_with_stdio(false);cin.tie(NULL)
#define FOR(i, a, b)    for(int i=(a);i<(b);i++)
#define REP(i, n)       FOR(i,0,n)
#define FORR(i, n)      for(int i=(n);i>=0;i--)
#define EPS (double) 1e-9
#define MOD (LL)(1000*1000*1000 + 7)
#define cerr2(x,y) cerr << (x) << " " << (y) << endl;
#define cout2(x,y) cout << (x) << " " << (y) << endl;
const LD PI = acos(-1);
sim>T gcd(T x, T y) {return (y==0)?x:gcd(y, x % y);}
sim>void mini(T &a, T b) { a = min(a, b); }
sim>void maxi(T &a, T b) { a = max(a, b); }
sim>inline void add(T &x, T y) {x += y;if (x >= MOD) x -= MOD;}
sim>inline void sub(T &x, T y) {x -= y;if (x < 0) x += MOD;}
sim>inline T mul(T a, T b) {LL x = (long long) a * b;x %= MOD;return x;}
sim>inline T power(T base, T exp) {T result = 1; while (exp) {if (exp & 1)result *= base;exp >>= 1;base *= base;}return result;}
sim>inline T power(T a, T b, T mod) {T res = 1;while (b > 0) {if (b & 1) { res = mul(res, a); }a = mul(a, a);b >>= 1;}return res%mod;}
sim>inline T modInverse(T n, T p) { return power(n, p - 2, p)%p; }
sim, typename U>string to_string(pair<T, U> p) {return "" + to_string(p.F) + " " + to_string(p.S) + "";}

int main(){
  int n = 5,k;
  VI a(n);
  REP(i,n) cin >> a[i];
  cin >> k;
  sort(ALL(a));
  cout << (abs(a[n-1] - a[0]) <= k ? "Yay!" :":(") << endl;
  return 0;
}


Measured memory_bytes: 256
def main():
    a,b,c = list(map(int, input().split()))
    k = int(input())
    
    for i in range (k):
        if b <= a:
            b = b*2
        elif c <= b:
            c = c*2
    
    if a < b and b < c:
        print("Yes")
    else:  
        print("No")
   
if __name__ == "__main__":
    main()

Measured memory_bytes: 9116
const MOD:i64 = 1_000_000_007;

fn mod_pow(a: i64, e:i64) ->i64{
    let mut ret = 1;
    if e ==0 {
        return 1;
    }
    ret = mod_pow(a * a % MOD, e / 2);
    if e % 2 == 1 {
        ret = ret * a % MOD;
    }
    ret
}

fn main() {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line);
    let mut it = line.split_whitespace();
    let mut n:i64 = it.next().unwrap().parse().unwrap();
    let mut k:i64 = it.next().unwrap().parse().unwrap();
    let mut add = vec![0i64; k as usize + 1];
    let mut ans = 0;
    for i in 1..=k {
        let count = k / i;
        let sum = add[i as usize];
        ans = (ans + mod_pow(count, n) * (i - sum)) % MOD;
        add[i as usize] = i - sum;
        let mut j = i;
        while j <= k {
            add[j as usize] += i-sum;
            j += i;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2852
def main():
    N = int(input())
    D = [list(map(int, input().split())) for _ in range(N)]
    for i in range(N - 2):
        if D[i][0] == D[i][1] and D[i + 1][0] == D[i + 1][1] and D[i + 2][0] == D[i + 2][1]:
            print('Yes')
            exit()
    print('No')


if __name__ == "__main__":
    main()

Measured memory_bytes: 9188
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  string T;
  cin >> T;
  int N = T.size();
  rep(i,N)
  {
    if(T[i]=='?')
    {
      T[i] = 'D';
    }
  }
  cout << T << endl;
  return 0;
}


Measured memory_bytes: 3720
#include <iostream>
#include <cmath>

int main() {
    int X; std::cin >> X;
    int money_remain;
    int n_500, n_5;

    n_500 = (int)std::ceil(X / 500);
    money_remain = X % 500;
    n_5 = (int)std::ceil(money_remain / 5);

    std::cout << n_500 * 1000 + n_5 * 5;
    return 0;
}

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

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define MOD  1000000007
#define INF  0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
typedef long long ll;

int main() {
    
    string A,B;
    cin >> A >> B;
    
    if(A.size() > B.size()) {
        cout << "GREATER" << endl;
    } else if(A.size() < B.size()) {
        cout << "LESS" << endl;
    } else {
        if(A > B) {
            cout << "GREATER" << endl;
        } else if(A < B) {
            cout << "LESS" << endl;
        } else {
            cout << "EQUAL" << endl;
        }
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <algorithm>
 
using namespace std;

int n, x[500000], y[500000]; pair<int, int> p1[500000], p2[500000];
 
int main()
{
    scanf("%d", &n);
     
    for(int i = 0; i < n; i++)
    {
        scanf("%d", &x[i]);
        scanf("%d", &y[i]);
    }
     
    for(int i = 0; i < n; i++)
    {
        p1[i] = make_pair(x[i], y[i]);
    }
     
    for(int i = 0; i < n; i++)
    {
        p2[i] = make_pair(y[i], x[i]);
    }
     
    sort(p1, p1 + n);
    sort(p2, p2 + n);
     
    int sqr_ans = 10000000;
     
    const int loops = 111;
     
    for(int i = 0; i < n - 1; i++)
    {
        int r = min(loops, n - i - 1);
         
        for(int j = 1; j <= r; j++)
        {
            int distance_ = (p1[i + j].first - p1[i].first) * (p1[i + j].first - p1[i].first) + (p1[i + j].second - p1[i].second) * (p1[i + j].second - p1[i].second);
         
            sqr_ans = min(distance_, sqr_ans);
        }
    }
     
    for(int i = 0; i < n - 1; i++)
    {
        int r = min(loops, n - i - 1);
         
        for(int j = 1; j <= r; j++)
        {
            int distance_ = (p2[i + j].first - p2[i].first) * (p2[i + j].first - p2[i].first) + (p2[i + j].second - p2[i].second) * (p2[i + j].second - p2[i].second);
         
            sqr_ans = min(distance_, sqr_ans);
        }
    }
     
    printf("%d\n", sqr_ans);
     
    return 0;
}

Measured memory_bytes: 14324
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);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; }

typedef long long ll;

using namespace std;


class UnionFind
{
public:
  UnionFind(int n)
  {
    parent=vector<int>(n,-1);
  }
  int root(int a)
  {
    if(parent[a]<0)return a;
    return parent[a]=root(parent[a]);
  }
  int size(int a)
  {
    return -parent[root(a)];
  }
  bool connect(int a,int b)
  {
    int A=root(a);
    int B=root(b);
    if(A==B)return false;
    if(size(A)>size(B))swap(A,B);
    parent[B]+=parent[A];
    parent[A]=B;
    return true;
  }
private:
  vector<int> parent;

};
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n,k,l;
  cin>>n>>k>>l;
  UnionFind uf1(n),uf2(n);
  rep(i,k)
  {
    int a,b;
    cin>>a>>b;
    a--;b--;
    uf1.connect(a, b);
  }
  rep(i,l)
  {
    int a,b;
    cin>>a>>b;
    a--;b--;
    uf2.connect(a, b);
  }
  unordered_map<ll,int>ma;
  rep(i,n)
  {
    ma[((ll)uf1.root(i)<<20)+uf2.root(i)]++;
  }
  rep(i,n)
  {
    cout<<ma[((ll)uf1.root(i)<<20)+uf2.root(i)]<<" ";
  }
  cout<<flush;
  return 0;

}


Measured memory_bytes: 9928
#include <bits/stdc++.h>
#define MOD 1000000007
#define ll long long int
#define db double
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define endl "\n"
#define mp make_pair
#define f first
#define s second
ll power(ll x, ll y){ ll ans = 1;x %= MOD;while(y){if(y&1)ans = (x * ans) % MOD;x = (x * x) % MOD;y >>= 1;}return ans;}
ll modInverse(ll a, ll m){ll m0 = m;ll y = 0, x = 1;if (m == 1) return 0;while (a > 1){ ll q = a / m;ll t = m;m = a % m,a = t;t = y;y = x - q * y;x = t;}if(x < 0) x += m0;return x;}
using namespace std;

#define no cout << "NO\n"
#define yes cout << "YES\n"

void solve() {
    int n;
    map<string, int> mp;
    
    cin >> n;
    for(int i = 0; i < n; i++) {
        string str;
        cin >> str;
        mp[str]++;
    }
    
    cout << "AC x " << mp["AC"] << endl;
    
    cout << "WA x " << mp["WA"] << endl;
    
    cout << "TLE x " << mp["TLE"] << endl;
    
    cout << "RE x " << mp["RE"] << endl;
}

int main() {
    fastio;
    solve();
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define LOOP(n) for (int _i = 0; _i < (n); _i++)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define FOR(i, r, n) for (int i = (r); i < (n); ++i)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

const int INF = 2100100100;
const int MOD = 1e9 + 7;

// 多次元 vector 生成
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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;
}

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    ll r, D, x;
    cin >> r >> D >> x;

    REP(i, 10) {
        x = r * x - D;
        cout << x << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

void eratosthenes(vector<bool> &isPrime) {
  int n = isPrime.size();
  REP(i, n) { isPrime[i] = true; }
  isPrime[0] = false;
  isPrime[1] = false;
  for (int i = 2; i < n; i++) {
    if (!isPrime[i])
      continue;
    for (int k = 2; i * k < n; k++) {
      isPrime[i * k] = false;
    }
  }
}

int main() {
  vector<bool> isPrime(100005);
  eratosthenes(isPrime);
  int x;
  cin >> x;
  for (int i = x; i < isPrime.size(); i++) {
    if (isPrime[i]) {
      cout << i << endl;
      return 0;
    }
  }
}


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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define CONCAT(x,y) (x).insert((x).end(),(y).begin(),(y).end())
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define FOR(i,a,b) for (int i=(int)(a);i<(int)(b);++i)
#define FORE(i,a,b) for (int i=(int)(a);i<=(int)(b);++i)
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)
#define REPE(i,n) FOR(i,0,n)

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<int> VEC;

int main() {
  int x1,y1,x2,y2;cin>>x1>>y1>>x2>>y2;
  VEC ans(4);
  int dx=x2-x1,dy=y2-y1;
  ans[0] = x2-dy;
  ans[1] = y2+dx;
  ans[2] = x1-dy;
  ans[3] = y1+dx;
  DUMP(ans);

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

const long long INF = 1e18;
//const ll mod = 1000000007;

int main() {
  int a, b;
  cin >> a >> b;
  string ans = "No";
  for(int i = 0; i <= 100; i++) {
    for(int j = 0; j <= 100; j++) {
      if(i+j==a and 4*i+2*j==b) ans = "Yes";
    }
  }
  cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3608
#include <math.h>
#include <stdio.h>

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>

//コンパイラ最適化
#pragma GCC optimize("Ofast")

/*

 */
//マクロ
// forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
// Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
// FORAは範囲for文(使いにくかったら消す)
#define REP(i, n) for (ll i = 0; i < ll(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= ll(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= ll(b); i--)
#define FORA(i, I) for (const auto &i : I)
// xにはvectorなどのコンテナ
#define ALL(x) x.begin(), x.end()
#define SIZE(x) ll(x.size())
#define SORT(x) sort(x.begin(), x.end())
//定数
#define INF 1000000000000  // 10^12:∞
#define MOD 1000000007     // 10^9+7:合同式の法
#define MAXR 100000        // 10^5:配列の最大のrange
//略記
#define PB push_back  //挿入
#define MP make_pair  // pairのコンストラクタ
#define F first       // pairの一つ目の要素
#define S second      // pairの二つ目の要素

typedef long long ll;
using namespace std;
int stringcount(string s, char c) { return count(s.cbegin(), s.cend(), c); }
int uppercount(string s) {
  int cnt = 0;
  REP(i, s.length()) {
    if (isupper(s[i])) cnt++;
  }
  return cnt;
}
int main() {
  string S;
  cin >> S;
  bool flg = false;
  if (S[0] == 'A' && stringcount(S.substr(2, S.length() - 3), 'C') == 1 &&
      uppercount(S) == 2) {
    flg = true;
  }
  if (flg)
    cout << "AC";
  else
    cout << "WA";
  return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define lli long long int
#define MOD 1000000007
#define KING 1000000002
#define queen 1000002
#define fi first
#define se second
#define se second
#define lsb(i) (i & -i)
#define nl cout<<'\n'
#define TEST cout<<"TEST",nl
#define all(a) a.begin(), a.end()
#define pr pair<lli,lli>
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define vi vector<lli>
#define vpi vector<pr> 
#define P pair<lli,pr>
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL)
#define NA(i,s,n) for(lli i=s;i<n;i++)
using namespace std;

void solve(){
    map<lli, vi> mpp;
    lli n,ans=0; cin>>n;
    vi a(n), p(n+1,0), neg(n+1,0);
    NA(I,0,n) cin>>a[I]; 
    for(lli i=n-1; i>=0; --i){
        if(a[i]+i<n-1)
            ans += (neg[a[i]+i]);
        if(i-a[i]>0) 
            neg[i-a[i]]++;
    }
    cout<<ans;
    return;
}

int main(){
    fastIO;
    lli t = 1; 
    // cin>>t;
    NA(i,0,t) solve();
    return 0;
}

Measured memory_bytes: 7924
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int N, M;
pii v[100010];
int dp[100010];

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    v[i] = {a, b};
  }
  sort(v, v+M, [&](pii p, pii q) {
    if (p.second != q.second) return p.second < q.second;
    return p.first < q.first;
  });

  int last = 0;
  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (i) dp[i] = dp[i-1];
    while (last < M && v[last].second == i) {
      last++;
    }
    if (last-1 >= 0 && dp[i] <= v[last-1].first) {
      dp[i] = i;
      ans++;
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1408
pub fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

pub fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

pub fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn f(v: &mut Vec<char>, dep: u8, n: u8) {
    if v.len() == n as usize {
        for i in 0..v.len() {
            print!("{}", v[i]);
        }
        println!("");
    } else {
        for i in 0..dep + 2 {
            v.push(('a' as u8 + i) as char);
            if i <= dep {
                f(v, dep, n);
            } else {
                f(v, dep + 1, n);
            }
            v.pop();
        }
    }
}

fn main() {
    let n: u8 = read();

    let mut v: Vec<char> = vec!['a'];

    f(&mut v, 0, n);
}


Measured memory_bytes: 5500
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

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

    int BcntA = 0, Bcnt = 0, cntA = 0, ans = 0;
    rep(i, n) {
        string s;
        cin >> s;
        int m = s.size();

        if(s[0] == 'B' && s[m-1] == 'A') {
            BcntA++;
        }
        else if(s[0] == 'B') {
            Bcnt++;
        }
        else if(s[m-1] == 'A') {
            cntA++;
        }

        rep(j, m-1) {
            if(s[j] == 'A' && s[j+1] == 'B') {
                ans++;
            }
        }
    }

    if(BcntA == 0) {
        ans += min(Bcnt, cntA);
        cout << ans << endl;
        return 0;
    }
    
    ans += BcntA - 1;

    if(Bcnt >= 1) {
        ans++;
        Bcnt--;
    }

    if(cntA >= 1) {
        ans++;
        cntA--;
    }

    ans += min(Bcnt, cntA);
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
// 17.07.2017


# include <iostream>
# include <vector>
# include <queue>
# include <algorithm>


using namespace std;

# define lint long long int

//# define __TRR__

struct E
{
   int info;
   E * next;
   E (int pinfo=0, E * pnext=NULL) { info = pinfo, next = pnext; }
};

struct List
{
   E * first;
   List () { first = NULL; }
   void Add (int x) { first = new E (x, first); }
};

const int N = 100100;

int a [N], b [N], col [N], n, k, m, aa, bb, kf, ks;
bool ok;
List e [N];
queue <int> qf, qs;

int main ()
{
# ifdef __TRR__
   freopen ("D.TXT", "r", stdin);
   freopen ("D.OUT", "w", stdout);
# endif

   cin >> n;

   for ( int i = 1; i < n; i++ )
   {
      cin >> aa >> bb;
      e [aa].Add (bb);
      e [bb].Add (aa);
   }

   col [1] = 1, col [n] = 2;
   kf++, ks++;
   qf.push (1); qs.push (n);
   for ( ; ; )
   {
      bool okf = false;
      int k1 = 0;
      for ( ; ! qf.empty (); k1++ )
      {
         a [k1] = qf.front ();
         qf.pop ();
      }

      for ( int i=0; i < k1; i++ )
         for ( E * p = e [a [i]].first; p != NULL; p = p->next )
            if ( col [p->info] == 0 )
            {
               okf = true;
               qf.push (p->info);
               col [p->info] = 1;
               kf++;
            }
/*
      if ( ! ok )
         break;
*/
      int k2 = 0;
      bool oks = false;
      for ( ; ! qs.empty (); k2++ )
      {
         b [k2] = qs.front ();
         qs.pop ();
      }

      for ( int i=0; i < k2; i++ )
         for ( E * p = e [b [i]].first; p != NULL; p = p->next )
            if ( col [p->info] == 0 )
            {
               ok = true;
               qs.push (p->info);
               col [p->info] = 2;
               ks++;
            }
/*
      if ( ok )
         break;
*/
      if ( ! okf && ! oks )
         break;
   }

   if ( kf > ks )
      cout << "Fennec";
   else
      cout << "Snuke";

   return 0;
}


Measured memory_bytes: 7680