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

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define f(i,a,b) for(int i=a;i<b;i++)
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
int ketasuu(int x){
  int n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}


ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

int main(){
  int h,a ;
  cin>>h>>a;
  if(h%a ==0) cout<< h/a<<endl;
  else cout<<h/a+1<<endl; 
  
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;
#define White 0
#define Black 1
static const int MAX=100;

int C[MAX],d[MAX],f[MAX];
vector<int> adj[MAX];
void init(){
    rep(i,MAX)C[i]=White;
}
int tt=0;
void solve(int node){
    d[node]=++tt;
    C[node]=Black;
    for(int x:adj[node]){
        if(C[x]==White)solve(x);
    }
    f[node]=++tt;
    return;
}

int main(){
    int n;cin>>n;
    init();
    rep(i,n){
        int id,k,node;
        scanf("%d %d",&id,&k);
        id--;
        rep(j,k){
            scanf("%d",&node);
            node--;
            adj[id].push_back(node);
        }
    }
    rep(i,n){
        if(C[i]==White)solve(i);
    }
    rep(i,n){
        printf("%d %d %d\n",i+1,d[i],f[i]);
    }
    return 0;
}


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

namespace ABC128_A
{
    class Program
    {
        static void Main(string[] args)
        {
            var AP = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var A = AP[0];
            var P = AP[1];

            Console.WriteLine((A*3+P)/2);
        }
    }
}


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

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  if(a+b==c||b+c==a||c+a==b){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <complex>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <iomanip>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second
#define Pqaz(T) priority_queue<T,vector<T>,greater<T>>
#define Pqza(T) priority_queue<T>
#define put(x) cout << x;
#define putsp(x) cout << x << ' ';
#define putln(x) cout << x << endl;
#define ENJYU std::ios::sync_with_stdio(false);std::cin.tie(0);

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef complex<double> comp;
typedef vector <int> vec;
typedef vector <ll> vecll;
typedef vector <double> vecd;
typedef vector <vec> mat;
typedef vector <vecll> matll;
typedef vector <vecd> matd;

//vector の中身を出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

const int MAX = 200000;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const int MOD = 1000000007;

void solve(void){
	int N;
	while (cin >> N && N) {

		mat tmat(N, vec(N+1, 0));

		vec dp(1<<N, INF);

		rep(N, i) rep(N+1, j)
		{
			cin >> tmat[i][j];
		}

		dp[0] = 0;

		rep((1<<N), bit)
		{
			rep(N, i)
			{
				if (bit >> i & 1)
				{
					int tmp = tmat[i][0];
					rep(N, j)
					{
						if (bit >> j & 1 && i != j)
						{
							tmp = min(tmp, tmat[i][j+1]);
						}
					}
					dp[bit] = min(dp[bit], dp[bit ^ 1 << i] + tmp);
				}
			}
		}

		cout << dp[(1<<N)-1] << endl;

	}


}

int main(void){
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}



Measured memory_bytes: 3260
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        
        int ans = 0;
        int num = 1;
        for (int i = 0; i < n; i++) {
            if(a[i] == num) {
                num++;
            } else {
                ans++;
            }
        }
        if(ans == n) {
            System.out.println(-1);
        } else {
            System.out.println(ans);
        }
    }
}


Measured memory_bytes: 60592
#include <cstdio>

int main() {
    int N;
    scanf("%d", &N);
    for(int n=1;n<=N;n++) {
        int ans = 0;
        for(int x=1;x*x<=n;x++) {
            for (int y=1;y*y<=n;y++) {
                int a = x*x+y*y+1*1+x*y+y*1+1*x;
                if(a>n) {
                    break;
                }
                for(int z=1;z*z<=n;z++) {
                    int v = x*x+y*y+z*z+x*y+y*z+z*x;
                    if(v>n) {
                        break;
                    }
                    if(v==n) {
                        ans++;
                    }
                }
            }
        }
        printf("%d\n", ans);
    }
}

Measured memory_bytes: 1724
#include<iostream>
#include<algorithm>
int A[111000];
int B[111000];
using namespace std;

int main()
{
    int n;
    cin>>n;
    int num = 0;
    for(int i=0;i<n;i++)
    {
        cin>>A[i];
        
        if(A[i] < 0)
        {
            B[i] = -A[i];
            num++;
        }
        else
        {
            B[i] = A[i];
        }
    }
    sort(B,B+n);
    long long sum = 0;
    for(int i=0;i<n;i++)
        sum = sum + B[i];
    if(num%2 != 0)
        sum = sum - B[0] *2;
    cout<<sum;
}

Measured memory_bytes: 1024
#dt = {} for i in x: dt[i] = dt.get(i,0)+1
import sys;input = sys.stdin.readline
inp,ip = lambda :int(input()),lambda :[int(w) for w in input().split()]

n = inp()
ct = n-1
for i in range(2,n):
        ct += (n-1)//i
print(ct)

Measured memory_bytes: 63100
f=lambda:map(int,input().split())
n,d,a=f()
lt=sorted(tuple(f()) for _ in range(n))
from collections import *
q=deque()
c=s=0
for x,h in lt:
  while q and q[0][0]<x: s+=q.popleft()[1]
  h-=s
  if h<1: continue 
  t=-h//a; c-=t; s-=t*a; q.append((x+d*2,t*a))
print(c)

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

char s[20][21];
int d[20][20];
int dx[]{ 0,-1,0,0,1 }, dy[]{ 0,0,1,-1,0 };

int main() {
	int h, w;
	while (scanf("%d%d", &h, &w), h) {
		int ax, ay, bx, by;
		rep(i, h) {
			scanf("%s", s[i]);
			rep(j, w) {
				if (s[i][j] == 'A')ax = i, ay = j;
				if (s[i][j] == 'B')bx = i, by = j;
			}
		}
		string p; cin >> p;
		for (char&c : p) {
			if (c == '5')c = 0;
			if (c == '8')c = 1;
			if (c == '6')c = 2;
			if (c == '4')c = 3;
			if (c == '2')c = 4;
		}
		queue<P>que;
		memset(d, -1, sizeof(d));
		d[ax][ay] = 0; que.push(P(ax, ay));
		while (!que.empty()) {
			P p = que.front(); que.pop();
			for (int i = 1; i <= 4; i++) {
				int nx = p.first + dx[i], ny = p.second + dy[i];
				if (0 <= nx&&nx < h && 0 <= ny&&ny < w&&s[nx][ny] != '#'&&d[nx][ny] == -1) {
					d[nx][ny] = d[p.first][p.second] + 1;
					que.push(P(nx, ny));
				}
			}
		}
		int x = bx, y = by;
		int t = 0;
		rep(i, 100) {
			for (char c : p) {
				if (d[x][y] != -1 && d[x][y] <= t) {
					printf("%d %d %d\n", t, x, y); goto g;
				}
				int nx = x + dx[c], ny = y + dy[c]; t++;
				if (0 <= nx&&nx < h && 0 <= ny&&ny < w)x = nx, y = ny;
			}
		}
		puts("impossible");
	g:;
	}
}

Measured memory_bytes: 3328
using System;
using System.IO;
using System.Collections;
using System.Collections.Generic;
using System.Text;

namespace Competitive_Programming
{
	class MainClass
	{
		static long f(long b, long n)
		{
			if (n < b) return n;
			return f(b, n / b) + (n % b);
		}

		public static void Main(string[] args)
		{
			long n = long.Parse(Console.ReadLine());
			long s = long.Parse(Console.ReadLine());
			long ans = (long)1e18;
			if (n < s)
			{
				Console.WriteLine(-1);
				return;
			}
			if (n == s)
			{
				Console.WriteLine(n + 1);
				return;
			}
			for (long i = 2; i * i <= n; i++)
			{
				if (f(i, n) == s)
				{
					ans = Math.Min(ans, i);
				}
			}
			for (long i = 1; i * i <= n; i++)
			{
				if ((n - s) % i != 0) continue;
				long b = ((n - s) / i) + 1;
				if (f(b, n) == s)
				{
					ans = Math.Min(ans, b);
				}
			}
			if (ans == (long)1e18)
			{
				ans = -1;
			}
			Console.WriteLine(ans);
		}
	}
}


Measured memory_bytes: 2648
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	int N;
	
	while (scanf("%d", &N) && N){
		pair<int, int> a[1024];
		for (int i = 0; i < N; i++){
			scanf("%d %d", &a[i].first, &a[i].second);
		}
		
		sort(a, a + N);
		
		int sum = 0, ans = 0;
		for (int i = 0; i < N - 1; i++) sum += a[i].first;
		for (int i = 0; i < N; i++) ans += a[i].first + a[i].second;
		
		if (sum >= a[N - 1].first){
			printf("%d\n", ans);
		}
		else {
			bool dp[1001] = {false};
			dp[0] = true;
			int spend = 0;
			for (int i = 0; i < N - 1; i++){
				for (int j = a[N - 1].first - sum; j >= a[i].second; j--){
					dp[j] |= dp[j - a[i].second];
					if (dp[j]) spend = max(spend, j);
				}
			}
			printf("%d\n", ans + a[N - 1].first - sum - spend);
		}
	}
	
	return (0);
}

Measured memory_bytes: 1036
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<algorithm>
#include<queue>
#include<vector>
#include<map>
#include<set>
#define ll long long
#define ull unsigned long long
#define mod 100000000
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define lowbit(x) (x& -x)
#define inf 0x3f3f3f3f
#define eps 1e-18
#define maxn 2000010
inline ll read(){ll tmp=0; char c=getchar(),f=1; for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1; for(;'0'<=c&&c<='9';c=getchar())tmp=(tmp<<3)+(tmp<<1)+c-'0'; return tmp*f;}
inline ll power(ll a,ll b){ll ans=1; for(;b;b>>=1){if(b&1)ans=ans*a%mod; a=a*a%mod;} return ans;}
inline ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
inline void swap(int &a,int &b){int tmp=a; a=b; b=tmp;}
using namespace std;
int sum[510][510];
int n,m,q;
int main()
{
	n=read(); m=read(); q=read();
	for(int i=1;i<=m;i++){
		int l=read(),r=read();
		++sum[l][r];
	}
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			sum[i][j]+=sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1];
	for(int i=1;i<=q;i++){
		int p=read(),q=read();
		printf("%d\n",sum[q][q]-sum[p-1][q]-sum[q][p-1]+sum[p-1][p-1]);
	}
}

Measured memory_bytes: 1792
#include<iostream>
#include <iomanip>
using namespace std;
 
int main(){
    
    int a, b, d, r;
    double f;
    
    cin >> a >> b;
    
    d = a / b;
    r = a % b;
    f = 1.0 * a / b;
    
    cout << d << " " << r << " ";
    cout << fixed << setprecision(6) << f << endl; 
    
    return 0;		 
}



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

int n,m;
bool map[90][90];

int backtrack(int h,int w){
  int res = 1,tmp = 1;

  map[h][w] = false;
  if(h>0 && map[h-1][w])tmp = backtrack(h-1,w) + 1;
  res = max(res,tmp);
  if(h<n-1 && map[h+1][w])tmp = backtrack(h+1,w) + 1;
  res = max(res,tmp);
  if(w>0 && map[h][w-1])tmp = backtrack(h,w-1) + 1;
  res = max(res,tmp);
  if(w<m-1 && map[h][w+1])tmp = backtrack(h,w+1) + 1;
  res = max(res,tmp);
  map[h][w] = true;

  return res;
}

int main(){
  int maxim;
  while(1){
    cin >> m;
    cin >> n;
    if(!m && !n)break;

    for(int i=0;i<n;i++){
      for(int j=0;j<m;j++)cin >> map[i][j];
    }
    maxim = 0;
    for(int i=0;i<n;i++){
      for(int j=0;j<m;j++){
	if(map[i][j])maxim = max(maxim,backtrack(i,j));
      }
    }

    cout << maxim << endl;
  }
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
using ll=long long;
#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) ((int)x.size())
#define fi first
#define se second
const int INF = 1e15;
using namespace std;

template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;

using pi=pair<int,int>;
using vi=vc<int>;

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;}

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

    vi a={1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51};
    int k; cin >> k;
    cout << a[k-1] << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
auto TopologicalSort(Int n, vector<vector<pair<Int,Int>>>&edge){
    vector<bool>v(n,false);
    vector<Int>out(n);
    int idx = n-1;
    function<void (Int)>dfs = [&](Int u) -> void{
        v[u] = true;
        for(int i = 0; i < edge[u].size();i++){
            Int nv = edge[u][i].first;
            if(!v[nv])dfs(nv);
        }
        out[idx--] = u;
    };
    for(int i = 0; i < v.size();i++){
        if(!v[i])dfs(i);
    }
    return out;
}
signed main(){
    Int N,M; cin >> N >> M;
    vector<vector<pair<Int,Int>>>edge(N);
    for(int i = 0; i < M; ++i){
        Int l,r,d;
        cin >> l >> r >> d;
        --l; --r;
        edge[l].emplace_back(r,d);
    }
    auto out = TopologicalSort(N,edge);
    vector<bool>visit(N,false);
    vector<Int>d(N,-1LL);
    bool valid = true;
    std::function<void(Int )>dfs =[&](Int v){
        visit[v] = true;
        for(auto p : edge[v]){
            Int nxt = p.first;
            Int cst = p.second;
            if(d[nxt] == -1){
                d[nxt] = d[v] + cst;
                dfs(nxt);
            } else if(d[nxt] != d[v] + cst){
                valid = false;
            }
        }
        return;
    };
    for(auto v : out){
        if(not visit[v]) {
            d[v] = 0;
            dfs(v);
        }
    }
    cout << (valid ? "Yes" : "No") << endl;
}


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

int main(){
  int l,r;
  cin>> l >> r;
 
  int ans=2019;
  if (r-l+1 >= 2019) ans=0;
  else {
    for (int i=l; i<r; i++){
      for (int j=i+1; j<=r; j++){
        ans=min((i%2019)*(j%2019)%2019,ans);
      }
    }
  }
  cout<< ans <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1005;
const int mod=1000000007;
int n,k,a[maxn];
ll f[21][maxn],c[maxn][maxn];
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=0;i<k;i++) scanf("%d",&a[i]);
	for(int i=0;i<=n;i++)
	{
		c[i][0]=1;
		for(int j=1;j<=i;j++)
			c[i][j]=(c[i-1][j]+c[i-1][j-1])%mod;
	}
	f[0][0]=1;
	for(int i=0;i<k;i++)
		for(int j=0;j<=n;j++)
			for(int l=0;l<=min(a[i],n-j);l++)
				f[i+1][j+l]=(f[i+1][j+l]+f[i][j]*c[n-j][l]%mod*c[n-l][a[i]-l])%mod;
	printf("%lld\n",f[k][n]);
	return 0;
}

Measured memory_bytes: 7552
# coding: utf-8


def main():
    k, x = map(int, input().split(" "))
    saidai = x + k-1
    saishou = x - k + 1
    r = ""
    for i in range(saishou, saidai+1):
        r = r + str(i) + " "
    print(r[0:-1])

main()

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using Int = long long int;
using namespace std;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    Int n, k;
    char s[100000];
    cin >> n >> k;
    cin >> s;
    
    Int cnt = 0;
    for(Int i=1; i<n; i++){
        if(s[i-1] == s[i]) cnt++;
    }
    cout << min(n-1, cnt + 2*k) << endl;
    return 0;
}

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

int main() {
	int n;
	cin >> n;
	double syojikinn = 0;
    double ans = syojikinn;
	double BTCmp = 380000.0;
	vector<double>X(n);
	vector<string>U(n);

	for (int i = 0; i < n; i++) {
		cin >> X[i];
		cin >> U[i];
		if (U[i] == "BTC"){
			ans += X[i] * BTCmp;
		}
		if (U[i] == "JPY") {
			ans += X[i];
		}
	}

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


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <string>
#include <typeinfo>
#include <random>
#include <vector>
//#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;

#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define all(a) (a).begin(), (a).end()

int main()
{
  int x;
  cin >> x;
  int ans = 0;
  int tmp;
  for (int i = 1; i <= x; i++)
  {
    for (int j = 2;; j++)
    {
      tmp = pow(i, j);
      if (i == 1)
      {
        ans = max(ans, tmp);
        break;
      }
      if (tmp > x)
      {
        break;
      }
      ans = max(ans, tmp);
    }
  }
  cout << ans << endl;
  return 0;
}

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

using ll = long long;
using P = pair<int, int>;

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

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

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

  int ans;
  if (400 <= x && x < 600) {
    ans = 8;
  } else if (x < 800) {
    ans = 7;
  } else if (x < 1000) {
    ans = 6;
  } else if (x < 1200) {
    ans = 5;
  } else if (x < 1400) {
    ans = 4;
  } else if (x < 1600) {
    ans = 3;
  } else if (x < 1800) {
    ans = 2;
  } else {
    ans = 1;
  }

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


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define ULL(...) ull __VA_ARGS__;in(__VA_ARGS__)
#define STR(...) string __VA_ARGS__;in(__VA_ARGS__)
#define CHR(...) char __VA_ARGS__;in(__VA_ARGS__)
#define DBL(...) double __VA_ARGS__;in(__VA_ARGS__)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);in(name)
#define vv(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define VV(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__));in(name)
#define vvv(type,name,h,w,...) vector<vector<vector<type>>>name(h,vector<vector<type>>(w,vector<type>(__VA_ARGS__)))
inline int scan(){ return getchar(); }
inline void scan(int &a){ scanf("%d", &a); }
inline void scan(unsigned &a){ scanf("%u", &a); }
inline void scan(long &a){ scanf("%ld", &a); }
inline void scan(long long &a){ scanf("%lld", &a); }
inline void scan(unsigned long long &a){ scanf("%llu", &a); }
inline void scan(char &a){ cin >> a; }
inline void scan(float &a){ scanf("%f", &a); }
inline void scan(double &a){ scanf("%lf", &a); }
inline void scan(long double &a){ scanf("%Lf", &a); }
inline void scan(vector<bool> &vec){ for(unsigned i = 0; i < vec.size(); i++) { int a; scan(a); vec[i] = a; } }
inline void scan(string &a){ cin >> a; }
template<class T> inline void scan(vector<T> &vec);
template<class T, size_t size> inline void scan(array<T, size> &vec);
template<class T, class L> inline void scan(pair<T, L> &p);
template<class T, size_t size> inline void scan(T (&vec)[size]);
template<class T> inline void scan(vector<T> &vec){ for(auto &i : vec) scan(i); }
template<class T, size_t size> inline void scan(array<T, size> &vec){ for(auto &i : vec) scan(i); }
template<class T, class L> inline void scan(pair<T, L> &p){ scan(p.first); scan(p.second); }
template<class T, size_t size> inline void scan(T (&vec)[size]){ for(auto &i : vec) scan(i); }
template<class T> inline void scan(T &a){ cin>>a; }
inline void in(){}
template <class Head, class... Tail> inline void in(Head &head, Tail&... tail){ scan(head); in(tail...); }
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using Graph = vector<vector<int>>;
/* 4方向への隣接頂点への移動を表すベクトル */
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

const long long INF = 1LL << 60;
int main(){
    STR(s);
    if(s[1] == 'B'){
        cout << "ARC" << endl;
    } else {
        cout << "ABC" << endl;
    }
   
}

Measured memory_bytes: 3584
k, t = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
while len(a) > 1:
    a[-1] -= 1
    a[-2] -= 1
    if a[-1] == 0:
        a.pop(-1)
        if a[-1] == 0:
            a.pop(-1)
    else:
        if a[-2] == 0:
            a.pop(-2)
    a.sort()
if len(a) == 1:
    print(a[0]-1)
else:
    print(0)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
 
using namespace std;
 
int main()
{
    string s;
    getline(cin, s);
    transform(s.begin(), s.end(), s.begin(), ::toupper);
    string t = s.substr(s.find(" ") + 1);
 
    if ((s[s.find(" ") - 1] == s[s.find(" ") + 1]) && (t[t.find(" ") - 1] == t[t.find(" ") + 1])){
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
}

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

using namespace std;

void writeTime(int hour, int min, int sec) {
	if (sec < 0) {
		min--;
		sec += 60;
	}

	if (min < 0) {
		hour--;
		min += 60;
	}


	cout << hour << " " << min << " " << sec << endl;

	return;
}


int main(){

	int ah, am, as, bh, bm, bs;

	for (int i = 0; i < 3; i++) {
		cin >> ah >> am >> as >> bh >> bm >> bs;
		int rs = bs - as;
		int rm = bm - am;
		int rh = bh - ah;

		writeTime(rh, rm, rs);
	}


//system("pause");
    return 0;
}




Measured memory_bytes: 3080
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
#include <array>
#include <numeric>
#include <regex>
#include <bitset>
#include <deque>
#include <cassert>

using namespace std;
using ll = long long;

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << #x << ": " << x << endl;


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

	for (int fi = 0; fi < 2; fi++) {
		for (int adj = 0; adj < 2; adj++) {
			vector<string> animal(N + 1, "?");
			vector<string> r_animal(N + 1, "?");

			if (fi == 0) {
				animal[0] = "S";
				animal[N] = "S";
				if (s[0] == 'o') {
					if (adj == 0) {
						animal[1] = "S"; animal[N-1] = "S";
					}
					else {
						animal[1] = "W"; animal[N-1] = "W";
					}
				}
				else {
					if (adj == 0) {
						animal[1] = "S"; animal[N-1] = "W";
					}
					else {
						animal[1] = "W"; animal[N-1] = "S";
					}
				}
			}
			else if (fi == 1) {
				animal[0] = "W";
				animal[N] = "W";
				if (s[0] == 'o') {
					if (adj == 0) {
						animal[1] = "S"; animal[N-1] = "W";
					}
					else {
						animal[1] = "W"; animal[N-1] = "S";
					}
				}
				else {
					if (adj == 0) {
						animal[1] = "S"; animal[N-1] = "S";
					}
					else {
						animal[1] = "W"; animal[N-1] = "W";
					}
				}
			}

			//*************以上初期化***************
			bool flg = true;
			for (int i = 1; i < N; i++) {
				if (animal[i] == "S") {
					if (animal[i + 1] != "?") {
						if (s[i] == 'o') {
							if (animal[i + 1] != animal[i - 1]) {
								flg = false;
								break;
							}
						}
						else {
							if (animal[i + 1] == animal[i - 1]) {
								flg = false;
								break;
							}
						}
					}
					else {
						if (s[i] == 'o') {
							animal[i + 1] = animal[i - 1];
						}
						else {
							animal[i + 1] = (animal[i - 1] == "S") ? "W" : "S";
						}
					}
				}
				else {
					if (animal[i + 1] != "?") {
						if (s[i] == 'o') {
							if (animal[i + 1] == animal[i - 1]) {
								flg = false;
								break;
							}
						}
						else {
							if (animal[i + 1] != animal[i - 1]) {
								flg = false;
								break;
							}
						}
					}
					else {
						if (s[i] == 'o') {
							animal[i + 1] = (animal[i - 1] == "S") ? "W" : "S";
						}
						else {
							animal[i + 1] = animal[i - 1];
						}
					}
				}
			}

			if (!flg)continue;
			else {
				for (int i = 0; i < N; i++) {
					cout << animal[i];
				}
				cout << endl;
				return 0;
			}
		}
	}

	cout << -1 << endl;

	return 0;
}

Measured memory_bytes: 4372
#include "bits/stdc++.h"
using namespace std;
#define mod 1000000007
#define all(c) begin(c),end(c)
template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
using ll = long long;
using vi = vector<int>; using vs = vector<string>;
int dd[] = { 0, 1, 0, -1, 0 }; //→↓←↑

void solve()
{
	int N;
	cin >> N;
	vi A(N + 2);
	A[0] = 0;
	ll sum = 0;
	for (int i = 1; i <= N; i++)
	{
		cin >> A[i];
	}
	A[N + 1] = 0;
	for (int i = 1; i <= N + 1; i++)
	{
		sum += abs(A[i] - A[i - 1]);
	}

	for (int i = 1; i <= N; i++)
	{
		cout << sum - (abs(A[i] - A[i - 1]) + abs(A[i] - A[i + 1])) + abs(A[i - 1] - A[i + 1]) << endl;
	}
}

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

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

int main()
{
    int A, B;
    cin >> A >> B;

    if (A != 1 && B != 1)
    {
        cout << 1;
    }

    if (A != 2 && B != 2)
    {
        cout << 2;
    }

    if (A != 3 && B != 3)
    {
        cout << 3;
    }
    
    
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <vector>
using namespace std;
#define ll long long
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define lowbit(x) (x & -x)
#define lrt nl, nr, rt << 1
#define rrt nl, nr, rt << 1 | 1
const ll Inf = 1e18;
const int inf = 0x3f3f3f3f;
inline int read()
{
	int x = 0, f = 1;
	char ch = getchar();
	while (!isdigit(ch)) { if (ch == '-') f = -1; ch = getchar(); }
	while (isdigit(ch)) { x = x * 10 + ch - '0'; ch = getchar(); }
	return f * x;
}

int main(void)
{
	int n, a;
	cin >> n >> a;
	cout << n * n - a << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=mod*mod*3LL;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    m1 += h1 * 60;
    m2 += h2 * 60;
    cout << m2 - m1 - k << endl;
    return 0;
}


Measured memory_bytes: 3652
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
 
using ull = unsigned long long int;
using ll = long long int;
using du = double;
using ld = long du;
using vi = vector<int>;
using vll = vector<ll>;
using vld = vector<ld>;
using vdu = vector<du>;
using vs = vector<string>;
using vc = vector<char>;
using si = set<int>;
using sll = set<ll>;
using sdu = set<du>;
using sld = set<ld>;
using pii = pair<int, int>;
using pll = pair<ll,ll>;
using pdu = pair<du,du>;
using pld = pair<ld,ld>;
using pis = pair<int,string>;
 
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define sp(x) setprecision(x)<<fixed
#define loop(i,n) for(int i=0;i<n;i++)
#define ff first
#define ss second
#define pi acos(-1)
#define meme(a,x) memset(a,x,sizeof(a))
 
//debugger
 
#ifdef KAIZER
#include "debug.h"
#else
#define debug(x...)
#endif
//debugger
 
//functions
bool check_pow(ll a)
{
    if((a&(a-1))==0) return true;
    else return false;
}
ld my_pow(ld a,int b)
{
    ld ans=1;
    for(int i=0;i<b;i++) ans*=a;
    return ans;
}
ll digits(ll a)
{
    string line=to_string(a);
    return line.size();
}
bool prime_check(ll a)
{
    bool flag=true;
    for(ll i=2;i<=sqrt(a);i++)
    {
        if(a%i==0) {flag=false; break;}
    }
    return flag;
}
bool comp(const ll &a , const ll &b)
{
    return a>b;
}
const ll xyz=2e5+10;
ll fact[xyz];
void mod_fact(ll m=1)
{
    fact[0]=1;
    loop(i,(2e5)) 
    {
        ll p=i+1;
        //if(p%2==0) p/=2;
        fact[i+1]=(((fact[i])%m)*(p%m))%m;
    }
}

//functions


int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    FASTIO;
    int a,b;
    cin>>a>>b;
    ll n=1;
    ll ans=0;
    while(n<b)
    {
        n+=(a-1);
        ans++;
    }
    cout<<ans<<endl;
}
 

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

using namespace std;

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

#define each(i,a) for (auto&& i : a)
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    each(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    rep(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, const vector< vector<T> >& vec) {
    rep(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}

ll f(ll n) {
    return n * (n+1) * (n+2) / 6;
}
vector<ll> make_dp(const vector<ll>& v, ll n) {
    vector<ll> dp(n+1, linf);
    dp[0] = 0;
    rep(i, v.size()) rep(j, n+1) {
        ll nj = j + v[i];
        if (nj <= n) chmin(dp[nj], dp[j]+1);
    }
    return dp;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    vector<ll> v1, v2;
    for (ll i = 1; f(i) <= ll(1e6); ++i) {
        v1.pb(f(i));
        if (f(i) % 2 == 1) v2.pb(f(i));
    }
    vector<ll> dp1 = make_dp(v1, ll(1e6));
    vector<ll> dp2 = make_dp(v2, ll(1e6));
    while (cin >> n, n) {
        cout << dp1[n] << " " << dp2[n] << endl;
    }
}

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

const int MAXH = 8;
const int MAXW = 8;
const int di[] = {0,1,0,-1};
const int dj[] = {1,0,-1,0};

int h, w, c;
int p[10][MAXH][MAXW];
int ans;

int dfs(int i, int j, int a, int b, int g[MAXH][MAXW]) {
  g[i][j] = b;
  int res = 1;
  for(int k = 0; k < 4; ++k) {
    int ni = i + di[k];
    int nj = j + dj[k];
    if(ni < 0 || ni >= h) continue;
    if(nj < 0 || nj >= w) continue;
    if(g[ni][nj] != a) continue;
    res += dfs(ni, nj, a, b, g);
  }
  return res;
}

void rec(int k) {
  if(k+1 == 5) {
    if(p[k][0][0] != c) {
      copy(p[k][0], p[k+1][0], p[k+1][0]);
      dfs(0, 0, p[k+1][0][0], 0, p[k+1]);
      dfs(0, 0, 0, c, p[k+1]);
      ans = max(ans, dfs(0, 0, c, 0, p[k+1]));
    }
    return;
  }
  for(int b = 1; b <= 6; ++b) {
    copy(p[k][0], p[k+1][0], p[k+1][0]);
    dfs(0, 0, p[k+1][0][0], 0, p[k+1]);
    dfs(0, 0, 0, b, p[k+1]);
    rec(k+1);
  }
}

int main() {
  while(cin >> h >> w >> c && (h|w|c)) {
    for(int i = 0; i < h; ++i) {
      for(int j = 0; j < w; ++j) {
        cin >> p[0][i][j];
      }
    }
    ans = 0;
    rec(0);
    cout << ans << endl;
  }
  return 0;
}

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

using namespace std;

int main(){
    int n;
    cin>>n;
    vector<int> l(n);
    int ma = 0;
    for(int i=0;i<n;i++){
        cin>>l[i];
    }
    sort(l.begin(),l.end(),greater<int>());

    int sum=0;
    for(int i=1;i<n;i++){
        sum += l[i];
    }
    if(sum>l[0])
        cout<<"Yes";
    else
        cout<<"No";
}


Measured memory_bytes: 256
from math import sqrt


def main():
    x, y = input().split()
    n = int(x + y)
    # print(n)

    for i in range(int(sqrt(n)) + 1):
        # print(i, i * i)
        if i * i == n:
            print("Yes")
            return
    print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
 
#define NL '\n'
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define ll long long
#define sz(x) x.size()
#define all(x) (x).begin(), (x).end()
#define mem(a, b) memset(a, b, sizeof(a))
#define rep(i,a,b) for(ll i=(ll)a;i<(ll)b;++i)
#define async() ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
 
//#define _debug 
void d(){cerr<<NL;}template<typename H,typename... T> void d(H h,T... t){cerr<<' '<<h;d(t... );}
#ifdef  _debug
#define debug(...) cerr<<"("<<#__VA_ARGS__<<"):",d(__VA_ARGS__)
#else
#define debug(...) 
#endif

const ll N = 43;
ll n, k, x, l = 41, cnt[N], dp[N][2];

ll f(ll pos, bool status){
	ll cur = !!(k&(1LL<<(l-pos)));
	if(pos == l) {
		if(status) {
			if(cur == 1) return max(cnt[0], n - cnt[0]);
			return cnt[0];
		}
		return max(cnt[0], n - cnt[0]);
	}
	ll &ret = dp[pos][status];
	if(ret > -1LL) return ret;
	ll m = (1LL << (l-pos)), val = 0;
	if(status) {
		if(cur == 0) val = m*cnt[l-pos] + f(pos + 1, true);
		else val = max(m*cnt[l-pos]+f(pos+1, false), m*(n-cnt[l-pos])+f(pos+1, true));
	}
	else val = max(m*cnt[l-pos]+f(pos+1, false), m*(n-cnt[l-pos])+f(pos+1, false));
	return ret = val;
}

int main() {
	async();
	mem(dp, -1LL);
	cin >> n >> k; 
	rep(ix, 0, n) {cin >> x; for(ll i = N - 1; i >= 0;i--) if(x&(1LL<<i)) cnt[i]++;} 
	cout << f(0, true);
}    


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) begin(a),end(a)
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> P;
typedef long long ll;
const int INF = 114514810;
const int MOD = 1000000007;
const double EPS = 1e-10;
struct edge
{
	int to, cost;
	bool operator < (const edge& e) const { return cost < e.cost; }
	bool operator >(const edge& e) const { return cost > e.cost; }
};
int dx[] = { -1, 0, 0, 1 }; int dy[] = { 0, -1, 1, 0 };
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
bool valid(int x, int y, int h, int w) { return (x >= 0 && y >= 0 && x < h&&y < w); }
int place(int x, int y, int w) { return w*x + y; }
///*************************************************************************************///
///*************************************************************************************///
///*************************************************************************************///

int d[111111];
vector<vector<edge>> es;

void dijkstra(int s)
{
	fill(ALL(d), INF);
	d[s] = 0;
	priority_queue<P, vector<P>, greater<P>> que;
	que.push(P(0, s));
	while (!que.empty())
	{
		P p = que.top(); que.pop();
		int v = p.second;
		if (d[v] < p.first) continue;
		REP(i, es[v].size())
		{
			edge e = es[v][i];
			if (d[e.to] > d[v] + e.cost)
			{
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to], e.to));
			}
		}
	}
}

int main()
{
	int n;
	while (cin >> n, n)
	{
		es.clear();
		es.resize(n);
		int bufd[1000], bufp[1000];
		REP(i, n - 1) cin >> bufd[i];
		REP(i, n - 1) cin >> bufp[i];
		int sum = 0;
		FOR(i,1, n)
		{
			es[i].push_back(edge{ bufd[i - 1] - 1, bufp[i - 1] });
			es[bufd[i - 1] - 1].push_back(edge{ i, bufp[i - 1] });
			sum += bufp[i - 1];
		}
		int leaf = 0;
		set<int> rem;
		REP(i, es.size()) if (es[i].size() == 1)
		{
			leaf += es[i][0].cost;
			rem.insert(i);
		}
		int st;
		REP(i, es.size())
		{
			if (es[i].size() != 1)
			{
				st = i;
			}
			REP(j, es[i].size())
			{
				if (rem.find(i) != rem.end())
				{
					es[i][j].cost = INF;
				}
				if (rem.find(es[i][j].to) != rem.end())
				{
					es[i][j].cost = -1;
				}
			}
		}
		dijkstra(st);
		int fr = max_element(d,d+n) - d;
		dijkstra(fr);
		int dist = *max_element(d, d + n);
		cout << 3 * sum - 2 * leaf - dist << endl;
	}
	return 0;
}

Measured memory_bytes: 1760
N=int(input())
a=input().split()
b=[int(c) for c in a]
list1=[0]*8
number=0
for d in b:
    if 1<=d and 399>=d:
        list1[0]+=1
    elif 400<=d and d<=799:
        list1[1]+=1
    elif 800<=d and d<=1199:
        list1[2]+=1
    elif 1200<=d and d<=1599:
        list1[3]+=1
    elif 1600<=d and d<=1999:
        list1[4]+=1
    elif 2000<=d and d<=2399:
        list1[5]+=1
    elif 2400<=d and d<=2799:
        list1[6]+=1
    elif 2800<=d and d<=3199:
        list1[7]+=1
    else:
        number+=1
while 0 in list1:
    list1.remove(0)
kazu=len(list1)
if kazu==0:
    if number==0:
        print(str(0)+' '+str(0))
    else:
        print(str(1)+' '+str(number))
else:
    if number==0:
        print(str(kazu)+' '+str(kazu))
    else:
        print(str(kazu)+' '+str(kazu+number))
        

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define inf 1000000007
#define mod 1000000007
//#pragma GCC optimize(2)
//#define int long long
using namespace std;
template <typename T> void read(T &x){
	x=0;char ch=getchar();int fh=1;
	while (ch<'0'||ch>'9'){if (ch=='-')fh=-1;ch=getchar();}
	while (ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
	x*=fh;
}
template <typename T> void write(T x) {
	if (x<0) x=-x,putchar('-');
	if (x>9) write(x/10);
	putchar(x%10+'0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
int n,m,h[100005];
int deg1[100005],deg2[100005];
signed main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>m;
	for(int i=1;i<=n;i++)
		cin>>h[i];
	for(int i=1;i<=m;i++)
	{
		int a,b;
		cin>>a>>b;
		deg1[a]++;
		deg1[b]++;
		if(h[a]>h[b]) deg2[a]++;
		if(h[a]<h[b]) deg2[b]++;
	}
	int ans=0;
	for(int i=1;i<=n;i++)
		if(deg1[i]==deg2[i])
			ans++;
	cout<<ans<<endl;
	return 0;
}


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

template<typename T> void chmin(T &a,T b){if(a>b) a=b;}
template<typename T> void chmax(T &a,T b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  int n;
  cin>>n;
  vector<int> a(n),b(n);
  for(int i=0;i<n;i++) cin>>a[i]>>b[i];
  vector<int> s(114514,0);
  for(int i=0;i<n;i++) s[a[i]]++,s[b[i]]--;
  partial_sum(s.begin(),s.end(),s.begin());
  int ma=0,mi=*max_element(s.begin(),s.end());
  vector<int> u=a,v=b;
  sort(u.begin(),u.end());
  sort(v.begin(),v.end());
  for(int i=0;i<n;i++){
    int tmp=0;
    tmp+=upper_bound(v.begin(),v.end(),a[i])-v.begin();
    tmp+=u.end()-lower_bound(u.begin(),u.end(),b[i]);
    chmax(ma,n-tmp);
  }
  cout<<ma<<" "<<mi<<endl;
  return 0;
}



Measured memory_bytes: 6544
#include <algorithm>
#include <array>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>

using namespace std;

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

    int mod = n % 111;
    if (mod != 0) {
        n += (111-mod);
    }

    cout << n << endl;
}


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

using namespace std;

#define LL long long
#define Re register
#define U unsigned
#define forn(i,a,b) for(Re int i = a;i <= b;++i)
#define nfor(i,a,b) for(Re int i = a;i >= b;--i)
#define CLR(i,a) memset(i,a,sizeof(i))
#define BR printf("--------------------\n")
#define pb push_back
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define DEBUG(x) std::cerr << #x << '=' << x << std::endl
const double PI=atan(1.)*4.;
const int maxn=1e6+5;
const int inf = 0x3f3f3f3f;
const int mod=1e9+7;
const double e=2.71828182845904523536;
int dir[4][2]={1,0,0,1,-1,0,0,-1};
LL a[maxn];
LL b[maxn];
int main()
{
	ios::sync_with_stdio(false);
    cin.tie(0);
   	cout.tie(0);
    int n;
    cin>>n;
    LL sum=0;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        if(i&1)
            sum+=a[i];
        else
            sum-=a[i];
    }
    b[1]=sum/2;
    for(int i=2;i<=n;i++)
    {
        b[i]=a[i-1]-b[i-1];
    }
    for(int i=1;i<=n;i++)
    {
        cout<<b[i]*2<<" ";
    }
	return 0;
}


Measured memory_bytes: 6272
#!/usr/bin/env fsharpi

open System;

let readIntN ( str : string ) =
    str.Split(' ')
    |> Array.map System.Int32.Parse

let readInt1 ( str : string ) =
    readIntN str |> fun arr -> arr.[0]

let readInt2 ( str : string ) =
    readIntN str |> fun arr -> (arr.[0],arr.[1])

let readInt3 ( str : string ) =
    readIntN str |> fun arr -> (arr.[0],arr.[1],arr.[2])


let [|a;b;c;d|] = readIntN <| Console.ReadLine()
let res = max (a * b) (c * d)
Console.WriteLine( res )


Measured memory_bytes: 2648
#include <iostream>
#include <algorithm>
#include <string.h>
#include <queue>

using namespace std;

#define ARRAY_MAX 150
#define MAX 1000 + 1

char X[MAX];
char Y[MAX];

#pragma region 暴力递归
int FindLCS1(char x[], int i, char y[], int j)
{
	int l1 = strlen(x);
	int l2 = strlen(y);

	// 到索引末尾结束
	if (i >= l1 || j >= l2) return 0;

	if (x[i] == y[j])
		return 1 + FindLCS1(x, i + 1, y, j + 1);
	else
		return max(FindLCS1(x, i, y, j + 1), FindLCS1(x, i + 1, y, j));
}

int LongestCommonSubsequence1(char x[], char y[])
{
	return FindLCS1(x, 0, y, 0);
}
#pragma endregion

#pragma region 记忆搜索
int memory[MAX][MAX];
int FindLCS2(char x[], int i, char y[], int j)
{
	int l1 = strlen(x);
	int l2 = strlen(y);

	// 到索引末尾结束
	if (i >= l1 || j >= l2) return 0;

	if (memory[i][j] != -1) return memory[i][j];

	if (x[i] == y[j])
		return memory[i][j] = 1 + FindLCS2(x, i + 1, y, j + 1);
	else
		return memory[i][j] = max(FindLCS2(x, i, y, j + 1), FindLCS2(x, i + 1, y, j));
}

int LongestCommonSubsequence2(char x[], char y[])
{
	int l1 = strlen(x);
	int l2 = strlen(y);
	for (int i = 0; i < l1; ++i)
		for (int j = 0; j < l2; ++j)
			memory[i][j] = -1;

	return FindLCS2(x, 0, y, 0);
}
#pragma endregion

#pragma region 动态规划
int dp[MAX][MAX];

int LongestCommonSubsequence3(char x[], char y[])
{
	int l1 = strlen(x);
	int l2 = strlen(y);
	int size = sizeof(int) * (MAX) * (MAX);
	memset(dp, 0, size);
	for (int i = l1 - 1; i >= 0; --i)
		for (int j = l2 - 1; j >= 0; --j)
		{
			if (x[i] == y[j])
				dp[i][j] = 1 + dp[i + 1][j + 1];
			else
				dp[i][j] = max(dp[i + 1][j], dp[i][j + 1]);
		}

	return dp[0][0];
}
#pragma endregion

int main()
{
	int q; cin >> q;
	queue<int> result;
	for (int i = 0; i < q; ++i)
	{
		cin >> X;
		cin >> Y;
		result.push(LongestCommonSubsequence3(X, Y));
	}

	while (!result.empty())
	{
		cout << result.front() << endl;
		result.pop();
	}

	return 0;
}


Measured memory_bytes: 7004
from collections import defaultdict

MOD = 1000000007
n = int(input())


def GCD(a: int, b: int) -> int:
    return a if b == 0 else GCD(b, a % b)


# GCD(-2, 4)

iwasi_cnt = defaultdict(int)
for _ in range(n):
    a, b = map(int, input().split())
    if b < 0:
        a, b = -a, -b
    # iwasi.append((a, b))

    g = GCD(abs(a), abs(b))
    if g == 0:
        # (0, 0)
        iwasi_cnt[(a, b)] += 1
    else:
        iwasi_cnt[(a // g, b // g)] += 1

iwasi_cnt = dict(iwasi_cnt)
# print(iwasi_cnt)
cand = []
cnt0 = 0
for (a, b), v in iwasi_cnt.items():
    if a == 0 and b == 0:
        cnt0 += v
    else:
        if (-b, a) in iwasi_cnt:
            m = iwasi_cnt[(-b, a)]
            cand.append((v, m))
        elif (b, -a) not in iwasi_cnt:
            cand.append((v, ))

# print(*cand, sep='\n')
ans = 1
for i in range(len(cand)):
    if len(cand[i]) == 1:
        x = cand[i][0]
        ans *= pow(2, x, MOD)
        ans %= MOD
    else:
        x, y = cand[i]
        ans *= (MOD + pow(2, x, MOD) + pow(2, y, MOD) - 1) % MOD
        ans %= MOD

ans -= 1  # 0匹を取り除く
ans %= MOD
ans += cnt0  # (0, 0)を追加
ans %= MOD
print(ans)


Measured memory_bytes: 56884
n = int(input())

minimum = 10**12

a = 1

while a <= n**(1/2):
    b = n / a
    if b.is_integer():
        if a + b - 2 < minimum:
            minimum = a + b - 2
    
    else:
        a += 1
        continue
    
    a += 1

print(int(minimum))
    

Measured memory_bytes: 3188
#include<iostream>
using namespace std;
#define ll long long
int main(){
	ll m,n; cin>>m>>n;
  ll ans=0;
  if(m>1) ans=ans+(m*(m-1))/2;
      if(n>1) ans=ans+(n*(n-1))/2;
	cout<<ans<<"\n";
}

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

int main() {
    string s;
    cin >> s;
    if(s=="Sunny"){
        cout << "Cloudy" <<endl;
    }else if(s=="Cloudy"){
        cout << "Rainy" <<endl;
    }else{
        cout << "Sunny" <<endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
const int INF = 1e9;
//const int dx[] = {-1,0,1,0};
//const int dy[] = {0,-1,0,1};
const int dx[] = {-1,-1,-1, 0, 0, 1, 1, 1};
const int dy[] = {-1, 0, 1,-1, 1,-1, 0, 1};
#define PI 3.14159265358979323846264338327950L
#define MOD 1000000007
//setprecision(15)
int main() {
	int H, W; cin >> H >> W;
	vector<string> vs(H);
	rep(i, H) cin >> vs[i];
	rep(i, H) {
		rep(j, W) {
			if (vs[i][j] == '#') {
				cout << '#'; continue;
			}
			int num = 0;
			for (int k = 0; k < 8; k++) {
				int s = i+dy[k], t = j+dx[k];
				if (s < 0 || s >= H || t < 0 || t >= W) continue;
				if (vs[s][t] == '#') num++;
			}
			cout << num;
		}
		cout << endl;
	}
}

Measured memory_bytes: 3520
//teja349
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);  
ll k,a[123456]; 
ll check(ll val){
	ll i;
	rep(i,k){
		val-=val%a[i];
	}
	return val;
}
int main(){
    std::ios::sync_with_stdio(false);
    ll i;
    cin>>k;
    ll iinf=inf;
    iinf*=inf;
    rep(i,k){
    	cin>>a[i];
    }
    ll mid;
    ll low=2;
    ll high=iinf,val,ans=-1;
    while(low<=high){
    	mid=(low+high)/2;
    	val=check(mid);
    	if(val>2){
    		high=mid-1;
    	}
    	else if(val==2){
    		ans=mid;
    		high=mid-1;
    	}
    	else{
    		low=mid+1;
    	}
    }
    if(ans==-1){
    	cout<<-1<<endl;
    	return 0;
    }
    cout<<ans<<" ";
    low=2;
    high=iinf;
    ans=-1;
    while(low<=high){
    	mid=(low+high)/2;
    	val=check(mid);
    	if(val>2){
    		high=mid-1;
    	}
    	else if(val==2){
    		ans=mid;
    		low=mid+1;
    	}
    	else{
    		low=mid+1;
    	}
    }
    cout<<ans<<endl;
    return 0;  
    
}



Measured memory_bytes: 1152