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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 62;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int n; cin >> n;
  int count = 0;
  int ans = 1;
  for(int i = 1; i <= n; ++i) {
    int c = 0;
    int x = i;
    while(x%2==0) {
      ++c;
      x/=2;
    }
    if(chmax(count, c)) ans = i;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3552
/*input
4 10
1 2 3 4
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

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

ll a[maxn];
ll b[maxn];
int main()
{
	IOS;
	ll n,x;
	cin>>n>>x;
	REP(i,n) cin>>a[i];
	REP(i,n) b[i]=a[i];

	ll ans=INF64;
	REP(i,n){
		ll cur=0;
		REP(i,n) cur+=b[i];
		ans=min(ans,cur+x*i);

		REP(j,n) b[j]=min(b[j],a[(j+i+1)%n]);
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define vi vector<int>
#define vvi vector<vector<int>>
#define pb push_back
#define pii pair<ll,ll>
#define ll long long
#define tii tuple<ll,ll,ll>
#define all(v) (v).begin(),(v).end()
#define deb(x) cout << #x << "=" << x << endl;
#define ull unsigned long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(nullptr);
#define ld long double
#define mod 1000000007
#define PI 3.141592653589793238
#define phi 1.638
#define eps 1e-9
#define endl "\n"
using namespace std;
using namespace __gnu_pbds;
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;   


int main() {
    fastio
    int x;
    cin>>x;
    if(x == 0) {
        cout<<1<<endl;
    }
    else  {
        cout<<0<<endl;
    }
}

Measured memory_bytes: 3632
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF 0x6fffffff
#define INFL 0x6fffffffffffffffLL

int main() {
	ll		a,b,c,h,i,j,k,l,m,n,p,x,y;
	ll		ans = 0;
	string	s;
	cin >> n;

	map<string , map<int , int>> pp;

	for(i=1;i<=n;i++) {
		cin >> s >> p;
		pp[s][p] = i;
	}
	for(auto d:pp) {
		map<int , int> qq = d.second;
		stack<int> st;
		for(auto dd:qq) st.push(dd.second);
		while(!st.empty()) {
			cout << st.top() << endl;
			st.pop();
		}
	}
	return 0;
}


Measured memory_bytes: 3616
#include <iostream>
#include <algorithm>
using namespace std;
int N, W, value[110], weight[110], dp[110][10100];

int main() {
	cin >> N >> W;
	for (int i = 0; i < N; i++) cin >> value[i] >> weight[i];
	for (int w = 0; w <= W; w++) dp[0][w] = 0;
	for (int i = 0; i < N; i++) {
		for (int w = 0; w <= W; w++) {
			if (weight[i] <= w) dp[i + 1][w] = max(dp[i][w - weight[i]] + value[i], dp[i][w]);
			else dp[i + 1][w] = dp[i][w];
		}
	}
	cout << dp[N][W] << endl;
	return 0;
}



Measured memory_bytes: 7076
a=[]
n=int(input())
for i in range(10):
        a.append(-1)
while(n!=0):
    n-=1
    b=[]
    c=[]
    a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7],a[8],a[9]=map(int,input().split())
    for i in range(10):
        b.append(-1)
        c.append(-1)
    j=1
    k=0
    lenb=0
    lenc=0
    b[0]=a[0]
    for i in range(1,10):
        if(a[i]>b[j-1]):
            b[j]=a[i]
            j+=1
        else:
            if(k==0):
                c[0]=a[i]
                k+=1
            elif(a[i]>c[k-1]):
                c[k]=a[i]
                k+=1
    for i in range(10):
        if(b[i]!=-1):
            lenb+=1
        if(c[i]!=-1):
            lenc+=1
    if(len(a)==(lenb+lenc)):
        print("YES")
    else:
        print("NO")

Measured memory_bytes: 7672
#include <iostream>

int main(int argc, char const *argv[]) {
  int house[4][3][10] = {};
  int n;
  std::cin >> n;
  for(int i=0;i<n;i++){
    int block,floar,r,v;
    std::cin >> block >> floar >> r >> v;
    if(v > 0){
      house[block-1][floar-1][r-1] += v;
      if(house[block-1][floar-1][r-1] > 10) house[block-1][floar-1][r-1] = 10;
    }else{
      house[block-1][floar-1][r-1] += v;
      if(house[block-1][floar-1][r-1] < 0)  house[block-1][floar-1][r-1] = 0;
    }
  }

  for(int i=0;i<4;i++){
    for(int j=0;j<3;j++){
      for(int k=0;k<10;k++){
        std::cout << " " <<house[i][j][k];
      }
      std::cout << std::endl;
    }
    if(i!=3){
      std::cout << "####################" << std::endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3108
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include<set>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <typeinfo>
#include <utility> 
#define all(x) (x).begin(),(x).end()
#define rep(i,m,n) for(int i = m;i < n;++i)
using namespace std;
using ll = long long;
using R = double;
const ll inf = 1LL << 50;
const ll MOD = 1e9 + 7;




int main() {
	ll n, m;
	cin >> n >> m;
	vector<ll>x(n);
	vector<ll>y(m);

	rep(i, 0, n) {
		cin >> x[i];
	}
	rep(i, 0, m) {
		cin >> y[i];
	}
	
	ll h = 0;
	ll w = 0;
	for (ll k = 1; k <= n; k++) {
		h += (2 * k - n - 1)*x[k - 1];
	}
	for (ll k = 1; k <= m; k++) {
		w += (2 * k - m - 1)*y[k - 1];
	}
	h %= MOD;
	w %= MOD;
	cout << (h * w) % MOD << endl;
	
	
	return 0;
}

Measured memory_bytes: 1920
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC073A
{
    class Program
    {
        static void Main(string[] args)
        {

            String n;

            n = Console.ReadLine();

            if (n[0] == '9'   ||  n[1] == '9')
               Console.WriteLine("Yes");
            else
               Console.WriteLine("No");

            Console.ReadKey();
        }
    }
}

Measured memory_bytes: 13140
# coding:utf-8

import sys


input = sys.stdin.readline
INF = float('inf')
MOD = 10 ** 9 + 7


def inpl(): return list(map(int, input().split()))


N, T = inpl()
A = inpl()
min_cost = INF
max_diff = 0
cnt = 0
for i in range(N):
    diff = A[i] - min_cost
    if max_diff <= diff:
        if max_diff == diff:
            cnt += 1
        else:
            cnt = 0
            max_diff = diff
    min_cost = min(min_cost, A[i])

print(1 + cnt)


Measured memory_bytes: 14756
def i1str():
    return input()


def istrs(n=None):
    if n is None:
        return input().split()
    a = []
    for _ in range(n):
        a.append(istrs())
    return a


def i1num():
    return int(input())


def inums(n=None):
    if n is None:
        return list(map(int, input().split()))
    a = []
    for _ in range(n):
        a.append(inums())
    return a


def ostrs(l, sp=" "):
    print(sp.join(l))


def onums(l, sp=" "):
    print(sp.join(map(str, l)))


def solve(n, aii):
    dp = [[0 for _ in range(n+1)] for _ in range(n+1)]

    for x in range(n+1):
        for y in range(n+1-x):
            if x == y == 0:
                continue
            ai, i = aii[n-x-y]
            dp[x][y] = max(dp[x-1][y] + ai * (i-x+1) if x > 0 else 0,
                           dp[x][y-1] + ai * (n-y-i) if y > 0 else 0)

    res = 0
    for x in range(n+1):
        if dp[x][n-x] > res:
            res = dp[x][n-x]
    return res


if __name__ == "__main__":
    n = i1num()
    a = inums()
    aii = sorted((a[i], i)for i in range(n))
    print(solve(n, aii))


Measured memory_bytes: 125804
n,k,q = map(int,input().split())
a = [0 for i in range(n)]
for i in range(q):
    aa = int(input()) - 1
    a[aa] = a[aa] + 1
for i in a:
    if k - q + i > 0:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 4680
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>

//#include<bits/stdc++.h>


using namespace std;


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

    vector<long long int>p(n);
    map<long long int, int>f;

    for (int i = 0; i < n; i++) {
        cin >> p[i];
        f[p[i]]++;
    }
    double ans = 0;
    long long int d = 0,s=0;
    int g = 0;
    sort(p.rbegin(), p.rend());
    for (int i = 0; i < a; i++) {
        g++;
        ans += p[i];
     //   d *= f[p[i]];
        f[p[i]]--;
    }
    g = 0;
    cout << setprecision(20);
    cout << ans / a << endl;
    for (int i = 0; i < n; i++) {
        if (p[i] == p[a - 1]) {
            d++;
            if (i < a)g++;
        }
    }

    int v = b;
    
    long long int N[55][55] = {};
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= i; j++) {
            if (j == 0 || i == j)N[i][j] = 1;
            else {
                N[i][j] = N[i-1][j-1] + N[i - 1][j];
            }
        }
    }
    if (p[0] == p[a - 1]) {
        for (int i = a; i <= min(b,d); i++) {
            s += N[d][i];
        }
    }
    else {
        s += N[d][g];
    }


    cout << s << endl;

    return 0;

}

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

typedef complex<double> P;
struct Line{
  P a,b;
  Line(P aa,P bb){a=aa,b=bb;};
};
const double eps=1e-9;

double dot (P a, P b) { return real(conj(a) * b); }
double cross (P a, P b) { return imag(conj(a) * b); }

int ccw (P a, P b, P c) {
  b -= a; c -= a;
  if (cross(b, c) > eps) return 1;   // counter clockwise
  if (cross(b, c) < -eps) return -1; // clockwise
  if (dot(b, c) < 0) return 2;       // c--a--b on line
  if (norm(b) < norm(c)) return -2;  // a--b--c on line
  return 0;                          // a--c--b on line
}

bool isis_ss(Line s, Line t) {
  return ccw(s.a, s.b, t.a) * ccw(s.a, s.b, t.b) <= 0 &&
         ccw(t.a, t.b, s.a) * ccw(t.a, t.b, s.b) <= 0;
}

int main(){
  int n;
  while(cin>>n,n){
  vector<double> x(n),y(n),r(n);
  for(int i=0;i<n;i++) cin>>x[i]>>y[i]>>r[i];
  const double INF=1e18;
  vector<double> dp1(n+1,INF); //between dp[0]=chuusin dp[i]=i,i-1 dp[n]=chunsin
  vector<double> dp2(n+1,INF);//
  vector<P> p1(n+1);
  vector<P> p2(n+1);
  for(int i=0;i<=n;i++){
    if(i==0){
      p1[i]=P(x[i],y[i]);
      p2[i]=P(x[i],y[i]);
    }
    else if(i==n){
      p1[i]=P(x[i-1],y[i-1]);
      p2[i]=P(x[i-1],y[i-1]);
    }
    else{
      //between i, i-1
      P pre=P(x[i-1],y[i-1]);
      P now=P(x[i],y[i]);
      double pi=acos(-1);
      double d=abs(now-pre);
      double s=(r[i]+r[i-1]+d)/2;
      double SIZE=sqrt(s*(s-r[i])*(s-r[i-1])*(s-d));
      double dd=SIZE*2/d;
      P center=pre+(now-pre)*(sqrt(r[i-1]*r[i-1]-dd*dd))/d;
      P vec=(pre-now)*P(cos(pi/2),sin(pi/2));      
      vec/=abs(vec);
      
            p1[i]=center+(dd+1e-6)*vec;
	    p2[i]=center-(dd+1e-6)*vec;

    }

  }

  
  auto okLine=[p1,p2](Line l,int j,int i){
    bool isok=true;
    for(int k=j+1;k<i;k++){
      isok&=(isis_ss(l,Line(p1[k],p2[k])));
    }
    return isok;
  };
	       
  dp1[0]=0;
  dp2[0]=0;
  for(int i=1;i<=n;i++){
    //renew dp1[i] and dp2[i]
    for(int j=0;j<i;j++){
      Line l1=Line(p1[j],p1[i]);
      Line l2=Line(p2[j],p1[i]);

      if(okLine(l1,j,i)){
	dp1[i]=min(dp1[i],dp1[j]+abs(p1[j]-p1[i]));
      }
      if(okLine(l2,j,i)){
	dp1[i]=min(dp1[i],dp2[j]+abs(p2[j]-p1[i]));
      }
      l1=Line(p1[j],p2[i]);
      l2=Line(p2[j],p2[i]);
      if(okLine(l1,j,i)){
	dp2[i]=min(dp2[i],dp1[j]+abs(p1[j]-p2[i]));
      }
      if(okLine(l2,j,i)){
	dp2[i]=min(dp2[i],dp2[j]+abs(p2[j]-p2[i]));
      }
    }
  }
  cout<<setprecision(10)<<fixed;
  cout<<dp1[n]<<endl;

  }
  return 0;
}

Measured memory_bytes: 3312
#include<stdio.h>

using namespace std;
int main(){
  int a,b,c;
  scanf("%d%d%d", &a, &b, &c);
  int count=0;
  while(a%2==0 && b%2==0 && c%2==0 && count < 10000000){
    int na,nb,nc;
    na = b/2+c/2;
    nb = a/2+c/2;
    nc = a/2+b/2;
    a = na;
    b = nb;
    c = nc;
    count++;
  }
  if(count >= 10000000){
    printf("-1\n");
  }else{
    printf("%d\n", count);
  }
}


Measured memory_bytes: 128
from itertools import accumulate as acc
from bisect import bisect_left as bl

def ans(n):
    tmp=0
    for i in range(N):
        tmp+=abs(a[i]-a[n-1])
    return tmp


N=int(input())
a=list(acc(map(int,input().split())))

ans=a[-1]
p=0
q=2
for j in range(1,N-2):
    q=max(q,j+1)
    while p<j-1 and abs(a[j]-a[p]*2)>abs(a[j]-a[p+1]*2):
        p+=1
    while q<N-2 and abs(a[j]+a[N-1]-a[q]*2)>abs(a[j]+a[N-1]-a[q+1]*2):
        q+=1

    x=[ a[p], a[j]-a[p], a[q]-a[j], a[N-1]-a[q] ]
    ans=min(ans, max(x)-min(x))

print(ans)

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

signed main () {
	int n;
	cin >> n;
	vector < int > p(n);
	vector < pair < int, int > > a(n);
	for (int i = 0; i < n; ++i) {
		cin >> p[i];
		a[i] = make_pair(p[i], i);
	}
	sort(a.rbegin(), a.rend());
	int64_t ans = 0;
	set < int > pos;
	for (int j = 0; j < n; ++j) {
		int i = a[j].second;
		int l1 = -1, l2 = -1, r1 = n, r2 = n;
		pos.insert(i);
		auto it = pos.find(i);
		if (it != prev(pos.end())) {
			r1 = *next(it);
			if (next(it) != prev(pos.end())) 
				r2 = *next(next(it));
		}
		if (it != pos.begin()) {
			l1 = *prev(it);
			if (prev(it) != pos.begin())
				l2 = *prev(prev(it));
		}
		ans += int64_t(p[i]) * (int64_t(r2 - r1) * int64_t(i - l1) + int64_t(l1 - l2) * int64_t(r1 - i));
	}
	cout << ans << '\n';
}


Measured memory_bytes: 6144
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define pw(b,p)         pow(b,p) + 0.1
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void c_p_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

int32_t main()
{
	c_p_c();
	int n; cin >> n;
	mk(arr, n, int);
	mii cnt;

	for (int i = 0; i < n; ++i)
	{
		cin >> arr[i];

		cnt[arr[i]]++;
	}

	int tot = 0;

	for (auto el : cnt)
		tot += (el.ss * (el.ss - 1)) / 2;

	for (int i = 0; i < n; ++i)
	{
		int a = cnt[arr[i]];
		int ans = tot;
		ans -= (a * (a - 1)) / 2;
		a--;
		ans += (a * (a - 1)) / 2;

		cout << ans << '\n';
	}
	return 0;
}

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

public class Main {
	private static final byte MASK_RIGHT = 0x0F;
	private static int[][] paper = new int[10][10];

	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 128);
		String sLine;
		while ((sLine = reader.readLine()) != null) {
			droppingInk(sLine.charAt(0) & MASK_RIGHT, sLine.charAt(2) & MASK_RIGHT, sLine.charAt(4) & MASK_RIGHT);
		}
		calcResult();
	}

	private static void droppingInk(int x, int y, int size) {
		staining(x, y - 1);
		staining(x - 1, y);
		staining(x, y);
		staining(x + 1, y);
		staining(x, y + 1);
		if (size == 1) {
			return;
		}

		staining(x - 1, y - 1);
		staining(x + 1, y - 1);
		staining(x - 1, y + 1);
		staining(x + 1, y + 1);
		if (size == 2) {
			return;
		}

		staining(x, y - 2);
		staining(x - 2, y);
		staining(x + 2, y);
		staining(x, y + 2);
	}

	private static void staining(int x, int y) {
		if (x >= 0 && x < 10 && y >= 0 && y < 10) {
			paper[x][y]++;
		}
	}

	private static void calcResult() {
		int white = 0;
		int maxnoud = 0;
		for (int[] row : paper) {
			for (int colum : row) {
				if (colum == 0) {
					white++;
				} else if (colum > maxnoud) {
					maxnoud = colum;
				}
			}
		}
		System.out.println(white);
		System.out.println(maxnoud);
	}
}

Measured memory_bytes: 16864
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

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

    int H, W, N;
    cin >> H >> W >> N;
    int count = 0;
    int hw[H][W];
    for (int i = 1; i <= N; i++) {
        int a;
        cin >> a;
        for (int j = count; j < count + a; j++) {
            hw[j/W][j%W] = i;
        }
        count += a;
    }

    for (int i = 0; i < H; i++) {
        if (i % 2 == 0) {
            for (int j = 0; j < W; j++) {
                cout << hw[i][j] << " ";
            }
            cout << "\n";
        } else {
            reverse(hw[i], hw[i]+W);
            for (int j = 0; j < W; j++) {
                cout << hw[i][j] << " ";
            }
            cout << "\n";
        }
    }

    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define INF INT_MAX/3

int main(){
    int H,W;cin >> H >> W;
    vector<vector<int> > table(10);
    for(int i = 0; i < 10; i++){
        table[i].resize(10);
        for(int j = 0 ;j < 10 ; j++){
            cin >> table[i][j];
        }
    }
    for(int k = 0 ; k < 10 ; k++){
        for(int i = 0 ; i < 10 ; i++){
            for(int j = 0 ; j < 10 ; j++){
                table[i][j] = min(table[i][j],table[k][j]+table[i][k]);
            }
        }
    }

    int res = 0;
    for(int i = 0; i < H ; i++){
        for(int j = 0; j < W ; j++){
            int a;
            cin >> a;
            if(a == -1 || a == 1)continue;
            res += table[a][1];
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	long long int A, B, C;
	scanf("%lld%lld%lld", &A, &B, &C);
	if(A == B && B == C && A % 2 == 0 && B % 2 == 0 && C % 2 == 0){
		printf("-1\n");
		return 0;
	}
	long long int sum = A + B + C, ans = 0;
	while(A % 2 == 0 && B % 2 == 0 && C % 2 == 0){
		A = (sum - A) / 2;
		B = (sum - B) / 2;
		C = (sum - C) / 2;
		ans++;
	}
	printf("%lld\n", ans);
	return 0;
}

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

#define ll long long
#define ull unsigned long long

bool isPalindrome(string s) {
    string t(s.rbegin(), s.rend());
    return s == t;
}

int main(void) {
    ll N;
    cin >> N;
    ll *res = new ll[N];
    for(ll i = 1;i < N;i++) {
        ll temp;
        cin >> temp;
        res[temp - 1] += 1;
    }
    for(ll i = 0;i < N;i++) {
        cout << res[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 5152
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>

using namespace std;

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

const ll INF = 1LL << 60;

int main() {
    int N, K;
    cin >> N >> K;
    vector<Pll> sushi(N); // {d, t}
    for(int i=0;i<N;++i){
        cin >> sushi[i].second >> sushi[i].first;
    }
    sort(sushi.rbegin(), sushi.rend());

    vector<ll> d_total(N+1, -INF);
    priority_queue<Pll, vector<Pll>, greater<Pll>> t_duplicate;
    vector<int> t_eaten(N+1, 0);
    ll d_total_tmp = 0LL;
    int bonus_count = 0;
    for(int i=0;i<K;++i){
        if(!t_eaten[sushi[i].second]) {
            ++bonus_count;
        } else {
            t_duplicate.push(sushi[i]);
        }
        ++t_eaten[sushi[i].second];
        d_total_tmp += sushi[i].first;
    }
    d_total[bonus_count] = d_total_tmp;

    for(int i=K;i<N&&!t_duplicate.empty();++i) {
        if(!t_eaten[sushi[i].second]) {
            ++bonus_count;
            ++t_eaten[sushi[i].second] = 1;
            d_total[bonus_count] = d_total[bonus_count-1] + sushi[i].first - t_duplicate.top().first;
            t_duplicate.pop();
        }
    }

    ll ans = 0LL;
    for(ll i=1;i<=N;++i){
        ans = max(ans, d_total[i] + i*i);
    }

    cout << ans << endl;
    
}

Measured memory_bytes: 4088
N, W = map(int, input().split())
w = [0]*N
v = [0]*N

for i in range(N):
    w[i], v[i] = map(int, input().split())

dp = [[0]*(W+1) for i in range(N+1)]

for i in range(N):
    for j in range(W+1):
        if j >= w[i]:
            dp[i+1][j] = max(dp[i][j], dp[i][j-w[i]]+v[i])
        else:
            dp[i+1][j] = dp[i][j]


print(dp[N][W])

Measured memory_bytes: 120300
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll N;
unordered_set<ll> v;
int f(ll k) {
	if (k < 2) return 0;
	if (!v.insert(k).second) return 0;
	ll n = N;
	while (n >= k) {
		if (n % k == 0) n /= k;
		else n %= k;
	}
	return n == 1 ? 1 : 0;
}
int main() {
	cin >> N;
	ll r = 0;
	for (ll n = N-1; n <= N; ++ n) {
		r += f(n);
		for (ll i = 2; i*i <= n; ++ i) if (n % i == 0) {
			r += f(i);
			r += f(n/i);
		}
	}
	cout << r << endl;
}


Measured memory_bytes: 512
N = int(input())
P = [int(p) for p in input().split()]
Q = [int(q) for q in input().split()]

import itertools
All = []
for i in itertools.permutations(range(1, N+1), N):
  All.append(list(i))

print(abs(All.index(P) - All.index(Q)))

Measured memory_bytes: 10228
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    REP(i,n) cin >> h[i];
    sort(ALL(h));
    int ans = 1 << 30;
    REP(i,n-k+1) ans = min(ans,h[k+i-1]-h[i]);

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 640
n = int(input())
s = [''.join(sorted(list(input()))) for x in range(n)]
ans = 0
s_dict = dict()
for v in s:
    if v in s_dict:
      ans += s_dict[v]
      s_dict[v] += 1
    else:
        s_dict[v] = 1
print(ans)

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

using namespace std;

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

  int n,k,x,y;cin>>n>>k>>x>>y;
  if(n<=k) cout<< x*n<<endl;
  else cout<< x*k+y*(n-k)<<endl;
}


Measured memory_bytes: 256
def e_roadwork(N, Q, Construction, D):
    from bisect import bisect_left
    from operator import itemgetter
    ans = [-1] * Q
    skip = [-1] * Q

    Construction.sort(key=itemgetter(2))

    for s, t, x in Construction:
        l = bisect_left(D, s - x)
        r = bisect_left(D, t - x)
        t = l
        while t < r:
            if skip[t] == -1:
                ans[t] = x  # lからr-1の時刻に出発した人は座標xの工事に引っかかる
                skip[t] = r  # lからr-1の時刻に出発した人はもう調べないようにする
                t += 1
            else:
                t = skip[t]  # tが指定する人はもう調べ終わっているので飛ばす
    return ' '.join(map(str, ans))
    # 参考: https://atcoder.jp/contests/abc128/submissions/5654623

N, Q = [int(i) for i in input().split()]
Construction = [tuple(int(i) for i in input().split()) for j in range(N)]
D = [int(input()) for _ in range(Q)]
print(e_roadwork(N, Q, Construction, D))

Measured memory_bytes: 69248
L = int(input())

N = L.bit_length()

edges = [[] for _ in range(N)]
for i in range(N - 1):
    edges[i].append((i + 1, 0))
    edges[i].append((i + 1, 2**i))

now = 2**(N - 1)

for i in range(N - 1)[:: -1]:
    cnt = 2**i
    if L - now >= cnt:
        edges[i].append((N - 1, now))
        now += cnt

M = sum(len(edges[i]) for i in range(N))
print(N, M)

for i in range(N):
    for to, cost in edges[i]:
        print(i + 1, to + 1, cost)

Measured memory_bytes: 3064
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

typedef struct top2{
  int a,b;
} val;

void max(val *x,val *a,val *b,int *array){
  int i,j,k,l;
  i=a->a;
  j=a->b;
  k=b->a;
  l=b->b;
  x->a=array[i]>=array[k]?i:k;
  if(i==k){
    x->b=array[j]>=array[l]?j:l;
    return;
  }
  if(array[i]<array[k]){
    k=i;
  }
  k=array[k]>=array[l]?k:l;
  x->b=array[j]>=array[k]?j:k;
  return;
}

void run(void){
  int n;
  scanf("%d",&n);
  int len=1<<n;
  int *a=(int *)malloc(sizeof(int)*len);
  int i;
  for(i=0;i<len;i++) scanf("%d",a+i);
  val *array=(val *)malloc(sizeof(val)*len);
  for(i=0;i<len;i++){
    array[i].a=a[0]>=a[i]?0:i;
    array[i].b=array[i].a^i;
  }
  for(i=1;i<len;i++){
    int j;
    for(j=0;(1<<j)<len;j++){
      if(((i>>j)&0x01)==1 && (i^(1<<j))!=0){
	max(array+i,array+i,array+(i^(1<<j)),a);
      }
    }
  }
  int max=0;
  for(i=1;i<len;i++){
    max=MAX(max,a[array[i].a]+a[array[i].b]);
    printf("%d\n",max);
  }
  return;
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 6016
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <iostream>
#include <locale>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

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

    vector<vector<int>> a(n, vector<int>(2));
    for (int i = 0; i < n; i++) {
        cin >> a[i][0];
        cin >> a[i][1];
    }
    int ans  = 0;
    int keep = 0;
    // for (int i = 0; i < n; i++) {
    //     for (int j = 0; j < n; j++) {
    //         if (a[j][0] < i + 1 && a[j][1] > i + 1) keep++;
    //         if (keep > i + 1) break;
    //     }
    //     ans  = max(ans, keep);
    //     keep = 0;
    // }

    vector<int> imosu(100002, 0);
    // fill(imosu.begin(), imosu.end(), 0);

    for (int i = 0; i < n; i++) {
        // if (a[i][0] - 2 >= 0)
        //     imosu[a[i][0] - 1]++;
        // else
        imosu[a[i][0]]++;
        // if (a[i][1] <= n)
        imosu[a[i][1] + 1]--;
    }

    for (int i = 1; i <= n + 1; i++) {
        imosu[i] = imosu[i - 1] + imosu[i];
    }

    // for (int test : imosu) cout << test << " ";

    for (int i = 0; i <= n + 1; i++) {
        if (i <= imosu[i] + 1) {
            ans = max(ans, i);
        }
    }
    cout << ans - 1 << endl;
}


Measured memory_bytes: 8680
from math import atan, degrees

a, b, x = map(int, (input().split()))

if x >= ((a ** 2) * b) / 2:
    theta = (2 * ((a ** 2) * b - x) / (a ** 3))
else:
    theta = ((a * (b ** 2)) / (2 * x))

print(degrees(atan(theta)))


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

using namespace std;

using ll = long long;

ll years(const ll x) {
    ll ans = 0;
    ll b = 100;
    
    while (b < x) {
        b += (b / 100LL);
        ++ans;
    }
    
    return ans;
}

int main() {
    ios_base::sync_with_stdio(0);
	cin.tie(0);
    
    ll X;
    cin >> X;
    
    cout << years(X) << endl;

    return 0;
}


Measured memory_bytes: 3636
#!/usr/bin/env python3

X, N = map(int, input().split())
P = list(map(int, input().split()))

P2 = []

for i in range(-100, 201):
    if i in P:
        continue
    P2.append(i)
sa = 10**9
ret = -1
for p in P2:
    if abs(X-p) < sa:
        sa = abs(X-p)
        ret = p

print(ret)


Measured memory_bytes: 9180
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mx=1e6;
int main()
{
int i,j,k,n,ans=0;
cin>>n;
int a[n];
for(i=0;i<n-1;i++)
    cin>>a[i];
ans+=a[0]+a[n-2];
for(i=0;i<n-2;i++)
    ans+=min(a[i],a[i+1]);
cout<<ans<<endl;

return 0;
}


Measured memory_bytes: 256
///
// File:  0011.cpp
// Author: ymiyamoto
//
// Created on Thu Nov  9 00:53:28 2017
//

#include <cstdint>
#include <iostream>
#include <vector>

using namespace std;

int32_t main()
{
  uint32_t w, n;
  cin >> w;
  cin >> n;

  vector<uint32_t> lines;
  for (uint32_t i = 1; i <= w; i++) {
    lines.push_back(i);
  }

  for (uint32_t i = 0; i < n; i++) {
    uint32_t a, b;
    char sep;
    cin >> a >> sep >> b;
    swap(lines[a - 1], lines[b - 1]);
  }

  for (auto iter = lines.begin(); iter < lines.end(); iter++) {
    cout << *iter << endl;
  }

  return 0;
}

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

int main() {
  string S;
  cin >> S;
  reverse(S.begin(),S.end());
  vector<string> dre={"maerd","remaerd","esare","resare"};
  bool ok = true;
  for(int i=0;i<S.size();){
    bool okk = false;
    for(int j=0;j<4;j++){
      string a=dre[j];
      if(S.substr(i, a.size())==a){
        i += a.size();
        okk =true;
      }
    }
    if(!okk){
      ok=false;
      break;
    }
  }
  if(ok) cout << "YES";
  else cout << "NO";
}


Measured memory_bytes: 512
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        long a = stdIn.nextLong();
        long b = stdIn.nextLong();
        long k = stdIn.nextLong();

        if (a >= k) {
            a -= k;
            k = 0;
        } else if (a > 0) {
            k -= a;
            a = 0;
        }

        if (b >= k) {
            b -= k;
            k = 0;
        } else if (b > 0) {
            k -= b;
            b = 0;
        }

        System.out.println(a + " " + b);
    }
}


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

int main(int argc, char *argv[])
{
    int a, l, cur, i;
    string str;
    bool flg;
    while (cin >> a >> l, a | l) {
        cur = 0;
        int res[20];
        flg = true;
        while (flg) {
            res[cur++] = a;
            str = to_string(a);
            for (i = str.size(); i < l; ++i)
                str += '0';
            sort(str.begin(), str.end());
            a = -stoi(str);
            reverse(str.begin(), str.end());
            a += stoi(str);
            for (i = 0; i < cur; ++i) {
                if (res[i] == a) {
                    flg = false;
                    break;
                }
            }
        }
        cout << i << ' ' << a << ' ' << cur - i << endl;
    }
    return 0;
}

Measured memory_bytes: 3204
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>  
#include <stdbool.h>   
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define PI 3.14159265358979323846;
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
/*
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r)
*/
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r)
#define TYPE long long
#define ll long long
#define MEMSET(a) memset(a,0,sizeof(a))
#define MEMSET_U(a) memset(a,-1,sizeof(a))
#define bool    _Bool
const int mod = (int)1e09 + 7;

//#define DEBUG1
//#define DEBUG2
//#define DEBUGF
#define DUMMY

int in(void) { int i; scanf("%d", &i); return i; }
long long llin(void) { long long i; scanf("%lld", &i); return i; }
double din(void) { double i; scanf("%lf", &i); return i; }
void chin(char s[]) { scanf("%s", s); }

void print(int a) { printf("%d\n", a); }
void llprint(long long a) { printf("%lld\n", a); }
void dprint(double a) { printf("%.10f\n", a); }
void print2(int a, int b) { printf("%d %d\n", a, b); }
int Max(int a, int b) { if (a > b) { return a; }return b; }
int Min(int a, int b) { if (a < b) { return a; }return b; }
long long llmax(long long a, long long b) { return a > b ? a : b; }
long long llmin(long long a, long long b) { return a < b ? a : b; }
double dmax(double a, double b) { return a > b ? a : b; }
double dmin(double a, double b) { return a < b ? a : b; }
//long long llmax(long long a, long long b) { return a > b ? a : b; }
//long long llmin(long long a, long long b) { return a < b ? a : b; }
//double dmax(double a, double b) { return a > b ? a : b; }
int cmp(const void *a, const void *b) { return *(TYPE *)a - *(TYPE *)b; }
int cmp_r(const void *a, const void *b) { return *(TYPE *)b - *(TYPE *)a; }
int char_cmp(const void *a, const void *b) { return strcmp((char *)a, (char *)b); }
int char_cmp_r(const void *a, const void *b) { return strcmp((char *)b, (char *)a); }
void swap(int *a, int *b) { int t = *a; *a = *b; *b = t; }



int main() {
	int N, M, X, Y;
	scanf("%d%d%d%d", &N, &M, &X, &Y);
	int *x = (int*)malloc(sizeof(int)*N);
	int *y = (int*)malloc(sizeof(int)*M);
	for (int i = 0; i < N; i++) {
		scanf("%d", &x[i]);
	}
	for (int i = 0; i < M; i++) {
		scanf("%d", &y[i]);
	}

	int xmax, ymin;
	qsort(x, N, sizeof(int), cmp_r);
	xmax = x[0];
	qsort(y, M, sizeof(int), cmp);
	ymin = y[0];

	bool jadge = false;

	//xmax<z && z<=ymin
	//xmax < X && ymin <= Y
	if (xmax + 1 <= ymin) {
		if (X <= xmax) {
			if (ymin <= Y) {
				jadge = true;
			}
		}
	}

	if (jadge) {
		puts("No War");
	}
	else {
		puts("War");
	}

#ifdef DEBUGF
	getch();
#endif
	return 0;
}


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

 
int main(){
  int n; cin >> n;
  vector<int> a(n);
  for(int i=0; i<n; i++){
    cin >> a[i];
  }
  int cnt=0;
  for(int j=0; j<n-2; ++j){
    if(((a[j]<=a[j+1]&&a[j+1]<=a[j+2])||
        (a[j]>=a[j+1]&&a[j+1]>=a[j+2]))&&
       !(a[j]==a[j+1]&&a[j+1]==a[j+2])){
      cnt++;
    }
  }

  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{  
int i,n,m;
for(i=1;;i++) 
  { 
     scanf("%d %d",&n,&m);
  	if(n==0&&m==0)break;
    if(n>m)printf("%d %d\n",m,n); 
	  else printf("%d %d\n",n,m); 
	   }  
	   return 0;
	   }


Measured memory_bytes: 2040
#include <bits/stdc++.h>
#define ll long long
using namespace std;
map<ll,ll> primeFac;
ll n,mod=1e9+7,arr[100000];

ll fp(ll base, ll exp)
{
    if (exp == 0)
        return 1;
    ll ans = fp(base, exp / 2);
    ans = (ans * ans) % mod;
    if (exp % 2 != 0)
        ans = (ans * base ) % mod;
    return ans;
}
void factors(ll n)
{
    ll cnt=0;
    while (n % 2 == 0)
    {
        n = n/2;
        cnt++;
    }
    if(primeFac[2]<cnt)
        primeFac[2]=cnt;



    for (int i = 3; i*i <= n; i = i + 2)
    {
        cnt=0;
        while (n % i == 0)
        {
            n = n/i;
            cnt++;
        }
        if(primeFac[i]<cnt)
            primeFac[i]=cnt;

    }
    if(n>2)
        if(primeFac[n]<1)
            primeFac[n]=1;
}



int main()
{
    cin>>n;
    for(int i=0; i<n; i++)
        cin>>arr[i],factors(arr[i]);
    ll lcm=1;
    for(auto x : primeFac)
        lcm*=fp(x.first,x.second),lcm%=mod;

    ll ans=0;
    for(int i=0; i<n; i++)
        ans += (lcm * fp(arr[i], mod - 2)) % mod,ans %= mod;

    cout << ans << endl;


    return 0;
}



Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

#include <climits>

#define DEBUG if(false)

using namespace std;

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i = 0; i < N; i++){
    cin >> A[i];
  }
  sort(A.begin(), A.end());
  cout << A[N-1] - A[0] << endl;
  return 0;
}


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

int main() {
  int N;
  cin >> N;
  int res = 1;
  set<int> se;
  se.insert(N);
  while (true) {
    if (N % 2 == 0) N /= 2;
    else N = N*3 + 1;
    ++res;
    if (se.count(N)) break;
    se.insert(N);
  }
  cout << res << endl;
}

Measured memory_bytes: 3600
#include"bits/stdc++.h"
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }

lint N;
lint arr_A[100000], arr_B[100000];
plint arr[100000];
int main() {
	cin.tie(0); ios_base::sync_with_stdio(false);
	cin >> N;
	lint sum = 0;
	REP(i, N) {
		cin >> arr_A[i] >> arr_B[i];
		arr[i] = plint(arr_A[i] + arr_B[i], i);
		sum -= arr_B[i];
	}
	sort(arr, arr + N);
	reverse(arr, arr + N);
	REP(i, (N + 1) / 2) {
		sum += arr[2 * i].first;
	}
	cout << sum;
}


Measured memory_bytes: 3328
import sys
from collections import deque, defaultdict
import copy
import bisect
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 9)
import math

N = int(input())
A = list(map(int, input().split()))
zeros = 0
minus = 0
B = []
for i in range(len(A)):
	if A[i] < 0:
		minus += 1
	elif A[i] == 0:
		zeros += 1
	B.append(abs(A[i]))


if zeros > 0:
	print(sum(B))
elif minus % 2 == 0:
	print(sum(B))
else:
	print(sum(B) - 2*min(B))

Measured memory_bytes: 65496
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e18;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
typedef pair<double,double> point;
const ll MAX = 200000;
constexpr ll nx[8] = {1,0,-1,0,1,-1,1,-1};
constexpr ll ny[8] = {0,1,0,-1,1,1,-1,-1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll h1,m1,h2,m2,k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    ll a = h1*60+m1,b = h2*60+m2;
    PRINT(b-a-k);
}


Measured memory_bytes: 3648
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kein Yukiyoshi
 */

#include "bits/stdc++.h"
#define int long long
#define rep(i, n)           for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b)        for (int i = (int)(a); i < (int)(b); i++)
#define FOR(i, a)           for (auto &i : a)
#define ALL(obj)            begin(obj), end(obj)
#define MAX(x)              *max_element(ALL(x))
#define MIN(x)              *min_element(ALL(x))
#define SUM(x)              accumulate(ALL(x), 0LL)
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))

using namespace std;
const int MOD    = (int)(1e9 + 7);
const int INF    = (int)(1e13 + 7);
const double EPS = 1e-14;
const double PI  = acos(-1);

int CEIL(int a, int b) { return (a >= 0 ? (a + (b - 1)) / b : (a - (b - 1)) / b); } //ceil() for int
int mod(int a, int b) { return a >= 0 ? a % b : a - (b * CEIL(a, b)); }             //always return positive num
int bpm(int a, int b) {                                                             //return x^y in order(log(y))
  int res = 1;
  for (a %= MOD; b; a = a * a % MOD, b >>= 1)
    if (b & 1) res = res * a % MOD;
  return res;
}

class ALphabet {
public:
  static void solve(istream &cin, ostream &cout) {
    char a;
    cin >> a;
    if (a >= 97) {
      cout << 'a' << endl;
    } else {
      cout << 'A' << endl;
    }
  }
};


signed main() {
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
  ALphabet solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,x,n) for(int i=x; i<(int)(n); i++)
#define rep_eq(i,x,n) for(int i=x; i<=(int)(n); i++)
using namespace std;

int main() {
  string s; cin >>s;
  int temp1,temp2;
  for (int i=0;i<(int)s.size();i++) {
    if (s[i]=='A') {
      temp1=i;
      break;
    }
  }
  for (int i=s.size()-1;0<=i;i--) {
    if (s[i]=='Z') {
      temp2=i;
      break;
    }
  }
  cout <<temp2-temp1+1 <<endl;
  return 0;
}


Measured memory_bytes: 640
#include <stdio.h>

int main (){
	// 3 4
	int A, B;
	// mnenampung postal code
	char str[255];
	// kita anggap semua postal code AWALNYA itu valid
	bool valid = true;
	
	scanf ("%d %d", &A, &B);
	scanf ("%s", str);
	
	// cek apakah di index A itu bukan -
	if (str[A] != '-'){
		// jika bukan, valid menjadi false
		valid = false;
	}
	for (int i = 0; str[i] != '\0'; i++){
		// cek index selain A
		if (i != A){ 
			// jika dia diluar rentang 0 sampai 9
			if (str[i] < '0' || str[i] > '9'){
				// valid menjadi false
				valid = false;
				// keluar dari loop
				break;
			}
		}
	}
	
	valid ? puts ("Yes") : puts ("No");
	
	return 0;
}

Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N,M;
    cin >> N >>M;
    long int A;
    priority_queue <int> p;
    for(int i=0;i<N;i++){
        cin >> A;
        p.push(A);
    }
    /* q.pop();//先頭を削除
    q.empty(); //空だったらtrue
    priority_queue ;//最も大きいものを素早く取り出せる
    pq.top();//最大要素を取り出す */
    int B;
    while(M>=1){
        B=p.top();
        p.pop();
        B = B/2;
        M--;
        p.push(B);
    }
    long long int sum = 0;
      for(int i=0;i<N;i++){
        sum += p.top();
        p.pop();
    }
    cout << sum <<endl;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
short dp[20][200][200][200];
int n, m;
char a[200][200];
int tmp[200];
int main() {
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= n; i++) scanf("%s", a[i] + 1);
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= n; j++)
            for (int k = 0; k <= 18; k++) dp[k][m + 1][i][j] = m;
    for (int i = m; i > 0; i--) {
        for (int j = 1; j <= n; j++) {
            if (a[j][i] == a[j][i + 1]) dp[0][i][j][j] = dp[0][i + 1][j][j];
            else dp[0][i][j][j] = i;
        }
        for (int l = 1; l <= n; l++)
            for (int r = l + 1; r <= n; r++) {
                if (a[r][i] != a[r - 1][i]) dp[0][i][l][r] = i - 1;
                else dp[0][i][l][r] = min(dp[0][i][l][r - 1], dp[0][i][r][r]);
            }
    }
    for (int v = 1; v <= 18; v++) {
        for (int i = 1; i <= m; i++) {
            for (int l = 1; l <= n; l++) {
                dp[v][i][l][l] = dp[v - 1][dp[v - 1][i][l][l] + 1][l][l];
                int now = l;
                for (int r = l + 1; r <= n; r++) {
                    while (now < r - 1 && min(dp[v - 1][i][l][now], dp[v - 1][i][now + 1][r]) <= min(dp[v - 1][i][l][now + 1], dp[v - 1][i][now + 2][r])) now++;
                    dp[v][i][l][r] = max(min(dp[v - 1][i][l][now], dp[v - 1][i][now + 1][r]), dp[v - 1][dp[v - 1][i][l][r] + 1][l][r]);
                }
            }
        }
    }
    for (int i = 0; i <= 18; i++) if (dp[i][1][1][n] == m) return cout << i << endl, 0;
    assert(0);
}

Measured memory_bytes: 297216
#B問題

#x匹　y本

x, y = map(int, input().split())
counter = 0
# iは鶴　jは亀
for i in range(0,x+1):
    j = x - i
    if (2*i + 4*j == y):
        counter += 1
        break
if counter >= 1:
    print("Yes")
else:
    print("No")

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

int main(void){
  int A,B,X,sum;
  cin >> A >> B >> X;
  
  sum = A+B;
  
  if(A>X){
    cout << "NO" << endl;
  }else if(sum>=X){
    cout << "YES" << endl;
  }else{
      cout << "NO" << endl;
  }
}
/*許してくれ*/

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


#define CI cin >>
#define CO cout <<
#define E << endl;

using namespace std;


int main(void) {
	int num = 0;
	vector<int>array;
	int temp = 0;

	CI num;

	for (int i = 0; i < num; ++i) {
		CI temp;
		array.push_back(temp);
	}
	
	for (int i = num - 1; i > 0; --i) {
		CO array[i] << " ";
	}

	CO array[0] E

}

Measured memory_bytes: 1216
from functools import reduce
from operator import add
X = int(input())
if X <= 105:
  if X<100:  print(0)
  else: print(1)
else:
  dp = [1] + [0]*X
  dp[100] = dp[101] = dp[102] = dp[103] = dp[104] = dp[105] = 1
  for i in range(106,X+1): dp[i] = min(reduce(add, [dp[i-(100+j)] for j in range(6)]),1)
  print(dp[-1])

Measured memory_bytes: 5092