akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#define WARU 1000000007
typedef struct ull{
 long long num;
}ull;

int main(){
int m,n,i;
ull ans;
long long x;
ans.num=1;

scanf("%d %d",&m,&n);
x=m;

while(n>0){
 if((n & 1)==1){
   ans.num=(ans.num*x)%WARU;
   
 }
 
 x=(x*x)%WARU;
 n=n>>1;
}




printf("%lld\n",ans.num%WARU);

return 0;
}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
#define pb push_back
#define Int long long
using namespace std;

const int MAXN=50005;
const int NAX=1005;
const long MOD=(long)(1e9+7);

Int N,M,K;
Int X,Y,Z;

int main()
{
   cin>>N>>M;
   M*=2;
   cout<<M-N<<"\n";
   
}


Measured memory_bytes: 3588
import heapq

def solve():
    N, M = map(int, input().split())
    X = list(map(int, input().split()))
    X_ = sorted(X)
    ret = X_[-1] - X_[0]
    diff = [X_[i]-X_[i+1] for i in range(M-1)]
    heapq.heapify(diff)

    while N > 1 and diff:
        ret += heapq.heappop(diff)
        N -= 1
        
    print(ret)
    
solve()

Measured memory_bytes: 13960
n, Y = map(int, input().split())
Y //= 1000

for x in range(n+1):
    y = (Y-n-9*x)//4
    z = n-x-y
    if z < 0 or y < 0 or x+y+z != n:
        continue
    if 10*x+5*y+z == Y:
        print(x, y, z)
        exit()
else:
    print(-1, -1, -1)

Measured memory_bytes: 3064
#include "bits/stdc++.h"

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,a) for(int i = 0; i < (a); ++i)

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int UI;

using namespace std;


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

	int n;
	cin >> n;

	string s;
	vector<int> abc('z' - 'a' + 1, INT_MAX);

	REP(i, n)
	{
		cin >> s;

		for (char j = 'a'; j <= 'z'; ++j)
		{
			abc[j - 'a'] = min((int)count(s.begin(), s.end(), j), abc[j - 'a']);
		}
	}

	for (char i = 'a'; i <= 'z'; ++i)
	{
		for (int j = 0; j < abc[i - 'a']; ++j)
		{
			cout << i;
		}
	}

	cout << "\n";

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
int main(){
  string s;cin >> s;reverse(s.begin(),s.end());
  ll n = s.size(),i,j,k,z,f = 1,dp[n+1][13] = {};dp[0][0] = 1;
  for(i=0;i<n;i++){
    if('0'<=s[i] && s[i]<='9'){
      z = s[i]-'0';
      for(j=0;j<13;j++) dp[i+1][(j+z*f)%13] = (dp[i+1][(j+z*f)%13]+dp[i][j])%mod;
    } else {
      for(k=0;k<10;k++){
        for(j=0;j<13;j++) dp[i+1][(j+k*f)%13] = (dp[i+1][(j+k*f)%13]+dp[i][j])%mod;
      }
    }
    f = (f*10)%13;
  }
  cout << dp[n][5] << "\n";
}

Measured memory_bytes: 10624
// 1_08.txt ～ 1_15.txt で, WA となったため, 修正版 を 再提出.
#include <bits/stdc++.h>
using namespace std;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
int toA[101010];

int main(){
    
    // 1. 入力情報.
    char c[101010];
    int K, total = 0;
    scanf("%s %d", c, &K);
    int l = strlen(c);
    
    // 2. 'a' に 変換できるまでに必要な操作回数は？
    rep(i, l){
        toA[i] = 26 - (c[i] - 'a');
        toA[i] %= 26;
        total += toA[i];
    }
    
    // 3. 操作をちょうどK回行った後の文字列で, 辞書順で最小のものを出力.
    if(K > total){
        int k = (K - total) % 26;
        rep(i, l){
            if(i < l - 1) printf("%c", 'a');
            else          printf("%c\n", 'a' + k);
        }
    }else{
        rep(i, l){
            // ex.
            // 
            // xyz
            // 3
            // -> ayz が 正解の筈だが, xaa と 出力された(1_08.txt 他で, WA となった理由と推測).
            // if(K > toA[i]){
            if(K >= toA[i]){
                c[i] = 'a';
                K -= toA[i];
            }
            if(i == l - 1 && K > 0){
                char t = c[i] + K;
                if(t > 'z') t -= 26;
                c[i] = t;
            }
        }
        rep(i, l) printf("%c", c[i]);
        puts("");
    }
    return 0;
    
}

Measured memory_bytes: 768
#include<stdio.h>

int main()
{
  int a,b,c;
  scanf("%d %d %d",&a,&b,&c);
  
  if(a==b && a!=c )
    printf("Yes");
  else if(a==c && a!=b)
      printf("Yes");
  else if(b==c && a!=b)
    printf("Yes");
  
  else
    printf("No");
  
    
  
  
 return 0; 
}


Measured memory_bytes: 128
/* ex5_4
   moka223711*/

#include <stdio.h>
#define SIZE 11

int main(void){
    char input;
    int count = 0, ans = 0;
    while((input = getchar()) != EOF){ // EOF = End Of File ファイルの終端に入っている文字、stdio.h内で定義されている
        if(input=='A'||input=='C'||input=='G'||input=='T')count++; // 受け取った入力が'A'、'C'、'G'、'T'のいずれかであればcountをインクリメント
        else{
            if(count > ans)ans = count; // 入力が'A'、'C'、'G'、'T'でなければcountとansの大小関係を比較して、大きければansにcountを代入
            count = 0; // countを0にする
        }
    }
    printf("%d\n", ans); // ansはACGT文字列の長さの最大値である
    return 0;
}



Measured memory_bytes: 1584
import java.util.*;
import java.io.*;

// Template for atcoder
public class Main {

    BufferedReader br;
    PrintWriter out;
    StringTokenizer st;
    boolean eof;
    final long MOD = 1000L * 1000L * 1000L + 7;
    private static final int[] dx = {0, -1, 0, 1};
    private static final int[] dy = {1, 0, -1, 0};

    void solve() throws IOException {
        char[] arr = nextString().toCharArray();
        char c = arr[0];
        if (c >= 'a' && c <= 'z') {
            outln("a");
        } else {
            outln("A");
        }
    }

    void shuffle(int[] a) {
        int n = a.length;
        for(int i = 0; i < n; i++) {
            int r = i + (int) (Math.random() * (n - i));
            int tmp = a[i];
            a[i] = a[r];
            a[r] = tmp;
        }
    }
    private void outln(Object o) {
        out.println(o);
    }
    private void out(Object o) {
        out.print(o);
    }
    public Main() throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        solve();
        out.close();
    }
    public static void main(String[] args) throws IOException {
        new Main();
    }

    public long[] nextLongArr(int n) throws IOException{
        long[] res = new long[n];
        for(int i = 0; i < n; i++)
            res[i] = nextLong();
        return res;
    }
    public int[] nextIntArr(int n) throws IOException {
        int[] res = new int[n];
        for(int i = 0; i < n; i++)
            res[i] = nextInt();
        return res;
    }
    public String nextToken() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (Exception e) {
                eof = true;
                return null;
            }
        }
        return st.nextToken();
    }
    public String nextString() {
        try {
            return br.readLine();
        } catch (IOException e) {
            eof = true;
            return null;
        }
    }
    public int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }
    public long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }
    public double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }
}


Measured memory_bytes: 32980
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <cassert>
#include <queue>
#include <ctime>
#include <string>
#include <cstring>
#define mp make_pair
#define pb push_back
#define NAME ""
#define y1 y1_423
#define list lista

using namespace std;

typedef long long ll;
typedef long double ld;

template<typename T>
ostream& operator << (ostream& cout, const vector<T> &a) {
	if ((int)a.size() == 0) {
		return (cout << "()");
	}
	cout << "(" << a[0];
	for (int i = 1; i < (int)a.size(); i++) {
		cout << "; " << a[i];
	}
	return (cout << ")");
}

template<typename T>
ostream& operator << (ostream& cout, const set<T> &a) {
	if ((int)a.size() == 0) {
		return (cout << "{}");
	}
	auto it = a.begin();
	cout << "{" << *it;
	++it;
	for (; it != a.end(); ++it) {
		cout << "; " << *it;
	}
	return (cout << "}");
}

template<typename T>
ostream& operator << (ostream& cout, const multiset<T> &a) {
	if ((int)a.size() == 0) {
		return (cout << "{}");
	}
	auto it = a.begin();
	cout << "{" << *it;
	++it;
	for (; it != a.end(); ++it) {
		cout << "; " << *it;
	}
	return (cout << "}");
}

template<typename T1, typename T2>
ostream& operator << (ostream& cout, const pair<T1, T2> &a) {
	return cout << "(" << a.first << "; " << a.second << ")";
}

const int nmax = 2000 * 1000;
const int inf = 2000 * 1000 * 1000;
const ll infl = 1000ll * 1000ll * 1000ll * 1000ll * 1000ll * 1000ll;
const int mod = 1000 * 1000 * 1000 + 7;
const ld pi = acos(-1.0);

int n, m;
string s[nmax];

int main() {
	//freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
	//freopen(NAME".in", "r", stdin);freopen(NAME".out", "w", stdout);
	cin >> n >> m;
	getline(cin, s[0]);
	for (int i = 0; i < n; i++) {
		getline(cin, s[i]);
	}
	int x = 0, y = 0;
	for (int i = 0; i < n + m; i++) {
		s[x][y] = '.';
		if (x + 1 < n && s[x + 1][y] == '#') {
			x++;
		} else if (y + 1 < m && s[x][y + 1] == '#') {
			y++;
		}
	}
	s[x][y] = '.';
	bool f = true;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if (s[i][j] == '#') {
				f = false;
			}
		}
	}
	if (!f || x != n - 1 || y != m - 1) {
		cout << "Impossible\n";
	} else {
		cout << "Possible\n";
	}
}

Measured memory_bytes: 15872
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

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

int main(void) {
    ll A, B, C;
    char c;
    cin >> A >> B >> c >> C;
    // printf("%lld, %lld, %lld\n", A, B, C);

    ll x = A * (B * 100 + C);
    // printf("%lld\n", x);
    x = x / 100;
    cout << x << endl;

    return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include <string>

using namespace std;

class DICE
{
public:
    void set_num (int a[])
    {
        for (int i=0; i<6; i++)
        {
            dicenum[i]=a[i];
        }
    }
    void make_move (char c)
    {
        int temp;
        if (c=='N')
        {
            temp=dicenum[4];
            dicenum[4]=dicenum[0];
            dicenum[0]=dicenum[1];
            dicenum[1]=dicenum[5];
            dicenum[5]=temp;
        }
        if (c=='S')
        {
            temp=dicenum[1];
            dicenum[1]=dicenum[0];
            dicenum[0]=dicenum[4];
            dicenum[4]=dicenum[5];
            dicenum[5]=temp;
        }
        if (c=='E')
        {
            temp=dicenum[2];
            dicenum[2]=dicenum[0];
            dicenum[0]=dicenum[3];
            dicenum[3]=dicenum[5];
            dicenum[5]=temp;
        }
        if (c=='W')
        {
            temp=dicenum[3];
            dicenum[3]=dicenum[0];
            dicenum[0]=dicenum[2];
            dicenum[2]=dicenum[5];
            dicenum[5]=temp;
        }
    }
    int get_top ()
    {
        return dicenum[0];
    }
private:
    int dicenum[6];
};

int main()
{
    int a[6];
    string s;
    DICE dice;
    for (int i=0; i<6; i++) cin>>a[i];
    dice.set_num(a);
    cin>>s;
    for (int i=0; i<s.size(); i++) dice.make_move(s[i]);
    cout<<dice.get_top()<<'\n';
    return 0;
}



Measured memory_bytes: 3220
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		// ?????????????????\????????????
		Scanner sc = new Scanner(System.in);

		// ??\?????°????????????????????°
		int input = sc.nextInt();

		// ???????????????
		int[][] card = new int[4][13];

		// ?????°????????????????????????????????°????????????
		String mark;
		int num;

		// ?????????????????°?????????
		int cnt;

		// ??????????????????????????????
		for (cnt = 0; cnt < input; cnt++) {

			mark = sc.next();
			num = sc.nextInt();

			switch (mark) {

			case "S":
				card[0][num - 1] = 1;
				break;

			case "H":
				card[1][num - 1] = 1;
				break;

			case "C":
				card[2][num - 1] = 1;
				break;

			case "D":
				card[3][num - 1] = 1;
				break;
			}

		}

		// ???????????????????????\????????????
		// ????¨?????????°???num???cnt???????????¨
		for (num = 0; num <= 3; num++) {

			for (cnt = 0; cnt <= 12; cnt++) {

				if (card[num][cnt] == 0) {

					switch (num) {

					case 0:
						System.out.println("S " + (cnt+1));
						break;

					case 1:
						System.out.println("H " + (cnt+1));
						break;

					case 2:
						System.out.println("C " + (cnt+1));
						break;

					case 3:
						System.out.println("D " + (cnt+1));
						break;
					}

				}

			}

		}
		sc.close();
	}

}

Measured memory_bytes: 26372
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define PI 3.1415926535897932384626
#define boost ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MOD 1000000007
#define forn(i,n) for(int i=0;i<n;i++)
int main()
{
       boost;
       int a,b;
       cin>>a>>b;
       cout<<max(a+b,max(a*b,a-b))<<endl;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> A(N+2, 0);
  for (int i = 1; i < N+1; i++) cin >> A.at(i);
  int S = 0;
  for (int i = 0; i < N+1; i++) S += abs(A.at(i) - A.at(i+1));
  for (int i = 1; i < N+1; i++) {
    int Si = S-abs(A.at(i-1)-A.at(i))-abs(A.at(i)-A.at(i+1))+abs(A.at(i-1)-A.at(i+1));
    cout << Si << endl;
  }
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define SIZE 100005
#define NUM 0

struct Info{

	int x_L1,x_L2,x_U1,x_U2;
};

struct Data{
	Data(int arg_value,int arg_index,bool arg_is_left){
		value = arg_value;
		index = arg_index;
		is_left = arg_is_left;
	}
	bool operator<(const struct Data &arg) const{

		return value < arg.value;
	}

	int value,index;
	bool is_left;
};

int N;
int table[8*SIZE];
int dp[SIZE];
Info info[SIZE];


void init(int first_N){
	while(N < first_N*2)N *= 2;
}

void update(int loc,int value){
	loc += N-1;

	table[loc] = value;

	if(N == 1)return;

	int parent = (loc-1)/2;

	while(true){
		table[parent] = max(table[2*parent+1],table[2*parent+2]);

		if(parent == 0)break;
		else{
			parent = (parent-1)/2;
		}
	}
}

int query(int search_left,int search_right,int node_id,int node_left,int node_right){

	if(search_right < node_left || search_left > node_right)return NUM;

	if(search_left <= node_left && search_right >= node_right){
		return table[node_id];
	}

	int left_max = query(search_left,search_right,2*node_id+1,node_left,(node_left+node_right)/2);
	int right_max = query(search_left,search_right,2*node_id+2,(node_left+node_right)/2+1,node_right);

	return max(left_max,right_max);
}


int main(){

	int first_N;

	scanf("%d",&first_N);

	vector<int> UPPER;
	vector<Data> V;

	for(int i = 0; i < first_N; i++){

		scanf("%d %d %d %d",&info[i].x_L1,&info[i].x_L2,&info[i].x_U1,&info[i].x_U2);

		//上辺
		UPPER.push_back(info[i].x_U1);
		UPPER.push_back(info[i].x_U2);

		//下辺
		V.push_back(Data(info[i].x_L1,i,true));
		V.push_back(Data(info[i].x_L2,i,false));
	}

	sort(UPPER.begin(),UPPER.end());
	sort(V.begin(),V.end());

	N = 1;
	init(first_N);

	for(int i = 0; i <= 2*N-2; i++){

		table[i] = 0;
	}

	for(int i = 0; i < first_N; i++){

		dp[i] = 0;
	}

	int L,R,mid;

	for(int i = 0; i < V.size(); i++){ //下辺の端点座標の昇順に走査

		int index = V[i].index;

		if(V[i].is_left){ //下辺左端の場合

			L = 0,R = UPPER.size()-1,mid = (L+R)/2;
			int loc;

			while(L <= R){

				if(info[index].x_U1 == UPPER[mid]){

					loc = mid;
					break;

				}else if(info[index].x_U1 > UPPER[mid]){

					L = mid+1;

				}else{

					R = mid-1;
				}
				mid = (L+R)/2;
			}

			dp[index] = query(0,loc-1,0,0,N-1)+1;

		}else{ //下辺右端の場合

			L = 0,R = UPPER.size()-1,mid = (L+R)/2;
			int loc;

			while(L <= R){

				if(info[index].x_U2 == UPPER[mid]){

					loc = mid;
					break;

				}else if(info[index].x_U2 > UPPER[mid]){

					L = mid+1;

				}else{

					R = mid-1;
				}
				mid = (L+R)/2;
			}

			update(loc,dp[index]);
		}
	}

	printf("%d\n",query(0,N-1,0,0,N-1));

	return 0;
}



Measured memory_bytes: 10280
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,m;
    cin >> n >> m;
    int count = 0;
    vector<int>ans(n, 99);
    int s, c;
    for(int i = 0; i < m; i++){
        cin >> s;
        cin >> c;
        if (n != 1 && s == 1 && c == 0) count +=1;
        else if(ans[s-1] == 99) ans[s-1] = c;
        else if (ans[s-1] == c) ans[s-1] = c;
        else count += 1;
    }
    if(count != 0) cout << -1;
    else if(n == 1 && m == 0) cout << 0;
    else {
        if(ans[0] == 99) ans[0] = 1;
        for(int i = 0; i < n; i++) {
            if(ans[i] == 99) ans[i] = 0;
            cout << ans[i];
        }
    }
}


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

vector<vector<int>> g;
vector<bool> seen;
vector<int> cnt;
vector<int> res;

void dfs(int v, int pv){
    seen[v] = true;
    res[v] = res[pv] + cnt[v];

    for(int nv: g[v]){
        if(seen[nv]) continue;
        dfs(nv, v);
    }
}

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

    int n, q;
    cin >> n>> q;

    g.resize(n);
    rep(i, n-1){
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        g[a].push_back(b);
        if(a) g[b].push_back(a);
    }

    cnt.resize(n, 0);
    rep(i, q){
        int p, x;
        cin >> p >> x;
        --p;
        cnt[p] += x;
    }

    res.resize(n, 0);
    seen.resize(n, false);
    res[0] = cnt[0];
    for(int nv: g[0]){
        dfs(nv, 0);
    }

    rep(i, n) cout << res[i] << " ";
    cout << endl;

    return 0;
}

Measured memory_bytes: 24320
R,G,B,N = map(int, input().split())
ans = 0
for r in range(N//R+1):
    for g in range(N//G+1):
        bB = N - (r*R + g*G)
        if bB % B > 0:
            continue
        if 0 <= bB//B:
            ans += 1
print(ans)


Measured memory_bytes: 40812
numbers = input()
a,b,c,d = numbers
i = len(numbers)-1

op = ['+','-']

for j in range(2 ** i):
  o = [op[int((j>>k)&1)] for k in range(i)]
  f=f"{a}{o[0]}{b}{o[1]}{c}{o[2]}{d}"
  if eval(f) == 7:
    print(f+'=7')
    break
      

Measured memory_bytes: 9084
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define all(v) v.begin(), v.end()
#define vl vector<ll>
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define ff first
#define ss second
const int N=100005;
int a[2*N];
void solve()
{
    int n,k=1,m=0,i=1,j,x,y,l,r,p,q,z;
    ll ans=0;
    string s;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        m=max(m,a[i]);
        ans+=m-a[i];
    }
    cout<<ans;
}
int main()
{
    ios::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
     #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin) ;
    freopen("output.txt", "w", stdout) ;
    #endif 
    int t=1;
    //cin>>t;
    while(t--)solve();
    return 0;
}

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

int main(){
    int_fast64_t N, a;
    scanf("%lld", &N);
    for(int i = 0; i < N; ++i){
        scanf("%lld", &a);
        if(a & 1)return 0 & puts("first");
    }
    puts("second");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E18;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

ll masu[1001][1001];
ll flag=1;
ll h,w;
string s[1000];
void hoge(ll i,ll j){
    if(i<0 || i>=h || j<0 || j>=w){
        return;
    }
    if(masu[i][j]!=0)return;
    if(s[i][j]=='#')return;
    masu[i][j]=flag;
    hoge(i-1,j);
    hoge(i+1,j);
    hoge(i,j-1);
    hoge(i,j+1);
}


struct edge{ll to,cost; };
vector<edge> G[1000010];
ll d[1000010];

void dijkstra(ll s){
    fill(d,d+1000010,inf);
    d[s]=0;
    priority_queue<l_l,vector<l_l>,greater<l_l>> que;
    que.push(l_l(0,s));
    while(!que.empty()){
        l_l p=que.top();que.pop();
        ll v=p.second;
        if(d[v]<p.first)continue;
        if(G[v].size()>0){
            rep(i,0,G[v].size()-1){
                edge e=G[v][i];
                if(d[e.to]>d[v]+e.cost){
                    d[e.to]=d[v]+e.cost;
                    que.push(l_l(d[e.to],e.to));
                }
            }
        }
    }
}


int main(){fastio
    cin>>h>>w;
    ll ch,cw,dh,dw;cin>>ch>>cw>>dh>>dw;
    rep(i,0,h-1)cin>>s[i];
    rep(i,0,h-1){
        rep(j,0,w-1){
            masu[i][j]=0;
        }
    }
    rep(i,0,h-1){
        rep(j,0,w-1){
            if(masu[i][j]==0 && s[i][j]=='.'){
                hoge(i,j);
                flag++;
            }
        }
    }
    set<ll> mp[flag];
    rep(i,0,h-1){
        rep(j,0,w-1){
            if(s[i][j]=='#')continue;
            rep(k,max(0,i-2),min(h-1,i+2)){
                rep(l,max(0,j-2),min(w-1,j+2)){
                    if(masu[k][l]!=0 && masu[k][l]!=masu[i][j]){
                        mp[masu[i][j]].insert(masu[k][l]);
                    }
                }
            }
        }
    }
    vector<ll> v[flag];
    rep(i,0,flag-1){
        for(auto it=mp[i].begin();it!=mp[i].end();++it){
            v[i].pb(*it);
        }
    }
    rep(i,0,flag-1){
        rep(j,0,(ll)v[i].size()-1){
            edge e;
            e.to=v[i][j];
            e.cost=1;
            G[i].pb(e);
        }
    }
    ll ss=masu[ch-1][cw-1];
    ll gg=masu[dh-1][dw-1];
    dijkstra(ss);
    if(d[gg]==inf){
        cout<<-1<<endl;
    }else{
        cout<<d[gg]<<endl;
    }

}




Measured memory_bytes: 86084
#include<stdio.h>
#include<iostream>
#include<string>
#include<math.h>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#include<time.h>
#include<ctime>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int main() {
	ll a, b;
	cin >> a >> b;
	cout << a - b + 1 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(i, name)in(i)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(i,v) for(auto &i:(v))
#define all(v) (v).begin(),(v).end()
#define print(...) out(__VA_ARGS__);cout<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void out(){} template<class T,class... U> void out(T t,U ...u){cout<<t<<" ";out(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(int, N);
  VAR(string, S);

  map<char, ll> mp;
  rep(i, 0, N) {
    mp[S[i]]++;
  }

  ll ans = mp['R'] * mp['G'] * mp['B'];

  rep(i, 1, N) {
    rep(j, 0, N) {
      if (j + i * 2 > N - 1) {
        break;
      }
      char si = S[j];
      char sj = S[j + i];
      char sk = S[j + i * 2];
      if (si != sj && sj != sk && si != sk) {
        ans--;
      }
    }
  }

  print(ans);
}

Measured memory_bytes: 3620
n = int(input())
V = list(map(int,input().split()))
import collections
co0 = collections.Counter()
co1 = collections.Counter()
for i in range(n):
    if i%2==0:
        co0[V[i]]+=1
    else:
        co1[V[i]]+=1
co0[-1] =0
co1[-1] =0
c0 = list(co0.items())
c0.sort(key=lambda x:x[1])
c1 = list(co1.items())
c1.sort(key=lambda x:x[1])
if c0[-1][0] == c1[-1][0]:
    b = max(c0[-1][1] + c1[-2][1],c0[-2][1] + c1[-1][1])
else:
    b = c0[-1][1] + c1[-1][1]
print(n-b)


Measured memory_bytes: 20976
#include <iostream>
#include <vector>

using namespace std;

struct CycleFinder {
    const int WHITE = 0, GRAY = 1, BLACK = 2;
    int n;
    vector<vector<int>> g;
    bool hasCycle = false;
    vector<int> color;
    
    CycleFinder(int n) : n(n) {
        g.assign(n, vector<int>());
        color.assign(n, WHITE);
    }
    
    void addEdge(int from, int to) {
        g[from].push_back(to);
    }
    
    void solve() {
        for (int i = 0; i < n; i++) {
            if (color[i] == WHITE) {
                dfs(i);
            }
        }
    }
    
    void dfs(int u) {
        color[u] = GRAY;
        for (int v : g[u]) {
            if (color[v] == WHITE) {
                dfs(v);
            }
            else if (color[v] == GRAY) {
                hasCycle = true;
            }
        }
        color[u] = BLACK;
    }   
};

int main() {
    int v, e;
    cin >> v >> e;
    CycleFinder d(v);
    for (int i = 0; i < e; i++) {
        int from, to;
        cin >> from >> to;
        d.addEdge(from, to);
    }
    d.solve();
    cout << (d.hasCycle? 1 : 0) << endl;
    return 0;
}

Measured memory_bytes: 3172
#include <iostream>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int MOD = 1E9 + 9;
const int INF = 1<<29; 

int main(){
    int A, B;
    cin >> A >> B;
    cout << max(A + B, max(A - B, A * B)) << endl;
}

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

int main()
{
	long long n;
	long long a[5];
	cin >> n;
	for(auto&& i : a)
	{
		cin >> i;
	}
	sort(begin(a), end(a));
	cout << 4 + n / a[0] + !!(n % a[0]) << "\n";
}


Measured memory_bytes: 256
'use strict'

const main = INPUT => {
  const tmp = INPUT.split('\n').map(n => Number(n))
  tmp.shift()
  let input = tmp.sort((a, b) => b - a)
  let ans = input[0] / 2
  for (let i = 1; i < input.length; i++) {
    ans += input[i]
  }
  console.log(ans)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


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

int main(){
    int K, N;
    cin >> K >> N;
    vector<int> A(N);
    for(int i = 0; i<N; i++){
        cin >> A[i];
    }
    sort(A.begin(), A.end());
    int maximum = A[0] + K - A[N-1];//最初と最後の差
    for(int i = 0; i < N; i++){
        if(maximum < (A[i+1] - A[i])){
            maximum = A[i+1] - A[i];
        }
    }
    int result = K - maximum;
    cout << result << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <iostream>
#include <vector>
#include <math.h>
using namespace std;

int main() {
	
	long long N;
	vector<int> insuu;
	cin >> N;
	double _N = sqrt(N);

	for (int i = 2;i <= _N;i++) {
		int count = 0;
		while (N % i == 0) {
			count++;
			N /= i;
		}
		if (count != 0) {
			insuu.push_back(count);
		}
		if (N == 1)break;
	}

	if (N > _N) {
		insuu.push_back(1);
	}

	int ans = 0;
	
	for (int i = 0;i < insuu.size();i++) {
		for (int j = 1;j <= insuu.at(i);j++) {
			ans++;
			insuu.at(i) -= j;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3728
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 6;
const ll MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
#define P pair<int, int>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
/* -- template -- */

ll myceil(ll a, ll b) {
    if(a % b == 0) return a / b;
    return (a + (b - a%b)) / b;
}

int main() {
    int N, K; cin >> N >> K;
    vector<int>D(10, false);//falseならつかって良い，trueなら使っちゃだめ
    rep(i, K) {
        int d; cin >> d;
        D[d] = true;
    }
    for(int i = N; i < 10000; ++i) {
        bool okflg = true;
        int tmp = i;
        while(tmp > 0) {
            if(D[tmp%10])okflg = false;
            tmp /= 10;
        }
        if(okflg) {
            cout << i << endl;
            return 0;
        }
    }
    if(D[0]) {
        rep(i, 9) {
            if(!D[i + 1]) {
                rep(j, 5)
                    cout << (i + 1);
                cout << endl;
                return 0;
            }
        }
    }else {
        rep(i, 9) {
            if(!D[i + 1]) {
                cout << (i + 1) * 10000 << endl;
                return 0;
            }
        }
    }
    //許された文字の中の最小 * 1e4
}


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

using namespace std;
vector <int> v , v2;
int main()
{
    wcin.tie(0) , wcout.tie(0) ;
    ios_base :: sync_with_stdio (0);
    int n , i , l;
    wcin >> n;
    l = n / 2 ;
    for(i = 1 ; i <= n ; ++ i)
    {
        int number;
        wcin >> number;
        v.push_back(number);
        v2.push_back(number);
    }
    sort(v2.begin() , v2.end());
    for(i = 0 ; i < n ; ++ i)
    {
        int value , v1 = v [i] , v11 = v2 [n - l];
        if(v2 [n - l] <= v [i])
            value = v2 [n - l - 1];
        else
            value = v2 [n - l];
        wcout << value << "\n";
    }
    return 0;
}


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

int main(){
  int n;
  cin >> n;
  int x[n],y[n],h[n];
  rep(i,n)cin >> x[i] >> y[i] >> h[i];
  for(int i=0;i<101;i++){
    for(int j=0;j<101;j++){
    int flag=1;
    int height;
    rep(k,n){
      if(h[k]>0)height=abs(i-x[k])+abs(j-y[k])+h[k];
    }
    rep(k,n){
      int tmp = height-abs(i-x[k])-abs(j-y[k]);
      if(tmp<0&&h[k]!=0)flag = 0;
      else if(tmp>=0&&h[k]!=tmp)flag = 0;
    }
    if(flag==1)cout << i << ' ' << j << ' ' << height << endl;
   }
 }
}


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

int		main(void)
{
	string w;

	cin >> w;
	vector<int> check(26, 0);
	for (int i = 0; w[i]; i++)
		check[w[i] - 97]++;
	for (int i = 0; i < 26; i++)
	{
		if (check[i] % 2 == 1)
		{
			cout << "No" << endl;
			return (0);
		}
	}
	cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,j,k,l=1000000000,i;
cin>> n>>k;
    int m[100002];
for(i=0;i<n;i++){
    cin>>m[i];
    
}
    sort(m,m+n);
for(i=0;i<n-k+1;i++){
        
     l=min(l,m[i+k-1]-m[i]);
        
    }
    cout<<l<<endl;
    }
    


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    vector<int> V(3);
    rep(i,0,3)cin >> V[i];
    sort(V.begin(), V.end());
    int mini = INF; 
    do{
        int num = 0;
        rep(i,0,2){
            num += abs(V[i+1] - V[i]);
        }
        mini = min(mini, num);
    }while(next_permutation(V.begin(), V.end()));   
    cout << mini << endl;
}

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

#define maxn 10005
#define INF 0x3f3f3f3f
#define mod 1000000007
typedef long long ll;
using namespace std;

ll N, K;

void slove()
{
	ll tmp;
	
	if (N % K == 0)
	{
		cout << 0 << '\n';
		return;
	}
	N -= N / K * K;
	tmp = abs(N - K);
	if (tmp < abs(N)) cout << tmp;
	else cout << abs(N);
	cout << '\n';
}

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0);
	while (cin >> N >> K)
	slove();

	return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func abs(a int) int {
	if a < 0 {
		return -1 * a
	} else {
		return a
	}
}

func main() {
	sc.Split(bufio.ScanWords)

	a, b, c, d := nextInt(), nextInt(), nextInt(), nextInt()
	if abs(a-c) <= d || (abs(a-b) <= d && abs(b-c) <= d) {
		fmt.Println("Yes")
		return
	}

	fmt.Println("No")
}

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

using namespace std;

#define int 		long long
#define endl 		"\n"
#define mod			1000000007
#define inf			1e9
#define IOS			ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)


int32_t main() {

	IOS;

	int x, k, d;

	cin >> x >> k >> d;

	if (x < 0)
		x *= -1;

	int reqd = x / d;

	if (k >= reqd) {
		k -= reqd;

		x -= reqd * d;

		if (k & 1) {
			x -= d;
		}
	}
	else {
		x -= k * d;
	}

	if (x < 0)
		x *= -1;

	cout << x;

	return 0;
}

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

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main()
{
  int N, M;
  cin >> N >> M;
  vector<ll> X(M);
  REP(i, M)
  cin >> X[i];
  sort(ALL(X));
  vector<ll> vc(M - 1);
  REP(i, M - 1)
  vc[i] = abs(X[i + 1] - X[i]);
  sort(ALL(vc));
  ll ans = 0;
  REP(i, M - N)
  ans += vc[i];
  cout << ans << endl;
  return 0;
}

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

// F : T x T -> T
// G : T x E -> T
// H : E x E -> E
// R : E x int(length of the range) -> E
template<typename T, typename E, typename F, typename G, typename H, typename R>
struct SegL{
private:
    vector<T> node;
    vector<E> lazy;
    int n;
    T defVal;
    E defOp;
    F f;    // merge elements(T)
    G g;    // update element(T) 
    H h;    // merge operators(E)
    R r;    // operator depends on length

public:
    SegL(int siz, T defVal, E defOp, F f, G g, H h, R r) : defVal(defVal), defOp(defOp), f(f), g(g), h(h), r(r){
        n = 1;
        while(n < siz)  n *= 2;
        node.resize(2*n-1, defVal);
        lazy.resize(2*n-1, defOp);
    }
    SegL(vector<T> v, T defVal, E defOp, F f, G g, H h, R r) : defVal(defVal), defOp(defOp), f(f), g(g), h(h), r(r){
        n = 1;
        while(n < v.size())  n *= 2;
        node.resize(2*n-1, defVal);
        lazy.resize(2*n-1, defOp);
        for(int i = 0; i < v.size(); i++)   node[n-1+i] = v[i];
        for(int i = n-2; i >= 0; i--)   node[i] = f(node[2*i+1], node[2*i+2]);
    }

    void eval(int k, int len){
        if(lazy[k] == defOp)    return;
        if(k < n-1){
            lazy[2*k+1] = h(lazy[2*k+1], lazy[k]);
            lazy[2*k+2] = h(lazy[2*k+2], lazy[k]);
        }
        node[k] = g(node[k], r(lazy[k], len));
        lazy[k] = defOp;
    }

    void update(int a, int b, E x, int k=0, int l=0, int r=-1){
        if(r < 0)   r = n;
        eval(k, r-l);
        if(b <= l || r <= a){
            return;
        }else if(a <= l && r <= b){
            lazy[k] = h(lazy[k], x);
            eval(k, r-l);
        }else{
            update(a, b, x, 2*k+1, l, (l+r)/2);
            update(a, b, x, 2*k+2, (l+r)/2, r);
            node[k] = f(node[2*k+1], node[2*k+2]);
        }
    }

    T query(int a, int b, int k=0, int l=0, int r=-1){
        if(r < 0)   r = n;
        eval(k, r-l);
        if(b <= l || r <= a)    return defVal;
        if(a <= l && r <= b)    return node[k];
        T lx = query(a, b, 2*k+1, l, (l+r)/2);
        T rx = query(a, b, 2*k+2, (l+r)/2, r);
        return f(lx, rx);
    }

    T get(int x){
        return node[x+n-1];
    }
};

typedef long long ll;

int main(){
    int n, q;
    cin >> n >> q;
    auto f = [](ll x, ll y)->ll{return min(x,y);};
    auto g = [](ll x, ll y)->ll{return x+y;};
    auto h = [](ll x, ll y)->ll{return x+y;};
    auto r = [](ll x, ll y)->ll{return x;};
    ll defv = 1ll<<60;
    ll defop = 0;
    vector<ll> tmp(n, 0);
    SegL<ll, ll, decltype(f), decltype(g), decltype(h), decltype(r)> seg(tmp, defv, defop, f, g, h, r);
    while(q--){
        int op;
        cin >> op;
        if(op == 0){
            int s, t, x;
            cin >> s >> t >> x;
            seg.update(s, t+1, x);
        }else{
            int s, t;
            cin >> s >> t;
            cout << seg.query(s, t+1) << endl;
        }
    }
    return 0;
}


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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define repr(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = 1e9 + 100;
const long long LLINF = 2e18 + 129;
const long long MOD = 1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

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

    int n;
    cin >> n;

    int m = (n % 2 == 0) + n;
    vector< P > ans;
    REP(i, 1, n + 1){
        REP(j, 1, i){
            if(i + j == m){
                continue;
            }
            ans.emplace_back(i, j);
        }
    }

    cout << ans.size() << endl;
    rep(i, ans.size()){
        cout << ans[i].first << " " << ans[i].second << endl;
    }

    return 0;
}

Measured memory_bytes: 384
N = int(input())
a = list(map(int, input().split()))

sl = sum(a[:1])
sr = sum(a[1:])

ans = int(1e9)
for i in range(1, N-1):
    sl += a[i]
    sr -= a[i]
    ans = min(ans, abs(sl - sr))

if N == 2:
    ans = abs(a[0] - a[1])
print(ans)

Measured memory_bytes: 24832
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define mod 998244353
using namespace std;
typedef pair<llint, llint> P;
typedef pair<P, llint> E;

llint n;
llint a[100005];
vector<llint> G[100005];

llint dfs(int v, int p)
{
	if(G[v].size() == 1) return a[v];
	
	llint ret = 0, mx = 0;
	for(int i = 0; i < G[v].size(); i++){
		if(G[v][i] == p) continue;
		llint res = dfs(G[v][i], v);
		if(res < 0) return -1;
		ret += res;
		mx = max(mx, res);
	}
	if(a[v] > ret) return -1;
	
	llint nump = ret-a[v], maxp = min(ret-mx, ret/2);
	if(nump > maxp) return -1;
	return ret - 2*nump;
}

int main(void)
{
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> a[i];
	llint u, v;
	for(int i = 1; i <= n-1; i++){
		cin >> u >> v;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	if(n == 2){
		if(a[1] == a[2]) cout << "YES" << endl;
		else cout << "NO" << endl;
		return 0;
	}
	
	llint root;
	for(int i = 1; i <= n; i++){
		if(G[i].size() > 1){
			root = i;
			break;
		}
	}
	if(dfs(root, -1)) cout << "NO" << endl;
	else cout << "YES" << endl;
	
	return 0;
}


Measured memory_bytes: 13184
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
const char sp = ' ';


using namespace std;

int main(void){
    int N;
    cin>>N;
    cout<<(N-1)/2+1<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<iomanip>
#include<iostream>
#include<map>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<vector>
#include<bitset>
#include<cmath>
using namespace std;
#define FOR(i,a,b) for(int i=(a); i<int(b); ++i)
#define RFOR(i,a,b) for(int i=(b)-1; i>=int(a); --i)
#define rep(i,n) FOR(i,0,n)
#define rep1(i,n) FOR(i,1,int(n)+1)
#define rrep(i, n) RFOR(i, 0, n)
#define rrep1(i, n) RFOR(i, 1, int(n) + 1)
#define all(c) begin(c), end(c)
#define al(d) d.begin(),d.end()
using namespace std;
template <typename T>
void putv(vector<T>& V){
	// cout << "The elements in the vector are: " << endl;
	for(auto x: V)
		cout << x << " ";
	cout << endl;
}
template <class T>
vector<T> getv(int n){
	vector<T> vec;
	rep(i,n){
		T input;
		cin >> input;
		vec.emplace_back(input);
	}
	return vec;
}
using AdjList = vector<vector<int>>;
using Weight = int;
using Flow = int;
struct Edge {
	int src, dst;
	Weight weight;
	Flow cap;
	Edge() : src(0), dst(0), weight(0) {}
	Edge(int s, int d, Weight w) : src(s), dst(d), weight(w) {}
};
using Edges = std::vector<Edge>;
using Graph = std::vector<Edges>;
using Array = std::vector<Weight>;
using Matrix = std::vector<Array>;

void add_edge(Graph &g, int a, int b, Weight w = 1) {
	g[a].emplace_back(a, b, w);
	g[b].emplace_back(b, a, w);
}
void add_arc(Graph &g, int a, int b, Weight w = 1) { g[a].emplace_back(a, b, w); }

// Recieve edge(=(int,int)) as an adj list.
AdjList getadj(int N, int M){
	// Initialize all lists of the graph as a empty vector.
	vector<int> init;
	vector<vector<int>> graph(N,init);

	rep(i,M){
		int a, b;
		cin >> a >> b;
		graph[a-1].emplace_back(b-1);
		graph[b-1].emplace_back(a-1);
	}
// rep(i,N)
// 	putv(graph[i]);
	return graph;
}

long long Manhattan_dist(long long x1, long long y1, long long x2, long long y2){return abs(x1-x2) + abs(y1-y2);}

void out(bool ans){
	if(ans == true) cout << "yes" << endl;
	else cout << "no" << endl;
}
void Out(bool ans){
	if(ans == true) cout << "Yes" << endl;
	else cout << "No" << endl;
}
void OUT(bool ans){
	if(ans == true) cout << "YES" << endl;
	else cout << "NO" << endl;
}
unsigned long long gcd(const unsigned long long a, const unsigned long long b){
	return (b==0) ? a : gcd(b,a%b);
}

int main(){
	string s;
	cin >> s;
	char out1,out2,out3;
	bool flag = false;
	for(int op1=-1; op1<=1; op1+=2){
		if(flag) break;
		for(int op2=-1; op2<=1; op2+=2){
			if(flag) break;
			for(int op3=-1; op3<=1; op3+=2){
				if(flag) break;
					if((s[0]-48)+(op1*(s[1]-48))+(op2*(s[2]-48))+(op3*(s[3]-48)) == 7){
						out1 = (op1==1)? '+':'-';
						out2 = (op2==1)? '+':'-';
						out3 = (op3==1)? '+':'-';
						cout << s[0] << out1 << s[1] << out2 << s[2] << out3 << s[3] << "=7"<<endl;
						flag = true;
					}
				}
		}
	}
}


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

double eps = 1e-8;
double T[100001][20];
double sum[100001];
bool equals(double a, double b) { return fabs(a-b) < eps; }
void make() {
  fill(T[0], T[100001], 0);
  T[1][1] = 1.0;
  for(int i = 2; i <= 100000; ++i) {
    double a = 1;
    T[i][0] = 1;
    for(int j = 1; j < 20; ++j) {
      double tmp = T[i-1][j-1] * a;
      a *= 0.5;
      //if(equals(tmp, 0.0)) continue;
      T[i][j] = tmp;
      T[i][0] -= tmp;
    }
  }
  sum[1] = 1;
  for(int i = 2; i <= 100000; ++i) {
    sum[i] = sum[i-1];
    for(int j = 1; j < 20; ++j) {
      sum[i] += T[i][j];
    }
  }
}

int main() {
  make();
  int n;
  while((cin >> n) && n) printf("%.8f\n", sum[n]);
  return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <cmath>
#include <limits>
#include <numeric>
#include <iomanip>
#include <cstdlib>
#include <iterator>
#include <functional>
#include <unordered_map>

using namespace std;

typedef unsigned                    ui;
typedef int                         si;
typedef long                        sl;
typedef long long                   ll;
typedef unsigned long long          ull;

#ifdef LOCALHOST
std::ifstream in("input.txt", std::ifstream::in);
#endif // LOCALHOST

#ifdef LOCALHOST
#define is in
#else
#define is cin
#endif // LOCALHOST

int answer = 0;
vector<vector<pair<int, int>>> t;
unordered_map<int, int> p;
vector<bool> a;

bool check() {
    unordered_map<int, int> f;
    for (int i = 0; i < t.size(); ++i) {
        for (int j = 0; j < t[i].size(); ++j) {
            if (a[i]) {
                const int person = t[i][j].first;
                const int fact = t[i][j].second;
                const auto found = f.find(person);

                if (a[person - 1] != fact) {
                    return false;
                }

                if (found != f.end()) {
                    if (found->second != fact) {
                        return false;
                    }
                } else {
                    f[person] = fact;
                }
            }
        }
    }

    return true;
}

void gen(int n, int i) {
    if (i == n) {
//        cout << "check: " << endl;
//        for (int i = 0; i < n; ++i) {
//            cout << a[i] << " ";
//        }
//        cout << endl;

        if (check()) {
//            cout << "TRUE" << endl;
            int cur_ans = 0;
            for (int i = 0; i < n; ++i) {
                if (a[i]) {
                    cur_ans += 1;
                }
            }

            answer = max(answer, cur_ans);
        }

        return;
    }

    a[i] = 0;
    gen(n, i + 1);
    a[i] = 1;
    gen(n, i + 1);
}

int main(int argc, char *argv[])
{
    std::ios_base::sync_with_stdio(false);

    ll n;
    cin >> n;

    for (int i = 0; i < n; ++i) {
        int c;
        cin >> c;

        vector<pair<int, int>> current;
        for (int j = 0; j < c; ++j) {
            int x, y;
            cin >> x >> y;

            current.emplace_back(x, y);
        }

        t.emplace_back(current);
    }

    a.resize(n);
    gen(n, 0);
/*
    for (int i = 0; i < n; ++i) {
        int c;
        cin >> c;

        vector<pair<int, int>> current;
        for (int j = 0; j < c; ++j) {
            int x, y;
            cin >> x >> y;

            if (y == 1) {
                p[x] += 1;
            }

            current.emplace_back(x, y);
        }

        t.emplace_back(current);
    }

    answer = n;
    for (int i = 1; i <= n; ++i) {
        if (p.count(i) > 0) {
            --answer;
        }
    }
    */

    cout << answer << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<algorithm>
using namespace std;

int main(){
	int n;
	while(cin >> n,n){
		int m[86400]={};
		for(int i=0;i<n;i++){
			int bh,bm,bs,eh,em,es;
			scanf("%d:%d:%d %d:%d:%d",&bh,&bm,&bs,&eh,&em,&es);
			m[(bh*60*60)+(bm*60)+bs]+=1;
			m[(eh*60*60)+(em*60)+es]+=-1;
		}
		int count=0,ans=0;
		for(int i=0;i<86400;i++){
			count+=m[i];
			ans=max(ans,count);
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 3472
using System;
using System.Collections.Generic;
using System.Linq;
 
static class MainClass {

  public static void Main (string[] args) {
    //var temp = Console.ReadLine().Split(' ').Select(long.Parse);
    var L = Decimal.Parse(Console.ReadLine());
    
    Console.WriteLine(L / 3 * L / 3 * L / 3);
 
  }
  
}

Measured memory_bytes: 11092
#define rep(i, n) for (int i = 0; i < (n); i++)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;
// MAX int 2,147,483,647 -> 10桁
// MAX ll 9,223,372,036,854,775,807 -> 19桁
// MAX O(n) 10^18 -> 18回
// double pi = M_PI or acos(-1)

int main() {
    double l;
    cin >> l;
    double x = l / 3;
    double ans = pow(x, 3);
    cout << fixed << setprecision(10) << ans << endl;
    // printf("%.10f\n", ans);
    return 0;
}


Measured memory_bytes: 4168