akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
typedef long long int ll;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
    // clang-format on

#include <utility>
#include <queue>
#include <tuple>
using Edge = pair<ll, int>;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n, m, c;
    cin >> n >> m >> c;
    vector<vector<Edge>> G(n);
    REP(i, 0, m) {
        int a, b, d;
        cin >> a >> b >> d;
        a--;
        b--;
        G[a].emplace_back(d, b);
        G[b].emplace_back(d, a);
    }
    const ll inf = 1LL << 60;
    vector<ll> Cost(n, inf);
    {
        priority_queue<Edge, vector<Edge>, greater<Edge>> pq;
        pq.emplace(0LL, 0);
        while (pq.size()) {
            ll cost;
            int ver;
            tie(cost, ver) = pq.top();
            pq.pop();
            if (Cost[ver] < cost) continue;
            Cost[ver] = cost;
            for (auto &edge : G[ver]) {
                ll ncost;
                int nver;
                tie(ncost, nver) = edge;
                if (Cost[nver] > ncost + cost) {
                    Cost[nver] = ncost + cost;
                    pq.emplace(Cost[nver], nver);
                }
            }
        }
    }
    vector<ll> candidateX = Cost;
    sort(candidateX.begin(), candidateX.end());
    candidateX.erase(unique(candidateX.begin(), candidateX.end()), candidateX.end());

    vector<Edge> edges;
    ll sum = 0;
    REP(i, 0, n) {
        for (auto &e : G[i]) {
            int j = e.second, dist = e.first;
            if (i > j) continue;
            edges.emplace_back(max(Cost[i], Cost[j]), dist);
            sum += dist;
        }
    }
    sort(edges.begin(), edges.end());

    ll ans = inf;
    int indices = 0;
    for (ll X : candidateX) {
        while (indices < m && edges[indices].first <= X) {
            sum -= edges[indices++].second;
        }
        ans = min(ans, c * X + sum);
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 21312
#include <stdio.h>
#include <math.h>
typedef struct En{
	double x,y,r;
};
int main(){
	En a,b;
	double dist,r;
	int n;
	scanf("%d",&n);
	while(n--){
		scanf("%lf%lf%lf%lf%lf%lf",&a.x,&a.y,&a.r,&b.x,&b.y,&b.r);
		dist = (a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y);
		dist = sqrt(dist);
		//a.r = a.r*a.r;b.r = b.r*b.r;
		if(dist>a.r+b.r) printf("0\n");
		else if(a.r>b.r+dist) printf("2\n");
		else if(b.r>a.r+dist) printf("-2\n");
		else printf("1\n");
	}
	return 0;
}

Measured memory_bytes: 1048
#include<iostream>
#include<vector>
#include<utility>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,i,j;
    cin>>n;
    vector<int>arr(n);
    for(i=0;i<n;i++) cin>>arr[i];
    vector<pair<long long,long long> >dp(n);
    dp[n-1].first=arr[n-1];
    dp[n-1].second=-arr[n-1];
    for(i=n-2;i>=0;i--)
    {
        dp[i].first=arr[i];
        dp[i].second=-arr[i];
        for(j=i+1;j<n;j++)
        {
            long long f=dp[j].first;
            long long s=dp[j].second;
            dp[j].first=max(arr[i]+s,arr[j]+dp[j-1].second);
            dp[j].second=min(-arr[i]+f,-arr[j]+dp[j-1].first);
        }
    }
    cout<<dp[n-1].first<<endl;
}


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

int main(){
    int H, W;
    while(true){
        cin>>H>>W;
        if(H==0&&W==0){
            break;
        }
        else{
            rep(i, H){
                rep(j, W){
                    if(i==0||i==H-1||j==0||j==W-1){
                        cout<<"#";
                    }
                    else{
                        cout<<".";
                    }
                    
                }
                cout<<""<<endl;
            }
            cout<<""<<endl;
        }
    }
}


Measured memory_bytes: 3076
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
 ll n,s,k,cnt,a[200005],sum[200005],i,j;
int main()
{

    while(cin>>n)
    {
        memset(sum,0,sizeof(sum));
        memset(a,0,sizeof(a));
        s=0;
        cnt=0;
        for(i=1;i<=n;i++)
        {
            cin>>a[i];
            s+=a[i];
            sum[i]=s;
        }
        ll mn=1e10;
        for(i=1;i<=n-1;i++)
        {
            mn=min(mn,abs(sum[i]-(sum[n]-sum[i])));
        }
        cout<<mn<<endl;
        /*for(i=1;i<=n;i++)
        {
            sum[i]+=a[i]+sum[i-1];
        }*/

    }
    return 0;
}


Measured memory_bytes: 3456
// cities to vapori-
// corner cases // int vs ll // cin vs scanf // clear structures // statement // doublesz // math is your friend
#include <bits/stdc++.h>
#define pb push_back
#define fst first
#define snd second
#define sz(x) int(x.size())
#define fill(x,v) memset(x,v,sizeof(x))
#define REP(i,a,b) for(int i = int(a); i < int(b); ++i)
#define trace(x) cout << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
const int N = 2e5+20;

int pref[N],suf[N],lst[N],pos[N];

int main(){

	fastio;
	int n,k,c;
	cin >> n >> k >> c;
	string cad;
	cin >> cad;
	
	int rest = 0, now = -1;
	for(int i = 0; i < n; ++i){
		if(i) pref[i] = pref[i-1];
		lst[i] = now;
		if(cad[i] == 'o'){
			rest = c;
			pref[i]++;
			now = i;
			while(rest--){
				i++;
				lst[i] = now;
				pref[i] = pref[i-1];
			}
		}
	}
	for(int i = n-1; i >= 0; --i){
		suf[i] = suf[i+1];
		if(cad[i] == 'o'){
			rest = c;
			suf[i]++;
			while(rest--){
				i--;
				suf[i] = suf[i+1];
			}
		}
	}

	vector<int> ans;
	for(int i = 0; i < n; ++i){
		if(cad[i] == 'o'){
			int prv = lst[i];
			if(prv == -1){
				int tot = suf[i+1];
				if(tot < k) ans.pb(i+1);
			}else{
				int tot = pref[prv];
				int lim = max(prv+c+1,i+1);
				if(lim < n) tot += suf[lim];
				if(tot < k) ans.pb(i+1);
			}
		}
	}

	for(int x : ans) cout << x << endl;

	return 0;
}


Measured memory_bytes: 5004
#include<bits/stdc++.h>
using namespace std;
int ans;
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> A(N);
    for (auto &a : A) cin >> a;
    int count = 0;
    for (int i = 0; i < N; i++) {
        if (A[i-1] >= A[i]) count++;
        else {
            ans = max(ans, count);
            count = 0;
        }
    }
    ans = max(ans, count);
    printf("%d\n", ans);
    return 0;
}


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

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int dfs() {
    vi s;
    char c;
    while (cin >> c) {
        switch (c) {
        case '0':
        case '1':
        case '2':
        case '3':
        case '4':
        case '5':
        case '6':
        case '7':
        case '8':
        case '9':
        {
            string num;
            num += c;
            while (cin >> c, c != ']') {
                num += c;
            }
            return atoi(num.c_str()) / 2 + 1;
        }
        case '[':
            s.push_back(dfs());
            break;
        case ']':
            if (!s.empty()) {
                int count = 0;
                sort(ALL(s));
                REP(i, s.size() / 2 + 1) {
                    count += s[i];
                }
                return count;
            } else {
                return 0;
            }
        }
    }
}

int main() {
    int n;
    cin >> n;
    REP(i, n) {
        char c;
        cin >> c; // ignore '['
        cout << dfs() << endl;
    }
}

Measured memory_bytes: 1268
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 200


int main(){
	int a[N];
	long long dp[N];
	long long dp2[N];
	int n, m, k, xx;
	int x, y, z;
	long long s, ans;
	bool v = true;
	ans = 0;
	scanf("%d %d %d", &n,&m,&xx);
	k = (1 << (m-1));
	f(i, m){
		dp[i] = 0;
		dp2[i] = 0;
	}
	dp[0] = 1;
	f(i, n){
		f(j, k){
			x = j;
			f(ii, m-1){
				a[ii] = x % 2;
				x = x / 2;
			}
			v = true;
			f(ii, m - 2){
				if (a[ii] == 1 && a[ii + 1] == 1)v = false;
			}
			if (v){
				f(ii, m){
					v = true;
					if (ii > 0){
						if (a[ii - 1] == 1){
							v = false;
							dp2[ii - 1] += dp[ii];
							dp2[ii - 1] = dp2[ii - 1] % MOD;
						}
					}
					if (ii < m-1){
						if (a[ii] == 1){
							v = false;
							dp2[ii + 1] += dp[ii];
							dp2[ii + 1] = dp2[ii + 1] % MOD;
						}
					}
					if (v){
						dp2[ii] += dp[ii];
						dp2[ii] = dp2[ii] % MOD;
					}
				}
			}
		}
		f(j, m){
			dp[j] = dp2[j];
			dp2[j] = 0;
		}
	}

	printf("%lld\n", dp[xx-1]);


	return 0;
}

Measured memory_bytes: 128
import java.io.*;

public class Main {
	public static void main(String[] args) throws Exception{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] str;
		str = br.readLine().split(" ");
		int N = Integer.parseInt(str[0]);
		int W = Integer.parseInt(str[1]);
		long[][] items = new long[N][2];
		for(int i=0; i<N; i++) {
			str = br.readLine().split(" ");
			items[i][0] = Long.parseLong(str[0]);
			items[i][1] = Long.parseLong(str[1]);
		}
		long[] dp = new long[W+1];
		for(int i=0; i<N; i++) {
			long we = items[i][0];
			for(int j=(int)(W-we); j>=0; j--) {
				dp[(int)(j+we)] = Math.max(dp[(int)(j+we)], dp[j]+items[i][1]);
			}
		}

		System.out.println(dp[W]);
	}
}


Measured memory_bytes: 22484
#include <iostream>
#include <vector>
#include<list>
#include <algorithm>
#include <string>
#include <math.h>
#include<map>
#include <utility>
#include <iomanip>
#include<queue>
#include<set>
using namespace std;
#define REP(i,k,n) for(int i=k;i<n;i++)
 
#define INF 1844674407370955161
typedef long long int ll;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define MOD 1000000007


int main()
{

   int N;
   cin>>N;

   int A[N][61];

   REP(i,0,N){
       ll a;
       cin>>a;
       REP(j,0,61){
           A[i][j]=(a>>j)&1;
       }
   }
    ll ans=0;
    ll mx=1;
    REP(i,0,61){
        ll count=0;
        ll zero=0;
        ll one=0;
        REP(j,0,N){
            if(A[j][i]==0){
                zero++;
            }else{
                one++;
            }
        }
        count=zero*one%MOD;
        ans+=mx*count%MOD;
        mx=mx*2%MOD;
    }
    ans%=MOD;
    cout<<ans<<endl;


    return 0;
}

Measured memory_bytes: 71680
#include<iostream>
#include<cstdio>
#include<stack>
#include<queue>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
#define N 100009
#define K 1000000007
#define LL long long
int head[N], tot = 0;
int main() {
	std::ios::sync_with_stdio(0); std::cin.tie(0);
	int n, m;
	cin >> n >> m;
	cout << n * m;
	return 0;
}

Measured memory_bytes: 3188
S,K=input().split()
K=int(K)
K=min(K,300)
mod=998244353
a=[]
val=0
for i in range(len(S)):
    if S[i]=="0":
        a.append(val)
        val=0
    else:
        val+=1

if val!=0:
    a.append(val)
m=len(a)
K=min(sum(a),K)

dp=[[0 for i in range(K+1)] for j in range(K+1)]

for j in range(K+1):
    dp[j][j]=1

b=[a[i] for i in range(m)]
c=[a[i] for i in range(m)]
for i in range(1,m):
    b[i]+=b[i-1]
b=[0]+b
for i in range(m-2,-1,-1):
    c[i]+=c[i+1]
for i in range(m-1,-1,-1):
    ndp=[[0 for j in range(K+1)] for k in range(K+1)]
    for k in range(min(b[i],K)+1):
        for j in range(min(K,k+c[i])+1):
            M=max(k-j,-a[i])
            for l in range(max(0,M),K-j+1):
                ndp[j][k]=(ndp[j][k]+dp[j+l][k])%mod
            for l in range(1,min(K-k,-M)+1):
                ndp[j][k]=(ndp[j][k]+dp[j][k+l])%mod
    dp=ndp

print(dp[0][0])

Measured memory_bytes: 82008
#include <cstdio>
//#include <iostream>
#include <algorithm>
#include <cstring>
//#include <queue> //priority_queue 优先队列
//#include <map>
//#include <set> //multiset  set<int,greater<int>>大到小
//#include <vector>// ::iterator it;
//#include <stack>
//#include <cmath> // auto &Name : STLName  Name.
//#include <utility>
//#include <sstream>
//#include <string>
#define mod 1000000007
#define mod9 998244353
typedef unsigned long long ull;
typedef long long ll;
typedef double db;
typedef long double ld;
const db eps=1e-10;
const int INF = 0x3f3f3f3f;
const ll inf=0x3f3f3f3f3f3f3f3f;
const int N=1e3+5;
using namespace std;

int n,m,k=0;

int main(){
    scanf("%d",&n);
    if(n%2) printf("%d\n",2*n);
    else printf("%d\n",n);
    return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
const int N = 2e5;
vector <int> v(N);

int main(){
    int n; cin >> n;
    for (int i=0; i!=n; i++){
        cin >> v[i];
    }
    sort(v.begin(), v.begin()+n, greater<int>());

    long long c=0;
    c+=v[0];
    for (int i=1; i!=n/2; i++) c+=2*v[i];

    if (n%2==1) c+=v[n/2];

    cout << c << endl;
    return 0;
}

Measured memory_bytes: 3852
#include <stdio.h>
#include<string>
using namespace std;

string s;

int main()
{
  long long n;
  scanf("%lld",&n);
  while(n>0){
    s+=(n-1)%26+'a';
    n--;
    n/=26;
  }
  for(int i=s.size()-1;i>=0;i--){
    printf("%c",s[i]);
  }
  return 0;
}


Measured memory_bytes: 3224
import bisect
def main():
    n=int(input())
    happiness=[list(map(int,input().split(' '))) for i in range(n)]
    ans = 0
    def rec(x,num):
        if num ==0:
            return happiness[0][x]
        else:
            a=[0,1,2]
            a.remove(x)
            return max(rec(a[0],num-1),rec(a[1],num-1))+happiness[num][x]
    dp=[[0 for i in range(n)] for j in range(3)]
    dp[0][0]=happiness[0][0]
    dp[1][0]=happiness[0][1]
    dp[2][0]=happiness[0][2]
    for i in range(1,n):
        for j in range(3):
            b=[0,1,2]
            b.remove(j)
            dp[j][i]=max(dp[b[0]][i-1],dp[b[1]][i-1])+happiness[i][j]
    print(max(dp[0][n-1],dp[1][n-1],dp[2][n-1]))


if __name__ == '__main__':
    main()


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

int main()
{
    int n;
    cin >> n;
    int ans = 0;
    for (int i = 1; i <= n; i++)
    {
        int dig = to_string(i).length();
        if (dig % 2 == 1)
        {
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		sc.close();
		if((b / k) * k >= a) {
			System.out.println("OK");
		} else {
			System.out.println("NG");
		}
	}
}


Measured memory_bytes: 27012
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

int main()
{
    int n;
    ll k;
    cin >> n >> k;
    ll a[503];
    ll s = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        s += a[i];
    }
    vector<ll> v;
    for(ll i = 1; i * i <= s; i++){
        if(s % i == 0){
            v.push_back(i);
            if(i * i != s) v.push_back(s / i);
        }
    }
    sort(v.begin(), v.end(), greater<ll>());
    for(ll d : v){
        ll t = 0;
        ll b[503];
        for(int i = 0; i < n; i++){
            b[i] = a[i] % d;
            t += b[i];
        }
        sort(b, b + n, greater<ll>());
        ll r = 0;
        for(int i = 0; i < n; i++){
            if(t == r) break;
            t -= b[i];
            r += d - b[i];
        }
        if(t <= k){
            cout << d << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 3664
#include<stdio.h>
    #include<string.h>
    #include<algorithm>
    #include<vector>
    #include<queue>
    using namespace std;
    vector<int> p[100010];
    queue<int> q;
    int vis1[100010],vis2[100010],n;
    void dfs()
    {
        int i,j,x,y;
        q.push(1);
        q.push(0);
        while(!q.empty())
        {
            x=q.front();
            q.pop();
            y=q.front();
            q.pop();
            for(i=0;i<p[x].size();i++)
            {
                j=p[x][i];
                if(vis1[j]==0)
                {
                    vis1[j]=y+1;
                    q.push(j);
                    q.push(y+1);
                }
            }
        }
    }
    void bfs()
    {
        int i,j,x,y;
        while(!q.empty())
            q.pop();
        q.push(n);
        q.push(0);
        while(!q.empty())
        {
            x=q.front();
            q.pop();
            y=q.front();
            q.pop();
            for(i=0;i<p[x].size();i++)
            {
                j=p[x][i];
                if(vis2[j]==0)
                {
                    vis2[j]=y+1;
                    q.push(j);
                    q.push(y+1);
                }
            }
        }
    }
    int main()
    {
        int i,j,k,x,y;
        scanf("%d",&n);
        for(i=1;i<n;i++)
        {
            scanf("%d%d",&x,&y);
            p[x].push_back(y);
            p[y].push_back(x);
        }
        memset(vis1,0,sizeof(vis1));
        vis1[1]=-1;
        dfs();
        memset(vis2,0,sizeof(vis2));
        vis2[n]=-1;
        bfs();
        vis2[n]=-1;
        y=0;
        for(i=1;i<=n;i++)
            if(vis2[i]<vis1[i])
                y++;
            x=n-y;
            if(x>y)
                printf("Fennec\n");
            else
                printf("Snuke\n");
            return 0;
    }

Measured memory_bytes: 6784
#include <bits/stdc++.h>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <limits>
#include <string>
#include <vector>

using namespace std;

const long long INF = 1LL << 60;

//各桁の和を出力
long long Sum(long long n) {
  long long m = 0;
  while (n) {
    m += n % 10;
    n /= 10;
  }
  return m;
}

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

void Comuse() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

#define comuse Comuse()
// nCk(comuseを使え)
long long combi(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// pCk(comuseを使え)
long long perm(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] % MOD) % MOD;
}

//最小公倍数(aとbの)
long long lcm(long long a, long long b) {
  long long n;
  n = a / __gcd(a, b) * b;
  return n;
}

// auto A = div(n)
vector<long long> div(long long n) {
  vector<long long> ret;
  for (long long i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) {
        ret.push_back(n / i);
      }
    }
  }
  sort(ret.begin(), ret.end());
  return ret;
}

//(aのn乗をmodで割ったあまり)
long long modpow(long long a, long long n, long long mod) {
  long long ans = 1;
  while (n > 0) {
    if (n & 1) {
      ans = ans * a % mod;
    }

    a = a * a % mod;

    n >>= 1;
  }

  return ans;
}

void solve();

const int MAX_N = 131072;
// segment tree
int NN;
int seg[MAX_N * 2 - 1];
void seguse() {
  for (int i = 0; i < 2 * NN - 1; i++) {
    seg[i] = INT_MAX;
  }
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(20) << fixed;
  solve();
}

///////////////////////////////////////////////////////////

int N;
void solve() {
  cin >> N;
  cout << N / 2 + N % 2 <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100000000000
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<int, int>
#define PP pair<P,P>
#define T tuple<int,int,int> 
using namespace std;

int main(){
  int n,m; cin >> n >> m;
  vector<P> is;
  rep(i,m){
    int a,b; cin >> a >> b;
    is.emplace_back(a,b);
  }

  sort(all(is));
  int ans=1;
  //int l=is[0].first;
  int r=is[0].second;
  rep(i,m-1){
    if(is[i+1].first>=r){
      ans++;
      //l=is[i+1].first;
      r=is[i+1].second;
    }
    r=min(r,is[i+1].second);
  }
  cout << ans << endl;
return 0;
}

Measured memory_bytes: 4288
#include <stdio.h>
#include <iostream>
#include <vector>

int main(int argc, char** argv)
{
    int N,V,C;
    std::cin >> N;
    std::vector<int> vV;
    std::vector<int> vC;
    for(int i=0; i<N; i++)
    {
        std::cin >> V;
        vV.push_back(V);
    }
    for(int i=0; i<N; i++)
    {
        std::cin >> C;
        vC.push_back(C);
    }
    int res=0;
    for(int i =0; i<N;i++)
    {
        if(vV[i] > vC[i])
        {
            res += vV[i] - vC[i];
        }        
    }

    std::cout << res;
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<bits/stdc++.h>
#define ll long long int
#define hell 1000000007LL
using namespace std;
ll power(ll x, ll y,ll z){ 
    if(y==0)
     return 1;
    else
    {
        ll p=power(x,y/2,z);
        ll w=(p*p)%z;
        if(y%2==0)
         return w;
        else
        return (x*w)%z;
    }}
ll gcd(ll x,ll y)
{
    if(y==0)
     return x;
    else
    return gcd(y,x%y);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(20);
   ll n;
   cin>>n;
   ll k=2001;
   ll f[k];
   f[0]=f[1]=1;
   for(ll i=2;i<=2000;i++)
   f[i]=(f[i-1]*i)%hell;
   ll ans=0;
   for(int i=1;3*i<=n;i++)
   {
       ans=ans+((((f[n-2*i-1])*power(f[i-1],hell-2,hell))%hell)*power(f[n-3*i],hell-2,hell))%hell;
       ans=ans%hell;
   }
   cout<<ans;}

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

typedef double du ;
typedef string st ;
typedef long long ll ;
typedef long double ld ;
typedef long long int lli ;

#define vi vector <lli>
#define loop(num) for (lli i = 0 ; i < num ; i ++ )
#define loopcin(num , ar ) for (lli i = 0 ; i < num ; i ++ ) {cin >> ar [i] ;}
#define loopcout(num , ar) for (lli i = 0 ; i < num ; i ++ ) {cout << ar [i] << ' '; }

#define forr(num1 , num2) for (lli i = num1 ; i < num2 ; i ++ )
#define forrcin(num1 , num2 , ar ) for (lli i = num1 ; i < num2 ; i ++ ) {cin >> ar [i] ;}
#define forrcout(num1 , num2 , ar) for (lli i = num1 ; i < num2 ; i ++ ) {cout << ar [i] << ' '; }

#define D2forrcin(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cin >> A[i][j] ;}}
#define D2forrcout(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cout << A[i][j] << ' ' ;}cout << endl ;}

#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

#define F first
#define S second

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main ()
{
    fastio
    set<lli> s ;
    loop(3)
    {
        lli num ;
        cin >> num ;
        s. insert(num) ;
    }
    cout << s . size() ;




    return 0 ;
}

/*___________________________________________________________________functions___________________________________________________________________________*/



Measured memory_bytes: 256
/*
 AUTHOR : ANSHU BABU RAJPUT
 
    JAI MAA SARASWATI
    OM NAMAH SHIVAY
    JAI SHRI KRISHNA
    JAI SHRI RAM
    BHARAT MATA KI JAI

    #PKMKB	
    #CKMKB
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define int  long long 
#define endl    ("\n")
#define ff       first
#define ss      second
#define pb   push_back
#define pf  push_front
#define ppb   pop_back
#define ppf  pop_front
#define mp   make_pair
#define mod 1000000007

#define L(x)    x.length()
#define B(x)     x.begin()
#define E(x)       x.end()
#define F(x)     x.front()
#define SZ(x)     x.size()
#define CLR(x)   x.clear()

#define all(x)                      x.begin(),x.end()
#define sortD(x) sort(x.begin(),x.end(),greater<int>)
#define rev(x)             reverse(x.begin(),x.end())

#define intV vector<int>

#define PI          (3.141592653589)
#define PMAX     priority_queue<int>
#define PMIN             priority_queue<int,vi,greater<int>>
#define setbits(x)                   __builtin_popcountll(x)
#define zrobits(x)                        __builtin_ctzll(x)

#define KING(i, n) for (int(i) = 0; (i) < n; (i)++)
#define MAHAKAL(i, n) for (int(i) = n-1; (i) >= 0; (i)--)

#define Anshu        int t; cin>>t; while(t--)
#define SITARAM(n,type) type* input=new type[n]

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 ViLiFY_KiNG()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt","w",stderr);
#endif
}
 
int32_t main()
{
    ViLiFY_KiNG();
    int n;
    cin>>n;

    SITARAM(n,int);
    map<int,int> m;
    KING(i,n) {
        cin>>input[i];
        m[input[i]] = m[input[i]]+1;
    }

    int total_count = 0;
    map<int,int>::iterator it;
    for(it = m.begin();it != m.end();it++) {
        if(it->second >= 2) {
            total_count += ((it->second-1)*it->second)/2;
        }
    }

    if(total_count == 0) {
        while(n--) {
            cout<<0<<endl;
        }
        return 0;
    }

    KING(i,n) {
        int curr = m[input[i]];
        if(curr==2) {
            cout<<total_count-1<<endl;
        } else if(curr < 2) {
            cout<<total_count<<endl;
        } else {
            int temp = ((curr-1)*curr)/2;
            int temp_total_count = total_count - temp;
            curr--;
            temp = ((curr-1)*curr)/2;
            temp_total_count += temp;
            cout<<temp_total_count<<endl;

        }
        
    }
    return 0;
}

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

using namespace std;

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

ll N, M, P, Q, R, A, B, C, X, Y, Z, arr[100005];
int onff[105], state, init;



int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> N >> M;
	for (int i = 1; i <= M; ++i){
		cin >> A;
		for (int j = 1; j <= A; ++j){
			cin >> X;
			onff[X-1] ^= (1 << (i-1));
		}
	}
	for (int i = 1; i <= M; ++i){
		cin >> X;
		init ^= ((X+1)%2)*(1 << (i-1));
	}
	for (int i = 0; i < (1 << N); ++i){
		state = init;
		for (int j = 0; j < N; ++j){
			if (i & (1 << j)){
				state ^= onff[j];
			}
		}
		if (state == (1 << M)-1){
			Y++;
		}
	}
	cout << Y << '\n';
}

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

int main(){
    int N; cin>>N;
    for(int i=0;i<N;i++){
        char c; cin>>c;
        if(c=='Y'){
            cout<<"Four"<<endl;
            return 0;
        }
    }
    cout<<"Three"<<endl;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
if m == 0:
    print([0, 10, 100][~-n])
    exit()
x = []
y = []
z = []
for _ in range(m):
    s, c = map(int, input().split())
    if s == 1:
        x.append(c)
    elif s == 2:
        y.append(c)
    else:
        z.append(c)
if n == 1:
    if len(set(x)) > 1:
        print(-1)
    elif len(set(x)) < 1:
        print(0)
    else:
        print(x[0])
elif n == 2:
    if len(set(x)) > 1 or len(set(y)) > 1:
        print(-1)
        exit()
    if len(set(x)) == 1 and x[0] == 0:
        print(-1)
        exit()
    if len(set(x)) == 0:
        a = 1
    else:
        a = x[0]
    if len(set(y)) == 0:
        b = 0
    else:
        b = y[0]
    print(a, b, sep='')
else:
    if len(set(x)) > 1 or len(set(y)) > 1 or len(set(z)) > 1:
        print(-1)
        exit()
    if len(set(x)) == 1 and x[0] == 0:
        print(-1)
        exit()
    if len(set(x)) == 0:
        a = 1
    else:
        a = x[0]
    if len(set(y)) == 0:
        b = 0
    else:
        b = y[0]
    if len(set(z)) == 0:
        c = 0
    else:
        c = z[0]
    print(a, b, c, sep='')


Measured memory_bytes: 3188
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int num = 0;
        for(int i = 0; i < s.length(); i++) {
            if(s.charAt(i) == 'o') {
                num++;
            }
        }
        int ans = 700 + 100 * num;
        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
import sys
sys.setrecursionlimit(100000000)
n = int(input())
def factrial(n):
    if n == 1:
        return 1
    return n * factrial(n-1)
def primes(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]:
            continue
        for j in range(i*2, n+1, i):
            is_prime[j] = False
    return [i for i in range(n+1) if is_prime[i]]
prime = primes(n)
fact = factrial(n)
ans = []
for i in prime:
    tmp = 0
    for j in range(1, 1000):
        ij = i**j
        if tmp > n:
            break
        tmp += n//ij
    ans.append(tmp + 1)
answer = 1
for i in ans:
    answer *= i
print(answer%(10**9+7))


Measured memory_bytes: 3700
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <cstdio>

using namespace std;

const long long INF = 1000000000000;
const long long MOD = 1000000007;

class Edge{
public:
  long long from;
  long long to;
  long long weight;
};

int main()
{
  long long N, M, L;
  cin >> N >> M >> L;
  long long d[N][N];

  for (int i = 0; i < N;i++){
    for (int j = 0; j < N; j++)
    {
      d[i][j] = INF;
      if (i == j)
        d[i][j] = 0;
    }
  }

  for (int i = 0; i < M;i++){
    long long a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;

    d[a][b] = c;
    d[b][a] = c;
  }

  for (int k = 0; k < N;k++){
    for (int i = 0; i < N;i++){
      for (int j = 0; j < N;j++){
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }

  long long G[N][N];
  for (int i = 0; i < N; i++)
  {
    for (int j = 0; j < N;j++){
      G[i][j] = INF;
      if(d[i][j]<=L)
        G[i][j] = 1;
      if(i==j)
        G[i][j] = 0;
    }
  }

  for (int k = 0; k < N; k++)
  {
    for (int i = 0; i < N; i++)
    {
      for (int j = 0; j < N; j++)
      {
        G[i][j] = min(G[i][j], G[i][k] + G[k][j]);
      }
    }
  }
  long long Q;
  cin >> Q;
  vector<long long> ans;
  for (int q = 0; q < Q; q++)
  {
    long long s, t;
    cin >> s >> t;
    s--;
    t--;
    ans.push_back(G[s][t]);
  }

  long long size = ans.size();
  //cout << "Graph" << endl;
  for (int i = 0; i < size; i++)
  {
    if(ans[i]!=INF)cout << ans[i]-1 << endl;
    else
      cout << -1 << endl;
  }
}


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

int main() {
  string S;
  cin >> S;
  int n = 0, w = 0, s = 0, e = 0;
  int a = S.size();
  for (int i = 0; i < a; i++){
    if (S[i] == 'N') n++;
    if (S[i] == 'W') w++;
    if (S[i] == 'S') s++;
    if (S[i] == 'E') e++;
  }
  bool flag = true;
  if ((n > 0 && s == 0) || (n == 0 && s > 0)) flag = false;
  if ((w > 0 && e == 0) || (w == 0 && e > 0)) flag = false;
  
  if (flag == true) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3576
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    unsigned long int n,k,num,count = 0;
    vector<unsigned long int>v;

    cin >> n >> k;

    for(int i = 0;i < n;i++){
        cin >> num;
        v.push_back(num);
    }
    
    if(n <= k){
        cout << 0 << endl;
        return 0;
    }else{
        sort(v.begin(),v.end(),greater<int>());
        
        for(vector<unsigned long int>::iterator it = v.begin()+k; it != v.end();it++){
            count += *it;
        }

        cout << count << endl;

    }

    return 0;

}

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

ll factorize(ll C, ll D) {
  ll x = C * D;
  if ( C < D ) {
    swap(C, D);
  } // C < D
  // 0 ~ B までのCの倍数の個数 - 0 ~ A までのCの倍数の個数
  ll r = C % D;
  while(r!=0) {
    C = D;
    D = r;
    r = C % D;
  }
  // cout << x << x/D << endl;
  return x / D;
}


int main() {
  ll A, B, C, D;
  cin >> A >> B >> C >> D;
  ll ans = 0;
  ll Csum, Dsum, CDsum;
  ll CD = factorize(C, D);
  // cout << C << D << CD << endl;

  /*
  Csum = B / C - (A - 1) / C; // 整数になる
  Dsum = B / D - (A - 1) / D;
  CDsum = B / CD - (A - 1) / CD;
  // cout << Csum << Dsum << CDsum << endl;
  ans = B - A + 1 - (Csum + Dsum - CDsum);
  */
  ll Bsum, Asum;
  Bsum = B - B/C - B/D + B/CD;
  Asum = (A-1) - (A-1)/C - (A-1)/D + (A-1)/CD;
  ans = Bsum - Asum;

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
bool ispalin(string s)
{
    ll n=s.length();
    bool fg=true;
	    for(int i=0;i<n/2;i++)
            if(s[i]!=s[n-i-1])
            fg=false;
            return fg;
}
int main()
{
	ll t;
	t=1;
	for(int x=1;x<=t;x++)
	{
	    cout<<fixed;
	    ll xx;
	    cin>>xx;
	    double d=((double)xx/3);
	    cout<<setprecision(16)<<d*d*d;
	}
}


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

using namespace std;

int main(){
 while(1){
    int n,x;
    cin>>n>>x;
    if(n == 0 && x == 0) break;
    int ans = 0; 
    for(int a = 1; a <= n ; a++)
     for(int b = a + 1; b <= n ; b++)
       for(int c = b + 1; c <= n ; c++){ 
      if(a + b + c != x) continue;
      ans++;
     }
    cout<<ans<<endl;
}
}


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

#define      pb    push_back
#define      ff    first
#define      ss    second
#define      ll    long long int
#define      endl  "\n"
#define      FASTIO        ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define      TEST    ll t ; cin >> t ; while( t -- )


//------------------------------------------------------------------------//

#define sc(a) scanf("%d",&a)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define sc3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define sc4(a,b,c,d) scanf("%d%d%d%d",&a,&b,&c,&d)

//------------------------------------------------------------------------//

const ll big = 10e15 ;

int  main (  ) {

    FASTIO ;

    string s1 , s2 ;

    cin >> s1 >> s2 ;

    if( s2.size( ) == s1.size( ) + 1 ){

        int flag = 0 ;

        for( int i = 0 ; i < s1.size( ) ; i++ )
        if( s1[ i ] != s2[ i ]){
            flag = 1 ;
            break ;
        }

        if( flag ) cout << "No" ;
        else  cout << "Yes" ;
    }
    else  cout << "No" ;

    return  0 ;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
int a[maxn],ans;
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    for(int i=1;i<=n;i++)
        ans^=a[i];
    !ans?puts("Yes"):puts("No");
    return 0;
}

Measured memory_bytes: 640
// In The Name Of God
#include<bits/stdc++.h>
#define err(i) cerr << #i << " : " << i << "\n"
#define pb push_back
#define ll long long

using namespace std;

const int N = 1e5+22 ;

int n,t[N],r,m;

int main()
{
	cin>>n>>m;
	for(int i=1,x,y;i<=m;i++)
	{
		cin>>x>>y;
		t[x]++;
		t[y]++;
		if(t[x]&1) r++;
		else r--;
		if(t[y]&1) r++;
		else r--;
	}
	if(r==0) cout<<"YES";
	else cout<<"NO";

	
	return 0;
}

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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;

vi v;

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

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

int unite(int x, int y)
{
    v[par(y)] = par(x);
}


void solve()
{
    int N, M; cin >> N >> M;
    v.resize(N+1); REP1(i, N) v[i] = i;
    vi p(N+1); REP1(i, N) cin >> p[i];
    REP1(i, M)
    {
        int x, y; cin >> x >> y;
        unite(x, y);
    }
    int ans = 0;
    REP1(i, N)
    {
        if(p[i] == i || same(p[i], i)) ans++;
    }
    cout << ans << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}

Measured memory_bytes: 1024
import sys

def main():
    input = sys.stdin.readline
    N = int(input())
    P = list(map(int, input().split()))

    cnt = 0
    for i in range(1, N-1):
        p = P[i]
        if min(P[i-1:i+2]) < p < max(P[i-1:i+2]):
            cnt += 1

    return cnt


if __name__ == '__main__':
    print(main())


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

using namespace std;
typedef long long LL;

int main(){
  int N;
  cin >> N;
  int ans[200010]={0};
  rep(i,N-1){
    int A;
    cin >> A;
    ans[A]++;
  }
  rep(i,N) cout << ans[i+1] << endl;

  return 0;
}


Measured memory_bytes: 4420
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdlib.h>
#include<set>
#include<math.h>
#include<iomanip>
#include<unordered_map>
#include<algorithm>

using namespace std;


int main(void)
{
    int n;
    cin>>n;
    
    int v[n];
    for(int i=0;i<n;i++){
        cin>>v[i];
    }
    
    for(int i=n-2;i>=0;i--){
        for(int j=0;j<=i;j++){
            if(v[j]>v[j+1]){
                int temp=v[j];
                v[j]=v[j+1];
                v[j+1]=temp;
            }
        }
    }
    
    double an=(double)(v[0]+v[1])/2;
    for(int i=2;i<n;i++){
        an=(double)(an+v[i])/2;
    }
    
    cout<<an<<endl;
    
}


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

int main(){
    int n;
    cin >> n;
    vector<int> c(n), s(n), f(n);
    rep(i, n-1) cin >> c[i] >> s[i] >> f[i];

    for (int i = 0; i < n; i++) {
        int t = 0;
        for (int j = i; j < n-1; j++) {
            if (t < s[j]) t = s[j];
            else if (t%f[j] == 0);
            else t = t + f[j] - t%f[j];
            t += c[j];
        }
        cout << t << endl;
    } 
    return 0;
}

Measured memory_bytes: 256
# coding: utf-8

N = int(input())
ab = [list(map(int, input().split())) for _ in range(N-1)]

def run(cur, tr, dist, d=1, pre=-1, recur=1, save_recur = []):
    for node in tr[cur]:
        if node == pre:continue
        dist[d].append(node)
        if recur >500:
            dic_ = {'cur':node, 'tr': tr, 'dist': dist,
                              'd': (d + 1) % 2, 'pre': cur, 'recur': recur + 1}
            save_recur.append(dic_)
            return None
        run(node, tr, dist, (d+1)%2, pre=cur, recur=recur+1, save_recur=save_recur)
    return None

if __name__ == '__main__':
    # generate dict
    tr = {}
    for line in ab:
        if line[0] not in tr.keys():
            tr[line[0]] = [line[1]]
        else:
            tr[line[0]].append(line[1])
        if line[1] not in tr.keys():
            tr[line[1]] = [line[0]]
        else:
            tr[line[1]].append(line[0])

    dist = {0: [1], 1: []}
    save_rec = []
    run(1, tr, dist, save_recur=save_rec)

    while True:
        save_rec2 = save_rec
        save_rec = []
        for dict in save_rec2:
            run(dict['cur'], dict['tr'], dict['dist'], dict['d'],
                dict['pre'], dict['recur'],save_recur = save_rec)
        if save_rec == []:break


    perm = [0] * (N+1)
    rem1_max, rem2_max, rem0_max = int(N/3),int(N/3),int(N/3)
    if N % 3 == 1:
        rem1_max +=1
    if N % 3 == 2:
        rem1_max += 1
        rem2_max += 1
    if (len(dist[0]) <= N/3) | (len(dist[0]) >= 2*N/3):
        bool = int(len(dist[0]) <= N/3)
        h0 = 1
        for k in dist[1-bool]:
            perm[k] = 3 * h0
            h0 += 1
        nums = [3*i for i in range(h0, rem0_max+1)] + [3*i+1 for i in range(0, rem1_max)] + [3*i+2 for i in range(0, rem2_max)]
        for k, val in zip(dist[bool], nums):
            perm[k] = val
    else:
        n = int(N/3)
        if N % 3 == 2:
            n += 1
        h1 = 0
        h2 = 0
        idx = 0
        bool = int((len(dist[0]) > len(dist[1])))
        for alpha in range(n):
            even = dist[bool][idx]
            perm[even] = alpha * 3 + 1
            odd = dist[1-bool][idx]
            perm[odd] = alpha * 3 + 2
            idx += 1
        h0 = 1
        for k in dist[1-bool][idx:]:
            perm[k] = 3 * h0
            h0 += 1
        nums = [3 * i for i in range(h0, rem0_max+1)] + [3 * i + 1 for i in range(n, rem1_max)] + [3 * i + 2 for i in range(n, rem2_max)]

        for h, k in enumerate(dist[bool][idx:]):
            perm[k] = nums[h]
    print(" ".join(list(map(str, perm[1:]))))

Measured memory_bytes: 101748
N = int(input())
base = 0
L = []
for _ in range(N):
	ta,tb = map(int,input().split())
	base -= tb
	L.append(ta+tb)

L.sort(reverse = True)

takahashi = 0

for i in range(0,N,2):
	takahashi += L[i]

print(takahashi + base)

Measured memory_bytes: 7488
module Main where
-- import Debug.Trace
import Data.List
import Data.Char
import Data.Array
import Data.Maybe
import Data.Ord
import Control.Monad

data Suit = Spade | Hart | Club | Diamond deriving (Eq)
data Card = Card Suit Int deriving (Eq)
instance Ord Card where
    compare (Card _ a) (Card _ b) = compare a b
instance Show Card where
    show (Card Spade   i) = "S"++show i
    show (Card Hart    i) = "H"++show i
    show (Card Club    i) = "C"++show i
    show (Card Diamond i) = "D"++show i

solve :: Int -> [Card] -> [([Card], String)]
solve n l = [(bl, stable ol bl), (sl, stable ol sl)] where
    bl = bSort l
    sl = sSort n l
    ol = sort l
    stable ol cl = if ol == cl then "Stable" else "Not stable" 

bSort :: [Card] -> [Card]
bSort l = iter 0 [] l where
    iter c sl [] = sl
    iter c sl l = iter2 c [] l where
        iter2 c ac [x] = iter c (x:sl) (reverse ac)
        iter2 c ac (x:y:ds)
            | x <= y     = iter2 (c) (x:ac) (y:ds)
            | otherwise = iter2 (c+1) (y:ac) (x:ds)

sSort :: Int -> [Card] -> [Card]
sSort n l = iter 0 (0, listArray (0, n-1) l) where
    iter p (c, ar)
        | p >= n    = elems ar
        | otherwise = iter (p+1) (setMin p p) where
            setMin i mi
                | i < n     = setMin (i+1) $ if ar!i < ar!mi then i else mi
                | mi == p   = (c, ar) 
                | otherwise = (c+1, ar // [(p, ar!mi), (mi, ar!p)])

toStr :: [Card] -> String
toStr l = init (concatMap (\x-> show x ++ " ") l)

readLine:: IO [Card]
readLine = fmap (map readCards . words) getLine where
    readCards c = case c of
        ('S':s) -> Card Spade   (read s)
        ('H':s) -> Card Hart    (read s)
        ('C':s) -> Card Club    (read s)
        ('D':s) -> Card Diamond (read s)

main :: IO() 
main = do
    n <- readLn :: IO Int
    l <- readLine
    mapM_ putStrLn $ concatMap (\(rl,s) -> [toStr rl, s]) (solve n l)



Measured memory_bytes: 4116
using System;
using System.Collections.Generic;
using System.Linq;

namespace ABC148A
{
    class Program
    {
        static void Main(string[] args)
        {
            HashSet<int> s = new HashSet<int>(){1,2,3};
            s.Remove(Cin.Int());
            s.Remove(Cin.Int());

            Console.WriteLine(s.First());
        }
    }

    class Solver
    {
        public Solver()
        {

        }

        public IConvertible Solve()
        {
            return 0;
        }
    }

    internal static class Cin
    {
        public static string String()
        {
            return Console.ReadLine();
        }

        public static int Int()
        {
            return int.Parse(String());
        }

        public static int[] IArr()
        {
            return Split().Select(int.Parse).ToArray();
        }

        public static long Long()
        {
            return long.Parse(String());
        }

        public static long[] LArr()
        {
            return Split().Select(long.Parse).ToArray();
        }

        public static double Double()
        {
            return double.Parse(String());
        }

        public static double[] DArr()
        {
            return Split().Select(double.Parse).ToArray();
        }

        private static IEnumerable<String> Split()
        {
            return String().Split(' ');
        }
    }
}

Measured memory_bytes: 13396
a, b, c = input().split(' ')
a = int(a)
b = int(b)
c = int(c)
if a > c:
  # 下る場合
  if b < c:
    print('Yes')
  else:
    print('No')
else:
  # 上る場合
  if b > c:
    print('Yes')
  else:
    print('No')

Measured memory_bytes: 3060