akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007
#define INF (1 << 30)
#define REP(i, m, n) for(int i = (int)m; i < (int)n; ++i)
#define rep(i, n) REP(i, 0, n)


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

    ll n, m, d; cin >> n >> m >> d;
    cout << fixed << setprecision(6);
    if(d == 0) {
        cout << (double)(m-1)*n/(n*n) << '\n';
        return 0;
    }
    cout << (double)(m-1)*2*(n-d)/(n*n) << '\n';
    return 0;
}

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

using namespace std;

void solve()
{
	int N;
	cin >> N;
	long long cnt = 0;
	for(int i = 1; i < N; i++)
	{
		for(int j = 1; j < N; j++)
		{
			if(1ll*i*j < N)
				cnt++;
			else
				break;
		}
	}
	cout << cnt;
}


int main() {
    int t;
    // cin>>t;
	// while(t--)
		solve();
	return 0;

}

Measured memory_bytes: 3632
# 何度やってもPresentation Errorが出ると思ったら改行が行けなかったので.chompで改行削除
# 20文字以内との指定なのでそれ以上は弾くようにした。他の解答例がそのまま返すだけで終わっているのは納得がいかない・・・
# 文字列入力
str = gets.to_s
# 21文字以上は弾いて再入力
while str.length > 21
str = gets.to_s
end
# 逆順出力
puts str.chomp.reverse

Measured memory_bytes: 6092
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int main() {
    SPEED;
    int n;
    cin >> n;
    int fh = n/500;
    n%=500;
    int fv = n/5;
    cout << 1000*fh + fv*5 << endl;
    return 0;
}

Measured memory_bytes: 3636
p = 10**9+7
N = int(input())
dp = [[[[[0 for _ in range(4)] for _ in range(4)] for _ in range(4)] for _ in range(4)] for _ in range(N+1)]
for i in range(4):
    for j in range(4):
        for k in range(4):
            for l in range(4):
                if i==0:
                    dp[3][i][j][k][l] = 1
for i in range(4):
    dp[3][i][0][1][2] = 0
    dp[3][i][1][0][2] = 0
    dp[3][i][0][2][1] = 0
for n in range(4,N+1):
    for i in range(4):
        for j in range(4):
            for k in range(4):
                for l in range(4):
                    for x in range(4):
                        dp[n][i][j][k][l] = (dp[n][i][j][k][l]+dp[n-1][x][i][j][k]*(str(j)+str(k)+str(l)!="012")\
                            *(str(j)+str(k)+str(l)!="102")*(str(j)+str(k)+str(l)!="021")\
                            *(str(i)+str(k)+str(l)!="012")*(str(i)+str(j)+str(l)!="012"))%p
cnt = 0
for i in range(4):
    for j in range(4):
        for k in range(4):
            for l in range(4):
                cnt = (cnt+dp[N][i][j][k][l])%p
print(cnt)

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

using namespace std;

vector<int> arr, st;
int query(int node,int l,int r,int ll,int rl){
    
    if(l<=ll && r>=rl)return st[node];
    if(r<ll || l>rl)return 0;
    int mid=ll + (rl-ll)/2;
    int left=query(2*node+1,l,r,ll,mid);
    int right=query(2*node+2,l,r,mid+1,rl);
    return max(left,right);

}
int update(int node ,int i,int v,int ll,int rl){
    if(i<ll||i>rl)return st[node];
    if(ll==rl){
        st[node]=v;
        return st[node];
    }
    int mid=ll + (rl-ll)/2;
    if(ll<=i && i<=mid)int left=update(2*node+1,i,v,ll,mid);
    else int right=update(2*node+2,i,v,mid+1,rl);
    st[node]=max(st[2*node+1],st[2*node+2]);
    return st[node];
}

int main()
{
    int n, k;
    cin >> n >> k;
    arr.resize(n);
    int size = 3e5;
    st.assign(1e8, 0);
    for (int i = 0; i < n; i++)
    {
        cin >> arr[i];
        int l=arr[i]-k;
        int r=arr[i]+k;
        int v=query(0,l,r,0,size);
        update(0,arr[i],v+1,0,size);
    }
    //for(auto x:st)cout<<x;
    cout<<query(0,0,size,0,size)<<'\n';
}

Measured memory_bytes: 395004
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"

using namespace std;
using namespace __gnu_pbds;


#define ll long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(),a.end()

typedef tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

int main(void)
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a;
    cin >> a;
    cout << a + a*a + a*a*a << "\n";
}

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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define M1 puts("-1")
#define pb push_back

template <typename T>
ostream &operator<<(ostream &os, vector<T> &v)
{
    os << "{";
    rep(i, v.size()) os << v[i] << (i == (int)v.size() - 1 ? "" : ", ");
    os << "}";
    return os;
}
template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }
struct in
{
    const size_t n = 0;
    in() = default;
    in(size_t n) : n(n){};
    template <typename T>
    operator T()
    {
        T ret;
        cin >> ret;
        return ret;
    }
    template <typename T>
    operator vector<T>()
    {
        assert(n != 0);
        vector<T> ret(n);
        for (auto &x : ret)
            cin >> x;
        return ret;
    }
};

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using pll = pair<ll, ll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

void Main()
{
    ll k = in();
    ll n = 50;
    vll a(n, n - 1 + (k / n) - (k % n));
    rep(i, k % n)
    {
        a[i] += n + 1;
    }
    cout << n << endl;
    rep(i, n)
    {
        cout << a[i] << (i == n - 1 ? "\n" : " ");
    }
}

int main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define bit(n,k) (((ll)n>>(ll)k)&1) /*nのk bit目*/
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
//const ll MOD=998244353LL;
//const ll MAX_V=114514LL;
//const ll MAX = 510000LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
vl dx={-1,-1,-1,0,0,1,1,1};
vl dy={1,-1,0,1,-1,1,0,-1};

int main(){
  ll h1,m1,h2,m2,k;cin>>h1>>m1>>h2>>m2>>k;
  ll a=h1*60+m1;
  ll b=h2*60+m2;
  cout<<max(0LL,b-a-k)<<endl;
}

Measured memory_bytes: 3628
#include <stdio.h>
const int N=1e3+10;
int main(){
    int w,h;
    char c[10],ans[N][N];
    scanf("%d%d",&w,&h);
    scanf("%s",c);
    for(int i=0;i<h;i++)for(int j=0;j<w;j++)ans[i][j]='.';
    for(int i=0;i<h;i++)ans[i][0]=ans[i][w-1]='|';
    for(int i=0;i<w;i++)ans[0][i]=ans[h-1][i]='-';
    ans[0][0]=ans[h-1][0]=ans[0][w-1]=ans[h-1][w-1]='+';
    ans[h>>1][w>>1]=c[0];
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++)printf("%c",ans[i][j]);
        printf("\n");
    }
    
}


Measured memory_bytes: 2624
//When I wrote this only God and I knew what it is
//Now, only The_Blitz knows...
#pragma GCC optimize ("Ofast,unroll-loops")
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <string>
using namespace std;
#define sz(x) int(x.size())
#define pb push_back
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ff first
#define ss second
typedef long long ll;
typedef pair<int, int> ii;

map< vector<int>, int> m;

int main(){
	fastio;
	int n; cin >> n;
	for(int i = 0; i < n; ++ i){
		string s; cin >> s;
		vector<int> x(26);
		for(char c: s) x[c -'a'] ++;
		m[x] ++;
	}
	ll ans = 0;
	for(auto x: m){
		ll r = x.ss;
		ans += r * (r - 1) / 2;
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 22168
#include<iostream>
#include<algorithm>

using namespace std;

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

  int sum = n * l + n * (n-1)/2;
  if ( l >= 0){
    cout << sum - l << endl;
  } else if ( l < 0 && abs(l) < n){
    cout << sum << endl;
  } else {
    cout << sum - (l + n - 1) << endl;
  }

  return 0;
}

Measured memory_bytes: 256
from collections import deque

n,m,k=map(int,input().split())
fre=[[]for _ in range(n)]
blo=[[] for _ in range(n)]
for i in range(m):
    a,b=map(int,input().split())
    fre[a-1].append(b-1)
    fre[b-1].append(a-1)
for i in range(k):
    c,d=map(int,input().split())
    blo[c-1].append(d-1)
    blo[d-1].append(c-1)

cnt=[0]*n
l=deque()
x=1
dic={}
for i in range(n):
    if cnt[i]==0:
        l.append(i)
    while l:
        now=l.popleft()
        for to in fre[now]:
            if cnt[to]==0:
                cnt[to]=x
                if x in dic:
                    dic[x]+=1
                else:
                    dic[x]=1
                l.append(to)
    x+=1

for i in range(n):
    if dic=={}:
        print(0)
    else:
        k=len(fre[i])
        for b in blo[i]:
            if cnt[b]==cnt[i]:
                k+=1
        if cnt[i] in dic:
            print(dic[cnt[i]]-k-1)
        else:
            print(0)

Measured memory_bytes: 42196
A,B = map(int,input().split())
def F(X):
    if X%4 ==0:return X
    elif X%4 == 1:
        return 1
    elif X%4 == 2:
        return 1^X
    else:
        return 0
ans = F(B)^F(A-1)
print(ans)


Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int l = Integer.parseInt(sc.next());
        int r = Integer.parseInt(sc.next());
        int[] count = new int[2019];
        for(int i=l;i<l+4038 && i<=r;i++){
            count[i%2019]++;
        }
        int min = Integer.MAX_VALUE;
        for(int i=0;i<2019;i++){
            if(count[i]>1){
                min = Math.min(min,(i*i)%2019);
            }
            if(count[i] > 0){
                for(int j=i+1;j<2019;j++){
                    if(count[j] >0){
                        min = Math.min(min,(i*j)%2019);
                    }
                }
            }
        }
        System.out.println(min);
        sc.close();
    }

}

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

using namespace std;

using ll = long long;

#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define ALL(A) A.begin(),A.end()


int main()
{
    int N;
    cin >> N;
    int answer = 0;

    rep1(i,N)
    {
        int count = 0;
        int x = i;
        while(x>0)
        {
            x/=10;
            count++;
        }
        if(count%2==1)
        {
            answer++;
        }    
    }

    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	int n,m;
  	cin >> n >> m;
  	vector<int> a(m);
   int res=0;
  	for(int i=0;i<m;i++){
      cin >> a.at(i);
      res += a.at(i);
      }
  	res = n - res;
  	if(res>=0)cout << res <<endl;
  	else cout << -1 << endl;
}

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

int main(){
	int c=0;
	int d=0;
	int i=0;
	int z=0;
	int e=0;
	int f=0;
	string a;
	string b;
	cin>>a>>b;   //stoi(a)
	c=a.size();
	d=b.size();
	if(c>d)cout<<"GREATER";
	if(c<d)cout<<"LESS";
	if(c==d){
		for(i=0;i<c;i++){
			if(a[i]=='1')e=1;
			if(a[i]=='2')e=2;
			if(a[i]=='3')e=3;
			if(a[i]=='4')e=4;
			if(a[i]=='5')e=5;
			if(a[i]=='6')e=6;
			if(a[i]=='7')e=7;
			if(a[i]=='8')e=8;
			if(a[i]=='9')e=9;
			if(a[i]=='0')e=0;
		        if(b[i]=='1')f=1;
			if(b[i]=='2')f=2;
			if(b[i]=='3')f=3;
			if(b[i]=='4')f=4;
			if(b[i]=='5')f=5;
			if(b[i]=='6')f=6;
			if(b[i]=='7')f=7;
			if(b[i]=='8')f=8;
			if(b[i]=='9')f=9;
			if(b[i]=='0')f=0;
			
		        if(e>f){
				z=1;
				break;
			}
			if(e<f){
				z=2;
				break;
			}
		}
		if(z==0)cout<<"EQUAL";
		if(z==1)cout<<"GREATER";
		if(z==2)cout<<"LESS";	
	}
}		


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

int main() {
  int N, K, cnt = 0;
  cin >> N >> K;
  /* お菓子をもらっていない人 */
  vector<int> no_treat(N, 1);
  // K種類のお菓子
  for (int i = 0; i < K; i++) {
    int d;
    cin >> d;
    vector<int> vec(d);
    for (int j = 0; j < d; j++) {
      int x;
      cin >> vec.at(j);
      no_treat.at(vec.at(j) - 1) = 0;
    }
  }
  for (int x : no_treat) {
    cnt += x;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 3628
#include <stdio.h>

int main()
{

int x,a,b,X,A,B,D_A,D_B;

scanf("%d%d%d",&x,&a,&b);

if (1<=x<=1000 && 1<=a<=1000 && 1<=b<=1000)
{
    X=x;
    A=a;
    B=b;
}

if(X>A)
    D_A=X-A;
else
    D_A=A-X;

if(X>B)
    D_B=X-B;
else
    D_B=B-X;


if (D_A>D_B)
    printf("B");
else
    printf("A");

}


Measured memory_bytes: 128
toInt :: String -> Int
toInt = read :: String -> Int

main = do
  [a, v] <- map toInt . words <$> getLine
  [b, w] <- map toInt . words <$> getLine
  t <- toInt <$> getLine
  putStrLn $ if (abs (a-b)) <= ((v-w) * t) then "YES" else "NO"


Measured memory_bytes: 3892
A = [list(map(int, input().split())) for i in range(3)]
#A11, A12, A13 = map(int, input().split())
#A21, A22, A23 = map(int, input().split())
#A31, A32, A33 = map(int, input().split())
N = int(input())
ans = [[0] * 3 for i in range(3)]
#print(A)
for i in range(N):
  x = int(input())
  for j in range(3):
    for k in range(3):
      if A[j][k] == x:
        ans[j][k] = 1
answer = "No"
for i in range(3):
  if ans[i] == [1, 1, 1]:
    answer = "Yes"
    
for i in range(3):    
  if (ans[0][i] == ans[1][i]) and (ans[0][i] == ans[2][i]) and (ans[0][i] == 1):
    answer = "Yes"

if (ans[0][0] == ans[1][1]) and (ans[0][0] == ans[2][2]) and (ans[0][0] == 1):
  answer = "Yes"
if (ans[0][2] == ans[1][1]) and (ans[0][2] == ans[2][0]) and (ans[0][2] == 1):
  answer = "Yes"
    
print(answer)  
#print(ans)


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

using i64 = int64_t;
using namespace std;
const i64 MOD = 1000000007LL;
vector<i64> fact(500000);

inline i64 powermod(i64 a,i64 b){
  i64 r = 1LL;
  for(int i = 32 - __builtin_clz(b) - 1; i >= 0; i-- ){
    if((1 << i) & b) r = r * r % MOD * a % MOD;
    else r = r * r % MOD;
  }
  return r;
}

inline i64 divmod(i64 a,i64 b){
  return a * powermod(b,MOD-2) % MOD;
}

i64 nCr(i64 n,i64 r){
  if(r<0)return 0;
  i64 ne = fact[n];
  i64 di = fact[n-r] * fact[r] % MOD;
  return divmod(ne,di);
}

inline i64 A(i64 a,i64 b){
  // cerr << nCr(a,b) << " " << nCr(a,b-1) << endl;
  return (nCr(a,b) + MOD - nCr(a,b-1)  ) % MOD;
}

int main() {
  i64 N,M,K;
  cin >> N >> M >> K;
  
  fact[0] = fact[1] = 1LL;
  for(int i = 2;i < 500000;i++){
    fact[i] = fact[i-1] * (i64)i % MOD;
  }
  
  i64 res = 0LL;
  for(i64 i = 0LL; i <= K; i++ ){
    res += nCr(N+M+K+K,N+i*2) * A(N+i*2,i) % MOD * A(M+(K-i)*2,K-i) % MOD;
    // cerr << nCr(N+M+K+K,N+i*2) << " " << A(N+i*2,i) << " " << A(M+(K-i)*2,K-i) << endl;
    res %= MOD;
  }
  
  cout << res << endl;
  // cerr << nCr(138,7) << endl;
  // cerr << nCr(3,1) << endl;
  // cerr << powermod(2,10) << endl;
}


Measured memory_bytes: 6616
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

struct UnionFind {
    UnionFind(int n) : p(n, -1) {}
    int root(int u) {
        return p[u] < 0 ? u : p[u] = root(p[u]);
    }
    bool same(int u, int v) {
        return root(u) == root(v);
    }
    void unite(int u, int v) {
        u = root(u);
        v = root(v);
        if (u == v) return;
        if (p[u] > p[v]) swap(u, v);
        p[u] += p[v];
        p[v] = u;
    }
    vector<int> p;
};

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

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

    vector<pair<int, int>> p(m);
    for (int i = 0; i < m; i++) {
        cin >> p[i].first >> p[i].second;
        p[i].first--;
        p[i].second--;
    }

    UnionFind uf(n);
    vector<ll> r(m);
    ll s = 0;
    for (int i = m - 1; i >= 0; i--) {
        r[i] = s;
        p[i].first = uf.root(p[i].first);
        p[i].second = uf.root(p[i].second);
        if (p[i].first != p[i].second) {
            s += uf.p[p[i].first] * uf.p[p[i].second];
            uf.unite(p[i].first, p[i].second);
        }
    }

    for (int i = 0; i < m; i++) {
        cout << s - r[i] << '\n';
    }
    cout << flush;

    return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define endl "\n";
#define int long long
#define fastio ios_base::sync_with_stdio(0); cin.tie(0)
#define double long double
const int mod = 1e9 + 7;

int32_t main()
{	
	fastio;
    int n, k; cin >> n >> k;
    map<int,int> mp;
    for(int i=0; i<n; i++){
    	int d; cin >> d;
    	for(int j=0; j<d; j++){
    		int x; cin >> x;
    		mp[x]++;
    	}
    }

    int ans = 0;
    for(int i=1; i<=n; i++){
    	if(mp[i] == 0){
    		ans++;
    	}
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
#define fin << '\n'
#define pb push_back
#define all(x) x.begin(), x.end()
#define rep( i, m, n ) for ( int i = m; i < n; ++i )
typedef long long ll;
typedef vector<int> vi;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;

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

  char num[10];
  scanf("%s", num);

  bool flg = false;
  for (int i = 1; i <= 4; ++i ) {
    if( num[i] == num[i-1] ){
      flg = true;
    }
  }

  if( flg ) printf("Bad\n");
  else printf("Good\n");

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;using int32=int_fast32_t;using uint32=uint_fast32_t;using int64=int_fast64_t;using uint64=uint_fast64_t;using pi=pair<int32,int32>;using pll=pair<int64,int64>;using vi=vector<int32>;using vvi=vector<vector<int32>>;using vll=vector<int64>;using ll=int64;using ull=uint64;
#define all(x) x.begin(),x.end()
inline ll read(){ll x=0,f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();return x*f;}
inline string read_s(){string s="";char c=getchar();while(c<'!'||c>'~'){c=getchar();}while(c>='!'&&c<='~'){s+=c;c=getchar();}return s;}
void Main(){
    map<string, string> m;
    m["T"]="A";m["A"]="T";m["G"]="C";m["C"]="G";
    string b = read_s();
    printf("%s\n", m[b].c_str());
}
int main(){cin.tie(nullptr);ios::sync_with_stdio(false);Main();return 0;}

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

int main()
{
    int a[3];
    int n5 = 0, n7 = 0;
    for(int i = 0; i < 3; i++){
        cin >> a[i];
        if(a[i] == 5) n5 += 1;
        if(a[i] == 7) n7 += 1;
    }

    
    if(n5 == 2 && n7 == 1) cout << "YES" << endl;
    else cout << "NO" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define All(V) V.begin(), V.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main()
{
  int n, m; cin >> n >> m;
  set<int> s; vector<int> v;
  rep(i, m){
    int a, b; cin >> a >> b;
    if(a == 1 || b == 1){
      if(a == 1)s.insert(b);
      else s.insert(a);
    }
    else if(a == n || b == n){
      if(a == n)v.push_back(b);
      else v.push_back(a);
    }
  }
  bool f = false;
  for(int i = 0; i < v.size(); i++){
    if(s.count(v[i]))f = true;
  }
  if(f)cout << "POSSIBLE" << endl;
  else cout << "IMPOSSIBLE" << endl;
  system("pause");
}


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

#define endl '\n'
#define pb push_back
#define mod 1000000007
typedef int integer;
//#define int long long
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 0
#endif
using namespace std;

template<typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
    cerr << name << ": " << arg1 << endl;
}

template<typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
    const char *comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << ": " << arg1 << " |";
    __f(comma + 1, args...);
}

int powmod(int a, int b) {
    int res = 1;
    a %= mod;
    assert(b >= 0);
    for (; b; b >>= 1) {
        if (b & 1)res = res * a % mod;
        a = a * a % mod;
    }
    return res;
}

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

const integer NN = (int) 5e5 + 2;
int ar[NN];
int n, m;


integer main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> ar[i];
    }
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            for (int k = j + 1; k < n; k++) {
                int a = ar[i], b = ar[j], c = ar[k];
                if (a == b || a == c || b == c) continue;
//                cout << a << ' ' << b << ' ' << c << endl;
                if (a + b > c && a + c > b && b + c > a) cnt++;

            }

        }
    }
    cout << cnt << endl;
}


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

int main() {
  long long  x;
  cin >> x;
  
  map<long long, long long> score;
  
 for (long long i = 0; i < std::pow(10, 4); i++){
  score[i] = std::pow(i, 5);
 }
 
  for (long long j = 0; j < std::pow(10, 4); j++){
  for (long long k = 0; k < std::pow(10, 4); k++){
    if(score.at(j) - score.at(k) == x){
      cout << j << " " << k;
      return 0;
    }
    if(score.at(j) + score.at(k) == x){
      cout << j << " " << -k;
      return 0;
    }
    
  }
  }
    
 
 
}

Measured memory_bytes: 4804
#include <iostream>

using namespace std;

int main(void){
  int N;
  cin >> N;
  int L[N];
  int i;
  int max = 0, max_n; //maximum, number of maximum
  int sum = 0; //summation  
  for(i=0; i<N; i++)
    cin >> L[i];

  //search maximum and number of maximum
  for(i=0; i<N; i++)
    if(max < L[i]){
      max = L[i];
      max_n = i;
    }

  //calculate summation except for maximum
  for(i=0; i<N; i++)
    if(i != max_n)
      sum += L[i];

  if(max < sum)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <sstream>
#include <map>
#include <queue>
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep1(i,n) for(int i = 1; i <= n; i++)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
using namespace std;
ll mod = 1e9 + 7;
vector<ll> divisors(ll);

int main()
{
	int n;
	cin >> n;
	string s1, s2;
	cin >> s1 >> s2;
	ll ans = 1;
	int i = 0;
	while(i<s1.size())
	{
		ll comb;
		int incr;
		if (i == 0)
		{
			comb = s1[i] == s2[i] ? 3 : 6;
			incr = s1[i] == s2[i] ? 1 : 2;
		}
		else
		{
			if (s1[i-1] == s2[i-1])
			{
				comb = s1[i] == s2[i] ? 2 : 2;
				incr = s1[i] == s2[i] ? 1 : 2;
			}
			else
			{
				comb = s1[i] == s2[i] ? 1 : 3;
				incr = s1[i] == s2[i] ? 1 : 2;
			}
		}
		ans *= comb;
		ans %= mod;
		i += incr;
	}
	co(ans);
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(int i=0;i<n;i++)
#define FORJ(n) for(int j=0;j<n;j++)
#define PRN(n) printf("%d\n",n)
#define PRF(n) printf("%lf\n",n)
#define PRL(n) printf("%lld\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
#define INF 10000000000
#define mod 1000000007
#define X 1000000
typedef long long int ll;
ll finv[X];
ll fac[X];
ll inv[X];
ll usort(const void *a, const void *b){return *(ll*)a-*(ll*)b;}
ll dsort(const void *a, const void *b){return *(ll*)b-*(ll*)a;}
ll ssort(const void *a, const void *b){return strcmp((char*)a,(char*)b);}
ll min(ll a,ll b){
  if(a>b)return b;
  return a;
}
ll max(ll a,ll b){
  if(a>b)return a;
  return b;
}
ll z(ll a){return max(a,-a);}
ll gcd(ll a,ll b){if(!b){return a;}else{return gcd(b,a%b);}}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
ll kt(ll a){
  ll sum=0;
  while(a){
    a/=10;
    sum++;
  }
  return sum;
}
ll ks(ll a){
  ll sum=0;
  while(a){
    sum+=a%10;
    a/=10;
  }
  return sum;
}
void ppp(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for (int i=2;i<X;i++){
    fac[i]=fac[i-1]*i%mod;
    inv[i]=mod-inv[mod%i]*(mod/i)%mod;
    finv[i]=finv[i-1]*inv[i]%mod;
  }
}
ll nCr(int n,int k){
  return fac[n]*(finv[k]*finv[n-k]%mod)%mod;
}
int main(void){
  int n;
  scanf("%d",&n);
  int a,mi=n+1,ans=0;
  FOR(n){
    scanf("%d",&a);
    if(mi>a){
      ans++;
      mi=a;
    }
  }
  PRN(ans);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
 
	#ifndef ONLINE_JUDGE
    	freopen("D:/Programming/input.txt", "r", stdin);
    	freopen("D:/Programming/output.txt", "w", stdout);
	#endif
 
	unsigned long long int a, b;
	string s;
	cin>>a>>s;
	b = (s[0]-'0')*100;
	b+= (s[2]-'0')*10;
	b+= (s[3]-'0');

	long long int abc = a*b;
	abc = abc/100;
	cout<<abc<<endl;
	return 0;
 
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
const int mod = 1e9 + 7;
const int maxn = 1e5 + 10;
const int inf = 0x3f3f3f3f;
int prime[maxn];
int main()
{
	ios::sync_with_stdio(false); cin.tie(0);
	for(int i=2;i<maxn;i++) {
		if(!prime[i]) prime[++prime[0]]=i;
		for(int j=1;j<=prime[0]&&prime[j]<=maxn/i;j++) {
			prime[i*prime[j]]=1;
			if(i%prime[j]==0) break;
		}
	}
	ll n,ans;
	cin>>n;
	ans=n;
	vi fc;
	rep(i,1,prime[0]) {
		if(n%prime[i]==0) {
			fc.pb(prime[i]);
			while(n%prime[i]==0) {
				n/=prime[i];
			}
		}
	}
	if(n!=1) fc.pb(n);
	for(int x:fc) {
		ans/=x;
		ans*=x-1;
	}
	cout<<ans<<'\n';
	return 0;
}



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

using namespace std;

template< class T >
struct DecomposableSearchingStructure
{
  struct DecomposableSearchingProblem
  {
    T structure;
    int length;

    DecomposableSearchingProblem(T t, int l) : structure(t), length(l) {}

    DecomposableSearchingProblem operator+(const DecomposableSearchingProblem &p)
    {
      return (DecomposableSearchingProblem(structure + p.structure, length + p.length));
    }
  };

  vector< DecomposableSearchingProblem > vs;

  DecomposableSearchingStructure() {}

  void add(const T &st)
  {
    vs.emplace_back(DecomposableSearchingProblem(st, 1));
    while(vs.size() > 1 && vs[vs.size() - 2].length == vs[vs.size() - 1].length) {
      DecomposableSearchingProblem renew(vs[vs.size() - 2] + vs[vs.size() - 1]);
      vs.pop_back(), vs.pop_back();
      vs.push_back(renew);
    }
  }

  size_t size()
  {
    return (vs.size());
  }

  T &operator[](int k)
  {
    return (vs[k].structure);
  }
};

struct Vector
{
  int top;
  vector< int > vs;

  Vector() : top(0) {}

  Vector(int v) : top(0)
  {
    vs.push_back(v);
  }

  int size() const
  {
    return ((int) vs.size() - top);
  }
};

Vector operator+(const Vector &a, const Vector &b)
{
  Vector ret;
  int x = 0, y = 0;
  while(x < a.size() || y < b.size()) {
    if(y == b.size() || (x != a.size() && a.vs[x] < b.vs[y])) {
      ret.vs.push_back(a.vs[x++]);
    } else {
      ret.vs.push_back(b.vs[y++]);
    }
  }
  return (ret);
}

int main()
{
  cin.tie(0);

  string S;
  int K;

  DecomposableSearchingStructure< Vector > dss;
  while(cin >> S, S != "end") {
    if(S[0] == 'i') {
      cin >> K;
      dss.add(Vector(K));
    } else {
      int ret = -1;
      for(int i = 0; i < dss.size(); i++) {
        auto &p = dss[i];
        if(p.size() == 0) continue;
        ret = max(ret, p.vs[p.size() - 1]);
      }
      for(int i = 0; i < dss.size(); i++) {
        auto &p = dss[i];
        if(p.size() == 0) continue;
        if(ret == p.vs[p.size() - 1]) {
          p.top++;
          cout << ret << endl;
          break;
        }
      }
    }
  }
}

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

int main(){
	string str, str_rev;
	int cnt=0;
	while(cin>>str){
		str_rev = str;
		reverse(str_rev.begin(), str_rev.end());
		if(str == str_rev)cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 1188
n = int(input())
csf = [list(map(int, input().split())) for _ in range(n-1)]

import math

for i in range(n):
    if i == n - 1:
        print(0)

    else:
        # start
        time = csf[i][1] + csf[i][0] # s_i + c_i

        if i != n - 2:
            station = i
            while True:
                station += 1
                c = csf[station][0]
                s = csf[station][1]
                f = csf[station][2]
                time = math.ceil(max(time - s, 0) / f) * f + s
                time += c

                if station == n-2:
                    break

        print(time)


Measured memory_bytes: 3316
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <stdlib.h>

int main(int argc, const char * argv[])
{
    char stc[100];
    int i;
    int m = 0;
    int total = 0;
    long len;
    while (scanf("%s", stc) != EOF) {
        len = strlen(stc);
        for (i = 0; i <= len; i++) {
            if (isdigit(stc[i])) {
                m = m * 10 + stc[i] - '0';
            }
            else {
                total += m;
                m = 0;
            }
        }
    }
    printf("%d\n", total);
    return 0;
}

Measured memory_bytes: 536
#: Author - Soumya Saurav
import sys,io,os,time
from collections import defaultdict
from collections import OrderedDict
from collections import deque
from itertools import combinations
from itertools import permutations
import bisect,math,heapq
alphabet = "abcdefghijklmnopqrstuvwxyz"

input = sys.stdin.readline

########################################
n = int(input())
arr = list(map(int , input().split()))
ans = 0
m = arr[0]
for i in range(n):
	if m > arr[i]:
		ans+= m - arr[i]
	m = max(arr[i],m)
print(ans)










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

int main(){
  int n;
  cin >> n;
  vector<pair<int, int>> ve(1000000), vo(1000000);
  for(int i = 0; i < n; ++i){
    int k;
    cin >> k;
    if(i % 2){
      vo.at(k).first++;
      vo.at(k).second = k;
    }
    else{
      ve.at(k).first++;
      ve.at(k).second = k;
    }
  }
  
  sort(vo.begin(), vo.end());
  reverse(vo.begin(), vo.end());
  sort(ve.begin(), ve.end());
  reverse(ve.begin(), ve.end());
  
  int sum = vo.at(0).first + ve.at(0).first;
  if(vo.at(0).second == ve.at(0).second){
    int s = vo.at(0).first + ve.at(1).first;
    int t = vo.at(1).first + ve.at(0).first;
    if(s > t) sum = s;
    else sum = t;
  }
  
  cout << n - sum << endl;
}

Measured memory_bytes: 15872
#include<bits/stdc++.h>
#define INF 2147483647
#define lli long long int
#define MOD 1000000007
#define pb push_back

using namespace std;
typedef vector<int> vi;
typedef vector< vector<int> > vvi;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
int main() {
	

	lli	 m,n; cin >> m >> n;
	lli ans = 1;
	while(n != 1) {
		if (n % 2 != 0) {
			ans = ans * m % MOD;
			n--;
		}
		m = m * m % MOD;
		n /= 2;
	}

	cout << ans * m % MOD << endl;
	return 0;
}

Measured memory_bytes: 3104
#include<iostream>
using namespace std;
int main(){
int price,cnt=0;
int div[6]={500,100,50,10,5,1};
int i;
while(1){
cin>>price;
if(price==0)break;
price=1000-price;
for(i=0;i<6;i++){
if((price/div[i])!=0){
cnt+=(price/div[i]);
price-=(price/div[i])*div[i];
}
}
cout<<cnt<<endl;
cnt=0;
}
return 0;
}

Measured memory_bytes: 1160
use proconio::fastout;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::{Chars, Bytes};
#[allow(unused_imports)]
use num::integer::gcd;

#[allow(dead_code)]
type Pi = (i32, i32);
#[allow(dead_code)]
fn pri<T: std::fmt::Display>(x: T) {
    println!("{}", x);
}

#[fastout]
fn main() {
    input!{
        n: i64,
    }
    let mut ans = 0;
    for i in 1..n+1 {
        for j in 1..n+1 {
            for k in 1..n+1 {
                ans += gcd(i, gcd(j, k));
            }
        }
    }
    pri(ans);
}

Measured memory_bytes: 2164
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define forn(i,a,b) for(int i =a;i<b;i++)
#define fi first
#define se second
#define fast ios_base::sync_with_stdio(false);
using namespace std;

//for debugging 
/*
g++ -D_GLIBCXX_ASSERTIONS -DDEBUG -ggdb3 -std=c++14 
*/
int recur_depth = 0;
#ifdef DEBUG
#define dbg(x) {++recur_depth; auto x_=x; --recur_depth; cerr<<string(recur_depth, '\t')<<"\e[91m"<<__func__<<":"<<__LINE__<<"\t"<<#x<<" = "<<x_<<"\e[39m"<<endl;}
#else
#define dbg(x)
#endif
template<typename Ostream, typename Cont>
typename enable_if<is_same<Ostream,ostream>::value, Ostream&>::type operator<<(Ostream& os,  const Cont& v){
	os<<"[";
	for(auto& x:v){os<<x<<", ";}
	return os<<"]";
}
template<typename Ostream, typename ...Ts>
Ostream& operator<<(Ostream& os,  const pair<Ts...>& p){
	return os<<"{"<<p.first<<", "<<p.second<<"}";
}
// debugging ends here

typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;


void solve(){
	int x;
	cin >> x;
	int ans = 0;
	if(x<600)
		ans=8;
	else if(x<800)
		ans = 7;
	else if(x<1000)
		ans = 6;
	else if(x<1200)
		ans = 5;
	else if(x<1400)
		ans = 4;
	else if(x<1600)
		ans = 3;
	else if(x<1800)
		ans = 2;
	else 
		ans  = 1;

	cout << ans << endl;

}

int main(){
	fast;
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif

	// int t;cin >> t;while(t--)
		solve();
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
int main(){
	string a,b;
  	cin >> a >> b;
  	int s = atoi((a+b).c_str());
  	int t = (int)sqrt(s);
  
  	puts(t*t==s?"Yes":"No");
  
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define maxn 200100
#define mod 1000000007
#define ll long long
#define P pair<ll,ll>
struct node{int f[3];};
int rt[maxn],sz,n;
vector<node>q[maxn];
struct Edge
{
    int to,next;
}edge[maxn<<1];
int head[maxn],tot;
void addedge(int u,int v)
{
    edge[tot].to=v;
    edge[tot].next=head[u];
    head[u]=tot++;
}
void init()
{
    tot=0;
    memset(head,-1,sizeof(head));
}
inline int merge(int x,int y)
{
    if((int)q[x].size()<(int)q[y].size()) swap(x,y);
    int nx=(int)q[x].size()-1,ny=(int)q[y].size()-1;
    for(int i=0;i<=ny;++i)
    {
        int sum0=0,sum1=0,sum2=0;
        sum0=1LL*q[x][nx-i].f[0]*q[y][ny-i].f[0]%mod;
        sum1=(1LL*q[x][nx-i].f[0]*q[y][ny-i].f[1]+1LL*q[x][nx-i].f[1]*q[y][ny-i].f[0])%mod;
        for(int j=0;j<=2;++j)
            for(int k=2;j+k>=2;--k)
                sum2=(sum2+1LL*q[x][nx-i].f[j]*1LL*q[y][ny-i].f[k])%mod;
        q[x][nx-i].f[0]=sum0; q[x][nx-i].f[1]=sum1; q[x][nx-i].f[2]=sum2;
    }
    q[y].clear();
    return x;
}
void dfs(int u)
{
    if(head[u]==-1) rt[u]=++sz;
    int dep=0;
    for(int i=head[u];~i;i=edge[i].next)
    {
        int v=edge[i].to;
        dfs(v);
        if(!rt[u]) rt[u]=rt[v];
        else
        {
            dep=max(dep,(int)min(q[rt[u]].size(),q[rt[v]].size()));
            rt[u]=merge(rt[u],rt[v]);
        }
    }
    int nx=q[rt[u]].size()-1;
    for(int i=0;i<dep;++i)
    {
        q[rt[u]][nx-i].f[0]+=q[rt[u]][nx-i].f[2];
        q[rt[u]][nx-i].f[2]=0;
        if(q[rt[u]][nx-i].f[0]>=mod) q[rt[u]][nx-i].f[0]-=mod;
    }
    node tmp;
    tmp.f[1]=tmp.f[0]=(mod+1)>>1; tmp.f[2]=0; q[rt[u]].push_back(tmp);
}
ll qpow(ll a,ll m)
{
    ll ret=1;
    while(m>0)
    {
        if(m&1) ret=ret*a%mod;
        a=a*a%mod;
        m>>=1;
    }
    return ret;
}
int main()
{
    scanf("%d",&n);
    init();
    for(int i=1;i<=n;++i)
    {
        int fa;
        scanf("%d",&fa);
        addedge(fa,i);
    }
    dfs(0);
    ll ans=0;
    int ss=(int)q[rt[0]].size();
    for(int i=0;i<ss;++i)
    {
        ans+=q[rt[0]][i].f[1];
        if(ans>=mod) ans-=mod;
    }
    ans=ans*qpow(2,n+1); ans%=mod;
    printf("%d\n",(int)ans);
    return 0;
}


Measured memory_bytes: 35444
#include<stdio.h>
#include<iostream>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<iterator>
#include<math.h>

using namespace std;
#define int long long
/*                      */    //#undef int
#define INF 1000000009
#define INFL 1000000000000000018ll
#define mod 1000000007
#define pb push_back
#define fi first
#define se second
#define mk(a, b) make_pair(a, b)
typedef pair<int, int> PA;
typedef priority_queue<int> PQ;
typedef priority_queue<PA, vector<PA>, greater<PA> >PQG;

int N, M, R, d[220][220], r[220];

signed main()
{
    cin >> N >> M >> R;
    for(int i = 0; i < R; i++){
        cin >> r[i];
    }
    for(int i = 0; i <= N; i++){
        for(int j = 0; j <= N; j++){
            if(i == j)continue;
            d[i][j] = INF;
        }
    }
    for(int i = 0; i < M; i++){
        int a, b, c;
        cin >> a >> b >> c;
        d[a][b] = c;
        d[b][a] = c;
    }
    for(int k = 1; k <= N; k++){
        for(int i = 1; i <= N; i++){
            for(int j = 1; j <= N; j++){
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
    int ans = INF;
    sort(r, r + R);
    do{
        int res = 0;
        for(int i = 1; i < R; i++){
            res += d[r[i - 1]][r[i]];
        }
        ans = min(ans, res);
    }while(next_permutation(r, r + R));
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 640
/*
          , -- 、
        /;;;;;;', 　　　
        i二二二i
      , ' 　    ヽ ???
     i　ﾉﾉﾉﾉﾉﾍ .', 　　
     〉ﾘi' ﾟ ヮﾟﾉﾚく　 WAyon..........
  ○⊂}〈lﾄ--ｲl〉{つ● 　　
      ,ｒ/ー i-ヽヽ 　　　
     ｀｀i_ﾗi_ﾗ
*/

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
const int INF=(int)1e12;
const int mod=(int)1e9+7;
#define all(a) (a).begin(),(a).end()
typedef vector<vector<int>> graph;

#define pb push_back

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

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



signed main () {
    int n;cin >>n;
    cout <<10-n/200<<endl;
}





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

int judge(int x) {
  if(x == 2) return 0;
  else if(x == 4 || x == 6 || x == 9 || x == 11) return 1;
  return 2;
}

int main() {
  int x, y;
  cin >> x >> y;
  
  if(judge(x) == judge(y)) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque> 

using namespace std;

struct Node
{
	int pos;
	std::vector<int> connects;	//树也是简单图，所以不需要考虑重复 
	int val;
};
Node nodes[10010];

int n;
int c[10010];

bool compare(const int &a, const int &b)
{
	return a > b;
}

int main()
{
	scanf("%d", &n);
	for (int i = 1 ; i <= n ; i++)
	{
		nodes[i].pos = i;
		nodes[i].val = -1;
	}

	
	int a, b;
	for (int i = 0 ; i < n - 1 ; i++)
	{
		scanf("%d%d", &(a), &(b));
		nodes[a].connects.push_back(b);
		nodes[b].connects.push_back(a);
	}
	
	int max = -1;
	int sum = 0;
	for (int i = 0 ; i < n ; i++)
	{
		scanf("%d", &(c[i]));
		if (max < c[i])
			max = c[i];
		sum = sum + c[i];
	}
	
	sort(c, c + n, compare);
	
	int total = sum - max;
	printf("%d\n", total);
	
	int pC = 0;	//指向c 
	int curNode;
	std::queue<int> q;
	q.push(1);	//简单bfs即可 
	
	while (pC < n)
	{
		curNode = q.front();
		q.pop();
		if (nodes[curNode].val != -1)
			continue;
			
		nodes[curNode].val = c[pC]; 
		pC++;
		
		for (int i = 0 ; i < nodes[curNode].connects.size() ; i++)
		{
			int nextNode = nodes[curNode].connects[i];
			if (nodes[nextNode].val == -1)
				q.push(nextNode);
		}
	}
	
	for (int i = 1 ; i <= n ; i++)
		printf("%d ", nodes[i].val);
		
	printf("\n");
	return 0;
}


Measured memory_bytes: 1152
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define ggr getchar();getchar();return 0;
#define prique priority_queue
constexpr auto mod = 1000000007;
#define inf 1e15
#define key 1e9
using namespace std;
typedef pair<int, int>P;
template<class T> inline void chmax(T& a, T b) {
	a = std::max(a, b);
}
template<class T> inline void chmin(T& a, T b) {
	a = std::min(a, b);
}
//combination(Nが小さい時はこれを使う
const int MAX = 330000;
int fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}

// 二項係数計算
long long COMB(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}

//繰り返し二乗法（Nが大きい時の場合のcombination)
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= (i % mod); res %= mod;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
//UnionFind
class UnionFind {
protected:
	int* par, * rank, * size;
public:
	UnionFind(unsigned int size) {
		par = new int[size];
		rank = new int[size];
		this->size = new int[size];
		rep(i, size) {
			par[i] = i;
			rank[i] = 0;
			this->size[i] = 1;
		}
	}
	int find(int n) {
		if (par[n] == n)return n;
		return par[n] = find(par[n]);
	}
	void unite(int n, int m) {
		n = find(n);
		m = find(m);
		if (n == m)return;
		if (rank[n] < rank[m]) {
			par[n] = m;
			size[m] += size[n];
		}
		else {
			par[m] = n;
			size[n] += size[m];
			if (rank[n] == rank[m])rank[n]++;
		}
	}
	bool same(int n, int m) {
		return find(n) == find(m);
	}
	int getsize(int n) {
		return size[find(n)];
	}
};
int dight(int n) {
	int ans = 1;
	while (n >= 10) {
		n /= 10;
		ans++;
	}
	return ans;
}
int dight_sum(int n) {
	int sum = 0;
	rep(i, 20)sum += (n % (int)pow(10, i + 1)) / (pow(10, i));
	return sum;
}
int dight_min(int n) {
	int ans = 9;
	while (n >= 10) {
		ans = min(ans, n % 10);
		n /= 10;
	}
	ans = min(ans, n);
	return ans;
}
int dight_max(int n) {
	int ans = 0;
	while (n >= 10) {
		ans = max(ans, n % 10);
		n /= 10;
	}
	ans = max(ans, n);
	return ans;
}
int a[3];
signed main() {
	rep(i, 3)cin >> a[i];
	sort(a, a + 3);
	cout << a[0] << " " << a[1] << " " << a[2] << endl;
	ggr
}



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

# https://en.wikipedia.org/wiki/Cycle_detection
def floyd_cycle_finding(f, x0):
    '''
    循環していない部分の長さをlam
    循環部分の長さをmuとして
    (lam, mu)
    を返す
    >>> floyd_cycle_finding(lambda x: x**2 % 3, 2)
    (1, 1)
    >>> floyd_cycle_finding(lambda x: x**2 % 1001, 2)
    (2, 4)
    >>> floyd_cycle_finding(lambda x: x**2 % 16, 2)
    (2, 1)
    >>> floyd_cycle_finding(lambda x: x*2 % 5, 3)
    (0, 4)
    >>> floyd_cycle_finding(lambda x: x*2 % 5, 0)
    (0, 1)
    '''
    # a_i = a_j
    # の関係が成り立つ時
    # a_{lam+n+k*mu} = a_{lam+n+k'*mu}
    # より|i-j|は循環の長さの整数倍になる
    # そこで
    # a_m = a_2m
    # なるmを見つける
    # 前述の性質からmは循環の長さの整数倍となっているため
    # 2m - m = m = k*mu = lam + n + k'*mu
    # したがって、lam + nはmuの倍数となるので
    # 地点mからlamステップ進むと循環の開始点に到達する
    # lamが求まれば後は流れでmuも求まる
    
    tortoise = f(x0)
    hare = f(f(x0))
    while tortoise != hare:
        tortoise = f(tortoise)
        hare = f(f(hare))
    lam = 0
    tortoise = x0
    while tortoise != hare:
        tortoise = f(tortoise)
        hare = f(hare)
        lam += 1
    mu = 1
    hare = f(tortoise)
    while tortoise != hare:
        hare = f(hare)
        mu += 1
    return lam, mu

def solve(N: int, X: int, M: int):
    f = lambda x: x**2 % M

    def g(x):
        while True:
            yield x
            x = f(x)
            
    lam, mu = floyd_cycle_finding(f, X)
    ans = 0
    gg = g(X)
    k = max((N - lam) // mu, 0)
    for i in range(min(N, lam)):
        ans += next(gg)
    for i in range(mu):
        ans += k * next(gg)
    for i in range((N-lam)%mu):
        ans += next(gg)
    return ans

# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    print(solve(N, X, M))


def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()


Measured memory_bytes: 9180
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function carry(x::Array{Int,1},n)
	k = length(x)
	for i in 1:k-1
		if x[k-i+1] > n-1
			x[k-i] += div(x[k-i+1],n)
			x[k-i+1] = x[k-i+1]%n
		end
	end
	if x[1] > n-1
		0
	else
		x
	end
end

function main()
	n = readline() |> parseInt
	a = zeros(Int,n,10)
	for i in 1:n
		a[i,:] = readline() |> split |> parseMap
	end
	p = zeros(Int,n,11)
	for i in 1:n
		p[i,:] = readline() |> split |> parseMap
	end
	q = zeros(Int,10)
	mx = -10^18
	b = zeros(Int,10)
	b[10] += 1
	while b!=0
		s = 0
		for i in 1:n
			x = 0
			for j in 1:10
				if b[j]==1&&a[i,j]==1
					x += 1
				end
			end
			s += p[i,x+1]
		end
		mx = max(mx,s)
		b[10] += 1
		b=carry(b,2)
	end
	println(mx)
end

main()

Measured memory_bytes: 115588
/* Murad Eynizade */
#include <bits/stdc++.h>
#define ll long long 
#define pb push_back
#define mp make_pair
using namespace std;
int main() {
	ll x,t;
	cin>>x>>t;
	cout<<max((ll)0,x-t)<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int d = sc.nextInt();
        System.out.print("Christmas");
        IntStream.range(0, 25-d)
                .forEach(i -> {
                    System.out.print(" Eve");
                });
    }
}


Measured memory_bytes: 26836
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	void run() {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		long[] a = new long[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextLong();
		}
		Arrays.sort(a);
		for (int i = 1; i < n; i++) {
			if (a[i] == a[i - 1]) {
				System.out.println("NO");
				return;
			}
		}
		System.out.println("YES");
	}

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


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

using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    long long a, b, c, d;
    cin >> a >> b >> c >> d;
    if (d < 0 && a > 0) {
        cout << max(c, d) * min(a, b);
    } else if (b < 0 && c > 0) {
        cout << min(c, d) * max(a, b);
    } else {
        cout << max(min(a, b) * min(c, d), max(a, b) * max(c, d));
    }
    return 0;
}

Measured memory_bytes: 3640