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

int main()
{
    int a,b,c;
    cin>>a>>b;
    c=a+b;
    if(c>=10)
    {
        cout<<"error\n";
    }
    else
    {
        cout<<c<<endl;
    }
    return 0;
}



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

#define copy(from, to) copy(from.begin(), from.end(), back_inserter(to));
#define sort(a) sort(a.begin(), a.end())

using namespace std;

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

  cout << (x - a) % b << endl;
}

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

using namespace std;
typedef long long int ll;
ll power(ll x, ll y)
{
    if(x==0)
    return 1%y;
    else if(x%2)
    return power(x-1, y)*2%y;
    else
    return power(x/2, y)*power(x/2, y)%y;
}
int main() {
    
    ll n, i, a[1000], dp[200001]={}, num1=0, minusnamuzy=0, plusnamuzy=0;
    string s;
    
    cin>>n;
    cin>>s;
    for(i=1;i<=200000;i++)
    {
        ll t=i, dap=0;
        while(t!=0)
        {
            dap+=t%2;
            t/=2;
        }
        dp[i]=dp[i%dap]+1;
    }
    for(i=0;i<n;i++)
    num1+=(s[i]=='1');
    
    if(num1==0)
    {
        for(i=0;i<n;i++)
        printf("1\n");
    }
    else if(num1==1)
    {
        if(s[n-1]=='1')
        {
            for(i=0;i<n;i++)
            {
                if(i==(n-1))
                printf("0\n");
                else
                printf("2\n");
            }
        }
        else
        {
            for(i=0;i<n;i++)
            {
                if(i==(n-1))
                printf("2\n");
                else if(s[i]=='1')
                printf("0\n");
                else
                printf("1\n");
            }
        }
    }
    else
    {
        ll k=1;
        for(i=(n-1);i>=0;i--)
        {
            if(s[i]=='1')
            {
                plusnamuzy+=k;
            }
            k*=2;
            k%=(num1+1);
        }
        k=1;
        
        for(i=(n-1);i>=0;i--)
        {
            if(s[i]=='1')
            {
                minusnamuzy+=k;
            }
            k*=2;
            k%=(num1-1);
        }
    
    
    for(i=0;i<n;i++)
    {
        ll ho=0;
        if(s[i]=='0')
        {
            ho=plusnamuzy;
            ho+=power(n-i-1, num1+1);
            ho%=(num1+1);
        }
        else
        {
            ho=minusnamuzy;
            ho-=power(n-i-1, num1-1);
            ho+=(num1-1);
            ho%=(num1-1);
        }
    
    
    printf("%lld\n", 1+dp[ho]);
    }
    }
    
    
    return 0;
}

Measured memory_bytes: 5416
import numpy as np

H, W, K = map(int, input().split())

valids = []
for i in range(2 ** (W - 1)):
    f0, f1 = False, False
    for bit in range(W - 1):
        if i >> bit & 1 == 0:
            f0 = True
            f1 = False
        else:
            if f1 == True:
                break
            f1 = True
            f0 = False
    else:
        valids.append(i)

M = np.zeros((W, W))

for valid in valids:
    m = np.eye(W)
    for bit in range(W - 1):
        if valid >> bit & 1 == 1:
            end = W - bit
            m[end-2:end, end-2:end] = np.array([[0, 1], [1, 0]])
    M += m

state = np.zeros((W,))
state[0] = 1
for i in range(H):
    state = M.dot(state)
    state %= int(1e9 + 7)

print(int(state[K - 1] % (int(1e9) + 7)))


Measured memory_bytes: 14452
import sys
input = sys.stdin.buffer.readline
from collections import Counter
 
def main():
    N = int(input())
    a = list(map(int,input().split()))
    
    c = [0 for _ in range(max(a))]
    for num in a:
        c[num-1] += 1
    
    count = 0
    for num in c:
        count += (num*(num-1))//2

    for i in a:
        if c[i-1] == 1:
            print(count)
        else:
            num = c[i-1]
            d = (num*(num-1))//2
            p = ((num-1)*(num-2))//2
            print(count-d+p)
    
if __name__ == "__main__":
    main()



Measured memory_bytes: 20732
import string
digs = string.digits + string.ascii_letters
def int2base(x, base):
    if x < 0:
        sign = -1
    elif x == 0:
        return digs[0]
    else:
        sign = 1
    x *= sign
    digits = []
    while x:
        digits.append(digs[int(x % base)])
        x = int(x / base)
    if sign < 0:
        digits.append('-')
    digits.reverse()
    return ''.join(digits)

n,m=map(int,input().split())
xx=int2base(n,m)
# print(xx)
print(len(xx))

Measured memory_bytes: 3772
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;

int main() {
  int a, b, h;
  cin >> a >> b >> h;
  cout << h/2*(a+b) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

using u128 = __uint128_t;

#define int long long
#define index_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define atIndex find_by_order
#define indexOf order_of_key
#define MOD 1000000007
#define MAX 200005

int dp[MAX];

void solve() {
    int n;
    cin>>n;
    int *h = new int[n];
    for(int i = 0 ;i< n ; i++)
        cin>>h[i];
    dp[0] = 0;
    dp[1] = abs(h[0] - h[1]);
    for(int i = 2 ; i< n ; i++){
        dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]) , dp[i-2] + abs(h[i] - h[i-2]));
    }
    cout<<dp[n-1]<<endl;
}

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    //cin>>t;
    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    // 標準入力
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    // 標準入力数値配列用
    static int[] inputval() throws Exception {
        String[] strarray = br.readLine().trim().split(" ");
        int[] intarray = new int[strarray.length];
        for (int i = 0; i < intarray.length; i++) {
            intarray[i] = Integer.parseInt(strarray[i]);
        }
        return intarray;
    }

    public static void main(String[] args) throws Exception {
	// write your code here
        int a = Integer.parseInt(br.readLine().trim());
        int b = Integer.parseInt(br.readLine().trim());
        int c = Integer.parseInt(br.readLine().trim());
        int x = Integer.parseInt(br.readLine().trim());
        int cnt = 0;
        for (int i=0; i<=a; i++){
            for (int j=0; j<=b; j++){
                for (int k=0; k<=c; k++){
                    if (500 * i + 100 * j + 50 * k == x){
                        cnt+=1;
                    }
                }
            }
        }
        System.out.println(cnt);
    }

}



Measured memory_bytes: 22484
#include "bits/stdc++.h"

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=(n); i--)
#define LREP(lst,itr) for(auto itr = lst.begin(); itr != lst.end(); ++itr)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define P(s) cout<<(s)<<endl
#define P2(a, b) cout<<(a)<<" "<<(b)<<endl
#define P3(a, b, c) cout<<(a)<<" "<<(b)<<" "<<(c)<<endl
#define V2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

ll fT=1,fA=1;

void calc(ll T, ll A){
    ll n=max((fT+T-1)/T , (fA+A-1)/A);
    fT=T*n; fA=A*n;
    return;
}

int main(){
    ll N,T,A;
    cin >> N;
    REP(i,0,N){
        cin >> T >> A;
        calc(T, A);
    }
    P(fT+fA);
}

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

const int N=100100;
char s[N],a[N]; int n,top,ans,b[N];

int main()
{
	scanf("%s",&s[1]); n=strlen(s+1); bool flag=0;
	for (int i=1; i<=n; ++i) if (s[i]!='x') {a[++top]=s[i];b[top]=i;}
	if (!top) {printf("0");return 0;}
	int i,j; if (top%2) i=b[top/2+1],j=i; else i=b[top/2],j=b[top/2+1];
	while (i>=1&&j<=n)
	{
		if (s[i]==s[j]) {i--;j++;continue;}
		if (s[i]=='x') {i--;ans++;continue;}
		if (s[j]=='x') {j++;ans++;continue;}
		flag=1; break;
	}
	if (i>=1) ans+=i; if (j<=n) ans+=n-j+1;
	if (flag) printf("-1"); else printf("%d",ans);
	return 0;
}


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

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<vector<int>> a(2, vector<int>(n));
	for (auto& x : a)
		for (auto& y : x)
			cin >> y;
	vector<vector<int>> pref(2, vector<int>(n + 1));
	for (int i = 0; i < 2; ++i)
		for (int j = 0; j < n; ++j)
			pref[i][j + 1] = pref[i][j] + a[i][j];
	int ans = 0;
	for (int i = 0; i < n; ++i)
		ans = max(ans, pref[0][i + 1] + pref[1].back() - pref[1][i]);
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<limits.h>
#include<stdio.h>
#include<cstring>
#include<string>
using namespace  std;
typedef long long ll;
typedef long double ld;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
#define fi first
#define se second
#define rsz(a,n) a.resize(n)
#define test(t) ll t;cin>>t;while(t--)
#define forn(i,e) for(int i = 0; i < e; i++)
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define rforn(i,s) for(int i = s; i >= 0; i--)
#define rforsn(i,s,e) for(int i = s; i >= e; i--)
#define fillv(a,k) memset(a,k,sizeof(a))
#define leadzero(a) __builtin_clz(a) //count leading zeros
#define trailzero(a) __builtin_ctz(a) //count trailing zeros
#define bitcount(a) __builtin_popcount(a) // count set bits (add ll)
#define ln cout<<"\n"
// #define sp cout<<" "
#define spaceprint(a,i,s,n) {forsn(i,s,n) { cout<<a[i]; sp;}}
#define lineprint(a,i,s,n) {forsn(i,s,n) {cout<<a[i]; ln;}}
#define maxe(a) *max_element(a.begin(),a.end())
#define maxi(a) max_element(a.begin(),a.end())-a.begin()
#define mine(a) *min_element(a.begin(),a.end())
#define mini(a) min_element(a.begin(),a.end())-a.begin()
#define all(c) c.begin(),c.end()
#define trav(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define present(container, element) (container.find(element) != container.end())
#define cpresent(container, element)  (find(all(container),element) != container.end())// check the presence of element
//copy(from_begin, from_end, to_begin); copy function
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<ll,ll> p64;
typedef pair<int,int> p32;
typedef pair<int,p32> p96;
typedef vector<ll> v64;
typedef vector<string> vs;
typedef vector<int> v32;
typedef vector<v32> vv32;
typedef vector<v64> vv64;
typedef vector<p32> vp32;
typedef vector<p64> vp64;
typedef vector<vp32> vvp32;
typedef map<int,int> m32;
typedef map<ll,ll> m64;
const int LIM = 1e5+5, MOD =  1e9;
#define sumv(v) accumulate(all(v),ll(0))
#define productv(v) accumulate(all(v), ll(1), multiplies< ll >())
ll gcd(ll a, ll b) { if(b == 0) return a; return gcd(b, a % b); }
ll mod=998244353;
ll fastpowMOD(ll a, ll p,ll MOD){ if(p==0) return 1; ll z = fastpowMOD(a,p/2,MOD); z = (z*z)%MOD; if(p%2) z = (z*a)%MOD; return z; }


int main()
{
	ll x;
	cin>>x;
	ll in=100;
	ll c=0;
	while (1)
	{
		in=in+in/100;
		c++;
		if (in>=x)
		{
			break;
		}
	}
	cout<<c;
}



Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m1(x) memset(x,-1,sizeof(x))
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589;

int a[100000];
int func(int k){
  return a[k-1];
}

int main(){
  int n;
  cin >> n;
  rep(i, n) cin >> a[i];
  int u = 1;
  int cnt = 0;
  bool flag = false;
  rep(i, 1000000){
    cnt++;
    u = func(u);
    if(u == 2){
      flag = true;
      break;
    }
  }
  if(flag) cout << cnt<<endl;
  else cout<<-1<<endl;
}
  

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long int ll;
#define rep(i,n) for(int i=0;i<(int)n;i++)
int Min(int a, int b, int c) {
	if (a <= b) { return std::min(a, c); }
	else return std::min(b, c);
}
int main(void) {
	double r, g; cin >> r >> g;
	for (int i = -4502;; i++) {
		if ((i + r) / 2 == g) {
			cout << i << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <utility>
#include <algorithm>
using namespace std;
int par[200010],sz[200010],x[200010],y[200010],mn[200010];
void init(int n){
	for(int i=0;i<n;i++){
		par[i] = i; sz[i] = 1; mn[i] = y[i];
	}
}

int find(int x){
	if(par[x]==x) return x;
	return par[x] = find(par[x]);
}

void unite(int x, int y){
	x = find(x); y = find(y);
    mn[y] = min(mn[x],mn[y]);
	if(x==y) return;
	if(sz[x]>sz[y]) swap(x,y);
	par[x] = y;
	sz[y] += sz[x];
}

bool same(int x, int y){
	return find(x)==find(y);
}

set<pair<int,int>> s;
pair<pair<int,int>,int> p[200010];
int main(){
    int i,n; cin >> n;
    for(i=0;i<n;i++){
        cin >> x[i] >> y[i]; x[i]--; y[i]--;
        p[i] = {{x[i],y[i]},i};
    }
    init(n);
    sort(p,p + n);
    s.insert({100000000,-1});
    for(i=0;i<n;i++){
        pair<int,int> q = p[i].first;
        pair<int,int> r = {q.second,p[i].second};
        for(auto x:s){
            if(q.second<x.first){
                s.insert(r);
                break;
            }else{
                unite(p[i].second,x.second);
                r = min(r,{mn[find(p[i].second)],find(p[i].second)});
                s.erase(x);
            }
        }
    }
    for(i=0;i<n;i++) cout << sz[find(i)] << endl;
}

Measured memory_bytes: 13480
#include <bits/stdc++.h>
//#define int long long 
   
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma") 
						   
using namespace std;
#define pb push_back
#define ll long long
#define fi first
#define se second
#define vi vector< int > 
#define pii pair<int,int>
 
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int dp[3005][3005],a,b,c,d;
const int mod = 998244353;
bool vis[3005][3005];
int pw[3005][2],pr[3005][3005],P[3004][3003];
int pow(int a,int n) {
	if (a == 0) return 0;
	int y = 1;
	for (;n;n/=2) {
		if (n & 1) y = 1ll*y*a%mod;
		a=1ll*a*a%mod;
	}
	return y;
}
void solve(int a,int b) {
	 if (vis[a][b]) return;
	 if (a > c || b > d) {
	 	vis[a][b] = 1;
	 	return;
	 }
	 solve(a,b+1);
	 solve(a+1,b);
	 if (a == c) {
			 dp[a][b] = pw[d - b][0];
		vis[a][b] =1 ;
		pr[b-1][a] = (1ll*pr[b-1][a+1] + 1ll*dp[a][b]*P[b-1][a]%mod)%mod;
		return;
	 }
	 if (b == d) {
			 dp[a][b] = pw[c-a][1]; 
		vis[a][b] =1 ;
		pr[b-1][a] = (1ll*pr[b-1][a+1] +  1ll*dp[a][b]*P[b-1][a]%mod)%mod;
		return;
	 }
	 //if (a == 1 && b== 2) cout <<'s';
	 int x = 1;
/*	 for (int i = a + 1; i <= c; i++) {
	 	x = 1ll*x*b%mod;
	 	dp[a][b] = (dp[a][b] + 1ll*dp[i][b+1]*x%mod)%mod;
	 }        */
	 dp[a][b] = 1ll*pr[b][a+1]*pow( P[b][a], mod-2)%mod; 
	 dp[a][b] = (1ll*dp[a][b] + 1ll*dp[a][b+1]*a%mod)%mod;
	 pr[b-1][a] = (1ll*pr[b-1][a+1] + 1ll*dp[a][b]*P[b-1][a]%mod)%mod;   
	 vis[a][b] = 1;
}
 int main(){
ios_base::sync_with_stdio(false);  
cin.tie(NULL);
cout.tie(NULL);
cin >> a >> b >> c >> d;
	pw[0][0] = pw[0][1] = 1;
	for (int i = 1; i <= 3003; i++) {
		pw[i][0] = 1ll*pw[i-1][0]*c%mod;
		pw[i][1] = 1ll*pw[i-1][1]*d%mod;
	}
	for (int i = 1; i <= 3001; i++) {
		P[i][0] = 1;
		for (int j = 1; j<= 3001; j++) {
			P[i][j] = 1ll*P[i][j-1]*i%mod;
		}
	}
	dp[c][d] = 1;
	pr[d-1][c] = pow(d-1,c);
	vis[c][d] = 1;
	solve(a,b);
	cout << (dp[a][b]%mod + mod)%mod <<'\n';
	
	
	
 
}

Measured memory_bytes: 118572
import sys
import math
import collections
import decimal
import itertools
from collections import deque
from functools import reduce
import heapq
import copy
n = int(input())
#n, x, t = map(int, sys.stdin.readline().split())
#n = input()
a = list(map(int, sys.stdin.readline().split()))

m = a[0]
ans = 0
for i in range(1, n):
    if a[i] < m:
        ans += (m - a[i])
    else:
        m = a[i]

print(ans)
    






Measured memory_bytes: 32600
#include <stdio.h>

int main(void)
{
	int a, i;
	int five = 0;
	int seven = 0;
	
	for(i=0; i<3; i++){
		scanf("%d", &a);
		
		if(a == 5)
			five++;
		else if(a == 7)
			seven++;
	}
	
	if(five == 2 && seven == 1)
		printf("YES\n");
	else
		printf("NO\n");
	
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <math.h>
#include <string.h>
#include <vector>


using namespace std;

int max(int x,int y){
    if(x<=y){
        return y;
    }
    return x;
}

int main() {
    string s;
    int a;
    cin>>s;
    a=s.size();
    int b,c;
    b=0;
    c=0;
    for(int i=0;i<=a-1;i++){
        if((s[i]=='A' || s[i]=='T' || s[i]=='C' || s[i]=='G') && i!=a-1){
            b=b+1;
        }else if((s[i]=='A' || s[i]=='T' || s[i]=='C' || s[i]=='G') && i==a-1){
            b=b+1;
            c=max(c,b);
        }else{
            c=max(c,b);
            b=0;
        }
    }
    cout<<c<<endl;
    
    return 0;
}



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

int a[26];

bool func() {
	for (int i = 0; i < 26; ++i) {
		if (a[i] % 2)
			return false;
	}
	return true;
}

int main() {
	std::string str;
	std::cin >> str;
	for (int i = 0; i < str.size(); ++i)
		++a[str[i] - 'a'];
	if (func())
		std::cout << "Yes" << std::endl;
	else
		std::cout << "No" << std::endl;
	return 0;
}

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

using namespace std;

int h[100002];
int dp[100002];
int n, k;

int solve(int i) {
	if(i == n-1) return 0;
	if(dp[i] != -1) return dp[i];

	if(i+1 < n) dp[i] = abs(h[i]-h[i+1]) + solve(i+1);

	for(int j=2; j<=k; j++) {
		if(i+j < n) dp[i] = min(dp[i], abs(h[i]-h[i+j]) + solve(i+j));
	}

	return dp[i];
}

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

	for(int i=0; i<n; i++)
		scanf("%d", &h[i]);

	memset(dp, -1, sizeof(dp));

	printf("%d\n", solve(0));

	return 0;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

int main() {
	std::string s; cin >> s;
	int ans = 0;
	for(auto c: s) ans += (c == '2');
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 256
//============================================================================
// Name        : Traveling.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

struct p{
	int x, y, t;

	friend bool operator<(const p &a, const p &b){
		return a.t < b.t;
	}
};

const int MAX = 100000;
int n, x = 0, y = 0, t = 0;
p pts[MAX];

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

	cin >> n;

	for (int i = 0; i < n; ++i) {
		cin >> pts[i].t >> pts[i].x >> pts[i].y;
	}

	sort(pts, pts + n);

	for (int i = 0; i < n; ++i) {
		int delta = pts[i].t - t, d = abs(pts[i].x - x) + abs(pts[i].y - y);

//		printf("i=%d d=%d delta=%d\n", i, d, delta);

		if(d > delta || (delta - d) % 2 == 1){
			printf("No\n");
			return 0;
		}

		x = pts[i].x;
		y = pts[i].y;
		t = pts[i].t;
	}

	printf("Yes\n");
}


Measured memory_bytes: 1408
#include<stdio.h>
int main(){
	int n,a[100],i;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	for(i=n-1;i>=0;i--){
		printf("%d",a[i]);
		if(i!=0) printf(" ");
	}
	printf("\n");
}


Measured memory_bytes: 2736
from __future__ import print_function
# import numpy as np
# import numpypy as np
import sys
input = sys.stdin.readline

def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return

import math
import string
import fractions
from fractions import Fraction
from fractions import gcd

def lcm(n,m):
    return int(n*m/gcd(n,m))

import re
import array
import copy
import functools
import operator

import collections
import itertools
import bisect
import heapq


from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace

from queue import PriorityQueue as pq

# from itertools import accumulate
# from collections import deque
import random


def main():
    n = int(input())
    print(180*(n-2))
    return

if __name__ == '__main__':
    main()


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

const int INF = 100000000;

typedef pair<int, int> P;

vector<vector<char>> maze(2000, vector<char>(2001));
int N, M;
int sx, sy;
int gx, gy;

int d[2000][2000];

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

int bfs() {
    queue<P> que;
    for (int i = 0; i < N; i++)
        for (int j = 0; j < M; j++) d[i][j] = INF;
    que.push(P(sx,sy));
    d[sx][sy] = 0;

    while(que.size()){
        P p = que.front(); que.pop();
        if(p.first == gx && p.second == gy) break;
        for (int i = 0; i < 4; i++) {
            int nx = p.first + dx[i], ny = p.second + dy[i];

            if(0<=nx&&nx<N&&0<=ny&&ny<M&&maze[nx][ny]!='#'&&d[nx][ny]==INF){
                que.push(P(nx,ny));
                d[nx][ny] = d[p.first][p.second]+1;
            }
        }
    }

    return d[gx][gy];
}

int main() {
    cin >> N >> M;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < M; j++) {
            cin >> maze.at(i).at(j);
        }
    }
    priority_queue<int> a;
    int res = 0;
    for (sx = 0; sx < N; sx++) {
        for (sy = 0; sy < M; sy++) {
                for (gx = 0; gx < N; gx++) {
                    for (gy = 0; gy < M; gy++) {
                        if(maze[sx][sy]=='#'||maze[gx][gy]=='#') continue;
                        int tmp = bfs();
                        if(tmp<INF) res = max(tmp,res);
                    }
                }
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 4352
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
// defines
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define invrep(i,b,a) for(int i = b; i >= a; --i)
#define umap unordered_map
#define uset unordered_set
// typedefs
typedef unsigned long long int ull;
typedef long long int ll;
// -------------------------------
int n, s, a[3000];
const ll MOD = 998244353LL;


// intuition:
//   we want to count all distinct tuples (L, seq, R)
//   where seq is a sequence [i1, i2, ..., ik] of indices such that
//      L <= i1 < i2 < ... < ik <= R
//      and a[i1] + a[i2] + ... + a[ik] == s
// dp(i, c, b):
//   number of ways of completing a seu
//



ll memo[3000][3001][2];
ll dp(int i, int c, int b) {
    // base case 1: out of range -> 0 ways
    if (i == n) return 0;
    // base case 2: already solved
    ll& ans = memo[i][c][b];
    if (ans != -1) return ans;
    // general case
    if (b == 0) { // mode 0: looking for 
        ans = (dp(i, c, 1) + dp(i+1, c, 0)) % MOD;
    } else {
        ans = dp(i+1, c, 1);
        if (a[i] < c) ans = (ans + dp(i+1, c - a[i], 1)) % MOD;
        if (a[i] == c) ans = (ans + dp(i+1, 0, 1) + 1) % MOD;
        if (c == 0) ans = (ans + 1) % MOD;
    }
    return ans;
}
int main() {
    ios::sync_with_stdio(false); 
    cin.tie(0);
    cin >> n >> s;
    rep(i,0,n) cin >> a[i];
    memset(memo, -1, sizeof memo);
    cout << dp(0,s,0) << '\n';
    return 0;
}

Measured memory_bytes: 141184
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		FastScanner fs = new FastScanner();

		int N = fs.nextInt();

		int x = N;
		if( (int)(x / 100) == 7) {
			System.out.println("Yes");
			return;
		}
		x = x - ( 100 * (int)(x / 100) );
		if( (int)(x / 10) == 7) {
			System.out.println("Yes");
			return;
		}
		x = x - ( 10 * (int)(x / 10) );
		if( x  == 7) {
			System.out.println("Yes");
			return;
		}
		System.out.println("No");
	}

}


Measured memory_bytes: 25344
/*
D - Teleporter
by.YXH_XianYu
   2018.6.20
 */
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#define rep(i,j,k) for(int i=j,lim=k;i<=lim;i++)
#define MXN 200003

int n,k,a,ans;

struct Edge{
	int to,
		next;
}e[MXN];
int tot,last[MXN];
void Add(int u, int v){
	tot++;
	e[tot].to=v;
	e[tot].next=last[u];
	last[u]=tot;
}

int fa[MXN],deg[MXN],dep[MXN],
	q[3*MXN],hd,tl;
int main(){
	//freopen("Teleporter.in","r",stdin);
	//freopen("Teleporter.out","w",stdout);

	scanf("%d%d",&n,&k);
	scanf("%d",&a);
	if(a!=1)ans++;
	rep(i,2,n){
		scanf("%d",&a);
		fa[i]=a;
		deg[a]++;
	}
	rep(i,2,n)if(deg[i]==0)q[++tl]=i;
	while(hd<tl){
		hd++;
		int fj=q[hd];
		if(fj==1)
			break;
		if(fa[fj]!=1 && dep[fj]==k-1)
			ans++;
		else
			dep[fa[fj]]=std::max(dep[fa[fj]],dep[fj]+1);
		deg[fa[fj]]--;
		if(deg[fa[fj]]==0)
			q[++tl]=fa[fj];
	}
	printf("%d\n",ans);

	return 0;
}


Measured memory_bytes: 4736
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#include <chrono>
#include <random>
#include <time.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
#define MAX_V 400010
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}

#define INF 1e9+7
#define LLINF 1e18+7
#define N 500000
ll MOD=1e9+7;
ll dp[2000000];
main(){
    int a=in();
    int p=in();
    cout<<(a*3+p)/2;
}



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

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		long[] lArray = convertLong(br.readLine().split(" "));
		long min = 0, max = 0, sum = 0;
		for (int i = 0; i < n; i++) {
			if (lArray[i] < min | i == 0) {
				min = lArray[i];
			}
			if (lArray[i] > max | i == 0) {
				max = lArray[i];
			}
			sum = sum + lArray[i];
		}
		System.out.println(min + " " + max + " " + sum);
	}

	private static long[] convertLong(String[] strArray) {
		long[] longArray = new long[strArray.length];
		for (int i = 0; i < strArray.length; i++) {
			longArray[i] = Long.parseLong(strArray[i]);
		}
		return longArray;
	}
}

Measured memory_bytes: 28660
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int N=2010;
const int dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
int mp[N][N],val[N][N],sum[N][N],sum1[N][N];
int fa[N][N][2];
int cnt_left[N][N],cnt_right[N][N],cnt_up[N][N],cnt_dw[N][N];
int vis[N][N];
int n,m,q;
bool ok(int x,int y){
	if (x<1||x>n||y<1||y>m||mp[x][y]==0||vis[x][y]) return false;
	return true;
}
void dfs(int x,int y){
	int xx,yy;
	vis[x][y]=true;
	for (int i=0;i<4;++i){
		xx=x+dx[i]; yy=y+dy[i];
		if (!ok(xx,yy)) continue;
		fa[xx][yy][0]=x; fa[xx][yy][1]=y;
		++val[x][y];
		dfs(xx,yy);
	}
}
void calc(){
	for (int i=1;i<=n;++i)
		for (int j=1;j<=m;++j){
			cnt_left[i][j]=cnt_left[i-1][j]+(fa[i][j-1][0]==i&&fa[i][j-1][1]==j);
			cnt_right[i][j]=cnt_right[i-1][j]+(fa[i][j+1][0]==i&&fa[i][j+1][1]==j);
			cnt_up[i][j]=cnt_up[i][j-1]+(fa[i-1][j][0]==i&&fa[i-1][j][1]==j);
			cnt_dw[i][j]=cnt_dw[i][j-1]+(fa[i+1][j][0]==i&&fa[i+1][j][1]==j);

			sum[i][j]=sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1]+val[i][j];
			sum1[i][j]=sum1[i-1][j]+sum1[i][j-1]-sum1[i-1][j-1]+mp[i][j];
		}
}
int query_fa(int x1,int y1,int x2,int y2){
	return sum[x2][y2]-sum[x1-1][y2]-sum[x2][y1-1]+sum[x1-1][y1-1];
}
int query_all(int x1,int y1,int x2,int y2){
	return sum1[x2][y2]-sum1[x1-1][y2]-sum1[x2][y1-1]+sum1[x1-1][y1-1];
}

int main(){
	char ch;
	int x1,y1,x2,y2;
	scanf("%d%d%d\n",&n,&m,&q);
	for (int i=1;i<=n;++i){
		for (int j=1;j<=m;++j){
			scanf("%c",&ch);
			mp[i][j]=ch=='1';
		}
		scanf("\n");
	}
	for (int i=1;i<=n;++i)
		for (int j=1;j<=m;++j)
			if (!vis[i][j]&&mp[i][j]) dfs(i,j);
	calc();
	for (int i=1;i<=q;++i){
		scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
		int tmp=query_all(x1,y1,x2,y2);
		int tmp1=query_fa(x1,y1,x2,y2);
		int tmp2=cnt_left[x2][y1]-cnt_left[x1-1][y1];
		tmp2+=cnt_right[x2][y2]-cnt_right[x1-1][y2];
		tmp2+=cnt_up[x1][y2]-cnt_up[x1][y1-1];
		tmp2+=cnt_dw[x2][y2]-cnt_dw[x2][y1-1];
		printf("%d\n",tmp-(tmp1-tmp2));
	}
}


Measured memory_bytes: 175872
n = gets.strip.to_i
ab = n.times.map { gets.strip.split.map(&:to_i) }

ab = ab.sort_by { |a, b| b }

now = 0
ans = 'Yes'
ab.each do |a, b|
    now += a
    if b < now
        ans = 'No'
        break
    end
end

puts ans

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

#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define each(it,v) for(auto &it : v)
#define all(v) (v).begin(),(v).end()
#define mod 1e9+7

using namespace std;
using vi = vector<int>;
using vl = vector<long>;
using P = pair<int,int>;

main()
{
        int n; cin>>n;
        int cnt=0;

        vi v(n);
        each(it,v)
        {
                cin>>it;
                cnt+=it%2;
        }

        if(cnt%2)cout<<"NO"<<endl;
        else cout<<"YES"<<endl;
}

Measured memory_bytes: 640
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

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




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


Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

typedef pair<long long int, long long int> P;

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

int main(){
	
	int A, B;
	cin >> A >> B;
	
	int ans = 0;
	
	for(int i = 0; i < 200000; i++){
		B -= A;
		ans += 1;
		if(B <= 0){
			break;
		}
	}
	
	cout << ans << endl;
	
	return 0;
}



Measured memory_bytes: 3088
from sys import exit, setrecursionlimit, stderr, stdin
from functools import reduce
from itertools import *
from collections import defaultdict, Counter
from bisect import bisect
import functools

setrecursionlimit(10**7)

def input():
  return stdin.readline().strip()

def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

N = read()
edges = [set() for _ in range(N)]
for _ in range(N-1):
  a, b = reads()
  a, b = a-1, b-1
  edges[a].add(b)
  edges[b].add(a)
c = reads()
c.sort()

M = sum(c[:-1])
visited = [False] * N
idx = 0

result = [0] * N

def dfs(x):
  global idx
  for y in edges[x]:
    edges[y].remove(x)
    dfs(y)
  result[x] = c[idx]
  idx += 1

dfs(0)

print(M)
print(" ".join(str(x) for x in result))

Measured memory_bytes: 56944
/*
// A - Traveling Budget
#include <iostream>
using namespace std;

int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0);
  int A,B,C,D;
  cin>>A>>B>>C>>D;
  cout<<min(A,B)+min(C,D)<<endl;
  return 0;
}

// B - Chocolate
#include <iostream>
using namespace std;

int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0);
  int N,D,X;
  cin>>N>>D>>X;
  int A[N];
  for (int i=0; i<N; i++) {
    cin>>A[i];
  }
  int ans=X;
  for (int i=0; i<N; i++) {
    int k=0;
    while (k*A[i]+1<=D) {
      ans++;
      k++;
    }
  }
  cout<<ans<<endl;
  return 0;
}
*/
// C - Traveling Plan
#include <iostream>
#include <cstring>
using namespace std;

int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0);
  int N;
  cin>>N;
  int A[N+2];
  memset(A,0,sizeof(A));
  for (int i=1; i<=N; i++) {
    cin>>A[i];
  }
  int total=0;
  for (int i=1; i<N+2; i++) {
    total+=abs(A[i]-A[i-1]);
  }
  for (int i=1; i<=N; i++) {
    cout<<total-abs(A[i]-A[i-1])-abs(A[i+1]-A[i])+abs(A[i+1]-A[i-1])<<endl;
  }
  return 0;
}


Measured memory_bytes: 1788
loop do
    m, t, p, r = gets.split.map(&:to_i)
    break if m == 0 && t == 0 && p == 0 && r == 0
    rec = r.times.map{gets.split.map(&:to_i)}
    wa = Array.new(t).map{Array.new(p+1,0)}
    grade = Array.new(t).map{Array.new(2,0)}
    rec.each do |rr|
        case rr[3]
        when 0
            grade[rr[1]-1][0] += 1
            grade[rr[1]-1][1] += rr[0] + 20 * wa[rr[1]-1][rr[2]]
        else
            wa[rr[1]-1][rr[2]] += 1
        end
    end
    gr = grade.map.with_index(1){|g,i| [i] + g}.sort{
        |a,b| (b[1] <=> a[1]).nonzero? || (a[2] <=> b[2]).nonzero? || b[0]<=>a[0]
    }
    pb = pc = -1
    ret = ""
    gr.each_with_index {|a,i|
        if a[1] == pb && a[2] == pc
            ret += "=#{a[0]}"
        else
            ret += "#{a[0]}" if i == 0
            ret += ",#{a[0]}" if i != 0
        end
        pb = a[1]
        pc = a[2]
    }
    puts ret
end

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

int n, q;
vector<int> v[200200];
int a[200200];

void dfs(int now, int par){
	rep(i, v[now].size()){
		if(v[now][i] != par){
			a[v[now][i]] += a[now];
			dfs(v[now][i], now);
		}
	}
}

int main(){
	cin >> n >> q;
	rep(i, n-1){
		int a, b;
		cin >> a >> b;
		a--, b--;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	rep(i, q){
		int pos, val;
		cin >> pos >> val;
		pos--;
		a[pos] += val;
	}
	dfs(0, -1);
	rep(i, n) cout << a[i] << " ";
	cout << endl;
	return 0;
}

Measured memory_bytes: 26624
#include<bits/stdc++.h>
#define INF 2000000000
#define MOD 1000000007
#define EPS (1e-10)

using namespace std;

int main(int argc, char *argv[]) {
	
	int nk; cin >> nk;
	int A,B; cin >> A >> B;
	
	for (int i = A; i <=B; i++) {
		if (i % nk == 0) {
			cout << "OK" << endl;
			return 0;
		}
	}
	cout << "NG" << endl;

	return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>

using namespace std;
using ll = long long int;
using vec = vector<int>;

#define rep(n) for(int i = 0; i < (n); ++i)
#define Sort(a)    sort(a.begin(), a.end())
#define gSort(a)   sort(a.begin(), a.end(), greater<int>())
const int INF = 2147483647;
const ll  MOD = 1000000007;

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

    vector<int> x(n);
    for(int i = 0; i < n; ++i) cin >> x[i];

    int all = 0;

    for(auto i : x) all += i;

    double popu = all / (4.0 * m);

    gSort(x);

    int num = 0;
    bool ans = false;
    for(auto i : x) {
        if(i >= popu) num++;

        if(num == m) {
            ans = true;
            break;
        }
    }

    cout << ((ans) ? "Yes" : "No");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define ff first
#define ss second
#define fr(a,b,c) for(int a=b; a<=c; a++)
 
const int N=1e5+5;
const int mod=1e9+7;
 
void solve(int tt)
{
    string str;
    cin>>str;
    for(int i=0;i<str.size();i++)
    {
        if(str[i]=='?')
            str[i]='D';
    }
    cout<<str;
}
 
int32_t main()
{
    IOS;


    int t=1;
    //cin>>t;
    for(int i=1;i<=t;i++)
    {
        solve(i);
        cout<<endl;
    }
}

Measured memory_bytes: 3772
#include<stdio.h>

long long int f(int, long long int);
long long int p[51]={1}, t[51]={1};

int main(void) {
  int i,n;
  long long int x;
  for (i=1; i<51; i++) {
    p[i] = p[i-1]*2+1;
    t[i] = t[i-1]*2+3;
  }
  scanf("%d%lld", &n, &x);
  printf("%lld\n",f(n,x));
  return 0;
}

long long int f(int n, long long int x) {
  // printf("  %d %lld\n", n, x);
  if (n==0) return 1;
  if (x==1) return 0;
  //long long int m = t[n]/2;
  if (x==t[n])
    return p[n];
  if (x==p[n])
    return p[n-1]+1;
  if (x<p[n])
    return f(n-1, x-1);
  return p[n-1]+f(n-1,x-p[n])+1;
}


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

using namespace std;

int main()
{
    long long int n,a,b;

    cin>>n>>a>>b;


    if(a==b){

        cout << 1 << endl;
    }

    else if(n == 1){

        cout << 0 << endl;
    }

    else if(b<a){

        cout<< 0 <<endl;
    }

    else

       cout << ((b - a) * (n - 2)) + 1 << endl;

    return 0;
}


Measured memory_bytes: 3624
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>
#include<set>
 
using namespace std;
 
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define P(p) cout<<(p)<<endl;
#define PP(p) cout<<(p)<<" ";
#define pb push_back
#define mp make_pair

typedef long long ll;
#define int ll
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<char> vc;
typedef pair<int, int> pi;
//int dy[8]={1,1,1,0,-1,-1,-1,0};
//int dx[8]={-1,0,1,1,1,0,-1,-1};
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};

const int INF = 2147483647;
int n,q,_n;
int data[400001];
vi c;
vector<pi>IN;

void init(int n){
  _n = 1;
  while(_n<n){
    _n *= 2;
  }
  fill(data,data+2*_n-1,INF);
}
 
void update(int i,int x){
  i += _n-1;
  data[i] = x;
  while(i>0){
    i = (i-1)/2;
    data[i] = min(data[2*i+1],data[2*i+2]);
  }
}
 
int query(int a,int b,int k,int l,int r){
  if(a<=l&&r<=b+1) return data[k];
  else if(b<l||a>=r) return INF;
  else{
    int vl = query(a,b,2*k+1,l,(l+r)/2);
    int vr = query(a,b,2*k+2,(l+r)/2,r);
    return min(vl,vr);
  }
}
void input(){
	cin>>n>>q;
	c.resize(q+1);
	rep(i,q){
		cin>>c[i];
		int x,y;
		cin>>x>>y;
		IN.pb(mp(x,y));
	}
}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	input();
	init(n);
	rep(i,q){
		if(c[i]==0)update(IN[i].first,IN[i].second);
		else P(query(IN[i].first,IN[i].second,0,0,_n))
	}
	return 0;
}

Measured memory_bytes: 7264
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#define REP(i, n) for (int i = 0; i < (n); i++) 

using namespace std;

using ll = long long;

template<class T>
struct BIT {
  vector<T> dat;

  BIT(int n) : dat(n) {}

  void add(int k, T v) {
    for (int i = k + 1; i < dat.size(); i += i & -i) {
      dat[i] += v;
    }
  }

  T sum(int k) {
    T res = 0;
    for (int i = k; i > 0; i -= i & -i) {
      res += dat[i];
    }
    return res;
  }

  T rsum(int k) {
    return sum(dat.size()-1) - sum(k);
  }

  // sum[0..k) >= v
  int lower_bound(T v) {
    if (v == 0) return 0;
    int k = 0;
    for (int i = dat.size() >> 1; i >= 1; i >>= 1) {
      if (dat[k + i] < v) {
        v -= dat[k + i];
        k += i;
      }
    }
    return k + 1;
  }
};

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int Q;
  cin >> Q;
  vector<int> type(Q);
  vector<ll> A(Q), B(Q);
  vector<ll> C;
  for (int i = 0; i < Q; i++) {
    cin >> type[i];
    if (type[i] == 1) {
      cin >> A[i] >> B[i];
      C.push_back(A[i]);
    }
  }
  sort(C.begin(), C.end());
  C.erase(unique(C.begin(), C.end()), C.end());
  BIT<int> bit0(1 << 18);
  BIT<ll> bit1(1 << 18);
  int n = 0;
  ll sumb = 0;
  for (int i = 0; i < Q; i++) {
    if (type[i] == 1) {
      sumb += B[i];
      int k = lower_bound(C.begin(), C.end(), A[i]) - C.begin();
      bit0.add(k, 1);
      bit1.add(k, A[i]);
      n++;
    } else {
      int k = bit0.lower_bound((n + 1) / 2);
      ll x = C[k - 1];
      ll ans = sumb + (x * bit0.sum(k) - bit1.sum(k)) + (bit1.rsum(k) - x * bit0.rsum(k));
      cout << x << ' ' << ans << '\n';
    }
  }
}


Measured memory_bytes: 10740
import random as rng
import itertools as it
import collections as col
import heapq as hq
import sys
import copy as cp
sys.setrecursionlimit(10**9)


def dump_impl(*objects):
    print(*objects, file=sys.stderr)


def dump_dummy(*objects):
    pass


dump = dump_impl if "DEBUG" in sys.argv else dump_dummy

A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())

print("YES" if abs(A-B)+W*T <= V*T else "NO")


Measured memory_bytes: 76828
#include <stdio.h>

int main(void)
{
    int a,b,c,total,i;
    total=0;
    
    scanf("%d%d%d",&a,&b,&c);
    
    for(i=a;i<=b;i++){
        if(c%i==0){
            total++;
        }
    }
    printf("%d\n",total);
    
    return 0;
}


Measured memory_bytes: 2108
#include "bits/stdc++.h"
#include <set>

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}
template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}

vector<int>yb[100001];

signed main(void) {
	int n, m;
	cin >> n >> m;
	vector<int>p(m);
	vector<int>y(m);
	rep(i, m) {
		cin >> p[i] >> y[i];
		yb[p[i]].pb(y[i]);

	}
	rep(i, n) {
		sort(yb[i+1].begin(), yb[i+1].end());
	}
	rep(i, m) {
		int x = lower_bound(yb[p[i]].begin(), yb[p[i]].end(), y[i]) - yb[p[i]].begin() + 1;
		printf("%012lld\n ", p[i]*1000000+x);
		println("");
	}
}

Measured memory_bytes: 8704
N = int(input())



for i in range(N):
    a,b,c = map(int,input().split())
    
    if a>b:
        a,b=b,a
    if b>c:
        b,c=c,b
    if a>c:
        a,c=c,a
    if a**2+b**2==c**2:
        print("YES")
    else:
        print("NO")



Measured memory_bytes: 5596
#!/usr/bin/python
# -*- coding: utf-8 -*-

# def
def int_mtx(N):
    x = []
    for _ in range(N):
        x.append(list(map(int,input().split())))
    return x

def str_mtx(N):
    x = []
    for _ in range(N):
        x.append(list(input()))
    return x

def int_map():
    return map(int,input().split())

def int_list():
    return list(map(int,input().split()))

def print_space(l):
    return print(" ".join([str(x) for x in l]))

# import
import numpy as np



# main code
N = int(input())
L = int_list()

ans = 0

for i in range(0,N):
    for j in range(i+1,N):
        for k in range(j+1,N):
            if L[i] != L[j] and L[j] != L[k] and L[k] != L[i]:
                if L[i]+L[j] > L[k] and L[j]+L[k] > L[i] and L[k] + L[i] > L[j]:
                    ans += 1

print(ans)


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

using namespace std;
using Graph = vector<vector<int>>;
using Grid= vector<vector<char>>;
using vin= vector<int>;
using ll=long long;
using vll= vector<ll>;
using vbl=vector<bool>;
using vch=vector<char>;
using pinin=pair<int ,int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rell(i,n) for (ll i=0; i< (ll)(n); i++)
#define sort(x) sort(x.begin(), x.end());
#define rese(x) reverse(x.begin(), x.end());

string yes="Yes",no="No";

int main() {
    ll n;
    cin>>n;
    vll a(n);
    rell(i,n) cin>>a[i];
    ll max=1000006;
    vll sub(max,max);
    rell(i,max){
        if(i==0) continue;
        else if(i==1) sub[i]=1;
        else if(sub[i]!=max) continue;
        else{
            sub[i]=i;
            for(ll j=1;i*j<=max; j++){
                if(sub[i]!=max) sub[i*j]=i;
            }
        }
    }
   
    set<ll> div;
    bool pa=true;
    rell(i,n){
        ll j=a[i];
        set<ll> divin;
        while(j!=1){
            
            divin.insert(sub[j]);
            j/=sub[j];
        }
        for(auto value:divin){
            if(div.count(value)) pa=false;
            else div.insert(value);
        }
        if(!pa){
            break;
        }
    }
    if(pa){
        cout<<"pairwise coprime"<<endl;
        return 0;
    }
    ll gc=a[0];
    rell(i,n){
        gc=gcd(gc,a[i]);
    }
    if(gc==1){
        cout<<"setwise coprime"<<endl;
        return 0;
    }
    cout<<"not coprime"<<endl;
  

}


Measured memory_bytes: 18832
#include<bits/stdc++.h>
#include<cstdlib>
using namespace std;
int main(){
  int K; cin>>K;
  string S; cin>>S;
  int J=S.size();
  if(J<=K)
    cout<<S<<endl;
  else {
    for(int i=0; i<K; i++){
      cout<<S.at(i);
    }
    cout<<"..."<<endl;
  }
     
}
  

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

int main(){
    
    int n,k;
    cin >> n >> k;
    vector<int> v(n);

    rep(i,n)cin >> v[i];
    int ans=0;
    for(int l=0;l<=min(k,n);l++){
        for(int r=0;r+l<=min(k,n);r++){
            vector<int> h;
            int su=0;
            rep(i,l){
                su+=v[i];
                h.push_back(v[i]);
            }
            rep(i,r){
                su+=v[n-1-i];
                h.push_back(v[n-1-i]);
            }
            sort(h.begin(),h.end());
            int ret=max(0,k-r-l);
            rep(i,min(ret,(int)h.size())){
                if(h[i]<0){
                    su-=h[i];
                }else{
                    break;
                }
            }
            //cout << l << " " << r << " " << su << endl;
            ans=max(ans,su);
        }
    }

    cout << ans << endl;

    return 0;
}

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

int main(){
  int64_t H;
  cin >> H;
  int64_t ans=0;
  int64_t count=0;
  while(1){
    ans+=pow(2,count);
    H/=2;
    count++;
    if(H==0){
      break;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 384
package main

import (
	"fmt"
)

func main() {
	var n int
	var s string
	sign := map[string]int{"AC": 0, "WA": 0, "TLE": 0, "RE": 0}
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		fmt.Scan(&s)
		sign[s] += 1
	}
	fmt.Printf("AC x %d\n", sign["AC"])
	fmt.Printf("WA x %d\n", sign["WA"])
	fmt.Printf("TLE x %d\n", sign["TLE"])
	fmt.Printf("RE x %d\n", sign["RE"])
}


Measured memory_bytes: 6328