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

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef array<int, 3> tri;
typedef long double ld;

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}


const int MOD = 1E9 + 7;
int dp[2001];
void _main() {
        int s; cin >> s;
        dp[0] = 1;
        for (int sum = 1; sum <= s; sum++) {
                for (int last = 3; last <= sum; last++) {
                        dp[sum] += dp[sum - last];
                        dp[sum] %= MOD;
                }
        }

        cout << dp[s];
}



signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}

Measured memory_bytes: 3548
S = input()
N = len(S)
left = S[:int(N/2)]
right = S[int((N+2)/2):]
S_reversed = "".join(reversed(list(S)))
left_reversed = "".join(reversed(list(left)))
right_reversed = "".join(reversed(list(right)))

if S == S_reversed and left == left_reversed and right == right_reversed:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main(){
    int m, f, r;
    while(true){
        cin >> m >> f >> r;
        if(m == -1 && f == -1 && r == -1) break;

        if(m == -1 || f == -1 || m + f <30) cout << "F" << endl;
        else if(30 <= m + f && m + f < 50){
            if(50 <= r){
                cout << "C" << endl;
            }
            else{
                cout << "D" << endl;
            }
        }
        else if(50 <= m + f && m + f < 65) cout << "C" << endl;
        else if(65 <= m + f && m + f < 80) cout << "B" << endl;
        else if(80 <= m + f) cout << "A" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3116
var n,m,i,j,ans,l:longint;
var a:array[0..1020] of longint;
begin
  read(n);ans:=0;l:=101;
  for i:=1 to n do
  begin
    read(a[i]);
    if (a[i]=a[i-1])then begin a[i]:=l;inc(ans);inc(l);end;
  end;
  writeln(ans);
end.

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, m, d;
    cin >> n >> m >> d;
    double b = (double)(n - d) / (n * n);
    if (d != 0) b *= 2.0;
    double ans = b * (m - 1);
    printf("%.10f\n", ans);
    return 0;
}

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

public class Main {
	static Scanner sc = new Scanner(System.in);
	private static final int NUM = 6; //?????£???????????°

	public static void main(String[] args) {
		int dataSet = sc.nextInt();
		int[] people = new int[NUM];
 		Arrays.fill(people, 0);

		for(int $ = 0; $ < dataSet; $++) {
			double hight = sc.nextDouble();

			if(hight < 165.0) {
				people[0]++;
			} else if(hight < 170.0) {
				people[1]++;
			} else if(hight < 175.0) {
				people[2]++;
			} else if(hight < 180.0) {
				people[3]++;
			} else if(hight < 185.0) {
				people[4]++;
			} else {
				people[5]++;
			}
		}

		for(int $ = 0; $ < NUM; $++) {
			System.out.print(($ + 1) + ":");
			for(int i = 0; i < people[$]; i++) {
				System.out.print("*");
			}
			System.out.println();
		}

	}

}

Measured memory_bytes: 28272
#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>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 20)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する


int main() {
    int N;
    int mi = 114514;
    cin >> N;
    rep(i,0,N){
        int tmp;
        cin >> tmp;
        int cnt = 0;
        while(true){
            if(tmp & 1){
                break;
            }else{
                cnt++;
                tmp >>= 1;
            }
        }
        mi = min(mi,cnt);
    }
    cout << mi << endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
a_list = list(map(int, input().split()))
b_list = list(map(int, input().split()))
ans = 0
tmp = 0
for i in range(N):
    if a_list[i] >= b_list[i] + tmp:
        ans += b_list[i] + tmp
        tmp = 0
    else:
        ans += a_list[i]
        if (a_list[i] - tmp) <= 0:
            tmp = b_list[i]
        else:
            tmp = b_list[i] - (a_list[i] - tmp)


if tmp == 0:
    print(ans)
else:
    if tmp >= a_list[N]:
        print(ans + a_list[N])
    else:
        print(ans + tmp)




Measured memory_bytes: 18624
A = int(input())
B = int(input())
C = int(input())
x = int(input())

ans = 0
for a in range(A + 1):
    for b in range(B + 1):
        temp = x - 500 * a - 100 * b
        if temp % 50 != 0 or temp < 0:
            continue
        if temp // 50 <= C:
            ans += 1

print(ans)

Measured memory_bytes: 3188
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <random>
#include <set>
#include <stack>
#include <time.h>

//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define SORTR(x) sort(x.begin(),x.end(),greater<vector<int>>())

#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple

using namespace std;
using ll = long long;
typedef std::pair<int, int> pii;
typedef std::pair<int, double> pid;
typedef std::vector<int> vi;
typedef std::vector<pii> vii;

#define PI 3.14159265358979323846264338327950L
const int mod = 1e9+7;


void solve(){
    int n;
    cin >> n;
    vector<int> a(n),b(n);
    rep(i,n) cin >> a[i] >> b[i];
    
    bool ans = 0;
    for(int i = 0; i < n; i++){
        if (i+2 >= n) continue;
        if (a[i] == b[i] && a[i+1] == b[i+1] && a[i+2] == b[i+2]){
            cout << "Yes";
            return;
        }
    }
    cout << "No";
    
}




int main() {
    int T;
    
    T = 1;
    //cin >> T;
    
    while (T--) {
        solve();
        cout << endl;
    }
}




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

int main(){
  int dice[100][6];
  int pos[6][6] = {{0,3,5,2,4,0},{4,0,1,6,0,3},{2,6,0,0,1,5},{5,1,0,0,6,2},{3,0,6,1,0,4},{0,4,2,5,3,0}};
  int a,b,n;

  cin>>n;
  for(int i=0;i<n;i++)
    for(int j=0;j<6;j++)
      cin>>dice[i][j];
  
  bool flg=false;
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      for(int p=0;p<6;p++){
	if(dice[i][0]==dice[j][p]){
	  a=p;
	  for(int k=0;k<6;k++){
	    if(dice[i][1]==dice[j][k] && k!=a && pos[a][k]!=0){
	      b=k;
	      if(dice[i][2]==dice[j][pos[a][b]-1] && dice[i][3]==dice[j][5-(pos[5-a][5-b]-1)] && dice[i][4]==dice[j][5-b] && dice[i][5]==dice[j][5-a]) flg=true;
	    }
	    if(flg) break;
	  }
	}
	if(flg) break;
      }
      if(flg) break;
    }
    if(flg) break;
  
  }


  if(flg) cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
  return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>
#include<string.h>
int main()
{
    int a,b,i,n=0;
    scanf("%d%d",&a,&b);
    char c[100];
    scanf("%s",&c);
    for(i=0; i<a; i++)
    {
        if(i==b-1)
        {
            n=c[i]+32;
            printf("%c",n);
        }
        else
        {
            printf("%c",c[i]);
        }
    }
    printf("\n");

    return 0;
}


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

int main()
{
    string s;

    getline(cin, s);

    for (int i = 0; s[i] != '\0'; i++)
    {
        if ('A' <= s[i] && s[i] <= 'Z')
        {
            s[i] = (s[i] - 'A') + 'a';
        }
        else if ('a' <= s[i] && s[i] <= 'z')
        {
            s[i] = (s[i] - 'a') + 'A';
        }
        cout << s[i];
    }

    cout << '\n';
    return 0;
}


Measured memory_bytes: 3172
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <stdlib.h>
#include <math.h>

int main(void)
{
	long int i, j;
	long int n;
	long int count;
	long int d[50];
	
	scanf("%ld", &n);
	
	for(i = 0; i < n; i++) {
		scanf("%ld", &d[i]);
	}
	
	count = 0;
	
	for(i = 0; i < n - 1; i++) {
		for(j = i + 1; j < n; j++) {
			count += d[i] * d[j];
		}
	}
	
	printf("%ld\n", count);
	
	return 0;
}


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

// Remove GCC optimizer for codechef
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

using namespace std;
using namespace __gnu_pbds;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define endl "\n"
#define int long long
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

const int INF = 1e16;
const double PI = acos(-1);
const int N = 1e6 + 7;
int mod = 1e9 + 7;


int32_t main()
{
    IOS;
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    
    int n;
    cin >> n;
    vector<int> v(n+1), mp(n+1, 0);
    for(int i = 1; i <= n; i++)
    {
        int a;
        cin >> a;
        mp[a]++;
        v[i] = a;
    }
    int sum = 0;
    for(int i = 1; i <= n; i++)
        sum += mp[i] * (mp[i] - 1) / 2;
    for(int i = 1; i <= n; i++)
    {
        int val = sum - (mp[v[i]] * (mp[v[i]] - 1) / 2) + ((mp[v[i]] - 1) * (mp[v[i]] - 2) / 2);
        cout << val << endl;
    }
    return 0;
}

Measured memory_bytes: 5760
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    ll A,B,C,X,Y;
    cin >> A >> B >> C >> X >> Y;

    ll ans = 0;
    if(2*C >= A+B) ans = A*X + B*Y;
    else{
        ll res = min(X,Y);
        ans = res*2*C;
        X -= res;Y -= res;

        if(X){
            if(A <= 2*C) ans += A*X;
            else         ans += 2*C*X;
        }
        if(Y){
            if(B <= 2*C) ans += B*Y;
            else         ans += 2*C*Y;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N;
	cin >> N;
	int P[110][3] = { 0 };
	int X;
	cin >> X;
	REP(i, X) {
		int a;
		cin >> a;
		P[a][0] = 1;
	}
	cin >> X;
	REP(i, X) {
		int a;
		cin >> a;
		P[a][1] = 1;
	}
	cin >> X;
	REP(i, X) {
		int a;
		cin >> a;
		P[a][2] = 1;
	}
	int ans = 0;
	eFOR(i, 1, N) {
		if (P[i][1] == P[i][2] && P[i][1] == 1) {
			ans++;
		}
		else if (P[i][0]==0 && P[i][2]==1) {
			ans++;
		}
	}

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




Measured memory_bytes: 3208
k = int(input())

keta = 1
_list = [0]
p = keta-1

while k > 0:
    k -= 1
    if keta == 1:
        _list[0] += 1
    else:
        while _list[p]-1 == _list[p-1] or _list[p] == 9:
            p -= 1
            if p == 0:
                break
        _list[p] += 1
        for i in range(p+1, keta):
            _list[i] = (_list[i-1]-1) * (_list[i-1] > 0)
    if _list[0] == 10:
        _list = [1] + [0]  * keta
        keta += 1
    p = keta-1

for num in _list:
    print(num, end="")
print()

Measured memory_bytes: 3064
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include <cstdint>
using namespace std;
#define rep(N) for(int i=0;i<N;i++)
#define rep2(N1,N2) for(int i=0;i<N1;i++)for(int j=0;j<N2;j++)
#define rep3(N1,N2,N3)for(int i=0;i<N1;i++)for(int j=0;j<N2;j++)for(int k=0;k<N3;k++)
#define For(i,N) for(int i=0;i<N;i++)
#define ll long long int
void yn(bool b) {
	if (b)printf("yes\n");
	else printf("no\n");
}

void Yn(bool b) {
	if (b)printf("Yes\n");
	else printf("No\n");
}

void YN(bool b) {
	if (b)printf("YES\n");
	else printf("NO\n");
}

int ctoi(char c) {
	return c - '0';
}

ll kai(ll x) {
	ll a = 1;
	if (x <= 0)
		return 1;
	else {
		for (ll i = 0; i < x; i++)
			a = a * (i + 1);
		return a;
	}
}

ll rui(ll x, ll y) {
	ll a = 1;
	for (ll i = 0; i < y; i++)
		a = a * x;
	return a;
}
const int nmax = 150;
int cccc[nmax][nmax];
ll comb(ll n, ll k) {
	if (n < k) {
		cout << "error n<k" << endl;
		return -1;
	}
	if (cccc[n][k] > 0)return cccc[n][k];
	if (k == 0 || n == k)return 1;
	return cccc[n][k] = comb(n - 1, k - 1) + comb(n - 1, k);
}


int main() {
	//cout.precision(16);
	ll A, B, C, K;
	cin >> A >> B >> C >> K;
	if (A >= K)
		cout << K;
	else if (A + B >= K)
		cout << A;
	else
		cout << A - (K - A - B);
}

Measured memory_bytes: 3640
function Main(input){
    input = input.split("\n");
    var A = input[0];
    var B = input[1];
    var C = input[2];
    var X = input[3];
    var ans = 0;
    for(var a = 0; a <= A; ++a){
        for(var b = 0; b <= B; ++b){
            if((X-500*a-100*b)%50 == 0 && (X-500*a-100*b)/50 >= 0 && (X-500*a-100*b)/50 <= C) ++ans;
        }
    }
    console.log(ans);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
str = gets.chomp
q = gets.to_i

q.times do
  cmd, a, b, q = gets.chomp.split
  a, b = [a, b].map(&:to_i)
  case cmd
  when 'print'
    puts str[a, b - a + 1]
  when 'reverse'
    str[a, b - a + 1] = str[a, b - a + 1].reverse
  when 'replace'
    str[a, b - a + 1] = q
  end
end

Measured memory_bytes: 6144
#include"bits/stdc++.h" 
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
typedef long long int ll;
vector<int>u;
vector<int>w;
vector<int>::iterator it;
priority_queue<int>pq;
const int N=1e5+10;
/*--------------------------hbp16@hbp16-Inspiron-3543:-$------------------------------*/

void solve()
{

}

int main(int argc, char const *argv[])
{
	int n,m;
	cin>>n>>m;

	int x = n*(n-1)/2;
	int y = m*(m-1)/2;

	cout<<x+y;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int md=1e9+7;
int n,c,a[405],b[405],dp[405][405],f[405];
bool calc(int aa,int bb)
{
	memset(f,0,sizeof(f));
	for(int i=aa;i<=bb;i++)
	{
		int s=1;
		for(int j=0;j<=c;j++)
		{
			f[j]=((f[j]+s)%md+md)%md;
			s=1ll*s*i%md;
		}
	}
	return true;
}
int main()
{
	scanf("%d%d",&n,&c);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)scanf("%d",&b[i]);
	calc(a[1],b[1]);
	for(int i=0;i<=c;i++)dp[1][i]=f[i];
	for(int i=2;i<=n;i++)
	{
		calc(a[i],b[i]);
		for(int j=0;j<=c;j++)for(int k=0;k<=j;k++)dp[i][j]=(dp[i][j]+1ll*dp[i-1][k]*f[j-k]%md)%md;
	}
	printf("%d\n",dp[n][c]);
	return 0;
}

Measured memory_bytes: 896
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

struct edge {
  int to;
  ll cost;
};
typedef pair<ll, ll> pl;
typedef vector<pl> vp;
typedef greater<pl> gp;

int n, m, s, t;
vector<edge> g[100000];
vector<edge> h[100000];

vector<ll> dijkstra(vector<edge> g[], int s) {
  priority_queue<pl, vp, gp> que;
  vector<ll> d(n, 1e18);
  d[s] = 0;
  que.push(make_pair(0, s));
  while (que.size()) {
    pl p = que.top();
    que.pop();
    int v = p.second;
    if (d[v] < p.first) continue;
    for (int i = 0; i < g[v].size(); ++i) {
      edge e = g[v][i];
      if (d[v] + e.cost < d[e.to]) {
        d[e.to] = d[v] + e.cost;
        que.push(make_pair(d[e.to], e.to));
      }
    }
  }
  return d;
}

int main() {
  cin >> n >> m >> s >> t;
  s--, t--;
  while (m--) {
    int u, v, a, b;
    cin >> u >> v >> a >> b;
    u--, v--;
    edge e1 = {v, a}, e2 = {u, a};
    g[u].push_back(e1), g[v].push_back(e2);
    edge e3 = {v, b}, e4 = {u, b};
    h[u].push_back(e3), h[v].push_back(e4);
  }
  vector<ll> dist1 = dijkstra(g, s);
  vector<ll> dist2 = dijkstra(h, t);
  vector<ll> ans(n);
  for (int i = 0; i < n; ++i) {
    ans[i] = dist1[i] + dist2[i];
  }
  for (int i = n - 2; i >= 0; --i) {
    ans[i] = min(ans[i], ans[i + 1]);
  }
  ll x = 1e15;
  for (int i = 0; i < n; ++i) {
    cout << x - ans[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 19140
N = int(input())
X = list(map(int, (input().split())))

distance = lambda Xi, P: (Xi - P) ** 2

X_min = min(X)
X_max = max(X)

answer = None
for P in range(X_min, X_max + 1):
    total = sum([distance(Xi, P) for Xi in X])
    answer = min(total, answer) if answer is not None else total

print(answer)


Measured memory_bytes: 3064
#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
    int h[100005],n,maxh;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&h[i]);
    }
    for(int i=n-1;i>=1;i--)
    {
        if(h[i+1]>=h[i])
        {
            continue;
        }
        else if(h[i+1]+1==h[i])
        {
            h[i]--;
        }
        else
        {
            printf("No");
            return 0;
        }

    }
    printf("Yes");

}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
#define MAX_VAL 110000
#define INF 4123456789123456

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

struct edge{ll to, cost;};

vector<edge> G[MAX_VAL];
ll d[MAX_VAL], V;

void dijkstra(ll s){
	priority_queue<P,vector<P>,greater<P>> q;
	fill(d,d+V, INF);
	
	d[s] = 0;
	q.push(P(0,s));
	
	while(!q.empty()){
		P p = q.top();q.pop();
		ll v = p.second;
		
		if(d[v] < p.first) continue;
		
		for(edge e : G[v]){
			if(d[e.to] > d[v] + e.cost){
				d[e.to] = d[v] + e.cost;
				q.push(P(d[e.to],e.to));
			}
		}
	}
	
	
}

int main(){
	int u, k, v, c;
	cin>>V;
	
	for(int i = 1; i <= V; i++){
		cin>>u>>k;
		for(int j = 1; j <= k; j++){
			cin>>v>>c;
			edge  e = {v,c};
			G[u].push_back(e);
		}
	}
		dijkstra(0);
	for(int i = 0; i < V; i++){
		cout<<i<<" "<<d[i]<<endl;
	}
	return 0;
}



Measured memory_bytes: 14536
#include <bits/stdc++.h>
using namespace std;
 
typedef long long int ll;
typedef pair<ll, ll> pll;
 
#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)
 
const ll MOD = 1000000007;
const ll INF = (ll)1e15;
 
ll A[100005];
ll B[100005];
ll C[100005];
 
int main()
{
    ll N;
    cin >> N;
    REP(i, N)
    {
        cin >> A[i];
    }
    ll max = 0;
 
    REP(i, N)
    {
        B[i] = A[i] - A[(N + i - 1) % N];
        max = std::max(max, B[i]);
    }
    REP(i, N)
    {
        ll k = (B[i] + (N - 1) * max) / N;
        C[i] = max - k;
    }
    FOR(i, N, 1)
    {
        C[0] += (N + 1 - i) * C[i];
    }
    FOR(i, N, 1)
    {
        C[i] = C[i - 1] + (max - C[i]) - (N - 1) * C[i];
    }
 
    string ans = "YES";
    REP(i, N)
    {
        if (A[i] < C[i])
        {
            ans = "NO";
            break;
        }
        if ((A[i] - C[i]) % (N * (N + 1) / 2) != 0)
        {
            ans = "NO";
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2560
#include <stdio.h>
#define INF 1000000000

int main(void){
	int v, n, a, b, c;
	int i, j, k;
	int cost[11][11];
	int sum, min, min_v;

	while(1){
		v = -1;
		min = INF;

		scanf("%d", &n);
		if(n == 0) break;

		//Initialaize
		for(i=0; i<11; i++){
			for(j=0; j<11; j++){
				cost[i][j] = INF;
			}
		}
		for(i=0; i<11; i++){
			cost[i][i] = 0;
		}

		for(i=0; i<n; i++){
			scanf("%d %d %d", &a, &b, &c);
			if(v < a) v = a;
			if(v < b) v = b;
			cost[a][b] = c;
			cost[b][a] = c;
		}
		v++;
		
		//Warshall-Floyd 
		for(k=0; k<v; k++){
			for(i=0; i<v; i++){
				for(j=0; j<v; j++){
					if(cost[i][j] > cost[i][k] + cost[k][j]){
						cost[i][j] = cost[i][k] + cost[k][j];
					}
				}
			}
		}
		
		//ツ津環凝篠篠楪甘板づ個堕債和ツづ個計ツ算
		for(i=0; i<v; i++){
			sum = 0;
			for(j=0; j<v; j++){
				sum += cost[i][j];
			}
			if(min > sum){
				min = sum;
				min_v = i;
			}
		}

		printf("%d %d\n", min_v, min);
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());
#define PAU system("pause")

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vb> vvb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 28);
const ll LINF = 1e18;
const double PI = acos(-1);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, K;
	cin >> N >> K;
	vi H(N);
	REP(i, N) {
		cin >> H[i];
	}
	vi dp(N,1e9+100);
	dp[0] = 0;
	REP(i, N) {
		FOR(j, i + 1, min(N,i + K + 1)) {
			dp[j] = min(dp[j], dp[i] + abs(H[i] - H[j]));
		}
	}
	cout << dp[N - 1] << endl;
	PAU;
	return 0;
}


Measured memory_bytes: 1272
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);


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


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


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


ll GCD(ll a,ll b){
  ll r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return b;
}


ll LCM(ll a,ll b){
  ll c=a,d=b,r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return c/b*d;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

vector<pair<char,ll>> runlength(string s,vector<pair<char,ll>> p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
    return p;
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
  return p;
}



/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll n;
  cin>>n;
  vector<ll> v(n),dp;
  rep(i,n) cin>>v[i];
  dp.push_back(0);
  dp.push_back(abs(v[1]-v[0]));
  for(ll i=0;i<n-2;i++){
    dp.push_back(min(dp[i]+abs(v[i]-v[i+2]),dp[i+1]+abs(v[i+1]-v[i+2])));
  }
  cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 2168
#include <bits/stdc++.h>
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<x<<endl
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
const ll LINF = LLONG_MAX;
const int INF = INT_MAX;
const double PI=acos(-1);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
      ll a,v, b,w,t;
      cin>>a>>v>>b>>w>>t;
      bool ok=false;
      if(a<b){
            if((a+v*t >= b+w*t)){
                  ok=true;
            }
      }else{
            if((b-w*t >= a-v*t)){
                  ok=true;
            }
      }
      if(ok){
            cout<<"YES"<<endl;
      }else{
            cout<<"NO"<<endl;
      }
}

Measured memory_bytes: 3632
using System;
class p
{
  static void Main()
  {
    string s = Console.ReadLine();
    string result = string.Empty;
    for (int i = 0; i < s.Length; i++) {
      if (s[i] != 'B') {
        result += s[i];
      } else {
        if (0 < result.Length) {
          result = result.Remove(result.Length - 1, 1);
        }
      }
    }
    Console.WriteLine(result);
  }
}


Measured memory_bytes: 11092
n, a, b = map(int, input().split())
mod = 10**9 + 7
a = min(a, n-a)
b = min(b, n-b)
com = [1] * (max(a, b) + 1)
for i in range(1,len(com)):
    com[i] = (com[i-1] * pow(i, mod-2, mod) * (n-i+1)) % mod
print((pow(2, n, mod) - 1 - com[a] - com[b] + mod) % mod)

Measured memory_bytes: 10936
N, K = map(int, input().split())
MOD = 10 ** 9 + 7
cnt = [0] * (K + 1)
for x in range(1, K + 1):
  cnt[x] = pow(K // x , N , MOD)

for x in range(K, 0, -1):
  for i in range(2, (K // x) + 1):
    cnt[x] -= cnt[x * i]
  #被りを消さなきゃいけない
ans = 0
for x in range(1, K + 1):
  ans += cnt[x] * x
print(ans % MOD)
  

Measured memory_bytes: 11364
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
using ll = long long;
using itn = int;
using namespace std;
int GCD(int a, int b){
    return b ? GCD(b, a%b) : a;
}
int main() {
	int N;
	cin >> N;
	int a[N];
	rep(i,N) cin >> a[i];
	map <int, int> cnt;
	rep(i,N){
		cnt[a[i]]++;
		cnt[a[i]-1]++;
		cnt[a[i]+1]++;
	}
	int imax = 0;
	for(auto itr=cnt.begin(); itr!=cnt.end(); itr++){
		imax = max(imax, itr->second);
	}
	cout << imax << endl;
	return 0;
}

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


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

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

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define FOR(i, s, e) for(int i = (s); i < (e); i++)
#define FOE(i, s, e) for(int i = (s); i <= (e); i++)
#define FOD(i, s, e) for(int i = (s); i >= (e); i--)
#define ll long long

int LINK[400005], ed[400005], l[400005];
int n, m, x, y, z, k, w;
int group[200005][2];

int bd(int x, int y) {
	LINK[w] = l[x]; l[x] = w; ed[w++] = y;
}

int v[200005];
int gp;

map< pair<int, int>, int> M;

void DFS(int x, int t) 
{
	v[x] = 1;
	group[x][t] = gp;
	for (int i = l[x]; i != -1; i = LINK[i])
	{
		if (v[ed[i]] == 1) continue;
		DFS(ed[i], t);
	}
}

void solve(int m, int t)
{
	w = 0;
	memset(l, -1, sizeof(l));
	FOR(i, 0, m) { scanf("%d%d", &x, &y); bd(x, y); bd(y, x); }

	memset(v, 0, sizeof(v));
	gp = 0;
	FOE(i, 1, n) if (v[i] == 0) { gp++; DFS(i, t); }

}

int main ()
{
	int K, L;
	scanf("%d %d %d", &n, &K, &L);
	solve(K, 0);
	solve(L, 1);
	
	FOE(i, 1, n) M[make_pair(group[i][0], group[i][1])]++;

	FOE(i, 1, n)
	{
		x = M[make_pair(group[i][0], group[i][1])];
		printf("%d ", x);
	}
	
	return 0;
}

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

sum_all_numbers = ((N + 1) * N) // 2
sum_mul_of_3 = sum([i for i in range(1, N+1) if i % 3== 0])
sum_mul_of_5 = sum([i for i in range(1, N+1) if i % 5 == 0])
sum_mul_of_15 = sum([i for i in range(1, N+1) if i % 15 == 0])

print(sum_all_numbers - sum_mul_of_3 - sum_mul_of_5 + sum_mul_of_15)

Measured memory_bytes: 22116
#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);
 
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 vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;
 
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }

int main()
{
  cin.tie( 0 );
  ios::sync_with_stdio( false );
  
  string s;cin>>s;
  vi v(26,0);
  rep(i,s.size()){
    v[s[i]-'a']=1;
  }
  rep(i,26){
    if(v[i]==0){
      char ans='a'+i;
      cout(ans);
      break;
    }else if(i==25)cout("None");
  }
  return 0;
}

Measured memory_bytes: 512
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#define REP(i,n) for (int i=1;i<=(n);++i)
#define FOR(i,a,b) for (int i=(a);i<=(b);++i)
#define ROF(i,a,b) for (int i=(a);i>=(b);--i)
#define FEC(p,u) for (edge*p=head[u];p;p=p->nxt)
using namespace std;
typedef long long LL;

int n, n1, n2, n0, m, m1, m2, a, x1[100], x2[100];
LL dp1[60][3000], dp2[60][3000], ans;
int main(){
	scanf("%d%d", &n, &a);
	REP(i,n) {
		int t;
		scanf("%d", &t);
		t -= a;
		if (t > 0) { x1[++n1] = t; m1 += t; }
		else if (t < 0){ x2[++n2] = -t; m2 += -t; }
		else ++n0;
	}
	m = max(m1, m2);
	dp1[0][0] = 1;
	REP(i,n1) {
		FOR(j,0,m) {
			dp1[i][j] = dp1[i-1][j];
			if (j >= x1[i]) dp1[i][j] += dp1[i-1][j-x1[i]];
		}
	}
	dp2[0][0] = 1;
	REP(i,n2) {
		FOR(j,0,m) {
			dp2[i][j] = dp2[i-1][j];
			if (j >= x2[i]) dp2[i][j] += dp2[i-1][j-x2[i]];
		}
	}
	ans = 0;
	FOR(j,0,m) ans += dp1[n1][j]*dp2[n2][j];
	REP(i,n0) ans *= 2;
	--ans;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1408
#include<cstdio>
#include<iostream>

using namespace std;

int main(){
  
  int num,n,data[101];
  cin>>num;
  for(int j=0;j<num;j++){
    int max1=0,max2=0;
    cin>>n;
    for(int i=0;i<n;i++)
      cin>>data[i];

    for(int i=1;i<n;i++){
      if(data[i]-data[i-1]>max1){
	max1=data[i]-data[i-1];
      }else if(data[i-1]-data[i]>max2)
	max2=data[i-1]-data[i];
    }
    
    cout<<max1<<" "<<max2<<endl;
  }
  return 0;
}

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

#define ll long long
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;


int main() {
    int N,A,B;
    cin >> N >> A >> B;
    if(N*A>=B) cout << B <<endl;
    else cout << N*A <<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define rep(n, i) Rep(0, n-1, i)

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef std::priority_queue<int> IntPrioQueue; //Z->A
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue; //A->Z

const int MAX = 200000;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<31-1;
const int MOD = 1000000007;


void solve(void){
    int N;
    cin >> N;
    ll L = 0LL, R = 0LL;
    rep(N, i) {
        ll A, B; scanf("%lld %lld\n", &A, &B);
        ll k = max(1LL, max((L-1)/A, (R-1)/B)+1LL);
        L = A*k; R = B*k;
        //cout << L<< ' ' << R << '\n';
    }
    cout << L+R << '\n';
}

int main(void){
  solve();
  return 0;
}


Measured memory_bytes: 256
N = int(input())
M = 1
while M*(M+1)//2 < N:
    M += 1
if M*(M+1)//2 != N:
    print('No')
    exit()
M += 1
S = [[] for i in range(M)]
k = 1
print('Yes')
print(M)
for i in range(M):
    for j in range(i+1, M):
        S[i].append(k)
        S[j].append(k)
        k += 1
for i in range(M):
    print(M-1, *S[i])

Measured memory_bytes: 47068
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}


int main() {
    string S;
    cin >> S;
    vector<int> dp(S.size()+1, 0);

    // if len(S) == 1 -> ans is 1
    if (S.size() == 1) {
        cout << 1 << endl;
        return 0;
    }

    // if len(S) == 2 -> ans is 1 or 2 ( depends on s1 and s2)
    if (S.size() == 2) {
        int ans = S[0] == S[1] ? 1 : 2;
        cout << ans << endl;
        return 0;
    }

    // if len(S) == 3 -> ans is 2 or 3
    if (S.size() == 3) {
        int ans = S[0] == S[1] || S[1] == S[2] ? 2 : 3;
        cout << ans << endl;
        return 0;
    }

    // if len(S) >= 4 then find answer with DP
    dp[0] = 0;
    dp[1] = 1;
    dp[2] = S[0] == S[1] ? 1 : 2;
    FOR(i, 3, S.size()+1) {
        dp[i] = S[i-1] == S[i-2] ? dp[i-3] + 2 : dp[i-1] + 1;
        // cout << "dp[i]" << dp[1] << endl;
    }

    cout << dp[S.size()] << endl;


    return 0;
}


Measured memory_bytes: 1412
s=input()
a=0
b=0
c=0
for i in range(len(s)):
    if s[i]=="a":
        a+=1
    elif s[i]=="b":
        b+=1
    else:
        c+=1

if max(a,b,c)-min(a,b,c)>1:
    print("NO")
else:
    print("YES")


Measured memory_bytes: 3188
#include <iostream>/*{{{*/
#include <bits/stdc++.h>
#define REP(i, x) for(int i = 0; i < (int)(x); i++)
#define REPS(i,x) for(int i = 1; i <= (int)(x); i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define RFOR(i, m, n) for(int i = m;i >= n;i--)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define FILL(x,y) memset(x,y,sizeof(x))
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define PB(a) push_back(a)
#define INF 999999999
#define debug(x) cerr << __LINE__ << ": " << #x << " -> " << x << '\n'
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};/*}}}*/

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

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

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);
        int[] a = new int[4];
        for(int i=0; i<6; i++) {
            a[sc.nextInt()-1]++;
        }
        for(int i=0; i<4; i++) {
            if(a[i] == 3) {
                System.out.println("NO");
                return;
            }
        }
        System.out.println("YES");
    }

}


Measured memory_bytes: 22996
/*Author - Shubham Gupta (@shubham107)*/
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<ll> vl;      typedef vector<int> vi;
typedef vector<vl> vvl;     typedef vector<vi> vvi;
typedef pair<ll, ll> pll;   typedef pair<int, int> pii;
#define forn(i,n) for(int i=0;i<n;i++)
#define rforn(i,n) for(int i=n-1;i>=0;i--)
#define forne(i,n) for(int i=1;i<=n;i++)
#define forse(i,s,e) for(int i=s;i<e;i++)
#define rforse(i,s,e) for(int i=e-1;i>=s;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define MOD 1000000007
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define fill(a,x) memset(a,x,sizeof a);
#define trav(a,x) for(auto &a:x)
#define INF ll(1e18)
#ifdef SHUBHAM107
#include "../trace.h"
#else
#define trace(args...)
#endif
void solve() {
    int n;
    cin >> n;
    vi arr(n);
    int xo = 0;
    forn(i, n) cin >> arr[i], xo ^= arr[i];
    forn(i, n) cout << (xo ^ arr[i]) << ' ';
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifdef SHUBHAM107
    freopen("inp.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("err.txt", "w", stderr);
#endif
    int t = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
}


Measured memory_bytes: 3920
use std::io::*;
use std::str::FromStr;

//https://qiita.com/tubo28/items/e6076e9040da57368845
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main(){
    let n:usize = read();
    let mut p:Vec<u32> = (0..n).map(|_| read()).collect();

    p.sort_by(|x,y|y.cmp(x));

    let mut sum:u32 = p.iter().sum();
    sum -= p[0]/2;

    println!("{}",sum);
}

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

int main()
{
    int a = 0, b = 0, c = 0;
    int x = 0, y = 0;
    cin >> a >> b >> c >> x >> y;

    int mxy = min(x, y);

    int res1 = a * x + b * y;
    int res2 = a * (x - mxy) + b * (y - mxy) + 2 * c * mxy;
    int res3 = 2 * c * max(x, y);

    cout << min(min(res1, res2), res3) << endl;

    return 0;
}

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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < (n); i++)
#define Rep(i, n) for(int i = 1; i < n; i++)

const int mod = 1000000007;
const int inf = (1 << 21);
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;
using vll = vector<pair<ll, ll>>;

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; }
template<class T> inline T GCD(T a, T b) { return b ? GCD(b, a % b) : a; }
template<class T> inline T LCM(T a, T b) { return (a + (b - 1)) / b; }

int round_int(int a, int b) { return (a + (b - 1)) / b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };

// ──────────────────────────────────────────────────────────────────

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

	map<ll, ll> mp;
	vl a(n);
	rep(i, n) {
		cin >> a[i];
		mp[a[i]]++;
	}

	ll mx = 0;
	for (auto itr = mp.begin(); itr != mp.end(); itr++) {
		auto p = *itr;
		ll m = p.second;
		mx += m * (m - 1) / 2;
	}

	rep(i, n) {
		ll c = mp[a[i]];
		//cout << c << endl;
		ll d = c * (c - 1) / 2;
		c--;
		ll e = c * (c - 1) / 2;
		cout << mx - d + e << endl;
	}
}

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

int p, q;
int gcd(int x, int y){
	if(x % y == 0) return y;
	return gcd(y, x % y);
}
bool prime(int x){
	bool f = true;
	for(int i=2; i*i<=x; ++i)
		if(x % i == 0)
			f = false;
	return f;
}

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	cin >> p >> q;
	int g = gcd(p, q);
	q /= g;
//	cout << p / g << " " << q << "\n";
	vector<int> a;
	if(prime(q)){
		cout << q << "\n";
		return 0;
	}
	for(int i=2; i<=q; ++i){
		if(q % i == 0){
			int t = 1;
			q /= i;
			while(q % i == 0){
				++t;
				q /= i;
			}
			a.push_back(i);
		}
	}
	int ans = 1;
	for(int i=0; i<a.size(); ++i)
		ans *= a[i];
	cout << ans << "\n";
}


Measured memory_bytes: 3164
#include<bits/stdc++.h>
#include<cstdio>
#include<cstdlib>

using namespace std;
typedef long long int ll;

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

int fact(int n){
    return n==1 ? 1 : n*fact(n-1);
}

int main(){
    int n;  cin >> n;
    vector<double> x(n);
    vector<double> y(n);

    for(int i=0;i<n;i++)    cin >> x[i] >> y[i];
    
    double ans=0.0;

    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(i!=j){
                double a1=pow(x[i]-x[j],2)+pow(y[i]-y[j],2);
                ans+=pow(a1,0.5);
            }    
        }
    }

    ans/=n;

    cout << fixed << setprecision(10) << ans << endl;
}


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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            ReadLine();
            var S = new HashSet<int>(ReadInts());
            ReadLine();
            var T = new HashSet<int>(ReadInts());
            System.Console.WriteLine(S.Intersect(T).Count());
        }

        static string ReadLine()
        {
            return Console.ReadLine();
        }

        static int ReadInt()
        {
            return int.Parse(Console.ReadLine());
        }

        static IEnumerable<int> ReadInts()
        {
            return ReadLine().Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries)
                .Select(x => int.Parse(x));
        }
    }

    //static class Console
    //{
    //    static StreamReader reader = new StreamReader("input.txt");

    //    public static string ReadLine()
    //    {
    //        return reader.ReadLine();
    //    }
    //}
}

Measured memory_bytes: 11028
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;
#define int ll
#define pb push_back
#define mp make_pair
using pii = pair<int,int>;
const int N = 100005;
const int Inf = 1e17+7;
#ifndef M_PI
#define M_PI 3.1415926535
#endif
#define F first
#define S second

void io()
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cerr.tie(NULL);
//		cout << setprecision(10) << fixed;
}

int n;

signed main()
{
	io();
	cin >> n;
	int p = 0;
	int s = 0;
	for (;;)
	{
		++p;
		while (p % 5 == 0 || p % 3 == 0)
			++p;
		if (p > n)
			break;
		s += p;
	}
	cout << s;
}

Measured memory_bytes: 3648
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

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

    int H = scanner.nextInt();
    int W = scanner.nextInt();
    char[][] map = new char[H][W];
    for (int i = 0; i < H; i++) map[i] = scanner.next().toCharArray();

    int maxDepth = 0;
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        if (map[i][j] == '.') {
          maxDepth = Math.max(maxDepth, bfs(H, W, map, i, j));
        }
      }
    }
    System.out.println(maxDepth);
  }

  private static int bfs(int H, int W, char[][] map, int i, int j) {
    boolean[][] visited = new boolean[H][W];
    Queue<Pos> queue = new LinkedList<>();
    queue.add(new Pos(0, i, j));
    int maxDepth = 0;
    while (!queue.isEmpty()) {
      Pos p = queue.poll();
      if (visited[p.i][p.j]) continue;
      visited[p.i][p.j] = true;
      maxDepth = Math.max(maxDepth, p.level);
      for (int[] d : new int[][]{{-1, 0}, {1, 0}, {0, -1}, {0, 1}}) {
        int ni = p.i + d[0];
        int nj = p.j + d[1];
        if (ni >= 0 && ni < H && nj >= 0 && nj < W && map[ni][nj] == '.' && !visited[ni][nj]) {
          queue.add(new Pos(p.level + 1, ni, nj));
        }
      }
    }
    return maxDepth;
  }

  private static class Pos {
    private final int level;
    private final int i;
    private final int j;

    private Pos(int level, int i, int j) {
      this.level = level;
      this.i = i;
      this.j = j;
    }
  }
}


Measured memory_bytes: 41968
import java.util.Scanner;

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

        int result = 0;
        for (int i = 0; i < N; i++) {
            int y = sc.nextInt();
            result = result + Math.min(y , K - y) * 2;
        }
        System.out.println(result);
    }
}


Measured memory_bytes: 21844