akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL

#define MAX 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n;
int M[MAX][MAX]; //u??????v??????????????????

void dijkstra() {
	//?§????s???????§???????v?????§??????????????????
	int d[MAX]; memset(d, 0x3f, sizeof(d)); d[0] = 0;
	int color[MAX] = { GRAY };

	while (true) {
		int minv = INF;
		int u = -1;
		for (int i = 0; i < n; i++) {
			if (minv > d[i] && color[i] != BLACK) {
				u = i;
				minv = d[i];
			}
		}
		if (u == -1)break;
		color[u] = BLACK;
		for (int v = 0; v < n; v++) {
			if (color[v] != BLACK&&M[u][v] != INF) {
				d[v] = min(
					d[v],
					d[u] + M[u][v]
				);
				//if (d[v] > d[u] + M[u][v]) {
				//	d[v] = d[u] + M[u][v];
				//	color[v] = GRAY;
				//}
			}
		}
	}

	for (int i = 0; i < n; i++) {
		cout << i << " " << (d[i] == INF ? -1 : d[i]) << endl;
	}
}

int main() {
	memset(M, 0x3f, sizeof(M));
	cin >> n;
	for (int i = 0; i < n; i++) {
		int u, k;
		cin >> u >> k;
		for (int j = 0; j < k; j++) {
			int v, c;
			cin >> v >> c;
			M[u][v] = c;
		}
	}
	dijkstra();
	return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int n,a[111],dp[111][111][11];

int dfs(int l,int r,int x){
    if(l==r)return x==a[l];
    if(dp[l][r][x]!=-1)return dp[l][r][x];
    dp[l][r][x]=0;
    for(int i=l;i<r;i++){
        for(int j=0;j<10;j++){
            if(dfs(l,i,j)&&dfs(i+1,r,j)) dp[l][r][0]=1 , dp[l][r][j]=1;
            if(dfs(l,i,j)&&dfs(i+1,r,0)) dp[l][r][j]=1;
            if(dfs(l,i,0)&&dfs(i+1,r,j)) dp[l][r][j]=1;
        }
    }
    return dp[l][r][x];
}

int main(){
    memset(dp,-1,sizeof(dp));
    cin>>n;
    r(i,n)cin>>a[i];
    dfs(0,n-1,0);
    cout<<(dp[0][n-1][0]==1?"yes":"no")<<endl;
}


Measured memory_bytes: 3672
#include <bits/stdc++.h>
#define ll long long
const int MOD = 1e9 + 7;
using namespace std;
ll func(int bit,ll a)
{
  return ((a >> bit) & 1);
}
ll d(ll num) {
    ll count = 0;
    while(num) {
        num /= 10;
        count++;
    }
    return count;
}
bool pos(ll num, ll a , ll b, ll x) {

    ll tot = a * num + b * d(num);
    // cout << num << " " << tot << "\n";
    if(tot <= x)
        return true;
    return false;
}
int main() {
    int N;
    string s[] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
    string s1;
    cin >> s1;
    for (int i = 0; i < 7; ++i)
    {
        if(s[i] == s1)
        {
            cout << 7-i << " ";
            break; 
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int main() {
	int a, b, c, d;
	while (scanf(" %d %d", &a, &b) != EOF) {
		d = 1;
		for (c = a + b; c > 9; c /= 10)
			d++;
		printf("%d\n", d);
	}
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,s,n) for(int i = s; i < n; i++)
using namespace std;
map<long long,int>Divisor_Enumeration(long long n){
  map<long long,int>ans;
  for(long long i = 1; i * i <= n; i++){
    if(n % i == 0){
      ans[i]++;
      if(n / i != i)ans[n / i]++;
    }
  }
  return ans;
}
int main(){
  int n;
  cin >> n;
  rep(i,1000000){
    auto a = Divisor_Enumeration(i + 1);
    if(a.size() == n){
      cout << i + 1 << endl;
      return 0;
    }
  }
}



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

int n, sum;
vector<int>v;

int main() {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		sum += i;
		v.push_back(i);
		if (sum >= n)break;
	}
	for (int i = 0; i < v.size(); i++) {
		if (v[i] == sum - n && n != 1)continue;
		cout << v[i] << endl;
	}
}

Measured memory_bytes: 384
#include<stdio.h>
int main(void){
    int i,n,m,a[100]={0},c=0,s=0;
    scanf("%d",&n);
    scanf("%d",&m);
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
        s+=a[i];
    }
    for(i=0;i<n;i++){
        if(a[i]>=(double)s/(4*m)){
            c++;
        }
    }
    if(c>=m){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = int;
ll grundy(const ll A, const ll K)
{
    const ll n = A / K;
    const ll m = A % K;
    const ll l = (m + n) / (n + 1);
    return A == n * K ? n : grundy(A - l * (n + 1), K);
}
int main()
{
    int N;
    cin >> N;
    ll ans = 0;
    for (int i = 0; i < N; i++) {
        ll A, K;
        cin >> A >> K;
        ans = ans ^ grundy(A, K);
    }
    cout << (ans == 0 ? "Aoki" : "Takahashi") << endl;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

int a[2000001],sum[2000001];
int ans[2000001];
int main(){
    int n;
    cin>>n;
    rep(i,n){
        cin>>a[i];
        ++sum[a[i]];
    }
    rep(i,2000000) sum[i+1]+=sum[i];
    for(int i=n-1;i>=0;--i){
        ans[sum[a[i]]]=a[i];
        --sum[a[i]];
    }
    FOR(i,1,n+1) cout<<ans[i]<<(i==n?"":" ");
    cout<<endl;
    return 0;
}


Measured memory_bytes: 26548
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define MAX(a,b) a=a>b?a:b
#define MIN(a,b) a=a<b?a:b
#define REP(i,x,n) for(int i=x;i<n;i++)
#define REPR(i,x,n) for(int i=n-1;i>=x;i--)
#define pb  push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLr(obj) (obj).rbegin(), (obj).rend()
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1e9 + 7;
int main(){
   int n[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
   int a;
   cin>>a;
   cout<<n[a-1]<<endl;

}


Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る

	
	const inputLines = input.split("\n");
	const line0 = inputLines[0];
	const line0vars = line0.split(" ");
	const line1 = inputLines[1];
	const line1vars = line1.split(" ");
	const line2 = inputLines[2];

	const a = parseInt(line0vars[0], 10);
	const v = parseInt(line0vars[1], 10);
	
	const b = parseInt(line1vars[0], 10);
	const w = parseInt(line1vars[1], 10);

	const t = parseInt(line2, 10);

	if (v <= w) {
		console.log((a === b) ? "YES" : "NO");
		return;
	}
	const time = Math.abs(b - a) / Math.abs(v - w);
	console.log((0 < time && time <= t) ? "YES" : "NO");
	return;

	// tmp = input[1].split(" ");
	// //文字列から10進数に変換するときはparseIntを使います
	// var a = parseInt(input[0], 10);
	// var b = parseInt(tmp[0], 10);
	// var c = parseInt(tmp[1], 10);
	// var s = input[2];

	//出力
	// console.log('%d %s',a+b+c,s);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

// node index.js
// 1
// 2 3
// test
// (Ctrl + D)


Measured memory_bytes: 29620
from statistics import mean

N = int(input())
a = [int(i) for i in input().split()]

a_mean = mean(a)

ans = 0
ans_dist = max(a)
for i, frame in enumerate(a):
    dist = abs(frame - a_mean)
    if dist < ans_dist:
        ans_dist = dist
        ans = i

print(ans)


Measured memory_bytes: 5640
use std::collections::BTreeMap;

fn read_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_owned()
}

fn reads<T>() -> Vec<T>
where
    T: std::str::FromStr,
    <T as std::str::FromStr>::Err: std::fmt::Debug,
{
    read_line()
        .split_whitespace()
        .map(|w| w.parse().unwrap())
        .collect()
}

fn main() {
    let (h, w, d) = {
        let t = reads::<i32>();
        (t[0] as usize, t[1] as usize, t[2])
    };

    let bd: Vec<Vec<i32>> = (0..h).map(|_| reads()).collect();

    let mut rev = vec![(0, 0); h * w];

    for y in 0..h {
        for x in 0..w {
            rev[bd[y][x] as usize - 1] = (x, y);
        }
    }

    let mut acc = vec![0; h * w];

    let dist = |(a, b): (usize, usize), (c, d): (usize, usize)| -> i32 {
        (a as i32 - c as i32).abs() + (b as i32 - d as i32).abs()
    };

    for i in 0..h * w {
        if i as i32 - d >= 0 {
            acc[i] = acc[i - d as usize] + dist(rev[i], rev[i - d as usize]);
        }
    }

    let q = reads()[0];

    for _ in 0..q {
        let (l, r) = {
            let t = reads::<usize>();
            (t[0], t[1])
        };

        println!("{}", acc[r - 1] - acc[l - 1]);
    }
}


Measured memory_bytes: 7292
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int gcd(int x, int y) { return (x % y) ? gcd(y, x % y) : y; }
const double PI = 3.14159265358979323846;
int main() {
  int n, k;
  cin >> n >> k;
  int a[n] = {0};
  int b;
  int d;
  for (int i = 0; i < k; i++) {
    cin >> b;
    for (int j = 0; j < b; j++) {
      cin >> d;
      a[d - 1]++;
      // cout << "a[d-1]" << a[d - 1] << endl;
    }
  }
  int ans = 0;
  for (int l = 0; l < n; l++) {
    if (a[l] == 0) ans++;
  }
  cout << ans;
  return 0;
}

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

typedef long long ll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    vector<pair<string,int>>pii;
    ll n,sum=0,i,a,j;
    string str,str1;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>str>>a;
        pii.push_back(make_pair(str,a));
        sum+=a;
    }
    cin>>str1;
    for(i=0;i<n;i++)
    {
        if(pii[i].first==str1)
        {
            sum-=pii[i].second;
            j=i;
            break;
        }
    }
    for(j=i-1;j>=0;j--)
    {
        sum-=pii[j].second;
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
k, n = map(int, input().split())
aa = list(map(int, input().split()))
aa.sort()
# 家間の距離の最も遠い家のルートを使わないように回る。k - max(aa_diff)
aa_diff = [min(k - abs(aa[-1]-aa[0]), abs(aa[-1]-aa[0]))]
for a1, a2 in zip(aa[1:], aa[:-1]):
    aa_diff.append(min(k - abs(a1 - a2), abs(a1 - a2)))
print(k-max(aa_diff))

Measured memory_bytes: 26436
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int A[] = new int[N];

		for (int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
		}
		for (int k = 0; k < N; k++) {
			if (k == N - 1) {
				System.out.println(A[k]);
			} else {
				System.out.print(A[k] + " ");
			}
		}
		int v;
		int j;
		for (int i = 1; i <= N - 1; i++) {

			v = A[i];
			j = i - 1;
			while (j >= 0 && A[j] > v) {
				A[j + 1] = A[j];
				j--;
			}
			A[j + 1] = v;
			for (int k = 0; k < N; k++) {
				if (k == N - 1) {
					System.out.println(A[k]);
				} else {
					System.out.print(A[k] + " ");
				}
			}
		}

	}

}

Measured memory_bytes: 31620
n = int(input())
s = list(map(int, input().split()))
cnt = 0
for i in range(1, n - 1):
    if s[i] < s[i + 1] and s[i - 1] <= s[i]:
        cnt += 1
    elif s[i] < s[i - 1] and s[i + 1] <= s[i]:
        cnt += 1
print(cnt)


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

using namespace std;

#define ll long long

ll x, m;

int main() {
    cin >> x;
    for (ll i = -150; i <= 150; i++){
        for (ll j = -150; j <= 150; j++){
            m = pow(i, 5) - pow(j, 5);
            if (m == x){
                cout << i << " " << j;
                exit(0);
            }
        }
    }
}

Measured memory_bytes: 4016
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define MAXN 100100
#define ll long long
ll n, m, a[510][510], dis[510][510], p[500100], ans;
void dfs(ll x, ll y)
{
	if(dis[x-1][y] > dis[x][y] + a[x][y])
	{
		dis[x-1][y] = dis[x][y] + a[x][y];
		dfs(x-1, y);
	}
	if(dis[x][y-1] > dis[x][y] + a[x][y])
	{
		dis[x][y-1] = dis[x][y] + a[x][y];
		dfs(x, y-1);
	}
	if(dis[x+1][y] > dis[x][y] + a[x][y])
	{
		dis[x+1][y] = dis[x][y] + a[x][y];
		dfs(x+1, y);
	}
	if(dis[x][y+1] > dis[x][y] + a[x][y])
	{
		dis[x][y+1] = dis[x][y] + a[x][y];
		dfs(x, y+1);
	}
}
int main()
{
	scanf("%lld",&n);
	for(ll i=1;i<=n*n;i++) scanf("%lld",&p[i]);
	for(ll i=1;i<=n;i++)
	{
		for(ll j=1;j<=n;j++)
		{
			a[i][j] = 1;
			dis[i][j] = min(i-1, min(j-1, min(n-i, n-j)));
		}
	}
	int x, y;
	for(ll i=1;i<=n*n;i++)
	{
		y = p[i]%n;
		if(y==0) y=n;
		x = (p[i]-y)/n+1;
		ans += dis[x][y];
		a[x][y] = 0;
		dfs(x, y);
	}
	printf("%lld\n",ans);
	
	return 0;
}

Measured memory_bytes: 32272
#include <stdio.h>
int main(void){
	int x,a,b;
	scanf("%d%d%d",&x,&a,&b);
	if(b-a<x+1){
		if(b-a<1){
			printf("delicious");
		}else{
			printf("safe");
		}
	}else{
		printf("dangerous");
	}
	return 0;
}

Measured memory_bytes: 128
const bool TEST=0;
#include<iostream>
#include<cctype>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<map>
#include<queue>
#include<set>
#include<cctype>
#include<cstring>
#include<utility>
#include<cmath>
#include<sstream>
#include<stack>
const int inf=0x7fffffff;
#define IF if(TEST)
#define FI if(!TEST)
#define gts(s) fgets((s),sizeof(s),stdin)
#define ALL(s) (s).begin(),(s).end()
#define MK(a,b) make_pair((a),(b))
typedef long long int LL;
typedef unsigned int U;
typedef unsigned long long ULL;
using namespace std;
typedef pair<int,int> Point;
template <typename T>
void pA(T *begin,int n){ for(int i=0;i<n;i++){ cout<<*(begin++); } printf("\n"); }
const int N =1e5+1e5;
int dat[N];
void sol(){
	int n;
	cin>>n;
	int x;
	bool flag2=0;
	while(n--){
		scanf("%d", &x);
		dat[x]++;
		if(dat[x]==3)dat[x]-=2;
	}
	IF pA(dat,9);
	for(int i =0 ;i < N ;i++){
		if(dat[i]==2){
			if(flag2){
				dat[x]--;
				flag2=0;
				dat[i]--;
			}
			else {
				x=i;
				flag2=1;
			}
		}
	}
	IF pA(dat,9);
	if(flag2){
		dat[x]-=2;
	}
	IF pA(dat,9);
	int cnt=0;
	for(int i = 0;i<N;i++){
		if(dat[i])cnt++;
	}
	cout<<cnt<<endl;
}
int main()
{
	sol();
	return 0;
}
//D.cc
//generated automatically at Sat Jan 28 20:34:39 2017
//by xsthunder


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
/******************************************
* AUTHOR : PANDRAVISAM SHIVA SANTHOSH *
* Handle : santhosh_80 *
* INSTITUTION : IIT Palakkad *
******************************************/
typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
#define ll long long int 
#define mod 1000000007
#define rep(i,a,b) for(int i=a;i<b;i++)
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define S(x) scanf("%d",&(x))
#define P(x) printf("%d\n",(x))
#define Sl(x) scanf("%lld",&(x))
#define Pl(x) printf("%lld\n",(x))
#define pb push_back
#define f first
#define s second

double dp[3000][3000] ;

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

	int n ; cin >> n ;
	vector<double> vi(n+1) ;

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

	dp[0][0] = 1.0 ;

	// dp is all about how you are dividing the subproblem, if you
	// get it , then you got it 

	for(int i = 1; i <= n ; i++){
		for(int j = 0; j <= i ; j++) {

			if( j == 0){
				dp[i][j] = dp[i-1][j]*(1.0-vi[i]);
			}
			else{
				dp[i][j] = dp[i-1][j-1]*vi[i] +dp[i-1][j]*(1.0-vi[i]) ;
			}

		}
	}

	double ans = 0.0 ;

	for(int i = (n+1)/2 ; i <= n ; i++)ans+=dp[n][i] ;

	cout << setprecision(11) << ans ;

 	return 0;
}

Measured memory_bytes: 68992
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC086A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b;
            var word = Console.ReadLine().Split(' ');
            a = int.Parse(word[0]);
            b = int.Parse(word[1]);

            if (a % 2 == 0 || b % 2 == 0)
                Console.WriteLine("Even");
            else
                Console.WriteLine("Odd");
                Console.ReadKey();
        }
    }
}


Measured memory_bytes: 13140
#include<stdio.h>

long long inp_t, inp_c, inp_n, i1, bal = 100;

long long inp_a[200005];

long long readNumber() {
	long long temp_func;
	scanf("%lld", &temp_func);
	return temp_func;
};
long long printNumber(long long temp_func) {
	printf("%lld", temp_func);
	return 0;
};

long long caler() {
	
	for (long long i1f = 1; i1f <= 4000; i1f++) {
		
		bal += bal / 100;
		
		if (bal >= inp_n) {
			
			return i1f;
			
		};
		
	};
	
};

int main() {
	
	inp_n = readNumber();
	
	printNumber(caler());
	
}

Measured memory_bytes: 1736
#pragma region template
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 998244353, MAX = 1e18, larg = 1e5, INF = -1e18;
long long A, B, C, D, E, F, G, H, I, J, K, L, N, M, O, P, Q, R, S, T, U, V, W, x, y, z;
long long max_value = INF, max_index = -1;
long long min_value = MAX, min_index = -1;
typedef long long ll;

/*一致文字数を計算する(計算量|S|)*/
ll* Z_algorithm(string S){
	ll i = 1, j = 0;
	ll* R;
	R = (ll*)malloc(sizeof(string)*S.length());
	R[0] = S.size();
	while (i < S.size()) {
		while (i+j < S.size() && S[j] == S[i+j]) ++j;
		R[i] = j;
		if (j == 0) { ++i; continue;}
		ll k = 1;
		while (i+k < S.size() && k+R[k] < j) R[i+k] = R[k], ++k;
		i += k; j -= k;
	}
	return R;
}

int main() {
	cin.tie(0); ios_base::sync_with_stdio(false);
	string S;
	ll _max = 0;
	cin >> N >> S;
	rep(i, N){
		ll* R = Z_algorithm(S.substr(i));
		rep(j, N-i-1){
			if(R[j+1] <= j+1) _max = max(_max, R[j+1]);
		}
		free(R);
	}
	cout << _max;
}

Measured memory_bytes: 3796
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
typedef long long ll;
int main() {
	int n;
	cin >> n;
	vector<int> v(n);
	rep(i,n) cin >> v[i];
	ll y = 1000;
	rep(i,n) {
		int s = v[i];
		ll t = y / v[i];
		while (i + 1 < n && v[i] <= v[i+1]) i++;
		y = (y - t * s) + (t * v[i]);
	}
	cout << y << endl;
}

Measured memory_bytes: 3616
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int N;
		int Z;
		N = scanner.nextInt();
		Z = N;
		int ans = 0;
		while(N > 0){
			ans += N % 10;
			N /= 10;
		}
		if (Z % ans == 0){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}

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

class Dice{
  public:
    int face[6];

    void north(){
      int tmp = face[0];
      face[0] = face[1];
      face[1] = face[5];
      face[5] = face[4];
      face[4] = tmp;
    }

    void south(){
      int tmp = face[0];
      face[0] = face[4];
      face[4] = face[5];
      face[5] = face[1];
      face[1] = tmp;
    }

    void west(){
      int tmp = face[0];
      face[0] = face[2];
      face[2] = face[5];
      face[5] = face[3];
      face[3] = tmp;
    }

    void east(){
      int tmp = face[0];
      face[0] = face[3];
      face[3] = face[5];
      face[5] = face[2];
      face[2] = tmp;
    }

    void print(int x){
      cout << face[x-1] << endl;
    }
};

int main(){
  Dice d;
  char dir;

  for ( int i = 0; i < 6; i++ ){
    cin >> d.face[i];
  }

  while ( cin >> dir ){
    if ( dir == 'N' ) d.north();
    else if ( dir == 'S' ) d.south();
    else if ( dir == 'W' ) d.west();
    else d.east();
  }

  d.print(1);

  return 0;
}
      


Measured memory_bytes: 3080
#include <bits/stdc++.h>
#define ll long long

using namespace std;

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

	ll x;
	cin >> x;

	ll b;

	for(b=0; b<=1e3; b++){
        ll p_b=1;
        for(ll i=0; i<5; i++)
            p_b=(ll)p_b*b;
        ll a1=x+p_b, a2=x-p_b;
        for(ll i=-1e3-100; i<=1e3+100; i++){
            ll prod=1;
            for(ll j=0; j<5; j++)
                prod=(ll)prod*i;
            if(prod==a1){
                cout << i << " " << b << endl;
                return 0;
            }
            if(prod==a2){
                cout << i << " " << (ll)-1*b << endl;
                return 0;
            }
        }

	}

	return 0;
}


Measured memory_bytes: 3596
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

def foo(i):
    print(i,flush=True)
    s = ins()
    a[i] = h[s]
    if h[s]==1:
        exit()

h = {'Vacant':1, 'Male':2, 'Female':3}
n = inn()
a = [0]*(n+1)
foo(0)
a[n] = a[0]
p = 0
q = n
while True:
    r = (p+q)//2
    foo(r)
    if a[r]==a[p] and (r-p)%2==1 or a[r]!=a[p] and (r-p)%2==0:
        q = r
    else:
        p = r
        #ddprint(a)
    #ddprint(f"p {p} q {q}")



Measured memory_bytes: 4424
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<typename T> istream& operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream& operator<<(ostream &os, vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream& operator<<(ostream &os, set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream& operator<<(ostream &os, unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream& operator<<(ostream &os, multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream& operator<<(ostream &os, unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream& operator<<(ostream &os, pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream& operator<<(ostream &os, map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream& operator<<(ostream &os, unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;



int main()
{
    int N;
    cin >> N;
    cout << "Christmas";
    REP(_, 25 - N) cout << " Eve";
    cout << endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
      	//データ取り込み
		Scanner sc = new Scanner(System.in);
 
		int N = sc.nextInt();
      	int A = sc.nextInt();
      int B = sc.nextInt();
      int max = 0;
      int min = 0;
   		if(A>B){
          max = B;
        }else{
          max = A;
        }
       if(A+B-N>=0){
       	min = A+B-N;
       }
       	System.out.println(max+" "+min);
    }
}

Measured memory_bytes: 23124
def bfs(branch,n):
	arrival = [0 for i in range(n+1)]
	q = [1]
	arrival[q[0]]=1
	while len(q) >= 1:
		for k in range(len(branch[q[0]])):
			if arrival[branch[q[0]][k]] == 0:
				arrival[branch[q[0]][k]] = arrival[q[0]] + 1
				q.append(branch[q[0]][k])
		q.pop(0)
	return arrival

n,m = map(int,input().split())
branch = dict()
for i in range(1,n+1):
    branch[i] = []
pair = []
for i in range(m):
    a,b = map(int,input().split())
    pair.append([a,b])
    branch[a].append(b)
    branch[b].append(a)
counter = 0

for i in range(m):
    branch[pair[i][0]].remove(pair[i][1])
    branch[pair[i][1]].remove(pair[i][0])
    arrival = bfs(branch,n)
    check = True
    for k in range(1,n+1):
        if arrival[k] == 0:
            check = False
    if check:
        counter += 1
    branch[pair[i][0]].append(pair[i][1])
    branch[pair[i][1]].append(pair[i][0])
print(m-counter)

Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    ll N,K;
    cin >> N >> K;
    ll ans = 0;
    for(ll i=K;i<=N+1;i++){ // iをllで宣言することを忘れない
        // 連続する数列なので最小値～最大値の間の数はすべて作れる
        // 0からi個目の和-> i*(0+i-1)/2
        // N-i+1からNまでの和-> i*(N+(N-i+1))/2
        ans += i*(N+(N-i+1))/2 - i*(0+i-1)/2 + 1;
        ans = (ans+MOD)%MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <iomanip>

using namespace std;

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

    if(a>8 || b>8){
        cout << ":(" << endl;
    }
    else{
        cout << "Yay!" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
from collections import Counter

N = int(input())
A = list(map(int,input().split()))
a = list(set(A))
cc = Counter(A)
dup = set([x for x in a if cc[x] > 1])
c_l = [(cc[i]-1)*(cc[i])/2 for i in a]
al = sum(c_l)

# for k in A:
#     if k in dup:
#         print(int(al-cc[k]+1))
#     else :
#         print(int(al))
[print(int(al-cc[k]+1)) if k in dup else print(int(al)) for k in A]

Measured memory_bytes: 107468
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define repd(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;
using Graph = vector<vector<int>>; // グラフ型
using pint = pair<int, int>;

int main()
{
    int N;
    cin >> N;
    vector<int> P(N), Q(N);
    rep(i, N)
    {
        cin >> P[i];
    }
    rep(i, N)
    {
        cin >> Q[i];
    }
    vector<int> R(N);
    rep(i, N)
    {
        R[i] = i + 1;
    }
    int count = 0;
    int a, b;
    do
    {
        ++count;
        if (R == P)
        {
            a = count;
        }
        if (R == Q)
        {
            b = count;
        }

    } while (next_permutation(R.begin(), R.end()));
    cout << abs(a - b) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<list>
#include<map>
#include<numeric>
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define ll long long

using namespace std;

//最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) {
		return a;
	}
	return gcd(b, a % b);
}

//最小公倍数
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}

ll pro1(ll a) {
	while (a / 10 != 0) {
		a = a % 10;
	}
	return a;
}

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

	vector<ll>x = { 1,2,3,4,5,6,7,8,9 };
	vector<ll>y = {};
	vector<ll>ans = x;
	ll cnt = 0;

	while (cnt < k) {

		rep(i, x.size()) {

			rep(j, 10) {

				ll temp = x[i] * 10 + j;
				if (abs(pro1(x[i]) - j) <= 1) {
					y.push_back(temp);
					ans.push_back(temp);
					cnt++;
				}

			}

		}

		x = {};
		rep(i, y.size()) {
			x.push_back(y[i]);
		}
		y = {};

	}

	cout << ans[k-1];
	return 0;
}

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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }

void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
 
//Write From this Line

//const ll mod = 1e9+7;
//const ll mod = 998244353;
int main()
{
	int x;
	cin >> x;
	int ans;
	if(x < 600) ans = 8;
	else if(x < 800) ans = 7;
	else if(x < 1000) ans = 6;
	else if(x < 1200) ans = 5;
	else if(x < 1400) ans = 4;
	else if(x < 1600) ans = 3;
	else if(x < 1800) ans = 2;
	else if(x < 2000) ans = 1;
	cout << ans << endl;
}


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

using namespace std;

bool is_vowel(char x)
{
    return (x == 'a' || x == 'i' || x == 'u' ||
            x == 'e' || x == 'o');
}

string change(string &s)
{
    string res;
    res += s[0];
    for (int i = 1; i < (int)s.size(); i++) {
        if (is_vowel(s[i-1])) {
            res += s[i];
        }
    }    
    return res;
}

bool check(vector<string> &t, int k, int N)
{
    set<string> st;
    for (int i = 0; i < (int)t.size(); i++) {
        if ((int)t[i].size() < k) {
            st.insert(t[i]);
        } else {
            st.insert(t[i].substr(0, k));
        }
    }
    return ((int)st.size() == N);
}

int main()
{
    int N;
    while (cin >> N, N) {
        string s;
        vector<string> t(N);
        for (int i = 0; i < N; i++) {
            cin >> s;
            t[i] = change(s);
        }
        
        int res = -1;
        for (int k = 1; k <= 50; k++) {
            if (check(t, k, N)) {
                res = k;
                break;
            }
        }
        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 3068
#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    int counters=0;
    for(int i=a;i<=b;i++)
    {
        if(c%i==0)
        {
            counters++;
        }
    }
    cout<<counters<<endl;

    return 0;
}



Measured memory_bytes: 3100
S = input()
T = input()
n = len(S)
s_str = []
s_count = []
t_str = []
t_count = []
for i in range(n):
  if not S[i] in s_str:
    s_str.append(S[i])
    s_count.append(S.count(S[i]))
for i in range(n):
  if not T[i] in t_str:
    t_str.append(T[i])
    t_count.append(T.count(T[i]))
if s_count == t_count:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3632
S = input()
Q = int(input())
Query = [input().split() for i in range(Q)]
countA,countB = 0,0
latter = []
former = []
for i in range(Q):
    if(Query[Q-i-1][0] == "1"):
        countA += 1
        countB += 1
    else:
        t = lambda x:1 if x=="1" else 0
        if((t(Query[Q-i-1][1])+countB)%2 == 1):
            former.append(Query[Q-i-1][2])
        else:
            latter.append(Query[Q-i-1][2])

for i in former:
    print(i,end="")
if(countA%2 == 0):
    print(S,end="")
else:
    for j in range(len(S)):
        print(S[len(S)-j-1],end="")
for i in range(len(latter)):
    print(latter[len(latter)-i-1],end="")

Measured memory_bytes: 42528
// Problem : D - Div Game
// Contest : AtCoder - AtCoder Beginner Contest 169
// URL : https://atcoder.jp/contests/abc169/tasks/abc169_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
#include<set>
#include<map>
#include<bitset>
#define rep(i,a,b)  for(i=a;i<b;i++)
#define Sort(a)	sort(a.begin(),a.end())
#define rev(a)	reverse(a.begin(),a.end())
#define all(a)	(a).begin(),(a).end()
#define vll vector<long long int>
#define lli long long int
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define db double
#define M 1000000007
#define pi 3.1415926535897932384626433832795028841971
#define INF 1e18

#define MAX 200005

using namespace std;
lli min(lli a,lli b){return a<b?a:b;}
lli min(lli a,lli b,lli c){a=min(a,b);a=min(a,c);return a;}
lli max(lli a,lli b){return a>b?a:b;}
lli max(lli a,lli b,lli c){a=max(a,b);a=max(a,c);return a;}
lli dsum(lli n){lli ans=0;while(n){ans+=(n%10);n/=10;}return ans;}
lli power(lli a,lli b){lli res=1;while(b){if(b&1) res=res*a;a=a*a;b>>=1;}return res;}
lli Ceil(lli a,lli b){lli res=a/b;if(a%b!=0)	res++;return res;}

template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }

struct pll{
	lli x,y;
};
bool comp(pll a,pll b){
	if(a.x==b.x)	return a.y<b.y;
	else	return a.x<b.x;
}
void solve(lli the)
{
	char ch;
	db aa,bb,cc,dd,xx;
	string s1,s2,s3,str;
    lli i,j,k,a,b,c,d,n,m,l,r,x,y,z,low,high,mid,sum=0,ans=0,temp,t;
    cin >> n;
    map<lli,lli>ma;
    for(i=2;i*i<=n;i++){
    	if(n%i==0){
    		c=0;
    		while(n%i==0){
    			c++;n/=i;
    		}
    		ma[i]=c;
    	}
    }
    if(n!=1)	ma[n]=1;
    for(auto it=ma.begin();it!=ma.end();it++){
    	a=it->first;
    	b=it->second;//cout<<b<<" ";
    	c=1;
    	while(b>=c){
    		ans++;b-=c;c++;
    	}
    }
    cout<<ans;
    
    
}













int main()
{
	long long int t=1,c=1;
	// scanf("%lld",&t);
	while(t--){
		solve(c);
		c++;
	}
	return 0;
}
/* UJJWAL KESHRI */

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

using ll = long long;

int n, m;
vector<int> s(10);
vector<int> c(10);

int main(int argc, char **argv)
{
	cin >> n >> m;
	for (int i = 0; i < m; ++i)
	{
		cin >> s[i] >> c[i];
	}

	string str;
	for (int i = 0; i <= 999; ++i)
	{
		str = to_string(i);

		bool flag = true;
		for (int j = 0; j < m; ++j)
		{
			if (str[s[j]-1] != '0'+ c[j])
			{
				flag = false;
			}
		}
		if (flag && str.size() == n)
		{
			std::cout << str << std::endl;
			return 0;
		}
	}

	std::cout << -1 << std::endl;
}

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

int main()
{
	int a,b,n,m;
	cin>>a>>b>>n>>m;
	
	long double alpha,beta;
	alpha=m/2.0+n*30;
	beta=m*6;
	
	long double dgree=alpha-beta;
		
	long double ans;
	ans=sqrt(a*a+b*b-2.0*a*b*cos(dgree*3.1415926535897/180.0));
	cout<<fixed<<setprecision(10)<<ans<<endl;
	return 0;
}

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

int main(){
    int N; cin >> N;
    int cnt = 0;
    vector<int> a(N);
    for(int i = 0; i < N; i++) cin >> a.at(i);

    int j = 1;
    for(int i = 0; i < a.size(); i++)
    {
        if(a.at(i) == j) { j++; cnt++;} 
    }
    if(cnt == 0) cout << -1 << endl;
    else cout << N - cnt << endl; 
}

Measured memory_bytes: 1024
antennas = []
for i in range(5):
    antennas.append(int(input()))
k = int(input())
ans = "Yay!"
for i in range(4):
    for j in range(i+1,5):
        if antennas[j] - antennas[i] > k:
            ans = ":("
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
struct E{
  ll to,cost;
  E(ll to,ll cost):to(to),cost(cost){}
};
typedef pair<ll,ll> P;
int main(){
  ll n,m,i,j,k,a,b,c;
  cin>>n>>m;
  vector<E> v[n];
  vector<E> can;
  for(i=0;i<m;i++){
    cin >> a >> b >> c;
    a--;b--;
    if(b==n-1) can.push_back(E(a,c));
    else v[a].push_back(E(b,c));
  }
  ll g[n];
  memset(g,-1,sizeof(g));
  priority_queue<P,vector<P>,greater<P> > q;
  q.push(P(1,0));
  while(!q.empty()){
    P p=q.top();q.pop();
    b=p.first;a=p.second;
    if(~g[a]&&g[a]<=b) continue;
    g[a]=b;
    for(i=0;i<v[a].size();i++){
      if(b<=v[a][i].cost)
	if(!~g[v[a][i].to]||g[v[a][i].to]>v[a][i].cost)
	  q.push(P(v[a][i].cost,v[a][i].to));
    }
  }
  ll ans=-1;
  for(i=0;i<can.size();i++)
    if(~g[can[i].to]&&g[can[i].to]<=can[i].cost) ans=max(ans,can[i].cost);
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 12020
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC114A
{
    class Program
    {
        static void Main(string[] args)
        {
            int x = int.Parse(Console.ReadLine());

            if (x == 3 || x == 5 || x == 7) 
            Console.Write("YES");
            else
            Console.WriteLine("NO");
            Console.ReadKey();

        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
vector<vector<int>> bra(200005);
map<int,int> quest;
vector<int> cnt(200005),sam(200005);
int tmp=0;
void dfs(int a,int p=-1){
    tmp+=quest[a];
    cnt[a-1]=tmp;
    sam[a]=tmp;
    for(auto r:bra[a]){
        if(r==p)continue;
        dfs(r,a);
        tmp=sam[a];
    }
}

int main(){
    int n,q;
    cin >> n >> q;
    for(int i=0; i<n-1; i++){
        int a,b;
        cin >> a >> b;
        bra[a].push_back(b);
        bra[b].push_back(a);
    }
    for(int i=0; i<q; i++){
        int p,x;
        cin >> p >> x;
        quest[p]+=x;
    }
    dfs(1);
    for(int i=0; i<n; i++){
        cout << cnt[i] << " ";
    }
    cout << endl;
}

Measured memory_bytes: 39936
// AtCoder ABC139: D - ModSum
// 2019.9.2 bal4u

#include <stdio.h>

int main()
{
	int N; long long ans;
	
	scanf("%d", &N);
	ans = (long long)N * (N-1) / 2;
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 128
s=raw_input()
while True:
    isDeleted=False
    if s[-7:] == "dreamer":
        s = s[:-7]
        isDeleted=True
    elif s[-6:] == "eraser":
        s = s[:-6]
        isDeleted=True
    elif s[-5:] == "erase" or s[-5:] == "dream":
        s = s[:-5]
        isDeleted=True
    if not isDeleted: break
if len(s)==0: print "YES"
else: print "NO"

Measured memory_bytes: 2820
#include<iostream>
#include<vector>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;

int main(){
	string s;
	cin>>s;
	int s_sum = 0;
	int sum=0;
	rep(i,s.size()){
		if(s[i]=='S'){
			s_sum++;
			sum++;
		}else{
			if(s_sum==0){
				sum++;
			}else{
				s_sum--;
				sum--;
			}
		}
	}
	cout<<sum<<endl;
	return 0;
}

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

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

	int Q = A / 1000;
	int W = A % 1000 / 100;
	int E = A % 1000 % 100 / 10;
	int R = A % 1000 % 100 % 10;

	if (Q + W + E + R == 7) {
		cout << Q << '+' << W << '+' << E << '+' << R << '=' << 7 << endl;
		return 0;
	}
	else if (Q + W + E - R == 7) {
		cout << Q << '+' << W << '+' << E << '-' << R << '=' << 7 << endl;
		return 0;
	}
	else if (Q + W - E + R == 7) {
		cout << Q << '+' << W << '-' << E << '+' << R << '=' << 7 << endl;
		return 0;
	}
	else if (Q + W - E - R == 7) {
		cout << Q << '+' << W << '-' << E << '-' << R << '=' << 7 << endl;
		return 0;
	}
	else if (Q - W - E - R == 7) {
		cout << Q << '-' << W << '-' << E << '-' << R << '=' << 7 << endl;
		return 0;
	}
	else if (Q - W - E + R == 7) {
		cout << Q << '-' << W << '-' << E << '+' << R << '=' << 7 << endl;
		return 0;
	}
	else if (Q - W + E - R == 7) {
		cout << Q << '-' << W << '+' << E << '-' << R << '=' << 7 << endl;
		return 0;
	}	
	else if (Q - W + E + R == 7) {
		cout << Q << '-' << W << '+' << E << '+' << R << '=' << 7 << endl;
		return 0;
	}
}

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

using namespace std;
using namespace __gnu_pbds; // namespace for pb_ds

/* short forms */
#define Accelerate                    \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL)
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define mt make_tuple
#define cld(x, y) (((x) / (y)) + ((x) % (y) != 0)) //integer ceil division
#define tc(tt) \
    int tt;    \
    cin >> tt; \
    for (int _tt = 0; _tt < tt; _tt++) // testcase
#define all(cont) (cont).begin(), (cont).end()
#define sz(cont) (int)(cont).size()
#define endl '\n'
#define cout_p(x, p) cout << fixed << setprecision((p)) << x << endl //print with precision
#define dbg(x) cerr << #x << "is" << (x) << endl
#define leadzero(a) __builtin_clz(a)      // count leading zeroes
#define trailzero(a) __builtin_ctz(a)     // count trailing zeroes
#define bitcount(a) __builtin_popcount(a) // count set bits (add ll)

/* constants */
const double PI = 3.1415926535897932384626433832795;
const double EPS = 1e-9;

/* typedefs */
typedef pair<int,int> pii;
typedef priority_queue<int, vector<int>, greater<int> > min_heap;
typedef priority_queue<int, vector<int> > max_heap;
typedef tree<int,null_type, less<int>,rb_tree_tag, tree_order_statistics_node_update> 
    indexed_set; // integer set with indexing / pb_ds

/* main program */
int main() {
    Accelerate;
    int n;
    cin >> n;
    int a[n+1];
    a[0] = 0;
    for(int i=1;i<=n;i++) cin >> a[i];
    for(int i=1;i<=n;i++) {
        if(a[i]>a[i-1]) a[i]--;
    }    
    for(int i=1;i<=n;i++) {
        if(a[i]<a[i-1]) {
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
 
#define int long long
 
// loop
#define FOR(i, a, b) for (int i = (a); i < (b); i++) 	// a ~ b-1	(ascending)
#define REP(i, n) FOR(i, 0, n)							// 0 ~ n-1
#define NREP(i, n) FOR(i, 1, n + 1)						// 1 ~ n
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)	// a ~ b	(descending)
#define RREP(i, n) RFOR(i, n, 0)						// n ~ 0
#define RNREP(i, n) RFOR(i, n, 1)						// n ~ 1
 
// container operation
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define ASORT(c) std::sort((c).begin(), (c).end())
#define DSORT(c) std::sort((c).begin(), (c).end(), std::greater<typeof((c).front())>())
#define SIZE(x) ((int)(x).size())
 
// debug
#define check(x) std::cout << #x << " = " << x << '\n'
 
// print
#define cout(x) std::cout << x << '\n'
 
// type alias
using VI = std::vector<int>;
using VII = std::vector<VI>;
using VB = std::vector<bool>;
using VBB = std::vector<VB>;
using VS = std::vector<std::string>;
using PII = std::pair<int, int>;

std::string yes = "Yes\n";
std::string no = "No\n";

void solve();

signed main() {
  solve();
  return 0;
}

void solve() {
  std::string s;
  std::cin >> s;
  cout(s.substr(0, 5) << ' ' << s.substr(6, 7) << ' ' << s.substr(14, 5));
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
    int num,temp,pre,i,ans=0;
    scanf("%d",&num);
    for (i=1;i<num;i++) {
        scanf("%d",&temp);
        if (i==1) {
            ans+=temp;
        }
        else if (temp<pre) {  //今の数が前の数より大きいとき
            ans+=temp;
        }
        else {  //前の数が今の数より大きいとき
            ans+=pre;
        }
        pre=temp;
    }
    printf("%d\n",ans+pre);
    return 0;
}

Measured memory_bytes: 128
import bisect


def typical_stairs(N: int, M: int, A: list)->int:
    MOD = 10**9 + 7

    A.sort()
    A.append(float('inf'))

    dp = [0] * (N+1)
    dp[0] = 1

    for i in range(N):
        if A[bisect.bisect_left(A, i+1)] == i+1:
            dp[i+1] = 0
        else:
            dp[i+1] = dp[i]
            if i > 0:
                dp[i+1] += dp[i-1]
                dp[i+1] %= MOD

    # print(dp)
    return dp[N]


if __name__ == "__main__":
    M = 0

    N, M = map(int, input().split())
    A = [int(input()) for _ in range(M)]

    ans = typical_stairs(N, M, A)
    print(ans)


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

using namespace std;
int main(){
	int i,j,k,n,ans,x;
	int a[2][101];
	cin >> n;
	for(i=0;i<n;i++){
		cin >> a[0][i];
	}
	for(i=0;i<n;i++){
		cin >> a[1][i];
	}
	ans = 0;
	for(i=0;i<n;i++){
		x = 0;
		for(j=0;j<=i;j++){
			x += a[0][j];
		}
		for(k=i;k<n;k++){
			x += a[1][k];
		}
		ans = max(x,ans);
	}
	cout << ans << endl;
}

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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define ALL(a) a.begin(),a.end()
#define INIT(a,b) memset(a,b,sizeof(a))
using lint = long long int;

int main() {
    int N, K;
    cin >> N >> K;

    vector<int> P(N);
    for_(i,0,N) cin >> P[i];
    sort(ALL(P));

    cout << accumulate(P.begin(), P.begin() + K, int()) << endl;
}

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

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

int getChar (char ch)
{
	if (ch=='A') return 1;
	else if (ch=='C') return 2;
	else if (ch=='G') return 3;
	else if (ch=='T') return 4;
	else return 0;
}

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*=7;
	}
	return sum;
} 

int h1(int key)
{
	return key%M;
}

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

int find (char str[])
{
	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[])
{
	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;
		}
	}
}
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)) printf ("yes\n");
			else printf ("no\n");
		}
	}
	return 0;
}


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

int comb(int n, int r){
    if(r == 0)return 1;
    return comb(n, r-1) * (n-r+1) / r;
}

void output( vector<int> u, vector<int> v){
    cout << u.size() << endl;
    for(int i =0; i < u.size(); i++){
        cout << u[i] << " " << v[i] << endl;
    }
}

int main(){
    int N, K;

    cin >> N >> K;
    
    int maxK = comb(N-1, 2);
    int limit = maxK - K;
    int count = 0;

    if(limit < 0){
        cout << -1 << endl;
        return 0;
    }
    vector<int> u,v;
    for(int i=2; i <= N; i++){
        u.push_back(1);
        v.push_back(i);
    }
    // K : maxK;
   
    for(int i = 2; i < N; i++){
        for(int j = i+1; j<=N; j++){
            if(count >= limit){
                output(u, v);
                return 0;
            }
            u.push_back(i);
            v.push_back(j);
            count++;
        }
    }

    output(u, v);
    return 0;
}

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

int main()
{
	int n;
	char str[100000], out[100000];
	char tmp[100000];

	while (cin >> n, n){
		cin >> str;
		for (int i = 0; i < n; i++){
			int cnt = 1;
			out[0] = '\0'; // clean
			for (int j = 0; j < strlen(str); j++){
				if (str[j] == str[j + 1]){
					cnt++;
				}
				else {
					sprintf(tmp, "%d%c", cnt, str[j]); // tmp <- cnt + str[j]
					strcat(out, tmp);
					cnt = 1;
				}
			}
			strcpy(str, out);
		}
		cout << out << endl;
	}

	return (0);
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(15);

  int x, n;
  cin >> x >> n;

  if (n == 0) {
    cout << x << '\n';
    return 0;
  }

  vector<int> p(n);
  for (int i = 0; i < n; ++i) {
    cin >> p[i];
  }
  sort(p.begin(), p.end());

  int cnt = 0;
  int dist = 999;
  int ans = -100;
  for (int i = -100; i <= 200; ++i) {
    if (i == p[cnt]) {
      ++cnt;
      continue;
    }
    if (dist > abs(x - i)) {
      dist = abs(x - i);
      ans = i;
    }
  }

  cout << ans << '\n';

  return 0;
}

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

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

    bool flag = false;
    for(int i = 0; i < 3; i++){
        int x = n % 10;
        if(x == 7){
            flag = true;
            break;
        }else{
            n /= 10;
        }
    }
    cout << (flag ? "Yes" : "No") << endl;
}

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

int main(){
    vector<int> a(5);
    for(int i=0; i<5; i++) a.at(i) = i+1;
    vector<int> x(5);
    for(int i=0; i<5; i++) cin >> x.at(i);

    int ans = 0;
    for(int i=0; i<5; i++){
        if(a.at(i) != x.at(i)) ans = i+1;
    }

    cout << ans << endl;
}

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

int main() {
    int A, B, K; cin >> A >> B >> K;
    if (B < A) {
        swap(A, B);
    }
    int cnt = 1;
    for (int i = A; 1 <= i; i--) {
        if (A%i == 0 && B%i == 0) {
            if (cnt == K) {
                cout << i << endl;
                return 0;
            } else {
                cnt++;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256