akhauriyash/Code-Regression huggingface dataset:
macro_rules !input {(source =$s :expr ,$($r :tt ) *) =>{let mut iter =$s .split_whitespace () ;let mut next =||{iter .next () .unwrap () } ;input_inner !{next ,$($r ) *} } ;($($r :tt ) *) =>{let stdin =std ::io ::stdin () ;let mut bytes =std ::io ::Read ::bytes (std ::io ::BufReader ::new (stdin .lock () ) ) ;let mut next =move ||->String {bytes .by_ref () .map (|r |r .unwrap () as char ) .skip_while (|c |c .is_whitespace () ) .take_while (|c |!c .is_whitespace () ) .collect () } ;input_inner !{next ,$($r ) *} } ;}
macro_rules !input_inner {($next :expr ) =>{} ;($next :expr ,) =>{} ;($next :expr ,$var :ident :$t :tt $($r :tt ) *) =>{let $var =read_value !($next ,$t ) ;input_inner !{$next $($r ) *} } ;}
macro_rules !read_value {($next :expr ,($($t :tt ) ,*) ) =>{($(read_value !($next ,$t ) ) ,*) } ;($next :expr ,[$t :tt ;$len :expr ] ) =>{(0 ..$len ) .map (|_ |read_value !($next ,$t ) ) .collect ::<Vec <_ >>() } ;($next :expr ,chars ) =>{read_value !($next ,String ) .chars () .collect ::<Vec <char >>() } ;($next :expr ,usize1 ) =>{read_value !($next ,usize ) -1 } ;($next :expr ,$t :ty ) =>{$next () .parse ::<$t >() .expect ("Parse error" ) } ;}

fn main() {
   input! {
      c: [[i32; 3]; 3]
   }
   for j in 0..2 {
      let da = c[j][0] - c[j+1][0];
      for i in 1..3 {
         if da != c[j][i] - c[j+1][i] {
            println!("No");
            return;
         }
      }
   }
   for j in 0..2 {
      let db = c[0][j] - c[0][j+1];
      for i in 1..3 {
         if db != c[i][j] - c[i][j+1] {
            println!("No");
            return;
         }
      }
   }
   println!("Yes");
}


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

using namespace std;

int main() {
  int N;
  cin >> N;
  int a[100] = {0};
  for (size_t i = 0; i < N; i++) {
    cin >> a[i];
  }
  
  sort(a, a + N, greater<int>());
  int diff = 0;
  for (size_t i = 0; i < N; i++) {
    diff += (i % 2 == 0) ? a[i] : -a[i];
  }
  cout << diff << endl;
  return 0;
}


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




int main(){
    ll N;
    cin >> N;
    vector<ll> a(N+1,0);
    for(int i=0;i<N;i++){
        cin>>a[i+1]
    ;}

    ll j=1;

    for(ll i=1;i<N+1;i++){
        if(a[i]==j){
            j++;
            //cout<<"i="<<i<<"j="<<j<<endl;
        }
    ;}
    if(j==1)cout<<-1<<endl;
    else{
        j--;
        cout<<N-j<<endl;

    }


return 0;


}  



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

int main() {
	ll N, K;
	cin >> N >> K;

	if (2*N < K) {
		cout << 0 << endl;
		return 0;
	}

	ll res = (N / K) * (N / K) * (N / K);
	if (K % 2 == 0) {
		ll x = N / K;
		if ((N / K) * K + K / 2 <= N) { ++x; }

		res += (x * x * x);
	}

	cout << res << endl;

	return 0;
}


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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long
#define MAX_V 10000

typedef pair<ll, ll> P;
vector<ll> dp(100000, INF);  /* dp[i]: i削るのに最小の魔力 */

int main(){
    ll h, n;
    cin >> h >> n;
    vector<int> a(n), b(n);
    REP(i, n) cin >> a[i] >> b[i];
    dp[0] = 0;
    
    REP(i, h+10000) {
        REP(j, n) {
            if(i - a[j] >= 0) dp[i] = min(dp[i], dp[i-a[j]] + b[j]);
        }
    }
    ll ans = INF;
    REP(i, 10000) {
        ans = min(ans, dp[h+i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
n = int(input())
a = list(map(int, input().split()))

cnt = [0] * (10**5 + 10)
for ai in a:
    cnt[ai] += 1

ans = []
s = sum(a)
q = int(input())
for _ in range(q):
    b, c = map(int, input().split())
    s = s + (c - b) * cnt[b]
    ans.append(s)
    cnt[c] += cnt[b]
    cnt[b] = 0

print(*ans, sep='\n')


Measured memory_bytes: 21440
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

func main() {
	sc = initScanner(os.Stdin)
	a, b, c, x := scanInt(sc), scanInt(sc), scanInt(sc), scanInt(sc)

	fmt.Println(resolve(a, b, c, x))
}

func resolve(a int, b int, c int, x int) int {
	count := 0
	for i := 0; i <= a; i++ {
		for j := 0; j <= b; j++ {
			for k := 0; k <= c; k++ {
				if x == i*500+j*100+k*50 {
					count++
				}
			}
		}
	}
	return count
}

// --------------- BASE DEFINITIONS ---------------

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords)
	return sc
}

func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func scanIntSlice(sc *bufio.Scanner, n int) []int {
	is := make([]int, n)
	for i := 0; i < n; i++ {
		is[i] = scanInt(sc)
	}

	return is
}

func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1780
#define _GLIBCXX_DEBUG//TLEの原因になるので注意！！！！！！！！！！！
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.xise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)

//cerrはコメントアウトしなくても通る

int main(){
    ll n,k;
    cin >> n>> k;
    ll s=n/k;//kの倍数の数
    ll ans;
    if(k%2){
        ans=s*s*s;
        cout<<ans<<endl;
        return 0;
    }
    ll t;
    if(k*s+k/2<=n){
        t=s+1;
    }else{
        t=s;
    }
    ans=s*s*s+t*t*t;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <limits.h>
 
#define MAX 100
 
int A[MAX],B[MAX][MAX],n;
    
main(){
  int i,r,c;
 
  scanf("%d",&n);
 
  for(i=0; i<n; i++)
    {
      scanf("%d %d",&r,&c);
      A[i]=r;
      A[i+1]=c;
    }
 
  MatrixChain();
 
  return 0;
}

void MatrixChain()
{
 
  int i,j,k,l,cost;
 
  for(i=1; i<=n; i++)
    {
      B[i][i]=0;
    }
 
  for(l=2; l<=n; l++)
    {
      for(i=1; i<=n-l+1; i++)
    {
      j=i+l-1;
      B[i][j]=INT_MAX;
 
      for(k=i; k<=j-1; k++)
        {
          cost=B[i][k]+B[k+1][j]+A[i-1]*A[k]*A[j];
          if(cost < B[i][j])
        {
          B[i][j]=cost;
        }
        }
    }
    }
  printf("%d\n",B[1][n]);
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main()
{
    int n;
    cin >> n;
    multiset<int> ms;
    for(int i = 0; i < 2 * n; i++)
    {
        int a;
        cin >> a;
        ms.insert(a);
    }
    auto itr = ms.begin();
    int ans = 0;
    while(itr != ms.end())
    {
        ans += *itr;
        itr++;
        itr++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int           long long
#define	pb            push_back
#define all(a)        (a).begin(),(a).end()
#define sz(x)         (int)x.size()
#define F             first
#define S             second
#define endl          "\n"
#define inf           1000000007
#define FOR(i, a, b)  for(int i=a; i<b; i++)
#define bigboi        1e18
mt19937 RNG(chrono::steady_clock::now().time_since_epoch().count()); 
#define SHUF(v) shuffle(all(v), RNG);
// Use mt19937_64 for 64 bit random numbers. 


void solve(){
	int a, b;
	cin>>a>>b;
	FOR(i, 1, 2000){
		if( i*8/100 == a && i/10 == b){
			cout<<i<<endl;
			return;
		}
	}
	cout<<-1<<endl;
}

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0); 	
	int t=1;
	//cin>>t;
	FOR(i, 1, t+1){	
	//	cout<<"Case #"<<i<<":"<<endl;
		solve();
	}
	cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
	return 0;
 
}


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

public class Main {

    public static void main(String[] args) {

        Scanner Input = new Scanner(System.in);
        long N = Input.nextLong();
        long X = 1;
        long Y = 1;
        while (X * Y <= N) {
            X++;
            Y++;
        }
        if (X * Y <= N) {
            System.out.println(X*Y);
        }else System.out.println((X-1)*(Y-1));
    }
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define mod 1000000007
#define mod998 998244353
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
#define lP pair<ll, ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;

int N, A[100001], B[100000];
ll res;

int main() {
	cin >> N;
	for (int i = 0; i <= N; ++i) {
		cin >> A[i];
	}
	for (int i = 0; i < N; ++i) {
		cin >> B[i];
	}
	for (int i = 0; i < N; ++i) {
		res += min(A[i], B[i]);
		B[i] -= min(A[i], B[i]);
		res += min(A[i + 1], B[i]);
		A[i + 1] -= min(A[i + 1], B[i]);
	}
	cout << res << endl;
}

Measured memory_bytes: 1024
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author NikuKyabe
 */

#include "bits/stdc++.h"

using namespace std;
#define int long long
#define FOR(i, a, b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i, n)  FOR(i,0,(n))


class CDubiousDocument2 {
public:
    void solve(std::istream &in, std::ostream &out) {
      string s, t;
      in >> s >> t;
      vector<string> ss;
      REP(i, s.length() - t.length() + 1) {
        string u = s.substr(i, t.length());
        bool f = true;
        REP(j, u.length()) {
          f &= (u[j] == t[j] || u[j] == '?');
        }
        if (f) {
          string v = s.substr(0, i) + t + s.substr(i + t.length(), s.length() - t.length() - i);
          REP(j, v.length()) {
            if (v[j] == '?') v[j] = 'a';
          }
          ss.push_back(v);
        }
      }
      if (!ss.empty()) {
        sort(ss.begin(), ss.end());
        out << ss[0] << endl;
      } else {
        out << "UNRESTORABLE" << endl;
      }

    }
};


signed main() {
  ios::sync_with_stdio(false);
  cout.tie(0);
  cout << fixed;
  CDubiousDocument2 solver;
  std::istream &in(std::cin);
  std::ostream &out(std::cout);
  solver.solve(in, out);
  return 0;
}


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

int main(){
	int n;
	cin >> n;
	int a[n];
	REP(i,n) cin >> a[i];
	int res = 0;
	REP(i,n) res += a[i] - 1;
	cout << res << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x) x
#define rep(...) MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<"\n"
using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<ll> vll;
template<class T>using vv = vector<vector<T>>; template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T>bool chmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
template<class T>bool chmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    ll n, m, d;
    cin >> n >> m >> d;

    if (d == 0) {
        write(1.0 * n * (m - 1) / (n * n));
    }
    else {
        write(1.0 * (2 * n - min(2 * d, n)) * (m - 1) / (n * n));
    }
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------


void solve() {
    int i,j,k,l,r,x,y; string s;
    bool exit = false;
    int N;
    cin>>N;
    cin>>s;
    int cnt_r=0;
    int cnt_b=0;
    FOR(i,N){
        if(s[i]=='R'){
            cnt_r+=1;
        }else{
            cnt_b+=1;
        }
    }
    if(cnt_r>cnt_b){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    /*cin>>N;
    vector<ll> V((N+1)*(N+1));
    FOR(x,N+1) {
            FOR(y,N+1) {
                    ll ret=1;
                    FOR(i,x) ret*=2;
                    FOR(i,y) ret*=5;
                    V.push_back(ret);
            }
    }
    sort(ALL(V));
    FORR(v,V) cout<<v<<endl;*/
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define array_input int n;cin>>n;int a[n+1],i;for(i=1;i<=n;i++){cin>>a[i];}
#define array_output for(i=1;i<=n;i++){cout<<a[i]<<" ";}cout<<endl;
#define quicker ios::sync_with_stdio(false);
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef long double ld;
const double pi=acos(-1);
const double eps=1e-6;
#define INF 2147483647
#define long_INF 18446744073709551615
#define hehe 23333333

void read(int &x)
{
    x=0;
	char c=getchar();
    while(c<'0' || c>'9')c=getchar();
    while(c>='0' && c<='9')
	{
        x=x*10+c-'0';
        c=getchar();
    }
}

void write(int x)
{
    if(x==0)
	{
		putchar(48);
		return;
	}
    int len=0,dg[20];
    while(x>0)
	{
		dg[++len]=x%10;
		x/=10;
	}
    for(int i=len;i>=1;i--)
	{
		putchar(dg[i]+48);
	}
}

int max(int x,int y)
{
	if (x>y)
	{
		return x;
	}
	else
	{
		return y;
	}
}

int min(int x,int y)
{
	if (x<y)
	{
		return x;
	}
	else
	{
		return y;
	}
}

int main()
{
	int n;
	cin>>n;
	int a[101]={0,1000,1,4,9,16,25,36,49,64,81,100,121,144,169,196,225,256,289,324,361,400,441,484,529,576,625,676,729,784,841,900,961,8,27,64,125,216,343,512,729,32,243,128,512};
	sort(a+1,a+101);
	for (int i=100;i>=1;i--)
	{
		if (a[i]<=n)
		{
			cout<<a[i]<<endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
    int N;
    char s[51];
    scanf("%d",&N);
    int a,count;
    a=0,count=0;
    for(int i =0;i<N;i++){
        scanf("%s",&s[i]);
        
        if(s[i]=='A'){
            a=1;
        }else if(s[i]=='B'){
            if(a==1){
                a = 2 ;
            }else{
                a=0;
            }
        }else if(s[i] == 'C'){
            if(a==2){
                count++;
                a=0;
            }else{
                a =0;
            }
        }
    }
    printf("%d",count);
    return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#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 int lli;
lli MOD = 1000000007;
int main()
{
    lli x;
    cin >> x;
    lli y = x % 11;
    lli ans = x / 11 * 2;
    if (y >= 7)
        ans += 2;
    else if(y>0)
        ans += 1;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
     
    #define fr(i,n) for(int i = 0; i < n ;i++)
    #define fr2(i,j,n) for(int i = j; i < n ;i++)
    using namespace std;
	
    int main(void)
    {

      int n,m;
      cin >> n >> m;
      int *a = new int[m];
      unsigned long long *list = new unsigned long long[n + 1];
      fr(i,m)
        cin >> a[i];
      unsigned long long num = 1;
      list[0] = 1;
      list[1] = 1;
      fr2(i,2,n + 1){
        list[i] = list[i - 1] + list[i - 2];
      	list[i] = list[i] %1000000007;
      }
      if(m == 0)
        num = list[n];
      else{
        num = list[a[0] - 1];
      	fr2(i,1,m){
          	if(a[i] - a[i - 1] == 1){
              num = 0;
              break;
            }
        	num *= list[a[i] - a[i - 1] -2];
          	num = num % 1000000007;
        }
        num *= list[n - a[m - 1] - 1];
        num = num % 1000000007;
      }
      cout << num;
       
      return 0;
    }

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;using ll=long long;using uint=unsigned int;using pii=pair<int,int>;using pll=pair<ll,ll>;using ull = unsigned long long;using ld=long double;template<typename T>void _(const char*s,T h){cerr<<s<<" = "<<h<<"\n";}template<typename T,typename...Ts>void _(const char*s,T h,Ts...t){int b=0;while(((b+=*s=='(')-=*s==')')!=0||*s!=',')cerr<<*s++;cerr<<" = "<<h<<",";_(s+1,t...);}// break continue pop_back 998244353
#define int ll
#define pii pll
#define f first
#define s second
#define pb emplace_back
#define forn(i,n) for(int i=0;i<(n);++i)
#define sqr(x) ((x)*(x))
struct init{init(){cin.tie(0);std::iostream::sync_with_stdio(0);cout<<std::fixed<<std::setprecision(10);cerr<<std::fixed<<std::setprecision(5);}~init(){
#ifdef LOCAL
#define dbg(...) _(#__VA_ARGS__,__VA_ARGS__)
cerr<<"Time elapsed: "<<(double)clock()/CLOCKS_PER_SEC<<"s.\n";
#else
#define dbg(...) 
#endif
}}init;template<typename T,typename U>void upx(T&x,U y){if(x<y)x=y;}template<typename T,typename U>void upn(T&x,U y){if(x>y)x=y;}

const int N=5e5+5;
int a[N];

int32_t main(){
    string s;
    cin>>s;
    int n=s.size()+1;
    s="<"+s+">";
    int mn=N;
    a[0]=a[n+1]=-1;
    for(int i=1;i<=n;++i){
        if(s[i-1]=='<')a[i]=a[i-1]+1;
        else a[i]=a[i-1]-1;
        upn(mn,a[i]);
    }
    for(int i=1;i<=n;++i){
        a[i]-=mn;
        dbg(i,a[i]);
    }
    dbg("==");
    int ans;
    forn(it,10){
        ans=0;
        for(int i=1;i<=n;++i){
            int x=-1;
            if(s[i-1]=='<')upx(x,a[i-1]);
            if(s[i]=='>')upx(x,a[i+1]);
            a[i]=x+1;
            ans+=a[i];
            dbg(a[i]);
        }
        ans=0;
        for(int i=n;i>=1;--i){
            int x=-1;
            if(s[i-1]=='<')upx(x,a[i-1]);
            if(s[i]=='>')upx(x,a[i+1]);
            a[i]=x+1;
            ans+=a[i];
            dbg(a[i]);
        }
    }
    cout<<ans<<'\n';



    return 0;
}


Measured memory_bytes: 4784
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


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

    int n;
    cin >> n;

    vector< vs32 > g(n);
    rep (i, n - 1)
    {
        int a, b;
        cin >> a >> b;
        --a, --b;
        if (a > b) swap(a, b);
        g[b].push_back(a);
    }

    s64 dp[n];
    dp[0] = 1;
    for (int i = 1; i < n; ++i)
    {
        dp[i] = dp[i - 1] + i + 1;
        for (auto j : g[i])
        {
            dp[i] -= j + 1;
        }
    }

    s64 ans = 0;
    rep (i, n)
    {
        ans += dp[i];
    }

    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 15476
import sys
readline = sys.stdin.readline

def solve():
    A, V = map(int, readline().split())
    B, W = map(int, readline().split())
    T = int(readline())

    d = abs(A - B)

    dv = V - W
    if T * dv >= d:
        print('YES')
    else:
        print('NO')

solve()

Measured memory_bytes: 61688
import math
K =  int(input())
ans = []
bc = [math.gcd(b, c) for b in range(1, K+1) for c in range(1, K+1)]
for a in range(1, K+1):
    for i in bc:
        x = math.gcd(a, i)
        ans.append(x)
print(sum(ans))

Measured memory_bytes: 71820
#include <iostream>
#include <algorithm>
#include <stack>
#include <string>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <list>
#include <string.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <map>
#define INFTY (1<<30)

using namespace std;

int main(){
	int n, f[45];
	cin >> n;
	f[0] = 1;
	f[1] = 1;
	for(int i = 2; i <= n; i++) {
		f[i] = f[i-1] + f[i-2];
	}
	cout << f[n] <<endl;
	return 0;
}

Measured memory_bytes: 1160
#coding:utf-8
import sys,os
from collections import defaultdict, deque
from fractions import gcd
from math import ceil, floor
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    XLMIIS = lambda x: [LMIIS() for _ in range(x)]
    YN = lambda c : print('Yes') if c else print('No')
    MOD = 10**9+7

    s = input()
    K = II()
    subs = set()
    for i in range(len(s)):
        for j in range(i+1,min(len(s)+1,i+6)):
            subs.add(s[i:j])
    subs = sorted(list(subs))
    print(subs[K-1])
    

if __name__ == '__main__':
    main()

Measured memory_bytes: 65900
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a; cin>>a;
    int a1 = a/100;
    int a2 = (a/10) %10;
    int a3 = a-(a/10)*10;
    //cout<<a1<<" "<<a2<<" "<<a3;
    if(a1 == 7 || a2 == 7 || a3 == 7){
        cout<< "Yes";
    }
    else cout<<"No";
    return 0;
}


Measured memory_bytes: 3672
import fractions
a, b, c, d = map(int, input().split())

#a~bでnで割り切れるものの数
def func(a, b, n):
    answer = (int(b/n) - int((a-1)/n))
    return answer

lcm = int((c * d) / fractions.gcd(c, d))

#print ((b - a + 1) - func(a,b,c) - func(a,b,d) + func(a,b,lcm))

#b以下でc,dで割り切れない数
b_anti_devide = b - b//c - b//d + b//lcm
#a未満でc,dで割り切れない数
a_anti_devide = (a - 1) - (a - 1)//c - (a - 1)//d + (a - 1)//lcm

print (b_anti_devide - a_anti_devide)

Measured memory_bytes: 5048
n,m=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
B=[]
for i in range(m-1):
  B.append(abs(A[i+1]-A[i]))
B.sort()
if n==1:
  print(sum(B))

else:
  print(sum(B[:-n+1:]))


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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A[] = new int[N];
		for (int i=0;i<N;i++) {
			A[i]= sc.nextInt();
		}
		Arrays.parallelSort(A);
		double now =(A[0]+A[1])/2.0;
		for (int i=2;i<N;i++) {
			now = (A[i]+now)/2.0;
		}
		System.out.println(now);
	}
}

Measured memory_bytes: 35704
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
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; }

int N,M;
vector<vector<int>> G(8);
vector<bool> seen(8, false);
int dfs(int i, int cnt, vector<bool> &seen){
    if(cnt==N-1) return 1;
    seen[i] = true;

    int ans = 0;
    for(auto x: G[i]){
        if (seen[x]==true) continue;
        //cout << i<<": "<<x << endl;
        ans += dfs(x, cnt+1, seen);
    }
    seen[i]=false;
    return ans;

}

int main()
{
    cin >> N>>M;

    REP(i, M){
        int a,b;
        cin>>a>>b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    
    cout << dfs(0,0,seen) << endl;

    

    

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
using namespace std;
typedef long long ll;
int main() {
    int K, S;
    cin >> K >> S;
    int ans = 0;
    for (int i = 0; i <= K; ++i)
    {
        for (int j = 0; j <= K; ++j)
        {
            int k = S - i - j;
            if (0 <= k && k <= K)
            {
                ans ++;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <map>
#include <cstring>
using namespace std;

char ary[200];
int main(){
	map<char,int> ma;
	ma.insert(make_pair('I',1));
	ma.insert(make_pair('V',5));
	ma.insert(make_pair('X',10));
	ma.insert(make_pair('L',50));
	ma.insert(make_pair('C',100));
	ma.insert(make_pair('D',500));
	ma.insert(make_pair('M',1000));
	while(true){
		cin>>ary;
		if(cin.eof()) break;
		int res=0;
		int n=strlen(ary);
		for(int i=0;i<n-1;i++){
			if(ma[ary[i]]<ma[ary[i+1]]){
				res-=ma[ary[i]];
			}
			else{
				res+=ma[ary[i]];
			}
		}
		res+=ma[ary[n-1]];
		cout<<res<<endl;
	}
	return 0;
}

Measured memory_bytes: 3136
#include <iostream>
#include <map>
#include <vector>
#include <array>

using namespace std;


int clear(vector<array<int, 5>>& m)
{
    int sum = 0;
    auto e = m.end();
    for(auto& arr: m){
        int cnt = 1, v = arr[0], ip = 0;
        int maxcnt = 0, maxv = 0, maxi = 0;
        for(int i = 1; i < 5; ++i){
            // cout << cnt << "," << v << endl;
            if(arr[i] == v)
                ++cnt;
            else{
                if(maxcnt < cnt){
                    maxcnt = cnt;
                    maxv = v;
                    maxi = ip;
                }
                v = arr[i];
                cnt = 1;
                ip = i;
            }
        }

        if(maxcnt < cnt){
            maxcnt = cnt;
            maxv = v;
            maxi = ip;
        }

        // cout << "max: " << maxcnt << "," << maxv << "," << maxi << endl;

        if(maxcnt >= 3){
            for(int i = 0; i < maxcnt; ++i)
                arr[maxi + i] = 0;
            sum += maxv * maxcnt;
        }
    }
    // cout << "sum: " << sum << endl;
    return sum;
}

void drop(vector<array<int, 5>>& m)
{
    if(m.size() < 2)
            return;
    for(int i = 0; i < 5; ++i){
        int idx = m.size() - 2;
        auto e = m.rend();
        int idx2 = m.size() - 1;
        for(auto s = m.rbegin(); s != e; ++s){
            if(idx > idx2)
                idx = idx2;
            auto& arr = *s;
            if(arr[i] == 0){
                while(m[idx][i] == 0 && idx != 0) { --idx; }

                arr[i] = m[idx][i];
                m[idx][i] = 0;

                if(idx == 0)
                    break;
            }

            --idx2;
        }
    }
}


int iter(vector<array<int, 5>>& m)
{
    int s = clear(m);
    drop(m);

    // for(auto&e : m){
    //     for(auto& ee: e){
    //         cout << ee << ",";
    //     }
    //     cout << endl;
    // }

    return s;
}




int main(void)
{
    int n;
    while(cin >> n){
        if(n == 0)
            break;

        vector<array<int, 5>> vec;
        for(int i = 0; i < n; ++ i){
            array<int, 5> arr;
            cin >> arr[0] >> arr[1] >> arr[2] >> arr[3] >> arr[4];
            vec.push_back(arr);
        }

        int l = 0;
        int s = 0;
        do{
            l = s;
            s += iter(vec);
        }while(l != s);

        cout << s << endl;
    }
}

Measured memory_bytes: 1216
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [list(input()) for _ in range(n)]
#a = [int(input()) for _ in range(n)]

d,n = map(int, input().split())

print(100**d * (n+n//100))


Measured memory_bytes: 9152
#include<bits/stdc++.h>
using namespace std;
#define debug(x) cout<<"### "<<x<<endl;
#define For(a,b,c) for(int a=b;a<=c;++a)
#define Dor(a,b,c) for(int a=b;a>=c;--a)
inline int read(){
    int x=0;char c=getchar();
    while(c<'0'||c>'9')c=getchar();
    while(c>='0'&&c<='9')x=(x<<3)+(x<<1)+(c^48),c=getchar();
    return x;
}

int main(){
	int n,d;
	scanf("%d%d",&n,&d);
	int p=2*d+1;
	printf("%d",(n-1)/p+1);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long 
#define endl '\n'
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

using namespace std;	

signed main(){IOS;
	int n ; cin>>n;
	vector<double>prob(n+1);
	prob[0]=1;
	for(int i=0;i<n;i++){
		double heads; cin>>heads;
		for(int coins=i+1;coins>=0;coins--){
			prob[coins]=(coins==0?0:prob[coins-1]*heads) + prob[coins]*(1-heads);
		}
	}
	double ans=0;
	for(int i=n/2+1;i<=n;i++){
		ans += prob[i];
	}
	cout<<fixed<<setprecision(10)<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)

#define int long long
//using ll = long long;
using P = pair<int,int>;

ostream &operator<<(ostream &os,const P &p){ return os << "(" << p.first << "," << p.second << ")"; }

template<class T> T &chmin(T &a,const T &b){ return a = min(a,b); }
template<class T> T &chmax(T &a,const T &b){ return a = max(a,b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

template<long long mod = 1000000007>
struct modint{
	long long a;

	modint() : a(0){}
	modint(long long t){
		a = t % mod;
		if(a < 0) a += mod;
	}

	operator long long() const{ return a; }

	bool operator==(const modint &x) const{ return a == x.a; }
	bool operator!=(const modint &x) const{ return a != x.a; }

	modint operator-() const{ return modint(a ? (mod - a) : 0); }
	modint operator~() const{ return pow(mod - 2); }

	modint operator+(const modint &x) const{ return modint(*this) += x; }
	modint operator-(const modint &x) const{ return modint(*this) -= x; }
	modint operator*(const modint &x) const{ return modint(*this) *= x; }
	modint operator/(const modint &x) const{ return modint(*this) /= x; }

	modint &operator+=(const modint &x){
		a += x.a;
		if(a >= mod) a -= mod;
		return *this;
	}
	modint &operator-=(const modint &x){
		a -= x.a;
		if(a < 0) a += mod;
		return *this;
	}
	modint &operator*=(const modint &x){
		a = a * x.a % mod;
		return *this;
	}
	modint &operator/=(const modint &x){
		a = a * (~x).a % mod; 
		return *this;
	}

	friend ostream &operator<<(ostream &os,const modint &x){
		return os << x.a;
	}
	friend istream &operator>>(istream &is,modint &x){
		long long t;
		is >> t;
		x = modint(t);
		return is;
	}

	modint pow(long long x) const{
		modint ret = 1,tmp = a;
		for(;x;tmp *= tmp,x >>= 1){
			if(x & 1) ret *= tmp;
		}
		return ret;
	}
};

template<class T>
struct Combination{
	vector<T> fact,factinv;
	Combination(int n) : fact(n + 1),factinv(n + 1){
		fact[0] = 1;
		for(int i = 1;i <= n;i++) fact[i] = fact[i - 1] * T(i);
		factinv[n] = ~fact[n];
		for(int i = n;i >= 1;i--) factinv[i - 1] = factinv[i] * T(i);
	}
	T nCr(int n,int r){
		if(r < 0 || n < r) return 0;
		return fact[n] * factinv[r] * factinv[n - r];
	}
};

signed main(){
	int n,k;
	modint<> ans = 0;
	cin >> n >> k;
	if(k == 1){
		cout << n * (n - 1) << endl;
		return 0;
	}
	Combination<modint<>> comb(n * 2 + 5);
	for(int i = 0;i <= min(n - 1,k);i++){
		ans += comb.nCr(n - 1,i) * comb.nCr(n,i);
	}
	cout << ans << endl;
}

Measured memory_bytes: 6528
#include <iostream>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <vector>
#include <cmath>
#include <cstdint>

using namespace std;

int main() {
  while (true) {
    int h, w;
    cin >> h >> w;
    if (!h && !w) break;
    for (int y = 0; y < h; ++y) {
      for (int x = 0; x < w; ++x) {
        if (y == 0 || y == h -1 || x == 0 || x == w - 1) {
          cout << '#';
        } else {
          cout << '.';
        }
      }
      cout << endl;
    }
    cout << endl;
  }
}

Measured memory_bytes: 3064
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        long N = scan.nextLong();
        long A = scan.nextLong();
        long B = scan.nextLong();
        long times = N / (A+B);
        long remain = N % (A+B);
        long remA = remain <= A ? remain : A;
        os.println(times*A +remA);
    }


}

Measured memory_bytes: 23124
#include <stdio.h>

int main(int argc, const char * argv[]) {
    // insert code here...
    int countTable[256] = {0};
    char ch;
    
    while((ch = getchar()) != EOF){
                countTable[ch]++;
    }
    for(int i = 97; i <=122;i++)printf("%c : %d\n",i,countTable[i]+countTable[i-32]);
    
    return 0;
}



Measured memory_bytes: 2692
#include<bits/stdc++.h>
using namespace std;
int main(){
  char a[100];
    cin>>a;
  for(int i=0;i<100;i++){
    if((i+1)%2==1 && a[i]=='L'){
      cout<<"No"<<endl;
      return(0);
    }
    if((i+1)%2==0 && a[i]=='R'){
      cout<<"No"<<endl;
      return(0);
    }
  }
    cout<<"Yes"<<endl;
  
  return(0);
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <list>
#include <cmath>
#include <stack>
#include <iomanip>

using namespace std;
typedef long long ll;
using Pll = pair<ll,ll>;

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

//cout << fixed << setprecision(10);

int main() {
    ll N,M;
    cin >> N >> M;
    vector<ll> X(N),Y(M);
    for(int i=0;i<N;i++) cin >> X[i];
    for(int i=0;i<M;i++) cin >> Y[i];
    ll sumx = 0, sumy = 0;
    for(int i=0;i<N;i++){
        ll tmp = X[i]*(2*(i+1)-N-1);
        if(tmp<0) tmp=(tmp+(llabs(tmp)/MOD+1)*MOD)%MOD;
        else tmp%=MOD;
        sumx=(sumx+tmp)%MOD;
    }
    for(int i=0;i<M;i++){
        ll tmp = Y[i]*(2*(i+1)-M-1);
        if(tmp<0) tmp=(tmp+(llabs(tmp)/MOD+1)*MOD)%MOD;
        else tmp%=MOD;
        sumy=(sumy+tmp)%MOD;
    }
    cout << (sumx*sumy)%MOD << endl;
    

    return 0;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <cstring>
#include <deque>

using namespace std;

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

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

void push(int light[10][10], int y, int x)
{
	const int dy[] = {-1, 0, 0, 0, 1};
	const int dx[] = {0, -1, 0, 1, 0};

	rep(i, 5){
		int py = y + dy[i];
		int px = x + dx[i];
		if(py<0 || 10<=py || px<0 || 10<=px)
			continue;
		light[py][px] = !light[py][px];
	}
}

void simulate(int tmp[10][10], int j, bool output)
{
	rep(k, 10){
		if((j>>k)&1){
			push(tmp, 0, k);
			if(output)
				printf("%s1", k?" ":"");
		}else if(output)
			printf("%s0", k?" ":"");
	}
	if(output)
		puts("");

	rep(k, 9){
		rep(l, 10){
			if(tmp[k][l]){
				push(tmp, k+1, l);
				if(output)
					printf("%s1", l?" ":"");
			}else if(output)
				printf("%s0", l?" ":"");
		}
		if(output)
			puts("");
	}
}

int main()
{
	int n;
	scanf("%d", &n);
	rep(i, n){
		int light[10][10];
		rep(j, 10) rep(k, 10)
			scanf("%d", &light[j][k]);

		rep(j, 1<<10){
			int tmp[10][10];
			rep(k, 10) rep(l, 10)
				tmp[k][l] = light[k][l];

			simulate(tmp, j, false);
			bool ok = true;
			rep(k, 10) rep(l, 10){
				if(tmp[k][l]){
					ok = false;
					k=10;
					break;
				}
			}

			if(ok){
				simulate(light, j, true);
				break;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const ll INF=mod*mod;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
ll min(ll a,ll b){
  if(a>b){
    return b;
    }
      else{
        return a;
      }
  }
  
  ll max(ll a,ll b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }

ll power(ll a,ll b){
 ll ans=1;
 for(ll i=1;i<=b;i++){
ans*=a;
  }
  return ans;
}

 ll gcd(ll m,ll n){
 	if(n==0){
       return m;
     }
   return gcd(n,m%n);
 }
ll lcm(ll a,ll b){
  ll g=gcd(a,b);
  return a/gcd(a,b)*b;
		

}
int main(){
  
  ll N,K;
  cin>>N>>K;
  
  vector<ll>A(N);
  
  rep(i,N){
cin>>A[i];
  }

  if(N-K==0){
cout<<1<<endl;
  }
  else if((N-K)%(K-1)==0){
    cout<<1+(N-K)/(K-1)<<endl;
  }
  else{
cout<<2+(N-K)/(K-1)<<endl;
  }
}


Measured memory_bytes: 1024
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(n: int, p: "List[int]"):
    ans = 0
    for i in range(1, n-1):
        if sorted([p[i-1], p[i], p[i+1]])[1] == p[i]:
            ans += 1

    print(ans)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    n = int(next(tokens))  # type: int
    p = [int(next(tokens)) for _ in range(n)]  # type: "List[int]"
    solve(n, p)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1000000007;
const double PI = 3.141592653589793238463;
const int N=1e5+10;
int main()
{
    FASTINOUT;
    int x,a;
    cin>>x>>a;
    cout<<x/a+(x%a!=0)<<endl;
    return 0;
}


Measured memory_bytes: 256
n,a,b,c=map(int,input().split())
arr=[input() for _ in range(n)]
ans=[]
for i in range(n):
  if arr[i]=='AB':
    if a==1 and b==1:
      if i==n-1 or arr[i+1]=='AB' or arr[i+1]=='AC':
        a+=1
        b-=1
        ans.append('A')
      elif arr[i+1]=='BC':
        a-=1
        b+=1
        ans.append('B')
    elif a==0 and b==0:
      print('No')
      break
    else:
      if a>=b:
        a-=1
        b+=1
        ans.append('B')
      else:
        a+=1
        b-=1
        ans.append('A')
  elif arr[i]=='AC':
    if a==1 and c==1:
      if i==n-1 or arr[i+1]=='AC' or arr[i+1]=='AB':
        a+=1
        c-=1
        ans.append('A')
      elif arr[i+1]=='BC':
        a-=1
        c+=1
        ans.append('C')
    elif a==0 and c==0:
      print('No')
      break
    else:
      if a>=c:
        a-=1
        c+=1
        ans.append('C')
      else:
        a+=1
        c-=1
        ans.append('A')
  elif arr[i]=='BC':
    if b==1 and c==1:
      if i==n-1 or arr[i+1]=='BC' or arr[i+1]=='AB':
        b+=1
        c-=1
        ans.append('B')
      elif arr[i+1]=='AC':
        b-=1
        c+=1
        ans.append('C')
    elif b==0 and c==0:
      print('No')
      break
    else:
      if b>=c:
        b-=1
        c+=1
        ans.append('C')
      else:
        b+=1
        c-=1
        ans.append('B')
else:
  print('Yes')
  for i in range(n):
    print(ans[i])

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

int main(){
  int n,m,i,temp;
  cin>>n;
  int x[n];
  for (i=0;i<n;i++)cin>>x[i];
  cin>>m;
  for (i=0;i<m;i++){
    cin>>temp;
    if (temp!=n){
      if (x[temp]-x[temp-1]>1)x[temp-1]++;
    }else{
      if(x[n-1]!=2019)x[n-1]++;
    }
  }
  for (i=0;i<n;i++)cout<<x[i]<<endl;
  return 0;
}



Measured memory_bytes: 3096
package main

import "fmt"

const LIMIT = 1000000000000000000

func main() {
	var N int
	fmt.Scan(&N)

	as := make([]int64, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&as[i])
		if as[i] == 0 {
			fmt.Println(0)
			return
		}
	}

	var ret int64 = 1
	for i := 0; i < N; i++ {
		if as[i] > LIMIT/ret {
			fmt.Println(-1)
			return
		}

		ret *= as[i]
		if ret > LIMIT {
			fmt.Println(-1)
			return
		}
	}
	fmt.Println(ret)
}


Measured memory_bytes: 6308
//ヘッダー
#include<bits/stdc++.h>
using namespace std;

//型定義
typedef long long ll;

//定数
const ll INF=1e+18;

const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

//グローバル変数


//ライブラリ挿入
//ダイクストラ O(ElogV)


int main(){
    int N,M,R;
    cin>>N>>M>>R;
    vector<int> r(R);
    vector<vector<ll>> d(N,vector<ll>(N,INF));
    int tmp;
    REP(i,R){
        cin >> tmp;
        tmp--;
        r[i]=tmp;
    }

    // データ構造
    
    vector<vector<ll>> cost(N,vector<ll>(N,-1)); //コスト
    vector<vector<int>> G(N);

    int a,b,c;
    REP(i,M){
        cin>>a>>b>>c;
        a--;
        b--;
        cost[a][b]=c;
        cost[b][a]=c;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    REP(i,R){
        vector<ll> dist(N, INF); // 全頂点を「未訪問」に初期化
        priority_queue<int> que;
        dist[r[i]] = 0;
        que.push(r[i]);
        
        // 開始 (キューが空になるまで探索を行う)
        while (!que.empty()) {
            int v = que.top(); // 優先度キューから先頭頂点を取り出す
            que.pop();

            // v から辿れる頂点をすべて調べる
            for (int nv : G[v]) {
                if (cost[v][nv] == -1) continue; // 行けない行き先ならパス
                // 新たな頂点 nv について距離が短いなら更新
                if(dist[v]+cost[v][nv]<dist[nv]){
                    dist[nv] = dist[v] + cost[v][nv];
                    que.push(nv);
                }
            }
        }
        REP(j,R){
            if(i==j) continue;
            d[r[i]][r[j]]=dist[r[j]];
            d[r[j]][r[i]]=dist[r[j]];
        }
    }

    ll ans=INF;
    ll sum;
    sort(r.begin(),r.end());
    do{
        sum=0;
        REP(i,R-1){
            sum+=d[r[i]][r[i+1]];
        }
        ans=min(ans,sum);
    }while(next_permutation(r.begin(),r.end()));
    cout << ans << endl;
    
    
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int,int>;
#define rep(i, j) for(int i=0; i < (int)(j); i++)

using EdgeList = vector<vector<int>>;

// ?????£?????????????????°?????? E ???????????????
// O(N + M) N: ????????°, M: ?????°
vector<pii> calc_bridge(const EdgeList &E) {
    int N = E.size();
    vector<int> ord(N, -1), low(N);
    int cnt = 0;
    vector<pii> bridges;
    function<void(int, int)> dfs = [&] (int now, int pre) {
        ord[now] = cnt++;
        low[now] = ord[now];
        for(int nxt : E[now]) {
            if(ord[nxt] < 0) {
                // not visited
                dfs(nxt, now);
                low[now] = min(low[now], low[nxt]);
                if(ord[now] < low[nxt]) {
                    bridges.emplace_back(min(now, nxt), max(now, nxt));
                }
            } else if(nxt != pre) {
                // visited
                low[now] = min(low[now], ord[nxt]);
            } 
        }
    };
    // ??£?????°????????????dfs(0)????????§OK?????????
    rep(i, N) if(ord[i] < 0) dfs(i, -1);
    return bridges;
}

#define all(v) v.begin(),v.end()

class Solver {
  public:
    bool solve() {
        int N, M; cin >> N >> M;
        EdgeList E(N);
        rep(i, M) {
            int a, b; cin >> a >> b;
            E[a].push_back(b);
            E[b].push_back(a);
        }
        auto ans = calc_bridge(E);
        sort(all(ans));
        for(pii p : ans) cout << p.first << " " << p.second << endl;
        
        return 0;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Solver s;
    s.solve();
    return 0;
}

Measured memory_bytes: 4620
N, K = map(int, input().split())
A = list(map(int, input().split()))
F = list(map(int, input().split()))

A = sorted(A)
F = sorted(F, reverse=True)

l = -1
r = 10**12+5

while (l+1<r):
  c = (l+r)//2
  tmp = 0
  for i in range(N):
    tmp += max(0, A[i]-(c//F[i]))
  
  if tmp <= K:
    r = c
  else:
    l = c

print(r)

Measured memory_bytes: 113648
#include<iostream>
#include<stdio.h>
#include<cstring>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<unordered_map>
#include<bits/stdc++.h>
#define ll long long 
#define dd double
using namespace std;

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
   
  int n;
  cin>>n;
  float o;
  if(n%2==0){
  	o=n/2;
  }
  
  else{
  	o=n/2+1;
  }
 
  float p=o/n;
  cout<<fixed<<setprecision(6)<<p<<endl;
  
  return 0;
}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
using ull = unsigned long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

template<class T>
bool ChangeMax(T&a,const T&b){
  if(a >= b) return false;
  a = b;    return true;
}

template<class T>
bool ChangeMin(T&a,const T&b){
  if(a <= b) return false;
  a = b;    return true;  
}

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int gcd(int x, int y){
  if(y==0)return x;
  return gcd(y,x%y);
}


int main(){
  int h,w; cin >> h >> w;
  cout << string(w+2,'#') << endl;
  for(int i = 0; i < h; ++i){
    string s; cin >> s;
    cout << '#' << s << '#' << endl;
  }
  cout << string(w+2,'#') << endl;
}



Measured memory_bytes: 3616
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <functional>
#include <queue>
#include <map>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
const int INF = 100000000;

int main(){
    ll a, b, c;
    cin >> a >> b >> c;

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

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

int main(){
  string s, t;
  cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.begin(), t.end(), greater<char>());
  if(s<t){
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256