akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX
#define INFL LLONG_MAX
typedef long long ll;
using namespace std;
int main(){
  int n; string s;
  cin >> n >> s;

  rep(i,s.size())  cout << (char)(((int)(s.at(i)-'A'+n))%('Z'-'A'+1)+'A');

}


Measured memory_bytes: 3632
# coding: utf-8
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, K = lr()
P = np.array(lr())
P = np.hstack([[0], P+1])
Pcum = P.cumsum()
result = Pcum[K:] - Pcum[:-K]
answer = result.max()
print(answer / 2)


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    string s;cin >>s;
    string ans="";
    int n=s.size();
    for (int i = 0; i < n; ++i) {
        if(s[i]=='B'){
            if(!ans.empty()) {
                ans.pop_back();
            }
        }
        else ans+=s[i];
    }
    cout <<ans <<endl;
    return 0;
}


Measured memory_bytes: 3576
mod = 998244353

n, s = map(int, input().split())
a = list(map(int, input().split()))

a.sort()

while a[-1] > s:
    a.pop(-1)
    if a == []:
        print(0)
        exit()

dp = [0] * (s + 1)
dp[0] = 1
for i in a:
    newdp = [2 * j for j in dp]
    for j in range(s - i + 1):
        newdp[j+i] += dp[j]
    dp = newdp

print(dp[s] * pow(2, n - len(a), mod) % mod)

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

int main() {
  char S;
  cin >> S;
  string ans;
  if (S == 'a'|S == 'e'||S == 'i'||S == 'o'||S == 'u') ans = "vowel";
  else ans = "consonant"; 
  cout << ans << endl;
}


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

namespace contest_Csharp
{
    class Program
    {


        static void Main(string[] args)
        {
            checked
            {
                var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
                Console.SetOut(sw);

                var vals = Console.ReadLine().Split(' ').
                    Select(x => int.Parse(x)).ToList();

                var N = vals[0];
                var K = vals[1];
                //var B = vals[2];
                //var K = int.Parse(Console.ReadLine());
                var A = Console.ReadLine().Split(' ').
                    Select(x => int.Parse(x)).ToList();
                
                for (int i = 0; i < N-K; i++)
                {
                    var ans = (A[K + i] > A[i]) ? "Yes" : "No";
                    Console.WriteLine(ans);
                }
                //Console.WriteLine(ans);







                Console.Out.Flush();
            }




        }
    }
}




Measured memory_bytes: 46292
q, h, s, d = map(int, input().split())
n = int(input())
min_2l = min(8*q, 4*h, 2*s, d)
min_1l = min(4*q, 2*h, s)
if n % 2 == 0:
  cost = (n // 2) * min_2l
else:
  cost = (n // 2) * min_2l + min_1l
print(cost)

Measured memory_bytes: 3064
//12/04/2020
#include<bits/stdc++.h>
#include<cmath>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define debug printf("Debug\n");
#define en '\n'


#define ll long long
#define ull unsigned long long

#define pi acos(-1.0)
#define mod 1000000007

#define _fastio  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define in_fre  freopen("in.txt", "r", stdin);
#define out_fre freopen("out.txt", "w", stdout);

struct Node{
    ll val,pos;
};
struct OverloadedNode{
    ll val,pos;
    bool operator < (const OverloadedNode &rhs) const {
        if(val==rhs.val) return pos<rhs.pos;
        else return val<rhs.val;
    }
};
//Algos
template<typename T> using Pbds=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
//typedef tree<OverloadedNode,null_type,less<OverloadedNode>,rb_tree_tag,tree_order_statistics_node_update>OverloadedPbds;

//Number Theory
template <typename T> T BigMod (T b,T p,T m){if (p == 0) return 1;if (p%2 == 0){T s = BigMod(b,p/2,m);return ((s%m)*(s%m))%m;}return ((b%m)*(BigMod(b,p-1,m)%m))%m;}
template <typename T> T ModInv (T b,T m){return BigMod(b,m-2,m);}
template <typename T> T gcd(T a,T b){if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
template <typename T> T lcm(T a,T b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}

//Geometry
template <typename T> T Dis(T x1,T y1,T x2, T y2){return sqrt( SQR(x1-x2) + SQR(y1-y2) );}
template <typename T> T Angle(T x1,T y1,T x2, T y2){ return atan2( double(y1-y2) , double(x1-x2));}


/*Containers*/
//vector<ll>v;
//deque<ll>dq;
//stack<ll>stk;
//map<ll,ll>mp;
//unordered_map<ll,ll>ump;
//set<ll>st;
//multiset<ll>mst;
//unordered_set<ll>ust;
//unordered_multiset<ll>umst;
//priority_queue<ll,deque<ll>,greater<ll>>pq;
//Pbds<ll>ost;
/*OverLoaded Containers*/
//vector<OverloadedNode>v;
//deque<OverloadedNode>dq;
//stack<OverloadedNode>stk;
//map<OverloadedNode,OverloadedNode>mp;
//set<OverloadedNode>st;
//multiset<OverloadedNode>mst;
//priority_queue<OverloadedNode>pq;
//OverloadedPbds oost;
/*Global Variables*/

ll dp[205][205][205];

int main(){
    _fastio
    ll k;
    cin>>k;
    ll ans=0;
    for(ll i=1;i<=k;i++){
        for(ll j=1;j<=k;j++){
            for(ll m=1;m<=k;m++){
                ll x=__gcd(i,j);
                x=__gcd(x,m);
                ans+=x;
            }
        }
    }
    cout<<ans<<en;



    return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define line cout<<"\n"
#define ci std ::cin
#define co std ::cout
#define sf(n) scanf("%d",&n);
#define sff(n,m) scanf("%d%d",&n,&m);
#define pf(n) printf("%d",n);
#define n_line printf("\n");
#define cas(n) printf("Case %d: ",n++);
#define task return
#define loop(x,n)  for(int x = 0 ; x < n ; x++)
#define constloop(x,a,n) for(int x = a ; x < n ; x++)
#define revloop(x,a,n)  for(int x = a ; x >= n ; x--)
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define pi acos(-1)
#define mx 10000000
ll P[mx+5],cnt=1;
bool nP[mx+5];
void sieve(void)
{
    P[0]=2;
    nP[0]=true;
    nP[1]=true;
    for(ll i=3 ; i<=mx ; i+=2)
    {
        if(nP[i]==true)
            continue;
        for(ll j=i+i ; j<=mx ; j+=i)
            nP[j]=true;
        P[cnt++]=i;
    }
}
void solve()
{
    //Code here
 	double n,x,t;
 	cin>>n>>x>>t;
 	ll value=ceil(n/x)*t;
 	cout<<value;
 	line;
}
int main()
{
	/*freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);*/
	/*ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);*/
	solve();
	return 0;
}

Measured memory_bytes: 3716
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;

#define rep(i,n) for(int i=0; i<((int)n); i++)
#define REP(i,n) for(int i=0; i<=((int)n); i++)
#define srep(i,a,n) for(int i=a; i<((int)n); i++)
#define SREP(i,a,n) for(int i=a; i<=((int)n); i++)
#define rrep(i,n) for(int i=n-1; i>=0; i--)
#define RREP(i,n) for(int i=n; i>=0; i--)
#define INF 1000000
const int mod = INF+7;

int main(){
  int N,K;
  string S;
  cin >> N >> K;
  cin >> S;
  int sum_out=0;
  if(S[0]=='L'){
    sum_out++;
  }
  if(S[N-1]=='R'){
    sum_out++;
  }
  int sum_in=0;
  rep(i,N-1){
    if(S[i]=='R' && S[i+1]=='L'){
      sum_in++;
    }
  }

  int ans;
  if(sum_in>=K){
    ans=(sum_in-K)*2+sum_out;
  }
  else{
    ans=1;
  }

  printf("%d\n", N-ans);

}


Measured memory_bytes: 512
#include <algorithm>
#include <iostream>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

ll MOD = 1e9 + 7;

int main(){
  ll N, M, nm;
  cin >> N >> M;
  nm = N * M;

  ll cnta[nm + 1];
  ll cntb[nm + 1];
  fill(cnta, cnta + nm + 1, 0);
  fill(cntb, cntb + nm + 1, 0);
  ll a[nm + 1]; //i以上の数の個数
  ll b[nm + 1]; //i以上の数の個数
  fill(a, a + nm + 1, 0);
  fill(b, b + nm + 1, 0);

  for(int i = 0; i < N; i++){
    int t;
    cin >> t;
    cnta[t]++;
    a[t]++;
  }
  for(int i = 0; i < M; i++){
    int t;
    cin >> t;
    cntb[t]++;
    b[t]++;
  }

  for(int i = nm; i > 0; i--){
    a[i - 1] += a[i];
    b[i - 1] += b[i];
  }

  /*
  //debug
  for(int i = 0; i <= nm; i++){
    cout << cnta[i] << " ";
  }
  cout << endl;
  for(int i = 0; i <= nm; i++){
    cout << cntb[i] << " ";
  }
  cout << endl;
  for(int i = 0; i <= nm; i++){
    cout << a[i] << " ";
  }
  cout << endl;
  for(int i = 0; i <= nm; i++){
    cout << b[i] << " ";
  }
  cout << endl;
  */

  ////////////////////////////////////////////////////////////////////
  ll ans = 1;
  for(int i = nm; i > 0; i--){
    if(cnta[i] == 0 && cntb[i] == 0){
      ans *= (a[i] * b[i]) - (nm - i);
      ans %= MOD;
    }
    else if(cnta[i] == 1 && cntb[i] == 0){
      ans *= b[i];
      ans %= MOD;
    }
    else if(cnta[i] == 0 && cntb[i] == 1){
      ans *= a[i];
      ans %= MOD;
    }
    else if(cnta[i] == 1 && cntb[i] == 1){
      ans *= 1;
      ans %= MOD;
    }
    else{
      ans = 0;
      break;
    }
    //cout << i << " " << ans << endl;
  }

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


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

int main() {
  char b;
  std::cin >> b;

  char ans;
  if(b=='A') ans = 'T';
  if(b=='T') ans = 'A';
  if(b=='G') ans = 'C';
  if(b=='C') ans = 'G';

  std::cout << ans << std::endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    int count[100] = {0};
    int ans[100] = {0};
    int n,j,c = 0,i = 0,max = 0;
    int temp;

    for(i = 0;scanf("%d",&n) != EOF;i++){
        count[n]++;
    }
    for(i = 0; i < 100; i++){
        if(count[i] > max) max = count[i];
    }
    for(i = 0; i < 100; i++){
        if(count[i] == max){
            ans[c] = i;
            c++;
        }
    }

    for(i = 0; i < 100; i++){
        for(j = 0; j < 100; j++){
            if(ans[i] > ans[j]){
                temp = ans[i];
                ans[i] = ans[j];
                ans[j] = temp;
            }
        }
    }
    for(i = c - 1; i >=  0 ; i--){
        printf("%d\n",ans[i]);
    }
    return 0;
}

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

typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef long long ll;

int main()
{
	int n;
	vii vec;
	scanf("%d",&n);
	
	for(int i=0;i<n;i++)
	{
		int a,b;
		scanf("%d %d",&a,&b);
		vec.push_back({a,b});
	}
	sort(vec.begin(),vec.end());
	long long val=vec[n-1].first+vec[n-1].second-0;
	cout<<val<<endl;
	
    return 0;
}



Measured memory_bytes: 1400
#include<stdio.h>
#include<string.h>

#define M 1046527
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){//getKeyで使用
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key%M; }
	int h2(int key){ return 1 +(key %(M-1)); }

int find(char str[]){//１なら発見、０ならなし
	
    /* your task */
	long long key, i, h;
	key = getKey(str);
	for(i = 0;;i++){
		h = (h1(key) + i*h2(key)) %M;
		if(strcmp(H[h], str) ==0)return 1;
		else if(strlen(H[h]) == 0)return 0;
	}
return 0;
}

int insert(char str[]){
	
    /* your task */
	long long key, i, h;
	key = getKey(str);
	for(i = 0;;i++){
		h = (h1(key) + i*h2(key)) %M;
		if(strcmp(H[h], str) ==0)return 1;
		else if(strlen(H[h]) == 0){
			strcpy(H[h], str);
			return 0;
		}
	}
return 0;

}

int main(){
    int i, n, h;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';
    
    scanf("%d", &n);
    
    for ( i = 0; i < n; i++ ){
	scanf("%s %s", com, str);
	
	if ( com[0] == 'i' ){
	    insert(str);
	} else {
	    if (find(str) == 1){
		printf("yes\n");
	    } else {
		printf("no\n");
	    }
	}
    }

    return 0;
}


Measured memory_bytes: 16052
#include <iostream>
// #include <cassert>
#include <vector>
#include <algorithm>
#include <climits>

#include <stack>
#include <queue>
// #include <deque>
// #include <set>
// #include <map>
// #include <string>
// #include <unordered_set>
// #include <unordered_map>

#include <tuple>
// #include <cmath>
// #include <numeric>

using namespace std;


typedef long long ll;
typedef pair<long,long> pll;
typedef pair<int,int> pii;
typedef pair<int,long> pil;
typedef pair<long,int> pli;
typedef pair<long long, long long> pllll;
typedef pair<long long, int> plli;
typedef pair<int,long long> pill;
typedef vector<vector<long long>> vvll;
typedef vector<vector<long>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<long long> vll;

#define emplace_back pb
const char el = '\n';

/*
Edge cases:


*/

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

    int n; cin>>n; cin.ignore();

    cout<<(n+1)/2<<el;

}

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

int main() {
	string s, out; cin >> s;
	out += s.substr(0,1);
	out += to_string(s.size() - 2);
	out += s.substr(s.size() - 1,1);
	cout << out << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i=0; i<N; i++) {
        cin >> A.at(i);
    }
    
    int ans = 0;
    
    for (int i=0; i<N; i++) {
        if (A.at(i) % 2 == 0) {
          if (A.at(i) % 3 == 0 || A.at(i) % 5 == 0) {
              ans = 0;
          } else {
              ans = 1;
              break;
          }
        } else {
            ans = 0;
        }
    }
    
    if (ans == 0) {
        cout << "APPROVED" << endl;
    } else {
        cout << "DENIED" << endl;
    }
}


Measured memory_bytes: 256
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <cctype>
#include <iostream>
#include <set>
#include <string>
#include <queue>
#include <map>
using namespace std;
int size(string x){
	string::size_type size=x.size();
	return size;
}
#define fu(l,k) for(int i=l;i<k;i++)
#define fd(l,k) for(int i=l;i>k;i--)
#define fi first
#define se second
typedef  vector<string> vs;
typedef  vector<int> vi;
double pi(){
	return M_PI;
}
typedef set<int> set_i;
typedef set<string> set_s;
int INF=1000000;
int main(){
	int n,ans,ss,a2,a5,is;
	while(1){
		ss=1;
		a5=0;
		a2=0;
		cin>>n;
		if(n==0) break;
		fd(n,0){
			is=i;
			while(1){
				if(is%5==0){
					a5++;
					is=is/5;
				}
				else break;
			}
			while(1){
				if(is%2==0){
					a2++;
					is=is/2;
				}
				else break;
			}
		}
		if(a5>=a2) cout<<a2<<endl;
		else cout<<a5<<endl;
	}
}

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

vector<vector<P>> G;
vector<int> res;

void dfs(int v,int p,int c){//v 今の頂点　p vの親　c vに塗るカラー
  res[v]=c;//vに塗った
  for(auto e : G[v]){//そのvに対してつながっている頂点を全部見る
    if(e.first==p)continue;//それが親だった場合はじく
    if(e.second&1)dfs(e.first,v,1-c);//ビットで奇数だった場合判定 見た頂点をbfs再帰する 親は今の頂点
    else dfs(e.first,v,c);
  }
}

int main() {
  int n;
  cin >>n;
  G.assign(n, vector<P>());
  rep(i,n-1){
    int u,v,w;
    cin>>u>>v>>w;
    --u;--v;//配列に合わせる処理
    G[u].push_back(P(v,w));//uとつながるvを配列
    G[v].push_back(P(u,w));
  }
  res.assign(n,0);
  dfs(0,-1,1);
  for(auto v:res) cout <<v<<endl;
}

Measured memory_bytes: 11660
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stdio.h>
#include <stdlib.h>

using namespace std;
//DP用
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 long long INF = 1LL << 60;

int count(int i,int c) {
    if(i % c == 0) {
        return i/c;
    }else {
        return i/c+1;
    }
}

int main() {
    int n;
    cin >> n;
    for(int i = 1; i <= 9; i++) {
        for(int j = 1; j <= 9; j++) {
            if(i*j == n) {
                cout << "Yes";
                return 0;
            }
        }
    }
    cout << "No";
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
typedef long long int ll;
using namespace std;
#define P 1000000007
#define rep(i,n) for(i=0;i<n;++i)
#define repp(i,a,n) for(i=a;i<n;++i)
#define repr(i,a,n) for(i=a;i>=n;--i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second

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

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

ll modInverse(ll n, ll p)
{
    return binpowmod(n, p-2, p);
}

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,t,m,i,f=0,j,k,x,r;
    ll ans=0;
    cin >> n >> k ;
    ll temp;
    for(i=k;i<=n+1;++i)
    {
        temp = (i*(n+1-i)+1)%P ;
        //cout << temp << endl ;
        //temp++;
        //temp%=P;
        ans=(ans+temp)%P;
        //cout << ans << endl ;
        
    }
    cout << ans%P ;
    
    return 0;
}

Measured memory_bytes: 3640
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;

double call(int x[], int y[],int n,int i) {
	double D = 0.0;

	for (int k = 0; k < n; k++) {
		D += pow(fabs((x[k] - y[k])), i);
	}

	return pow(D, 1.0 / i);
}

int main() {
	int n, x[100], y[100], i;

	cin >> n;

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

	double max;
	
	for (i = 0; i < n; i++) {
		int xy = x[i] - y[i];

		xy = fabs(xy);

		if (i == 0)
			max = 1.0*xy;
		else
			if (max < xy)
				max = xy;
	}

	for (i = 1; i <= 3; i++) {
		printf("%lf\n", call(x, y, n, i));
	}
	printf("%lf\n", max);

	return 0;
}

Measured memory_bytes: 1240
#include <bits/stdc++.h>
using namespace std;
//Author: Ezio Sam
/* Shorthands */
#define ll long long
#define pb push_back 
#define mp make_pair
#define sp " "
#define cs "Case "
#define fi first
#define sn second 
#define po(x) x*x
/* STL */
#define vi vector<int>v
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mem(a,n) memset(a, n, sizeof(a));
#define all(x) x.begin(),x.end()
#define alr(x) x.rbegin(),x.rend()
#define sz(x)  (int)x.size()
#define mx(v)  *max_element(v.begin(),v.end())
#define mxi(v) distance(v.begin(),max_element(v.begin(),v.end()))
#define mxa(a) *max_element(a, a.size())
#define r(a) reverse(a.begin(),a.end())
/* loops */
#define fr(i,n)   for(__typeof(n) i=0;i<(n);i++)
#define fn(i,n)   for(__typeof(n)i=1;i<=(n);i++)
#define fa(i,a,n) for(int  i=a;i<=b;i++)
/*Special*/
#define Ezio ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define db(something)  cerr<<#something<<" - "<<something<<"\n";         

int main()
{
  
   Ezio
   ll t,m,n,x,a,b;
   string s;
   
   cin>>t;
   a=b=m=n=0;
   while(t--){
     cin>>s;
     transform(s.begin(),s.end(),s.begin(),::toupper);
     if(s[0]=='A')a++;
     if(s[0]=='W')b++;
     if(s[0]=='T')m++;
     if(s[0]=='R')n++;
   }
   
   cout<<"AC x "<<a<<endl;
   cout<<"WA x "<<b<<endl;
   cout<<"TLE x "<<m<<endl;
   cout<<"RE x "<<n<<endl;
   return 0;
}
    

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define INF 1000000001
//0=48,A=65,a=97

int main() {
    int n,m;cin >> n >> m;
    vector<int> a(n);for(int i=0;i<n;i++) cin >> a[i];
    sort(a.begin(),a.end());
    vector<P> d(m);
    for(int i = 0; i < m; i++) {
        int b,c;cin >> b >> c;
        d[i]=P(c,b);
    }
    sort(d.begin(),d.end());
    reverse(d.begin(),d.end());
    queue<P> q;
    for(int i = 0; i < m; i++) {
        q.push(d[i]);
    }

    int b=0,c=0;
    for(int i = 0; i < n; i++) {

        if(b==0 && q.empty()) break;
        if(b==0){
            P p=q.front();q.pop();
            c=p.first;
            b=p.second;
        }

        if(a[i]<c){
            a[i]=c;
            b--;
        }
        else break;

    }

    ll sum=0;
    for(int i = 0; i < n; i++) {
        sum += a[i];
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 5376
n=int(input())
T=list(map(int,input().split()))
AB=list(map(int,input().split()))
ans=0

for i in range(n):
  ans+=min(T[i]+T[i+1],AB[i])
  T[i+1]=max(0,T[i+1]-max(0,AB[i]-T[i]))
  
print(ans)

Measured memory_bytes: 18624
def main():
    N = int(input())
    H = list(map(int, input().split(" ")))
    tmp = 0
    result = 0
    before = H[0]
    for i in range(1, N):
        if before >= H[i]:
            tmp += 1
        else:
            result = max(result, tmp)
            tmp = 0
        before = H[i]
    print(max(result, tmp))


if __name__ == '__main__':
    main()

Measured memory_bytes: 14252
/*
    飲んだ魔剤で家が建つ。
    created at: 2020-04-12 12:47:37
*/

#include <bits/stdc++.h>
using namespace std;

#define all(x) (x).begin(),(x).end()
#define rev(x) greater<x>()
#define MOD 1000000007
#define INF 1000000000

typedef long long LL;
typedef long double LD;

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

LL modpower(LL n, LL m, LL mod)
{
    if (m == 0) {
        return 1;
    } else if (m % 2 == 0) {
        LL p = modpower(n, m/2, mod);
        return p*p % mod;
    } else {
        return n*modpower(n, m-1, mod) % mod;
    }
}

LL modinv(LL n, LL mod)
{
    return modpower(n, mod-2, mod);
}

LL modcombination(LL n, LL r, LL mod)
{
    LL ret = 1;

    for (int i = 0; i < r; i++) {
        ret *= (n-i);
        ret %= mod;
        ret *= modinv(i+1, mod);
        ret % mod;
    }

    return ret % mod;
}

int gcd(int k, int l)
{
    if (l > 0) return gcd(l, k%l);
    else return k;
}

struct UnionFind
{
    vector<int> par;

    UnionFind(int n) : par(n) {
        for (int i = 0; i < n; i++) par[i] = i;
    }

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

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

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

    int ans = 0;
    for (int i = 1; i <= sqrt(n); i++) {
        ans = i*i;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
S = list(map(int, list(input())))
N = len(S)

# 最終状態は0,1,0,1,...か1,0,1,0,...しかない
END1 = [0]
END2 = [1]

for _ in range(N-1):
    END1.append(END1[-1] ^ 1)
    END2.append(END2[-1] ^ 1)

for idx in range(N):
    END1[idx] = END1[idx] ^ S[idx]
    END2[idx] = END2[idx] ^ S[idx]

print(min(sum(END1),sum(END2)))

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


int main(){ 
    int N;
    cin >> N;
    string S;
    cin >> S;
    string ans = "";
    rep(i,S.size()) {
      int now = S[i] - 'A';
      now = (now + N) % 26;
      char c;
      c = 'A' + now;
      ans += c;
    }

    cout << ans << endl;
}




Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long ll;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())
 
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const ll MOD = (ll)1000000007;//10^9+7
const ll INF2 = (ll)100000000000000000;//10^18


int main() {
    ll N,A;
    cin >>N>>A;
    VI x(N);
    REP(i,N){
        int a;
        cin>>a;
        x[i]=a-A;
    }
    vector<map<ll, ll> > dp(N+1);
    dp[0][0]=1;
    REP(i,N){
        for(int j = -49*N;j<49*N;j++){
            dp[i+1][j]=dp[i][j]+dp[i][j-x[i]];
        }
    }   
    cout<<dp[N][0]-1<<endl;

}


Measured memory_bytes: 16000
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define pi pair<int ,int >
#define pl pair<ll ,ll >
#define pb push_back
#define vl vector <long long int >
#define vi vector <int >
#define vp vector <pi>
#define mod 1000000007
#define eps 1e-9
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define _ <<" "<<
#define forn(x,	n) for(int x = 0; x < n ;++ x) 
#define forn1n(x,n) for(int x = 1; x <= n ;++ x)
#define forn1(x,n) for(int x = 1; x < n ;++ x)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#pragma GCC optimize ("Ofast")
void scan(){}
template<typename F, typename... R> void scan(F &f,R&... r){cin>>f;scan(r...);}
int di_; string dnms_, co_ = ",";
void debug_(){cout<<endl;}
template<typename F, typename... R> void debug_(F &f, R&... r){while(dnms_[di_] != ',')cout<<dnms_[di_++];di_++;cout<<": "<<f<<",";debug_(r...);}
#define debug(...) dnms_=#__VA_ARGS__+co_,di_=0,debug_(__VA_ARGS__)

template<class A, class B> ostream& operator<<(ostream& out, const pair<A, B> &a){
    return out<<"("<<a.first<<","<<a.second<<")";}
template<class A> ostream& operator<<(ostream& out, const vector<A> &a){
	out<<"";for(auto it=a.begin();it!=a.end();it++){if(it!=a.begin())out<<" ";out<<*it;}out<<"";
	return out;}
template<class A, class B> istream& operator>>(istream& in, pair<A,B> &a){in>>a.first>>a.second;return in;}
template<class A> istream& operator>>(istream& in, vector<A> &a){for(A &i:a)in>>i;return in;}

int main(){
	IOS

	int a,b;
	cin>>a>>b;

	if(a>=1&&a<=9&&b>=1&&b<=9)
	{
		cout<<a*b;
	}
	else
		cout<<-1;
 
	return 0;	
}

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

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

  if (A >= 13) {
    cout << B << endl;
  } else if (A >= 6) {
    cout << B/2 << endl;
  } else {
    cout << 0 << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <cstring>
#include <map> 
#include <set>
#include <queue>
#include <iomanip>
#include <sstream>
typedef long long ll;

#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;

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; }

const long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<ll, ll> P;
ll ma = 1000000000 + 7;
ll mx = 1000003;
ll h,n, w,m,t; string s;
ll R, C;
ll sy, sx, gy, gx;
char maze[510][510];
ll dis[20][20];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);
}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
void comb(vector<vector <ll> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j])%ma;
		}
	}
}

ll GetDigit(ll num) {
	return log10(num) + 1;
}
ll Combination(int n, int r)
{
	if (n - r < r) r = n - r;
	if (r == 0) return 1;
	if (r == 1) return n;

	vector<ll> numerator(r);
	vector<ll> denominator(r);

	for (int k = 0; k < r; k++)
	{
		numerator[k] = n - r + k + 1;
		denominator[k] = k + 1;
	}

	for (int p = 2; p <= r; p++)
	{
		int pivot = denominator[p - 1];
		if (pivot > 1)
		{
			int offset = (n - r) % p;
			for (int k = p - 1; k < r; k += p)
			{
				numerator[k - offset] /= pivot;
				denominator[k] /= pivot;
			}
		}
	}

	ll result = 1;
	for (int k = 0; k < r; k++)
	{
		if (numerator[k] > 1) result *= numerator[k];
		result %= ma;
	}

	return result;
}
/*
ll bfs() {
	queue<P> que;
	for (int i = 0; i < R; i++) {
		for (int j = 0; j < C; j++) dis[i][j] = INF;
	}
	que.push(P(sy - 1, sx - 1));
	dis[sy - 1][sx - 1] = 0;

	while (que.size() > 0) {
		P p = que.front();
		que.pop();
		if (p.first == gy - 1 && p.second == gx - 1) break;
		for (ll i = 0; i < 4; i++) {
			ll ny = p.first + dy[i];
			ll nx = p.second + dx[i];
			if (0 <= ny && ny < R && 0 <= nx && nx < C && maze[ny][nx] == '.' && dis[ny][nx] == INF) {
				que.push(P(ny, nx));
				dis[ny][nx] = dis[p.first][p.second] + 1;
			}
		}
	}
	return dis[gy - 1][gx - 1];
}*/
vector<ll> v(100005);
vector<ll> vis(100005, 0); ll c = 0, check = 0;
queue<ll>que;
void bfs(ll a, ll src) {
	vis[a] = src;
	que.push(src);
	while (!que.empty()) {
		src = que.front();
		for (ll x = 1; x <= v[src];x++) {
			if (vis[x] == 0) {
				c++;
				vis[x] = src;
				que.push(x);
			}
		}
		que.pop();
	}
}
int main() {
	ll a, b, c;
	cin >> a >> b >> c;
	ll p = -a - b + c;
	if (p > 0 && p * p > 4 * a * b) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <string.h>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <utility>
#include <queue>
#include <climits>
using namespace std;

#define endl '\n'
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define FORE(i, a, b) for(int i=(a); i<=(b); i++)
typedef pair<int, int> ii;
typedef long long LL;
typedef long double LD;

int k, n;
int a[105];

void solve(){
    priority_queue<ii> q;
	FOR(i, 0, n) {
		q.push(ii(a[i], i));
	}
	
	int res = 0, last = -1;
	while(!q.empty()) {
		int i = q.top().second, x = q.top().first;
		q.pop();
		if(i == last) {
			if(q.empty()) {
				break;
			} else {
				int j = q.top().second, y = q.top().first;
				q.pop();
				res += 2;
				y -= 1; x -= 1;
				last = i;
				if(y) q.push(ii(y, j));
				if(x) q.push(ii(x, i));
			}
		} else {
			res += 1;
			x -= 1;
			last = i;
			if(x) q.push(ii(x, i));	
		}
	}
	cout << k - res << endl;
}

int main(int argc, char *argv[]){
    ios::sync_with_stdio(false);
    std::cin.tie(0);
    while(cin >> k >> n) {
    	FOR(i, 0, n) {
    		cin >> a[i];
    	}	
		solve();
    }
    return 0;
}

Measured memory_bytes: 256
//#define DEBUG
 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
using namespace std;
 
const long long mod = 998244353l;
#define int ll
 
#define BSET(a, p) ((a) | (1ll << (p)))
#define BCHK(a, p) (((a) & (1ll << (p)))>0)
#define BXOR(a, p) ((a) ^ (1ll << (p)));
#define BREM(a, p) (BCHK(a, p)?(BXOR(a, p)):(a))
#define BSHO(a, N) (bitset<N>(a))
 
#define fi first
#define sc second 
#define pb push_back
 
 
#ifdef DEBUG
    #define dbg(s) {s;}
    #define PRELUDE {common();}
#endif
 
#ifndef DEBUG 
    #define PRELUDE { common(); ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); }
    #define dbg(s)
    #define endl "\n"
#endif
 
#define i32 int32_t
 
#define RBTTYPE int
#define ordered_set tree<RBTTYPE, null_type, less<RBTTYPE>, rb_tree_tag,tree_order_statistics_node_update> 
// Ordered set docs:
// order_of_key (k) : Number of items strictly smaller than k .
// find_by_order(k) : K-th element in a set (counting from zero).
 
#define all(v) (v).begin(),(v).end()
 
typedef long long ll;
typedef long double ld;
typedef pair< int, int > pii;
typedef pair< ld, ld > point;
 
istringstream _inp;
string _inps;
 
void common() {
    _inp.clear();
    _inps = "";
    _inp.str(_inps);
}
 
int gi() {
    int x;
    while (true) {
        try {
            while (_inp.peek() == ',' || _inp.peek() == ' ') 
                _inp.ignore();
            if (_inp >> x) 
                return x;
            else throw 6;
        } catch (...) {
            getline(cin, _inps);
            _inp.clear();
            _inp.str(_inps);
        }
    }
}
 
// To remove randomization use 0 below:
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline int ri(int x) { // from [0, n-1]
    return uniform_int_distribution<int>(0, x - 1)(rng);
}
 
inline ld rf() { // from [0, 1]
    return uniform_real_distribution<ld>(0, 1)(rng);
}
 
ll gcd(ll x, ll y) {
    if (x < y) return gcd(y, x);
    if (y == 0) return x;
    return gcd(y, x % y);
} 
  
ll modexp(ll x, ll ex) {
    ll ans = 1ll;
    while (ex > 0) {
        if (ex & 1ll) ans = (ans * x) % mod;
        ex >>= 1ll;
        x = (x * x) % mod;
    }
    return ans;
}
 
 
#define X first
#define Y second
 
const int maxn = 1e6 + 7;
const ll inf = 1e9 + 7;
 
const ld eps = 1e-7;
const ld pi = acosl(-1.0);


i32 main() {    
    PRELUDE;        
 
    int n; cin >> n;
    
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        ans += i * (n - i + 1);
    }

    for (int j = 1; j < n; j++) {
        int l, r; cin >> l >> r;
        if (l > r) swap(l, r);
        ans -= l * (n - r + 1);
    }
    cout << ans << endl;
}


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

int int_len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}

int int_sum(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}

int vec_sum(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}

int main() {
  int n,a,b;
  cin>>n>>a>>b;
  if((b-a)%2==0){
    cout<<"Alice"<<endl;
  }else{
    cout<<"Borys"<<endl;
  }
}


Measured memory_bytes: 256
# N: 夏休みの日数，M: 宿題の数
N, M = list(map(int, input().split()))
# i番目の宿題にかかる日数
A = list(map(int, input().split()))

free_days = N - sum(A)

if (free_days >= 0):
    print(free_days)
else :
    print(-1)

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

using namespace std;

string str; int pos, P, Q, R;

int formula() {
  pos ++;
  if(str[pos] == '(') {
    int f = formula(); pos++;
    if(str[pos] == '*') f = min(f, formula());
    if(str[pos] == '+') f = max(f, formula());
    pos ++;
    return f;
  }
  if(str[pos] == '-') return 2-formula();
  if(str[pos] == 'P') return P;
  if(str[pos] == 'Q') return Q;
  if(str[pos] == 'R') return R;
  if(isdigit(str[pos])) return str[pos]-'0';
}

int main() {
  while(cin >> str) {
    if(str == ".") return 0;
    int cnt = 0;
    for(P=0; P<=2; P++)
      for(Q=0; Q<=2; Q++)
	for(R=0; R<=2; R++) {
	  pos = -1;
	  cnt += formula() == 2;
	}
    cout << cnt << endl;
  }
  return 0;
}

Measured memory_bytes: 1188
n,m = map(int,input().split())
l={i for i in range(1,n+1)}
li=list(map(int,input().split()))
d={0}
for i in range(m):
    a,b=map(int,input().split())
    if li[a-1]<li[b-1]:
        d|={a}
    elif li[a-1]>li[b-1]:
        d|={b}
    else:
        d|={a,b}
print(len(l-d))

Measured memory_bytes: 28128
#include<iostream>
#include<vector>
#include<cstdint>
#include<algorithm>
using namespace std; // 575
const int MAX = 100000;
/**
 * Union-Find木です。
 * クラスカル法でも扱う時にどうぞ
 */
typedef class unionFind {
	private:
		vector<int> parent; // 負数ならばデータ数、正数ならば親の場所
	public:
		unionFind(int n) : parent(n, -1){}
		int find(int n);
		void unite(int n, int m);
		bool isEqual(int n, int m);
		int getSize(int n);
} UnionFind;

/**
 * nの属している木の頂点を返します
 * @param n 調べるデータ
 * @return nが属している木の頂点
 */
int unionFind::find(int n) {
	if (parent[n] < 0) return n;
	return parent[n] = find(parent[n]);
}

/**
 * nの属する木とmの属する木を結合します
 * @param n 結合したいデータ
 * @param m 結合したいデータ
 */
void unionFind::unite(int n, int m) {
	n = find(n);
	m = find(m);
	if (n == m) return;
	if (parent[n] > parent[m]) {
		parent[m] += parent[n];
		parent[n] = m;
	} else {
		parent[n] += parent[m];
		parent[m] = n;
	}
}

/**
 * nとmが同じ木に属しているか調べます
 * @param n 調べるデータ
 * @param m 調べるデータ
 * @return 同じ木に属していたならtrue
 */
bool unionFind::isEqual(int n, int m) {
	return find(n) == find(m);
}

/**
 * nの属している木のデータ数を返します。
 * @param n 調べるデータ
 * @return nの属している木のデータ数
 */
int unionFind::getSize(int n) {
	return parent[find(n)];
}

int main() {
	int N, M;
	static int64_t X[MAX];
	static int E[MAX]; // その頂点に繋がる辺の数
	static pair<int, pair<int, int> > edge[MAX];
	cin >> N >> M;
	for (int i = 0;i < N;++ i) {
		cin >> X[i];
		E[i] = 0;
	}
	for (int i = 0;i < M;++ i) {
		cin >> edge[i].second.first >> edge[i].second.second >> edge[i].first;
		-- edge[i].second.first;
		-- edge[i].second.second;
	}
	sort(edge, edge + M);
	UnionFind uf(N);
	int connect = 0;
	for (int i = 0;i < M;++ i) {
		int l = uf.find(edge[i].second.first), r = uf.find(edge[i].second.second);
		uf.unite(l, r);
		int parent = uf.find(l);
		if (l != parent) {
			X[r] += X[l];
			E[r] += E[l] + 1;
			X[l] = E[l] = 0;
		} else if (r != parent) {
			X[l] += X[r];
			E[l] += E[r] + 1;
			X[r] = E[r] = 0;
		} else {
			++ E[parent];
		}
		if (X[parent] >= edge[i].first) { // そこまでの頂点をすべて繋げても大丈夫
			connect += E[parent];
			E[parent] = 0;
		}
		/*
		cout << i << "手目" << endl;
		cout << l + 1 << "<->" << r + 1 << ":" << edge[i].first << endl;
		for (int i = 0;i < N;++ i) {
			cout << X[i] << " ";
		}
		cout << endl;
		for (int i = 0;i < N;++ i) {
			cout << E[i] << " ";
		}
		cout << endl;
		*/
	}
	cout << M - connect;
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

まず、ある辺について、その辺を含む連結成分の頂点の重みはほかの操作によって減ることはあっても増えることはない
よって、削除しなきゃいけない辺は必ず削除する必要がある
この時、辺を削除することによって連結が途切れたら、また削除する辺が増える可能性がある
さて、削除すべき辺の候補をどうやって高速に求めるか？

まず、大事な性質
1. 自分と連結でないところが幾ら変わっても関係ない
2. 自分と連結なところの変更はすべてに影響する
3. 同じ連結成分内だと大きい辺から死ぬ
4. １つの辺を削除することによる連結成分の増える数は高々1個

逆から考えてみよう
小さい順に設置していくわけだし

*/

Measured memory_bytes: 2944
using System;
class c
{
    static void Main()
    {
        var inp = Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
        long ans = 0;
        if (inp[0] == 1) ans = inp[1];
        else
            for (int i = 1; i <= Math.Pow(inp[1], 1.0 / inp[0]) + 1; i++)
            {
                if (inp[1] % Math.Pow(i, inp[0]) == 0) ans = i;
            }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 13140
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long  fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y){
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
vector<long long int >meguru;
bool isOK(int index, int key) {
	if (meguru[index] >= key) return true;
	else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)meguru.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key)) right = mid;
		else left = mid;
	}
	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

int main() {
	string s;
	string sub;
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] != s[s.size() - 1 - i]) {
			cout << "No";
			return 0;
		}
	}
	sub = s.substr(0, (s.size() - 1) / 2 );
	for (int i = 0; i < sub.size(); i++) {
		if (sub[i] != sub[sub.size() - 1 - i]) {
			cout << "No";
			return 0;
		}
	}
	sub = s.substr((s.size() + 3) / 2 - 1, s.size() - (s.size()+3)/2+1);
	for (int i = 0; i < sub.size(); i++) {
		if (sub[i] != sub[sub.size() - 1 - i]) {
				cout << "No";
				return 0;
		}
	}
	cout << "Yes";
 }

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(void)
{
    int m,h,i;
    string str;
    cin >> str;
    while(str != "-") {
        cin >> m;
        for(i=0;i<m;i++) {
            cin >> h;
            string left = str.substr(0,h);
            str.erase(0,h);
            str+=left;
        }
        cout << str << endl;
        cin >> str;
    }
}


Measured memory_bytes: 3180
import java.util.*;
import java.util.stream.*;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt(), m = in.nextInt(), s = in.nextInt() - 1, t = in.nextInt() - 1;
		List<Grid>[] yen = new List[n], snu = new List[n];
		for(int i = 0; i < n; i++) {
			yen[i] = new ArrayList<>();
			snu[i] = new ArrayList<>();
		}
		for(int i = 0; i < m; i++) {
			int u = in.nextInt() - 1, v = in.nextInt() - 1;
			long a = in.nextLong(), b = in.nextLong();
			yen[u].add(new Grid(v, a));
			yen[v].add(new Grid(u, a));
			snu[u].add(new Grid(v, b));
			snu[v].add(new Grid(u, b));
		}
		long[] sc = Dijkstra.execute(yen, s), tc = Dijkstra.execute(snu, t);
		long[] ans = new long[sc.length];
		ans[ans.length - 1] = sc[sc.length - 1] + tc[tc.length - 1];
		for(int i = ans.length - 2; 0 <= i; i--) {
			ans[i] = Math.min(ans[i + 1], sc[i] + tc[i]);
		}
		for(long a : ans) {
			System.out.println((long)1e15 - a);
		}
	}
}

class Dijkstra {

	public static long[] execute(List<Grid>[] list, int start) {
		long[] cost = new long[list.length];
		Arrays.fill(cost, Long.MAX_VALUE / 2);
		cost[start] = 0;

		Queue<Grid> que = new PriorityQueue<>(Comparator.comparing(Grid::getCost));
		que.add(new Grid(start, 0));
		while(0 < que.size()) {
			Grid p = que.poll();
			if(cost[p.to] < p.cost) continue;
			for(Grid g : list[p.to]) {
				if(cost[p.to] + g.cost < cost[g.to]) {
					cost[g.to] = cost[p.to] + g.cost;
					que.add(new Grid(g.to, cost[g.to]));
				}
			}
		}
		return cost;
	}
}

class Grid {
	int to;
	long cost;

	public Grid(int to, long cost) {
		this.to = to;
		this.cost = cost;
	}
	public long getCost() { return this.cost; }
}


Measured memory_bytes: 196212
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
# ifdef __GNUC__
# if __cplusplus > 199711L
# include <unordered_set>
# include <unordered_map>
# else
# include <tr1/unordered_map>
# include <tr1/unordered_set>
using namespace tr1;
# endif
# else
# include <unordered_map>
# include <unordered_set>
# endif
using namespace std;

#define fi first
#define se second
#define FO(x, n) for (int x = 0; x < n; ++x)
#define FOR(x, a, b) for (int x = a; x < b; ++x)
#define RFO(x, n) for (int x = n - 1; x >= 0; --x)
#define RFOR(x, a, b) for (int x = b - 1; x >= a; --x)
typedef unsigned char byte;
typedef unsigned int uint;
typedef long long llong;
typedef unsigned long long ullong;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<llong, llong> pll;
inline bool feq(const double& a, const double& b) { return fabs(a - b) < 1e-10; }

const int MAXN = 200200;
int N, M;
vector<int> edges[MAXN];
bool can[MAXN];

int main()
{
    while (cin >> N >> M)
    {
        memset(can, 0, sizeof(can));
        FO (i, N + 1)
            edges[i].clear();

        FO (i, M)
        {
            int a, b;
            cin >> a >> b;
            edges[a].push_back(b);
            edges[b].push_back(a);
        }

        vector<int> bfs = {1};
        can[1] = true;
        FO (t, 2)
        {
            vector<int> nxt;
            for (int i = 0; i < bfs.size(); ++i)
            {
                int u = bfs[i];
                for (int j = 0; j < edges[u].size(); ++j)
                {
                    int v = edges[u][j];
                    if (can[v])
                        continue;
                    nxt.push_back(v);
                    can[v] = true;
                }
            }
            swap(nxt, bfs);
        }
        cout << (can[N] ? "POSSIBLE" : "IMPOSSIBLE") << endl;
    }
    return 0;
}

Measured memory_bytes: 12912