akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>

int main(){
    int n,k;
    scanf("%d %d",&n,&k);
    int min = n / k;
    int max;
    if(n % k >= 1){
        max = min + 1;
    }else{
        max = min;
    }
    printf("%d\n",max - min);

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
const int mod = 1000000007;
int n,ma=0;
std::vector<int> b,ans;
int main(){
  cin >> n;
  b.resize(n);
  for (size_t i = 0; i < n; i++) {
    cin >> b[i];
    ma = max(ma,b[i]);
  }
  for (size_t i = 0; i < n; i++) {
    for (size_t l = (ma < b.size() ? ma : b.size()); l > 0; l--) {
      if(l == b[l-1]){
        ans.push_back(b[l-1]);
        b.erase(b.begin()+(l-1));
        break;
      }
    }
  }
  if(ans.size() == n){
    reverse(all(ans));
    for (size_t i = 0; i < n; i++) {
      cout << ans[i] << endl;
    }
  }else{
    cout << -1 << endl;
  }
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;

long long arr[55];
long long stu[55];
long long ans = 0;
int n;
long long x;
void f(int d){
    if(x==arr[d]){
        ans += stu[d];
        return ;
    }else if(x){
        x--;// 吃掉最底层的 b
        if(x>arr[d-1]){
            x-=arr[d-1];
            ans += stu[d-1];
            x--;
            ans++;
            if(x)f(d-1);
        } else f(d-1);
    }
}
int main(){
    arr[0] = 1;
    arr[1] = 5;
    arr[2] = 13;
    stu[0] = 1;
    stu[1] = 3;
    stu[2] = 7;
    for(int i=3;i<51;i++){
        //arr[i] = 1+arr[i-1]+1+arr[i-1]+1;
        arr[i] = arr[i-1]*2+3;
        stu[i] = stu[i-1]*2+1;
    }
    scanf("%d%lld",&n,&x);
    f(n);
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#define MAX 100005
#define NIL -1
 
struct Node{
    int p, l, r;
};
struct Node T[MAX];
int dep=1,m;

main(){
  int i, j, d, v, c, l, n,tmp;
     
    scanf("%d", &n);
     
    for ( i = 0; i < n; i++ ) {
        T[i].p = T[i].l = T[i].r = NIL;
    }
     
    for (i = 0; i < n; i++){
        scanf("%d %d", &v, &d);
        for ( j = 0; j < d; j++ ){
      m=d;
            scanf("%d", &c);
             
            if(j==0){
                T[c].p=v;
                T[v].l=c;
        tmp=c;
            }
            else{
                T[c].p=v;
                T[tmp].r=c;
        tmp=c;
            }
             
        }
    }
     
    for ( i = 0; i < n; i++ ) print(i);
    return 0;
}


int depth(int u){
  if(T[u].p == NIL)return 0;
  if(T[T[u].p].p != NIL){
     dep++;
    depth(T[u].p);
  }
  return dep;
}
 
 
void print(int u){
  int i;
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].p);
  dep=1;
  printf("depth = %d, ",depth(u));
  
   if(T[u].p == NIL){
     printf("root, [");
     if(T[u].l != NIL){
      printf("%d",T[u].l);
      while( T[T[u].l].r!=NIL){
     printf(", %d", T[T[u].l].r);
     T[u].l=T[T[u].l].r;
      }
     }
      printf("]\n");
   }//Endroot
 
   else if(T[u].p != NIL && T[u].l != NIL){
      printf("internal node, [%d",T[u].l);
      while( T[T[u].l].r!=NIL){
     printf(", %d", T[T[u].l].r);
     T[u].l=T[T[u].l].r;
       }
      printf("]\n");
   }//Endroot
 
   else if(T[u].l == NIL){
  printf("leaf, []\n");
   }//Endleaf
 
}

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

int main()
{
	int N;
	cin >> N;
	vector<int> h(N + 2);
	for (int i = 0; i < N; i++) {
		cin >> h[i + 1];
	}
	int cnt = 0;
	for (int i = 0; i < N + 1; i++) {
		cnt += abs(h[i + 1] - h[i]);
	}
	cout << cnt / 2 << endl;
	return 0;
}


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

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

	int n=0;
	int i=x;
	while(i>0){
		n+=i%10;
		i/=10;
	}
	if(x%n==0)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main()
{
	int a, b, c, d, p, prix, priy, ans;

	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	scanf("%d",&d);
	scanf("%d",&p);

	prix = a * p;
	if(p <= c)
	{
		priy = b;
	}else{
		priy = b + (p-c)*d;
	}

	if(prix < priy)
	{
		ans = prix;
	}else{
		ans = priy;
	}

	printf("%d\n",ans);
	return 0;
}

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

int main() {
  int A , B , C , D;
  cin >> A >> B >> C >>D;
  if (A+B > C+D) {
    cout << "Left" << endl;
  }
  else if (A+B == C+D) {
    cout << "Balanced" << endl;
  }
  else {
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 3588
#include <cstdio>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <utility>
#include <string>

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ul;

const int iinf = 1 << 29;
const long long linf = 1l << 62;

int x[60];
int y[60];
int X[60];
int Y[60];
int N, K;

int main(int argc, char* argv[])
{
	scanf("%d %d", &N, &K);
	for(int i = 0; i < N; i++)
	{
		int x_, y_;
		scanf("%d %d", &x_, &y_);
		x[i] = x_;
		y[i] = y_;
		X[i] = x_;
		Y[i] = y_;
	}
	sort(X, X + N);
	sort(Y, Y + N);

	ll ans = linf;

	for(int left = 0; left < N; left++)
	{
		for(int right = left; right < N; right++)
		{
			for(int bottom = 0; bottom < N; bottom++)
			{
				for(int top = bottom; top < N; top++)
				{
					int count = 0;
					for(int i = 0; i < N; i++)
					{
						if(x[i] >= X[left] && x[i] <= X[right] && y[i] >= Y[bottom] && y[i] <= Y[top])
						{
							count++;
						}
					}
					if(count >= K)
					{
						ans = min(ans, ((ll)X[right] - (ll)X[left]) * ((ll)Y[top] - (ll)Y[bottom]));
					}
				}
			}
		}
	}
	printf("%lld\n", ans);

	return 0;
}


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

int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	int mod = 1000000007;
	long long sum = 0;
	for (int i = 0; i < N; i++)
	{
		cin >> A[i];
		sum += A[i];
		sum %= mod;
	}

	long ans = 0;

	//i について全探索する
	for (int i = 0; i < N; i++)
	{
		//A[i+1] ... A[N] の値を更新する
		sum -= A[i];
		if (sum < 0) sum += mod;

		ans += A[i] * sum;
		ans %= mod;
	}

	cout << ans << endl;
}



Measured memory_bytes: 4016
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;

int main() {
	double r0,w0,c,r,ans,w;
	for (;;) {
		r = 0, w = 0,ans=0;
		cin >> r0 >> w0 >> c >> r;
		if (r0 == 0 && w0 == 0 && c == 0 && r == 0) return 0;
		for (;;) {
			if ((r0+r*ans) / (w0+w) == c) {
				cout << ans << endl;
				break;
			}
			if ((r0 + r*ans) / (w0 + w) > c) {
				cout << ans << endl;
				break;
			}
			else ans++;
		}
	}
	return 0;
}

Measured memory_bytes: 3224
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int R = sc.nextInt();
    if (R < 1200) {
      System.out.println("ABC");
    } else if (R<2800) {
      System.out.println("ARC");
    } else {
      System.out.println("AGC");
    }
  }
}

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

#define ll long long
#define endl "\n" 
#define FOR(n) for(int i=0 ; i<n ; i++)
#define FORa(a, n) for(ll i=a ; i<=n ; i++)
ll mod=1000000007;
ll inf=1e9;
vector<ll> dp;
void solve()
{
  int ct=1,ans=0;
 string s ;
 cin >> s;
  if(s[0]==s[1] && s[1]==s[2] && s[0]=='R') cout << 3 ;
  else if((s[0]==s[1] && s[0]=='R') || (s[1]==s[2]  && s[1]=='R')) cout << 2 ;
  else if(s[0]=='R' || s[1]=='R' || s[2]=='R') cout << 1 ;
  else cout << 0 ;
  cout << endl;
}   

  


int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t=1;
  //cin >> t;
  while(t--)
    solve();
    return 0 ;
}
  

Measured memory_bytes: 3588
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    ll n;
    cin >> n;
    VL a(n);
    REP(i,n){
        a[i] = in() - i;
    }
    VL b(a);
    sort(ALL(b));
    ll x = b[n/2];
    ll ans = 0;
    REP(i,n) ans += abs(x - a[i]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3328
gets
ARGF.each_line do |line|
  x1, y1, x2, y2, x3, y3 = line.split.map(&:to_f)
  
  px = -((y2-y1)*y3**2 + (-y2**2+y1**2-x2**2+x1**2)*y3 + y1*y2**2 + (-y1**2+x3**2-x1**2)*y2 + (x2**2-x3**2)*y1) /
        ((2*x2-2*x1)*y3 + (2*x1-2*x3)*y2 + (2*x3-2*x2)*y1)
  py = ((x2-x1)*y3**2 + (x1-x3)*y2**2 + (x3-x2)*y1**2 + (x2-x1)*x3**2 + (x1**2-x2**2)*x3 + x1*x2**2 - x1**2*x2) /
       ((2*x2-2*x1)*y3 + (2*x1-2*x3)*y2 + (2*x3-2*x2)*y1)
  r = Math.sqrt((px - x1)**2 + (py - y1)**2)

  puts [sprintf("%#.3f", (px * 1000).round / 1000.0) , sprintf("%.3f", (py * 1000).round / 1000.0), sprintf("%#.3f", (r * 1000).round / 1000.0)].join("\s")
end

Measured memory_bytes: 8780
#include <bits/stdc++.h>
using namespace std;
#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 ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define pb push_back
#define mp make_pair
#define INF9 1000000000 //10^9
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pii=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
using vb=vector<bool>;
int n,q,m,k,l,ans;
vi a,b;
ll lans;
vll la,lb;
string s;

// 初期位置と活発度を保持
struct Child{
    int i;
    ll v;
    Child(int i, ll v){this->i = i;this->v = v;}
};

int main() {
    // 入力
    cin >> n;
    vector<Child> childs;
    rep(i,n) {
        ll tmp;cin >> tmp;
        childs.pb(Child(i,tmp));
    }
    // 活発度の降順にソート
    sort(ALL(childs),[](Child& c1, Child& c2){return c1.v > c2.v;});

    // 活発度が大きい順に左右どちらかに振り分けていく
    // dp[i][j] : 左端にi人,右端にj人置いたときのうれしさの合計
    ll dp[n+1][n+1];
    dp[0][0] = 0;
    // 左端のみ、右端のみに並べる場合
    rep(i,n) {
        Child c = childs[i];
        dp[i+1][0] = dp[i][0] + c.v * abs(c.i - i);
        dp[0][i+1] = dp[0][i] + c.v * abs(n-1-i - c.i);
    }
    rng(i,1,n+1){
        rng(j,1,n+1){
            if(i+j>n){
                dp[i][j] = max(dp[i][j-1],dp[i-1][j]);
            }else{
                Child c = childs[i+j-1];
                ll left = dp[i-1][j] + c.v * abs(c.i - (i-1));
                ll right = dp[i][j-1] + c.v * abs(n-j - c.i);
                dp[i][j] = max(left,right);
            }
        }
    }

    cout << dp[n][n] << endl;
    return 0;
}

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

using namespace std;
#define eps = (1e-10);
//点
struct Point{
    double x,y;
    Point(double _x=0,double _y=0):x(_x),y(_y){}
    Point operator + (Point p){return Point(x+p.x,y+p.y);}
    Point operator - (Point p){return Point(x-p.x,y-p.y);}
    Point operator * (double a){return Point(a*x,a*y);}
    Point operator / (double a){return Point(x/a,y/a);}
    double norm(){return x*x+y*y;}//模的平方
    double ABS() {return sqrt(norm());}//模
};
//线段
struct Segment{
    Point p1,p2;
};
double dot(Point a,Point b){
    return a.x*b.x+a.y*b.y;
}
double cross(Point a,Point b){
    return a.x*b.y-a.y*b.x;
}
//计算p1,p2为线段，p,p1向线段上的投影坐标(x,y)
Point cal(Point p,Segment s){
    Point alp=p-s.p1;Point beta=s.p2-s.p1;
    //cout<<p.x<<' '<<p.y<<' '<<' '<<s.p1.x<<' '<<s.p1.y<<' '<<alp.x<<' '<<alp.y<<endl;
    double res=dot(alp,beta)/beta.norm();
    return s.p1+(beta*res);
}
int main(){
    double x1,y1,x2,y2;
    scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
    Point p1={x1,y1};Point p2={x2,y2};
    Segment s={p1,p2};
    int T;
    scanf("%d",&T);
    double x,y;
    while(T--){
        scanf("%lf %lf",&x,&y);
        Point p={x,y};
        Point ans=cal(p,s);
        printf("%.11lf %.11lf\n",ans.x,ans.y);
    }
    return 0;
}


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

struct UF{
   vector<int> par;
   vector<int> sz;
   UF(){}
   UF(int n){
       par.resize(n);
       sz.resize(n, 1);
       for(int i = 0; i < n; i++) par[i] = i;
   }
   int find(int x){
       if(x == par[x]) return x;
       return par[x] = find(par[x]);
   }
   void unite(int x, int y){
       x = find(x); y = find(y);
       if(x == y) return;
       if(sz[x] < sz[y]) swap(x, y);
       sz[x] += sz[y];
       par[y] = x;
   }
   bool same(int x, int y){
       return find(x) == find(y);
   }
};

struct edge{
    int u, v, cost;
    bool operator<(const edge &e) const{
        return cost < e.cost;
    }
};

int n, m;
vector<edge> es; 

int kruskal(){
    int res = 0;    
    UF uf(n);
    sort(es.begin(), es.end());
    for(int i = 0; i < m; i++){
        edge e = es[i];
        if(!uf.same(e.u, e.v)){
            uf.unite(e.u, e.v);
            res += e.cost;
        }
    }
    return res;
}

int main(){
    cin >> n;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            int in;
            cin >> in;
            if(in == -1) continue;
            es.push_back({i, j, in});
        }
    }
    m = es.size();
    cout << kruskal() << endl;
}


Measured memory_bytes: 3272
import Control.Applicative
import Control.Monad
import Data.List
import Data.Array.Unboxed

main = do
    n <- readLn :: IO Int
    as <- fmap read . words <$> getLine :: IO [Int]
    let ary = listArray (1, n) as :: UArray Int Int
    let ans = length $ filter (\(i, a) -> ary ! a == i) (zip [1..] as)
    print (ans `div` 2)

Measured memory_bytes: 31100
# Returns length of LCS for X[0..m-1], Y[0..n-1] 
def lcs(X, Y, m, n): 
	L = [[0 for x in range(n+1)] for x in range(m+1)] 

	# Following steps build L[m+1][n+1] in bottom up fashion. Note 
	# that L[i][j] contains length of LCS of X[0..i-1] and Y[0..j-1] 
	for i in range(m+1): 
		for j in range(n+1): 
			if i == 0 or j == 0: 
				L[i][j] = 0
			elif X[i-1] == Y[j-1]: 
				L[i][j] = L[i-1][j-1] + 1
			else: 
				L[i][j] = max(L[i-1][j], L[i][j-1]) 

	# Following code is used to print LCS 
	index = L[m][n] 

	# Create a character array to store the lcs string 
	lcs = [""] * (index+1) 
	lcs[index] = "" 

	# Start from the right-most-bottom-most corner and 
	# one by one store characters in lcs[] 
	i = m 
	j = n 
	while i > 0 and j > 0: 

		# If current character in X[] and Y are same, then 
		# current character is part of LCS 
		if X[i-1] == Y[j-1]: 
			lcs[index-1] = X[i-1] 
			i-=1
			j-=1
			index-=1

		# If not same, then find the larger of two and 
		# go in the direction of larger value 
		elif L[i-1][j] > L[i][j-1]: 
			i-=1
		else: 
			j-=1

	print (''.join(lcs))

# Driver program 

s=input()
t=input()
m = len(s) 
n = len(t) 
lcs(s, t, m, n) 

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

int main(void)
{
	int n;
	while (cin >> n, n){
		int c1, m1, s1, m2, s2, m3, s3, m4, s4;
		vector < pair < pair <int, int>, int> > data;
		for (int i = 0; i < n; i++){
			cin >> c1 >> m1 >> s1 >> m2 >> s2 >> m3 >> s3 >> m4 >> s4;
			int minute = m1 + m2 + m3 + m4;
			int sec = s1 + s2 + s3 + s4;
			minute += (sec / 60);
			sec %= 60;
			data.push_back(make_pair(make_pair(minute, sec), c1));
		}
		sort(data.begin(), data.end());
		cout << data[0].second << endl;
		cout << data[1].second << endl;
		cout << data[data.size() - 2].second << endl;
	}

	return 0;
}

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

int main(){
  int n, t;
  cin >> n >> t;
  string s[2][n];
  int time[2][n];
  for(int j = 0; j < n; j++){
    for(int i = 0;i < 2; i++){
      int a, b;
      scanf("%d:%d", &a, &b);
      time[i][j] = 60*a + b;
    cin >> s[i][j];
    }
  }
  int ans = 0;
  vector<int> id;
  for(int i = 1; i < n; i++) {
    if(time[0][i] - time[1][i - 1] >= t){
      ans++;
      id.push_back(i);
    }
  }
  cout << ans << endl;
  for(int i = 0; i < id.size(); i++) {
    cout << s[0][id[i]] << " " << time[0][id[i]] - time[1][id[i] - 1] << endl;
  }
  
  return 0;
}

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

using namespace std;

int main(){
    int A,B,C,add=0;
    cin >> A >> B >> C;
    if(A%2==B%2 && B%2==C%2){
    }else{
        if(A%2!=B%2 && B%2==C%2){
            B++;
            C++;
            add++;
        }else if(A%2==B%2 && B%2!=C%2){
            A++;
            B++;
            add++;
        }else{
            A++;
            C++;
            add++;
        }
    }
    cout << (max({A,B,C})-A)/2 +  (max({A,B,C})-B)/2 +  (max({A,B,C})-C)/2 + add << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <string>
#include <algorithm>
#include <cmath>
#include <climits>
#define REP(i, n) for(int i=0; i<(n); i++)
#define FOR(i, a, n) for(int i=(a); i<(n); i++)
using namespace std;

int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int ans=a*b > c*d ? a*b : c*d;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int a = input.nextInt();
        int b = input.nextInt();
        int c = input.nextInt();
        if ((a <= c && c <= b) || (b <= c && c <= a) ){
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

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

int main() {
  int sum = 0;
  int a[5];
  int minpos = -1;

  for (int i = 0; i < 5; i++) {
    cin >> a[i];

    if (minpos == -1 || ((a[minpos] % 10 > a[i] % 10) && a[i] % 10 != 0))
      minpos = i;
  }

  for (int i = 0; i < 5; i++){
    int b = a[i];
    if (minpos == i)
      continue;

    if (b % 10 >= 1) {
      b -= b % 10;
      b += 10;
    }
    sum += b;
  }

  sum += a[minpos];

  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
using ll = long long;
using ld = long double;

#define ALL(x) begin(x), end(x)
#define REP(i, n) for (size_t i = 0, i##_len = (n); i < i##_len; ++i)

const string YES = "Possible";
const string NO = "Impossible";

void solve(ll A, ll B) {
  bool pred = A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0;
  cout << (pred ? YES : NO) << endl;
}

int main() {
  ll A;
  cin >> A;
  ll B;
  cin >> B;
  solve(A, B);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long i = 0; i < n; i++)
#define erep(i, n) for(long i = 1; i <= n; i++)
const long MOD = 1000000007;

int main() {string S, T;
cin >> S >> T;
 long N = S.size();
map<char, int> sword;
map<char, int> tword;
vector<long> safter(N);
vector<long> tafter(N);

// for(char x = 'a'; x <= 'z'; x++){
//     after[x] = x;
// }
map<char, bool> viss;
map<char, bool> vist;


long k = 1;
rep(i, N){
    if(viss[S.at(i)] == false){
        viss[S.at(i)] = true;
        sword[S.at(i)] = k;
        safter.at(i) = k;
        k++;
    }
    else{
        safter.at(i) = sword[S.at(i)];
    }
}
k = 1;
rep(i, N){
    if(vist[T.at(i)] == false){
        vist[T.at(i)] = true;
        tword[T.at(i)] = k;
        tafter.at(i) = k;
        k++;
    }
    else{
        tafter.at(i) = tword[T.at(i)];
    }
}
rep(i, N){
    if(safter.at(i) != tafter.at(i)){
        cout << "No" << endl;
        return 0;
    }
}

cout << "Yes" << endl;
return 0;

}



Measured memory_bytes: 3848
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define all(a) a.begin(), a.end()
#define mkp make_pair
#define F first
#define S second
#define pb push_back
#define ll long long
#define vi vector<long long>
#define sz(x) (int)x.size()
#define pi pair<long long, long long>
#define endl '\n'
#define _ << ' '
#define FAST_LOG2(x) (sizeof(unsigned long)*8 - 1 - __builtin_clzl((unsigned long)(x)))
#define clog2(x) (((x) - (1 << FAST_LOG2(x))) ? FAST_LOG2(x) + 1 : FAST_LOG2(x))
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> idxset;
//find_by_order(i) : iterator to the value at index i, order_of_key(x) : the index of value x
const ll mod = 998244353;
const ll INF = (ll)1e9+1;
const ll N = 1e5;

int n, k, q, a[100001];

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    #ifndef ONLINE_JUDGE
    //freopen("B.txt", "r", stdin);
    #endif
    cin >> n >> k >> q;
    for(int i=0; i<n; i++){
        a[i] = k-q;
    }
    int in;
    for(int i=0; i<q; i++){
        cin >> in;
        a[in-1] ++;
    }
    for(int i=0; i<n; i++){
        if(a[i]>0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}


Measured memory_bytes: 1152
N, A, B = map(int, input().split())
S = input()
J = ""

a_cnt = 0
b_cnt = 0

for i in range(N):
    if S[i] == "a":
        if a_cnt + b_cnt < A + B:
            J += "Yes\n"
            a_cnt += 1
        else:
            J += "No\n"
    elif S[i] == "b":
        if a_cnt + b_cnt < A + B and b_cnt < B:
            J += "Yes\n"
            b_cnt += 1
        else:
            J += "No\n"
    else:
        J += "No\n"

print(J)

Measured memory_bytes: 9836
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  unsigned long int answer=0;
  unsigned long int N=0;
  unsigned long int n=0;
  unsigned long int A=0;
  unsigned long int B=0;
  
  cin >> N >> A >> B;

  if(N >= A+B){
    n = N%(A+B);
    answer += A * (N/(A+B));
  }else{
    n = N;
  }

  if(n < A){
    answer += n;
  }else{
    answer += A;
  }
  
  cout << answer;

  return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <vector>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define ctoi(c) c - '0'
#define tos(s) to_string(s)

typedef long long ll;


int main() {
    int a,b;
    cin >> a >> b;
    rep(i, 1010) {
        if (int(i*0.08) == a && int(i*0.1) == b) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

/*
ACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACAC                                                                              
                                   ******,  .,, .,, ,,,    ****.**              
                                   ** . .,,,,,,,,,,,,,,,,,,,,,. .,*             
                                   **,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,.            
                                .,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,.        
                                .,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,.        
                    ****      ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,      
              ***************,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,    
         ********************,,,,,,,,,,,,,,@@@,,,,,,,,,,,/@@@,,,,,,,,,,,,,,,    
        ******************,,,,,,,,,,,,,,,,,,(,,.         ,,,,,,,,,,,,,,,,,,,    
       ********************,,,,,,,,,,,*,,,,,.     %&&&     .,,,,*,,,,,,,,,,,,.  
       ***,,,,,,,,,,,,,,*,,,,,,,,,,,,,,,,,,,,               ,,,,,,,,,,,,,,,,,   
       ,,,,,,,,,,,,,,,,,,,**,,,,,,,,,,.......      ##(     ........,,,,,,,,,,.  
     .,,,,,,,,,,,,,,,,,,**,,,,,,,,,,..............    ..............,,,,,,,,    
    .,,,,,,,,,,,,,,,,,,,**,,,,,,,,,.................................,,,,,,,,,   
   ,,,,,,,,,,,,,,,,,,,,***,,,,,,,....................................,,,,,,,,,  
   ,,,,,,,,,,,,,,,,,,,,**,,,,,,,,.....................................,,,,,,,   
   ,,,,,,,,,,,,,,,,,,,,,**,,,,,,,,....................................,,,,,,,   
   ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,.....................................,,,,,     
   ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,...................................,.,,,,,     
    ,,,,,,,,,,,,,,,,,,,,,,,,,,,,.....................................,,,        
     ,,,,,,,,,,,,,,,,,,,,,,,,,,,,....................................,,,        
      ,,,,,,,,,,,,,,,,,,,,,,,,,,,,...................................,          
       ..,,,,,,,,,,,,,,,,,,,,,,,,,,.................................,           
       .........**.....       ,,,,,..............................               
        .......*......                  ****,**,       ,..****                  
        .......*,....                   .......        ......                   
          .......*....                   .....          .....                   
                                         ......          .....                  
*/

Measured memory_bytes: 3192
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;
typedef long long ll;

int a, b;
int main(void) {
  int n;
  scanf("%d%d%d", &n, &a, &b);
  int maxi = min(a, b);
  int mini = min(n, max(0, a + b - n));
  cout << maxi << " " << mini << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fastIO std::ios_base::sync_with_stdio(false); std::cin.tie(0); std::cout.tie(0)
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
//mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
const int INF = 0x3f3f3f3f;
//int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

const int maxn = 4e5 + 10; 

int n;
ll k,a[maxn];

int main()
{
	fastIO;
	cin >> k >> n;
	rep(i,0,n){
		cin >> a[i];
		a[i + n] = a[i];
	}
	ll ans = LLONG_MAX;
	ll tmp = 0;
	rep(i,1,n) {
		tmp += a[i] - a[i - 1];
	}
	ans = min(ans,tmp);
	rep(i,1,n ) {
		tmp -= (a[i] - a[i - 1]);
		//cout << a[i + n - 1]  << " " << a[i + n - 2] << endl;
		tmp += (a[i + n - 1] - a[i + n - 2] + k) % k;
		//cout << tmp << endl;
		ans = min(ans,tmp);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3328
def insertionsort(a,n,g)
  cnt = 0
  for i in g...n
    v = a[i]
    j = i-g
    while j >= 0 && a[j] > v
      a[j+g] = a[j]
      j -= g
      cnt += 1
    end
    a[j+g] = v
  end
  cnt
end

def shellsort(a,n)
  cnt = 0
  g = Array.new
  m = h = 1
  g.push(h)
  while h * 3 + 1 < n
    h = h * 3 + 1
    g.unshift(h)
    m += 1
  end
  puts m
  for i in 0...m
    print " " unless i == 0
    print g[i]
  end
  print "\n"
  for i in 0...m
    cnt += insertionsort(a,n,g[i])
  end
  puts cnt
end

n = gets.to_i
a = Array.new(n)
for i in 0...n
  a[i] = gets.to_i
end
shellsort(a,n)
for i in 0...n
  puts a[i]
end

Measured memory_bytes: 13924
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
    vector<int> v;
    int i,n,t,cou = 0,x,mid;
    vector<int>::iterator ip;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>t;
        v.push_back(t);
    }
    sort(v.begin(), v.end());
    cout<<v[n/2]-v[-1+(n/2)]<<endl;
    return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
#define int long long
using P = pair<int, int>;
constexpr array<int, 4> dx = {1, 0, -1, 0};
constexpr array<int, 4> dy = {0, 1, 0, -1};
constexpr int INF = 1234567890;
constexpr int MOD = 1000000000 + 7;
// constexpr int MOD = 998244353;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int fact(int n) { return n > 1 ? n * fact(n - 1) % MOD : 1; }
int modinv(int a)
{
    int b = MOD, u = 1, v = 0;
    while (b)
    {
        int t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= MOD;
    if (u < 0)
        u += MOD;
    return u;
}
constexpr int modpow(int a, int n)
{
    int rtn = 1;
    while (n > 0)
    {
        if (n & 1)
            rtn = rtn * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return rtn;
}

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

    int x, y;
    int ans = 0;
    cin >> x >> y;
    switch (x)
    {
    case 3:
        ans += 100000;
        break;
    case 2:
        ans += 200000;
        break;
    case 1:
        ans += 300000;
        break;
    }
    switch (y)
    {
    case 3:
        ans += 100000;
        break;
    case 2:
        ans += 200000;
        break;
    case 1:
        ans += 300000;
        break;
    }
    if (x == 1 && y == 1)
    {
        ans += 400000;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
//#include <math.h>
#include <set>
#include<iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
#define all(a) a.begin(),a.end()
#define P pair<int,int>
#define space ' '
#define pll pair<ll,ll>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

bool jud(ll x){
    for(ll i=2;i*i<=x;i++){
        if(x%i==0){
            return false;
        }
        if(x%i==0&&x%(x/i)==0){
            return false;
        }
    }
    return true;
}

int main(){
    
    ll x;
    cin >> x;
    
    while(true){
        bool key = jud(x);
        if(key)break;
        x++;
    }
    
    cout << x<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm> 
#include <cstdlib>
#include <map>
#include <queue>
#include <vector>
#define ll long long
using namespace std;
int main(){
	int a[4];
	for(int i=0;i<4;i++){
		cin >> a[i];
	}
	sort(a,a+4);

	if(a[0]==1&&a[1]==4&&a[2]==7&&a[3]==9){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}
}
	



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long n,ans=0;
  cin>>n;
  vector<long long> vec(n);
  for (long long i = 0; i < n; i++) {
 cin>>vec.at(i);
  }
   sort(vec.begin(), vec.end()); 
  for (long long i = 1; i < n; i++) {
    ans+=vec.at(n-i/2-1);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 4820
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const ll INF = 1LL << 60;


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

    int ans = 0;
    while(1){
        ans++;
        //printf("%d %d %d\n",ans,(int)(ans*0.08),(int)(ans*0.1));

        if((int)(ans*0.08) == A){
            
            if((int)(ans*0.1) == B){
                break;
            }
        }
        if(ans > 10500){
            cout << "-1" << endl;
            return 0;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<set>
#include<algorithm>
#include<queue>
#include<functional>
#define ll long long
#define PLL pair<ll,ll>
#define VS vector<string>
#define VL vector<ll>
#define rep(i,a) for (ll i=0;i<a;i++)
#define nrep(i,n,a) for (ll i=n;i<a;i++)
#define mrep(i,a) for(ll i=a;i>=0;i--)
#define INF 1145141919810
#define VMIN(vec) *std::max_element(vec.begin(),vec.end())
#define VMIN(vec) *std::max_element(vec.begin(),vec.end())
#define TS(n) to_string(n)

using namespace std;


int main() {
	string s;
	cin >> s;
	rep(i, s.size() - 1){
		if (s[i] == s[i + 1]){
			cout << i + 1 << " " << i + 2 << endl;
			return 0;
		}if (i < s.size() - 2 && s[i] == s[i + 2]){
			cout << i + 1 << " " << i + 3 << endl;
			return 0;
		}
	}cout << -1 << " " << -1 << endl;
	return 0;
}

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

int main(){

    int N;
    cin >> N;
    vector<int64_t> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A.at(i);
    }

    sort(A.begin(),A.end());
    A.erase(unique(A.begin(),A.end()),A.end());

    if(A.size() == N){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 1792
#include <atcoder/dsu>
#include <cstdio>
#include <iostream>
using namespace std;
using namespace atcoder;
 
int main() {
    int n, m, i, cnt = 0;
    cin >> n >> m;
    int check[n];
    for (i = 0; i < n; i++) {
        check[i] = 0;
    }
    dsu d(n);
    for (i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        d.merge(a-1, b-1);
    }
    for (i = 0; i < n; i++){
        check[d.leader(i)] = 1;
    }
    for (i = 0; i < n; i++){
        if (check[i] == 1){
            cnt++;
        }
    }
    cout << cnt-1 << endl;
    return 0;
}


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

typedef pair<int,int> pii;
typedef pair<pii,int> tri;
int main(){
  int m,t,p,r;
  int team[55][15];
  while(cin>>m>>t>>p>>r,m){
    memset(team,0,sizeof(team));
    vector<tri> ans;
    int a,b,c,d;
    for(int i=0;i<r;i++){
      cin>>a>>b>>c>>d;
      if(d!=0){
	team[b][c]++;
      }else{
	team[b][p+1]+=a+20*team[b][c];
	team[b][p+2]++;
      }
    }
    for(int i=1;i<=t;i++){
      ans.push_back(tri(pii(-team[i][p+2],team[i][p+1]),-i));
    }
    sort(ans.begin(),ans.end());
    for(int i=0;i<t;i++){
      cout<<-ans[i].second;
      if(i+1==t)cout<<endl;
      else if(ans[i].first == ans[i+1].first)cout<<"=";
      else cout<<",";
    }
  }
}

Measured memory_bytes: 1200
#!/usr/bin/env python3
import sys


def solve(S, Q, Qvery):
    pool = []
    fw = True
    for qvery in reversed(Qvery):
        if qvery[0] == 1:
            if fw:
                fw = False
            else:
                fw = True
        else:
            if qvery[1] == 1 and fw or qvery[1] == 2 and not fw:  # 先頭に描く
                print(qvery[2], end='')
            else:
                pool.append(qvery[2])

    if fw:
        print(S, end='')
    else:
        rev_S = S[::-1]
        print(rev_S, end='')
    for p in reversed(pool):
        print(p, end='')
    print()

    # fw = True
    # ret = list(S)
    # # ret.append(S)
    # for qvery in Qvery:
    #     if qvery[0] == 1:
    #         # fw = not fw
    #         if fw:
    #             fw = False
    #         else:
    #             fw = True
    #     else:
    #         if qvery[1] == 1 and fw or qvery[1] == 2 and not fw:  # 先頭に追加
    #             ret.insert(0, qvery[2])
    #             # S = qvery[2] + S
    #         else:  # 末尾に追加
    #             ret.append(qvery[2])
    #             # S = S + qvery[2]

    # if fw:
    #     print(''.join(ret))
    # else:
    #     rev_ret = ret[::-1]
    #     print(''.join(rev_ret))


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = str(next(tokens))  # type: int
    Q = int(next(tokens))  # type: int
    Qvery = []
    for i in range(Q):
        T = int(next(tokens))
        if T == 1:
            Qvery.append([1])
        elif T == 2:
            Qvery.append([2, int(next(tokens)), str(next(tokens))])
    solve(S, Q, Qvery)

if __name__ == '__main__':
    main()


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

int main(){
  int a;
  int cnt5=0,cnt7=0;
  for(int i=0;i<3;i++){
    cin >> a;
    if(a==7){
      cnt7++;
    }else if(a==5){
      cnt5++;
    }
  }
  if(cnt5==2&&cnt7==1)cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}
    

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

int main() {
	int a,b;
	cin >> a >> b;
	if (a > b){
		cout << "a > b"<< endl;
	}else if( a < b ){
		cout << "a < b" << endl;
	}else if( a == b ){
		cout << "a == b" << endl;
	}
	return 0;
}


Measured memory_bytes: 3084
#include <cstring>
#include <map>
#include <unordered_map>
#include <string>
#include <list>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdio>
#include <iostream>
#include <set>
#include <unordered_set>
using namespace std;

#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int, int> pii;

int gi() {
    int a;
    scanf("%d", &a);
    return a;
}

ll gli() {
    ll a;
    scanf("%lld", &a);
    return a;
}

#define M 1000000007

int n;
int c[200000];
int p2[200004];
vector<int> ne[200000];
int res = 0;

void dfsc(int a, int p) {
    int r = 1;
    for (int b : ne[a])
        if (b != p) {
            dfsc(b, a);
            r += c[b];
        }
    c[a] = r;
}

void dfs(int a, int p) {
    for (int b : ne[a])
        if (b != p) {
            dfs(b, a);
            res += (p2[c[b]]+M-1) % M;
            res %= M;
        }
    res += p2[n - c[a]];
    res %= M;
}

ll pw(ll a, ll b) {
    if (b == 0)
        return 1;
    ll x = pw(a, b/2LL);
    x *= x;
    x %= M;
    if (b%2LL)
        return (x*a)%M;
    return x;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    n = gi();
    for (int i = 1; i < n; i++) {
        int x = gi()-1;
        int y = gi()-1;
        ne[x].push_back(y);
        ne[y].push_back(x);
    }

    p2[0] = 1;
    for (int i = 1; i <= n; i++) {
        p2[i] = p2[i-1] * 2;
        p2[i] %= M;
    }

    dfsc(0, -1);
    dfs(0, -1);

    int tot = (ll(n) * ll(p2[n-1])) % M;
    res = (tot + M - res) % M;

    int den = pw(p2[n], M-2);
    res = (ll(res) * ll(den)) % M;
    printf("%d\n", res);

    return 0;
}


Measured memory_bytes: 23936
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<bitset>
using namespace std;
#define gc getchar()
inline int read(){
	register int x(0);register char c(gc);
	while(c>'9'||c<'0')c=gc;
	while(c>='0'&&c<='9')x=x*10+c-48,c=gc;
	return x;
}
const int N=1100,M=520000;
int X[M],Y[M],mustdie[N],n,m,ans;
bitset<810> mustlive[N];
int main(){
	n=read();m=read();
	register int i,j;
	for(i=1;i<=m;i++)X[i]=read(),Y[i]=read();
	for(i=1;i<=n;i++){
		mustlive[i][i]=1;
		for(j=m;j>=1;j--)
			if(mustlive[i][X[j]]&&mustlive[i][Y[j]]){
				mustdie[i]=1;break;
			}
			else if(mustlive[i][X[j]])mustlive[i][Y[j]]=1;
			else if(mustlive[i][Y[j]])mustlive[i][X[j]]=1;
	}
	for(i=1;i<n;i++){
		if(mustdie[i])continue;
		for(j=i+1;j<=n;j++){
			if(mustdie[j])continue;	
			if(!(mustlive[i]&mustlive[j]).any())ans++;
		}
	}
	cout<<ans;
}

Measured memory_bytes: 2816
#include<bits/stdc++.h>
using namespace std;
int a[100+10];
int main(){
	int n,k;
	scanf("%d %d",&n,&k);
	for(int i=1;i<=k;i++){
		int d;
		scanf("%d",&d);
		for(int j=1;j<=d;j++){
			int t;
			scanf("%d",&t);
			a[t]++;
		}
	}
	int ans=0;
	for(int i=1;i<=n;i++){
		if(a[i]==0)
			ans++;
	}
	printf("%d\n",ans);
	return 0;
} 

Measured memory_bytes: 3812
import sys

n = int(input())
aaa = list(map(int, sys.stdin))
MOD = 998244353

s = sum(aaa)
dp1 = [0] * (s + 1)
dp2 = [0] * (s + 1)
dp1[0] = 1
dp2[0] = 1
tmp_sum = 0
for a in aaa:
    for i in range(tmp_sum, -1, -1):
        dp1[i + a] += dp1[i]
        dp1[i] *= 2
        dp2[i + a] += dp2[i]
    for i in range(tmp_sum, -1, -1):
        dp1[i] %= MOD
        dp2[i] %= MOD
    tmp_sum += a

h = (s + 1) // 2
ans = (pow(3, n, MOD) - sum(dp1[h:]) * 3) % MOD
if s % 2 == 0:
    ans = (ans + dp2[h] * 3) % MOD
print(ans)


Measured memory_bytes: 42460
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		int n = 0;
		Scanner scan = new Scanner(System.in);
		n = scan.nextInt();

		for(int i = 0; i < n; i++) {
			int left = Integer.MIN_VALUE, right = Integer.MIN_VALUE;
			boolean isCorrect = true;

			for(int j = 0; j < 10; j++) {
				int ball = scan.nextInt();
				if(ball > left) {
					left = ball;
				} else if(ball > right) {
					right = ball;
				} else {
					isCorrect = false;
				}
			}

			System.out.println(isCorrect ? "YES" : "NO");
		}

		scan.close();
	}

}


Measured memory_bytes: 26208
#include<stdio.h>

int main(){
    int s;
    int Y,M;
    int ans=0;

    scanf("%d", &s);
    Y=s/100;
    M=s%100;

    if(M>0 && M<13){
        ans += 1;
    }
    if(Y>0 && Y<13){
        ans += 2;
    }

    if(ans==0){
        printf("NA");
    }if(ans==1){
        printf("YYMM");
    }if(ans==2){
        printf("MMYY");
    }if(ans==3){
        printf("AMBIGUOUS");
    }

    return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main {

    private static final int MOD = 1_000_000_007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int N = sc.nextInt();
        int sum = 0;
        for (int i = 0; i < N; i++) {
            sum += sc.nextInt();
        }

        System.out.println(sum >= H ? "Yes" : "No");
    }
}


Measured memory_bytes: 47940
#include <bits/stdc++.h>
#include <ext/numeric>

using namespace std;
using namespace __gnu_cxx;

#define all(v)   v.begin(), v.end()
#define endl "\n"
#define pb push_back
#define F first
#define S second
#define THINK_TWICE_CODE_ONCE cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
#define isOdd(n)    (n&1)
#define LLMAX LLONG_MAX
#define LLMIN LLONG_MIN
#define IMN INT_MIN
#define IMX INT_MAX
#define pow(n, m) power((ll)n, (ll)m)
#define numOfDigits(n)  ((n)? (ll)(log10(n)+1) : 1)
#define mem(x, val)    memset(x, val, sizeof(x))
#define MOD 1000000007

typedef long long ll;
typedef long double ld;
typedef double dd;
typedef string str;
typedef pair<int, int> pii;


int main()
{
    THINK_TWICE_CODE_ONCE
    //freopen("test cases\\.txt", "r", stdin) ;
    ll n, k; cin>>n>>k;
    vector<pii> v(n);
    for(int i = 0; i<n; i++) cin>>v[i].F>>v[i].S;
    sort(all(v));
    ll sum = 0;
    for(int i  = 0; i<n; i++){
        sum += v[i].S;
        if(sum>=k)return cout<<v[i].F, 0;
    }
	return 0;

}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)
#define mp std::make_pair

typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int,int> P;
typedef std::pair<int,P> State;

const int INF = 1001001001;

// S N E W(南北東西)
const int dx[8] = {0, 0, 1, -1, 1, 1, -1, -1}, dy[8] = {1, -1, 0, 0, 1, -1, 1, -1};

struct Deck{
    int first, last;
};

Deck ds[100];
// dp[i][j][k] := 位置iからj個とk個の山に分ける時の最小値
int dp[100][101][101];

int rec(int pos, int a, int b){
    if(dp[pos][a][b] != -1){
        return dp[pos][a][b];
    }

    if(a == 0 || b == 0){
        return 0;
    }

    int res = ds[pos].first * ds[pos+a-1].last * ds[pos+a].first * ds[pos+a+b-1].last;
    // printf("%d, %d, %d: %d\n", pos, a, b, res);
    if(a == 1 && b == 1){
        return res;
    }

    int min_a = rec(pos, 1, a-1);
    FOR(i, 2, a){
        min_a = std::min(rec(pos, i, a-i), min_a);
    }

    int min_b = rec(pos+a, 1, b-1);
    FOR(i, 2, b){
        min_b = std::min(rec(pos+a, i, b-i), min_b);
    }

    res += min_a + min_b;
    return dp[pos][a][b] = res;
}

int main(){
    int N;
    std::cin >> N;
    
    REP(i, N){
        std::cin >> ds[i].first >> ds[i].last;
    }
    std::fill(dp[0][0], dp[0][0]+100*101*101, -1);
    
    int res = rec(0, 1, N-1);
    FOR(i, 2, N){
        res = std::min(rec(0, i, N-i), res);
    }

    std::cout << res << std::endl;
}

Measured memory_bytes: 5148
// AOJ 3051 Lunch
// 2018.3.16 bal4u

#include <stdio.h>
#include <stdlib.h>

int main()
{
	int max, a, i, id;

	max = 0; for (i = 0; i < 3; i++) {
		scanf("%d", &a);
		if (a > max) max = a, id = i;
	}
	printf("%c\n", 'A' + id);
	return 0;
}


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

using namespace std;
using p_int = pair<int, int>;
struct edge { int to, cost; };

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

    int INF = (int) 1e9 + 1;
    int V, E, r;
    cin >> V >> E >> r;
    vector<edge> g[V];
    int s, t;
    for (int i = 0; i < E; ++i) {
        edge e{};
        cin >> s >> e.to >> e.cost;
        g[s].push_back(e);
    }

    priority_queue<p_int, vector<p_int>, greater<>> que;
    int d[V];
    fill(d, d + V, INF);
    d[r] = 0;
    que.push(p_int(0, r));

    while (!que.empty()) {
        p_int p = que.top();
        que.pop();
        int v = p.second;
        if (d[v] < p.first) continue;
        for (int i = 0; i < g[v].size(); ++i) {
            edge e = g[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(p_int(d[e.to], e.to));
            }
        }
    }

    for (auto e: d) {
        if (e < INF) {
            cout << e << '\n';
        } else {
            cout << "INF" << '\n';
        }
    }

    return 0;
}



Measured memory_bytes: 12880
from collections import Counter

n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]
ans, sav = 0, 0
smc = Counter(s).most_common()
for v, i in smc:
    if v in t:
        sav = i - t.count(v)
    else:
        sav = i

    if ans < sav:
        ans = sav
if ans < 0:
    ans = 0
print(ans)


Measured memory_bytes: 3316
N = int(input())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return len(divisors)
  
ans = 0

for i in range(1,N+1):
  a = make_divisors(i)
  if a ==8 and i%2 == 1 :
    ans += 1
    
print(int(ans))

Measured memory_bytes: 3188
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
  Name:- OMHARI 
  Institution:- UNIVERSIT OF CALCUTTA(INFORMATION TECHNOLOGY)
  Email:- omharicu@gmail.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#include<bits/stdc++.h>
using namespace std; 

#define F first
#define S second
#define ull unsigned long long
#define ll long long
#define ul unsigned long
#define db double
#define pb push_back
#define mp make_pair
#define el "\n"
#define vll vector <ll>
#define vl vector <long int>
#define vi vector <int>
#define all(v) (v.begin(), v.end()) 
#define rall(v) (v.rbegin(), v.rend()) 
const ll mod = 1e9+7;

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

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
     #endif
    /***************-Code starts from here-***************/
    ull a,c;
    string b;
    cin>>a>>b;
  c=(b[0]-'0')*100 + (b[2]-'0')*10 +(b[3]-'0');
  
   c=c*a;
    cout<<c/100;
    return 0; 
} 


Measured memory_bytes: 3592