akhauriyash/Code-Regression huggingface dataset:
import math
N = int(input())

s1 = []
s2 = []
#visited
for i in range(N):
    x, y = map(int, input().split())
    d0 = x + y
    d1 = x - y
    #if d0 in s1 and d1 in s2 and s1.index(d0) == s2.index(d1):
    #    continue
    s1.append(d0)
    s2.append(d1)


ans = 0

if len(s1) > 1 and len(s2) > 1:
    s1s = sorted(s1)
    s2s = sorted(s2)

    ans = max(s1s[0] - s1s[-1], s2s[0] - s2s[-1]
              , s1s[-1] - s1s[0], s2s[-1] - s2s[0])

print(int(ans))




Measured memory_bytes: 106592
#include <bits/stdc++.h>
#include<cmath>
#define N 100005
#define A 1000005
#define MOD 998244353 //1000000007 // //100000000
#define INF 1000000000000000000
#define ll long long
//#define M_PI 3.141592653589793238463

using namespace std;

#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)
#define itr(it, x) for(auto it = x.begin(); it != x.end(); it++)
#define mem(a, b) memset(a, (ll)b, sizeof(a))
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define edge(v, x, y) v[x].pb(y); v[y].pb(x);
#define popcount __builtin_popcount
#define ANS(s) {cout << s << "\n"; return;}

//~~~~~~fancy print~~~~~~~//
#define printpii(a) cout << a.ft << " " << a.sd << endl;
#define printpiii(a) cout << a.ft << " " << a.sd.ft << " " << a.sd.sd << endl;
#define print(a, n) rep(i, n) cout << a[i] << " "; cout << endl;
#define printv(v) for(auto x: v)cout << x << " "; cout << endl;
#define printm(a, n, m) rep(i, n) { rep(j, m) cout << a[i][j] << "\t"; cout << endl;}

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

void fast(){ios_base::sync_with_stdio(false);cin.tie(0);cout << setprecision(12) << fixed;}

bool cmp(pair <string, pii> a, pair <string, pii> b)
{
    if(a.ft == b.ft) return a.sd > b.sd;
    return a.ft < b.ft;
}
void solve(){
    string s;
    cin >> s;
    string a, b;a +=s[0];
    ll l = 1;
    for(ll i = 1; i < s.size(); i++){
        b += s[i];
        if(a == b){

        }
        else{ //cout << a << " " << b << endl;
            a = b; b.clear(); l++;
        }
    } cout << l << endl;

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


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

int main(){
   
    int A,B,K;
    cin>>A>>B>>K;
    for(int i=0;i<K;i++){
        if(i%2==0){
            if(A%2) A--;
            B+=A/2;
            A/=2;
        }
        else{
            if(B%2) B--;
            A+=B/2;
            B/=2;
        }
    }
    cout<<A<<" "<<B<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int pre[100005];
int find_root(int x)
{
    if(pre[x] == x)
        return x;
    return find_root(pre[x]);
}
int main()
{
    int n, q;
    while(scanf("%d%d", &n, &q), n || q)
    {
        pre[1] = 1;
        for(int i = 2; i <= n; i++)
            scanf("%d", &pre[i]);
        char a;
        int b;
        long long ans = 0ll;
        while(q--)
        {
            scanf(" %c%d", &a, &b);
            if(a == 'Q')
                ans += find_root(b);
            else
                pre[b] = b;
        }
        printf("%lld\n", ans);
    }
    return 0;
}

Measured memory_bytes: 1416
# -*- coding: utf-8 -*-

# AtCoder Beginner Contest
# Problem C

if __name__ == '__main__':
    n, intervel = list(map(int, input().split()))
    ts = list(map(int, input().split()))
    ts += [ts[-1] + intervel]

    total_t = 0
    previous_t = ts[0]

    for i in range(1, n + 1):
        current_t = ts[i]

        if (previous_t + intervel) > current_t:
            total_t += max(0, current_t - previous_t)
        else:
            total_t += intervel

        previous_t = current_t

    print(total_t)


Measured memory_bytes: 26708
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
int gcd(int a,int b){return b?gcd(b,a%b):a;}

const int MAX=510000;
long long 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 COM(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;
}


vector<ll> prime_fact(ll n){
    vector<ll> ret;ll k=n;bool flag;
    while(k>1)
    {
        ll s=sqrt(k)+1;flag=false;ll i=2;
        while(k%i!=0){
            if(i>=s){
                flag=1;break;
            }
            i++;
        }
        if(flag){
            ret.push_back(k);  k=1;
        }
        else{
            k/=i;  ret.push_back(i);
        }
    }
    return ret;
}
//問題やばいのは素数きても{1,1,1,1,p}{1,1,1,p,1}みたいな場合があり得る
//だから足りない分は1で埋めるし、
//普通に{2,3,4}の順列数えた後に{24,1,1}とかも数えに行かなきゃいけない
int main(){
    COMinit();
    ll n,m;
    cin>>n>>m;
    vector<ll> p=prime_fact(m);//O(log(m))
    ll el=p.size();//要素数
    map<ll,ll> ma;
    for(ll x:p){
        ma[x]++;
    }
    //これでダブリカウントできるなぁ
    //重複組み合わせ蟻本P67
    ll ans=1;
    for(auto x:ma){
        ll num=x.second;
        ll tmp=COM(num+n-1,num);
        ans=(ans*tmp)%mod;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 12160
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <unordered_map>
#include <map>
#include <numeric>
#include <limits>
#include <utility>
#include <queue>
#include <random>
using namespace std;

int main(){
	int a,b,c,d,x,y;
    
    cin >> a >> b >> c >> d;
    
    x = a * b;
    y = c * d;
    
    if(x > y){
        cout << x;
    }
    else{
        cout << y;
    }
    
	return 0;
}

Measured memory_bytes: 256
using System;

class AtCoder{
  public static void Main(){

    string s = Console.ReadLine();
    char[] c = s.ToCharArray();
    Array.Sort(c);
    
    bool b = true;
    for (int i = 1; i < s.Length; i++){
        if(c[i] == c[i-1]){
            b = false;
            break;
        }
    }
    if(b) Console.WriteLine("yes");
    else Console.WriteLine("no");
  }
}


Measured memory_bytes: 11348
#include<stdio.h>

typedef struct{
  int parent;
  int left;
  int right;
} Tree;

Tree tree[1000000];

#define NIL -1

int main()
{
  int a,id,j,n,k,c[100000],depth=0,num;

  scanf("%d",&n);

  for(a=0;a<n;a++){
    tree[a].parent=NIL;
    tree[a].left=NIL;
    tree[a].right=NIL;
  }

  for(a=0;a<n;a++){
    scanf("%d%d",&id,&k);
    for(j=0;j<k;j++){
      scanf("%d",&c[j]);
      if(j==0){
	tree[c[0]].parent=id;
        tree[id].left=c[0];
      }
      else{
        tree[c[j]].parent=id;
        tree[c[j-1]].right=c[j];
      }
    }
  }
  
  for(a=0;a<n;a++){
    printf("node %d: parent = %d, ",a,tree[a].parent);
    num=a;
    while(tree[num].parent!=NIL){
      depth++;
      num=tree[num].parent;
    }
    printf("depth = %d,",depth);
    depth=0;
    if(tree[a].parent==NIL && tree[a].left==NIL){
      printf(" root, []\n");
    }
    else if(tree[a].parent==NIL && tree[a].left!=NIL){
      printf(" root, [%d",tree[a].left);
      for(j=tree[tree[a].left].right;j!=NIL;j=tree[j].right){
        printf(", %d",j);
      }
      printf("]\n");
    }
    else if(tree[a].left!=NIL){
      printf(" internal node, [%d",tree[a].left);
      for(j=tree[tree[a].left].right;j!=NIL;j=tree[j].right){
        printf(", %d",j);
      }
      printf("]\n");
    }
    
    else{
      printf(" leaf, []\n");
    }
    
  }
  return 0;
}



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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define VI         vector<int>
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e19;
//const int INF=(1<<30);


int main(){
  int a,b;
  cin >> a >> b;
  cout << (a <= b ? a : a-1) << endl;
}



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

#define INF ((1<<30)-1)
#define LLINF (1LL<<60)
#define EPS (1e-10)

int main() {
    int N;
    double D;
    cin >> N >> D;
    vector<double> x(N), y(N);
    int num = 0;
    rep(i, N) {
        double a, b;
        cin >> a >> b;
        if (a*a+b*b <= D*D) {
            num++;
        }
    }
    cout << num << endl;
}


Measured memory_bytes: 6488
from operator import itemgetter

N, M = map(int, input().split())

ci = []
pi = [0] * N
for i in range(M):
    ci.append([i] + list(map(int, input().split())))

ci.sort(key=itemgetter(1,2))
for c in ci:
    pi[c[1]-1] += 1
    prestr = str(c[1]).zfill(6)
    bhstr = str(pi[c[1]-1]).zfill(6)
    c.append(''.join([prestr, bhstr]))

ci.sort()
for c in ci:
    print(c[3])

Measured memory_bytes: 35704
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define REP1(i,a,b) for(int i=a; i<=(int)(b); i++)
#define ALL(x) begin(x),end(x)
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin >> s;
    reverse(ALL(s));

    int carry = 0;
    LL ans=0;
    int n = s.length();
    for(int i=0; i<n; i++) {
        int cc=(s[i]-'0')+carry;
        if(cc>5 || (cc==5 && i+1<n && s[i+1]>='5')) {
            ans += 10-cc;
            carry=1;
        } else {
            ans += cc;
            carry=0;
        }
    }
    cout << ans+carry << endl;
    return 0;
}

Measured memory_bytes: 1948
#include<stdio.h>
int main()
{
  int a,b,i,j;
  while(1)
	   {
  scanf("%d%d",&a,&b);
  if(a==0&&b==0){break;}

  for(i=1;i<=a;i++)
    {
      for(j=1;j<=b;j++)
	{
	  if(i>1&&i<a&&j<b&&j>1)printf(".");
	  else printf("#");
	}
      printf("\n");
    }
  printf("\n");
    
	   }
  return 0;
}



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

int main() {
    int n,m, x;
    int b = 0, s = 0;
    int a[105];
    cin >> n >> m>>x;
    for (int i = 0; i < m; i++) {
        cin >> a[i];
        if (a[i] > x)b++;
        else s++;
    }
    cout << min(b, s) << endl;

}

Measured memory_bytes: 256
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
//#include <utility>
#include <set>
#include <iostream>
//#include <memory>
#include <string>
#include <vector>
#include <algorithm>
//#include <functional>
#include <sstream>
//#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
//#include <cctype>
#include <cstring>
//#include <ctime>
#include <iterator>
#include <bitset>
//#include <numeric>
//#include <list>
//#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


namespace{
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}


#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8
static const int INF=1<<24;

void mainmain(){
	int h,w;
	while(cin>>h>>w,h||w){
		vvint vv;
		initvv(vv,h,w,0);
		vvint ww=vv,hh=vv;
		rep(i,h){
			rep(j,w){
				char t;
				cin>>t;
				vv[i][j]=(t=='*'?1:0);
			}
		}
		rep(i,h){
			ww[i][0]=vv[i][0];
		}
		rep(i,w){
			hh[0][i]=vv[0][i];
		}
		rep(i,h){
			reep(j,1,w){
				ww[i][j]+=ww[i][j-1];
				ww[i][j]+=vv[i][j];
			}
		}
		rep(i,w){
			reep(j,1,h){
				hh[j][i]+=hh[j-1][i];
				hh[j][i]+=vv[j][i];
			}
		}
		int ans=0;
		rep(i,h){
			rep(j,w){
				if(vv[i][j]==0){
					ans=max(ans,1);
					reep(k,i,h){
						if(hh[k][j]!=hh[i][j]) break;
						reep(g,j,w){
							// cout<<"g "<<g<<endl;
							if(hh[k][g]!=hh[i][g]-vv[i][g]){
								ans=max(ans,(k-i+1)*(g-j));
								break;
							}
							if(g==w-1){
								ans=max(ans,(k-i+1)*(g-j+1));
							}
						}
					}
				}
			}
		}
		cout<<ans<<endl;
	}
}



}
main() try{
    mainmain();
}
catch(...){
}

Measured memory_bytes: 4172
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	int A, B;
	cin >> A >> B;

	if (8 < max(A, B))
		cout << ":(" << endl;

	else
		cout << "Yay!" << endl;

	return;
}

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

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>

using namespace std;

int a[100001];

int main()
{
    int n;
    scanf("%d",&n);
    int i;
    for(i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
    }
    int t=1,tem,c=0;
    while(1)
    {
            c++;
            if(a[t]==2)break;
            if(a[t]==0)
            {
                printf("-1\n");
                return 0;
            }
            tem=t;
            t=a[tem];
            a[tem]=0;
            
    }
    printf("%d\n",c);
    return 0;
}

Measured memory_bytes: 640
fun main(args: Array<String>) {
    val input = readLine()!!.split(" ").map { it.toInt() }
    val playerNumber = input[0]
    val defaultPoint = input[1]
    val correctAnswer = input[2]
    val who = mutableListOf<Int>()
    repeat(correctAnswer) {
        who.add(readLine()!!.toInt())
    }
    abc141c(playerNumber, defaultPoint, who)
}

fun abc141c(playerNumber: Int, startPoint: Int, answerPlayer: MutableList<Int>){
    val playerScore = mutableListOf<Int>()
    repeat(playerNumber) {
        playerScore.add(startPoint)
    }

    for (element in answerPlayer) {
        playerScore[element - 1] += 1
    }

    for (i in playerScore) {
        when {
            i > answerPlayer.size -> println("Yes")
            else -> println("No")
        }
    }
}

Measured memory_bytes: 48548
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)
int main(void){
    string A,B;
    cin>>A>>B;

    if(A.size()>B.size())
        cout<<"GREATER"<<endl;
    else if(A.size()<B.size())
        cout<<"LESS"<<endl;
    else{
        int cnt=0;
        rep(i,A.size()){
            if(A[i]>B[i]){
                cout<<"GREATER"<<endl;
                return 0;
            }else if(A[i]<B[i]){
                cout<<"LESS"<<endl;
                return 0;
            }
        }
            cout<<"EQUAL"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
class Main {

	static int []col;
	static boolean [][]adj;
	static boolean []visited;
	static int inf=(int)1e4;
	
	static pair color (int u)
	{
		
		pair ans=new pair(col[u]);
		for(int v=0;v<visited.length;v++)
		{
			if(!adj[u][v])
				continue;
			if(col[v]==-1)
			{
				col[v]=1-col[u];
				ans.merge(color(v));
			}
			else if(col[v]==col[u])
				return new pair(inf,inf);
				
		}
		return ans;
	}
	public static void main(String[] args) throws IOException {
		Scanner sc=new Scanner(System.in);
		PrintWriter pw=new PrintWriter(System.out);
		int n=sc.nextInt(),m=sc.nextInt();
		adj=new boolean [n][n];
		visited=new boolean[n];
		for(int i=0;i<n;i++)
		{
			Arrays.fill(adj[i], true);
			adj[i][i]=false;
		}
		
		while(m-->0)
		{
			int u=sc.nextInt()-1,v=sc.nextInt()-1;
			adj[u][v]=adj[v][u]=false;
		}
		ArrayList<pair> pairs=new ArrayList();
		int cc=1;
		boolean [][]reachable=new boolean[n+1][n+1];
		// what values are reachable after processing i connected components
		reachable[0][0]=true;
		col=new int [n];
		Arrays.fill(col, -1);
		for(int i=0;i<n;i++)
			if(col[i]==-1)
			{
				col[i]=0;
				pair p=color(i);
				if(p.S>=inf)
				{
					System.out.println(-1);
					return;
				}
				pairs.add(p);
				for(int j=0;j<=n;j++)
					if(reachable[cc-1][j])
						reachable[cc][j+p.S]=reachable[cc][j+p.T]=true;
				cc++;
				
			}
		cc--;
		long ans=n*1L*(n-1);
		for(int i=0;i<=n;i++)
			if(reachable[cc][i])
			{
				long A=i,B=n-i;
				ans=Math.min(ans, A*(A-1)+B*(B-1));
			}
		pw.println(ans/2);
		
			
		
		
		pw.close();
		
	}
	static class pair
	{
		int S,T;
		pair(int x)
		{
			if(x==0)
				S++;
			else T++;
		}
		pair(int x,int y)
		{
			S=inf;T=inf;
		}
		void merge(pair other)
		{
			S+=other.S;
			T+=other.T;
		}
	}
	static class Scanner {
        StringTokenizer st;
        BufferedReader br;
 
        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }
 
        public Scanner(FileReader s) {
            br = new BufferedReader(s);
        }
 
        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }
 
        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }
 
        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }
 
        public String nextLine() throws IOException {
            return br.readLine();
        }
        public boolean ready() throws IOException {return br.ready();}
        public double nextDouble() throws IOException {return Double.parseDouble(next());}
       
    }

}

Measured memory_bytes: 47232
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<iostream>
using namespace std;

int a[105];
int n;

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	sort(a+1,a+n+1);
	int ans=0;
	for(int i=1;i<=n;i++){
		if(a[i]!=a[i+1]){
			ans++;
		}
	}
	printf("%d\n",ans);
	return 0;
}	

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define rep(i, s, n) for(int i = s; i < n; i++)

int main() {
    ll n;
    cin >> n;
    cout << n*(n-1)/2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
using namespace std;
typedef long long ll;
const int MOD = 1000000007;

int main()
{
  int N;
  ll res=1;
  cin >> N;

  FOR(i,1,N){
    res = (res * (i%MOD)) % MOD;
  }

  cout << res << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
using namespace std;
typedef long long LL;
const LL INF = 0x3f3f3f3f3f3f3f3f;

LL n,a;
LL mx = 0,cnt[100005];

int main(){
	ios::sync_with_stdio(false);
	cin >> n;
	for(LL i = 1;i <= n;i ++){
		cin >> a; mx = max(mx,a);
		cnt[a] ++;
	}
	for(LL i = 0;i <= mx;i ++) cnt[max(i,mx - i)] --;
	for(LL i = 1;i <= n;i ++) if(cnt[i] < 0){ cout << "Impossible" << endl; return 0; }
	
	for(LL i = 0;i <= ((mx + 1) >> 1);i ++) if(cnt[i] > 0){ cout << "Impossible" << endl; return 0; }
	for(LL i = mx + 1;i <= 100;i ++) if(cnt[i] > 0){ cout << "Impossible" << endl; return 0; }
	
	cout << "Possible" << endl;
	return 0;
}
//

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
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...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 30;
const int MOD = 1e9 + 7;

const int N = 1e5 + 10;
int64 dp[N];
int x[N];
int64 c[N];

void add(int x, int64 y, int n) {
  for (; x <= n; x += x & -x) {
    c[x] = min(c[x], y);
  }
}

int64 query(int x) {
  int64 ret = 1LL << 60;
  for (; x; x -= x & -x) {
    ret = min(ret, c[x]);
  }
  return ret;
}

int main() {
  int n, E, t;
  scanf("%d%d%d", &n, &E, &t);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &x[i]);
  }
  x[n] = E;
  fill(c, c + N, 1LL << 60);
  dp[n] = 0;
  int64 y = dp[n] + x[n] + 2 * x[n - 1];
  add(1, y, n);
  for (int i = n - 1; i >= 0; --i) {
    int j = upper_bound(x + i, x + n, t / 2 + x[i]) - x;
    int k = j - 1;
    // trace(i, j, k);
    dp[i] = x[k + 1] + dp[k + 1] + t - x[i];
    if (j + 1 <= n) {
      int64 cur = query(n - j);
      dp[i] = min(dp[i], cur - 3LL * x[i]);
    }
    if (i > 0) {
      y = dp[i] + x[i] + 2 * x[i - 1];
      add(n + 1 - i, y, n);
    }
  }
  // for (int i = 0; i < n; ++i) {
  //   cout << i << " " << dp[i] << endl;
  // }
  printf("%lld\n", x[0] + dp[0]);
  return 0;
}


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

int main() {
  int n; cin >> n;
  int money = 100000;
  for(int i = 0; i < n; i++) {
    int add = money * 0.05;
    if( add % 1000 ) {
      add -= add % 1000;
      add += 1000;
    }
    money += add;
  }
  cout << money << endl;
}

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

void solve(std::string S){
  long long N = S.size()+1;
  vector<long long> tab(N);

  for(long long i = 0; i < (N-1); i++) {
    if(S[i] == '<') tab[i+1] = max(tab[i+1], tab[i] + 1);
  }

  for(long long i = (N-2); i >= 0; i--) {
    if(S[i] == '>') tab[i] = max(tab[i], tab[i+1] + 1);
  }

  cout << accumulate(tab.begin(), tab.end(), 0ll) << endl;
}

// 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)
int main(){
    std::string S;
  std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 5252
/*
	AOJ_0100: Sale Result
*/
#include	<iostream>
#include	<vector>
#include	<utility>

using namespace std;

typedef unsigned long long ull;

class employee {
private:
	int number;
	ull proceed;
public:
	employee() {
		number = 1;
		proceed = 0;
	}
	employee(int _n, ull _p) {
		number = _n;
		proceed = _p;
	}
	void addProceed(ull in_prcd) {
		if (proceed < 1000000) { proceed += in_prcd; }
	}
	bool isSatisfy(void) {
		return (proceed >= 1000000 ? true : false);
	}
	int showNumber(void) {
		return number;
	}
};

int main(void) {
	vector<employee> Emps;
	int n, member, price, count;
	ull buf_prcd;
	bool isNothing, isNotHit;

	while (1) {
		isNothing = true;

		cin >> n;
		if (n == 0) { break; }
		for (int i = 0; i < n; i++) {
			cin >> member >> price >> count;
			buf_prcd = price * count;
			isNotHit = true;

			vector<employee>::iterator it = Emps.begin();
			while (it != Emps.end()) {
				if (it->showNumber() == member) {
					isNotHit = false;
					it->addProceed(buf_prcd);
					break;
				}
				it++;
			}
			if (isNotHit) {
				Emps.push_back( employee(member, buf_prcd) );
			}
		}

		isNotHit = true;
		vector<employee>::iterator it = Emps.begin();
		while (it != Emps.end()) {
			if (it->isSatisfy() == true) {
				isNotHit = false;
				cout << it->showNumber() << endl;
			}
			it++;
		}
		if (isNotHit) {
			cout << "NA" << endl;
		}
		Emps.clear();
	}
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> vec(n);
  for(int i = 0; i < n; i++) {
    cin >> vec.at(i);
  }
  
  int answer = 0;
  for(int i = 1; i < n - 1; i++) {
    if(vec.at(i-1) < vec.at(i) && vec.at(i) < vec.at(i+1)) {
      answer++;
    } else if(vec.at(i-1) > vec.at(i) && vec.at(i) > vec.at(i+1)) {
      answer++;
    }
  }
  
  cout << answer << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <unordered_map>
#include <cstring>
#include <queue>
#include <stack>
#define INT long long
#define MOD 1000000007
#define oo 987654321
#define OO 999999987654321ll
using namespace std;

INT x, n, k, a[5050], ans, sum;
bool dt[2][5050];
unordered_map<INT, int> chk;
queue<INT> q;

int main()
{
    ios::sync_with_stdio(false);
    cin>>x;
    for( ans = 1 ;  sum < x ; ans++ )
        sum += ans;
    cout<<ans-1<<endl;
    return 0;
}


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

#include <vector>
using namespace std;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)

typedef long long ll;

int main() {
    int N;
    ll ans = 0;
    cin >> N;
    vector<int> A(100005);
    rep(i, N) {
        int tmp;
        cin >> tmp;
        A[tmp]++;
        ans += tmp;
    }
    int Q;
    cin >> Q;
    rep(i, Q) {
        ll B, C;
        cin >> B >> C;
        ll cnt = A[B];
        A[B] = 0;
        ans -= B * cnt;
        ans += C * cnt;
        A[C] += cnt;
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3748
#include <iostream>
#include <string>

std::string K;
int d;

int dp[10001][100][2];
constexpr int mod = 1000000007;

int main(){
  std::cin >> K;
  std::cin >> d;
  int n = K.length();
  dp[0][0][0] = 1;
  dp[0][0][1] = 1;
  for(int i = 1; i <= n; i++){
    for(int j = 0; j < d; j++){
      for(int k = 0; k < 10; k++){
        int l = (10 * d + j - k) % d;
        dp[i][j][0] += dp[i-1][l][0];
        if(dp[i][j][0] >= mod) dp[i][j][0] -= mod;
        if(k == K[n-i]-'0') dp[i][j][1] += dp[i-1][l][1];
        if(k <  K[n-i]-'0') dp[i][j][1] += dp[i-1][l][0];
        if(dp[i][j][1] >= mod) dp[i][j][1] -= mod;
      }
    }
  }
  std::cout << (dp[n][0][1] + mod-1) % mod << std::endl;
  return 0;
}


Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using Pt = pair<int, int>;

int main()
{
	ll N, X, M;
	cin >> N >> X >> M;

	vl B(2 * M);
	B[0] = X;
	int i = 1;
	for (; i < 2 * M; ++i)
	{
		B[i] = (B[i - 1] * B[i - 1]) % M;
		if (B[i] == 0)
		{
			ll ans = 0;
			for (int j = 0; j < i; ++j)
				ans += B[j];
			cout << ans << endl;
			return 0;
		}
	}
	if (N <= M)
	{
		ll ans = 0;
		for (int j = 0; j < N; ++j)
			ans += B[j];
		cout << ans << endl;
		return 0;
	}


	int K = 0;
	for (int i = M - 2; i > -1; --i)
	{
		++K;
		if (B[M - 1] == B[i])
			break;
	}
	int stub = 0;
	for (int i = 0; i < M; ++i)
	{
		if (B[i + K] == B[i])
			break;
		++stub;
	}
	ll ans = 0;
	for (int i = 0; i < stub; ++i)
		ans += B[i];
	N -= stub;
	ll m = N / K;
	ll r = N % K;
	ll tmp = 0;
	for (int i = 0; i < K; ++i)
		tmp += B[i + stub];
	ans += tmp * m;
	for (int i = 0; i < r; ++i)
		ans += B[i + stub];
	cout << ans << endl;

	//ll ans2 = 0;
	//int x = X;
	//for (int i = 0; i < N + stub; ++i)
	//{

	//	ans2 += X;
	//	X = (X * X) % M;
	//}
	//cout << ans2 << endl;
	return 0;
}


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

#define en "\n"
#define INF (int) 9e18
#define HELL (int) (1e9 + 7)
#define int long long
#define double long double
#define uint unsigned long long
#define pii pair<int, int>
#define pb push_back
#define fs first
#define sc second
#define size(a) (int) a.size()
#define deb(x) cerr << #x << " => " << x << en
#define deba(x) cerr << #x << en; for (auto a : x) cerr << a << " "; cerr << en;
#define debp(x) cerr << #x << en; for (auto a : x)cerr<<"("<<a.fs<<", "<<a.sc<<") "; cerr << en;
#define debm(x) cerr << #x << en; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << en;}
#define getMat(x, n, m, val) vector<vector<int>> x(n, vector<int> (m, val))
#define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define pout cout << fixed << setprecision(10)
int fastpow(int a, int b, int m = HELL) { int res = 1; a %= m;
while (b > 0) { if (b & 1) res = (res * a) % m; a = (a * a) % m; b >>= 1; } return res;}
#define inv(a) fastpow(a, HELL - 2)
#define mul(a, b) ((a % HELL) * (b % HELL)) % HELL

int32_t main() { fastio;
	string a, b;
	cin >> a >> b;
	b.pop_back();
	if (a.compare(b) == 0) {
		cout << "Yes" << endl; 
	} else {
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 3616
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    k,x = LI()

    return JA(range(x-k+1,x+k), " ")


print(main())





Measured memory_bytes: 6476
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

vint ans;
vint c;
vbool canuse;
vint e[10005];
void dfs(int v, int id) {
    if (ans[v]) return;
    while (!canuse[id]) {
        id++;
    }
    ans[v] = c[id];
    canuse[id] = false;
    for (auto u : e[v]) {
        dfs(u, id);
    }
}

int main() {
    int n;
    cin >> n;
    ans.resize(n, 0);
    c.resize(n);
    canuse.resize(n, true);
    vpair edge;
    rep(i, n-1) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        e[a].push_back(b);
        e[b].push_back(a);
        edge.emplace_back(a, b);
    }
    rep(i, n) cin >> c[i];
    sort(rall(c));

    dfs(0, 0);

    ll score = 0;
    rep(i, n-1) score += min(ans[edge[i].fi], ans[edge[i].se]);
    cout << score << endl;
    out_ary(ans);
    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <algorithm>    
#include <cmath>
#include <map>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <set>
#include <functional>
#define int long long
#define mod(int)(1000000007)
using namespace std;
const int INF = 1000000000000;
int test[345678];
signed main() {
	int n, m, a, ans = 0; cin >> n >> m;
	priority_queue<int, vector<int>, less<int>> cnt;
	for (int h = 0; h < n; h++) {
		cin >> a; cnt.push(a);
	}
	for (int h = 0; h < m; h++) {
		int b = 0; b = cnt.top(); cnt.pop();
		b /= 2; cnt.push(b);
	}
	int b = cnt.size();
	for (int h = 0; h < b; h++) {
		ans += cnt.top(); cnt.pop();
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1400
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <sstream>
#include <set>
#include <tuple>
#include <algorithm>
#include <memory>
#include <numeric>
#include <queue>
#include <functional>
#include <cmath>
#include <cstring>
#include <map>
#include <unordered_map>
#include <sstream>
#include <iomanip>

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

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

const ll INF = 1LL << 60;
const ll MOD = 1000000007;

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

	ll N, M, K;
	cin >> N >> M >> K;

	vector<ll> A(N + 1);
	vector<ll> B(M + 1);
	for (ll i = 0; i < N; ++i) cin >> A[i + 1];
	for (ll i = 0; i < M; ++i) cin >> B[i + 1];

	ll pA = 0;
	ll pB = 0;
	
	ll kA = 0;
	ll kB = 0;

	for (pB = 0; pB <= M; ++pB)
	{
		kB += B[pB];
		if (kB > K)
		{
			kB -= B[pB];
			pB--;
			break;
		}
	}

	pB = max(pB, 0LL);
	pB = min(pB, M);

	ll ans = 0;
	//ll ans = pB + 1;
	
	for (pA = 0; pA <= N; ++pA)
	{
		kA += A[pA];

		while (kA + kB > K)
		{
			if (pB <= 0) break;

			kB -= B[pB];
			pB--;
		}

		if (pB <= 0 && kA + kB > K)
		{
			kA -= B[pA];
			pA--;

			break;
		}

		ans = max(ans, min(max(pA, 0LL), N) + min(max(pB, 0LL), M));
	}

	ans = max(ans, min(max(pA, 0LL), N) + min(max(pB, 0LL), M));

	cout << ans << endl;
}


Measured memory_bytes: 6348
data class JudgeStatus(
    var ac: Int,
    var wa: Int,
    var tle: Int,
    var re: Int
)

fun main() {

    val numberTest = readLine()!!.toInt()
    val inputs = mutableListOf<String>()
    repeat(numberTest) {
        inputs.add(readLine()!!)
    }

    val judgeStatus = judge(inputs)

    println("AC x ${judgeStatus.ac}")
    println("WA x ${judgeStatus.wa}")
    println("TLE x ${judgeStatus.tle}")
    println("RE x ${judgeStatus.re}")
}

fun judge(inputs: MutableList<String>): JudgeStatus {
    val judgeStatus = JudgeStatus(0,0,0,0)
    inputs.forEach {
        when(it) {
            "AC" -> judgeStatus.ac++
            "WA" -> judgeStatus.wa++
            "TLE" -> judgeStatus.tle++
            "RE" -> judgeStatus.re++
        }
    }
    return judgeStatus
}

Measured memory_bytes: 60076
#include<bits/stdc++.h>
#define rep(i,a,...) for(int i = (a)*(strlen(#__VA_ARGS__)!=0);i<(int)(strlen(#__VA_ARGS__)?__VA_ARGS__:(a));++i)
#define per(i,a,...) for(int i = (strlen(#__VA_ARGS__)?__VA_ARGS__:(a))-1;i>=(int)(strlen(#__VA_ARGS__)?(a):0);--i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using ll = long long;
//const ll MOD = (ll)1e9+7;
const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}
#ifdef DEBUG
#define debug(x) cout<<"LINE "<<__LINE__<<": "<<#x<<" = "<<x<<endl;
#else
#define debug(x) (void)0
#endif

namespace templates{
  ll modpow(ll x, ll b){
    ll res = 1;
    while(b){
      if(b&1)res = res * x % MOD;
      x = x * x % MOD;
      b>>=1;
    }
    return res;
  }

  ll modinv(ll x){
    return modpow(x, MOD-2);
  }

  bool was_output = false;
  template<class t>
  void output(t a){
    if(was_output)cout << " ";
    cout << a;
    was_output = true;
  }
  void outendl(){
    was_output = false;
    cout << endl;
  }
  ll in(){
    ll res;
    scanf("%lld", &res);
    return res;
  }

  template<class t>
  istream& operator>>(istream&is, vector<t>&x){
    for(auto &i:x)is >> i;
    return is;
  }

  template<class t, class u>
  istream& operator>>(istream&is, pair<t, u>&x){
    is >> x.first >> x.second;
    return is;
  }

  template<class t>
  void in(t&x){
    cin >> x;
  }

  template<class t>
  t in(){
    t res; cin >> res; return res;
  }

  template<class t>
  void out(t x){
    cout << x;
  }

  template<class t>
  vector<t> sorted(vector<t> line,function<bool(t,t)> comp=[](t a,t b){return a<b;}){
    sort(line.begin(),line.end(),comp);
    return line;
  }

  template<class t>
  vector<t> reversed(vector<t> line){
    reverse(line.begin(),line.end());
    return line;
  }
}

using namespace templates;

int main(){
  int n = in();
  vector<pll> line;
  rep(i,n)line.emplace_back(in(),i);
  sort(all(line),greater<pll>());
  function<ll(int,int)> func =
    [&](int l,int r) -> ll{
      if(l>r)return 0;
      static vvector<ll> dp(n,vector<ll>(n,-1));
      ll &res = dp[l][r];
      if(res>=0)return res;
      int p = l + n - r - 1;
      ll place = line[p].second;
      ll score = line[p].first;
      chmax(res,abs(place-l)*score+func(l+1,r));
      chmax(res,abs(place-r)*score+func(l,r-1));
      return res;
    };
  cout << func(0,n-1) << endl;
  return 0;
}


Measured memory_bytes: 34964
from itertools import permutations
N = int(input())

P = [int(x) for x in input().split()]
Q = tuple(map(int, input().split()))

copy = P.copy()
copy.sort()

P = tuple(P)


permuts = list(permutations(copy))

p = 0
q = 0

for i in range(len(permuts)):
    if permuts[i] == P:
        p = i + 1
    if permuts[i] == Q:
        q = i + 1

print(abs(p - q))

Measured memory_bytes: 8052
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <functional>
#include <queue>
#include <math.h>
#include <cmath>
#include <unordered_map>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;


const string YES = "Yes";
const string NO = "No";

void solve(std::string N){
    int ans=0;
    rep(i,N.length()){
        ans+=N[i]-'0';
        ans%=9;
    }
    if(ans==0){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::string N;
    std::cin >> N;
    solve(N);
    return 0;
}


Measured memory_bytes: 3920
/**
这个题目要求依次装车
*/

#include<stdio.h>
#include<iostream>

#define MAX_N 100000
#define MAX_K 100000
#define MAX_W 10000
#define MAX_P (MAX_N*MAX_W)

typedef long long LL;

using namespace std;

int goods[MAX_N];

bool Judge(int P, int N, int K){
    int goodsIdx=0;
    for(int k=0; k<K; k++){
        //依次装车
        int restVol=P;
        while(restVol>=goods[goodsIdx]){
            restVol-=goods[goodsIdx];
            goodsIdx++;
            if(goodsIdx==N)
                return true;
        }
    }
    return false;
}

int main()
{
    int N, K;
    scanf("%d%d",&N, &K);
    for(int i=0; i<N; i++)
        scanf("%d", goods+i);
    int l=0, r=MAX_P;
    while(l<=r){
        int mid=(l+r)/2;
        if(Judge(mid, N, K)){
            r=mid-1;
        }
        else{
            l=mid+1;
        }
    }
    printf("%d\n", r+1);
    return 0;
}



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

int main(int argc, char const *argv[]) {
  int n, a, max, min;
  max = -1000000;
  min = 1000000;
  long int sum = 0;

  cin >> n;

  for (int i = 0; i < n; i++) {
    cin >> a;
    if (a > max) max = a;
    if (a < min) min = a;
    sum = sum + a;
  }
  cout << min << " " << max << " " << sum << endl;

  return 0;
}



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

int main() {
	string str;
	cin>>str;
	if(str[0]==str[1] && str[1]==str[2])
	  cout<<"Yes"<<'\n';
	else if(str[1]==str[2] && str[2]==str[3])
		cout<<"Yes"<<'\n';
	else
	   cout<<"No"<<'\n';
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
const int N=1e6;
int a[N],f1[N],f2[N];
int main()
{
	int n,d;
	scanf("%d%d",&n,&d);
	f1[0]=d;
	for (int i=1;i<=n;i++) 
	{
		scanf("%d",&a[i]);
		f1[i]=min(f1[i-1],abs(f1[i-1]-a[i]));
	}
	f2[n+1]=1;
	for (int i=n;i>=1;i--)
	{
		if (a[i]>=2*f2[i+1]) f2[i]=f2[i+1]; else f2[i]=f2[i+1]+a[i];
	}
	int q;
	scanf("%d",&q);
	for (int i=1;i<=q;i++)
	{
		int j;
		scanf("%d",&j);
		if (f1[j-1]<f2[j+1]) printf("%s\n","NO"); else printf("%s\n","YES");
	}
}

Measured memory_bytes: 12032
#include <iostream>
#include<iomanip>
#include <cstdint>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int abs( int a ) { return a < 0 ? -a : a; }

int main() {
	int w, h, x, y;
	cin >> w >> h >> x >> y;
	double s = (double)w * (double)h / 2.0;
	int g = ( x * 2 == w && y * 2 == h ) ? 1 : 0;
	cout << fixed << setprecision(10) << s << " " << g << endl;
	return 0;
}

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

int main(){
    int a,b,c;
    int i;
    int x;
    int y=0;
    
    cin >> a >> b >> c;
    x = b - a + 1; 
    
    for (i=0; i < x; i++){
        if (c % (a + i) == 0){
            y++;
        }
    }   
    cout << y << endl;
    
    return 0;
}

Measured memory_bytes: 3064
import copy
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
tmp = copy.copy(a)
tmp.sort()
max_num = tmp[-1]
min_num = tmp[-2]
for i in range(n):
    if a[i] == max_num:
        print(min_num)
    else:
        print(max_num)

Measured memory_bytes: 14560
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cassert>
#define InfL 2000000000
#define InfLL 4000000000000000000LL
#define mod 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
using namespace std;
typedef long long ll;
typedef double db;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<db> vd;

int main() {
	string S;
	cin >> S;
	int N = S.length();
	vi Ssum(N + 1, 0);
	rep(i, N) {
		Ssum[i + 1] = Ssum[i];
		if (S[i] == '1')
			Ssum[i + 1]++;
		else
			Ssum[i + 1]--;
	}
	vi Ssummax(N + 1);
	Ssummax[N] = Ssum[N];
	rrep(i, N)
		Ssummax[i] = max(Ssummax[i + 1], Ssum[i]);
	int Ssummax_all = Ssummax[0];
	int ans = InfL;
	for (int Ssummax_all_new = Ssummax_all; Ssummax_all_new <= Ssummax_all + 1; Ssummax_all_new++) {
		int Ssummin_all_new = Ssum[0];
		int plus1_count = 0;
		rep(i, N) {
			int Ssumtmp = Ssum[i + 1] + plus1_count * 2;
			if (S[i] == '?') {
				if (Ssummax[i + 1] + 2 + plus1_count * 2 <= Ssummax_all_new) {
					// -1 -> +1
					plus1_count++;
					Ssumtmp += 2;
				}
			}
			Ssummin_all_new = min(Ssummin_all_new, Ssumtmp);
		}
		int anstmp = Ssummax_all_new - Ssummin_all_new;
		ans = min(ans, anstmp);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 12156
#include <bits/stdc++.h>
#define PI 3.1415926535897932
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
  
  int N,M,X,Y;
  cin>>N>>M>>X>>Y;
  
  vector<int> a(N);
  for(int i=0;i<N;i++){
    cin>>a[i];
  }
  sort(a.begin(),a.end());
  
  vector<int> b(M);
  for(int j=0;j<M;j++){
    cin>>b[j];
  }
  sort(b.begin(),b.end());
  
  
  if(Y-X<=0){
    cout<<"War"<<endl;
  }
  else{
    vector<int> bound(Y-X);
    for(int i=0;i<Y-X;i++){
      bound[i]=i+1+X;
    }
    
    for(int i=0;i<Y-X;i++){
      if(bound[i]>a[N-1]&&bound[i]<=b[0]){
        cout<<"No War"<<endl;
        return 0;
      }
    }
    cout<<"War"<<endl;
  }
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
//cervello|Phoenix
using namespace std;
#define ll long long int
#define eb emplace_back
#define mk make_pair
#define all(x) x.begin(),x.end()
#define mod 1000000007

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  ll n; cin>>n;
  ll ans = 0;
  for(int i=1; i<=n; i++){
    ans += (n-1)/i;
  }
  cout<<ans<<"\n";
  return 0;
}

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

struct UnionFind{
// 同値関係をサポートするデータ構造
// 併合,所属する同値類の代表元:O(logN), 集合の分割はNG
// 経路圧縮する場合,各クエリはO(a(n)) (a(n): アッカーマン関数A(m,n)について,f(n)=A(n,n)としたときの逆関数)
  vector<int> root;
  vector<int64_t> size;
  int64_t Ninconv;

  UnionFind(int64_t N): root(N), size(N,1), Ninconv(N*(N-1)/2)
  { iota(root.begin(), root.end(), 0); }

  int find(int a){
    if(root.at(a)==a){
      return a;
    }
    else{
      return root.at(a)= find(root.at(a));
    }
  }

  void unify(int a, int b){
    int r_a= find(a);
    int r_b= find(b);

    if(r_a != r_b){
      if(size.at(r_a) < size.at(r_b)){
        root.at(r_a)= r_b;
        Ninconv-= size.at(r_a)* size.at(r_b);
        size.at(r_b)+= size.at(r_a);
        return;
      }
      else{
        root.at(r_b)= r_a;
        Ninconv-= size.at(r_a)* size.at(r_b);
        size.at(r_a)+= size.at(r_b);
        return;
      }
    }
  }
  
  bool are_comrade(int a, int b){
    return find(a)==find(b);
  }

  int get_size(int a){
    return size.at(find(a));
  }

  int64_t get_inconv(){
    return Ninconv;
  }
};

int main(){
  using pii= pair<int, int>;
  int64_t N,M;
  cin >> N >> M;

  UnionFind uf(N);
  stack<pii> falling;
  stack<int64_t> ans;

  int buf1,buf2;
  for(int i=0; i<M; i++){
    cin >> buf1 >> buf2;
    buf1--; buf2--; // 1-indexed -> 0-indexed
    falling.push(make_pair(buf1,buf2));
  }

  while(!falling.empty()){
    ans.push(uf.get_inconv());

    auto bridge= falling.top();
    tie(buf1, buf2)= bridge;
    uf.unify(buf1, buf2);
    falling.pop();
  }

  while(!ans.empty()){
    cout << ans.top() << endl;
    ans.pop();
  }
}

Measured memory_bytes: 3328