akhauriyash/Code-Regression huggingface dataset:
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right #func(リスト,値)
from heapq import heapify, heappop, heappush
from math import *

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x):
        self.setdefault(x,0)
        self[x] += 1

N = int(input())
C = counter()

def f(s):
    ans = 0
    for i in range(10):
        ans += 11**ston(s[i])
    return ans

ans = 0
for _ in range(N):
    s = input()
    k = f(s)
    C.add(k)
    ans += C[k]-1
print(ans)

Measured memory_bytes: 108964
/*
 * AOJ 0525: Osenbei
 * ?¢???????R???C?????????????????????0???1???????¬?????????´????????´????????????????????¬????±??????????????????°????°????0???
 * ?±?????????????????´¢????????????
 * ???????????????10???????????????????????¬????????¨??¨????????????????????¶????????????1????????°???????????¬?????????????°?0???1????????°??¨????±???????
 */


#include <cstdio>
#include <iostream>
#include <string>
#include <cstring>

using namespace std;

int m, n;
int mat[11][10001];
int one[10001], _one[10001];
int ans;

void solve() {
  ans = 0;
  memset(one, 0, sizeof(one));
  for (int i = 0; i < m; ++i) {
    for (int j = 0; j < n; ++j) {
      cin >> mat[i][j];
      one[j] += mat[i][j];
    }
  }
  for (int no = (1 << m) - 1; no >= 0; --no) {
    int _no = no;
    for (int i = 0; i < n; ++i) {
      _one[i] = one[i];
    }
    for (int i = 0; i < m; ++i) {
      if (_no & 1) {
        for (int j = 0; j < n; ++j) {
          _one[j] += mat[i][j] ? -1 : 1;
        }
      }
      _no >>= 1;
    }
    int tmp = 0;
    for (int i = 0; i < n; ++i) {
      tmp += max(_one[i], m - _one[i]);
    }
    ans = max(ans, tmp);
  }

}

int main() {
  while (cin >> m >> n && m > 0 && n > 0) {
    solve();
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3524
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#if defined(DAIJOBU)
#include "/home/ichigo/includes.hpp"
#include "/home/ichigo/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#include <bits/stdc++.h>
#define deb(x...)
#endif
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long lint;
typedef vector<lint> vlint;
typedef vector<vlint> vvlint;
typedef pair<lint, lint> plint;
typedef double ld;

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

char grid[100][100];
int dx[] = {-1, 1, 0, 0};
int dy[] = {0, 0, -1, 1};
bool used[100][100];
int dist[100][100], n, m;

bool ok(int x, int y){
	if(x >= 0 && x < n && y >= 0 && y < m && grid[x][y] != '#')return true;
	return false;
}

void bfs(int x, int y){
	used[x][y] = true;
	dist[x][y] = 0;
	queue<pii> q;
	q.push({x, y});
	while(!q.empty()){
		auto u = q.front();
		q.pop();
		forn(i, 4){
			int tx = u.fi + dx[i];
			int ty = u.se + dy[i];
			if(!used[tx][ty] && ok(tx, ty)){
				used[tx][ty] = true;
				dist[tx][ty] = dist[u.fi][u.se] + 1;
				q.push({tx, ty});
			}
		}
	}
			
}

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

	cin >> n >> m;
	
	int dot = 0;
	forn(i, n){
		forn(j, m){
			cin >> grid[i][j];
			if(grid[i][j] == '.')dot++;
		}
	}
	if(grid[0][0] == '#' || grid[n - 1][m - 1] == '#')cout << -1;
	else{
		bfs(0, 0);
		if(!used[n - 1][m - 1])cout << -1;
		else cout << dot - dist[n- 1][m - 1] - 1 << '\n';
	}
	return 0;
}



Measured memory_bytes: 384
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<ctime>
#include<utility>
#include<cmath>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
void sort(int &a,int &b)
{
	if(a>b)
		swap(a,b);
}
void open(const char *s)
{
#ifndef ONLINE_JUDGE
	char str[100];
	sprintf(str,"%s.in",s);
	freopen(str,"r",stdin);
	sprintf(str,"%s.out",s);
	freopen(str,"w",stdout);
#endif
}
int rd()
{
	int s=0,c;
	while((c=getchar())<'0'||c>'9');
	do
	{
		s=s*10+c-'0';
	}
	while((c=getchar())>='0'&&c<='9');
	return s;
}
int upmin(int &a,int b)
{
	if(b<a)
	{
		a=b;
		return 1;
	}
	return 0;
}
int upmax(int &a,int b)
{
	if(b>a)
	{
		a=b;
		return 1;
	}
	return 0;
}
vector<int> g[100010];
int dfs(int x,int f)
{
	int s=0;
	for(auto v:g[x])
		if(v!=f)
			s^=dfs(v,x)+1;
	return s;
}
int main()
{
	int n;
	scanf("%d",&n);
	int i,x,y;
	for(i=1;i<n;i++)
	{
		scanf("%d%d",&x,&y);
		g[x].push_back(y);
		g[y].push_back(x);
	}
	if(dfs(1,0))
		printf("Alice\n");
	else
		printf("Bob\n");
	return 0;
}

Measured memory_bytes: 10368
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        Map<Integer, Integer> map = new HashMap<>();
        for (int i = 0; i < m; i++) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            map.put(a, map.getOrDefault(a, 0) + 1);
            map.put(b, map.getOrDefault(b, 0) + 1);
        }
        for (int i = 1; i <= n; i++) {
            if (map.getOrDefault(i, 0) % 2 != 0) {
                System.out.println("NO");
                return;
            }
        }
        System.out.println("YES");
    }

}


Measured memory_bytes: 63132
<?php
fscanf(STDIN, "%d", $n);
$p = explode(' ', trim(fgets(STDIN)));
$x = 0;
for ($i = 0; $i < $n - 1; $i++) {
	$j = $i + 1;
	if ($p[$i] == $j) {
		list($p[$i], $p[$j]) = [$p[$j], $p[$i]];
		$x++;
	}
}
if ($p[$n-1] == $n) $x++;
echo $x;

Measured memory_bytes: 12792
#include <bits/stdc++.h>
using namespace std;
#define mem(a,n) memset(a,n,sizeof(a))
#define rep(i,a,n) for(int i=a;i<n;i++)
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef unsigned long long ull;
const double eps=1e-6;
const int INF=0x3f3f3f3f;
const int mod=1e9+7;
const int N=1e5+5;
int prime[N],sum[N];
bool is_pr[N];
int cnt;
inline int Scan()
{
    int r = 0,f = 1;
    char ch = getchar();
    while(ch < '0' || ch > '9')
    {
        if(ch == '-')f = -1;
        ch = getchar();
    }
    while(ch >= '0' && ch <= '9')
    {
        r = r * 10 + ch - '0';
        ch = getchar();
    }
    return r * f;
}
void sieve()
{
    cnt=0;
    mem(is_pr,0);
    for(int i=2; i*i<=N; i++)
    {
        if(!is_pr[i])
        {
            for(int j=i*i; j<=N; j+=i)
                is_pr[j]=1;
        }
    }
    for(int i=2; i<N; i++)
        if(!is_pr[i]) prime[cnt++]=i;
    mem(sum,0);
    for(int i=1; i<cnt; i++)
    {
        int tmp=(prime[i]+1)/2;
        int pos=lower_bound(prime,prime+i,tmp)-prime;
        if(prime[pos]==tmp) sum[prime[i]]++;
    }
    for(int i=1; i<cnt; i++) sum[prime[i]]+=sum[prime[i-1]];
}
int main()
{
    sieve();
    int q;
    q=Scan();
    rep(i,0,q)
    {
        int l,r;
        l=Scan(),r=Scan();
        int pos1=lower_bound(prime,prime+cnt,l)-prime;
        // printf("prime  %d\n",prime[pos1]);
        int pos2=lower_bound(prime,prime+cnt,r)-prime;
        if(prime[pos2]==r) r=prime[pos2];
        else r=prime[pos2-1];
        //printf("%d %d\n",sum[r],sum[pos1]);
        printf("%d\n",sum[r]-sum[prime[pos1-1]]);
    }
    return 0;
}


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

#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
 
typedef long long ll;
using namespace std;
 
int main(){
  int a,b,c;
  cin >> a >> b >> c;

  if(c >= a && c <= b){
    printf("Yes\n");
  }
  else printf("No\n");
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define st first
#define nd second
#define pb push_back
#define ppb pop_back
#define umax(x,y) x=max(x,y)
#define umin(x,y) x=min(x,y)
#define ll long long
#define ii pair<int,int>
#define iii pair<int,ii>
#define iiii pair<ii,ii>
#define sz(x) ((int) x.size())
#define orta ((bas+son)>>1)
#define all(x) x.begin(),x.end()
#define dbgs(x) cerr<<(#x)<<" --> "<<(x)<<" "
#define dbg(x) cerr<<(#x)<<" --> "<<(x)<<endl;getchar()
#define pw(x) (1ll<<(x))
#define inf 2005000
#define MOD 1000000007
#define N 200005
#define M 1000005
#define LOG 60
#define KOK 4000000
using namespace std;

int ne[105];
char s[105];
int ans=inf;

int main() {

	//freopen("input.txt","r",stdin);	

	scanf("%s",s+1);

	int n=strlen(s+1);

	for(int i=0;i<26;i++) {

		for(int j=0;j<=n;j++) {

			for(int k=n;k>=1;k--) {

				ne[k]=(s[k]=='a'+i?0:ne[k+1]+1);

			}

			bool flag=0;

			for(int k=1;k<=n-j;k++) {

				if(ne[k]>j) flag=1;

			}

			if(!flag) {

				umin(ans,j);

				break ;
			}

		}

	}

	printf("%d",ans);

}



Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>
#include<set>
 
using namespace std;
 
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define P(p) cout<<(p)<<endl;
#define p(p) cout<<(p)<<" ";
#define pb push_back
#define mp make_pair
#define INF 1<<25

typedef long long ll;
#define int ll
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pi;

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

int N,C;
vi c;
int imos[30][200001];
void input(){
	cin>>N>>C;
	//IN.resize(N);
	rep(i,N){
		int s,t,c;
		cin>>s>>t>>c;
		c--;
		//IN.pb((T){s,t,c});
		s*=2;t*=2;
		s--;
		imos[c][s]++;
		imos[c][t]--;
	}	
	rep(i,30){
		REP(j,1,200000){
			imos[i][j]+=imos[i][j-1];
	//		p(imos[i][j])
		}
		//cout<<endl;
	}
}


signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	input();
	c.resize(200000,0);
	rep(i,30){
		rep(j,200000){
			if(imos[i][j]){
				c[j]++;
			}
		}
	}
	//rep(i,40)p(c[i])
	int ans=0;
	rep(i,200000)ans=max(ans,c[i]);
	P(ans)
	return 0;
}



Measured memory_bytes: 48768
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <random>
#include <iomanip>

using namespace std;
typedef long long unsigned int ll;
typedef pair<int, int> P;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvdi(xs) sort(xs.begin(), xs.end(), std::greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)

#define rep(i,n) for(auto i=0; i<(n); i++)
#define isValidPoint(x, y, mx, my) x >= 0 && x  < mx && y >= 0 && y < my

int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MOD = 1000000007;

struct Pony
{
    long a, b;
 
    Pony(long a_, long b_)
    {
        a = a_;
        b = b_;
    }
 
    bool operator<(const Pony &another) const
    {
        return b < another.b;
    };
};

int fac(int k){
    int sum = 0;
    for (int i = 1; i <= k; ++i)
    {
        sum += i;
    }
    return sum;
}

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

  int  n, a, b;
  cin >> n >> a>> b;

  cout << min(a*n, b) << endl;

}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    ll ans = 0;
    while(true) {
        bool f = false;
        rep(i, n) {
            if (a[i] >= n) {
                f = true;
                break;
            }
        }
        if (!f) {
            break;
        }
        rep(i, n) {
            if (a[i] < n) continue;
            ll c = max(0LL, a[i] / n);
            ans += c;
            a[i] %= n;
            rep(j, n) {
                if (i == j) continue;
                a[j] += c;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
def num2alpha(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64+num%26)

num=int(input())
print(str.lower(num2alpha(num)))

Measured memory_bytes: 9172
#include<vector>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef vector<int> vi;
int main(){
  int n,m; cin>>n;

  int adj[100][100]={0};
  rep(i,n){
    int r,k,t; cin>>r>>k, r--;
    rep(j,k)cin>>t,adj[r][t-1]=1;
  }
  cin>>m;
  rep(i,m){
    int s,d,v; cin>>s>>d>>v,s--,d--;
    vi frontier; frontier.push_back(s);
    int cost[n]; rep(j,n)cost[j]=9999; cost[s]=0;
    for(int step=0;step<v-1&&cost[d]==9999;step++){
      vi next;
      rep(j,frontier.size())rep(h,n)if(adj[frontier[j]][h]&&cost[h]>step+1)
	cost[h]=step+1,next.push_back(h);
      frontier=next;
    }
    if(cost[d]!=9999)cout<<cost[d]+1<<endl;
    else cout<<"NA"<<endl;
  }
  return 0;
}

Measured memory_bytes: 948
#include<iostream>

using namespace std;

int main(){

    int d, n;
    cin>> d>> n;
    int T[d+1];
    for(int i=1; i<=d; i++){
        cin>> T[i];
    }
    int A[n+1], B[n+1], C[n+1];
    for(int i=1; i<=n; i++){
        cin>> A[i]>> B[i]>> C[i];
    }

    int dp[d+1][n+1];
    fill(dp[0], dp[d+1], -1);
    for(int i=1; i<n+1; i++){
        if(A[i]<=T[1]&&T[1]<=B[i]){
            dp[1][i]=0;
        }
    }

    for(int day=1; day<=d; day++){
        for(int pre=1; pre<=n; pre++){
            for(int now=1; now<=n; now++){
                if(A[now]<=T[day]&&T[day]<=B[now]&&dp[day-1][pre]!=-1)
                    dp[day][now]=max(dp[day][now], dp[day-1][pre]+abs(C[now]-C[pre]));
            }
        }
    }

    int ans=-1;
    for(int i=1; i<=n; i++){
        ans=max(ans, dp[d][i]);
    }

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

Measured memory_bytes: 3244
import java.util.*;
import java.io.*;

public class Main {

	int[] dx = new int[] { 1, 0, -1, 0 };
	int[] dy = new int[] { 0, 1, 0, -1 };

	void solve() {
		char[] c = in.nextToken().toCharArray();
		int x = in.nextInt(), y = in.nextInt();

		int dir = 0;
		int i = 0;
		while (i < c.length && c[i] == 'F') {
			i++;
			x--;
		}
		if (i == c.length) {
			if (x == 0 && y == 0) {
				out.println("Yes");
			} else {
				out.println("No");
			}
			return;
		}

		List<Integer> lensX = new ArrayList<>();
		List<Integer> lensY = new ArrayList<>();

		while (i < c.length) {
			// c[i] == 'T'
			dir = (dir + 1) % 4;
			i++;
			int len = 0;
			while (i < c.length && c[i] == 'F') {
				i++;
				len++;
			}
			
			if (dir % 2 == 1) {
				lensY.add(len);
			} else {
				lensX.add(len);
			}
		}
		
		out.println(can(x, lensX) && can(y, lensY) ? "Yes" : "No");
	}

	private boolean can(int x, List<Integer> lens) {
		int MAX = 10000;
		boolean[] dp = new boolean[2 * MAX + 1];
		boolean[] newDp = new boolean[2 * MAX + 1];
		dp[MAX] = true;
		for (int t : lens) {
			for (int i = 0; i < dp.length; i++) {
				if (!dp[i]) {
					continue;
				}
				if (i - t >= 0) {
					newDp[i - t] = true;
				}
				if (i + t >= 0) {
					newDp[i + t] = true;
				}
			}
			System.arraycopy(newDp, 0, dp, 0, dp.length);
			Arrays.fill(newDp, false);
		}
		
		return dp[MAX + x];
	}

	FastScanner in;
	PrintWriter out;

	void run() {
		in = new FastScanner();
		out = new PrintWriter(System.out);
		solve();
		out.close();
	}

	class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		public FastScanner(String s) {
			try {
				br = new BufferedReader(new FileReader(s));
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}

		public String nextToken() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
				}
			}
			return st.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextToken());
		}

		public long nextLong() {
			return Long.parseLong(nextToken());
		}

		public double nextDouble() {
			return Double.parseDouble(nextToken());
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
}


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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}


int main(){
  int K; cin >> K;
  queue <ll> que;
  for (int i = 1; i <= 9; i++) que.push(i);

  for (int i = 0; i < K - 1; i++){
    ll Q = que.front(); que.pop();

    if (Q % 10 > 0){
      que.push(Q * 10 + Q % 10 - 1);
    }
    que.push(Q * 10 + Q % 10);
    if (Q % 10 < 9){
      que.push(Q * 10 + Q % 10 + 1);
    }
  }
  cout << que.front() << endl;

  return 0;
}


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

int main() {
    int W, H, N;
    cin >> W >> H >> N;
    int xmin = 0;
    int ymin = 0;
    int xmax = W;
    int ymax = H;

    for (int i = 0; i < N; i++) {
        int x, y, a;
        cin >> x >> y >> a;
        if (a == 1) xmin = max(xmin, x);
        if (a == 2) xmax = min(xmax, x);
        if (a == 3) ymin = max(ymin, y);
        if (a == 4) ymax = min(ymax, y);
    }
    cout << max(0, max(0, (xmax - xmin)) * max(0, (ymax - ymin))) << endl;
    return 0;
}

Measured memory_bytes: 384
# 初期入力
import bisect
import heapq
import sys
input = sys.stdin.readline
N,K = (int(i) for i in input().split())
V = list(map(int, input().split()))
V_sorted =sorted(V)

#取る個数take_num、返す個数reverse(t +r <=K)個全て決める

ans =[]
take_V =[] #最後に持っている宝石の価値
#Vが全てマイナスなら取らない
if V_sorted[-1] <=0:
    ans =0
else:
    take_num =min(K,N)
    for tak in range(1,take_num +1):
        for lef in range(tak+1):
            #for rev in range(reverse +1):
            
                take =[]  #取った宝石
                rig =N-(tak -lef )          #lef:左側の取る数 rig:右側の取る数
                take.extend(V[    :lef])
                take.extend(V[rig:   ])
                take.sort()
                reverse =min(K -tak,tak) #返す数はtake_numではなく、Kから引く
                ind_0 =bisect.bisect_left(take,0)
                rev =min(ind_0,reverse,K -tak)
                take_V.append(sum(take[rev:])) #返す分を除く
        
    ans =max(take_V)
print(ans)

Measured memory_bytes: 9256
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
#define ALL(a)  (a).begin(),(a).end()
 
const ll mod = 1000000007;
const ll LINF = 1e13;
const ll LLINF = 1e18;
const ll ALPHABET = 26;
 
template <class T>
void Swap(T& r, T& l) {
  T tmp = r;
  r = l;
  l = tmp;
}
 
template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x; //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいい
  return is;
}


int main(){
    // ll N,S,K;
    ll a,b,c;
    cin >> a >>b ;

    cout << (6-a-b);


}




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

int main()
{
    ll i,j,k,l,m,n,o,p,t,z=0;
    cin>>i>>j>>k;
    vector<ll>vc;
    m=abs(i-j)+abs(j-k);
    n=abs(j-k)+abs(k-i);
    o=abs(i-k)+abs(i-j);
    cout<<min(m,min(n,o))<<endl;
    return 0;



    return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){

 int y,x;

 scanf("%2d%2d",&x,&y);

 int a,b;a=b=0;

 if(x<=12&&x)a=1;if(y<=12&&y)b=1;

 if(!x&&!b||!y&&!a)cout<<"NA";

 else

 if(a&&b)cout<<"AMBIGUOUS";

 else if(a)cout<<"MMYY";

 else if(b)cout<<"YYMM";

 else cout<<"NA";

 

 }

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define LIMIT 1000000000

int gcd(int,int);

int main(int argc, char** argv) {
    int a,b;
    int checkScan = scanf("%d %d", &a, &b);
    if(checkScan != 2)
        return(EXIT_FAILURE);
    if(a > LIMIT || a < 1 || b > LIMIT || b < 1)
        return(EXIT_FAILURE);
    printf("%d\n",gcd(a,b));
    
    return (EXIT_SUCCESS);
}

int gcd(int a, int b){
    if(b != 0)
        return gcd(b, a%b);
    return a;
}



Measured memory_bytes: 2120
N = int(input())
S = input()
nl = 0
for c in reversed(S):
  if c == "(":
    nl = max(0, nl-1)
  if c == ")":
    nl += 1
nr = 0
for c in S:
  if c == ")":
    nr = max(0, nr-1)
  if c == "(":
    nr += 1
r = "("*nl + S + ")"*nr
print(r)


Measured memory_bytes: 3060
s = int(input())
sen = s//1000
hyaku = s//100 - sen*10
juu = s//10 - sen*100 - hyaku*10
iti = s - sen*1000 - hyaku*100 - juu*10

if (sen==hyaku)or(hyaku==juu)or(juu==iti):
    print("Bad")
else:
    print("Good")

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

# define p(s) std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;

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

    int res=0;
    int m=0;
    for(int i=0;i<n;i++){
        int tmp;cin >> tmp;
        res+=tmp;
        m=max(m,tmp);
    }
    p(res-m/2)
} 

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

#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define fi first
#define se second
#define ff first
#define ss second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef long double ld;
typedef string st;
const double PI=3.14159265358979323846264338327950288419716939937510582097494459230;
const ll MOD = 1e9 + 7 ;
const ll INF=1e14;
ll mpow(ll a,ll b,ll p=MOD){a=a%p;ll res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
const ll N=800005;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll n;
  cin>>n;
  ll a[n][3];
  forn(i,n) forn(j,3) cin>>a[i][j];
  ll dp[n][3];
  forn(i,3) dp[0][i]=a[0][i];
  for(ll i=1;i<n;i++)
  {
    forn(j,3)
    {
      ll ma=-1;
      forn(k,3)
      {
        if(j!=k) ma=max(dp[i-1][k],ma);
      }
      dp[i][j]=a[i][j]+ma;
    }
  } 
  cout<<max({dp[n-1][0],dp[n-1][1],dp[n-1][2]});
}
//nothing is impossible

Measured memory_bytes: 4992
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#include <vector>
#include <numeric>
#include <map>
#include <cmath>
#include <iomanip>
#include <queue>
using ll =long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vs = vector<string>;

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


    ll mini = min(min(abs(A*B*(C/2) - A*B*(C-C/2)), abs(A*C*(B /2) - A*C*(B-B/2))), abs(B*C*(A /2) - B*C*(A-A/2)));

    cout << mini << endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
	Scanner scan = new Scanner(System.in);
	int a=scan.nextInt();
	int b=scan.nextInt();
	int c=scan.nextInt();
	int count;
	public Main(){
		for(int i=a;i<=b;i++){
			if(c%i==0)count++;
		}
		System.out.println(count);
	}
	public static void main(String[]args){
		new Main();
	}
}

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

//Compiler version g++ 6.3.0
typedef long long ll;
int main()
{
    ll n;
    cin>>n;
    string s;
    ll a=0,w=0,t=0,r=0;
    while(n--)
    {
      cin>>s;
      if(s=="AC")a++;
      else if(s=="WA")w++;
      else if(s=="TLE")t++;
      else
      r++;    
    }
    cout<<"AC x "<<a<<"\n";
    cout<<"WA x "<<w<<"\n";
    cout<<"TLE x "<<t<<"\n";
    cout<<"RE x "<<r<<"\n";
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>          
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define int long long
#define mk_p(a,b)	make_pair((a),(b))
#define fixed(n) fixed<<setprecision((n))
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr long long MOD = 1000000007;

int gcd(int a,int b){return b ? gcd(b,a%b) : a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}

int a[200050];

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,k;
	cin >> n >> k;
	int cnt = 0;
	rep(i,n){
		int x;
		cin >> x;
		if(a[x] == 0) ++cnt;
		++a[x];
	}
	if(cnt <= k){
		cout << 0 << '\n';
		return 0;
	}
	sort(a,a+200050,greater<int>());
	sort(a,a+cnt);
	int sum = 0;
	rep(i,cnt-k){
		sum += a[i];
	}
	cout << sum << '\n';
	return 0;
}


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

typedef uint64_t u64;
typedef int64_t i64;
typedef uint32_t u32;
typedef int32_t i32;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;

#define rep(idx, N) for (u64 idx = 0; idx < N; idx++)

int main() {
  i32 l;
  cin >> l;
  printf("%.10lf", pow(l / 3.0, 3));

  return 0;
}


Measured memory_bytes: 4132
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cstring>
using namespace std;

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

int sz;
int primes[1120];
bool check[5000];
int dp[190][1120][15];

void make_prime(){
  check[0]=check[1]=true;
  for(int i=2; i*i<=1120; i++){
    if( !check[i] ){
      for(int j=i*2; j<=1120; j+=i){
	check[j] = true;
      }
    }
  }
  for(int i=2; i<=1120; i++){
    if( !check[i] ){
      primes[sz++] = i;
    }
  }
}

int solve(int idx, int n, int k){
  int ret = 0;
#if DEB
  printf("(%d,%d,%d)\n",idx,n,k);
#endif
  if( dp[idx][n][k]!=-1 ){
    return dp[idx][n][k];
  }
  if( k==0 ){
    return n==0;
  }
  for(int i=idx; i<sz && primes[i]<=n; i++){
    ret += solve(i+1,n-primes[i],k-1);
  }
  return dp[idx][n][k] = ret;
}

int main(){
  int n,k;
  make_prime();
  memset(dp,-1,sizeof(dp));
  while(scanf("%d%d",&n,&k),n|k){
    printf("%d\n",solve(0,n,k));
  }
  return 0;
}

Measured memory_bytes: 13000
#include<iostream>
#include<algorithm>
using namespace std;
int per[100001],peo[100001],m=1e9+7,n;
long long ans=1;
int main()
{
    cin>>n;
    if(n%2==0) for(int i=1;i<=n;i+=2) peo[i]=i,peo[i+1]=peo[i];
    else for(int i=2;i<=n;i+=2) peo[i]=i,peo[i+1]=peo[i];
    for(int i=1;i<=n;i++) cin>>per[i];
    sort(per+1,per+1+n);
    for(int i=1;i<=n;i++) if(peo[i]!=per[i])
        {
            cout<<"0";
            return 0; 
        }
    n/=2;
    while(n--) ans=ans*2%m;
    cout<<ans;
    return 0;
}

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

using namespace std;

using VI = vector<int>;
using VVI = vector<VI>;
using VB = vector<bool>;
using VVB = vector<VB>;
using VS = vector<string>;
using PII = pair<int, int>;
using VPII = vector<PII>;
using VL = vector<long long>;
using VVL = vector<VL>;

#define sz(var) (int)var.size()
#define REP(var, start, end) for(int var = start; var < (int)end; ++var)
#define CLEAR(var, with) memset(var, with, sizeof(var))
#define ALL(x) x.begin(), x.end()
#define LL long long
#define ULL unsigned long long


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
#ifndef ONLINE_JUDGE
//	freopen("tmp.in", "r", stdin);
//	freopen("tmp.out", "w", stderr);
#endif
	LL n, k;
	cin >> n >> k;

	VPII oper(n, PII());
	REP(i, 0, n)
		cin >> oper[i].first >> oper[i].second;
	
	sort(ALL(oper));

	LL idx = 0;
	REP(i, 0, n)
	{
		int a = oper[i].first, b = oper[i].second;

		idx += b;
		if(k <= idx){
			cout << a << endl;
			exit(0);
		}
	}

	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
//cout << fixed << setprecision(8) << a << endl;
//cout << "Case " << ca << ": " << ans << endl;
#define Fast_Input ios_base :: sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
#define MX 100005
#define infinity 20000000
#define pb push_back
int main()
{
    long long int n,k;
    cin >> n >> k;
    long long int ans,ans2;
    ans=n%k;
    ans2=abs(ans-k);
    cout << min(ans,ans2) << endl;
    return 0;
}


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

#define FOR(i, a, b) for(long long int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;



int main(void) {
	
	while (1) {
		bool flag = true;
		int n;
		int dp[101][101] = {};
		int m, p;
		int k;
		int l[101] = {};
		int count = 0;

		cin >> n;
		if (n == 0) {
			break;
		}
		FOR(i, 1, n) {
			cin >> m;
			FOR(t, 1, m) {
				cin >> p;
				dp[i][p] = 1;
			}
		}
		cin >> k;
		FOR(i, 0, k-1) {
			cin >> l[i];
		}
		FOR(i, 1, n) {
			FOR(t, 0, k - 1) {
				if (dp[i][l[t]] != 1) {
					break;
				}
				if (t == k - 1) {
					if (count == 0){
						count = i;
					}
					else {
						flag = false;
					}
				}
			}
		}
		if (count == 0) {
			flag = false;
		}
		if (flag) {
			cout << count << endl;
		}
		else {
			cout << -1 << endl;
		}
	}
	

	
}


Measured memory_bytes: 3160
import bisect
import copy
import heapq
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(500000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n=int(input())
tmp=n%1000
if tmp==0:
    print(0)
else:
    print(1000-tmp)

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

using namespace std;

#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n);i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(a);i>=(int)(b);--i)
#define ALL(a) (a).begin(),(a).end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;

const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
  if(a < b) {a = b; return true;}
  return false;
}

template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
  if(a > b) {a = b; return true;}
  return false;
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  REP(i, SZ(v)) {
    if(i) os << " ";
    os << v[i];
  }
  return os;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int h, w; cin >> h >> w;
  vector<vector<char>> g(h, vector<char>(w));
  REP(i, h) {
    REP(j, w) {
      cin >> g[i][j];
    }
  }

  ll ans = 0;
  REP(i, w-1) {
    vvll su(2 * h + 1, vll(h + 1));

    REP(j, h) {
      REP(k, h) {
        if (k + (h - j) < h) su[j][k] = g[h - 1 - k][i + 1] == g[h - 1 - k - h + j][i];
      }
      RREP(k, h - 1) {
        su[j][k] += su[j][k + 1];
      }
    }
    REP(j, h + 1) {
      REP(k, h) {
        if (k + j < h) su[h + j][k] = g[h - 1 - k][i] == g[h - 1 - k - j][i + 1];
      }
      RREP(k, h - 1) {
        su[h + j][k] += su[h + j][k + 1];
      }
    }

    vvi dp(2 * h + 1, vi(2 * h + 1, INF));
    dp[0][h] = 0;

    REP(j, 2 * h) {
      REP(k, 2 * h + 1) {
        if (dp[j][k] == INF) continue;
        int rem = (j - abs(k - h)) / 2;
        if (k != 0) {
          chmin(dp[j + 1][k - 1], dp[j][k] + su[k][rem]);
        }

        if (k != 2 * h) {
          chmin(dp[j+1][k+1], dp[j][k] + su[k][rem]);
        }
      }
    }

    int mi = INF;
    REP(j, 2*h+1) {
      chmin(mi, dp[2*h-1][j]);
    }
    ans += mi;
  }
  cout << ans << endl;
}
























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

#define     FasterIO        ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     bug(a,b)        cout<<a<<"\t"<<b<<"\n";
#define     Case(a,b)       cout<<"Case "<<a<<": "<<b<<"\n";
#define     precision(a,b)  fixed<<setprecision(a)<<b
#define     lp(i,a,b)       for(int i=a;i<b;i++)
#define     Endl            "\n"
#define     tab             "\t"
#define     reset(a,b)      memset(a,b,sizeof(a));
#define     sf(a)           scanf(" %d", &a);
#define     sfl(a)          scanf(" %lld", &a);
#define     srt(a)          sort(a.begin(),a.end());
#define     ALL(a)          a.begin(),a.end()
#define     pi              2*acos(0.0)

typedef long long int ll;
typedef unsigned long long int ull;

const int sz=1e5+9 , inf=INT_MAX ,mod=1e9+7;


void solve(){
    ll  l,r,d,ans=0 ;
    cin>>l>>r>>d;

    ans=r/d;
    if(l%d==0){
        ans-=(l/d)-1;
    }else{
        ans-=(l/d);
    }
    cout<<ans<<Endl;

    
}

int main(){
    FasterIO;
    #ifndef ONLINE_JUDGE
        freopen("input.in","r",stdin);
        freopen("output.in","w",stdout);
    #endif
    int t=1;
    // cin>>t;
    while(t--)
        solve();
}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include<numeric>
using namespace std;
using P = pair<int, int>;
#define rep(i,n) for(int i=0; i<(n);i++)
typedef long long ll;


int main(){
    int n; cin >> n;
    if(n%2!=0) cout << n/2 + 1 << endl;
    else cout << n/2 << endl;
    return 0;
}


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 pii = pair<int,int>;

const int INF = 2e9;

int main(){
    int a,b,c,k;
    cin >> a >> b >> c >> k;
    int cnt = 0;
    while(a >= b){
        b *= 2;
        cnt++;
    }
    while(b >= c){
        c *= 2;
        cnt++;
    }
    if(cnt <= k)cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define rep(i,n) for(int i=0; i<n; i++)
typedef long long ll;
typedef pair<int,int> P;
const ll MOD = (int)1e9+7;
const ll INF = MOD*MOD;
const ll powll = 1LL<<1;

int main(){
  string s; cin >> s;
  if(s == "AAA" || s == "BBB") cout << "No\n";
  else cout << "Yes\n";
}

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

const ll INF = 1001001001001001001;
const ll mod = 1000000007;

int main(){
    int n, m; cin >> n >> m;
    vector<ll> x(n), y(n), z(n);
    for(int i = 0; i < n; i++){
        cin >> x[i] >> y[i] >> z[i];
    }
    ll ans = -INF;
    for(int i = 0; i < (1 << 3); i++){
        vector<ll> sum;
        for(int j = 0; j < n; j++){
            ll tmp = 0;
            for(int k = 0; k < 3; k++){
                if(i & (1 << k)){
                    if(k == 0) tmp += x[j];
                    if(k == 1) tmp += y[j];
                    if(k == 2) tmp += z[j];
                }
                else{
                    if(k == 0) tmp -= x[j];
                    if(k == 1) tmp -= y[j];
                    if(k == 2) tmp -= z[j];
                }
            }
            sum.push_back(tmp);
        }
        sort(sum.rbegin(), sum.rend());
        ll cnt = 0;
        for(int j = 0; j < m; j++){
            cnt += sum[j];
        }   
        ans = max(cnt, ans);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3684
#include<iostream>
#include<cstdio>
#include<string>
#include<cmath>

using namespace std;

int main()
{
    string s,t;
    cin>>s>>t;
    int flag=1;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]==t[i])
        {
            flag=1;
        }
        else
        {
            flag=0;
            break;
        }
        
    }
    if(flag==1)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
    
    //system("pause");
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define Inf 0x3f3f3f3f
#define rg register
using namespace std;
typedef long long ll;
inline ll min(ll x, ll y) { return x < y ? x : y; }
inline ll max(ll x, ll y) { return x > y ? x : y; }
const int Maxn = 1e5 + 5;
inline ll read()
{
	rg ll res = 0;
	rg char ch = getchar();
	while (!isdigit(ch))
		ch = getchar();
	do
	{
		res = (res << 3) + (res << 1) + (ch ^ 48);
		ch = getchar();
	}while(isdigit(ch));
	return res;
}
int n,f[Maxn];
set<int>E[Maxn];
set<int>::iterator it;
queue< pair<int,int> >q;
int Find(int x){return f[x]==x?x:f[x]=Find(f[x]);}
int main()
{
	rg int a,b;
	cin>>n;
	for(int t=0;t<=1;t++)
		for(int i=1;i<n;i++)
		{
			a=read();
			b=read();
			if(!t)
			{
				E[a].insert(b);
				E[b].insert(a);
			}
			else
			{
				if(E[a].find(b)!=E[a].end())
					q.push(make_pair(a,b));
				E[a].insert(b);
				E[b].insert(a);
			}
		}
	for(int i=1;i<=n;i++)
		f[i]=i;
	rg int ans=n;
	while(!q.empty())
	{
		a=Find(q.front().first);
		b=Find(q.front().second);
		ans--;
		q.pop();
		if(E[a].size()<E[b].size())
			swap(a,b);
		E[b].erase(a);
		for(it=E[b].begin();it!=E[b].end();++it)
		{
			if(E[a].find(*it)!=E[a].end())
				q.push(make_pair(a,*it));
			E[a].insert(*it);
			E[*it].erase(b);
			E[*it].insert(a);
		}
		f[b]=a;
	}
	if(ans==1)
		puts("YES");
	else
		puts("NO");
	return 0;
}


Measured memory_bytes: 32512
//
//  atc1019.cpp
//  National Olympiad in Informatics in Provinces
//
//  Created by 黄子齐 on 2019/10/19.
//  Copyright © 2019 黄子齐. All rights reserved.
//

#include <stdio.h>
#include <algorithm>
#include <string.h>
const int N = 3e2+10;
#define ll long long
ll f[N][N], s[N][N];
int n, m, L, q;
using std::min;
int main() {
//    freopen("mytestdata.in", "r", stdin);
    scanf("%d%d%d", &n, &m, &L);
    memset(f, 0x3f, sizeof(f));
    memset(s, 0x3f, sizeof(s));
    for (int i=1; i<=m; i++) {
        int x, y, z;
        scanf("%d%d%d", &x, &y, &z);
        f[x][y] = f[y][x] = z;
    }
    for (int i=1; i<=n; i++) {
        f[i][i] = 0;
    }
    for (int k=1; k<=n; k++) {
        for (int i=1; i<=n; i++) {
            for (int j=1; j<=n; j++) {
                f[i][j] = min(f[i][j], f[i][k]+f[k][j]);
            }
        }
    }
    for (int i=1; i<=n; i++) {
        for (int j=1; j<=n; j++) {
            if (f[i][j] <= L) {
                s[i][j] = 0;
            }
        }
    }
    for (int k=1; k<=n; k++) {
        for (int i=1; i<=n; i++) {
            for (int j=1; j<=n; j++) {
                s[i][j] = min(s[i][j], s[i][k]+s[k][j]+1);
            }
        }
    }
    scanf("%d", &q);
    for (int i=1; i<=q; i++) {
        int x, y; scanf("%d%d", &x, &y);
        printf("%lld\n", (s[x][y]==s[0][0]?-1:s[x][y]));
    }
    return 0;
}


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

int main(){
  int N,n,d;
  int x[200],y[200];
  int a,b,l,r;

  while(cin >> N,N){
    x[0] = y[0] = 0;
    a = b = l = r = 0;
    for(int i=1;i<N;i++){
      cin >> n >> d;
      if(d==0){
	x[i] = x[n]-1;
	y[i] = y[n];
      }else if(d==1){
	x[i] = x[n];
	y[i] = y[n]-1;
      }else if(d==2){
	x[i] = x[n]+1;
	y[i] = y[n];
      }else{
	x[i] = x[n];
	y[i] = y[n]+1;
      }
      a = min(a,y[i]);
      b = max(b,y[i]);
      l = min(l,x[i]);
      r = max(r,x[i]);
    }
    cout << r-l+1 << " " << b-a+1 << endl;
  }
}

Measured memory_bytes: 1160
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>
#include <cassert>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//edit
class Solve {
public:
    void solve() {
//        Int H, W;
//        cin >> H >> W;
//        if (H > W) swap(H, W);
//        Int ans = H * W / 2 + (H * W % 2);
//        if (H == 1) {
//            ans = 1;
//        }
//        cout << ans << endl;

        Int a, b, c;
        cin >> a >> b >> c;

        Int right = (c - a - b) * (c - a - b);
        Int left = 4 * a * b;
        if (c - a - b <= 0) {
            cout << "No" << endl;
        } else if (left < right) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();


    return 0;
}


Measured memory_bytes: 888
// May this submission get accepted!

#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define UNIQUE(v) { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); }
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) { cerr << "[DEBUG] " #q ": ["; REP(i, (q).size()) { cerr << (q)[i] << (i == i_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; }
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
#define CHOKUDAI_ const
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using cll = DANCE_ DANCE_ CHOKUDAI_;
using  ld = long double;
using namespace std;

// モジュール

// 処理内容
int main() {
    
    ll n; cin >> n;
    vector<ll> p(n);
    REP(i, n) cin >> p[i];

    vector<ll> rank(n);
    iota(ALL_OF(rank), 0LL);
    sort(ALL_OF(rank), [&](ll i, ll j) {
        return p[i] > p[j];
    });
    
    multiset<ll> g;

    REP(i, 2) {
        g.insert(-1);
        g.insert(n);
    }

    ll ans = 0;
    REP(_i, n) {
        ll i = rank[_i];

        auto itr = g.lower_bound(i);
        auto itrl1 = itr;   itrl1--;
        auto itrl2 = itrl1; itrl2--;
        auto itrr1 = itr;
        auto itrr2 = itrr1; itrr2++;

        ll l1 = *itrl1;
        ll l2 = *itrl2;
        ll r1 = *itrr1;
        ll r2 = *itrr2;

        ll cnum = (i - l1) * (r2 - r1) + (r1 - i) * (l1 - l2);
        ans += p[i] * cnum;

        g.insert(i);

    }

    cout << ans << endl;
    
}

Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
#define data_type long long

int main()
{
  data_type n,m;
  cin>>n>>m;
  if(n==1 ||m ==1)
   return cout<<1<<endl,0;
   data_type x=(n+1)/2,x1=n/2,y=(m+1)/2,y1=m/2;
  cout<<x*y+x1*y1<<endl;


    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep1(i,n) for (int i = 1; i <= n; ++i)
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
const long long MOD = 1e9+7;
#define precout(val) cout << std::fixed << std::setprecision(20) << val;
const string alphabet = "abcdefghijklmnopqrstuvwxyz";
const int dy[4] = { 0, 1, 0, -1 };
const int dx[4] = { 1, 0, -1, 0 };

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

  int s,w; cin >> s >> w;
  if(w >= s) {
    cout << "unsafe" << endl;
  } else {
    cout << "safe" << endl;
  }
}


Measured memory_bytes: 3688