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

class UnionFind {
public:
vector<int> Parent;

UnionFind(int N) {
  Parent = vector<int>(N, -1);
}

int root(int A) {
  if (Parent[A] < 0) return A;
    return Parent[A] = root(Parent[A]);
  }

int size(int A) {
  return -Parent[root(A)];
}

bool connect(int A, int B) {
  A = root(A);
  B = root(B);
  if (A == B) {
    return false;
  }
  if (size(A) < size(B)) swap(A, B);
    Parent[A] += Parent[B];
    Parent[B] = A;
    return true;
  }
};

int main(){
  int N, M; 
  cin >> N >> M;
  vector<int> X(M), Y(M), Z(M);
  for (int i = 0; i < M; ++i){
    cin >> X[i] >> Y[i] >> Z[i];
    --X[i], --Y[i];
  }
  UnionFind uf(N);
  for (int i = 0; i < M; ++i) uf.connect(X[i], Y[i]);
  set<int> se;
  for (int i = 0; i < N; ++i) se.insert(uf.root(i));
  cout << se.size() << endl;
}

Measured memory_bytes: 6400
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = Integer.parseInt(scanner.next());
        Integer minValue = Integer.parseInt(scanner.next());
        Integer maxDiff = -1000000001;
        for (int i = 1; i < n; i++) {
            int value = Integer.parseInt(scanner.next());
            maxDiff = Math.max(maxDiff, value - minValue);
            minValue = Math.min(minValue, value);
        }
        System.out.println(maxDiff);
    }
}

Measured memory_bytes: 71284
a[9],b[9],i,x,y;main(j){while(scanf("%d",&a[0])>0){for(i=1;i<4;)scanf("%d",&a[i++]);for(i=0;i<4;)scanf("%d",&b[i++]);x=y=0;for(i=0;i<4;i++)for(j=0;j<4;j++)if(a[i]==b[j])i==j?x++:y++;printf("%d %d\n",x,y);}exit(0);}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <cstdio>

using namespace std;

int main() {
    long long int n, k;
    cin >> n >> k;

    vector<long long int> bb;
    long long int bb2 = 1;

    while (bb2 < k) {
        bb2 *= 2;
        bb.push_back(bb2);
    }
    long long int base = 1;
    for (long long int i = 0; i < bb.size(); i++) {
        if (bb[i] >= k) {
            base *= bb[i];
            break;
        }
    }
    long long int aa = 1;
    for (long long int i = 2; i <= n; i++) {
        if (i >= k) {
            aa += base;
        } else {
            for (long long int j = 0; j < bb.size(); j++) {
                if (i*bb[j] >= k) {
                    aa += base/bb[j];
                    break;
                }
            }
        }
    }
    base *= n;

    double ans = (double)aa / (double)base;
    //cout << aa << ' '  << base << endl;
    printf("%.15f\n", ans);

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl "\n"
using namespace std;
#define ll unsigned long long
#define ld long double
#define ui unsigned int
#define ull unsigned ll
#define foi(n) for(ll i=0;i<n;i++)
#define foj(n) for(ll j=0;j<n;j++)
#define fok(n) for(ll k=0;k<n;k++)
#define fom(n) for(ll m=0;m<n;m++)
#pragma GCC optimize("O3", "unroll-loops")
#define fixed(); cout << fixed << setprecision(20);
#define fast(); ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

/*****************************************************************************/


#define graph          vector<vector<int>>
#define V              vector
typedef pair<int, int> pii;
typedef pair<ll, ll>   pll;
typedef V<int>         vi;
typedef V<ll>          vll;
typedef V<string>      vs;
typedef V<double>      vd;
typedef V<pii>         vpii;             
typedef V<pll>         vpll;             
typedef pair<int,pii>  piii;             
typedef priority_queue<pii, vector<pii>, greater<pii> > pqq;   

/*****************************************************************************/

#define mp                   make_pair
#define eb                   emplace_back
#define pb                   push_back
#define pf                   push_front
#define popb                 pop_back
#define popf                 pop_front
#define hashmap              unordered_map
#define hashset              unordered_set
#define lb                   lower_bound
#define ub                   upper_bound
#define all(a)               (a).begin(), (a).end()
#define rall(a)              (a).rbegin(), (a).rend()
#define ff                   first
#define ss                   second
#define lbpos(v,x)           (int)(lower_bound(all(v),x)-v.begin())//=v.size()==>No LB 
#define ubpos(v,x)           (int)(upper_bound(all(v),x)-v.begin())//=v.size()==>No UB

//*****************UVAISH ZAFRI(Rush_For_AC)**********************
#define mod 1000000007

int32_t main() {
    fast();fixed();
    #ifndef ONLINE_JUDGE
    freopen("tad.txt","r",stdin);
    freopen("tada.txt","w",stdout);
    #endif
    
   float a,b,c;
   cin>>a>>b>>c;
   cout<<(long long)(ceil(a/b)*c)<<endl;
    return 0;
    
  
    
}



Measured memory_bytes: 3712
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		 Scanner sc = new Scanner(System.in);
		 int X = sc.nextInt();
		 int Y = sc.nextInt();
		 String ans = "No";
		 for (int i = 0; i <= X; i++) {
			if (Y == -2*i + 4*X) { 
				ans="Yes";
			} 
		 }
		 System.out.print(ans);
	}
}

Measured memory_bytes: 35648
#define SUBMIT

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_4_C
// Search - Dictionary

#include <iostream>
#include <vector>
#include <set>
#include <limits>

using namespace std;

int main() {
    int n;
    set<string> dict;
    vector<string> outputs;

    string s;
    cin >> n;
    cin.ignore(numeric_limits<streamsize>::max(), '\n');
    for (int i = 0; i < n; ++i) {
        getline(cin, s);
        if (s[0] == 'i') { // insert
            auto str = s.substr(7);
            dict.emplace(str);
        }
        else { // find
            auto str = s.substr(5);
            if (dict.find(str) != dict.end()) {
                outputs.emplace_back("yes");
            } else {
                outputs.emplace_back("no");
            }
        }
    }

    for (const auto& o: outputs) {
        cout << o << endl;
    }
    return 0;
}


Measured memory_bytes: 52360
class dice():
    def __init__(self):
        self.number = [i for i in range(6)]
        self.work = [i for i in range(6)]
    
    def setnum(self,s):
        self.number = s

    def kai(self,h):
        tmp = self.number
        if h == 'E':
            self.number = [tmp[3],tmp[1],tmp[0],tmp[5],tmp[4],tmp[2]]
        elif h == 'S':
            self.number = [tmp[4],tmp[0],tmp[2],tmp[3],tmp[5],tmp[1]]
        elif h == 'W':
            self.number = [tmp[2],tmp[1],tmp[5],tmp[0],tmp[4],tmp[3]]
        elif h == 'N':
            self.number = [tmp[1],tmp[5],tmp[2],tmp[3],tmp[0],tmp[4]]

    def Qright(self,up,flont,num):
        uf = (up,flont)
        if uf == (num[1],num[2]) or uf ==(num[2],num[4]) or uf ==(num[4],num[3]) or uf ==(num[3],num[1]):
            ans = num[0]
        elif uf == (num[0],num[3]) or uf ==(num[3],num[5]) or uf ==(num[5],num[2]) or uf ==(num[2],num[0]):
            ans = num[1]
        elif uf == (num[0],num[1]) or uf ==(num[1],num[5]) or uf ==(num[5],num[4]) or uf ==(num[4],num[0]):
            ans = num[2]
        elif uf == (num[0],num[4]) or uf ==(num[4],num[5]) or uf ==(num[5],num[1]) or uf ==(num[1],num[0]):
            ans = num[3]
        elif uf == (num[0],num[2]) or uf ==(num[2],num[5]) or uf ==(num[5],num[3]) or uf ==(num[3],num[0]):
            ans = num[4]
        elif uf == (num[1],num[3]) or uf ==(num[3],num[4]) or uf ==(num[4],num[2]) or uf ==(num[2],num[1]):
            ans = num[5]
        print(ans)




num = list(map(int,input().split()))
#kaitenn = input()
testall = 'NNNNENNNNENNNNENNNNENWNNNNEENNNN'
#q = int(input())
num2 = list(map(int,input().split()))
dice = dice()
dice.setnum(num)
for i in range(len(testall)):
#    up,flont = map(int,input().split())
#    dice.Qright(up,flont,num)
    dice.kai(testall[i])
    if dice.number == num2:
        print("Yes")
        break
    if i == len(testall)-1:
        print("No")
#print(dice.number[0])


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

auto N = std::size_t();
auto W = std::size_t();
int main()
{
    std::cin >> N >> W;

    auto weight = std::vector<std::size_t>(N);
    auto value = std::vector<std::int64_t>(N);

    for (std::size_t i = 0; i < N; ++i) std::cin >> weight[i] >> value[i];

    auto dp = std::vector<std::vector<std::int64_t>>(N + 1, std::vector<std::int64_t>(W + 1, 0));

    for (std::size_t i = 0; i < N; ++i)
    {
        for (std::size_t w = 0; w <= W; ++w)
        {
            if (w >= weight[i])
                dp[i + 1][w] = std::max(dp[i][w - weight[i]] + value[i], dp[i][w]);
            else
                dp[i + 1][w] = dp[i][w];
        }
    }

    std::cout << dp[N][W] << std::endl;

    return 0;
}

Measured memory_bytes: 80256
#include<iostream>
#include<cstdio>
using namespace std;
int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
int w,h,bum,wum,sum,B,W;
char s[60][60];
void func1(int y,int x){
	int p=y,q=x;
	if(s[y][x]=='B'){
		B++;
	}
	else if(s[y][x]=='W'){
		W++;
	}
	else if(s[y][x]!='*'){
		s[y][x]='*';
		sum++;
		for(int l=0;l<4;l++){
			y=p+dy[l];
			x=q+dx[l];
			if(y>=0&&y<h&&x>=0&&x<w){
				func1(y,x);
			}
		}
	}
}
void func2(int y,int x,char c){
	int p,q;
	if(s[y][x]=='*'){
		s[y][x]=c;
		for(int o=0;o<4;o++){
			p=y+dy[o];
			q=x+dx[o];
			if(p>=0&&p<h&&q>=0&&q<w)
				func2(p,q,c);
		}
	}
}
int main(){
	while(cin>>w>>h,w||h){
		wum=0;
		bum=0;
		for(int i=0;i<h;i++)
		scanf("%s",s[i]);
		for(int i=0;i<h;i++)
		for(int j=0;j<w;j++){
			if(s[i][j]=='.'){
				B=0;
				W=0;
				sum=0;
				func1(i,j);
				if(B>0&&W==0){
					bum+=sum;
					func2(i,j,'s');
				}
				else if(B==0&&W>0){
					wum+=sum;
					func2(i,j,'t');
				}
				else{
					func2(i,j,'D');
				}
			}
		}
		
		cout<<bum<<' '<<wum<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int answer = 0;
		while(true) {
			int a = sc.nextInt();
			String op = sc.next();
			int b = sc.nextInt();

			if(op.equals("?")) {
				break;
			}
			if(op.equals("+")) {
				answer = a + b;
			} else if(op.equals("-")) {
				answer = a - b;
			} else if(op.equals("*")) {
				answer = a * b;
			} else if(op.equals("/")) {
				answer = a / b;
			}
			System.out.println(answer);
		}
	}
}


Measured memory_bytes: 26360
#include<stdio.h>
#include<iostream>

using namespace std;

int N;
int main() {
    cin >> N;
    int cnt = 0;
    for(int i=1;i<=N;i++){
        int x;
        cin >> x;
        if( x != i ) cnt++;
    }
    cout << (cnt <= 2 ? "YES": "NO") << endl; 
    return 0;
}


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

bool card[10];
void init(){
	for(int i=0;i<10;i++){
		card[i]=true;
	}
}
int main()
{
	int a,b,c;
	while(cin >> a >> b >> c){
		init();
		card[a-1] = false;
		card[b-1] = false;
		card[c-1] = false;
		int count = 0;
		for(int i=0;i<10;i++){
			if(card[i]==true){
				if(a+b+i+1 <= 20){
					count++;
				}
			}
		}
		if(count>=4)
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 0
def smaller(x, y):
	if x < y: return x
	return y

W, a, b = map(int, input().split())
if (a<=b and b<=a+W) or (a<=b+W and b+W<=a+W):
	print(0)
else:
	print(smaller(abs(b-a-W), abs(a-b-W)))

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

#define ll long long
// #define endl '\n'

// void max_self(int &a, int b){a = max(a, b);}
// void min_self(int &a, int b){a = min(a, b);}

void solve(){
	int a, b, c; cin>>a>>b>>c;
	if(a + b + c >= 22){
		cout<<"bust"<<endl;
	}else{
		cout<<"win"<<endl;
	}
}

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int t = 1; //cin>>t;
	for(int i = 1; i<=t; i++){
		solve();
	}
	return 0;
}


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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;


int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

int main(int argc, const char * argv[]) {
    
    // source code
  int n;
  cin >> n;
  int k;
  cin >> k;
  char s[n];
  int ans = 0;
  rep(i,n)
  {
    cin >> s[i];
  }
  rep(i,n)
  {
    if(i > 0 && i < n - 1)
    {
    	if(s[i] == 'L' && s[i - 1] == 'L')
        {
          ans += 1;
        }
      	else if(s[i] == 'R' && s[i + 1] == 'R')
        {
          ans += 1;
        }
    }
    else
    {
      if(i == 0 && s[i] == 'R' && s[i + 1] == 'R')
      {
        ans += 1;
      }
      else if(i == n- 1 && s[i] == 'L' && s[i - 1] == 'L')
      {
        ans += 1;
      }
    }
  }
  ans = (ans + 2 * k) > n - 1 ? n-1 : ans + 2 * k;
  cout << ans << endl;
}
  





Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    ll h,w;
    cin>>h>>w;
    string s[h];
    rep(0,i,h)cin>>s[i];
    ll dp[h][w];
    rep(0,i,h)rep(0,j,w)dp[i][j]=10000000;
    dp[0][0]=(s[0][0]=='#')?1:0;
    rep(0,i,h){
        rep(0,j,w){
            if(i+1<h){
                if(s[i][j]=='.'&&s[i+1][j]=='#')dp[i+1][j]=min(dp[i][j]+1,dp[i+1][j]);
                else dp[i+1][j]=min(dp[i][j],dp[i+1][j]);
            }
            if(j+1<w){
                if(s[i][j]=='.'&&s[i][j+1]=='#')dp[i][j+1]=min(dp[i][j]+1,dp[i][j+1]);
                else dp[i][j+1]=min(dp[i][j],dp[i][j+1]);
            }
        }
    }
    cout<<dp[h-1][w-1];
}

Measured memory_bytes: 3708
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;
typedef pair<int, int> P;

double x[3], y[3], xp, yp;

double cross(int a, int b){
    return x[a] * y[b] - y[a] * x[b];
}

signed main(){
    while(1){
        rep(i, 0, 3) cin >> x[i] >> y[i];
        cin >> xp >> yp;
        if(cin.eof()) break;        
        
        rep(i, 0, 3){
            x[i] -= xp;
            y[i] -= yp;
        }
        int cnt = 0;
        rep(i, 0, 3){
            if(cross(i, (i + 1) % 3) < 0) cnt++;
        }
        cout << (cnt % 3 == 0 ? "YES" : "NO") << endl;
    }
}

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

int main()
{
    int n;
    bool check = false;
    cin>>n;
    for(int i=1; i<10; i++) {
        for(int j=1; j<10; j++) {
            if(n==i*j) {
                check= true;
            }
        }
    }
    if(check) {
        cout<<"Yes"<<endl;
    } else {
        cout<<"No"<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);

		int length = sc.nextInt();
		char S[] = sc.next().toCharArray();
		char T[] = sc.next().toCharArray();

		char ans[] = new char[S.length + T.length];

		{
			int count = 0;
			for(int i = 0; i < T.length; i ++){
				ans[count] = S[i];
				count ++;
				ans[count] = T[i];
				count ++;
			}
		}

		String temp = new String(ans);
		System.out.println(temp);
	}
}


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

using i64 = int64_t;

constexpr i64 MOD = 1000000007;

i64 dp[1003][1003] = {0};
string grid[1003];

int main(){
    int h, w;
    cin >> h >> w;
    for(int i=0;i<h;++i){
        cin >> grid[i];
    }
    dp[0][0] = 1;
    for(int i=0;i<h;++i){
        for(int j=0;j<w;++j){
            if(grid[i][j] == '#')continue;
            if(j+1 < w && grid[i][j+1] == '.'){
                dp[i][j+1] = (dp[i][j+1] + dp[i][j]) % MOD;
            }
            if(i+1 < h && grid[i+1][j] == '.'){
                dp[i+1][j] = (dp[i+1][j] + dp[i][j]) % MOD;
            }
        }
    }

    cout << dp[h-1][w-1] << endl;

    return 0;
}


Measured memory_bytes: 9088
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <time.h>
#define int long long
#define endl '\n'
#define INF 1000000000000000000
#define EPS 1e-10
#define all(a) a.begin(),a.end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define fi first
#define se second
#define pb push_back
#define double long double
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
template<class T, class S> bool chmax(T &a, const S &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class S> bool chmin(T &a, const S &b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	//modcalc();

	int n;
	cin >> n;
	vector<int> a(3 * n);
	rep(i, 3 * n) cin >> a[i];
	multiset<int> stl;
	int lp = 0;
	rep(i, n) {
		lp += a[i];
		stl.insert(a[i]);
	}
	vector<int> l;
	l.pb(lp);
	rep(i, n) {
		lp += a[n + i];
		stl.insert(a[n + i]);
		auto p = stl.begin();
		lp -= *p;
		l.pb(lp);
		p = stl.erase(p);
	}
	multiset<int> str;
	int rp = 0;
	for (int i = 2 * n; i < 3 * n; i++) {
		rp -= a[i];
		str.insert(-a[i]);
	}
	vector<int> r;
	r.pb(rp);
	rep(i, n) {
		rp -= a[2 * n - i - 1];
		str.insert(-a[2 * n - i - 1]);
		auto p = str.begin();
		rp -= *p;
		r.pb(rp);
		p = str.erase(p);
	}
	int ans = -INF;
	rep(i, n + 1) {
		chmax(ans, l[i] + r[n - i]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 14328
class RangeMaximumQuery:
    def __init__(self, n):
        self.size = n
        self.dat = [0] * (2 * n - 1)
    
    def update(self, i, x):
        i += self.size - 1
        self.dat[i] = x
        while i > 0:
            i = (i - 1) // 2
            d1 = self.dat[i * 2 + 1]
            d2 = self.dat[i * 2 + 2]
            if d1 > d2:
                self.dat[i] = d1
            else:
                self.dat[i] = d2
    
    def getmax(self, a, b, k, l, r):
        if r <= a or b <= l:
            return 0
        elif a <= l and r <= b:
            return self.dat[k]
        else:
            vl = self.getmax(a, b, k * 2 + 1, l, (l + r) // 2)
            vr = self.getmax(a, b, k * 2 + 2, (l + r) // 2, r)
            if vl > vr:
                return vl
            else:
                return vr

def solve():
    from math import ceil, log
    
    n = int(input())
    A = map(int, input().split())
    s = 2 ** ceil(log(n, 2))
    W = RangeMaximumQuery(s)
    for a_i in A:
        cost = W.getmax(0, a_i - 1, 0, 0, s) + a_i
        W.update(a_i - 1, cost)
    ans = n * (n + 1) // 2 - W.getmax(0, n, 0, 0, s)
    print(ans)

solve()


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

int main() {
	int x, y;
	cin >> x >> y;
	int a, b;
	for(a=0; a<=x; a++)
	{
		b=x-a;
		int c=2*a+4*b;
		if(c==y)
		{
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a, b;
    string s;
    cin >> a >> b >> s;
    for (int i = 0; i < a + b + 1; i++)
    {

        if ((i == a && s[i] != '-') || (i != a && s[i] < '0') || (i != a && s[i] > '9'))
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 256
//package BeginnerContest145;

import java.util.*;
import java.io.*;

public class Main {

    public static void main(String[] args) throws IOException {
        FastReader sc = new FastReader();
        PrintWriter pw = new PrintWriter(System.out);
        pw.println((long)Math.pow(sc.nextInt(), 2));
        pw.close();
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}

Measured memory_bytes: 23124
if __name__ == '__main__':
    a = int(input())
    max =1
    maxcount=0

    for i in range(1,a+1):
        s2 = i
        count =0
        while s2 >=2:
            if s2 %2 == 0:
                count+=1
                s2 = s2//2

            else:
                break
            if maxcount < count:
                max = i
                maxcount = count

    print(max)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
long long N,ans=0,p;
int main() {
	cin>>N;
	cin>>p;
	for(int i=2;i<=N;i++) {
		int q;
		cin>>q;
		if(q<p) {
			ans+=p-q;
		} else {
			p=q;
		}
	}
	cout<<ans;
}


Measured memory_bytes: 3620
a,b=map(int,input().split())
c=list(map(int,input().split()))
c.sort()
ans=0
h=0
for i in range(a):
    if sum(c[0:i+1])>b:
        ans=i
        h=1
        break
    elif sum(c)==b:
        ans=a
        h=1
        break
if h==0:
    ans=a-1
print(ans)

Measured memory_bytes: 9200
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

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

	int A, B, C;
	
	cin >> A >> B >> C;

	cout << A * B / 2 << endl;
	
	return 0;
}


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

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

using namespace std;

using  ll = long long;

template<class T,class U>
using umap = unordered_map<T,U>;

template<class T>
using uset = unordered_set<T>;

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

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


int main(){  
  ll n;
  cin >> n;
  vector<ll> a(n);
  vector<ll> b(n);

  priority_queue<pair<ll, ll>> pq;

  bitset<200000> bs = 0;
  ll finished = 0;
  
  for(ll i = 0; i < n; ++i){
    cin >> a[i];
  }

  for(ll i = 0; i < n; ++i){
    cin >> b[i];
    pq.push({b[i], i});
    if(a[i] == b[i]){
      bs[i] = 1;
      finished++;
    }
    if(a[i] > b[i]){
      cout << -1 << endl;
      return 0;
    }
  }
  ll cnt = 0;
  while(!pq.empty()){
    if(finished == n){
      cout << cnt << endl;
      return 0;
    }
    while(!pq.empty() && bs[pq.top().second] == 1){
      pq.pop();
    }
    if(pq.empty()){
      cout << cnt << endl;
      return 0;
    }
    ll val, pos;
    tie(val, pos) = pq.top();
    pq.pop();
    ll r = pos + 1, l = pos - 1;
    if(l < 0) l += n;
    if(r >= n) r -= n;

    ll mns = b[r] + b[l];
    ll div = (b[pos] - a[pos]) / mns;
    if(div == 0){
      cout << -1 << endl;
      return 0;
    }
    cnt = (cnt + div);
    b[pos] -= div*mns;
    
    if(b[pos] < a[pos]){
      cout << -1 << endl;
      return 0;
    } else if(b[pos] == a[pos]){
      bs[pos] = 1;
      finished++;
    } else {
      pq.push({b[pos], pos});
    }
    
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 9584
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
signed main(){
  Int n,m;
  cin>>n>>m;
  vector<Int> a(m);
  for(Int i=0;i<m;i++) cin>>a[i];
  a.emplace(a.begin(),n);
  stack<Int> b;
  for(Int i=0;i<(Int)a.size();i++){
    while(!b.empty()&&b.top()>=a[i]) b.pop();
    if(b.empty()||b.top()<a[i]) b.emplace(a[i]);
  }
  m=b.size();
  a.resize(m);
  for(Int i=0;i<m;i++){
    a[i]=b.top();b.pop();
  }

  vector<Int> t(m,0),ans(n+1,0);
  t[0]=1;
  for(Int i=0;i<m;i++){
    Int k=a[i];
    Int j=i;
    while(1){
      Int l=j,r=m;
      while(l+1<r){
	Int p=(l+r)>>1;
	if(k>=a[p]) r=p;
	else l=p;
      }
      if(r==m) break;
      j=r;
      t[j]+=t[i]*(k/a[j]);
      k%=a[j];
    }
    ans[0]+=t[i];
    ans[k]-=t[i];
  }
  
  for(Int i=1;i<n;i++) ans[i]+=ans[i-1];
  for(Int i=0;i<n;i++) cout<<ans[i]<<endl;
  
  return 0;
}


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

using namespace std;

using ll = long long;
using ull = unsigned long long;

int main(int argc, char const *argv[]) {
	int d,n;
	std::cin >> d >> n;
	if (n == 100) {
		n++;
	}
	std::cout << (int)(pow(100,d)) * n << '\n';
	return 0;
}


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

int main(int argc, char const *argv[])
{
    int N;
    cin>>N;
    vector<int> play(N);

    for(auto &x:play){
        cin>>x;
    }

    sort(play.begin(),play.end());

    int add=0;

    vector<int> rate(8);

    for(int i=0;i<N;++i){
        for(int k=1;k<=8;++k){
            if(play[i]<(400*k)){
                rate[k-1]=1;
                break;
            }
        }
        if(play[i]>=3200){
            add++;
        }
    }
    int m=0;
    if(accumulate(rate.begin(),rate.end(),0)==0){
        m=1;
    }

    cout<<accumulate(rate.begin(),rate.end(),0)+m<<" "<<(accumulate(rate.begin(),rate.end(),0)+add)<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(a); i++)
typedef long long ll;
const string yes = "Yes";
const string no = "No";

int main()
{
  vector<vector<ll>> a(3, vector<ll>(3));
  for (int i=0; i<3; i++){
    for (int j=0; j<3; j++){
      cin >> a[i][j];
    }
  }
  ll n;
  cin >> n;
  vector<ll> b(n);
  for (int i=0; i<n; i++){
    cin >> b[i];
  }
  for (auto v:b) {
    rep(i, 3) rep(j, 3) {
      if (a[i][j]==v) a[i][j]=0;
    }
  }
  if ((a[0][0]==0&&a[0][1]==0&&a[0][2]==0)
      || (a[1][0]==0&&a[1][1]==0&&a[1][2]==0)
      || (a[2][0]==0&&a[2][1]==0&&a[2][2]==0)
      || (a[0][0]==0&&a[1][0]==0&&a[2][0]==0)
      || (a[0][1]==0&&a[1][1]==0&&a[2][1]==0)
      || (a[0][2]==0&&a[1][2]==0&&a[2][2]==0)
      || (a[0][0]==0&&a[1][1]==0&&a[2][2]==0)
      || (a[0][2]==0&&a[1][1]==0&&a[2][0]==0)
  ) {
    cout << yes << endl;
  } else cout << no << endl;

  return 0;
}


Measured memory_bytes: 256
def main():
    n,m=map(int,input().split())
    a=list(map(int,input().split()))
    cnt=[]
    for i in a:
        cnt.append([i,1])
    for i in range(m):
        b,c=map(int,input().split())
        cnt.append([c,b])
    cnt.sort()
    s,k=0,0
    while k<=n and cnt:
        i,j=cnt.pop()
        if k+j>=n:
            s+=(n-k)*i
        else:
            s+=i*j
        k+=j
    print(s)

if __name__ == '__main__':
    main()

Measured memory_bytes: 34640
#include <stdio.h>
int n;
long long t[100000];
long long a[100000];
int ft[100000];
int fa[100000];
long long x;
long long p = 1000000007;
int main() {
	x = 1;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%lld", t + i);
	}
	for (int i = 0; i < n; i++) {
		scanf("%lld", a + i);
	}
	ft[0] = t[0];
	fa[n - 1] = a[n - 1];
	for (int i = 1; i < n; i++) {
		if (t[i] > t[i - 1])ft[i] = 1;
		if (a[i - 1] > a[i])fa[i - 1] = 1;
	}
	for (int i = 0; i < n; i++) {
		if (ft[i] && fa[i]) {
			if (t[i] != a[i])x = 0;
		}
		else if (!ft[i] && !fa[i]) {
			if (t[i] < a[i])x *= t[i];
			else x *= a[i];
			x %= p;
		}
		else {
			if (ft[i]) {
				if (t[i] > a[i])x = 0;
			}
			else if (a[i] > t[i])x = 0;
		}
	}
	printf("%lld\n", x);
}

Measured memory_bytes: 3816
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
const int MN=3000;
int N;
int a[MN];
vector<int> G[MN];
bool Awin(int v,int p=-1){
	bool can=0;
	for(int u:G[v]) if(u!=p){
		if(a[v]<=a[u]) continue;
		if(!Awin(u,v)) can=1;
	}
	return can;
}
int main(){
	cin>>N;
	rep(i,N) cin>>a[i];
	rep(i,N-1){
		int x,y;
		cin>>x>>y;
		x--,y--;
		G[x].pb(y);
		G[y].pb(x);
	}
	rep(r,N){
		if(Awin(r)) cout<<r+1<<" ";
	}
	puts("");
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
using namespace std;
int main()
{
    string s,t;
    int i,n,count=0;
    cin>>s>>t;
    n=s.length();
    for(i=0;i<n;i++)
    {
        if(s[i]!=t[i])
            count++;
    }
    cout<<count;
    return 0;
}

Measured memory_bytes: 3836
#include<iostream>
#include<cstring>
#include<vector>
#include<queue>
using namespace std;

const int NMax = 100000 + 10;
const int mod = 1000000007;

int N;

int main() {

    cin>>N;
    long long sol = 1;
    for (int i=1;i<=N;++i) {
        sol = (sol*i) % mod;
    }
    cout<<sol;

    return 0;
}





Measured memory_bytes: 256
A, B = map(int, input().split())

def getPrimeFactors(x):
    ans = []
    for d in range(2, int(x**0.5)+1):
        while x%d == 0:
            ans.append(d)
            x //= d
    if x != 1:
        ans.append(x)
    return ans

pfAs = [1] + getPrimeFactors(A)
pfBs = [1] + getPrimeFactors(B)

ans = len(set(pfAs) & set(pfBs))
print(ans)


Measured memory_bytes: 3060
//inlclude before define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
#include<assert.h>
#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef pair<int, int> P1;
typedef long long int ll;

//define
#define INF 1e9
#define NUM 1000000007
#define all(x) begin(x),end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,a,b) for(int i=int(a);i<int(b);i++)
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))

//function

/*ll gcd(ll a, ll b) {
	if (b == 0) return a;
	else return gcd(b, a%b);
}*/

/*ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a * (b / g);
}*/

/*int dig(int a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}*/

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

	if (a < 1 && b>=0 ) {
		cout << "Zero" << endl;
	} else if (a >= 1 && b >= 1) {
		cout << "Positive" << endl;
	} else {
		int num = abs (a) - abs (b);
		if (num % 2 == 0) cout << "Negative" << endl;
		else cout << "Positive" << endl;
	}
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef double db; 
typedef string str; 
typedef pair<ll,ll> pl; 
typedef vector<ll> vl; 
typedef vector<vl> vvl; 
#define mp make_pair
#define se second
#define pb push_back
#define pf push_front
#define nn <<"\n"
#define F0R(i,a) for(ll i=0;i<a;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
int INF=0x3f3f3f3f;
ll MOD=1000000007;

ll binpow(ll a,ll b, ll c=1e18){
	ll res=1;
	while(b>0){
		if(b & 1){
			res*=a;
			res%=c;
		}
		a*=a;
		a%=c;
		b>>=1;
	}
	return res;
}
map<int,int> freq;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	//ifstream cin("name.in");
	//ofstream cout("name.out");
	ll n;
	cin>>n;
	vl nums;
	ll sum=0;
	F0R(i,n){
		ll a;
		cin>>a;
		nums.pb(a);
		sum+=a;
		freq[a]++;
	}
	ll q;
	cin>>q;
	F0R(i,q){
		ll a,b;
		cin>>a>>b;
		ll occur=freq[a];
		freq[b]+=freq[a];
		freq[a]=0;
		sum+=occur*b-occur*a;
		cout<<sum nn;
	}
	
}


Measured memory_bytes: 8460
#include<iostream>

using namespace std;


int main(){
	int n,l;
	cin>>n>>l;
	int ans=-1;
	int pre=0;
	for(int i=0;i<n;i++){
		int a;
		cin>>a;
		if(a+pre>=l)ans=i;
		pre=a;
	}
	if(ans!=-1){
		cout<<"Possible"<<endl;
		for(int i=1;i<ans;i++)cout<<i<<endl;
		for(int i=n-1;i>ans;i--)cout<<i<<endl;
		if(ans!=0)cout<<ans<<endl;
	}
	else cout<<"Impossible"<<endl;
}


Measured memory_bytes: 768
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <functional>
#include <map>
#include <set>
#define REP(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define INF 10000000
#define ll long long

using namespace std;

typedef pair<int, int> P;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

int N;
int d[100010];
vector<int> v = {6, 36, 216, 1296, 7776, 46656, 9, 81, 729, 6561, 59049};

int main(){
	scanf("%d", &N);

	d[0] = 0;
	rep(i, 100000){
		d[i] = i;
	}

	REP(i, 11){
		rep(j, 100000){
			if(j >= v[i]){
				d[j] = min(d[j], d[j-v[i]] + 1);
			}
		}
	}

	printf("%d", d[N]);

	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
int main(void)
{
int coin500, coin100, coin50, sum, a, b, c, count=0;
scanf("%d%d%d%d", &coin500, &coin100, &coin50, &sum);
for(a=0; a<=coin500; a++)
{
 for(b=0; b<=coin100; b++)
 {
  for(c=0; c<=coin50; c++)
  {
   if(sum == 500*a+100*b+50*c) count++;
}}}
printf("%d", count);
return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <stdio.h>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cfloat>
#include <math.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <iomanip>

using namespace std;

#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
// #define req(j, n) for (ll j = 1; j < (n+1); j++)
// #define rer(k, n) for (ll k = 1; k < (n+1); k++)



int main()
{
    string s;
    string t;
    cin >> s;
    cin >> t;
    int ans = 0;
    int length;
    length = s.length();
    rep(i, length) {
        if (s[i] != t[i]) {
            ans += 1;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3844
import sys

N = int(sys.stdin.readline().rstrip())
A = [int(x) for x in sys.stdin.readline().rstrip().split()]

sumf = 0
max_ = 0
for a in A:
    if max_ < a:
        max_ = a
        continue
    else:
        sumf += max_ - a

print(sumf)

Measured memory_bytes: 32180
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

//find_by_order gives kth-largest element
//order_of_key gives the number of items in the set that are strictly smaller!!

// OT.find_by_order(k-1)
// 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define db4(x, y, z, w) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << "," << #w << "=" << w << endl
#define ll long long
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define X first
#define Y second
#define sz(x) (int)((x).size())
#define pii pair<int,int>
#define MOD (ll)(998244353)
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
typedef vector<int> vi;
#define inf (ll)(1e18)
#define double long double
#define int long long

//////////////////////
const int N = 2005;


int32_t main() {

    ios::sync_with_stdio(false);
    cin.tie(0); 
    cout.tie(0);

    string st;
    cin >> st;

    int c0 = 0, c1 = 0;
    rep(i,sz(st)) {
        if(st[i]=='0') c0++;
        else c1++;
    }
    cout << 2*min(c0,c1) << '\n';
}

Measured memory_bytes: 512
def pre_cmb(N, MOD):
    FACT = [1, 1]  # 階乗
    INV = [0, 1]  # 各iの逆元
    FACTINV = [1, 1]  # 階乗の逆元

    for i in range(2, N + 1):
        FACT.append((FACT[-1] * i) % MOD)
        INV.append(pow(i,MOD-2,MOD))
        FACTINV.append((FACTINV[-1] * INV[-1]) % MOD)
    PRELIST = FACT, FACTINV
    return PRELIST


def cmb(N, R, MOD, PRELIST):
    FACT, FACTINV = PRELIST
    if (R < 0) or (N < R):
        return 0
    R = min(R, N - R)
    return FACT[N] * FACTINV[R] * FACTINV[N-R] % MOD


n, m, k = map(int, input().split())
mod = 998244353

prelist = pre_cmb(n, mod)

cnt = 0
for i in range(k + 1):
    cnt += (m * pow(m - 1, n - i - 1, mod) * cmb(n - 1, i, mod, prelist)) % mod

print(cnt % mod)


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

using namespace std;

int main() {
		long long X;
		cin >> X;

		long long five_hundred = ceil(X / 500);
		long long res = X % 500;
		long long five = ceil(res / 5);
		long long output = five_hundred * 1000 + five * 5;
		cout << output << endl;
}


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


#define  SZ(items) (int)items.size()
#define  CLR(a)  memset(a,0,sizeof(a))
#define  SET(a)  memset(a,-1,sizeof(a))

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

template <class T> inline T biton(T n, T pos)
{
    return n | ((T)1 << pos);
}
template <class T> inline T bitoff(T n, T pos)
{
    return n & ~((T)1 << pos);
}
template <class T> inline T ison(T n, T pos)
{
    return (bool)(n & ((T)1 << pos));
}
template <class T> inline T gcd(T a, T b)
{
    while (b)
    {
        a = a%b;
        swap(a, b);
    }
    return a;
}
template <class T> inline T bigmod(T p, T e, T m)
{
    T ret = 1;
    for (; e > 0; e >>= 1)
    {
        if (e & 1)
            ret = (ret * p) % m;
        p = (p * p) % m;
    }
    return (T)ret;
};

#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1)
{
    cerr << name << " is " << arg1 << std::endl;
}
template < typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args)
{
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " is " << arg1 << " | ";
    __f(comma + 1, args...);
}
#else
#define debug(...)
#endif


void solve()
{
  int n;
  cin>>n;
  vector<int> items(n);

  for(int i=1;i<n;i++){
    cin>>items[i];
  }

  long long sum=items[n-1]+items[1];

  for(int i=1;i<n-1;i++){
    sum+=min(items[i],items[i+1]);
  }

  cout<<sum<<endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    cout.tie(nullptr);
    cin.tie(nullptr);

    int t = 1;
    while (t--)
    {
        solve();
    }


    return 0;
}


Measured memory_bytes: 256
import java.util.*;

import javax.lang.model.type.ArrayType;

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();
		sc.close();
		Arrays.sort(a);
		long ans = 0;
		Queue<Integer> queue = new ArrayDeque<Integer>();
		queue.add(a[n - 1]);
		for(int i = n - 2; i >= 0; --i){
			int tmp = queue.poll();
			ans += (long)tmp;
			tmp = a[i];
			queue.add(tmp);
			queue.add(tmp);
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 63080
#include<cstdio>
#include<algorithm>
using namespace std;
int N,Ans0,Ans1;
int main(){
	scanf("%d",&N);
	for(int i=1;i<=N;i++){
		if(i%2)Ans0++;
		else Ans1++;
	}
	printf("%.7f\n",Ans0*1.0/(Ans0+Ans1));
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
#include<deque>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define rep2(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

int main() {
	int n, x;
	cin >> n >> x;
	vector<i64> a(n);
	i64 ans = 0;
	rep(i, 0, n) {
		cin >> a[i];
		if (a[i] > x) {
			ans += a[i] - x;
			a[i] = x;
		}
	}
	rep(i, 1, n) {
		if (a[i] + a[i - 1] > x) {
			int y = a[i] - x + a[i - 1];
			ans += y;
			a[i] -= y;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>

#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
using namespace std;

int N, K;
int X[50];
int Y[50];

int cnt_map[50][50];
vector<int> grid_x;
vector<int> grid_y;

signed main()
{
	cin >> N >> K;
	REP(i, N)
	{
		cin >> X[i] >> Y[i];
		if (!CONTAINS(grid_x, X[i])) grid_x.push_back(X[i]);
		if (!CONTAINS(grid_y, Y[i])) grid_y.push_back(Y[i]);
	}
	SORT(grid_x);
	SORT(grid_y);

	for (int x = 0; x < grid_x.size(); x++)
	{
		for (int y = 0; y < grid_y.size(); y++)
		{
			for (int i = 0; i < N; i++)
			{
				if (X[i] == grid_x[x] && Y[i] == grid_y[y])
				{
					for (int j = y; j < grid_y.size(); j++)
					{
						cnt_map[x][j]++;
					}
				}
			}
		}
	}


	int ans = LLONG_MAX;

	for (int y1 = 0; y1 < grid_y.size(); y1++)
	{
		for (int y2 = y1; y2 < grid_y.size(); y2++)
		{
			for (int x1 = 0; x1 < grid_x.size(); x1++)
			{
				int cnt = 0;
				for (int x2 = x1; x2 < grid_x.size(); x2++)
				{
					int upper = (y1 == 0) ? 0 : cnt_map[x2][y1 - 1];
					cnt += (cnt_map[x2][y2] - upper);

					if (cnt >= K)
					{
						int dx = grid_x[x2] - grid_x[x1];
						int dy = grid_y[y2] - grid_y[y1];
						ans = MIN(ans, dx * dy);
					}
				}
			}
		}
	}

	cout << ans << endl;
}



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

int main() {
  int k;
  int a[1000001];
  cin >> k;
  a[1] = 7 % k;
  if (a[1] == 0) {
    cout << 1 << endl;
    return 0;
  }
  for (int i = 2; i <= k; i++) {
    a[i] = (a[i - 1] * 10 + 7) % k;
    if (a[i] == 0) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 7428
using System;
using System.Linq;
using System.Collections.Generic;

using E = System.Linq.Enumerable;
using System.Text;

public class Program
{
    const int Base = 'Z' - 'A' + 1;

    public static void Main()
    {
        var n = long.Parse(Console.ReadLine());

        // source: https://docs.microsoft.com/ja-jp/office/troubleshoot/excel/convert-excel-column-numbers
        var name = new List<char>();
        while (n > 0)
        {
            n = Math.DivRem(n - 1, Base, out var r);
            name.Add((char)(r + 'a'));
        }
        name.Reverse();

        Console.WriteLine(new string(name.ToArray()));
    }
}


Measured memory_bytes: 27824
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    a, b = map(int, input().split())
    res = [[""] * 100 for _ in range(100)]
    for i in range(100):
        for j in range(100):
            res[i][j] = "." if i < 50 else "#"

    b -= 1
    for i in range(0, 50, 2):
        for j in range(0, 100, 2):
            if b == 0:
                break
            res[i][j] = "#"
            b -= 1
        else:
            continue
        break

    a -= 1
    for i in reversed(range(50, 100, 2)):
        for j in range(0, 100, 2):
            if a == 0:
                break
            res[i][j] = "."
            a -= 1
        else:
            continue
        break

    print(100, 100)
    for i in res:
        print("".join(i))


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 9156
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>
#define vecd vector<double>
template <typename T>
T lcm(T a, T b)
{
	return a / __gcd(a, b) * b;
}
void comb(vector<vector<long long int>> &v)
{
	for (int i = 0; i < v.size(); i++)
	{
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (int k = 1; k < v.size(); k++)
	{
		for (int j = 1; j < k; j++)
		{
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
		}
	}
}
bool is_not_out_of_range(size_t now, size_t max_num)
{
	return !(now < 0 || max_num <= now);
}
ll repeat_squaring(ll n, ll p, ll m)
{
	if (p == 0)
		return 1;
	if (p % 2 == 0)
	{
		ll t = repeat_squaring(n, p / 2, m);
		return t * t % m;
	}
	return n * repeat_squaring(n, p - 1, m);
}

int main()
{
	int n, nn;
	cin >> n >> nn;
	vector<str> v(n);
	rep(i, n)
	{
		cin >> v[i];
	}
	sort(all(v));
	rep(i, n)
	{
		cout << v[i];
	}
	cout << endl;
	return 0;
}

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

int main() {
  int n, q;
  cin >> n >> q;
  vector<vector<int>> v(n);
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    v[a - 1].push_back(b - 1);
    v[b - 1].push_back(a - 1);
  }
  vector<int> r(n);
  for (int i = 0; i < q; i++) {
    int p, x;
    cin >> p >> x;
    r[p - 1] += x;
  }
  function<void(int, int)> dfs = [&](int i, int j) {
    for (auto e : v[j]) {
      if (e == i) continue;
      r[e] += r[j];
      dfs(j, e);
    }
  };
  dfs(0, 0);
  for (auto e : r) cout << e << ' ';
  cout << endl;
}


Measured memory_bytes: 29696