akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい

#define ALL(x) x.begin(),x.end()
#define get_tp(t,i) get<i>(t)
#define len(x) (ll)(x.size())
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef pair<long long,long long> pllll; //pair<ll,ll>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<int, vector<int>, greater<int> > gpq; //逆順priority_queue
typedef priority_queue<int> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const long double PI=3.1415926535897932;

int main(){
    ll N;
    cin>>N;
    ll ans=0;
    for(ll i=1;i<=N;i++){
        ll cnt=N/i;
        ans+=i*cnt*(cnt+1)/2;   
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#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;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;

int n, q;
ll s[200010], t[200010], x[200010], d[200010], ans[200010];

int main(){
    cin >> n >> q;
    rep(i, n) cin >> s[i] >> t[i] >> x[i];
    rep(i, q) cin >> d[i];

    vector<tuple<ll,ll,ll>> event;

    rep(i, n){
        event.push_back({s[i] - x[i], 1, x[i]});
        event.push_back({t[i] - x[i], -1, x[i]});
    }
    sort(event.begin(), event.end());

    set<ll> st;

    int idx = 0;


    rep(i, q){
        ll t = d[i];
        while(idx < event.size() && get<0>(event[idx]) <= t){
            if (get<1>(event[idx]) == 1) st.insert(get<2>(event[idx]));
            else st.erase(get<2>(event[idx]));
            idx++;
        }
        if(st.empty()) ans[i] = -1;
        else ans[i] = *st.begin();
    }

    rep(i, q) cout << ans[i] << endl;

    return 0;
}


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

struct Node{
  Node *parent, *left, *right;
  int key, priority;
};

Node *deleteN(Node*,int);

Node *root, *NIL;


Node *rightRotate(Node *t){
  Node *s=t->left;
  t->left=s->right;
  s->right=t;
  return s;
}

Node *leftRotate(Node *t){
  Node *s=t->right;
  t->right=s->left;
  s->left=t;
  return s;
}

Node *insert(Node *t,int key,int priority){
  if(t==NIL){
    Node *temp;
    temp=new Node;
    temp->key=key;
    temp->priority=priority;
    temp->left=NIL;
    temp->right=NIL;
    return temp;
  }
  if(key==t->key){
    return t;
  }
  
  if(key<t->key){
    t->left=insert(t->left,key,priority);
    if(t->priority<t->left->priority)
      t=rightRotate(t);
  }else{
    t->right=insert(t->right,key,priority);
    if(t->priority<t->right->priority)
      t=leftRotate(t);
  }
  return t;
}

bool find(Node *t,int key){
  while(t!=NIL && key!=t->key){
    if(key<t->key) t=t->left;
    else t=t->right;
  }
  return t!=NIL;
}

void inorder(Node *t){
  if(t==NIL) return;
  cout<<" "<<t->key;
  inorder(t->left);
  inorder(t->right);
}

void preorder(Node *t){
  if(t==NIL)return;
  preorder(t->left);
  cout<<" "<<t->key;
  preorder(t->right);
}

void print(Node *t){
  preorder(t);
  cout<<endl;
  inorder(t);
  cout<<endl;
}

Node *_delete(Node *t, int key){
  if(t->left==NIL && t->right==NIL){
    if(t->parent!=NIL){
      if(t->parent->left->key==key) t->parent->left=NIL;
      else t->parent->right=NIL;
    }
    return NIL;
  }else if(t->left==NIL)
    t=leftRotate(t);
  else if(t->right==NIL)
    t=rightRotate(t);
  else {
    if(t->left->priority > t->right->priority)
      t=rightRotate(t);
    else
      t=leftRotate(t);
  }
  return deleteN(t,key);
}

Node *deleteN(Node *t,int key){
  if(t==NIL) return NIL;
  if(key<t->key) t->left=deleteN(t->left,key);
  else if(key>t->key) t->right=deleteN(t->right,key);
  else return _delete(t,key);
  return t;
}

int main(){
  int m,k,p;
  string s;
  cin>>m;
  for(int i=0;i<m;i++){
    cin>>s;
    if(s=="insert"){
      cin>>k>>p;
      root=insert(root,k,p);
    }else if(s=="find"){
      cin>>k;
      if(find(root,k)) cout<<"yes"<<endl;
      else cout<<"no"<<endl;
    }else if(s=="delete"){
      cin>>k;
      root=deleteN(root,k);
    }else if(s=="print"){
      print(root);
    }
  }
  return 0;
}



Measured memory_bytes: 12456
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<random>
#include<stack>
#include<queue>
#include<bitset>
#include<sstream>

#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 cosp(x) cout << x << " "

using namespace std;
using ll = long long;

int main(int argc, const char *argv[]){
    string s;
    cin >> s;
    if(s=="Sunny"){co("Cloudy");return 0;}
    if(s=="Cloudy"){co("Rainy");return 0;}
    co("Sunny");
    return 0;
}

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

using namespace std;

int main(){
	int n[5];
	int i,j;
	
	for(i=0;i<5;i++){
		cin >> n[i];
	}

	int k;
	cin >> k;

	bool ans=true;

	for(i=0;i<5;i++){
		for(j=i+1;j<5;j++){
			if(n[j]-n[i]>k){
				ans=false;
	}}}

	if(ans){
		puts("Yay!");
	}else{
		puts(":(");
	}
	
}

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

namespace ConsoleApp11
{
    class Class45
    {
        static void Main()
        {
            var I = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var N = I[0];
            var M = I[1];
            var a = new int[M];
            var b = new int[M];
            Dictionary<int, int> roads = new Dictionary<int, int>();
            for(int i = 0; i < N; i++)
            {
                roads.Add(i, 0);
            }
            for(int i = 0; i < M; i++)
            {
                var read = Console.ReadLine().Split().Select(int.Parse).ToArray();
                a[i] = read[0]-1;
                b[i] = read[1]-1;
            }
            for(int i = 0; i < M; i++)
            {
                roads[a[i]]++;
                roads[b[i]]++;
            }
            foreach (int i in roads.Values)
                Console.WriteLine(i);
        }
    }
}


Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,i,j,k,c;cin>>n;
  int a[3]={},b[3]={};
  for(i=0;i<n;i++){
    cin>>k;
    a[k%3]++;
    b[k%3]++;
  }
  int ans=0;
  if(a[1]==0&&a[2]==0){
    ans=1;
  }else{
    j=0;
    if(a[1]){
      j++;a[1]--;c=1;
      while(1){
	if(c==1){
	  if(a[1]){
	    j++;a[1]--;c=2;
	  }else {
	    if(a[2]) j++;
	    break;
	  }
	}else{
	  if(a[2]){
	    j++;a[2]--;c=1;
	  }else{
	    if(a[1]) j++;
	    break;
	  }
	}
      }
      j+=a[0];
      ans=max(ans,j);

    }
    j=0;
    if(b[2]){
      j++;b[2]--;c=2;
      while(1){
	if(c==1){
	  if(b[1]){
	    j++;b[1]--;c=2;
	  }else{
	    if(b[2]) j++;
	    break;
	  }
	}else{
	  if(b[2]){
	    j++;b[2]--;c=1;
	  }else{ 
	    if(b[1]) j++;
	    break;
	  }
	}
      }
      j+=b[0];

      ans=max(ans,j);
    }
  }
  
  cout << ans << endl;
}

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

int main()
{
  int a,b;cin>>a>>b;
  int count=0;
  if (a>b)
  {
    count += a;
    a--;
  }
  else
  {
    count+=b;
    b--;
  }
  if (a>b)
  {
    count += a;
    a--;
  }
  else
  {
    count+=b;
    b--;
  }
  
  cout<<count<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
using namespace std;

int main(void) {
	int k,t,maxi=0;
	cin >> k >> t;
	vector<int> cake(t);
	for(int i=0; i<t; i++){
		cin >> cake[i];
		maxi=max(cake[i],maxi);
	}
	cout << max(k-(k-maxi)*2-1,0) << endl;
	return 0;
}

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

int main(){
	char a, b;
	cin >> a >> b;
	if(a > b) cout << '>' << endl;
	else if(a == b) cout << '=' << endl;
	else cout << '<' << endl;
}

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

int main() {

  int N;
  cin >> N;

  string S;
  cin >> S;

  if (S.substr(0, N / 2) == S.substr(N / 2)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

}

Measured memory_bytes: 256
N = int(input())
V = input().split()
C = input().split()

V = [int(v) for v in V]
C = [int(c) for c in C]

def dp(i):
    if(i==0):
        if(V[i]<C[i]):
            return 0,0 
        else:
            return V[i],C[i]
    
    else:
        v,c = dp(i-1)
        v1 = v + V[i]
        c1 = c + C[i]
        
        if(v1-c1 <= v-c):
            return v,c
        else:
            return v1,c1
        
        
v,c = dp(N-1)
print(v-c)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

#include <complex>
#include <math.h>

typedef double D;
typedef complex<D> P;
typedef pair<P, P> L;
typedef vector<P> VP;

const D EPS = 1e-9;
const D INF = 1e9;

#define X real()
#define Y imag()

#define LE(n,m)	((n) < (m) + EPS)
#define GE(n,m)	((n) + EPS > (m))
#define EQ(n,m) (abs((n)-(m)) < EPS)

VP cpr(P a, P b, D r) {
	VP cs;
	P h = (b - a) * 0.5;
	D d = abs(h);
	if (d == 0 || d > r) return cs;
	D N = sqrt(r*r - d*d);
	P n = h * P(0, 1) * (N / d);
	cs.push_back(a + h + n);
	if (N > 0)cs.push_back(a + h - n);
	return cs;
}

int main() {
	int n;
	while (cin >> n && n) {
		VP v(n);
		rep(i, n) {
			D x, y;
			cin >> x >> y;
			v[i] = P(x, y);
		}
		int ans = 1;
		rep(i, n)rep(j, n)if (i != j) {
			auto t = cpr(v[i], v[j], 1.0);
			for (auto p : t) {
				int count = 0;
				rep(k, n) {
					if (abs(p - v[k]) <= 1.0 + EPS) {
						count++;
					}
				}
				ans = max(ans, count);
			}
		}
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 3104
import time

def sequence(A, n):
    dic = {}
    
    def solve(i, m):
        if (i, m) in dic:
            return dic[(i, m)]
        if m == 0:
            dic[(i, m)] = True
        elif i >= n:
            dic[(i, m)] = False
        elif solve(i+1, m):
            dic[(i, m)] = True
        elif solve(i+1, m-A[i]):
            dic[(i, m)] = True
        else:
            dic[(i, m)] = False
        return dic[(i, m)]
    
    return solve

if __name__ == '__main__':
    n = int(raw_input())
    A = map(int, raw_input().split())
    q = int(raw_input())
    m = map(int, raw_input().split())

    #start = time.time()
    solve = sequence(A, n)
    for m_i in m:
        print "yes" if solve(0, m_i) else "no"
    #end = time.time()
    #print end - start

Measured memory_bytes: 12208
import math
import copy
import sys
import fractions
import numpy as np
from functools import reduce


# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum


def getInputListInt():
    outputoData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===

n = getInputInt()
data = getInputListInt()

ans = data[0]


for i in range(1, n):
    ans = ans * data[i] // fractions.gcd(ans, data[i])

prians=0
for i in range(n):
    prians += (ans-1) % data[i]
print(prians)

Measured memory_bytes: 15676
#include <bits/stdc++.h>
 
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long
 
const int N=3e5+5,MAX=3e7,MOD=1e9+7;
 
using namespace std;

int n,k,q,m;
int a[N];
int main()
{
   	
 

    	scanf("%d %d",&n,&m);
    	priority_queue<int>q;
    	for(int i=0;i<n;i++){
    		int x;
    		scanf("%d",&x);
    		q.push(x);
    	}
    	
    	while(m--){
    		int u = q.top();

    		u/=2;
    		q.pop();
    		q.push(u);
    	}
    	ll ans=0;
    	while(!q.empty())ans+=q.top(),q.pop();

    	printf("%lld\n",ans );
 	


}


Measured memory_bytes: 892
import math
import numpy as np

def myfunc(n):
    f = []
    c = 0
    r = int(n ** 0.5)
    for i in range(2, r + 2):
        while n % i == 0:
            c += 1
            n = n // i
        if c != 0:
            f.append([i, c])
            c = 0

    if n != 1:
        f.append([n, 1])

    return f

N = int(input())
M = (math.sqrt(N)) + 1

L = np.array([1, 3, 6, 10, 15, 21, 28, 36])

f = myfunc(N)
count = 0
for _, c in f:
    if c == 1:
        count += c
    else:
        i = (L <= c).sum()
        count += i

print(count)

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

// {{{
template<typename T>
void printmatrix(vector<vector<T> > ar){
    for (int i = 0; i < (int)ar.size(); i++) {
        for (int j = 0; j < (int)ar[0].size(); j++) {
            cout << ar[i][j];
        }
        cout << endl;
    }
}

template<typename T>
void printvector(vector<T> vec){
    for (int i = 0; i < (int)vec.size(); i++) {
        cout << vec[i] << endl;
    }
}

template<typename T>
void unique(vector<T>& vec){
    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
}

template<typename T>
vector<T> cumsum(vector<T> vec){
    vector<T> newvec((T)vec.size());
    ll tmp = 0;
    for (ll i = 0; i < (ll)vec.size(); i++) {
        tmp += vec[i];
        newvec[i] = tmp;
    }

    return newvec;
}

template<typename T>
T digitsum(T x){
    T y=0;
    while(x){
        y += x % 10;
        x /= 10;
    }

    return y;
}

template<typename T>
T gcd(T x, T y){
    if (x == 0 || y == 0) {
        return 0;
    }

    while (x != y){
        if (x > y) {
            x -= y;
        }else{
            y -= x;
        }
    }
    return x;
}

// }}}
/* vim:set foldmethod=marker: */

void solve(){
    ll n;
    cin >> n;
  
    string s="";
    if (n == 0) {
        s = "0";
    }

    while(n != 0){
        s = to_string(n & 1) + s;
        n -= (n & 1);
        n /= -2;
    }

    cout << s << endl;

    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}

// sortの仕方
// int a[N];
// array<int,N> ar;
// vector<int> v;
//
// sort(a, a+N); // 配列
// sort(ar.begin(), ar.end()); // array
// sort(v.begin(), v.end()); // vector 昇順
// sort(v.begin(), v.end(), greater<int>()); // 降順

// Template
// template <class T>
// T foomax(T x, T y){
//   if (x > y){
//     return x;
//   }else{
//     return y;
//   }
// }

// string を int に変換 stoi("1010")
// int を string に変換 to_string(1010)


// map の key, value を全て抜き出す。
// for (auto itr = mp.begin(); itr != mp.end(); itr++) {
//     cout << "key" << itr->first << " value" << itr->second << endl;
// }

// 文字列の検索
// string s="abc";
// if (s.find('d') == string::npos){
//     cout << "find" << endl;
// }else{
//     cout << "not find" << endl;
// }


Measured memory_bytes: 256
#include <cstdio>

using namespace std;

int main()
{
	int a, b, c, t = 0;
	scanf("%d%d%d",&a,&b,&c);
	if(a >= b) {t = a; a = b; b = t;}
	if(b >= c) {t = b; b = c; c = t;}
	if(a >= c) {t = a; a = c; c = t;}
	if(a == 5 && b == 5 && c == 7) printf("YES\n");
	else printf("NO\n");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
 
#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);
 
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;
 
constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433;
 
template <class T> vector<T> multivector(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto multivector(size_t N,T... t){return vector<decltype(multivector(t...))>(N,multivector(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

int main() {
    ll N,K,S; cin >> N >> K >> S;
    vector<ll> A(N);
    for(int i = 0; i < K; ++i){
        A[i] = S;
    }
    ll x = 1000000000;
    for(int i = K; i < N; ++i){
        if(S!=x) A[i] = x;
        else A[i] = x - 1;
    }
    for(int i = 0; i < N; ++i) cout << A[i] << " ";
    cout << endl;

	return 0;
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
int main(){
    int A,B,C,X,ans = 0;
    cin >> A >> B >> C >> X;
    for(int i = 0;i < min(X/500,A)+1;i ++){
        for(int j = 0;j < min((X-500*i)/100,B)+1;j ++){
            if((X-500*i-100*j)/50<=C) ans ++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int n;
int id;
int t[100000];
int u[100000];
int v[100000];
int w[100000];
int tmp[100000];
 
void setdepth(int x){
  if(t[x]==-1){
    w[x]=0;
    return;
  }
  if(w[x]!=-1)return;
  setdepth(t[x]);
  w[x]=w[t[x]]+1;
}
 
void init(){
  int i;
  for(i=0;i<100000;i++){
    t[i]=-1;
    u[i]=-1;
    v[i]=-1;
    w[i]=-1;
  }
}
 
int main(){
  int i,j,k,pos;
 
  init();
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&id);
    scanf("%d",&k);
    for(j=0;j<k;j++){
      scanf("%d",&tmp[j]);
      t[tmp[j]]=id;
      if(j>0)v[tmp[j-1]]=tmp[j];
    }
    if(k)u[id]=tmp[0];
  }
 
 
  for(i=0;i<n;i++){
    setdepth(i);
    printf("node %d: parent = %d, depth = %d, ",i,t[i],w[i]);
    if(w[i]==0)printf("root, ");
    else if(u[i]==-1)printf("leaf, ");
    else printf("internal node, ");
    pos=u[i];
    printf("[");
    if(pos!=-1){
      while(1){
    printf("%d",pos);
    pos=v[pos];
    if(pos==-1)break;
    printf(", ");
      }
    }
    printf("]\n");
     
  }
  return 0;
}

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

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define fst first
#define snd second

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

    cout << fixed << setprecision(12) << (double)(pow(l, 3) / 27);

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long l,r,st,en,mini,i,j;
int main(){
    mini=3000;
    cin>>l>>r;
    st=l%2019;
    en=r%2019;
    if(r-l+1>=2019||en<st){
        cout<<"0"<<endl;
    }
    else{
        for(i=st;i<=en;i++){
            for(j=i+1;j<=en;j++){
                mini=min(mini,i*j%2019);
            }
        }
        cout<<mini;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,m,c=0;cin>>n>>m;
  if(n>=m)return cout<<0,0;
  vector<int> x(m),s(m-1);
  for(int i=0;i<m;++i)cin>>x[i];
  sort(x.begin(),x.end());
  for(int i=0;i<m-1;++i)s[i]+=(x[i+1]-x[i]),c+=s[i];
  sort(s.begin(),s.end(),greater<int>());
  n--;
  for(int i=0;i<n;++i)c-=s[i];
  cout<<max(c,0);
}

Measured memory_bytes: 1024
S=input()
T=input()
L=len(S)
AZ="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
j=0
for i in range(L):
	if S[i:i+1].islower()==True:
		S=S.replace(S[i],AZ[j])
		j=j+1
k=0
for i in range(L):
	if T[i:i+1].islower()==True:
		T=T.replace(T[i],AZ[k])  
		k=k+1
if S==T:
	print("Yes")
else:
	print("No")

Measured memory_bytes: 3632
#!/usr/bin/env python3

def main():
    sn = input()
    sa = input().split(' ')
    aa = [int(s) for s in sa]

    c = 0
    f = True

    while f:
        for i, ai in enumerate(aa):
            if ai & 1 != 0:
                f = False
                break
            else:
                aa[i] = ai >> 1
        if f:
            c += 1

    print(c)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
	
	public static Boolean search(int[] S, int t, int low, int high) {
		int mid = low + (high-low)/2;  // initializing middle value to search
		if (high < low) {
			return false;  // the algorithm has iterated through without finding t
			}
		if (S[mid] > t) {
			return search(S,t,low,mid-1);  // if t is in S, it'll be in the half of the array less than the middle value
			}
		else if (S[mid] < t) {
			return search(S,t,mid+1,high);  // if t is in S, it'll be in the half of the array greater than the middle value
			}
		else /*(S[mid] == t)*/ {  // this means mid = t, so t is in S
			return true;
			}
	}
	
	public static int contains(int[] S, int[] T) {
		int counter = 0;
		int low = 0;
		int high = S.length - 1;
		for (int t : T) {
			if (search(S, t, low, high)) {  // iterates through each value in T and searches for it in S
				counter++;
			}
		}
		return counter;
	}

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int sizeS = in.nextInt();
		int[] S = new int[sizeS];
		for (int i = 0; i < sizeS; i++) {
			S[i] = in.nextInt();
		}
		int sizeT = in.nextInt();
		int[] T = new int[sizeT];
		for (int i = 0; i < sizeT; i++) {
			T[i] = in.nextInt();
		}
		in.close();
		int result = contains(S,T);
		System.out.println(result);
	}

}



Measured memory_bytes: 67616
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n,c;

struct BITree{
	ll bit[100005];
	BITree(){}
	void update(int k,ll a){
		while(k<=100000){
			bit[k]+=a;
			k+=(k&(-k));
		}
	}

	ll sum(int k){
		ll s=0;
		while(k>0){
			s+=bit[k];
			k-=(k&(-k));
		}
		return s;
	}

	ll query(int a,int b){
		return sum(b)-sum(a);
	}
};

BITree seg,seg2;

int b[100005],w[100005];
P vec_l[100005],vec_r[100005];
P vec[100005];

ll solve(int l,int r){
	int n=r-l;
	if(n<=1)return 0;
	ll ans=0;
	ans+=solve(l,(l+r)/2);
	ans+=solve((l+r)/2,r);
	int li=0,ri=0;
	int size_vl=(l+r)/2-l;
	int size_vr=r-(l+r)/2;
	for(int i=0;i<size_vl;i++){
		vec_l[i]=vec[l+i];
	}
	for(int i=0;i<size_vr;i++){
		vec_r[i]=vec[(l+r)/2+i];
	}
	for(int i=0;i<size_vl;i++){
		seg.update(vec_l[i].second,1);
		seg2.update(vec_l[i].second,vec_l[i].second);
	}
	for(int i=0;i<n;i++){
		if(li<size_vl && (ri==size_vr || vec_l[li].first<vec_r[ri].first)){
			seg.update(vec_l[li].second,-1);
			seg2.update(vec_l[li].second,-vec_l[li].second);
			vec[l+i]=vec_l[li++];
		}else{
			if(ri<size_vr){
				ans+=(ll)seg2.query(0,vec_r[ri].second)*c+seg.query(0,vec_r[ri].second)*vec_r[ri].second;
				ans+=(ll)seg2.query(vec_r[ri].second,100000)+seg.query(vec_r[ri].second,100000)*vec_r[ri].second*c;
			}
			vec[l+i]=vec_r[ri++];
		}
	}
	return ans; 
}

int main(void){
	scanf("%d%d",&n,&c);
	for(int i=0;i<n;i++){
		scanf("%d%d",&b[i],&w[i]);
		b[i]--;
		vec[i]=P(b[i],w[i]);
	}
	printf("%lld\n",solve(0,n));
	return 0;
}

Measured memory_bytes: 7864
import math
import numpy as np

def main():
    A,B,H,M = map(int, input().split())
    min = H*60+M
    
    H_loc = min * 0.5
    M_loc = M * 6
    
    if abs(H_loc-M_loc) > 180:
        theta = 360 - abs(H_loc - M_loc)
    else:
        theta = abs(H_loc - M_loc)
    #print(theta)
    
    r = math.sqrt(A**2 + B**2 - 2*A*B*np.cos(np.radians(theta)))
    print(r)
    #a = list(map(int, input().split()))
    #print(a)
    
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 27200
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int N, K, T, U, V, L;
int A[10010];

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

  cin >> N >> K >> T >> U >> V >> L;
  for (int i = 0; i < N; i++) {
    int D;
    cin >> D;
    A[D]++;
  }

  int car = 0, bst = 0;
  double ans = 0;
  for (int i = 1; i <= L; i++) {
    ans += 1.0 / (bst ? V : U);
    bst = max(0, bst - 1);
    if (A[i]) {
      if (bst == 0) bst = T * V;
      else if (car < K) car++;
      else bst = T * V;
    } else {
      if (bst == 0 && car) car--, bst = T * V;
    }
  }
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 3304
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

//Cheese
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[][] move = {{0,1},{0,-1},{1,0},{-1,0}};
		int h = sc.nextInt();
		int w = sc.nextInt();
		int n = sc.nextInt();
		char[][] m = new char[h][w];
		int si = 0;
		int sj = 0;
		for(int i=0;i<h;i++){
			char[] s = sc.next().toCharArray();
			for(int j=0;j<w;j++){
				m[i][j] = s[j];
				if(s[j]=='S'){
					si = i;
					sj = j;
				}
			}
		}
		int ans = 0;
		for(int x=1;x<=n;x++){
			boolean[][] used = new boolean[h][w];
			used[si][sj] = true;
			List<int[]> l = new ArrayList<int[]>();
			l.add(new int[]{si,sj});
			int step = 0;
			while(!l.isEmpty()){
				List<int[]> next = new ArrayList<int[]>();
				for(int[]a:l){
					int i = a[0];
					int j = a[1];
					if(m[i][j]==(char)(x+'0')){
						ans += step;
						si = i;
						sj = j;
						next.clear();
						break;
					}
					for(int k=0;k<4;k++){
						int ni = i+move[k][0];
						int nj = j+move[k][1];
						if(0<=ni&&ni<h&&0<=nj&&nj<w&&m[ni][nj]!='X'&&!used[ni][nj]){
							used[ni][nj] = true;
							next.add(new int[]{ni,nj});
						}
					}
				}
				step++;
				l = next;
			}
		}
		System.out.println(ans);
	}
}

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

using namespace std;

int main()
{
 long long int a,b,x;
 cin>>a>>b>>x;

long long int count;

if(a==0 && b==0)
   count=1;
else if(a==0 && b>0)
    count=b/x+1;

else
    count=b/x-(a-1)/x;

cout<<count;
}


Measured memory_bytes: 3180
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define MOD 1000000007
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec; typedef pair<int, int> pi;
int dd[] = { 0, 1, 0, -1, 0 };
#define all(u) begin(u),end(u)
#define mp make_pair
#define pb push_back

int A[10010][1500];
int main()
{
  while(true)
    {
      int N, M;
      scanf("%d%d", &N,&M);
      if(N == 0 && M == 0)break;
      //int A[10010][1500]={0};
      //int A[10010][1500];
      memset(A,0,sizeof(A));
      int r;
      scanf("%d", &r);
      rep(i, r)
	{
	  int t, n, m, s;
	  scanf("%d%d%d%d", &t, &n, &m, &s);
	  if(s == 1)
	    {
	      A[m][t]++;
	    }
	  else
	    {
	      A[m][t+1]--;
	    }
	}
      repi(i, 1, M + 1)
	{
	  rep(t, 1300)
	    {
	      if(t == 0)continue;
	      A[i][t] += A[i][t-1];
	    }
       }

      int q;
      scanf("%d", &q);
      rep(i, q)
	{
	  int ts, te, m;
	  scanf("%d%d%d", &ts,&te,&m);
	  int start = -1;
	  int ans = 0;
	  repi(t, ts, te+1)
	    {
	      if(start == -1)
		{
		  if(A[m][t] > 0)
		    {
		      start = t;
		    }
		}
	      else
		{
		  if(A[m][t] <= 0)
		    {
		      ans += t - start - 1;
		      start = -1;
		    }
		}
	    }
	  if(start != -1)ans += te - start;
	  printf("%d\n", ans);
	}
    }
  return 0;
}

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

int main(){
	int n; cin >> n;
	unordered_set<string> st;
	string b;
	for(int i = 0; i < n; ++i){
		string a;
		cin >> a;
		if(st.count(a) != 0){
			cout << "No" << endl;
			return 0;
		}
		else{
			if(i){
				if(b.back() != a.front()){
					cout << "No" << endl;
					return 0;
				}
			}
		}
		st.insert(a);
		b = a;
	}
	cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
    int n,i,j,k;
    cin>>n;
    int a[n],b[n],c[n],dp[3][n]={0};
    for(i=0;i<n;i++){
        cin>>a[i]>>b[i]>>c[i];
    }
    dp[0][0]=a[0];
    dp[1][0]=b[0];
    dp[2][0]=c[0];
    for(i=1;i<n;i++){
        dp[0][i]=0;
        dp[1][i]=0;
        dp[2][i]=0;
        dp[0][i]=max(dp[0][i],max(dp[1][i-1]+a[i],dp[2][i-1]+a[i]));
        dp[1][i]=max(dp[1][i],max(dp[0][i-1]+b[i],dp[2][i-1]+b[i]));
        dp[2][i]=max(dp[2][i],max(dp[0][i-1]+c[i],dp[1][i-1]+c[i]));
    }
    cout<<max(dp[0][n-1],max(dp[1][n-1],dp[2][n-1]));
}

Measured memory_bytes: 2560
def resolve():
    N = int(input())
    _xmin, _xmax = float("inf"), -float("inf")
    _ymin, _ymax = float("inf"), -float("inf")
    for i in range(N):
        x, y = list(map(int, input().split()))
        _x, _y = x - y, x + y
        _xmin = min(_x, _xmin)
        _xmax = max(_x, _xmax)
        _ymin = min(_y, _ymin)
        _ymax = max(_y, _ymax)
    print(max(_xmax-_xmin, _ymax-_ymin))


if '__main__' == __name__:
    resolve()

Measured memory_bytes: 69800
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <numeric>
#include <unordered_map>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <memory>
#include <iomanip>
#include <type_traits>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
constexpr long long MOD = 1e9 + 7;
constexpr long long MAX = 1000000;

//long long MOD = 998244353;
constexpr ll INF = 1e17;
constexpr double PI = 3.141592653589793;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }



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

    ll a, b, c;
    cin >> a >> b >> c;

    if (a + b + c >= 22ll) {
        cout << "bust" << "\n";
    }
    else {
        cout << "win" << "\n";
    }
    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;
 
class Main {
    public static void main(final String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] a = new int[n+1];
        int[] b = new int[n];
        for (int i = 0; i < n + 1; i++) {
            a[i] = scan.nextInt();
        }
        for (int i = 0; i < n; i++) {
            b[i] = scan.nextInt();
        }
        long ans = 0;
        for (int j = 0; j < n; j++) {
            int x = Math.min(a[j], b[j]);
            ans += x;
            b[j] -= x;
            int y = Math.min(a[j + 1], b[j]);
            ans += y;
            a[j + 1] -= y;
            b[j] -= y;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 64964
// ALDS1_7_D.cpp
// Tree - Reconstruction of a Tree

#include <iostream>
#include <vector>
using namespace std;

void reconst(vector<int>& pre, vector<int>& in, vector<int>& post)
{
    if (pre.empty()) return;
    int root = pre[0];
    int in_root = 0;
    for (int i = 0; i < in.size(); i++) {
        if (in[i] == root) {
            in_root = i;
            break;
        }
    }
    vector<int> in_left(in.begin(), in.begin() + in_root);
    vector<int> in_right(in.begin() + in_root + 1, in.end());
    vector<int> pre_left(pre.begin() + 1, pre.begin() + in_root + 1);
    vector<int> pre_right(pre.begin() + in_root + 1, pre.end());
    reconst(pre_left, in_left, post);
    reconst(pre_right, in_right, post);
    post.push_back(root);
}

int main()
{
    int n;
    cin >> n;
    vector<int> preorder(n);
    vector<int> inorder(n);
    vector<int> postorder;
    for (int i = 0; i < n; i++) {
        cin >> preorder[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> inorder[i];
    }
    reconst(preorder, inorder, postorder);
    for (int i = 0; i < n; i++) {
        if (i > 0) cout << " ";
        cout << postorder[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3140
#include<bits/stdc++.h>
#define fo(i,l,r) for(int i=l;i<=r;i++)
#define of(i,l,r) for(int i=l;i>=r;i--)
#define fe(i,u) for(int i=head[u];i;i=e[i].next)
#define el putchar('\n')
#define ta putchar('	')
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
inline void open(const char *s)
{
	#ifndef ONLINE_JUDGE
	char str[20];
	sprintf(str,"%s.in",s);
	freopen(str,"r",stdin);
//	sprintf(str,"%s.out",s);
//	freopen(str,"w",stdout);
	#endif
}
inline int rd()
{
	static int x,f;
	x=0;f=1;
	char ch=getchar();
	for(;ch<'0'||ch>'9';ch=getchar())if(ch=='-')f=-1;
	for(;ch>='0'&&ch<='9';ch=getchar())x=x*10+ch-'0';
	return f>0?x:-x;
}
const int N=1000010,mod=998244353;
int n,a[N];
bool vis[N];int pri[N],cnt=0,miu[N],inv[N],f[N];
vector<int>fac[N];

inline int pls(int a,int b){return a+b>=mod?a+b-mod:a+b;}
inline int upd(int&a,int b){return a=pls(a,b);}
inline int mns(int a,int b){return a<b?a-b+mod:a-b;}
inline int mul(int a,int b){return(ll)a*b%mod;}

inline void prelude(int n)
{
	miu[1]=1;inv[0]=inv[1]=1;
	fo(i,2,n){
		inv[i]=mns(0,mul(mod/i,inv[mod%i]));
		if(!vis[i])miu[i]=mod-1,pri[++cnt]=i;
		for(int j=1;j<=cnt&&pri[j]*i<=n;++j){
			int x=pri[j]*i;vis[x]=1;
			if(i%pri[j]==0){miu[x]=0;break;}
			miu[x]=mns(0,miu[i]);
		}
	}
	fo(i,1,n){
		for(int j=i;j<=n;j+=i){
			upd(f[j],mul(miu[i],inv[j/i]));
			if(i^j)upd(a[i],a[j]);
		}
	}
	fo(i,1,cnt)for(int j=pri[i];j<=n;j+=pri[i])fac[j].push_back(pri[i]);
}

int main()
{
	n=rd();
	int ans=0;
	fo(i,1,n){
		int x=rd();
		upd(a[x],x);
		ans=mns(ans,x);
	}
	prelude(N-10);
	fo(i,1,N-10)if(f[i]){
		int tmp=mul(f[i],mul(a[i],a[i]));
		upd(ans,tmp);
	}
	ans=mul(ans,(mod+1)/2);
	cout<<ans;
	return 0;
}


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

string s;
bool a = false, b = false;

int main()
{
    ios_base::sync_with_stdio(false);
    cin >> s;
    for (int i = 0; i < s.size(); i++)
    {
        if (s[i] == 'A')
        {
            a = true;
        }
        if (s[i] == 'B')
        {
            b = true;
        }
    }

    if (a && b)
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int n,
      a,b,c,d,
      answer;
  while(feof(stdin) == 0){
    scanf("%d\n",&n);
    answer = 0;
    if(n <= 36){
      for(a = 0;a <= 9;a++){
        for(b = 0;b <= 9;b++){
          for(c = 0;c <= 9;c++){
            for(d = 0;d <= 9;d++){
              if(n == (a + b + c + d)){
                answer++;
              }
            }
          }
        }
      }
    }
    printf("%d\n",answer);
  }
  return 0;
}

Measured memory_bytes: 604
#include <iostream>
#include <string>
using namespace std;
int main(){
    int n,HP=0,TP=0;
    string HC,TC;
    cin>>n;
    for(int i = 0 ; i < n ; i++){
        cin>>HC>>TC;
        if(HC>TC){
            TP=TP+3;
        }else if(HC<TC){
            HP=HP+3;
        }else{
            TP++;
            HP++;
        }
    }
    cout<<TP<<" "<<HP<<endl;
}



Measured memory_bytes: 3108
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>; // グラフ型

int main()
{
  string s; cin >> s;
  string t[7] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
  int i;
  rep(k,7){ if(s==t[k]) i=k;}
  int j=0;
  while(true){
    j++;
    i++;
    i %= 7;
    if(t[i] == "SUN") break;
  }
  cout << j << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
    int a, b, c = 0, x = 0, y = 0, z = 0, e;
	cin >> a >> b;
	for (int h = x; h <= a; h++) {
		for (int k = y; k <= a; k++) {
			if(b - (h + k) >= 0 && b - (h + k) <= a){
                             c++;
                        }
		}
	}
	cout << c << "\n";
	cin >> e;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s,abc;
	rep(i,26)abc.push_back((char)('A'+i));
	cin>>s;
	rep(i,s.size()){
		cout<<abc[(s[i]-'A'+23)%26];
	}
	cout<<endl;

}



Measured memory_bytes: 3200
h, w = map(int, input().split())
L = [input() for _ in range(h)]
r = 0
for i in range(h):
    for j in range(w):
        if L[i][j] == '#':
            if j < r:
                print('Impossible')
                exit()
            else:
                r = j
else:
    print('Possible')


Measured memory_bytes: 3060
N = int(input())
l = list(map(int,input().split()))
t = sum(l)
half = t/2
tmp = 0
flag = False
for n,i in enumerate(l):
    tmp+=i
    ano = t-tmp
    dif = ano - tmp
    if dif<=0:
        pre = tmp-i
        ano2 = t-pre
        dif2 = ano2 - pre
        if dif2<abs(dif):
            print(dif2)
        else:
            print(abs(dif))
        break

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>
#include<bitset>
#include<list>

using namespace std;

#define ll long long int

ll const MOD = 1000000007;
ll const INF = (long long int)1 << 61;

ll mypow(ll x,ll n,ll mod = MOD){
    ll ret = 1;
    while(n > 0){
        if(n&1){
            ret = (ret*x)%mod;
        }
        x = (x*x)%mod;
        n >>= 1;
    }
    return ret;
}

ll mygcd(ll a,ll b){
    if(b == 0)return a;
    return mygcd(b,a%b);
}

ll twoPow(ll shiftNum){
    return (1LL << (shiftNum - 1));
}

void dfs(ll &ans,ll k,const vector<list<ll>> &edge,ll count,ll x,vector<bool> &used){
    used[x] = true;
    if(k - count > 0){
        ans *= (k-count);
        ans %= MOD;
    }else{
        ans = 0;
    }
    if(count > 0){
        count = 2;
    }else{
        count = 1;
    }
    for(auto itr = edge[x].begin(); itr != edge[x].end(); itr++){
        if(!used[*itr]){
            dfs(ans,k,edge,count++,*itr,used);
        }
    }
    return;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
 
    ll n,k;
    cin >> n >> k;

    vector<list<ll>> edge(n+1);

    for(int i = 0; i < n-1; i++){
        ll a,b;
        cin >> a >> b;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }

    vector<bool> used(n+1,false);

    ll ans = 1;

    dfs(ans,k,edge,0,1,used);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 13952
import itertools


n, m, q = map(int, input().split())
pairs = []
for i in range(q):
    pairs.append(list(map(int, input().split())))

elem = [i for i in range(1, m+1)]

# elemからn回くじを引いて，出た値を昇順にソートする．引いたくじはすぐにelemに戻す．この全組み合わせをリストで返す．
candidates = list(itertools.combinations_with_replacement(elem, n))

dsummax = 0
for cand in candidates:
    dsum = 0
    for i in range(q):
        if cand[pairs[i][1]-1]-cand[pairs[i][0]-1] == pairs[i][2]:
            dsum += pairs[i][3]
    if dsummax < dsum:
        dsummax = dsum

print(dsummax)


Measured memory_bytes: 21456
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <set>
#include <assert.h>
#include <sstream>
#include <string>
//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
typedef std::pair<int,int> P;
using namespace std;
using ll = long long;

struct edge{int to; int color;};

vector<vector<edge>> g(1010101);
map<P,int> m;
void dfs(int v, int p=-1, int c=-1){
    int k = 1;
    rep(iu,(int)g[v].size()){
        edge u = g[v][iu];
        if (u.to!=p){
            if (k==c){
                k++;
            }
            m[P(v,u.to)] = k;
            m[P(u.to,v)] = k;
            dfs(u.to,v,k);
            k++;
        }
    }
}

int main(){
    int n;
    cin >> n;
    
    int a,b;
    vector<P> ab;
    rep(i,n-1){
        cin >> a >> b;
        a--;b--;
        g[b].pb((edge){a,-1});
        g[a].pb((edge){b,-1});
        ab.pb(P(a,b));
    }
    int maxNode = 0;
    rep(i,n){
        maxNode = max(maxNode,(int)g[i].size());
    }
    dfs(0);
    
    cout << maxNode << endl;
    rep(i,n-1){
        a = ab[i].first;
        b = ab[i].second;
        cout << m[ab[i]]<< endl;
    }
    rn 0;
}

Measured memory_bytes: 41848
#include <stdio.h>

int v[200001] = { 0 };

void init(int n) {
  for(int i = 0;i < n;i++) v[i] = i;
}

int root(int x) {
  if(v[x] == x) {
    return x;
  } else {
    v[x] = root(v[x]);
    return v[x];
  }
}

void unite(int x, int y) {
  x = root(x);
  y = root(y);
  if(x == y) return;
  if(v[x] > v[y]) { int tmp = x; x = y; y = tmp; }
  v[y] = v[x];
}

int main(void) {
  int n, m;
  scanf("%d%d", &n, &m);
  init(n);
  for(int i = 0;i < m;i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    x--, y--;
    unite(x, y);
  }
  for(int i = 0;i < n;i++) {
    v[i] = root(v[i]);
  }
  int r[n];
  for(int i =0;i < n;i++) {
    r[i] = 0;
  }
  for(int i = 0;i < n;i++) {
    r[v[i]]++;
  }
  int result = 0;
  for(int i = 0;i < n;i++) {
    if(result < r[i]) result = r[i];
  }
  printf("%d\n", result);
  return 0;
}


Measured memory_bytes: 3708
#include<bits/stdc++.h>
using namespace std;
int cnt(int x)
{
    int k=0;
    while(x)
    {
        x/=10;
        k++;
    }
    return k;
}
int main()
{
    int n;
    cin>>n;
    int y=0;
    for(int i=1;i<=n;i++)
    {
        if(cnt(i)%2!=0)
        {
            y++;
        }
    }
    cout<<y<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next().toUpperCase();
        char a[] = s.toCharArray();
         int count = 0 ;
        for(int j = 0 ; j<a.length ; j++)
        {
        for(int  i= 1+j; i<a.length ; i++)
        {
              if(a[j]==a[i]){
                 count++;
                   break ;
              }  
           
        } 
      
    }  
        if(count==2)System.out.println("Yes");
        else System.out.println("No");
 
 }
}


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

int main() {
  int N,i,m1=0,m2=0;
  cin >> N;
  vector<int> A(N);
  for(i=0; i<N; i++)
    cin >> A.at(i);

  int c=0;
  for(int x : A)
    if(x>m1)
      m1 = x;
  for(int x : A) {
    if(x>m2 && x<m1)
      m2 = x;
    if(x == m1)
      c++;
  }

  if(m2==0 || c>1)
    m2 = m1;

  for(int x : A) {
    if(x != m1)
      cout << m1 << endl;
    else
      cout << m2 << endl;
  }
}

Measured memory_bytes: 2432
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <string>
#include <map>

using namespace std;
int main(int argc, const char * argv[]) {
    
    int n, m;
    cin >> n >> m;
    n++;
    vector<int> a(n,0);
    vector<int> s(n,0);
    for(int i=0; i<m; i++) {
        int t;
        cin >> t;
        a[t] = 1;
    }

    s[0] = a[0] ? 0 : 1;
    s[1] = a[1] ? 0 : 1;
    
    for (int i=2; i<n; i++) {
        if (!a[i]) {
            s[i] = s[i-1] + s[i-2];
            s[i] %=  1000000007;
        }
    }

    cout << s[n-1] << endl;

    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#define loop(i,start,end) for(int i=start;i<end;i++)
using namespace std;
int main(){
   int n;
   cin>>n;
   vector<int> v(n);
   loop(i,0,n-1){
   		int l;
   		cin>>l;
   		v[l-1]++;
   }
   loop(i,0,n){
   		cout<<v[i]<<"\n";
   }
    
}


Measured memory_bytes: 4048
m = int(input())
blue = [input() for i in range(m)]
n = int(input())
red = [input() for j in range(n)]
l = list(set(blue))
anslist = []
for k in range(len(l)):
  anslist.append(max(0,blue.count(l[k]) - red.count(l[k])))
print(max(anslist))

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

int main() {
    int a;
    uint64_t i;
    string s;
    a = 0;
    cin >> s;
    for(i=0;i < s.size();i++){
        a += (s[i] - '0');
    }
    if(a % 9 == 0 && a >= 9|| a == 0){
        cout << "Yes";
    }else{
        cout << "No";
    }
    
}

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

int main()
{
    int K,X;
    
    cin >> K;
    cin >> X;
    
    if(K*500 >= X){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main()
{   char x[2],y[2];
    scanf("%s%s",x,y);
    if((x[0]-'A')>(y[0]-'A')){
        printf(">");
    }else if((x[0]-'A')==(y[0]-'A'))
    printf("=");
    else printf("<");
    return 0;
}


Measured memory_bytes: 128