akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#pragma GCC optimize("-ffloat-store")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
typedef vector <int> vi;
typedef pair< int ,int > pii;
#define endl "\n"
#define f(i,a,b) for(int i=a;i<b;i++)
#define debug(val) printf("check%d\n",val)
#define all(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ll long long
#define mod 1000000007
#define inf  1e18
#define ps(x,y)   fixed<<setprecision(y)<<x
#define clr(val) memset(val,0,sizeof(val))
#define what_is(x) cerr << #x << " is " << x << endl;
#define inp(a,n) for(int i=0;i<n;i++) cin>>a[i];
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int main() 
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
    #endif
    FIO;
    int k; cin >> k;
    int amari = 0, ans = 0;
    
    while (true) {
        ++ans;
        amari = (7 + amari * 10) % k;
        
        if (amari == 0) {
        cout << ans << endl;
        return (0);
        }
    
        if (ans >= 1000000) break;
    }
    
    cout << -1 << endl;
    
    return (0);
}

Measured memory_bytes: 3648
import bisect

N = int(input())
L = list(map(int, input().split()))
s = 0

L = sorted(L)

for c in reversed(range(2, N)):
	for b in reversed(range(1, c)):
		a = bisect.bisect_right(L, L[c]-L[b])
		if a<b:
			s += b-a
print(s)

Measured memory_bytes: 3188
n = int(input())
s = [input() for _ in range(n)]
for i in range(n):
  s[i] = ''.join(sorted(s[i]))
t = {}
for i in range(n):
  if s[i] in t:
    t[s[i]] += 1
  else:
    t[s[i]] = 1
print(sum(t[k] * (t[k] -1) // 2 for k in t))


Measured memory_bytes: 73048
#pragma GCC optimize ("Ofast")
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i=(a); i<(int)(b); i++)
#define FORD(i, a, b) for (int i=a; i>(int)(b); i--)
#define PPC(x) __builtin_popcount(x)
#define MSB(x) (31 - __builtin_clz(x))
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define ithBit(m, i) ((m) >> (i) & 1)
#define ft first
#define sd second
#ifdef DEBUG
#include "debug.h"
#else
#define dbg(...) 0
#endif
using namespace std;

const int maxN = 1 << 17;

vector <int> G[maxN], comp;
int res[maxN], compId[maxN], compCtr;
pair <int, int> H[maxN];

void dfs(int v)
{
	compId[v] = compCtr;
	comp.pb(v);
	for (int u : G[v])
		if (compId[u] == 0)
			dfs(u);
}

void solve()
{
	int n, m, k;
	scanf ("%d%d%d", &n, &m, &k);
	FOR(i, 0, m)
	{
		int a, b;
		scanf ("%d%d", &a, &b);
		G[a].pb(b);
		G[b].pb(a);
	}
	
	FOR(i, 1, n+1) if (compId[i] == 0)
	{
		comp.resize(0);
		compCtr++;
		dfs(i);
		for (int v : comp)
			res[v] = comp.size() - 1 - G[v].size();
	}	
	
	while (k--)
	{
		int a, b;
		scanf ("%d%d", &a, &b);
		if (compId[a] == compId[b])
			res[a]--, res[b]--;	
	}
	
	FOR(i, 1, n+1)
		printf("%d ", res[i]);
	printf("\n");
} 
 
int main()
{
    int t;
    t = 1;//scanf ("%d", &t);
    while (t--)
    	solve();
    return 0;    
}




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

using namespace std;

template<class INT>
std::vector<INT> factorize(INT n){
    std::vector<INT> res;
    for (INT i = 1; i * i <= n; i++){
        if (n % i == 0){
            res.push_back(i);
            if (i * i != n)
                res.push_back(n / i);
        }
    }
    return res;
}

int main(){
    int64_t x;
    cin >> x;
    int64_t n = 1e5;
    auto F = factorize(x);
    auto pow5 = [](auto a){return a * a * a * a * a;};
    for (const auto &f: F){
        for (int64_t a = 0; a < n; a++){
            int64_t b = a - f;
            if (pow5(a) - pow5(b) == x){
                cout << a << " " << b << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3596
a = 0
_ = 0
ab = 0
a_ = 0
_b = 0
__ = 0
abc = 0
ab_ = 0
a_c = 0
_bc = 0
a__ = 0
_b_ = 0
__c = 0
___ = 0

T = input()

for c in T:
    if c == "A":
        a += 1
    if c == "B":
        ab += a
        _b += _
    if c == "C":
        abc += ab
        a_c += a_
        _bc += _b
        __c += __
    if c == "?":
        ___ += __
        __ += _
        _ += 1
        a__ += a_
        a_ += a
        _b_ += _b
        ab_ += ab

print(sum([
    abc * 3**(max(_ - 0, 0)),
    ab_ * 3**(max(_ - 1, 0)),
    a_c * 3**(max(_ - 1, 0)),
    _bc * 3**(max(_ - 1, 0)),
    a__ * 3**(max(_ - 2, 0)),
    _b_ * 3**(max(_ - 2, 0)),
    __c * 3**(max(_ - 2, 0)),
    ___ * 3**(max(_ - 3, 0)),
]) % (10**9 + 7))


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

using namespace std;

typedef long long ll;

const ll mod = 1000000007;

int main()
{
  ll N, T;
  cin >> N >> T;
  vector<ll> D(N);
  for(int i = 0; i < N; i++) cin >> D[i];
  sort(D.begin(), D.end());
  ll ans = 1;
  for(int i = 0; i < N; i++) {
    ans = ans * (upper_bound(D.begin(), D.begin() + i, D[i]) - lower_bound(D.begin(), D.begin() + i, D[i] - T)+1) % mod;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3628
import java.util.Scanner;

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

		int d = sc.nextInt();
		int[] c = new int[27];
		for (int i = 1; i < 27; i++) {
			c[i] = sc.nextInt();
		}
		int[][] s = new int[d + 1][27];
		for (int i = 1; i < d + 1; i++) {
			for (int j = 1; j < 27; j++) {
				s[i][j] = sc.nextInt();
			}
		}
		sc.close();

		int[] last = new int[27];
		int v = 0;
		for (int i = 1; i <= d; i++) {
			int maxType = 0;
			int maxV = 0;
			int[] vlist = new int[27];
			for (int j = 1; j < 27; j++) {
				int lastTmp = last[j];
				last[j] = i;
				int tmpV = v;
				tmpV += s[i][j];
				int downSatis = 0;
				for (int k = 1; k < 27; k++) {
					downSatis += (c[k] * (i - last[j]));
				}
				tmpV -= downSatis;
				vlist[j] = tmpV;
				if (maxV < tmpV) {
					maxV = tmpV;
					maxType = j;
				}
				last[j] = lastTmp;
			}
			v = vlist[maxType];
			last[maxType] = i;
			System.out.println(maxType);
		}
	}
}


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

class vertex{
public:
  vector<vertex*> to;
  bool visited;
  int num;
  int visit_time;
  int leave_time;
  vertex(){
    visited=false;
  }
  void dfs(){
    visited=true;
    visit_time=time();
    for(int i=0; i<to.size(); i++){
      if(!to[i]->visited) to[i]->dfs();
    }
    leave_time=time();
  }

  void print(){
    cout << num << " " << visit_time << " " << leave_time << endl;
  }

private:
  static int time(){
    static int ti=0;
    ti++;
    return ti;
  }
};

int main(){
  int n; cin >> n;
  vertex graph[n+1];

  int v, k, to;
  for(int i=0; i<n; i++){
    cin >> v >> k;
    graph[v].num = v;
    for(int j=0; j<k; j++){
      cin >> to;
      graph[v].to.push_back(&graph[to]);
    }
  }


  for(int v=1; v<=n; v++){
    if(!graph[v].visited) graph[v].dfs();
  }

  for(int v=1; v<=n; v++){
    graph[v].print();
  }
  
  return 0;
}



Measured memory_bytes: 3124
import collections
N = int(input())
l_A = list(map(int,input().split()))

#Aの累積和を記録したリストruisekiwa_Aを出す
ruisekiwa_A = [0]
for i in range(N):
  ruisekiwa_A.append(l_A[i]+ruisekiwa_A[i])

#総和がゼロになる部分列の個数とは、
#累積和リスト中の同じ整数を2つ選ぶ組み合わせの数に等しい
#ruisekiwa_A中のかく要素ごとの登場回数をリスト化する
c = dict(collections.Counter(ruisekiwa_A))
onaziyatu_l = list(c.values())

#登場回数をnとすればそこから2つを選ぶ組み合わせはn(n-1)/2なので、
#それをすべての登場回数について計算し和を取る
souwa_zero = 0
for i in onaziyatu_l:
  souwa_zero = souwa_zero + i*(i-1)//2
print(souwa_zero)  

Measured memory_bytes: 47836
c = []
for i in range(3):
    c.append(list(map(int,input().split())))
"""
変数6個で解9個
b1-b2 : c*1-c*2
b2-b3 : c*2-c*3 
b3-b1 : c*3-c*1
a1-a2 : c1*-c2* 
a2-a3 : c2*-c3*
a3-a1 : c3*-c1*
"""

i = 0
flaga12 = True
flaga23 = True 
flaga31 = True
flagb12 = True
flagb23 = True 
flagb31 = True

b12 = c[i][0]-c[i][1]
b23 = c[i][1]-c[i][2]
b31 = c[i][2]-c[i][0]

for i in range(3):
    flagb12 = flagb12 and (b12 == c[i][0]-c[i][1])
    flagb23 = flagb23 and (b23 == c[i][1]-c[i][2])
    flagb31 = flagb31 and (b31 == c[i][2]-c[i][0])
    
j = 0
a12 = c[0][j]-c[1][j]
a23 = c[1][j]-c[2][j]
a31 = c[2][j]-c[0][j]
for i in range(3):
    a12 = c[0][j]-c[1][j]
    a23 = c[1][j]-c[2][j]
    a31 = c[2][j]-c[0][j]
    flaga12 = flaga12 and (a12 == c[0][j]-c[1][j])
    flaga23 = flaga23 and (a23 == c[1][j]-c[2][j])
    flaga31 = flaga31 and (a31 == c[2][j]-c[0][j])

judge = (flaga12 and flaga23 and flaga31 and flagb12 and flagb23 and flagb31)
if judge:
    print("Yes")
else:
    print("No")

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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

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

ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
ll LCM(ll a, ll b) { return a / GCD(a, b)* b; }

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

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  int n; string s; cin>>n>>s;
  
  int l=0;
  int pointer=0;
  rep(i,n){
    if(s[i]=='(') pointer++;
    else{
      if(pointer==0) l++;
      else pointer--;
    }
  }
  int r=pointer;
  string ans="";
  rep(i,l) ans+='(';
  ans+=s;
  rep(i,r) ans+=')';
  cout<<ans<<endl;
}

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

int main() {
    int N, T;
    cin >> N >> T;
    vector< pair<int, int> > route(N);
    for(int i = 0; i < N; i++) {
    int c, t;
        cin >> c >> t;
        route[i] = make_pair(t, c);
    }

    // 時間が昇順になるようにソート
    sort(route.begin(), route.end());

    bool flag = false;
    int min_cost = 100000;
    for(int i = 0; i < N; i++){
        if (route[i].first > T) break;

        if(route[i].second <= min_cost){
            flag = true;
            min_cost = route[i].second;
        }
    }

    if (flag == true){
        cout << min_cost << endl;
    }
    else {
        cout << "TLE" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int a,b,c,n,ans=0;
	cin>>a>>b>>c>>n;
	for(int i=0;i<=a;i++)
		for(int j=0;j<=b;j++)
			for(int o=0;o<=c;o++)
				{
					if(500*i+100*j+50*o==n)
					ans++;
				}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
import math
a, b, C_deg = map(float, input().split())
C_rad = C_deg/360 * 2 * math.pi
S = a * b * math.sin(C_rad) /2
c = math.sqrt((a*math.sin(C_rad))**2 + (b - a*math.cos(C_rad))**2)
L = a + b + c
h = S*2/a
print(str(S))
print(str(L))
print(str(h))


Measured memory_bytes: 5696
import java.util.*;

class Main{
	int n;
  String s;
  

  public static void main(String[] ar){
    new Main();
  }
  public Main(){
  	Scanner sc=new Scanner(System.in);
  	n=Integer.parseInt(sc.nextLine());
    s=sc.nextLine();

    int result=0;
    for(int i=1;i<n;i++){
      //System.out.println(s.substring(0,i)+" "+s.substring(i));
      int count=countChar(s.substring(0,i),s.substring(i));
      if(result<count) result=count;
    }
    System.out.println(result);

    //System.out.println(countChar(s));
  }
  public int countChar(String str1,String str2){
    int c1[]=new int[26];
    int c2[]=new int[26];

    for(int i=0;i<str1.length();i++){
      c1[(int)str1.charAt(i)-97]=1;
    }

    for(int i=0;i<str2.length();i++){
      c2[(int)str2.charAt(i)-97]=1;
    }

    int sum=0;
    for(int i=0;i<26;i++){
      //System.out.println(c1[i]+" "+c2[i]);
      sum+=c1[i]*c2[i];
    }
    return sum;
  }
}

Measured memory_bytes: 22612
#include<iostream>
#include<algorithm>
#include<string>
#define LL long long
LL N;
LL ans;
int main() {
	std::cin >> N;
	LL sum = 0;
	for (int i = 1; i <= N; i++) {
		LL tmp;
		std::cin >> tmp;
		if (tmp) {
			sum += tmp;
		}
		else {
			ans += sum / 2;
			sum = 0;
		}
	}
	ans += sum / 2;
	std::cout << ans << std::endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import static java.lang.Integer.parseInt;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		while ((line = br.readLine()) != null && !line.isEmpty()) {
			int n = parseInt(line);
			if (n == 0) break;

			int[] count = new int[7];
			for (int i = 0; i < n; i++) {
				int age = parseInt(br.readLine()) / 10;
				count[age > 6 ? 6 : age]++;
			}
			for (int c : count) System.out.println(c);
		}
	}
}

Measured memory_bytes: 55800
#include<bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define vv vector<ll>
#define pb push_back
#define rep(i,a,n) for(ll i=a;i<(long long)n;++i)
#define repr(i,n,a) for(ll i=n;i>(long long)a;--i)
#define fe(it,v) for(auto it:v)
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define mod 1000001
using namespace std;

void solve(){
	float n,x,t;
	cin>>n>>x>>t;
	cout<<fixed<<int(ceil(n/x)*t);

}

int main()
{
	// ll t;
	// cin>>t;
	// while(t--){
		solve();
		cout<<endl;
// }/
return 0 ;
}


Measured memory_bytes: 3696
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

int main(){
  int N,K;
  while(cin>>N>>K){
    int card[500][500];
    REP(i,K){
      REP(j,N/2){
        cin>>card[i][j];
        card[i][j]--;
      }
    }
    while(true){
    NEXTLOOP:
      vector<int> seq(N);
      REP(i,N)seq[i] = rand() % 2;
      REP(i,K){
        int sum = 0;
        REP(j,N/2) sum += seq[card[i][j]];
        if(sum < N/8 || sum > 3*N/8){
          goto NEXTLOOP;
        }
      }
      REP(i,N)putchar('0'+seq[i]);putchar('\n');
      break;
    }
  }

  return 0;
}

Measured memory_bytes: 0
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;

#define ll long long
#define pal pair<ll,ll>
#define pad pair<double,double>
#define PB push_back
#define MP make_pair
#define F first
#define S second

const ll MOD = 1e9+7;
const ll INF = 1e18;
const double EPS = 1e-8;

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

template<typename T,typename U>
bool chmax(T& max, const U& x){
	if(max<x){
		max = x;
		return true;
	}
	return false;
}

template<typename T,typename U>
bool chmin(T& min, const U& x){
	if(min>x){
		min = x;
		return true;
	}
	return false;
}


int main(){
	ll n,ans=0;
	cin >> n;
	vector<ll> l(n);
	for(ll i=0;i<n;i++){
		cin >> l[i];
	}

	for(ll i=0;i<n;i++){
		for(ll j=i+1;j<n;j++){
			for(ll k=j+1;k<n;k++){
				if(l[i]+l[j]>l[k] && l[k]+l[j]>l[i] && l[i]+l[k]>l[j]){
					if(l[i]!=l[j]&& l[j]!=l[k]&& l[i]!=l[k]){
						ans++;
					}
				}
			}
		}
	}
	cout << ans << endl;
}

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
typedef long long ll;
const int IINF = INT_MAX;
const ll INF = 1LL << 30;
const ll MOD = 1e9 + 7;


int main() {
    string s; cin >> s;
    int k; cin >> k;

    int n = s.size();
    map<string, int> m;
    for(int i = 0; i < n; i++){
        for(int j = 1; j <= 5; j++){
            string c = s.substr(i, j);
            if(c == "") continue;
            m[c]++;
        }
    }

    int i = 0;
    for(auto p : m){
        i++;
        if(i == k){
             cout << p.first << endl;
             return 0;
        }
    }

    return 0;
}


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

int main() {
  char c;
  cin >> c;

  // ここにプログラムを追記
  if(c=='a' || c=='i' || c=='u' || c=='e' || c=='o'){
    cout << "vowel" << endl;
  }
  else{
    cout << "consonant" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0)
#define endl "\n";
#define pb push_back
#define f first
#define s second
#define all(a) a.begin(),a.end()
#define int long long
const int MOD=1e9+7;
const int N=2e3+10;
int dp[N][N];
vector<pair<int,int> >v;
int go(int pos,int l,int r)
{
    if(pos==v.size())
    {
        return 0;
    }
    int &ans=dp[l][r];
    if(ans!=-1)
        return ans;
    ans=0;
    ans=max(ans,go(pos+1,l+1,r)+v[pos].f*abs(v[pos].s-l));
    ans=max(ans,go(pos+1,l,r-1)+v[pos].f*abs(v[pos].s-r));
    return ans;

}
int32_t main()
{
    IOS;
    int n;
    cin>>n;
    memset(dp,-1,sizeof(dp));
    for(int i=1;i<=n;i++)
    {
        int x;
        cin>>x;
        v.pb({x,i});
    }
    sort(all(v));
    reverse(all(v));
    cout<<go(0,1,n)<<endl;

    
    
}

Measured memory_bytes: 35404
#include <stdio.h>
#include <algorithm>

int D,N,M;
int d[200000], k[100000];

int min(int a, int b) {
        return (a >= b) ? b : a;
}

int* lb(int a[], int size, int target)
{
        int b=0, e=size-1;
        while(e-b>1){
                int p = (b + e)/2;
                if(a[p] >= target) e = p;
                else b = p;
        }

        return (a[b] >= target) ? a + b : a + e;
}

void solve()
{
        int res=0;
        for(int i=0; i<M; i++) {
                int *a;
                a = lb(d, 2*N, k[i]);
                res += min(*a-k[i], k[i]-*(a-1));
                //printf("%d,%d,%d\n",*a,*(a-1),k[i]);
        }
        printf("%d\n", res);
}

int main(void)
{
        while(true){
                scanf("%d", &D);
                if(!D) break;
                scanf("%d%d", &N,&M);
                d[0] = 0; d[N] = D;
                for(int i=1; i<N; i++) { scanf("%d", &d[i]); d[N+i] = D+d[i]; }
                std::sort(d, d+2*N);
                for(int i=0; i<M; i++)
                        scanf("%d", &k[i]);
                solve();
        }
        return 0;
}

Measured memory_bytes: 1868
N,Q = map(int,input().split())
ab = [list(map(int,input().split())) for i in range(N-1)]
px = [list(map(int,input().split())) for i in range(Q)]

graph = [[] for _ in range(N+1)]
for a,b in ab:
    graph[a].append(b)
    graph[b].append(a)

value = [0] * (N+1)
for p,x in px:
    value[p] += x

from collections import deque
todo = deque([(1,0)])
while len(todo) > 0:
    x,parent = todo.pop()
    value[x] += value[parent]
    for y in graph[x]:
        if y == parent:
            continue
        todo.append((y,x))

answer = ' '.join(map(str,value[1:]))
print(answer)

Measured memory_bytes: 158544
#include<stdio.h>

int main() {
  int n;
  int i;
  int a[200010];
  int ans[200010];
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  if (n % 2 == 0) {
    for (i = 0; i < (n/2); i++) {
      ans[i] = a[n - 2*i - 1];
    }
    for (i = 0; i < (n/2); i++) {
      ans[(n/2)+i] = a[2*i];
    }
  }
  if (n % 2 == 1) {
    for (i = 0; i < (n/2)+1; i++) {
      ans[i] = a[n - 2*i - 1];
    }
    for (i = 0; i < (n/2); i++) {
      ans[(n/2)+1+i] = a[2*i+1];
    }
  }
  for (i = 0; i < n; i++) {
    printf("%d ", ans[i]);
  }
  return 0;
}

Measured memory_bytes: 3712
package main

import "fmt"

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

func main() {
	var n, m, x, right, left int
	fmt.Scan(&n, &m, &x)
	a := make([]int, m)
	for i, _ := range a {
		fmt.Scan(&a[i])
	}
	for i := 0; i < m; i++ {
		if a[i] < x {
			left += 1
		} else {
			right += 1
		}
	}
	fmt.Println(min(right, left))
}


Measured memory_bytes: 512
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

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

#include <iostream>

using namespace std;

int main()
{
    int N,T;
    int c,t;
    int min=99999;
    
    cin >> N >> T;
    
    for(int i=0; i<N; i++){
        cin >> c >> t;
        if(t<=T && c<min)min=c;
    }
    
    if(min==99999)cout<<"TLE"<<endl;
    else cout<<min<<endl;
    return 0;
}


Measured memory_bytes: 256
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL A,B,C,D;

string ans = "Yes";

void solve(){
	while(1){
		C -= B;
		if(C<=0) return;
		A -= D;
		if(A<=0){
			ans = "No";
			return;
		}
	}
}
 
int main(){
    cin >> A >>B>>C>>D;
 
    solve();

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3132
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
using namespace std;
string alphabet = "abcdefghijklmnopqrstuvwxyz";
string ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  if(n % 2 == 0){
    int t = n / 2; 
    string k = s.substr(0 , t);
    string l = s.substr(t, t);
    if(k == l)cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  else cout << "No" << endl;
}



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

using ll = long long;
using ull = unsigned long long;
using st = string;
using db = double;
using vll = vector<long long>;
using vdb = vector<db>;
using vvll = vector<vll>;
using vst = vector<st>;
using vchar = vector<char>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
#define rep(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define vrep(i, vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b;return true;} return false;}
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b;return true;} return false;}
const ll mod = 1000000007;
const ll inf = 1LL << 60;


int main(){
  ll n, k;
  cin >> n >> k;
  ll ans = 0;
  rep(i, k, n + 2) ans = (ans + (n + 1 - i) * i % mod + 1) % mod;
  cout << ans << endl;
}

Measured memory_bytes: 3636
#include <stdio.h>
#define ull unsigned long long int
typedef struct{
	int o;
	ull val;
}pair;

ull hoge(pair crew[],ull t,ull s,int num){
	crew[num].val+=t*s;
	return crew[num].val;
}

int main(){
	pair crew[4000];
	ull t,s;
	int i,n,num,N=1000000;
	while(1){
		for(i=0;i<4000;i++) crew[i].val=0,crew[i].o=-1;
		i=0;
		scanf("%d",&n);
		if(!n) break;
		while(n--){
			scanf("%d%llu%llu",&num,&t,&s);
			if(N<=hoge(crew,t,s,num)) if(crew[num].o<0) crew[num].o=i++;
		}
		for(int j=0;j<i;j++){
			for(int k=0;k<4000;k++) if(j==crew[k].o) printf("%d\n",k);
		}
		if(!i) printf("NA\n");
	}
	return 0;
}

Measured memory_bytes: 1104
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
// Welcome to my source code!

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

const int MOD = 1e9+7;
const int BROKEN = 0;

int main() {
    IOS
    int n, m;
    cin >> n >> m;
    bool bf[n+1] = {};
    for (int i = 0; i < m; i++) {
        int a;
        cin >> a;
        bf[a] = true;
    }
    ll dp[n+1] = {};
    dp[0] = 1;
    for (int i = 1; i <= n; i++) {
        if (bf[i]) dp[i] = BROKEN;
        else {
            dp[i] += dp[i-1];
            dp[i] %= MOD;
            if (i > 1) dp[i] += dp[i-2];
            dp[i] %= MOD;
        }
    }
    cout << dp[n] << endl;
}

Measured memory_bytes: 1152
from collections import defaultdict, deque
outs = defaultdict(list)
ins = defaultdict(int)

def get_ab(h):
    return h // 10000, h % 10000

def get_hash(a, b):
    if a >= b:
        return 10000*a + b
    else:
        return 10000*b + a
v = []
N = int(input())
for i in range(N):
    nums = list(map(int, input().split()))
    pred = get_hash(i+1, nums[0])
    if pred not in v:
        v.append(pred)
    for j in range(len(nums)-1):
        now = get_hash(i+1, nums[j+1])
        outs[pred].append(now)
        ins[now] += 1
        pred = now

q = deque(v1 for v1 in v if ins[v1] == 0)
res = []
ans = 0
before = []
while q:
    v1 = q.popleft()
    res.append(v1)
    a, b = get_ab(v1)
    if (a in before) or (b in before):
        before = [a, b]
        ans += 1
    else:
        before.append(a)
        before.append(b)
    for v2 in outs[v1]:
        ins[v2] -= 1
        if ins[v2] == 0:
            q.append(v2)
if len(res) < (N*(N-1)) // 2:
    print(-1)
else:
    print(ans+1)


Measured memory_bytes: 174696
#include <bits/stdc++.h>
//#pragma GCC optimize("O3")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
#define pb push_back
#define IOS                                                                    \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0);                                                                  \
  cout.tie(0);cout<<fixed<<setprecision(16);
#define ll long long int
#define ld long double
#define el '\n'
#define El '\n'
#define PI (ld)3.141592653589793238462643383279502884197169399375105820974944
#define inf (ll)1000000000
#define mod (ll)1000000007
#define mod1 (ll)998244353
#define fo(i, n) for (long long i = 0; i < n; i++)
#define pll pair<ll, ll>
#define ml map<ll,ll>
#define vpl vector<pll>
#define vvl vector<vector<ll> >
#define vvpl vector< vector<pll> >
#define ff first
#define ss second
#define pqueue priority_queue< ll >
#define pdqueue priority_queue< ll,vl ,greater< ll > >
#define mem(a,b) memset(a,b,sizeof(a));
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define sz(a) (ll)a.size()
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fd(i,a,b) for(ll i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define vl vector<ll>
//#define x ff
//#define y ss
#define pt(a) for(auto it:a)cout<<it<<" ";cout<<endl;
unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
using namespace std;

// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << t<<" "; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << v.first << " " << v.second ; }

double gcd(double a, double b) { return a < 0.01 ? b : gcd(fmod(b, a), a); }

long long bpow(long long a, long long b, long long m) {
  a %= m;
  long long res = 1;
  while (b > 0) {
    if (b & 1)

      res = res * a % m;
      a = a * a % m;
      b >>= 1;
  }
  return res;
}


ll kv;
ll t,n,x,y,h,k,z,p,q,w,r;
string s,s1,s2;
vl v,a;
//vl vis,d;
ll dp[500][500];

ll sg(ll x,ll y){
    if(dp[x][y]!=0)return dp[x][y];
    if(x==y)return dp[x][y]=0;
    dp[x][y]=sg(x+1,y)+a[y+1]-a[x];
    for(int i=1;i<y-x;i++)dp[x][y]=min(dp[x][y],a[y+1]-a[x]+sg(x,x+i)+sg(x+i+1,y));
    //cout<<x<<" "<<y<<" "<<dp[x][y]<<el;
    return dp[x][y];
}

int main() {
    IOS;
    cin>>n;
    v.resize(n);cin>>v;
    a.resize(n+1,0);
    fo(i,n)a[i+1]=a[i]+v[i];
    cout<<sg(0,n-1);
    return 0;
}



Measured memory_bytes: 1920
#include<stdio.h>
int main(void)
{
  int n;
  scanf("%d",&n);
  int a[n];
  for(int i=0;i<n;i++)
  {
    scanf("%d",&a[i]);
  }
  int min;
  int temp;
  int count=0;
  for(int i=0;i<n;i++)
  {
    min=i;
    for(int j=i;j<n;j++)
    {
      if(a[j]<a[min])
      {
        min=j;
      }
    }
  	if(a[min]<a[i])
  	{
  		temp=a[i];
        a[i]=a[min];
        a[min]=temp;
        count++;
  	}
  }
  for(int i=0;i<n-1;i++)
  {
    printf("%d ",a[i]);
  }
  printf("%d",a[n-1]);
  printf("\n");
  printf("%d\n",count);
  return 0;
}



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

using namespace std;

#define ll long long

int main()
{
	ll A, B, K;
	cin >> A >> B >> K;

	A -= K;
	if (A < 0) {
		B += A;
	}

	cout << max((ll) 0, A) << " " << max((ll) 0, B) << endl;

	return 0;
}


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

int main(){
  int a, b, c, i;
  cin >> a >> b >> c;
  int k;
  cin >> k;
  for ( i = 0 ; i < k ; i++ ){
    if (a >= b && a >= c )
      a = a * 2;
    else if (b >= a && b >= c)
      b = b * 2;
    else
      c = c * 2;
  }
  cout << a + b + c << endl;  
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <algorithm>    
#include <vector>       
#include <set>
#include <utility>  
#include <cstring>
#include <stdio.h>
#include <limits.h>
#include <queue>
#include <algorithm> 
#define MAX_DOUBLE  40000000000.0 
#include <math.h> 
#include <unistd.h>

using namespace std;

long long res[110][100100];


long long min(long long a, long long b){
	if(a > b) return b;
	return a;
}

long long max(long long a, long long b){
	if(a < b) return b;
	return a;
}

int main(){
	vector<long long> vec;
	int n,k;
	cin>>n>>k;
	for(int i =0; i<n; i++){
		int a;
		cin>>a;
		vec.push_back(a);
	}
	
	long long mod = 1e9+7;
	for(int i = 0; i<n; i++){
		for(int j = 0; j<=k; j++){
			if(i == 0){
				if(vec[i]>=j)
					res[i][j] = 1;
			}else{
				res[i][j] += res[i][j-1] + res[i-1][j];
				if(vec[i]<j) res[i][j] -=  res[i-1][j-vec[i]-1];
			}
			
			res[i][j] = (res[i][j]+mod) % (mod);
		}
	}	
	
	cout<<(res[n-1][k]+mod) % (mod);
}


Measured memory_bytes: 80128
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
using PLL = pair<LL, LL>;
using VI = vector<int>;
using VVI = vector<vector<int>>;
const int INF = 1e9;
const int MXN = 0;
const int MXV = 0;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define FOR(i, L, R) for (int i = L; i < (int)R; ++i)
#define FORD(i, L, R) for (int i = L; i > (int)R; --i)
#define IOS                                                                    \
    cin.tie(nullptr);                                                          \
    cout.tie(nullptr);                                                         \
    ios_base::sync_with_stdio(false);

int main()
{
    // IOS;
    int n;
    cin >> n;
    VVI data(3, VI(n + 5)), dp(3, VI(n + 5));
    FOR(i, 0, n) { cin >> data[0][i] >> data[1][i] >> data[2][i]; }
    FOR(i, 0, 3)
    {
        fill(dp[i].begin(), dp[i].end(), 0);
        dp[i][0] = data[i][0];
    }

    FOR(i, 1, n) FOR(j, 0, 3)
    {
        FOR(k, 0, 3) if (j != k)
        {
            dp[j][i] = max(dp[j][i], dp[k][i - 1] + data[j][i]);
        }
        // printf("%d,%d=%d\n", j, i, dp[j][i]);
    }
    cout << max({dp[0][n - 1], dp[1][n - 1], dp[2][n - 1]}) << '\n';
}


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

long long mem[512][512], mod = 1000000007;
long long a[512], b[512], n, prePow[512][512];

long long pow2( long long x, long long st ) {
    long long ret = 1;
    while ( st ) {
        if ( st &1 ) {
            ret *= x;
            ret %= mod;
        }

        st /= 2;
        x *= x;
        x %= mod;
    }
    return ret;
}
long long presp[512][512];

long long sumPows ( int ind, int st ) {
    if ( presp[ind][st] ) { return presp[ind][st]; }

    int s = a[ind];
    int f = b[ind];

    long long ret = 0;
    for ( int i = s ; i <= f ; i ++ ) {
        ret += prePow[ i][ st ];
        if ( ret >= mod ) { ret -= mod; }
    }
    presp[ind][st] = ret;
    return ret;
}

long long solve ( int ind, int c ) {
    if ( mem[ind][c] ) { return mem[ind][c]-1; }
    if ( ind == n ) {
        if ( c == 0 ) { return 1; }
        return 0;
    }

    long long ret = 0;
    for ( int i = 0 ; i <= c; i++ ) {
        ret += solve ( ind+1, c-i )*sumPows( ind, i ) %mod;
        if ( ret >= mod ) { ret -= mod; }
    }
    mem[ind][c] = ret +1;
    return ret;
}

int main () {
    for ( int i = 1 ; i <= 400 ; i ++ ) {
        for ( int st = 0 ; st <= 400 ; st ++ ) {
            prePow[i][st] = pow2( i, st );
        }
    }


    int c;
    cin >> n >> c;
    for ( int i = 0 ; i < n ; i ++ ) { cin >> a[i]; }
    for ( int i = 0 ; i < n ; i ++ ) { cin >> b[i]; }

    cout << solve ( 0, c ) << "\n";

    return 0;
}


Measured memory_bytes: 6016
///**Bismillahir Rahmanir Rahim.**

#include <bits/stdc++.h>
#define clr(a, v)             memset(a, v, sizeof a)
#define all(v)                v.begin(), v.end()
#define ast(v)                sort(v.begin(),v.end())
#define dst(v)                sort(v.begin(),v.end(), greater <int> ())
#define fast ios_base::       sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ass(tmp, v)           tmp.assign(v.begin(), v.end())
#define mid(b, e)             (b+e)/2
#define left(node)            node*2
#define right(node)           node*2+1
#define rep(i, l, r)          for (int i = l; i < r; i++)
#define rep2(i, l, r)         for (int i = l-1; i >= r; i--)
#define sf(n)                 scanf("%d", &n)
#define sff(n, m)             scanf("%d %d",&n,&m)
#define sfl(n)                scanf("%lld", &n)
#define sffl(n, m)            scanf("%lld %lld",&n,&m)
#define sfff(n, m, o)         scanf("%d %d %d",&n,&m, &o)
#define pf(n)                 printf("%d", n)
#define sp                    printf(" ")
#define nl                    printf("\n")
#define prln(n)               printf("%d\n", n)
#define pfl(n)                printf("%lld", n)
#define pb                    push_back
#define pii                   pair<int,int>
#define mp                    make_pair
#define S                     second
#define F                     first
#define PI                    3.1415926

struct greaters
{
    bool operator()(const long& a, const long& b) const
    {
        return a > b;
    }
};

//-----------------------------------***********************----------------------------------------------//

typedef long long int ll;
typedef unsigned long long int ull;
using namespace std;
const int N = 200050;
const int mod = 1e9+7;

void reset(){

}

int main(){
    //freopen("test.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    fast;
    int tc = 1, cas = 0;
    while(tc--){
      //reset();
	  ll n; cin >> n; n--;
	  cout << (n*(n+1))/2 << '\n';

      ///printf("Case %d: %lld\n", ++cas, ans);
    }
    return 0;

}

//-----------------------------------***********************----------------------------------------------//



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, start, n) for (ll i = (ll)(start); i < (ll)(n); ++i)
static const ll INFTY = 1L << 62L;
ll solver(ll n,ll k)
{
    ll ans=(n/k)*(n/k)*(n/k);
    if(k%2!=0){
        return ans;
    }
    else
    {
        ll a=(n/(k/2))-(n/k);
        return ans+a*a*a;
    }
    
}
int main()
{
cin.tie(0);
ios::sync_with_stdio(false);
ll n,k;
cin>>n>>k;
cout<<solver(n,k)<<endl;
}

Measured memory_bytes: 3660
import qualified Data.Map as M

main = do
  li <- getLine
  let n = read li
  s <- getLine
  let ans = compute n s
  print ans

{-
より数学チックに書きたいから書く
左はカウントする意味すらない。Setでいい。
-}

compute :: Int -> String -> Int
compute n s = maximum $ map comCnt $ scanl step (l0,r0) s
  where
    l0 = M.empty
    r0 = M.fromListWith (+) [ (c,1) | c <- s ]
    step (lm,rm) c = (M.insert c () lm, M.update decl c rm)
    decl 1 = Nothing
    decl n = Just (pred n)
    comCnt = M.size . uncurry (M.intersectionWith const)


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

struct Card {char suit, value;}; //クラスの定義(suit:絵柄、value:数字)

void BubbleSort(struct Card c[], int n){
    for(int i = 0; i < n; i++){
        for(int j = n - 1; j > i; j--){
            if(c[j].value < c[j - 1].value){ //.valueはカードの数字部分をみることを表す
                Card tmp = c[j];
                c[j] = c[j - 1];
                c[j - 1] = tmp;
            }
        }
    }
}

void SelectionSort(struct Card c[], int n){
    for(int i = 0; i < n; i++){
        int minj = i;
        for(int j = i; j < n; j++){
            if(c[j].value < c[minj].value) minj = j;
        }
        Card tmp = c[i];
        c[i] = c[minj];
        c[minj] = tmp;
    }
}

//ソート済みのカードを出力
void print(struct Card c[], int n){
    for(int i = 0; i < n; i++){
        if(i == 0) cout << c[i].suit << c[i].value;
        else cout << " " << c[i].suit << c[i].value;
    }
    cout << endl;
}

// バブルソートと選択ソートの結果を比較
bool isStable(struct Card c1[], struct Card c2[], int n){
    for(int i = 0; i < n; i++){
        if(c1[i].suit != c2[i].suit) return false;
        /*バブルソートは常に安定だから、もし選択ソートにより並び替えられた、
        バブルソートと同番目の要素の絵柄が異なっていると、安定でないことがわかる*/
    }
    return true;
}

int main(){
    Card card1[50], card2[50];
    int N;

    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> card1[i].suit >> card1[i].value;
    }

    for(int i = 0; i < N; i++) card2[i] = card1[i]; //同じ並びのものをもうひとつ作る（比較するため）

    BubbleSort(card1, N);
    SelectionSort(card2, N);
    
    print(card1, N);
    cout << "Stable" << endl;

    print(card2, N);
    if(isStable(card1, card2, N)) cout << "Stable" << endl;
    else cout << "Not stable" << endl;

    return 0;
}



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

ll f(ll a, ll x){
  ll n = a/x+1;
  if (a < 0) return 0;
  else return n;
}

int main(){
  ll a,b,x;
  cin >> a >> b >> x;
  ll ans = f(b,x);
  
  cout << f(b,x)-f(a-1,x) << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n,v) rep(i,n) cin >> v[i]
using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
// const lint MOD = 998244353;
int x_pos[4] = {1,0,-1,0}, y_pos[4] = {0,1,0,-1};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
char upper(char c){
	return c-0x20;
}
char lower(char c){
	return c+0x20;
}

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

int main(){
	int a,b,c,x,y; cin>>a>>b>>c>>x>>y;
	int cost = 0;
	if (a+b >= c*2){
		if (x>=y){
			cost += y*c*2;
			x -= y;
			y = 0;
		}else{
			cost += x*c*2;
			y -= x;
			x = 0;
		}
	}else{
		if (x>=y){
			cost += y*(a+b);
			x -= y;
			y = 0;
		}else{
			cost += x*(a+b);
			y -= x;
			x = 0;
		}
	}
	if (x){
		if (a >= c*2){
			cost += c*2*x;
		}else{
			cost += a*x;
		}
	}else{
		if (b >= c*2){
			cost += c*2*y;
		}else{
			cost += b*y;
		}
	}
	cout << cost << endl;
 }


Measured memory_bytes: 256
/*#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
#include<bits/stdc++.h>
#define ll long long
#define inf 1000000005
#define put putchar('\n')
#define F(i,a,b) for (int i=(a);i<=(b);i++)
#define D(i,a,b) for (int i=(a);i>=(b);i--)
#define go(i,t) for (int i=head[t];i;i=Next[i])
#define sqr(x) ((x)*(x))
#define re register
#define mp make_pair
#define fi first
#define se second
#define pa pair<int,int>
#define pb push_back
#define be begin()
#define en end()
#define ret return puts("No"),0;
#define mod 1000000007
#define N 500055
//#define int ll
using namespace std;
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read(){char c=getchar();int tot=1;while ((c<'0'|| c>'9')&&c!='-') c=getchar();if (c=='-'){tot=-1;c=getchar();}
int sum=0;while (c>='0'&&c<='9'){sum=sum*10+c-'0';c=getchar();}return sum*tot;}
inline void wr(int x){if (x<0) {putchar('-');wr(-x);return;}if(x>=10)wr(x/10);putchar(x%10+'0');}
inline void wrn(int x){wr(x);put;}inline void wri(int x){wr(x);putchar(' ');}
inline void wrn(int x,int y){wri(x);wrn(y);}inline void wrn(int a,int b,int c){wri(a);wrn(b,c);}
int n,m,a[N],tot;
struct xx{
	int x,i;
}z[N];
bool cmp(xx a,xx b){
	return a.x<b.x;
}
signed main(){
	n=read();
	F(i,1,n){
		z[i].x=read();z[i].i=i;
	}
	sort(z+1,z+n+1,cmp);
	F(i,1,n){
		if (z[i].x==z[i-1].x) ret;
		a[z[i].x]=z[i].i;
		F(j,1,z[i].i-1){
			tot++;
			while (a[tot]) tot++;
			a[tot]=z[i].i;
		}
		if (tot>z[i].x) ret;
	}
	tot=n*n+1;
	D(i,n,1){
		F(j,1,n-z[i].i){
			tot--;
			while (a[tot]) tot--;
			a[tot]=z[i].i;
		}
		if (tot<z[i].x) ret;
	}
	puts("Yes");
	F(i,1,n*n) wri(a[i]);
	return 0;
}

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

typedef long long int ll;
typedef long double ld;

//****************************************************                
#define lp(var,start,end) for (ll var = start; var <end ; ++var)
#define rlp(var,start,end) for(ll var = start; var>=end ; var--)
#define pb push_back
#define mp make_pair
#define pf push_front
#define ff first
#define ss second
#define vll vector<ll>
#define pll pair<ll,ll> 
#define vpll vector<pll>
#define all(X) X.begin(),X.end()
#define endl "\n" //comment it for interactive questions
#define trace1(a) cerr << #a << ": " << a << endl;
#define trace2(a,b) cerr << #a << ": " << a << " " << #b << ": " << b << endl;
#define trace3(a,b,c) cerr << #a << ": " << a << " " << #b << ": " << b << " " << #c << ": " << c << endl;
#define trace4(a,b,c,d) cerr << #a << ": " << a << " " << #b << ": " << b << " " << #c << ": " << c << #d << ": " << d << endl;
#define OC freopen("input.txt" , "r", stdin); freopen("output.txt" , "w", stdout) 
#define MOD (ll)1e9+7;
#define PI 3.14159265 //change it for other mods
#define FAST_IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
        //*******************************************************
//Some Functions

ll powmod(ll a,ll b)
{
   ll res = 1;
   while(b > 0) {
      if(b & 1) res = (res * a) % MOD;
      a = (a*a)%MOD;
      b = b >> 1; 
  }
  return res % MOD;
}

void solve()
{
    double a,b,x;
    cin >> a >> b >> x;
    double h = 2*(b - (x/(a*a)));
    if(h == 0) {
    	cout << 0 << "\n";
    	return;
    }
    if(h > 0 && h < b) {
    	cout << fixed << setprecision(8) << ((atan(h/a) * 180) / PI) << "\n";
    	return;
    }
    double k = (2*x)/(a*b);
    // cout << k << "\n";
    cout << fixed << setprecision(8) << atan(b/k) * 180/PI << "\n";
}

int main()
{
    FAST_IO;
    // #ifndef ONLINE_JUDGE 
    //   OC;
    // #endif
    ll t = 1;
    // cin >> t;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 256
N = int(input())
ans1 = 0
ans2 = 0
ans3 = 0
ans4 = 0
for i in range(N):
  s = input()
  if s[0] == "A":
    ans1 += 1
  elif s[0] == "W":
    ans2 += 1
  elif s[0] == "T":
    ans3 += 1
  elif s[0] == "R":
    ans4 += 1
    
print("AC x "+str(ans1))
print("WA x "+str(ans2))
print("TLE x "+str(ans3))
print("RE x "+str(ans4))

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

import java.util.Arrays;
import java.util.Collections;
import java.util.ArrayList;
import java.util.List;
import java.util.HashSet;
import java.io.PrintWriter;
import java.io.OutputStream;
import java.util.Comparator;
import java.util.Set;
import java.util.HashMap;

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

    // 標準入力数値配列用 int
    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;
    }

    // 標準入力数値リスト用 int
    static List<Integer> inputIntList() throws Exception {
        List<String> strList = Arrays.asList(br.readLine().trim().split(" "));
        List<Integer> intList = new ArrayList<Integer>();
        for (String elem : strList){
            intList.add(Integer.parseInt(elem));
        }
        return intList;
    }

    // 標準入力数値配列用 integer 降順ソート用
    static Integer[] inputvalInteger() throws Exception {
        String[] strarray = br.readLine().trim().split(" ");
        Integer[] intarray = new Integer[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 n = Integer.parseInt(br.readLine());
        HashMap<String,Integer> map = new HashMap<String,Integer>();
        for(int i=0; i<n; i++){
            String line = br.readLine().trim();
            if (map.get(line) == null){
                map.put(line,1);
            }else{
                map.replace(line,map.get(line)+1);
            }
        }
        int m = Integer.parseInt(br.readLine());
        for(int i=0; i<m; i++){
            String line = br.readLine().trim();
            if (map.get(line) != null){
                map.replace(line,map.get(line)-1);
            }
        }
        int max = map.values().stream().max(Comparator.naturalOrder()).get();
        System.out.println(Math.max(max, 0));

    }

}



Measured memory_bytes: 33600
#include <algorithm>
#include <climits>
#include <iostream>
#include <vector>

using namespace std;

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

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

    int min = R[0];
    vector<int> v(n, INT_MIN);
    for (int i = 1; i < n; ++i) {
        v[i] = max(v[i - 1], R[i] - min);
        if (min > R[i])
            min = R[i];
    }
    cout << v[n - 1] << '\n';
}



Measured memory_bytes: 4424
<?php
$coin_500 = trim(fgets(STDIN));
$coin_100 = trim(fgets(STDIN));
$coin_50 = trim(fgets(STDIN));
$price = trim(fgets(STDIN));
$count = 0;

for($i=0;$i<=$coin_500;$i++) {
  for($j=0;$j<=$coin_100;$j++) {
	for($k=0;$k<=$coin_50;$k++) {
      $sum = $i*500 + $j*100 + $k*50;
      if($sum == $price) {
        $count++;
      }
    }
  }
}

echo $count;

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = (int)(n); i >= 0; i--)
#define repm(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define repmr(i, m, n) for(int i = (int)(n); i >= (int)(m); i--)
#define all(x) (x).begin(),(x).end()
#define inf 2e9

using namespace std;
typedef long long int lli;
typedef long long ll;

int main() {
    char c;
    cin >>c;

    if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') cout << "vowel" << endl;
    else cout << "consonant" << endl;
}


Measured memory_bytes: 256