akhauriyash/Code-Regression huggingface dataset:
using static System.Math;
using System.Collections.Generic;
using System;

public class hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        var tab = new List<int>();
        var tp = new List<int>();
        for (int i = 0; i < n; i++)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var a = int.Parse(line[0]);
            var b = int.Parse(line[1]);
            var g = int.Parse(line[2]);
            for (int j = a; j <= b; j++)
            {
                tab.Add(j);
                tp.Add(g);
            }
        }
        tab.Add(0); tp.Add(0);
        var L = tab.ToArray();
        var good = tp.ToArray();
        var m = int.Parse(Console.ReadLine().Trim());
        var q = new int[m];
        var qmax = 0;
        for (int i = 0; i < m; i++)
        {
            var w = int.Parse(Console.ReadLine().Trim());
            q[i] = w;
            qmax = Max(qmax, w);
        }
        var LL = L.Length;

        var dp = new int[LL + 1, qmax + 1];
        for (int i = 0; i < LL; i++)
            for (int j = 0; j <= qmax; j++)
                if (j < L[i]) dp[i + 1, j] = dp[i, j];
                else dp[i + 1, j] = Max(dp[i, j], dp[i + 1, j - L[i]] + good[i]);
        var ans = new int[m];
        for (int i = 0; i < m; i++)
        {
            var tw = dp[LL, q[i]];
            if (tw == 0) { Console.WriteLine(-1); goto exit; }
            else ans[i] = tw;
        }
        foreach (var x in ans) Console.WriteLine(x);
        exit:;
    }
    public static void readData(int[] good, int[] L)
    {
        for (int i = 0; i < good.Length - 1; i++)
        {
            string[] line2 = Console.ReadLine().Trim().Split(' ');
            good[i] = int.Parse(line2[0]);
            L[i] = int.Parse(line2[1]);
        }
    }
}


Measured memory_bytes: 259740
#include <iostream>
#include <cmath>
#include <vector>

using namespace std;

void solve()
{
	int n;
	cin >> n;
	vector<int> factorize;
	cout << n << ": ";
	int input = n;
	for (int i = 2; i <= sqrt((double)input); ++i)
	{
		while (n % i == 0)
		{
			n /= i;
			factorize.push_back(i);
		}
	}
	if (n != 1)
	{
		factorize.push_back(n);
	}
	for (int i = 0; i < factorize.size() - 1; ++i)
	{
		cout << factorize[i] << " ";
	}
	cout << factorize[factorize.size() - 1] << endl;
}

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

Measured memory_bytes: 1224
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <tuple>
#include <utility>
#include <set>
#include <numeric>
#include <queue>
#include <sstream>
#include <map>
using namespace std;
using LLI = long long int;

#define Rep(i, N) for (int i = 0; i < N; i++)


int main(int argc, char *argv[])
{
    int X, Y;
    scanf("%d %d", &X, &Y);
    int x = X + Y / 2;
    cout << x << endl;    

    return 0;
}

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

int main() {
  char c;
  cin >> c;
  if (c >= 'A' && c <= 'Z') {
    cout << 'A' << endl;
  }
  else if (c >= 'a' && c <= 'z') {
    cout << 'a' << endl;
  }
}

Measured memory_bytes: 3596
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA60E solver = new TaskA60E();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA60E {
        int MAX = 20;
        int N;
        int[] x;
        int L;
        int Q;
        int[][] right;

        public void solve(int testNumber, Scanner in, PrintWriter out) {
            N = in.nextInt();
            x = new int[N + 1];

            for (int i = 1; i <= N; i++) {
                x[i] = in.nextInt();
            }
            L = in.nextInt();
            Q = in.nextInt();
            right = new int[MAX][N + 1];


            for (int i = 1; i <= N; i++) {
                int idx = Arrays.binarySearch(x, x[i] + L);
                right[0][i] = (idx >= 0) ? idx : -idx - 1 - 1;
            }


            for (int i = 1; i < MAX; i++) {
                for (int j = 0; j <= N; j++) {
                    right[i][j] = right[i - 1][right[i - 1][j]];
                }
            }

            for (int q = 1; q <= Q; q++) {
                int _u = in.nextInt();
                int _v = in.nextInt();

                int u = Math.min(_u, _v);
                int v = Math.max(_u, _v);

                int r = 0;
                for (int i = MAX - 1; i >= 0; i--) {
                    if (right[i][u] < v) {
                        u = right[i][u];
                        r += (1 << i);
                    }
                }
                out.println(r + 1);
            }
        }

    }
}


Measured memory_bytes: 37792
from collections import Counter

import numpy as np


def part(pts, a, ans):
    b = np.dot(pts, [np.sin(a), np.cos(a)])
    c = np.argmax(b, axis=0)
    for i, v in Counter(c).items():
        ans[i] += v


def solve(n, pts):
    ans = [0] * n
    part(pts, np.linspace(0, np.pi, 100000, endpoint=False), ans)
    part(pts, np.linspace(np.pi, 2 * np.pi, 100000, endpoint=False), ans)
    return [v / 200000 for v in ans]


n = int(input())
pts = np.array([list(map(int, input().split())) for _ in range(n)])
print('\n'.join(map(str, solve(n, pts))))


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

#define int long long
#define ff first
#define ss second
#define pb push_back
#define vi vector<int>
#define setbits(x) __builtin_popcountll(x)
#define ps(x, y) fixed << setprecision(y) << x
#define rep(i, begin, end) for (int i = begin; i < end; i++)
#define all(p) p.begin(), p.end()
#define sz(x) (int)x.size()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int mod = (int)(1e9 + 7);
const int inf = (int)(1e18);
void run()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
void solution()
{
    int x;
    cin >> x;
    cout << (1 - x) << endl;
    return;
}
int32_t main()
{
    run();
    int t;
    t = 1;
    while (t--)
    {
        solution();
    }
    return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
#define Yes "Yes"
#define No "No"
#define YES "YES"
#define NO "NO"
typedef long long ll;

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

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/
ll N,x;
ll a[2320];

//k回回すとき、
//f[i][k] = min({a[i-k] ~ a[i])
//f[i][k] = min(f[i][k-1], a[i-k])
ll f[2320][2320];
int main() {
    cin>>N>>x;
    rep(i,N)cin>>a[i];
    //k回回すとする
    ll ans = 0;
    //k = 0回のとき
    rep(i,N)ans += a[i];

    rep(i,N)f[i][0] = a[i];
    rep1(k,N){
        ll tmp = k * x;
        rep(i,N){
            f[i][k] = min(f[i][k-1], a[(i-k+N) % N]);
            tmp += f[i][k];
        }
        chmin(ans, tmp);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 37120
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
try (Scanner sc = new Scanner(System.in)) {
String line = sc.nextLine();
String answer = "";
int length = line.length();
for (int i = 0; i < length; i++) {
char ch = line.charAt(i); 
if(Character.isLowerCase(ch)==true){
    answer += Character.toUpperCase(ch);
}
else{
    answer += Character.toLowerCase(ch);
}
}
System.out.println(answer);
}
}
}



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


namespace AtCoder
{
    class Program
    {
        public static void Main()
        {
            new Program().Solve();
        }

        void Solve()
        {
            var tmp = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
            int n = tmp[0];
            int y = tmp[1];

            for (int i = 0; i <= n; i++)
            {
                for (int j = 0; j <= n - i; j++)
                {
                    int k = n - i - j;
                    if (10000 * i + 5000 * j + 1000 * k == y)
                    {

                        Console.WriteLine($"{i} {j} {k}");
                        return;
                    }
                }
            }
            Console.WriteLine("-1 -1 -1");
        }




    }
}


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

using namespace std;

#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define MP make_pair
#define PB push_back
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
const double pi=acos(-1.0);
typedef pair<int, int> PII;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;


#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

#define int long long
int dp[3000][3000][2];
int ar[3000];
int n;
int recur(int i, int j, int p)
{
    p=p%2;
    if(j<i || min(i,j)<0 || max(i,j)>n)
        return 0;
    if(dp[i][j][p])
        return dp[i][j][p];
    int t = max(ar[i], ar[j]);
    if(p == 0)
        dp[i][j][p] = max(ar[i] + recur(i+1,j,p+1),  ar[j] + recur(i,j-1,p+1));
    else
        dp[i][j][p] = min(recur(i+1,j,p+1) - ar[i], recur(i,j-1,p+1)-ar[j]);
    return dp[i][j][p];
}



signed main()
{
    IOS
    cin >> n;
    REP(i, n)
        cin >> ar[i];
    
    cout << recur(0,n-1,0);
    
}

Measured memory_bytes: 139776
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <list>
#include <math.h>
#include <string.h>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define INF (1LL<<60)
#define int long long
#define ll long long
#define mod 1000000007


struct edge{
	int from, to, length;
};

signed main(){

	int L;
	cin >> L;
	vector<int> v;
	vector<edge> e;
	bitset<64> bit(L);

	v.push_back(0);
//	v.push_back(1);
//	e.push_back(edge{ 0, 1, 1 });
//	e.push_back(edge{ 0, 1, 0 });

	int sum = 1;
	int i;
	for (i = 63; i >= 0; i--){
		if (bit[i] == 1) break;
	}
	i--;
	for (; i >= 0; i--){
		if (bit[i] == 0){
			v.push_back(v.size());
			e.push_back(edge{ v.size() - 2, v.size() - 1, sum });
			e.push_back(edge{v.size() - 2, v.size() - 1, 0});
			sum *= 2;
		}
		else{
			v.push_back(v.size());
			e.push_back(edge{ v.size() - 2, v.size() - 1, sum });
			e.push_back(edge{ v.size() - 2, v.size() - 1, 0 });
			e.push_back(edge{ 0, v.size() - 1, sum*2 });
			sum=sum*2+1;
		}
	}

	cout << v.size() << " " << e.size() << endl;
	for (int i = 0; i < e.size(); i++)
		cout << e[i].from+1 << " " << e[i].to+1 << " " << e[i].length << endl;

	

	return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main()
{
  int a[3];
  int tmp;

  cin >> a[0] >> a[1] >> a[2];

  tmp = a[2];
  a[2] = a[1];
  a[1] = a[0];
  a[0] = tmp;

  cout << a[0] <<" "<< a[1] <<" "<< a[2];

  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
main(){
	int n,a,b;
	vector<pair<int,int> >v;
	for(scanf("%d",&n);n--;v.push_back(make_pair(-b,a)))scanf("%d%d",&a,&b);
	sort(v.begin(),v.end());
	printf("%d %d\n",v[0].second,-v[0].first);
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

ll n;
ll a[22],b[22],c[22];

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

  cin>>n;
  rep(i,n){
    cin>>a[i];
    a[i]--;
  }
  ll res=0;
  rep(i,n){
    cin>>b[i];
    res+=b[i];
  }
  rep(i,n-1)cin>>c[i];

  rep(i,n-1){
    if(a[i]+1==a[i+1])res+=c[a[i]];
  }
  cout<<res<<endl;

  return 0;
}


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


int main() {
    int N; cin >> N;
    vector<int> H(N); for (int i = 0; i < N; i++) cin >> H[i];

    int ans = 1;
    int max_height = H[0];
    for (int i = 1; i < N; i++) {
        if (max_height <= H[i]) {ans++; max_height = H[i];}
    }

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


Measured memory_bytes: 256
//define debug for debugging
//#define DEBUG
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define MAX 100000 + 100
#define max3(a,b,c) max(a,max(b,c))
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
void swap(int *a,int *b){
	int temp = *a;
	*a = *b;
	*b = temp;
}


int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifdef DEBUG
    freopen("i.txt","r",stdin);
    freopen("o.txt","w",stdout);
#endif              
    string a;cin >> a;
    int ret = 0;
    for(int i = 0;i < a.size()/2;i++){
    	if(a[i] != a[a.size()-i-1]){
    		ret++;
    	}
    }
    cout << ret;
	return 0;
}


Measured memory_bytes: 256
N = int(input())
S = [input() for i in range(N)]
cnt = [0 for i in range(5)]

for num, cap in enumerate(['M', 'A', 'R', 'C', 'H']):
    for i in range(N):
        if S[i][0] == cap:
            cnt[num] += 1

lastcnt = 0

for i in range(3):
    for j in range(i+1, 4):
        for k in range(j+1, 5):
            # print(cnt[i]*cnt[j]*cnt[k])
            lastcnt += cnt[i]*cnt[j]*cnt[k]
print(lastcnt)


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

int main()
{
	ios::sync_with_stdio(false);
	ll n;
	while(cin>>n){
		int a=INT_MAX,b=INT_MIN,temp;
		for(int i=0;i<n;i++){
			cin>>temp;
			a=min(a,temp);
			b=max(b,temp);
		}
		cout<<abs(a-b)<<endl;
	}
	return 0;
}

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

#define rep(i, x, n) for (int i = x; i < n; i++)
typedef long long ll;

const int INF = 1e9 + 7;

using namespace std;

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

	int n, m;
	cin >> n >> m;

	cout << (100 * (n - m) + 1900 * m) * pow(2, m) << endl;


	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;int flag = 0;
    cin>>n;
    for(int i=0;i<15;i++)
    {
        int sum = 0;
        for(int j=0;j<26;j++)
        {
            sum = i*7 + j*4;
            if(sum == n){
             flag = 1;

            }
        }
    }
    if(flag == 1)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define RANGE(i,n) for(int i=0;i<n;i++)
typedef long long ll;
struct P{
    ll var1;
    ll var2;
};
bool operator< ( const P &one, const P &two){
    return one.var1 < two.var1;
};
bool operator> ( const P &one, const P &two){
    return one.var1 > two.var1;
};

using namespace std;

signed main() {
    int N,M;
    cin >> N >> M;
    vector<int> dp(N+1,-1);
    dp[0] = 1;
    dp[1] = 1;
    RANGE(i,M){
        int a;
        cin >> a;
        dp[a] = 0;
    }
    for(int i=2;i<N+1; i++){
        if(dp[i] < 0) dp[i] = (dp[i-1] + dp[i-2])% 1000000007;
    }

    cout << dp[N] << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define print(x) cout<<(x)<<endl
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define INF10 1001001001 
#define INF5 100000
#define EPS 1e-10


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

	int cnt = 1;
	REP(i, N) {
		if (i == 0)continue;
		if (s[i] != s[i - 1]) {
			cnt++;
		}
	}
	cout << cnt << endl;



	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,LL> PL;

const int MOD=1000000007;
int INF=100100100;
int n;
vector<int> g[100010];
int depth[100010];
int mdepth[100010];
int par[100010];

int dfs(int v,int p){
  par[v]=p;
  if(p<0)depth[v]=0;
  else depth[v]=depth[p]+1;
  int res=0;
  for(int w:g[v]){
    if(w!=p){
      res=max(res,dfs(w,v)+1);
    }
  }
  mdepth[v]=res;
  return res;
}

int main(){
  cin>>n;
  int u,v;cin>>u>>v;u--;v--;
  for(int i=0;i<n-1;i++){
    int a,b;cin>>a>>b;a--;b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  dfs(v,-1);
  int po=u;
  for(int i=1;i<=(depth[u]-1)/2;i++){
    po=par[po];
  }
  for(int i=0;i<n;i++){
    //cout<<depth[i]<<" "<<mdepth[i]<<endl;
  }
  //cout<<depth[po]<<" "<<mdepth[po]<<endl;
  cout<<depth[po]+mdepth[po]-1<<endl;
  return 0;
}

Measured memory_bytes: 12032
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(){
    vector< vector<int> > dp(1001,vector<int>(1001));
    int q;
    cin >> q;
    
    for(int i=0; i<q; i++){
        string x;
        string y;
        cin >> x;
        cin >> y;
        int xLength = x.length();
        int yLength = y.length();

        for(int j=0; j<xLength; j++){
            for(int k=0; k< yLength; k++){
                int suggest[3];
                if(x[j] == y[k]){
                    dp[j+1][k+1] = dp[j][k] + 1; 
                }else{
                    if(dp[j+1][k] > dp[j][k+1]){
                        dp[j+1][k+1] = dp[j+1][k]; 
                    }else{
                        dp[j+1][k+1] = dp[j][k+1];
                    }
                }
            }
        }
        cout << dp[xLength][yLength] << endl;
    }
    return 0;
}



Measured memory_bytes: 6688
#include<stdio.h>

int main(void){
    int a[4][3][10]={0},i,j,k,n,b,f,r,v;
    
    scanf("%d",&n);
    
    for(i=0;i<n;i++){
        scanf("%d %d %d %d",&b,&f,&r,&v);
        a[b-1][f-1][r-1]+=v;
    }
    
    for(i=0;i<4;i++){
        for(j=0;j<3;j++){
            for(k=0;k<10;k++){
                printf(" %d",a[i][j][k]);
            }
            printf("\n");
        }
        if(i<3) printf("####################\n");
    }
}


Measured memory_bytes: 2040
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
    
from collections import defaultdict
n,m,k=map(int,input().split())
tree = UnionFind(n)
friend=defaultdict(int)
block =defaultdict(int)

ab=[]
for _ in range(m):
    a,b=map(int,input().split())
    ab.append((a,b))
    
for a,b in ab:
    tree.union(a-1,b-1)
    
for a,b in ab:
    if tree.same(a-1,b-1):
        friend[a-1] +=1
        friend[b-1] +=1
    
for _ in range(k):
    c,d=map(int,input().split())
    if tree.same(c-1,d-1):
        block[c-1] +=1
        block[d-1] +=1
    
ans=[]
for i in range(n):
    l = tree.size(i) - block[i]  - friend[i]
    ans.append(l-1)
print(*ans)

Measured memory_bytes: 119768
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <algorithm>
using namespace std;

int main() {
  int N;
  cin >> N;
  int t[N];
  int x[N];
  int y[N];
  for(int i = 0;i < N;i++)
    cin >> t[i] >> x[i] >> y[i];
  bool b[N];
  for(int i = 0;i < N;i++)
  {
    b[i] = false;
    if(((x[i] + y[i]) % 2 == 0) && (t[i] % 2 == 0)){
      if(t[i] >= x[i] + y[i])
    //    if(x[i] <= N && y[i] <= N)
          b[i] = true;
    }
    if(((x[i] + y[i]) % 2 != 0) && (t[i] % 2 != 0)){
      if(t[i] >= x[i] + y[i])
      //s  if(x[i] <= N && y[i] <= N)
          b[i] = true;
    }
  }
  for(int i = 0;i < N;i++)
  {
    if(b[i] == false){
      cout << "No" <<'\n';
      return 0;
    }
  }
    cout << "Yes" <<'\n';
  return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
	ll t;
	cin >> t;
	int n;
	cin >> n;
	vector<pll> v;
	rep(i, n) {
		ll a, b;
		cin >> a >> b;
		v.pb({a, b});
	}
	vl sum(n+1);
	rep(i, n) sum[i+1] += sum[i] + v[i].se-v[i].fi;
	ll ans = 0LL;
	rep(i, n) {
		auto it = upper_bound(all(v), make_pair(v[i].fi+t, (ll)(1e18)));
		int idx = it - v.begin();
		idx--;
		ll tmp = sum[idx] - sum[i];
		tmp += max(0LL, min(v[idx].se, v[i].fi+t)-v[idx].fi);
		ans = max(ans, tmp);
		// cout << idx << endl;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5184
n=input()
L=len(n)-1
for i in range(2**L):
    tmp=["-"]*L
    for j in range(L):
        if((i>>j)&1):
            tmp[j]="+"
    F=""
    for num,sig in zip(n,tmp+[""]):
        F+=(num+sig)
    if eval(F)==7:
        print(F+"=7")
        break

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

bool prime(const int& x) {
    if (x <= 1) return false;
    for (int i = 2; i * i <= x; ++i) {
        if (x % i == 0) return false;
    }
    return true;
}

void func149c(){
    int N;
    cin >> N;

    while (!prime(N)) N++;
    cout << N << "\n";
}

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

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll temp;
    cin >> temp;
    if(temp >= 30)
    cout << "Yes" <<endl;
    else
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3656
from collections import deque
N, ta, ao = map(int, input().split())  # N頂点, 逃げ役の初期値u, 鬼役の初期値v
ta -= 1
ao -= 1
tree = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = map(lambda x: int(x)-1, input().split())
    tree[a].append(b)
    tree[b].append(a)
# これで木の構造が定義できた
takahashi_distant = [10**9] * N
aoki_distant = [10**9] * N

# 逃げ役の方 (高橋くん) から先に計算する
q = deque([ta])
takahashi_distant[ta] = 0
visited = [False] * N
visited[ta] = True
while len(q):
    v = q.pop()
    for e in tree[v]:
        if visited[e]:
            continue
        visited[e] = True
        takahashi_distant[e] = takahashi_distant[v] + 1
        q.append(e)

# 鬼役の方 (青木くんくん) の計算する
q = deque([ao])
aoki_distant[ao] = 0
visited = [False] * N
visited[ao] = True
while len(q):
    v = q.pop()
    for e in tree[v]:
        if visited[e]:
            continue
        visited[e] = True
        aoki_distant[e] = aoki_distant[v] + 1
        q.append(e)

# print(takahashi_distant)
# print(aoki_distant)
# aoki_distant[i] > takahashi_distant[i]を満たす時のaoki_distantの最大値-1
ans = 0
for i in range(N):
    if aoki_distant[i] > takahashi_distant[i]:
        ans = max(ans, aoki_distant[i])
print(ans-1)


Measured memory_bytes: 30196
import sys
import numpy as np

# 実行環境(0:vscode, 1:atcoder)
MODE = 1

# 入力の次元
DIMENSION = 0

# int型に変換
INT_TYPE = 0

if not (MODE):
    with open("input.txt", "r") as f:
        s = f.read()
else:
    s = sys.stdin.read()

if DIMENSION == 0:
    if INT_TYPE == 1:
        s = int(s)
elif DIMENSION == 1:
    if INT_TYPE == 0:
        s = s.split()
    elif INT_TYPE == 1:
        s = [int(x) for x in s.split()]
elif DIMENSION == 2:
    if INT_TYPE == 0:
        s = [x.split() for x in s.splitlines()]
    elif INT_TYPE == 1:
        s = [[int(y) for y in x.split()] for x in s.splitlines()]

if s.isupper():
    print("A")
else:
    print("a")


Measured memory_bytes: 27112
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 2 - 170;

int main() {
    ll h, w;
    cin >> h >> w;
    if(h*w % 3 == 0){
        cout << 0 << "\n";
        return 0;
    }
    ll ans = INF<ll>;
    for (int i = 0; i < 2; ++i) {
        for (int j = 1; j < h; ++j) {
            ll s1 = j*w;
            ll s2 = (h-j)*(w/2);
            ll s3 = h*w- (s1+s2);
            ans = min(ans, max({s1, s2, s3})- min({s1, s2, s3}));
        }
        for (int j = 1; j < h; ++j) {
            ll s1 = j*w;
            ll s2 = (h-j)/2*w;
            ll s3 = h*w- (s1+s2);
            ans = min(ans, max({s1, s2, s3})- min({s1, s2, s3}));
        }
        swap(h,w);
    }
    cout << ans << "\n";
    return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MAX=1e12;
ll mod=1e9+7;
#define pb push_back
#define se second
#define fi first
#define maxe max_element
#define mine min_element
#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;
#define debug4(x,y,z,w) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#w<<" :: "<<w<<endl;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define boost  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
vector<int> graph[205];
int color[205];
int nCk[100][100];
bool bipartite_jugding(int v, int c){
    color[v] = c;
    for(int i = 0; i < graph[v].size(); ++i){
        if(color[graph[v][i]] == c) return false;
        if(color[graph[v][i]] == 0 && !bipartite_jugding(graph[v][i], -c)){
            return false;
        }
    }
    return true;
}

 void combi() {
	for (int i = 0; i <= 99; ++i) nCk[i][0] = 1;
	for (int i = 1; i <= 99; ++i) for (int j = 1; j <= i; ++j) {
		nCk[i][j] = (nCk[i-1][j] + nCk[i-1][j-1]) % mod;
	}
}

long long expo(ll x,ll n,ll M)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return expo((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*expo((x*x)%M,(n-1)/2,M))%M;

}


void solve(){
   int n,m;
   cin>>n>>m;
   vector<int> re(100001,0);
   vector<int> v(100001,0);int ans=0;
   for(int i=0;i<m;i++)
   {
       int p;string s;
       cin>>p>>s;
       if(!v[p]){
         if(s=="AC"){
            v[p]=1;ans++;}
         else
            re[p]++;
       }
   }
   ll pe=0;
   for(int i=1;i<=n;i++)
    if(v[i])
    pe+=re[i];
   cout<<ans<<" "<<pe<<endl;

}

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


Measured memory_bytes: 1024
from itertools import accumulate
N = int(input())
a = list(map(int, input().split()))
a.sort()

b = list(accumulate(a))

ans = N
for i in range(N-1)[::-1]:
    if 2 * b[i] < a[i+1]:
        ans -= i+1
        break
        
print(ans)

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

const ll mod = 1000000007;
const double eps = 1e-8;

#ifdef DEBUG
#include "inc/debug.hpp"
#else
#define debug(...) 42
#endif

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i=0; i<N; ++i) cin >> A[i];

    ll r = 0;
    map<int,int> cnt;
    for (int i=0; i<N; ++i) {
        r += cnt[A[i]];
        cnt[A[i]]++;
    }

    for (int i=0; i<N; ++i) {
        cout << r-(cnt[A[i]]-1) << endl;
    }
    
    return 0;
}

Measured memory_bytes: 8320
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
struct UF
{
  vector<int> par;
  vector<int> sz;
  vector<int> rank;
  UF(int n):par(n),sz(n),rank(n){
    for(int i = 0; i < n; i++){
      par[i] = i;sz[i] = 1;rank[i] = 0;
    }
  }
  int find(int x) {
    if (par[x] == x) return x;
    else return par[x] = find(par[x]);
  }
  void merge(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return;
    if(rank[x] < rank[y]){
      par[x] = y;
      sz[y] += sz[x];
    }
    else{
      par[y] = x;
      sz[x] += sz[y];
      if(rank[x] == rank[y])rank[x]++;
    }
  }
  bool same(int x, int y) { return find(x) == find(y); }
  int size(int n){return sz[find(n)];}
};
vi block[200010];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,m,k;cin>>n>>m>>k;
  UF uni(n+10);
  vi fri(n+10);
 
  for(int i=0;i<m;i++){
    ll a,b;cin>>a>>b;
    b--;a--;
    uni.merge(a,b);
    fri[a]++;
    fri[b]++;
  }

  for(int i=0;i<k;i++){
    ll a,b;cin>>a>>b;
    a--;b--;
    block[a].pb(b);
    block[b].pb(a);
  }
  vi ans;
  for(int i=0;i<n;i++){
    ll sz = uni.size(i);
    sz -= fri[i];
    sz--;
    for(auto e:block[i]){
      if(uni.same(i,e)){
	sz--;
      }
    }
    ans.pb(sz);
  }
  for(auto aa:ans){
    cout<<aa<<" ";
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 11896
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
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; }
const ll INF=1LL<<60;
const int inf=1<<30;
const int mod=1e9+7;
vector<ll> v;
void f(ll t,int cnt){
    if(cnt>10){
        return;
    }
    int r=t%10;
    for(int i=-1;i<=1;i++){
        if(i+r>=0&&i+r<=9){
            v.push_back(t*10+i+r);
            f(t*10+i+r,cnt+1);
        }
    }
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int k;cin >> k;
    for(int i=1;i<=9;i++){
        v.push_back(i);
        f(i,1);
    }
    sort(v.begin(),v.end());
    cout << v[k-1] << endl;
}

Measured memory_bytes: 10604
//
//  main.cpp
//  atcoder - flowers
//
//  Created by r on 6/2/19.
//  Copyright © 2019 r. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <cstring>
#include <iomanip>
#include <fstream>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <stack>
#include <queue>
#include <assert.h>
#include <limits>
#include <cstdio>
using namespace std;

//#define RDEBUG 1
#ifdef RDEBUG
#define D(x) x
#else
#define D(x)
#endif
#define inf 0x7fffffff
#define MOD 1000000007

long long N, h[200010], a[200010], dp[200010];
long long t[900100];

long long findmax(long long v, long long tl, long long tr, long long l, long long r) {
    if (l > r)
        return numeric_limits<long long>::min(); // check negative numbers
    if (l == tl && r == tr) {
        return t[v];
    }
    long long tm = (tl + tr) / 2;
    return max(findmax(v*2, tl, tm, l, min(r, tm)) ,findmax(v*2+1, tm+1, tr, max(l, tm+1), r));
}


void updatemax(long long v, long long tl, long long tr, long long pos, long long new_val) {
    if (tl == tr) {
        t[v] = new_val;
    } else {
        long long tm = (tl + tr) / 2;
        if (pos <= tm)
            updatemax(v*2, tl, tm, pos, new_val);
        else
            updatemax(v*2+1, tm+1, tr, pos, new_val);
        t[v] = max(t[v*2], t[v*2+1]);
    }
}



int main() {
    ios_base :: sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> N;
    for (long long i = 0; i<N; i++) cin >> h[i];
    for (long long i = 0; i<N; i++) cin >> a[i];
    for (long long i = 0; i<N; i++) {
        dp[i] = a[i]+findmax(1, 1, N, 1, h[i]);
        updatemax(1, 1, N, h[i], dp[i]);
    }
    long long best = 0;
    for (int i = 0; i<N; i++) {
        best = max(best, dp[i]);
    }
    cout << best << endl;
    return 0;
}





Measured memory_bytes: 12032
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#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 VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int N){
    vector<int>S;
    rep(i,N)if(bit & (1<<i))S.push_back(i);
    return S;
}

int main(){
    int n;cin>>n;
    VEC(ll,a,n);
    VEC(ll,b,n);
    VEC(ll,c,n);
    sort(ALL(a));
    sort(ALL(b));
    sort(ALL(c));
    map<ll,ll>mp;
    rep(i,n){
        int lb = -1,ub = n;
        while(ub-lb>1){
            int mid = (ub+lb)/2;
            if(b[i]>=c[mid])lb = mid;
            else ub = mid;
        }
        mp[b[i]] += n-ub;
    }
    ll mem = 0;
    for(auto m : mp){
        mem += m.second;
        mp[m.first] = mem;
    }
    ll res = 0;
    rep(i,n){
        int lb = -1,ub = n;
        while(ub-lb>1){
            int mid = (ub+lb)/2;
            if(a[i]>=b[mid])lb = mid;
            else ub = mid;
        }
      //cout<<ub<<endl;
      if(n<=lb)continue;
        res += mem-mp[b[lb]];
    }
    cout<<res;
}



Measured memory_bytes: 8832
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a, b) ((a < b) ? a : b)
#define _max(a, b) ((a < b) ? b : a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a) ? 1 : -1)
#define SORT(v) sort(v.begin(), v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380
struct ST {
    int parent = -1;
    int memo = -1;
    int cnt;
};

vector<ST> p(200000);
int getParent(int idx) {
    if(p[idx].memo != -1)
        return p[idx].memo;
    if(p[idx].parent == -1)
        return p[idx].cnt;
    p[idx].memo = getParent(p[idx].parent) + p[idx].cnt;
    return p[idx].memo;
}

int main() {
    cout << fixed << setprecision(10);
    LLI N, Q;
    cin >> N >> Q;
    vector<int> cnt(N);
    REP(i, N - 1) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        p[b].parent = a;
    }
    REP(i, Q) {
        int p2, x;
        cin >> p2 >> x;
        p2--;
        p[p2].cnt += x;
    }
    REP(i, N) { cout << getParent(i) << " "; }
    return 0;
}

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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif

    ll N, D, A;
    cin >> N >> D >> A;
    vector<Pll> mos(N);
    for (int i = 0; i < N; i++) {
        cin >> mos[i].first >> mos[i].second;
    }

    sort(mos.begin(), mos.end());

    ll ans = 0;
    ll dmg = 0;
    queue<Pll> q;
    for (int i = 0; i < N; i++) {
        while (!q.empty()) {
            ll pos, d;
            tie(pos, d) = q.front();
            if (pos + D * 2 < mos[i].first) {
                dmg -= d;
                q.pop();
            }
            else {
                break;
            }
        }
        ll h = max(mos[i].second - dmg, 0LL);
        ll c = (h + A - 1) / A;
        ans += c;
        dmg += c * A;
        q.emplace(mos[i].first, c * A);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 6656
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
#define fore(i,x,y) for(ll i=(x);i<(y);i++)
#define disp(a) cout << a << endl;
typedef long long ll;
using namespace std;

bool compare_by_b(pair<string, int> a, pair<string, int> b) {
	if (a.second != b.second) {
		return a.second > b.second;
	}
	else {
		return a.first < b.first;
	}
}

int main()
{
	int N, R;
	cin >> N >> R;
	if (N < 10) {
		cout << R + 100 * (10 - N) << endl;
	}
	else {
		cout << R << endl;
	}

}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
#include<cassert>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};
#define ceil(a, b) a / b + !!(a % b)

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    string s, t; cin >> s >> t;
    int st = 1;
    ll ans = 3;
    if (s[0] != t[0]) {
        st = 2;
        ans = 6;
    }
    rrep(i, st, s.size()) {
        if (s[i] == t[i]) {
            if (s[i - 1] == t[i - 1]) {
                ans *= 2;
                ans %= (ll)(1e9 + 7);
            }
        } else {
            //i++ forbidden here
            if (s[i - 1] == t[i - 1]) {
                ans *= 2;
                ans %= (ll)(1e9 + 7);
            } else {
                ans *= 3;
                ans %= (ll)(1e9 + 7);
            }
            i++;
        }
    }
    cout << ans % (ll)(1e9 + 7) << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using Debug;
//using static System.Globalization.CultureInfo;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
        Solve();
        //WriteLine(Solve());
    }
    static void Solve()
    {
        var num = Input.num;
        var vs = Input.ar;
        var cs = Input.ar;
        var res = 0;
        for (var i = 0; i < num; i++)
            res += Max(vs[i] - cs[i], 0);
        WriteLine(res);
    }
}

public class Input
{
    public static string read => ReadLine();
    public  static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse);
    public  static int num => ToInt32(read);
    public static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse);
    public  static long numL => ToInt64(read);
    public static char[][] gred(int h) 
        => Enumerable.Repeat(0, h).Select(v => read.ToCharArray()).ToArray();
    public static int[][] ar2D(int num)
        => Enumerable.Repeat(0, num).Select(v => ar).ToArray();
    public static long[][] arL2D(int num)
        => Enumerable.Repeat(0, num).Select(v => arL).ToArray();
    public const long Inf = (long)1e18;
    public const double eps = 1e-6;
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}

Measured memory_bytes: 13140
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(){
	int count = 0;
	string w, t;
	cin >> w;
	transform(w.begin(), w.end(), w.begin(), ::tolower);
	while(cin >> t){
		if(t == "END_OF_TEXT") break;
		transform(t.begin(), t.end(), t.begin(), ::tolower);
		if(w == t) count++;
	}
	cout << count << endl;
	
	return 0;
}

Measured memory_bytes: 1192
#include <iostream>
#include <tuple>
#include <set>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>

typedef std::tuple<int, int, double> T;

std::vector<T> dis_city;
std::vector<int> num_basya;
int n, m, p, a, b;

std::vector<std::tuple<int,int>> table;
double cost[1<<8][30];


double search()
{
	for ( int i = 0; i < (1<<n); ++i ) {
		for ( int k = 0; k < m; ++k ) {
			cost[i][k] = 0xffff;
		}
	}
	cost[(1<<n)-1][a] = 0;
	double ans = 0xffff;

	std::priority_queue<std::tuple<double, int, int>, std::vector<std::tuple<double, int, int>>, std::greater<std::tuple<double, int, int>>> q;
	q.push(std::make_tuple(0, a, (1<<n)-1));
	while(!q.empty()) {
		double c = std::get<0>(q.top());
		int from = std::get<1>(q.top());
		int s = std::get<2>(q.top());
		q.pop();

		if ( from == b ) { ans = c; break; }
		for ( int i = 0; i < n; ++i ) {
			if ( s & (1<<i) ) {
				for ( int j = 0; j < dis_city.size(); ++j ) {
					if ( std::get<0>(dis_city[j]) == from ) {
						int to = std::get<1>(dis_city[j]);
						double f = c + std::get<2>(dis_city[j]) / num_basya[i];
						if ( cost[s ^ (1<<i)][to] > f ) {
							cost[s ^ (1<<i)][to] = f;
							q.push(std::make_tuple(f, to, s ^ (1<<i)));
						}
					}
				}
			}
		}
	}
	return ans;
}

int main(void)
{

	while(true) {
		dis_city.clear(); num_basya.clear();
		std::cin >> n >> m >> p >> a >> b;
		if ( n == 0 && m == 0 ) return 0;
		a--; b--;

		num_basya.resize(n);
		for ( auto &v: num_basya ) {
			std::cin >> v;
		}


		for ( int i = 0; i < p; ++i ) {
			int x, y, z;
			std::cin >> x;
			std::cin >> y;
			std::cin >> z;
			x--; y--;

			T t1(x,y,z), t2(y,x,z);
			dis_city.push_back(t1);
			dis_city.push_back(t2);
		}

		double ans = search();
		if ( ans > 65530 ) {
			std::cout << "Impossible" << std::endl;
		} else {
			printf("%.4f\n", ans);
		}
	}

	return 0;
}

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

int main() {
    int x, y;
    while(cin >> x >> y) {
        if (x == 0 && y == 0) {
            break;
        }
        else {
            if(x > y) {
                cout << y << " " << x << endl;
            }
            else {
                cout << x << " " << y << endl;
            }
        }
    }
    return 0;
}


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

int main (void){

    int N,i;
    scanf("%d",&N);
    double sum=0;
    int *X = (int*)malloc(sizeof(int)*N);
    for(i=0;i<N;i++){
        scanf("%d",&X[i]);
        sum += X[i];
    }

    double point = sum/N;
    point = (int)(point+0.5);

    int ans=0;
    for(i=0;i<N;i++){
        ans += (point-X[i])*(point-X[i]);
    }
    
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 128
n = int(input())
a = list(map(int, input().split()))
counter = 0
flag = True

while 1:
  for i in range(n):
    if a[i]%2 == 1:
      flag = False
      break
    else:
      a[i] = a[i]//2
      if i == n-1:
        counter += 1
  if flag == False:
  	break
  
print(counter)

Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
#define MAXSIZE 100010

int main()
{
    int a[MAXSIZE],n,num = 0,num1 = 0,num2 = 0;
    scanf("%d",&n);
    for(int i = 0;i < n;i++)
    {
        scanf("%d",&a[i]);
        if(a[i] % 4 == 0)
            num++;
        else
        {
            if(a[i] % 4 == 2)
                num2++;
            else
                num1++;
        }
    }
    if(num1 > num)
    {
        if(num1 == num + 1&&num2 == 0)
            printf("Yes\n");
        else
            printf("No\n");
    }
    else
        printf("Yes\n");
    return 0;
}


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

#include <cstdlib>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <cassert>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// head

//tourist head

#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pw(x) (1ll << (x))
////////////////////////////////////////////////////////////////////////

void read_input(){
	
}

void solve(){
	
}

int main(){
	string s;
	getline(cin,s);
	s[3] = '8';
	cout<<s<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define mod 1000000007
using namespace std;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define all(arr) arr.begin() , arr.end()
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define rep(i , a , n) for(int i = a ; i < n ; i++)
#define rrep(i , n , a) for (int i = n - 1 ; i >= a ; i--)
#define ms(arr , val) memset(arr , val , sizeof(arr))
#define siz(temp) temp.size()
#define len(temp) temp.length()
#define timepass 1073741824
#define int ll

ll modexpo(ll a , ll b)
{
    ll res = 1;
    while(b > 0)
    {
        if(b&1)
            res = (res*a)%mod;
        a=(a*a)%mod;
        b >>=1;
    }
    return res;
}
ll expo(ll a , ll b)
{
    ll res = 1;
    while(b > 0)
    {
        if(b&1)
            res = (res*a);
        a=(a*a);
        b >>=1;
    }
    return res;
}
ll gcd(ll a , ll b)
{
    if (a == 0)
        return b;
    return gcd(b%a , a);
}

bool isPrime(ll n)
{
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;
    if (n%2 == 0 || n%3 == 0)
        return false;
    for (int i = 5 ; i*i <= n ; i+=6)
    {
        if ((n%i==0) || (n%(i + 2) == 0))
            return false;
    }
    return true;
}

ld dist(ll x1 , ll y1 , ll x2 , ll y2)
{
    return (ld)sqrt((long double)((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2)));
}
ll squaredist(ll x1 , ll y1 , ll x2 , ll y2)
{
    return ((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2));
}
ll nCr(ll n , ll r)
{
    if(r == 0)
        return 1;
    return (n*nCr(n - 1 , r - 1))/r;
}

signed main()
{
    int n;
    cin >> n;
    vector<ll> arr(n , 0),arr1(n , 0);
    rep(i , 0 , n)
        cin >> arr[i];
    arr1 = arr;
    sort(all(arr));
    int c=0;
    for (int i = 0 ; i < n ; i++)
        if (arr[i] != arr1[i])
            c++;
    if (c <= 2)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256