akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;
using VD = vector<double>;
using VLL = vector<ll>;
using VS = vector<string>;
using VC = vector<char>;
using VB = vector<bool>;

const int MOD = 1000000007;
const int INF = 1000000000;

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




int main(){
    int n; cin >> n;
    VI a(n);
    REP(i, n) cin >> a[i];
    vector<VLL> dp(n+1, VLL(n+1, 0));//[i,j[　の状態からの点数変化
    FORS(k, 1, n){//k:差
        for(int i = 0; i + k <= n; ++i){
            int j = i + k;
            //後手
            if((n-k) % 2) dp[i][j] = min(dp[i+1][j]-a[i], 
                                         dp[i][j-1]-a[j-1]);
            //先手
            else  dp[i][j] = max(dp[i+1][j]+a[i], 
                                 dp[i][j-1]+a[j-1]);
        }
    }
    cout << dp[0][n] << "\n";
    return 0;
}


Measured memory_bytes: 70784
#include <cmath>
#include <cstdio>
#include <cassert>
#include <cstring>
#include <algorithm>
#define meow(args...) fprintf(stderr, args)
const int N=5005;
int n, k;
char s[N], t[N<<1];
int main() {
	assert(scanf("%d%d%s", &n, &k, s)==3);
	char c=*std::min_element(s, s+n);
	if(k>log2(n)+1) {
		std::fill(s, s+n, c);
		puts(s);
		return 0;
	}
	while(k--) {
		std::copy(s, s+n, t);
		std::reverse_copy(s, s+n, t+n);
		int cho=0;
		for(int i=1; i<=n; ++i) if(strcmp(t+i, t+cho)<0) cho=i;
		std::reverse_copy(t+cho, t+cho+n, s);
	}
	std::reverse(s, s+n);
	puts(s);
	return 0;
}


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

const long long mod=1e9+7;
long long n, k, ans=0;

int main(){
	cin >> n >> k;
	for (long long i=k;i<=n+1;i++){
		long long tmp1=((i-1)*i)/2;
		long long tmp2=(((n+1)*n)/2)-(((n-i+1)*(n-i))/2);
//		cout << i-1 << " " << n << "\n";
//		cout << tmp1 << " " << tmp2 << "\n";
		ans+=tmp2-tmp1+1;
		ans%=mod;
	}
	cout << ans << "\n";
}

Measured memory_bytes: 3632
#include<stdio.h>

int main(void)

{
    int n[3], i, count5 = 0, count7 = 0;
    for (i = 0; i < 3; i++)
    {
        scanf("%d", &n[i]);
        if (n[i] == 5) {
            count5 ++;
        } else if (n[i] == 7) {
            count7 ++;
        }
    }

    if (count5 == 2 && count7 == 1) {
        printf("YES\n");
    } else {
        printf("NO\n");
    }
}


Measured memory_bytes: 128
#include"bits/stdc++.h"
#define sz(a) (int)a.size()
using namespace std;
int main()
{
  ios_base::sync_with_stdio(false); cin.tie(0); 
  int n; cin>>n; vector<int>a(n),v1(n),v2(n); for(int i=0;i<=n-1;i++){ cin>>a[i]; }
  v1[0]=a[0]; v2[n-1]=a[n-1]; for(int i=1;i<=n-1;i++) v1[i]=max(a[i],v1[i-1]); for(int i=n-2;i>=0;i--) v2[i]=max(v2[i+1],a[i]); 
  for(int i=0;i<=n-1;i++)
  {
    if(i==0) { cout<<v2[1]<<"\n";}
    else if(i==n-1){ cout<<v1[n-2]<<"\n"; }
    else cout<<max(v1[i-1],v2[i+1])<<"\n"; 
  }  
  return 0;
}

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

using namespace std;

int main()
{
	int n;
	cin >> n;
	long long a[100010] = {};
	long long sum = 0;
	for (int i = 0; i < n; i++) {
		int t;
		cin >> t;
		a[t]++;
		sum += t;
	}
	
	int q;
	cin >> q;
	for (int i = 0; i < q; i++) {
		int b, c;
		cin >> b >> c;

		sum -= b * a[b];
		sum += c * a[b];
		cout << sum << endl;

		a[c] += a[b];
		a[b] = 0;
	}

	return 0;
}

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

const int N_MAX = 10000;
const int Q_MAX = 500;

int main() {
  int n, q;
  int s[N_MAX + 1], t[Q_MAX + 1];
  cin >> n;
  for (int i = 0; i < n; i++) cin >> s[i];
  cin >> q;
  for (int i = 0; i < q; i++) cin >> t[i];

  int ans = 0;
  for (int i = 0; i < q; i++) {
    s[n] = t[i];
    int j = 0;
    while (s[j] != t[i]) j++;
    if (j < n) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3124
#include <stdio.h>
int abs(int n){
		if(n<0){
		return -1*n;}else
		return n;}
int main(void)
{int N,x,i,l,m,tmp;
	int T[1000];
	int A[1000];
	long long int k1,k2,k;
	long long int t[1000];
	long long int a[1000];
	scanf("%d",&N);
for(i=0;i<=N-1;i++){
	scanf("%d%d",&T[i],&A[i]);}
	t[0]=T[0];
	a[0]=A[0];
	for(m=0;m<=N-2;m++){
		if((t[m]%T[m+1])==0){
			k1=t[m]/T[m+1];}
			else
		k1=(t[m]/T[m+1])+1;
		if((a[m]%A[m+1])==0)
		k2=a[m]/A[m+1];
		else
		k2=(a[m]/A[m+1])+1;
		if(k1>=k2)
		k=k1;
		else
		k=k2;
		t[m+1]=T[m+1]*k;
		a[m+1]=A[m+1]*k;
	}
	printf("%lld",t[N-1]+a[N-1]);



	return 0;
}


Measured memory_bytes: 128
import sys
import copy
from collections import deque
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n = ni()

li = []
for _ in range(n):
    li.append(na())

li.sort()

def solve_odd():
    mid = int((n-1)/2)
    li.sort()
    left = li[mid][0]
    li.sort(key=lambda x: x[1])
    right = li[mid][1]
    print(right-left+1)

def solve_even():
    mid = int(n/2)
    li.sort()
    left1 = li[mid-1][0]
    left2 = li[mid][0]
    li.sort(key=lambda x: x[1])
    right1 = li[mid-1][1]
    right2 = li[mid][1]
    st = (left1+left2)/2
    en = (right1+right2)/2
    print(int((en-st)*2+1))


if n%2:
    solve_odd()
else:
    solve_even()

Measured memory_bytes: 111144
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<complex>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

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

//using Graph=vector<vector<ll>>;

#define ketasitei setprecision(15) //15桁表示

const ll MOD = 1000000007;


int main(void)

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

	ll n;
	cin >> n;
	ll ans = 0;
	for (int i = 1; i <= n; i++)
	{
		if (i % 2 == 0)
			continue;
		ll count = 0;
		for (int j = 1; j <= i; j++)
		{
			if (i % j == 0)
				count++;
		}
		if (count == 8)
			ans++;
	}
	cout << ans << endl;
	debug;
	return 0;
}

Measured memory_bytes: 504
//  cout << char(i+48) << endl;//なぜかaは47と得る時がある。+48で出力もaにできる。
//  cout << char(97) << endl;//アスキーコードでaを出力
// sort(b.begin(), b.end());//bという配列を小さい方からソート
// reverse(b.begin(), b.end());//bという配列をリターン
// 10桁でdouble出力するパターン１ 
// printf("%.10f\n", ma);
// 10桁でdouble出力するパターン２
//cout << fixed << setprecision(10);
//  cout << ma << endl;

/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*///vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
//10の1/2乗（ルート）pow(10, 0.5)
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int n,w;
  cin >> n >> w;
  vector<vector<char>> c(n, vector<char>(w));//int型の2次元配列(3×4要素の)の宣言
  for(int i=0;i<n;i++){
    for(int j=0;j<w;j++){
      cin >> c.at(i).at(j);
    }
  }
  int count = 0;
  vector<vector<char>> d(n*2, vector<char>(w));//int型の2次元配列(3×4要素の)の宣言
  for(int i=0;i<n;i++){
    for(int j=0;j<w;j++){
      d.at(i*2).at(j) = c.at(i).at(j);
      d.at(i*2+1).at(j) = c.at(i).at(j);
    }
  }
  for(int i=0;i<2*n;i++){
    for(int j=0;j<w;j++){
      cout << d.at(i).at(j);
    }
    cout << endl;
  }
}

Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<vector>

using namespace std;
typedef long long int lld;

int main(){
	string s;
	lld k;
	
	cin >> s >> k;
	
	char ans;
	for(int i = 0;i < s.size();i++){
		if(s[i] == '1'){
			if(i == (k-1)){
				ans = s[i];
				break;
			}
		}else{
			ans = s[i];
			break;
		}
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
# N: ボールの個数
# Ai: i番目のボールに書かれている整数
N = int(input())
As = list(map(int, input().split()))
As_sorted = sorted(As)

pre_num = 0
sum_cnt = 0
inner_sum_cnt = 1
num_cnt_list = [0 for i in range(max(As)+1)]  # 各数字が何個入っているかを見る
for A in As_sorted:
    if pre_num == A:
        inner_sum_cnt += 1
    else:
        if pre_num != 0:
            sum_cnt += inner_sum_cnt * (inner_sum_cnt - 1) // 2
            num_cnt_list[pre_num] = inner_sum_cnt
        pre_num = A
        inner_sum_cnt = 1

if pre_num == A:
    sum_cnt += inner_sum_cnt * (inner_sum_cnt - 1) // 2
    num_cnt_list[pre_num] = inner_sum_cnt

for A in As:
    cnt = num_cnt_list[A]
    if cnt < 2:
        print(sum_cnt)
    else:
        print(sum_cnt - cnt + 1)


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

#define ll long long
#define INF_LL 1LL << 60
#define INF 99999999
#define MOD (ll)1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

void put_double(double obj){printf("%.12f\n",obj);};

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

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


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

    cout << A*B - A-B+1 << endl;

}


Measured memory_bytes: 256
import java.util.*;

class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong() -1;
		List<Integer> list = new ArrayList<>();
		
		while(N > 25) {
			list.add((int)(N % 26));
			 N = N / 26 - 1;
		}
		list.add((int)N);
		char[] alphabet = "abcdefghijklmnopqrstuvwxyz".toCharArray(); 
		String ans = "";
		
		//System.out.println(list.size());
		//System.out.println(list.get(list.size()-1));
		
		for(int i = 0; i < list.size(); i++) {
			int index = list.get(list.size()-i-1);
			ans += alphabet[index];
		}
		
		System.out.println(ans);		
	}
}




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

int main(){
  int a,b;

  
  cin >> a >> b;
  
  int x = a*b;
  if(x%2 == 0) cout<< "Even"<<endl;
  else if(x%2 == 1) cout<<"Odd"<<endl;
  
  return 0;
}

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

int main(){
	ll h,w;
	cin>>h>>w;
	if(h==1 || w==1)cout<<1<<endl;
	else if((h*w) % 2)cout<< ((h*w)/2)+1<<endl;
	else cout<<(h*w)/2<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int n;
    cin >> n;
    vector<ll>a(n+5),dp(n+5), sum(n+5);
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
        sum[i] = a[i];
        if(i > 2) sum[i] += sum[i-2];
    }
    for(int i = 2; i <= n; i++) 
        dp[i] = max((i&1?dp:sum)[i-1], dp[i-2] + a[i]);
    cout << dp[n] << endl;
    return 0;
}



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

int main()
{
  int x,y,z,ans;
  cin>>x>>y>>z;
  for(int i=int(ceil(x/y));i>=1;i--)
  {
    if(i*y+(i+1)*z<=x)
       {
         ans = i;
         break;
       }
  }
  cout<<ans<<"\n";
  return 0;
}


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

int main()
{
    int ans1=0,ans2=0,N,M,X;
    cin >> N >> M >> X;
    int A[M];
    
    for(int i = 0; i < M; i++)
    {
        cin >> A[i];
        
        if (A[i]<X) {
            ans1++;
        }else{
            ans2++;
        }
        
    }
    if(ans1<=ans2)
    {
        cout << ans1;
    }else{
        cout<<ans2;
    }
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
dp = [[0] * 4 for _ in range(200005)]
k = 1 + N % 2
for i in range(N + 1):
    for j in range(k + 1):
        dp[i][j] = - float('inf')
dp[0][0] = 0
for i in range(N):
    for j in range(k + 1):
        dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j])
        now = dp[i][j]
        if (i + j) % 2 == 0:
            now += A[i]
        dp[i + 1][j] = max(dp[i + 1][j], now)
ans = dp[N][k]
print(ans)

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

int main(){
	int n;
	string s;
	set<string>p;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>s;
		p.insert(s);
	}
	cout<<p.size()<<endl;
	return 0;
}


Measured memory_bytes: 19168
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String params[] = sc.nextLine().split(" ", 3);

		int n = Integer.parseInt(params[0]);
		int a = Integer.parseInt(params[1]);
		int b = Integer.parseInt(params[2]);

		int sum;

		sum = IntStream.rangeClosed(1, n)
		.filter(i -> sumDigits(i) >= a && sumDigits(i) <= b)
		.sum();

		System.out.println(sum);
	}

	private static int sumDigits(int n) {
		if (n == 0) {
			return 0;
		}
		return n%10 + sumDigits(n/10);
	}

}

Measured memory_bytes: 27476
#include <stdio.h>

int ice[11];

int main(void)
{
	int n, k;
	int i, j;
	
	while (1){
		for (i = 0; i < 10; i++){
			ice[i] = 0;
		}
		scanf("%d", &n);
		if (n == 0){
			return (0);
		}
		for (i = 0; i < n; i++){
			scanf("%d", &k);
			ice[k]++;
		}
		for (i = 0; i < 10; i++){
			if (ice[i] == 0){
				printf("-\n");
			}
			else {  
				for (j = 0; j < ice[i]; j++){
					printf("*");
				}	
				printf("\n");
			}
		}
	}
	return (0);
}
				

Measured memory_bytes: 572
#include<iostream>
 
using namespace std;
 
int main(){
  int n = 0;
  cin >> n;
    
  int m = n % 1000;
  if (m == 0){
  	cout << 0;
  }
  else{
  	cout << 1000-m;
  }
  return 0;
}

Measured memory_bytes: 3564
using System;

public class Hello
{
    static int[,] map;
    static int[] dx = new int[] { 0, 1, 0, -1 };
    static int[] dy = new int[] { 1, 0, -1, 0 };
    static int MAXC;

    public static void Main()
    {
        while (true)
        {
            MAXC = 0;
            var w = int.Parse(Console.ReadLine().Trim());
            var h = int.Parse(Console.ReadLine().Trim());
            if (w == 0 && h == 0) break;
            map = new int[h, w];
            for (int i = 0; i < h; i++)
            {
                string[] line = Console.ReadLine().Trim().Split(' ');
                for (int j = 0; j < w; j++) map[i, j] = int.Parse(line[j]);
            }
            for (int i = 0; i < h; i++)
                for (int j = 0; j < w; j++)
                    if (map[i, j] == 1) goDfs( i, j, 1, h, w);
            Console.WriteLine(MAXC);
        }
    }
    public static void goDfs( int x, int y, int via, int h, int w)
    {
        MAXC = Math.Max(MAXC, via);
        map[x, y] = 0;
        for (int i = 0; i < 4; i++)
        {
            var nx = x + dx[i];
            var ny = y + dy[i];
            if (nx >= 0 && nx < h && ny >= 0 && ny < w && map[nx, ny] == 1)
                goDfs( nx, ny, via + 1, h, w);
        }
        map[x, y] = 1;
    }
}


Measured memory_bytes: 9344
//#include "debug.h"
#include <string.h>
#include <limits.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;

#define MAXN 100000

int n, k;
int a[MAXN];

int input() {
	if (scanf("%d %d", &n, &k) < 0) return 0;
	for (int i=0; i<n; i++) scanf("%d", &a[i]);
	return 1;
}

void init() {
}

long solve() {
	return (n+k-3)/(k-1);
}

void output(long ans) {
	printf("%ld\n", ans);
}

void cleanup() {
}

int main() {
	while (input()) {
		init();
		output(solve());
		cleanup();
		//break;
	}
}





Measured memory_bytes: 512
#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 ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
const ll INF = 1ll<<30;
const ll MOD = 1000000007;
const double EPS  = 1e-9;

int main() {
	ll n, a, b, c, d;
	cin >> n >> a >> b >> c >> d;
	
	b = abs(b - a);
	
	if (c == d) {
		bool ans = false;
		if (d == 0) ans = false;
		else if (b % d != 0) ans = false;
		else {
			 ll cnt = b / d + 1;
			 if (cnt <= n && (n - cnt) % 2 == 0) ans = true;
		}
		
		puts(ans ? "YES" : "NO");
		return 0;
	}
	
	bool ans = false;
	FOR(i, 1, n + 1) {
		ll l = i * c, r = i * d;
		ll cnt = INF;
		
		if (b < l) {
			cnt = (l - b + d - c - 1) / (d - c) * 2 + i + 1;
		}
		else if (l <= b && b <= r) {
			cnt = i + 1;
		}
		else if (r < b) {
			cnt = (b - r + d - c - 1) / (d - c) * 2 + i + 1;
		}
		
		if (cnt <= n && (n - cnt) % 2 == 0) ans = true;
	}
	
	puts(ans ? "YES" : "NO");
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
typedef long long ll;
typedef vector<vector<ll>> vvl;
typedef vector<ll> vl;
typedef vector<vector<char>> vvc;
typedef vector<char> vc;
typedef pair<ll,ll> pll;
typedef priority_queue<string> priquest;
typedef priority_queue<string,vector<string>,greater<string>> rpriquest;
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
  return x+y-max(x,y);
}

const ll big=1000000007;
int exp(int x,int y){
    if(y==0)return 1;//0^0=1
    if(x==1||x==0)return x;
    if(y%2==1)return (exp(x,y-1)*x);
    int t=exp(x,y/2);
    return (t*t);
}
void chmin(ll a,ll b){
    if(a>b)a=b;
    return;
}

int main(){
    int n;cin >> n;
    n%=10;
    if(n==2||n==4||n==5||n==7||n==9)cout << "hon";
    else if(n==3)cout << "bon";
    else cout << "pon";
    cout << endl;
}
//言語選択！！！！！！！！

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

using namespace std;

typedef long long ll;
typedef pair<int, int> PII;

const int MM = 1e9 + 7;
const double eps = 1e-8;

void upd(ll & x, ll y){
	x += y;
	if (x >= MM) x -= MM;
}

const int MAXN = 5555;

ll C[MAXN];
char s[MAXN];

ll f[MAXN][MAXN];

int main(){
	int n;
	scanf("%d%s", &n, s);
	int l  =strlen(s);
	f[0][0] = 1;
	for(int i = 1; i <= n; i++){
		f[i][0] = (f[i-1][0] + f[i-1][1] * 2) % MM;
		for(int j = 1; j <= n; j++)
			f[i][j] = (f[i-1][j-1] + f[i-1][j+1] * 2) % MM;
	}
	cout<<f[n][l]<<endl;
	/*
	C[1] = 1;
	for(int i = 2; i <= n; i++){
		C[i] = 0;
		for(int j = 1; j < i; j++){
			upd(C[i], C[j] * C[i-j] % MM); 
		}
	}
	ll o = 1;
	for(int i = 1; i <= n; i++){
		upd(o, 2);
		C[i] = C[i] * o % MM;
	}
	int l = strlen(s); 
	f[0][0] = 1;
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= l; j++){
			f[i][j] = f[i-1][j-1];
			for(int k = 0; k * 2 <= i; k++){
				upd(f[i][j], f[i-2*k][j] * C[k] % MM);
			}
		}
	ll ans = 0;
	for(int i = 0; i <= n; i++)
		upd(ans, f[i][l] * );
	cout<<ans<<endl;*/
	return 0;
} 

Measured memory_bytes: 215552
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  auto bsearch = [&]() {
    string s0;
    bool done = false;
    auto query = [&](int k) {
      cout << k << endl;
      string res; cin >> res;
      done = (res=="Vacant");
      return res;
    };
    auto test = [&](int k) {
      string res = query(k);
      return ((res==s0 && k%2) || (res!=s0 && k%2==0));
    };
    s0 = query(0);
    if(done) return;
    int ok = N, ng = -1;
    while(ok-ng>1) {
      int mid = (ok+ng)/2;
      (test(mid) ? ok : ng) = mid;
      if(done) return;
    }
  };
  bsearch();
  return 0;
}


Measured memory_bytes: 3792
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define sz(x) int(x.size())
using namespace std;
using ll = long long;
using P = pair<int ,int>;
const int INF = 1001001001;
const int MOD = 1000000007;
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 (b<a) {a=b; return 1;} return 0;}

#ifdef _DEBUG
#include "debug.h"
#else
#define debug(...)
#define print(...)
#endif

int main() {
    int a; cin >> a;
    cout << a + a*a + a*a*a << endl;
}

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

namespace ABC087A
{
    class Program
    {
        static void Main(string[] args)
        {
            int x, a, b, c;
            x = int.Parse(Console.ReadLine());
            a = int.Parse(Console.ReadLine());
            b = int.Parse(Console.ReadLine());

            c = (x - a) % b;

            Console.WriteLine(c);
            Console.ReadKey(); 
        }
    }
}


Measured memory_bytes: 11092
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<utility>
#include<cstdio>
#include<set>
#include<string>
#include<map>
#include<queue>
#include<stack>
#include <bitset>
using namespace std;
const int mod=1e9+7;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,x,n) for (int i= x;i<n;i++)
#define all(v) v.begin(), v.end()
#define nepe(v) next_permutation(all(v))
using ll = long long;
using vi = vector<int>; 
using vvi = vector<vi>;

typedef pair<int,int> P;
string s;
int k;
ll INF = 10000000000000000;

int main(){
    int A,B,C,D;
    cin >>A>>B>>C>>D;
    int turnT,turnA;
    turnT = C/B +1 ;
    if(C%B == 0) turnT-=1;
    turnA = A/D +1;
    if(A%D == 0) turnA -=1;
    if(turnT<=turnA) cout <<"Yes"<<endl;
    else cout << "No"<<endl;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  int n;
  cin>>n;
  vector<ll> a(n);
  rep(i,n) cin>>a[i];
  ll s1=0;
  ll ans1=0;
  rep(i,n) {
    s1+=a[i];
    if(i%2==0) {
      if(s1<=0) {
        ans1+=(1-s1);
        s1=1;
      }
    } else {
      if(s1>=0) {
        ans1+=(s1+1);
        s1=-1;
      }
    }
  }
  ll s2=0;
  ll ans2=0;
  rep(i,n) {
    s2+=a[i];
    if(i%2==0) {
      if(s2>=0) {
        ans2+=(1+s2);
        s2=-1;
      }
    } else {
      if(s2<=0) {
        ans2+=(1-s2);
        s2=1;
      }
    }
  }
//  cout << ans1 << " " << ans2 << endl;
  cout << min(ans1,ans2) << endl;
  return 0;
}


Measured memory_bytes: 1024
N, Ma, Mb = map(int, input().split())
ABC = []

inf = float('inf')
for i in range(N):
    ai, bi, ci = map(int, input().split())
    ABC.append((ai,bi,ci))

dp = [[[inf] * 401 for i in range(401)] for j in range(N + 1)]
dp[0][0][0] = 0

for i in range(N):
    for j in range(401):
        for k in range(401):
            if dp[i][j][k] == inf: continue
            dp[i+1][j][k] = min(dp[i+1][j][k], dp[i][j][k])
            dp[i+1][j+ABC[i][0]][k+ABC[i][1]] = min(dp[i+1][j+ABC[i][0]][k+ABC[i][1]], dp[i][j][k]+ABC[i][2])

ans = inf
for i in range(1, 401):
    for j in range(1, 401):
        if i * Mb == j * Ma:
            ans = min(ans, dp[N][i][j])

if ans == inf: ans = -1
print(ans)


Measured memory_bytes: 59504
#include <iostream>
#include <string>
#include <vector>
#include <bits/stdc++.h>
#define ll long long
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

using namespace std;

int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }

int main(){
    ll n,k; cin >>k>>n;
    vector<int> len(n);
    vector<int> zahyou(n);

    for (int i = 0; i < n; i++)
    {
      cin >> zahyou[i];
    }
    len[0]=k-zahyou[n-1]+zahyou[0];

    for (int i = 0; i < n-1; i++)
    {
      len[i+1] = zahyou[i+1] - zahyou[i];
    }
    sort(len.begin(), len.end());
    int sum = accumulate(len.begin(), len.end(), 0);

    cout << sum-len[n-1] << endl;
    return 0;
    
}


Measured memory_bytes: 1792
import java.util.*
object MainKt {
  @JvmStatic fun main(args:Array<String>) {
    val N=readLine()!!.toInt()
    val K=readLine()!!.toInt()

    val input=readLine()!!.split(" ").map(String::toInt)
    val point=input.indices.map{
      Pair(input[it],it)
    }
    println(point.map{
      val (x,y)=it
      2*arrayOf(Math.abs(K-x),x).min()!!
    }.fold(0) {sum,ele ->sum+ele})
  }
}

Measured memory_bytes: 37824
#pragma comment(linker,"/STACK:1024000000,1024000000")
#pragma GCC optimize(2)
#pragma G++ optimize(2)
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<cstring>
#include<utility>
#include<iostream>
#include<algorithm>
#include<functional>
#include<unordered_map>
#include<unordered_set>
using namespace std;

#define ios ios::sync_with_stdio(false)
#define ll long long
#define pa pair<int,int>
#define sc(n) scanf("%d",&n)
#define ss(s) scanf("%s",s)
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define of(i,a,b) for(int i=a;i>=b;i--)
#define mem(a,b) memset(a,b,sizeof a)
#define uint unsigned int
#define vr vector<int>
#define pi acos(-1)

const ll inf = 0x3f3f3f3f;
const ll mod = 1e9 + 7;
const ll N = 1e6 + 10;

ll a, b;

ll gcd(ll x, ll y)
{
	return y ? gcd(y, x % y) : x;
}

int main()
{
	cin >> a >> b;
	ll c = gcd(a, b);
	ll ans = 1;
	ll tot = 1;
	for (ll i = 2; i * i <= c; i++)
	{
		if (c % i == 0)
		{
			ans++;
			while (c % i == 0)
			{
				c /= i;
			}
		}
	}
	if (c != 1)
		ans++;
	cout << ans <<endl;
}


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

#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define FOR(i,m,n) for(int i=(m) ; i<(n) ; i++)
#define FORR(i,m,n) for(int i=(m) ; i>=(n) ; i--)

typedef long long ll;
typedef unsigned long long ull;

const int INF = 1000000000;

int main(){
   string s;
   cin >> s;
   int l = s.size();
   if(s[0] != 'A'){
      cout << "WA";
      return 0;
   }
   int cnt = 0;
   FOR(i,1,l){
      if(isupper(s[i])){
         if(i == 1 || i == l-1 || s[i] != 'C'){
            cout << "WA";
            return 0;
         }
         cnt++;
      }
   }
   if(cnt != 1){
      cout << "WA";
   }else{
      cout << "AC";
   }
   return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> mypair;
#define inf 1000000
void daikustora(int s,vector<vector<mypair> > &g,vector<int> &cost){
	priority_queue<mypair,vector<mypair> ,greater<mypair> > q;
	cost[s] = 0;
	q.push(mypair(0,s));
	while(!q.empty()){
		mypair now =q.top();
		q.pop();	
		if(now.first>cost[now.second])continue;
		for(int i=0;i<g[now.second].size();i++){
			int next = g[now.second][i].second;
			int ncost = g[now.second][i].first;
			if(cost[next]>cost[now.second]+ncost){
				cost[next] = cost[now.second]+ncost;
				q.push(mypair(cost[next],next));
			}

		}
	}

	return ;
}
int main(){
int n,m;
cin>>n>>m;
int s,f,v,p;
vector<vector<mypair> > g(n+1);
for(int i=0;i<m;i++){
int a,b,c,d;
scanf("%d,%d,%d,%d",&a,&b,&c,&d);
g[a].push_back(mypair(c,b));
g[b].push_back(mypair(d,a));

}
scanf("%d,%d,%d,%d",&s,&f,&v,&p);

vector<int> cost_go(n+1,inf),cost_re(n+1,inf);
daikustora(s,g,cost_go);
daikustora(f,g,cost_re);
p+=cost_go[f]+cost_re[s];
cout<<v-p<<endl;

	return 0;
}



Measured memory_bytes: 3260
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <deque>

#define AS(a) (sizeof(a)/sizeof(a[0]))
using namespace std;
long long int MOD = 1000000007;

int main() {
  int N;
  cin >> N;
  deque<int> v;
  bool b = true;
  int a[N];
  for(int i = 0; i < N; i++) {
    cin >> a[i];
  }
  for(int i = 0; i < N; i++) {
    if(b) {
      v.push_back(a[i]);
      b = false;
    } else {
      v.push_front(a[i]);
      b = true;
    }
  }
  if(b) {
    cout << v.front();
    v.pop_front();
    for(int i = 1; i < N; i++) {
      cout << " " << v.front();
      v.pop_front();
    }
    cout << endl;
  } else {
    cout << v.back();
    v.pop_back();
    for(int i = 1; i < N; i++) {
      cout << " " << v.back();
      v.pop_back();
    }
    cout << endl;
  }




}


Measured memory_bytes: 3840
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100//000000000
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<int, int>
#define PP pair<P,P>
#define T tuple<int,int,int> 
using namespace std;

int main(){
    string s,t; cin >> s >> t;
    int ans=INF;
    int sl=s.length();
    int tl=t.length();
    rep(i,sl-tl+1){
        int tmp=0;
        rep(j,tl){
            if(s[i+j]!=t[j]) tmp++;
        }
        ans=min(ans,tmp);
    }
    cout << ans << endl;
return 0;
}

Measured memory_bytes: 3600
#include <iomanip>
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <tuple>
#include <climits>
#include <algorithm>
#include <cmath>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<double> VD;
typedef vector<LL> VLL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef vector<vector<bool>> VVB;
typedef vector<vector<double>> VVD;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(a) (a).begin(),(a).end()

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

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

int main(){
	int a,b;cin>>a>>b;
	if(a<=0 and b>=0){
		cout<<"Zero"<<endl;
		return 0;
	}
	if(0<a){
		cout<<"Positive"<<endl;
		return 0;
	}
	if((b-a)%2==1){
		cout<<"Positive"<<endl;
		return 0;
	}
	cout<<"Negative"<<endl;
	return 0;
}


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

typedef long long ll;

#define INF 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { debug(itr); }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

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

    int r;
    cin >> r;
    cout << r * r << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mo 1000000007
using namespace std;
long long n,i,k,ans;
struct nyh{
	long long x,y,z;
}o[105];
double ans2;
long long read(){
	long long xx=0;
	char ch=getchar();
	while(ch<'0'||ch>'9')
		ch=getchar();
	while(ch>='0'&&ch<='9'){
		xx=xx*10+ch-'0';
		ch=getchar();
	}
	return xx;
}
long long pus(long long xx,int flagg){
	if(xx>=10)
		pus(xx/10,0);
	putchar(xx%10+'0');
	if(flagg==1)
		putchar(' ');
	if(flagg==2)
		putchar('\n');
}
int ss(long long j,long long u,long long v){
	if(j>n){
		ans=max(ans,u*u+v*v);
		return 0;
	}
	if(j<=10||u*u+v*v<=(u+o[j].x)*(u+o[j].x)+(v+o[j].y)*(v+o[j].y))
		ss(j+1,u+o[j].x,v+o[j].y);
	if(j<=10||u*u+v*v>(u+o[j].x)*(u+o[j].x)+(v+o[j].y)*(v+o[j].y))
		ss(j+1,u,v);
}
bool cmp(nyh u,nyh v){
	return u.z<v.z;
}
int main(){
	
	n=read();
	for(i=1;i<=n;i++)
		scanf("%lld%lld",&o[i].x,&o[i].y);
	for(i=1;i<=1000;i++){
		srand(i*i*123+i*456);
		for(k=1;k<=n;k++)
			o[k].z=rand();
		sort(o+1,o+n+1,cmp);
		ss(1,0,0);
	}
	ans2=sqrt(ans);
	printf("%.13lf\n",ans2);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// #define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
#define ITR(v,c) for(auto v=begin(c);v!=end(c);v++)
#define FORE(x,c) for(auto &x:c)
#define FOR(v,a,n) for(int v=a;v<(int)(n);v++)
#define REP(v,n) FOR(v,0,n)
#define RREP(v,n) for(int v=((int)(n)-1);v>=0;v--)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define SZ(c) ((int)c.size())
const int DX[9]={0,1,0,-1,1,1,-1,-1,0}, DY[9]={-1,0,1,0,-1,1,1,-1,0};
const int INF=1e9; const long long INFLL=1e18;
template<class T> ostream& operator << (ostream &os, const vector<T> &v) {
    ITR(i,v) os<<*i<<(i==end(v)-1?"":" "); return os; }
template<class T> istream& operator >> (istream &is, vector<T> &v) {
    ITR(i,v) is>>*i; return is; }
//------------------------------------------------------------------------------
 
signed main() {
    int N,T;
    cin>>N>>T;
    vi a(N);
    cin>>a;
 
    int M=0,m=INF,max_dif=0;
    REP(i,N) {
        if(m>a[i]) {
            m=a[i];
            M=0;
        }
        else if(M<a[i]) {
            M=a[i];
            max_dif=max(max_dif,M-m);
        }
    }
    
    int ans=0;
    set<int> s;
    REP(i,N) {
        if(s.find(a[i]-max_dif)!=end(s)) {
            ans++;
        }
        s.insert(a[i]);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 5376
#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, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const 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, const 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...); }
template<typename T> bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool mmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first - r.first, l.second - r.second); }
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;
#define FI first
#define SE second
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))


int main()
{
    string S;
    cin >> S;
    cout << S.substr(0, S.length() - 8) << endl;
    return 0;
}


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

int main(int argc, const char * argv[]) {
    // insert code here...
    int N;
    cin >> N;
    
    int total = 0;
    
    /*for (int i = 1; i <= N; i++) {
        total += i;
    }*/
    
    total = (N + 1) * N / 2;
    
    cout << total << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<set>
#include<unordered_set>
#include<map>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const ll MOD = 1000000007;
const int INF = 2000000000;
std::pair<string,pair<int,int>> Q[101];
    ll N,M;
    ll A,B,C;
    bool F[5][5];
    bool ad=false;
    ll ans=0;
    string S;
int main(){
    ios_base::sync_with_stdio(false);
    cin>>S;
    string s=S;reverse(S.begin(),S.end());
    string t=S.substr(0,(S.size()-1)/2);
    string t2=t;reverse(ALL(t));
    string u=S.substr((S.size()+3)/2-1);
    string u2=u;reverse(ALL(u));
    cout<<((S==s&&t==t2&&u==u2)?"Yes":"No")<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define debug(a) cout << #a << ": " << a << endl
int main(){
	int n; cin>>n;
	map<string, int> map;
	for(int a = 1; a <= n; a++){
		string s = to_string(a);
		char FIRST = s[0];
		char SECOND = s.back();
		s.clear();
		s += FIRST;
		s += SECOND;
		++map[s];
	}
	assert((int) map.size() <= 100);
	long long ans = 0;
	for(auto p: map){
		string s = p.first;
		if(s[0] == s[1]){
			int x = p.second;
			ans += (long long) x * x;
		}
		else{
			swap(s[0], s[1]);
			ans += (long long) p.second * map[s];			
		}
	}
	cout<<ans<<endl;
}
	


Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
signed main() {
    vector<int> cnt(26);
    string s; cin >> s;
    for(auto c : s) cnt[ c - 'a' ]++;

    int cntOdd = 0;
    for(auto x : cnt) cntOdd += (x % 2 == 1);

    if(cntOdd > 1) {
        cout << 0 << endl;
    }
    else {
        int sum = 0;
        for(auto x : cnt) sum += x / 2;

        int ans = 1, rem = sum;
        for(auto x : cnt) {
            for(int i=0; i<x/2; i++) {
                ans *= rem--;
                ans /= i + 1;
            }
        }
        cout << ans << endl;
    }
    return 0;
}



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

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

const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;

bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}

ll minll(ll a, ll b){
    if(a >= b)  return b;
    else    return a;
}

ll maxll(ll a, ll b){
    if(a >= b)  return a;
    else    return b;
}

const int SIZE = 1e5+10;
ll n;

ll d[SIZE];

int main(){
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> d[i];
    }
    sort(d,d+n);
    ll ans = d[n/2]-d[n/2-1];

    cout << ans << endl;
}

Measured memory_bytes: 1024
H, W = map(int, input().split())
s = [list(input()) for _ in range(H)]

dp = [[float("inf")] * W for _ in range(H)]
if s[0][0] == "#":
    dp[0][0] = 1
else:
    dp[0][0] = 0

dxdy = [(1, 0), (0, 1)]
for y in range(H):
    for x in range(W):
        for dx, dy in dxdy:
            nx = x + dx
            ny = y + dy
            if nx >= W or ny >= H: continue
            if s[ny][nx] == '#' and s[y][x] == '.':
                dp[ny][nx] = min(dp[ny][nx], dp[y][x] + 1)
            else:
                dp[ny][nx] = min(dp[ny][nx], dp[y][x])

print(dp[-1][-1])


Measured memory_bytes: 3188
#include<iostream>

int main()
{
	int x=1;
	int y=1;
	


	while (x + y){
		std::cin >> x >> y;
		if (x + y == 0){
			break;
		}
		else if (x > y){
			std::cout << y <<' '<< x<<'\n';
		}
		else{
			std::cout << x<<' ' << y<<'\n';
		}

	}
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    string S;
    cin >> S;
    if (S.find('7') == string::npos) {
        cout << "No" << '\n';
    }else {
        cout << "Yes" << '\n';
    }
    

}

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


Measured memory_bytes: 3616
class Array
	def at(index)
		return nil if index < 0
		self[index]
	end
end

# indexは0オリジン
def description(heap, index)
	key             = heap.at(index)
	parent_key      = heap.at((index + 1) / 2 - 1)
	left_child_key  = heap.at(2 * index + 1)
	right_child_key = heap.at(2 * index + 2)

	desc  = "node #{index + 1}: "
	desc += "key = #{key}, " if key
	desc += "parent key = #{parent_key}, " if parent_key
	desc += "left key = #{left_child_key}, " if left_child_key
	desc += "right key = #{right_child_key}, " if right_child_key

	desc
end

n = STDIN.gets.to_i
heap = STDIN.gets.split[0...n].map(&:to_i)
heap.each_index { |i| puts description(heap, i) }

Measured memory_bytes: 6112
#include <bits/stdc++.h>
 using namespace std;
 int main(void){
 int N,M;
 cin >> N >> M;

 const int nmmax=50;
 char A[nmmax][nmmax],B[nmmax][nmmax];


 for(int y=0;y<N;++y){
 for(int x=0;x<N;++x){
 cin >> A[y][x];
 }
 }

 for(int y=0;y<M;++y){
 for(int x=0;x<M;++x){
 cin >> B[y][x];
 }
 }

 bool exist=false;

 for(int ly=0;ly<N;++ly){
 for(int lx=0;lx<N;++lx){
 if(ly+M-1>=N or lx+M-1>=N) continue;

 bool match=true;
 for(int y=0;y<M;++y){
 for(int x=0;x<M;++x){
 if(A[ly+y][lx+x]!=B[y][x]) match=false;
 }
 }
 if(match) exist=true;
 }
 }

 if(exist)
 cout << "Yes" << endl;
 else
 cout << "No" << endl;

 return 0;
 }


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i = 1; i <= (n); ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (ll)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
ll gcd(ll a,ll b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const int INF=1e9;
const ll MX = 1e18;
const ll MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define YN {puts("YES");}else{puts("NO");}
const int MAX = 1000001;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {fac[0] = fac[1] = 1;finv[0] = finv[1] = 1;inv[1] = 1;for (int i = 2; i < MAX; i++){fac[i] = fac[i - 1] * i % MOD;inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;finv[i] = finv[i - 1] * inv[i] % MOD;}}
long long COM(int n, int k){if (n < k) return 0;if (n < 0 || k < 0) return 0;return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;}

int main() {
  string s;
  cin>>s;
  int q;
  cin>>q;
  int ja=0;
  int cntt=0;
  rep(i,q){
    int t;
    cin>>t;
    if(t==1&&len(s)>1){
      cntt++;
      if(ja==0){
        ja=1;
      }else{
        ja=0;
      }
    } 
    if(t==2){
      int f;
      string c;
      cin>>f>>c;
      if(ja==0){
        if(f==1){
          s.insert(0,c);
        }
        if(f==2){
          s.insert(len(s),c);
        }
      }
      if(ja==1){
        if(f==1){
          s.insert(len(s),c);
        }
        if(f==2){
          s.insert(0,c);
        }
      }
    }
  }
  if(cntt%2!=0){
    reverse(all(s));
  }
  cout<<s<<endl;
}

Measured memory_bytes: 3880