akhauriyash/Code-Regression huggingface dataset:
//
//  main.cpp
//  C - Slimes
//
//  Created by Hashizo on 2019/10/19.
//  Copyright © 2019 Hashizo. All rights reserved.
//

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <regex>
#include <cmath>

using namespace std;
 
#undef LONG_MAX
#undef LONG_MIN
 
#define LONG_MAX    9223372036854775807
#define LONG_MIN    (-LONG_MAX  -1)
 
#define ll long long
 
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
 
#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())

int main(int argc, const char * argv[]) {
    ll ans = 1;


	ll n;
	cin >> n;

	vector<char> slimes(n);
	REP(i, n) {
		cin >> slimes[i];
	}
	
	char slime = slimes[0];

	REP(i, n) {
		if (slime == slimes[i]) {
			continue;
		}

		ans++;
		slime = slimes[i];
	}
	
	
	
	cout << ans << endl;
    return 0;
}



Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<unordered_set>
#include<unordered_map>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod;

int main(){
  ll a,b,c; cin>>a>>b>>c;
  cout<<max(0LL,c-(a-b))<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define ll long long
#define mem(a,b) memset(a,b,sizeof(a))
const int maxn=1e5+10;
ll num[maxn];
int n;
ll gcd(ll a,ll b){
	return b==0?a:gcd(b,a%b);
}
int main(){
	int i,j,n,m,k,u,v;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%lld",&num[i]);
	}
	ll ans=num[1];
	for(i=2;i<=n;i++){
		ans=gcd(ans,num[i]);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 896
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int strengh = Integer.parseInt(br.readLine());
		String line = br.readLine();
		String[] lines = line.split(" ");

		for (int i = strengh - 1; i >= 0; i--) {
			if (i == 0) {
				System.out.print(lines[i]);
			} else {
				System.out.print(lines[i] + " ");
			}
		}
		System.out.println();
	}
}

Measured memory_bytes: 24368
N, A, B = map(int , input().split())
X = list(map(int,input().split()))
now = X[0]
ans = 0
for i in range(1, len(X)):
    if (X[i] - now) * A > B:
        ans += B
    else:
        ans += (X[i] - now) * A
    now = X[i]
print(ans)

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

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

signed main(){
    int N;string S;
    cin>>N>>S;

    rep(i,N-1){
        if(S[i]=='x'&&S[i+1]=='x'){
            cout<<i+1<<endl;
            return 0;
        }
    }
    cout<<N<<endl;
    return 0;
}

Measured memory_bytes: 3280
import sys
ab = [list(map(int, input().split())) for _ in range(3)]
count = [0] * 5
for i in range(3):
    count[ab[i][0]] += 1
    count[ab[i][1]] += 1

for i in count:
    if i >= 3:
        print('NO')
        sys.exit(0)
print('YES')

Measured memory_bytes: 3060
/* be name Khoda */
// VJUDGE
#include <bits/stdc++.h>
using namespace std;

const int N = 3010;
string st, st2;
int dp[N][N];
pair<int, int> p[N][N];
string ans;

int main() {
	cin >> st >> st2;
	st = '$' + st;
	st2 = '$' + st2;
	int sz = st.size(),
		sz2 = st2.size();
//	cout << sz << "  " << sz2 << endl;
	for (int i = 1; i < sz; i++) {
		for (int j = 1; j < sz2; j++) {
			if (st[i] == st2[j]) {
				dp[i][j] = dp[i - 1][j - 1] + 1;
				p[i][j] = {i - 1, j - 1};
			}
			else {
				if (dp[i - 1][j] >= dp[i][j - 1]) {
					dp[i][j] = dp[i - 1][j];
					p[i][j] = {i - 1, j};
				}
				else {
					dp[i][j] = dp[i][j - 1];
					p[i][j] = {i, j - 1};
				}
			}
		}
	}
	sz--, sz2--;
	while (sz && sz2) {
		if (st[sz] == st2[sz2]) 
			ans += st[sz];
		auto t = p[sz][sz2];
		sz = t.first;
		sz2 = t.second;
	}
	reverse(ans.begin(), ans.end());
	cout << ans << endl;
}

Measured memory_bytes: 106368
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <cstdio>
#include <utility>
#include <algorithm>
#include <iomanip>
using std::cin;
using std::cout;
using std::endl;

int main(void)
{
    cout << std::fixed << std::setprecision(10);
    std::vector<int> a;
    int answer;
    int m1;
    for(int i=0;i<3;i++){
        scanf("%d",&m1);
        a.push_back(m1);
    }
    std::sort(a.begin(),a.end(),std::greater<int>() );
    answer=(a[0]-a[1])+(a[1]-a[2]);
    cout<<answer<<endl;

    return 0;
}


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

using namespace std;
using ll = long long;
using ld = double;
using base = complex <ld>;


const ll mod = 200003;
const ll sz = 1 << 19;

const ld PI = acos(-1);
random_device rd;
mt19937 rng(rd());

vector <base> X(sz);
ll P[202020], Q[202020], D[606060];
ll n, s;

void fft(vector <base> &X, bool f)
{
	ll i, j, l, k = X.size();
	ld th; base w, x, y;

	for(i = 1, j = 0; i < k; i ++){
		for(l = k >> 1; j >= l; l >>= 1) j -= l;
		j += l; if(i < j) swap(X[i], X[j]);
	}

	for(i = 1; i < k; i <<= 1){
		th = (f? -PI : PI) / i;
		w = base(cos(th), sin(th));
		for(j = 0; j < k; j += i << 1){
			for(l = 0; l < i; l ++){
				if(l & 255) x *= w;
				else x = l? base(cos(th * l), sin(th * l)) : 1;
				y = x * X[i | j | l];
				X[i | j | l] = X[j | l] - y;
				X[j | l] += y;
			}
		}
	}

	if(f) for(i = 0; i < k; i ++){
		X[i] /= k;
	}
}

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

	ll i, t, x;

	for(i = 0, t = 1; ; i ++){
		P[t] = i; Q[i] = t;
		t = t * 5 % mod;
		if(t == 1) break;
	}

	cin >> n;

	for(i = 0; i < n; i ++){
		cin >> x; s -= x * x % mod;
		if(x == 0) continue;
		else D[P[x]] ++;
	}

	for(i = 0; i < sz; i ++){
		X[i] = D[i];
	}

	fft(X, 0);
	for(i = 0; i < sz; i ++){
		X[i] *= X[i];
	}
	fft(X, 1);

	for(i = 0; i < sz; i ++){
		t = (ll)round(X[i].real());
		s += t * Q[i % (mod - 1)];
	}

	cout << s / 2 << "\n";

	return 0;
}

Measured memory_bytes: 16204
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
#define int long long
using namespace std;
int test[213][213], aa[213];
signed main() {
	int n, m, a, b, ans = 0; cin >> n >> m;
	for (int h = 0; h < m; h++) {
		cin >> a >> b;
		test[a][b] = 1;
		test[b][a] = 1;
	}
	for (int h = 0; h < n; h++) {
		aa[h] = h + 1;
	}
	do{
		int c = 0;
		for (int h = 1; h < n; h++) {
			if (test[aa[h - 1]][aa[h]] == 0) { c = 1; }
		}
		if (c == 0) { ans++; }
	} while (next_permutation(aa + 1, aa + n));
	cout << ans << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <climits>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
//#include <tuple>

#define INF INT_MAX>>1 
#define SIZE 100010
#define MOD 1000000007
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep2(i, from, to) for(int i=(from); i<(int)(to); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define LLPair pair<ll, ll>
typedef long long ll;

using namespace std;

struct Point { int x, y; };
struct Edge { int to, cost; };
struct gNode { int from, to, cost; };
struct tNode { int value; int parent; vector<int> child; };

int dx[] ={-1, 0, 0, 1};
int dy[] ={0, -1, 1, 0};

int gcd(int a, int b){ return a % b == 0 ? b : gcd(b, a%b); }
int lcm(int a, int b){ return a * b/ gcd(a, b); }
int extgcd(int a, int b, int& x, int& y){
	int d = a;
	if(b != 0){
		d = extgcd(b, a%b, y, x);
		y -= (a/b) * x;
	} else{
		x = 1; y = 0;
	}
	return d;
}
ll mod_pow(ll x, ll n){
	if(n == 0) return 1;
	ll res = mod_pow(x*x % MOD, n/2);
	if(n & 1) res = res * x % MOD;
	return res;
}

int main(void){
	string s;
	cin >> s;
	rep(i, s.length()){
		if(i%2 == 0) if(s[i] == 'L'){
			cout << "No" << endl;
			return 0;
		}
		if(i%2 == 1) if(s[i] == 'R'){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main() {
  // 入力
  int a, b;
  std::cin >> a >> b;

  // 平均切り上げ
  int round_up_avg = (a + b + 1) / 2;

  // 出力
  std::cout << round_up_avg << std::endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	private Scanner sc;
	
	public static void main(String[] args) {
		new Main();
	}
	
	public Main() {
		sc = new Scanner(System.in);
		
		int lines = Integer.parseInt(sc.nextLine());
		while (lines != 0) {
			int two = 0;
			int five = 0;
			
			for (int i = 0; i < lines; i++) {
				int tmp = i + 1;
				while ((tmp % 2) == 0) {
					tmp = tmp / 2;
					two++;
				}
				
				tmp = i + 1;
				while ((tmp % 5) == 0) {
					tmp = tmp / 5;
					five++;
				}
			}
			System.out.println(Math.min(two, five));
			
			lines = Integer.parseInt(sc.nextLine());
		}
	}
}

Measured memory_bytes: 26164
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <string>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define SORT(x) sort(x.begin(),x.end())
#define REVE(x) reverse(x.begin(),x.end())
#define all(x) (x).begin(),(x).end()
#define fst first
#define mp make_pair
#define pb push_back
#define pob pop_back
#define sw swap
using LL = long long;
using ULL = unsigned long long;
#define FOR(i, m, n) for(int i = m;i <= n;i++)
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
int main(){
LL a=0,b=0,c=0;
cin >> a;
FOR(i,1,a){
b=800*i;
if(i%15==0){
    c+=200;
}
}
cout << b-c;
 return 0;
  }

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

int main() {
	int N, X, Y;
	cin >> N >> X >> Y;
	X--;Y--;
	map<int, int> mii;

	int tmp1, tmp2;
	for (int s = 0; s < N-1; s++) {
		for (int e = s+1; e < N; e++) {
			int tmp1 = e - s;
			if (s <= X && Y <= e) tmp2 = (X - s) + 1 + (e - Y);
			else if (e <= X || Y <= s) tmp2 = e - s;
			else if (s <= X && e <= Y) tmp2 = (X - s) + 1 + (Y - e);
			else if (X <= s && Y <= e) tmp2 = (s - X) + 1 + (e - Y);
			else tmp2 = (s - X) + 1 + (Y - e);
			if (tmp1 < tmp2) mii[tmp1]++;
			else mii[tmp2]++;
		}
	}

	for (int i = 1; i < N; i++) {
		cout << mii[i] << "\n";
	}

	return 0;
}


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

#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  int N;
  string S;

  cin >> N >> S;
  if (N >= 3200) {
    cout << S << endl;
  } else {
    cout << "red" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include <limits.h>
#include <cinttypes>
#include <string.h>
#include <bits/stdc++.h>

#define countof(a) (sizeof(a)/sizeof(*a))

#define vi vector<int>
#define vvi vector<vector<int> >
#define pi pair<int,int>
#define fi first
#define se second

#define FOR(var, to)          for (register s64 var = 0; var < (s64)to; var++)
#define FROMTO(var, from, to) for (register s64 var = from; var <= (s64)to; var++)

#define INIT(var) FOR(i,countof(var)) var[i] = 0
#define INPUT(var) FOR(i,countof(var)) var[i] = ri()

#define SORT(v) qsort(v,countof(v),sizeof(*v),int_less)
#define SORTT(v) qsort(v,countof(v),sizeof(*v),int_greater)

#define MOD 1000000007
#define INF (1 << 30)

typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;

using namespace std;

static inline int ri() {
  int a;
  scanf("%d", &a);
  return a;
}

static inline s64 rs64() {
  s64 a;
  scanf("%" SCNd64, &a);
  return a;
}

static inline void wi(int a) {
  printf("%d", a);
}

static inline void wu64(u64 a) {
  printf("%" PRIu64, a);
}

static inline void ws64(s64 a) {
  printf("%" PRId64, a);
}

int int_less(const void *a, const void *b) {
  return (*((const int*)a) - *((const int*)b));
}
int int_greater(const void *a, const void *b) {
  return (*((const int*)b) - *((const int*)a));
}

int main() {
    string s;
    cin >> s;
    int k;
    cin >> k;
    
    int res=1;
    for (int i = 0; i < k && i < 100 && i < s.size(); i++) {
        if (s[i] != '1') {
            res = s[i]-'0';
            break;
        }
        
    }
  
  wi(res);
  return 0;
}


Measured memory_bytes: 384
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <list>
#include <stack>

using namespace std;

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

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

int DP[310][310][310] = {};

int main(){
	
	string S;
	int K;
	
	cin >> S;
	cin >> K;
	
	for(int i = 0; i < S.size(); i++){
		for(int j = S.size() - 1; j > i; j--){
			int id1 = i + 1;
			int id2 = S.size() - j;
			for(int k = 0; k <= K; k++){
				DP[id1][id2][k] = max(DP[id1 - 1][id2][k], DP[id1][id2 - 1][k]);
				if(k != 0){
					DP[id1][id2][k] = max(DP[id1][id2][k], DP[id1][id2][k - 1]);
				}
				if(S[i] == S[j]){
					DP[id1][id2][k] = max(DP[id1][id2][k], DP[id1 - 1][id2 - 1][k] + 1);
				}else if(k != 0){
					DP[id1][id2][k] = max(DP[id1][id2][k], DP[id1 - 1][id2 - 1][k - 1] + 1);
				}
			}
		}
	}
	
	int ans = 0;
	
	for(int i = 0; i <= S.size(); i++){
		ans = max(ans, DP[i][S.size() - i][K] * 2);
	}
	
	for(int i = 0; i < S.size(); i++){
		ans = max(ans, DP[i][S.size() - i - 1][K] * 2 + 1);
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 112640
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
import math
import bisect
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
#
# インデックス系
# int min_y = max(0, i - 2), max_y = min(h - 1, i + 2);
# int min_x = max(0, j - 2), max_x = min(w - 1, j + 2);
#
#
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
#mod = 998244353
from sys import stdin
readline = stdin.readline
def readInts():
  return list(map(int,readline().split()))
def readTuples():
    return tuple(map(int,readline().split()))
def I():
  return int(readline())
C = [readInts() for _ in range(3)]
A = [0] * 3
B = [0] * 3
A[0] = 0
for i in range(3):
    B[i] = C[0][i]
for j in range(3):
    A[j] = C[j][0] - B[0]
for i in range(3):
    for j in range(3):
        if A[i] + B[j] == C[i][j]:
            pass
        else:
            print('No')
            exit()
print('Yes')


Measured memory_bytes: 10336
use std::io;
fn main(){
    let mut s = String::new(); /*mutはmutableを指す*/
    io::stdin().read_line(&mut s).ok();
    let num = s.trim().to_string();
    if num.chars().nth(0).unwrap() == num.chars().nth(2).unwrap(){
        println!("Yes");
    }
    else{
        println!("No");
    }
}

Measured memory_bytes: 4352
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <cstring>
#include <map>
#include <set>
#include <algorithm>

using namespace std;

int dp[101][4][4][4];

int main()
{
  int N;
  cin >> N;
  dp[0][3][3][3] = 1;
  int mod = 1000'000'007;
  for (int len = 0; len < N; len++) {
    for (int i = 0; i < 4; i++) {
      for (int j = 0; j < 4; j++) {
        for (int k = 0; k < 4; k++) {
          for (int a = 0; a < 4; a++) {
            if (j==0 && k==2 && a==1) continue;
            if (j==0 && k==1 && a==2) continue;
            if (j==2 && k==0 && a==1) continue;
            if (i==0 && k==2 && a==1) continue;
            if (i==0 && j==2 && a==1) continue;
            dp[len+1][j][k][a] += dp[len][i][j][k];
            dp[len+1][j][k][a] %= mod;
          }
        }
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 4; j++) {
      for (int k = 0; k < 4; k++) {
        ans += dp[N][i][j][k];
        ans %= mod;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Schedule {
	int t = 0;
	int x = 0;
	int y = 0;
}

public class Main {
	public static void main(String[] args) {

		// 処理対象個数の入力
		Scanner sc = new Scanner(System.in);
		int input_n = sc.nextInt();
		Schedule schedule[] = new Schedule[input_n+1];

		schedule[0] = new Schedule();

		for(int i=1;i<=input_n;i++) {
			schedule[i] = new Schedule();
			schedule[i].t = sc.nextInt();
			schedule[i].x = sc.nextInt();
			schedule[i].y = sc.nextInt();
		}

		sc.close();

		for(int i=1;i<=input_n;i++) {
			int move_time = schedule[i].t - schedule[i-1].t;
			int distance = Math.abs(schedule[i].x - schedule[i-1].x) + Math.abs(schedule[i].y - schedule[i-1].y);

			if(move_time < distance || ((move_time - distance) % 2 == 1)) {
				System.out.println("No");
				return;
			}
		}

		System.out.println("Yes");

	}

}

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

int main() {
	int  a, b;

	cin >> a >> b;

	if (a == b)
		cout << "a == b" << endl;
	else if (a < b)
		cout << "a < b" << endl;
	else
		cout << "a > b" << endl;

	return 0;

}

Measured memory_bytes: 3092
n,m=map(int,input().split())
ab=[]
for i in range(n):
  a,b=map(int,input().split())
  ab.append((a,b))
ab.sort(key=lambda x: x[0])
ans=0
t=10**10
for a,b in ab:
  t=min(b,m)
  if t<=0:break
  m-=t
  ans+=a*t
print(ans)

Measured memory_bytes: 18140
#include <bits/stdc++.h>
#define p5(i) i*i*i*i*i
using namespace std;
int n,k,a[100005];
map<long long ,long long > m;
int main()
{
    long long X;cin>>X;

    for(long long x=0;x<=5000;++x)
    {
        for(long long y=0;y<=5000;++y)
        {
            if(x*x*x*x*x+y*y*y*y*y==X)
            {
                cout<<x<<" "<<-y;
                return 0;
            }
        }
    }

    for(long long x=0;x<=5000;++x)
    {
        for(long long y=0;y<=x;++y)
        {
            if(x*x*x*x*x-y*y*y*y*y==X)
            {
                cout<<x<<" "<<y;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 3624
n = int(input())
data =input().split()
data =list(map(int, data))

max=min=data[0]
sum=0
for i in range(n):
    sum+=data[i]
    if data[i]>max:
        max=data[i]
    if data[i]<min:
        min=data[i]
print(min,max,sum)    



Measured memory_bytes: 6588
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include<iostream>
#include<math.h>

using namespace std;

int main() {
	int A, B;
	int total = 0;
	cin >> A >> B;


	if (A > B) {
		total = A*2-1;
	}
	else if(B > A){
		total = B*2-1;
	}
	else
	{
		total = A * 2;
	}
	cout << total << endl;

}



Measured memory_bytes: 256
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

typedef long double ld;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const long long infll = (long long) 1.01e18;
const ld eps = 1e-9;
const ld pi = acos((ld) -1);

#ifdef DEBUG
mt19937 mrand(300); 
#else
mt19937 mrand(chrono::steady_clock::now().time_since_epoch().count()); 
#endif

int rnd(int x) {
  return mrand() % x;
}

void precalc() {
}

int n;

bool read() {
  if (scanf("%d", &n) < 1) {
    return false;
  }
  return true;
}

void solve() {
  vector<vector<int>> vs;
  if (n & 1) {
    vs.push_back({n});
    for (int i = 1; i < n - i; i++) {
      vs.push_back({i, n - i});
    }
  } else {
    for (int i = 1; i < n + 1 - i; i++) {
      vs.push_back({i, n + 1 - i});
    }
  }
  vector<pair<int, int>> es;
  for (int i = 0; i < sz(vs); i++) {
    for (int j = 0; j < sz(vs[i]); j++) {
      for (int ii = i + 1; ii < sz(vs); ii++) {
        for (int jj = 0; jj < sz(vs[ii]); jj++) {
          es.push_back(make_pair(vs[i][j], vs[ii][jj]));
        }
      }
    }
  }
  printf("%d\n", sz(es));
  for (int i = 0; i < sz(es); i++) {
    printf("%d %d\n", es[i].first, es[i].second);
  }
}

int main() {
  precalc();
#ifdef DEBUG
  assert(freopen(TASK ".in", "r", stdin));
  assert(freopen(TASK ".out", "w", stdout));
#endif
  while (read()) {
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 384
N,M=map(int,input().split())
S=input()
T=input()

def gcd(a,b):
  if b==0:
    return a
  else:
    return gcd(b,a%b)

if S[0]==T[0]:
  g=gcd(N,M)
  if g==1:
    print(N*M)
  else:
    for i in range(0,g-1):
      n=N//g
      m=M//g
      if S[n*i]!=T[m*i]:
        print(-1)
        exit()
    print(N*M//g)
else:
  print(-1)

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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;

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

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n; cin>>n;
  vll l(n);
  rep(i,n) cin>>l[i];
  
  vsort(l);
  
  ll ans=0;
  rep(i,n){
    irep(j,i+1,n){
      ll sum=l[i]+l[j];
      auto itr=lower_bound(all(l),sum);
      ll span=itr-l.begin();
      ans+=span-j-1;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll MOD = 1000000007;
const ll INF = 1061109567;
const double EPS = 1e-10;
int main(){

    string s,t;
    int c=0;
    cin>>s>>t;
    for(int i=0;i<s.size();i++){
        if(s[i]!=t[i]){
            c++;
        }
    }
    cout<<c<<endl;
    
    return 0;
}


Measured memory_bytes: 3912
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int N,M;
int L[2<<17],R[2<<17];
int main()
{
    cin>>N>>M;
    vector<int>A;
    A.push_back(0);
    A.push_back(M);
    for(int i=0;i<N;i++)
    {
        cin>>L[i]>>R[i];
        A.push_back(L[i]);
        A.push_back(R[i]);
    }
    sort(A.begin(),A.end());
    A.erase(unique(A.begin(),A.end()),A.end());
    long long ans=0;
    long long T=0;
    vector<long long>S(A.size());
    for(int i=0;i<N;i++)
    {
        int l=lower_bound(A.begin(),A.end(),L[i])-A.begin();
        int r=lower_bound(A.begin(),A.end(),R[i])-A.begin();
        S[l]++;
        S[r+1]--;
    }
    for(int i=0;i<A.size();i++)
    {
        T+=S[i];
        ans=max(ans,(long long)(T-1)*M+(T%2?A[i]:M-A[i]));
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 9068
#[allow(unused_imports)]
use {
    proconio::{fastout, input, marker::*},
    std::cmp::*,
    std::collections::*,
    std::ops::*,
};

fn main() {
    input! {
        q: usize,
        ab: [(i64, i64); q]
    }
    for (a, b) in ab.iter().map(|&(a, b)| if a > b { (b, a) } else { (a, b) }) {
        if a + 1 >= b {
            println!("{}", 2 * a - 2);
            continue;
        }

        let mut c = ((a * b - 1) as f64).sqrt() as i64;
        c += 10;
        while c * c >= a * b {
            c -= 1;
        }
        if c * (c + 1) >= a * b {
            println!("{}", 2 * c - 2);
        } else {
            println!("{}", 2 * c - 1);
        }
    }
}


Measured memory_bytes: 2172
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
#define int long long
using namespace std;

template <typename X, typename T>
auto vectors(X x, T a) {
	return vector<T>(x, a);
}

template <typename X, typename Y, typename Z, typename... Zs>
auto vectors(X x, Y y, Z z, Zs... zs) {
	auto cont = vectors(y, z, zs...);
	return vector<decltype(cont)>(x, cont);
}

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

int n;
int ans;

vector<int> v = {3,5,7,};

bool check(int number){
	bool res[3] = {};
	while(number != 0){
		rep(i,3){
			if(number % 10 == v[i]) res[i] = true;
		}
		number /= 10;
	}
	return res[0] and res[1] and res[2];
}

void dfs(int number){
	if(number > n) return;
	if(check(number)) ans++;

	number *= 10;
	for(auto i : v){
		dfs(number + i);
	}
}

signed main(){
	cin >> n;

	dfs(0);
	cout << ans << endl;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5+7;
int f[N];
int sf(int x){
    return f[x]==x ? x : f[x] = sf(f[x]);
}
void un(int a,int b){
    f[sf(a)] = sf(b);
}
vector<int> G[N];
int main()
{
    int m,k,n,x;
    for(int i=0;i<N;i++)f[i]=i;
    scanf("%d %d",&n,&m);
    for(int i=1;i<=n;i++){
        scanf("%d",&k);
        while(k--){
            scanf("%d",&x);
            G[x].push_back(i);
        }
    }
    int s;
    for(int i=1;i<=m;i++){
        s = G[i].size();
        if(s>0) x=G[i][0];
        for(int j=1;j<s;j++){
            un(x,G[i][j]);
        }
    }
    int f=sf(1);
    for(int i=2;i<=n;i++){
        if(f!=sf(i)){
            puts("NO");
            return 0;
        }
    }
    puts("YES");
    return 0;
}


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

int main(void) {
  int N, a=0, cnt=1, i;
  string S;
  cin >> N >> S;
  
  while(a<N){
    i=a;
    for(int j=i; j<N; j++){
      if(S[i] != S[j]){
        cnt++;
        a=j;
        break;
      }
      else
        a++;
    }
  }
       
  cout << cnt << endl;
  
  return 0;
}

Measured memory_bytes: 512
#include <stdio.h>

int main()
{
	int i, q, a, b, c, d;
	char S[100001], T[100001];
	scanf("%s", S);
	scanf("%s", T);
	scanf("%d", &q);
	
	int count[2][100001] = {};
	for (i = 0; S[i] != 0; i++) count[0][i+1] = count[0][i] + ((S[i] == 'A')? 1: 0);
	for (i = 0; T[i] != 0; i++) count[1][i+1] = count[1][i] + ((T[i] == 'A')? 1: 0);
	
	for (i = 1; i <= q; i++) {
		scanf("%d %d %d %d", &a, &b, &c, &d);
		if (((b - a + 1) - (count[0][b] - count[0][a-1]) * 2 + (count[1][d] - count[1][c-1]) * 2 - (d - c + 1)) % 3 == 0) printf("YES\n");
		else printf("NO\n");
	}
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 2640
n,k=map(int,input().split())
a=[0]+list(map(int,input().split()))
s=[0]
p=[0]
for i in range(1,n+1):
  s.append(s[i-1]+a[i])
  p.append(p[i-1]+max(0,a[i]))
ans=0
for i in range(1,n-k+2):
  t=max(0,s[i+k-1]-s[i-1])
  t+=p[i-1]+p[n]-p[i+k-1]
  ans=max(ans,t)
print(ans)

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

#define ll long long
#define pb push_back

#define rep(i,n) for(ll i=0;i<n;i++)
#define rrep(i,n) for(ll i=n-1;i>=0;i--)

void solve()
{
    int x;
    cin >>x;
    int temp=x;
    for(int i=1;;i++)
    {
        if(x%360==0)
        {
            cout << i << "\n";
            break;
        }
        else
            {
                x+=temp;
                ///cout <<x << "  ";
            }
    }

}

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

    int tt=1;
    ///cin >> tt;
    while(tt--)
        solve();
}



Measured memory_bytes: 3640
#include<stdio.h>
int main()
{
	int d;
	scanf("%d", &d);
	int c[30];
	int i;
	for (i = 0; i < 26; i++)
		scanf("%d", &c[i]);
	int j;
	int s[400][30];
	for (i = 0; i < d; i++)
		for (j = 0; j < 26; j++)
			scanf("%d", &s[i][j]);
	int l[400][30];
	for (i = 0; i < 26; i++)
		l[0][i] = 0;
	int t[400];
	for (i = 0; i < d; i++)
	{
		scanf("%d", &t[i]);
		t[i]--;
	}
	int m;
	scanf("%d", &m);
	int dd, q;
	int a;
	for (i = 1; i <= d; i++)
	{
		for (j = 0; j < 26; j++)
			l[i][j] = l[i - 1][j];
		l[i][t[i - 1]] = i;
	}
	int ans = 0;
	for (i = 0; i < d; i++)
	{
		ans += s[i][t[i]];
		for (j = 0; j < 26; j++)
			ans -= c[j] * (i + 1 - l[i + 1][j]);
	}
	for (j = 0; j < m; j++)
	{
		scanf("%d %d", &dd, &q);
		dd--;
		q--;
		a = t[dd];
		ans -= s[dd][a];
		ans += s[dd][q];
		t[dd] = q;
		for (i = 0; i < d; i++)
		{
			ans += c[a] * (i + 1 - l[i + 1][a]);
			ans += c[q] * (i + 1 - l[i + 1][q]);
			l[i + 1][a] = l[i][a];
			l[i + 1][q] = l[i][q];
			l[i + 1][t[i]] = i + 1;
			ans -= c[a] * (i + 1 - l[i + 1][a]);
			ans -= c[q] * (i + 1 - l[i + 1][q]);
		}
		printf("%d\n", ans);
	}
	return 0;
}

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

public class Main {
    public static void main(String[] args) throws IOException {
        final BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));


        int n = Integer.parseInt(br.readLine());
        int[] a = new int[n];
        String[] line = br.readLine().split(" ");
        for (int i = 0; i < n; ++i) {
            a[i] = Integer.parseInt(line[i]);
        }
        int q = Integer.parseInt(br.readLine());
        int[] b = new int[q], c = new int[q];
        for (int i = 0; i < q; ++i) {
            line = br.readLine().split(" ");
            b[i] = Integer.parseInt(line[0]);
            c[i] = Integer.parseInt(line[1]);
        }

        long sum = 0;
        Map<Integer, Integer> count = new HashMap<>();
        for (int i = 0; i < n; ++i) {
            sum += a[i];
            count.put(a[i], count.getOrDefault(a[i], 0) + 1);
        }

        for (int i = 0; i < q; ++i) {
            if (count.containsKey(b[i])) {
                int changed = count.get(b[i]);
                count.remove(b[i]);
                count.put(c[i], count.getOrDefault(c[i], 0) + changed);
                sum += changed * (c[i] - b[i]);
            }
            bw.write(Long.toString(sum));
            bw.newLine();
        }

        bw.close();
        br.close();
    }
}


Measured memory_bytes: 61544
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<utility>
#include<queue>
#define rep(i, n) for(int i=0;i<n;i++)
using namespace std;
int main(){
	int long long h;
	cin>>h;
	int long long a=1, b=0;
	while(h>=a){
		b+=a;
		a*=2;
	}
	cout<<b<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	private static int[] encode = {0, 1, 2, 3, 5, 7, 11, 13, 17};
	private static int[] decode = {0, 1, 2, 3, 0, 4, 0, 5, 0, 0, 0, 6, 0, 7, 0, 0, 0, 8};
	private static int[][] graph = new int[9][9];
	private static int goal = 1;

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String[] conf = scanner.nextLine().split(" ");
		int numNodes = Integer.parseInt(conf[0]);
		int numEdges = Integer.parseInt(conf[1]);

		for (int i = 1; i <= numNodes; i++) goal *= encode[i];
		for (int i = 0; i < numEdges; i++) {
			String[] input = scanner.nextLine().split(" ");
			int start = Integer.parseInt(input[0]);
			int end = Integer.parseInt(input[1]);
			graph[start][end] = 1;
			graph[end][start] = 1;
		}

		System.out.println(numPaths(1, 1));
	}

	private static int numPaths(int current, int passed) {
		if (passed == goal) return 1;

		int numPaths = 0;
		for (int dest = 1; dest <= 8; dest++) {
			if (graph[current][dest] == 1 && passed % encode[dest] != 0) {
				numPaths += numPaths(dest, passed * encode[dest]);
			}
		}
		return numPaths;
	}
}


Measured memory_bytes: 21972
c = []
for i in range(3):
    c.append(list(map(int, input().split())))

a = [0] * 3
b = [0] * 3

b[0] = c[0][0] - a[0]
b[1] = c[0][1] - a[0]
b[2] = c[0][2] - a[0]

ans = "Yes"

for i in range(3):
    if not c[1][0] - b[0] == c[1][1] - b[1] == c[1][2] - b[2]:
        ans = "No"
    if not c[2][0] - b[0] == c[2][1] - b[1] == c[2][2] - b[2]:
        ans = "No"
print(ans)


Measured memory_bytes: 3064
#include "bits/stdc++.h"
#define PRECISION(x) cout << fixed << setprecision(x)
#define FAST_IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define ALLR(X) (X).rbegin(), (X).rend()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define F first
#define S second

using namespace std;
 
template<class T> bool max_self(T & a, const T & b){ 
  return b > a ? a = b, true : false; 
}
template<class T> bool min_self(T & a, const T & b){ 
  return b < a ? a = b, true : false;    
}
typedef long long LL;
const int INF = 1e9 + 7;
const double PI = acos(-1.0);
const double EPS = (1e-9);

int N, nxt[(int)2e5 + 7][30], opt[(int)2e5 + 7];
string in;

int main(){
  FAST_IO
  cin >> in;
  N = SZ(in);
  for(int c = 0; c < 26; ++c) nxt[N][c] = N;

  for(int idx = N - 1; idx >= 0; --idx){
    for(int c = 0; c < 26; ++c){
      if(in[idx] == char(c + 'a')) nxt[idx][c] = idx;
      else nxt[idx][c] = nxt[idx + 1][c];
    }
  }

  opt[N] = 1;
  for(int idx = N - 1; idx >= 0; --idx){
    opt[idx] = INF;
    for(int c = 0, match; c < 26; ++c){
      match = nxt[idx][c];
      min_self(opt[idx], opt[match + 1] + 1);
    }
  }
      
  int itr = 0, c;
  while(itr < N + 1){
    for(c = 0; c < 26; ++c){
      int match = nxt[itr][c];
      if(opt[itr] == opt[match + 1] + 1){
        itr = match + 1;
        break;
      }
    }

    assert(c >= 0 && c < 26);
    cout << char('a' + c);
  }

  return 0;
}


Measured memory_bytes: 27972
n, *AB = map(int, open(0).read().split())
A, B = map(sorted, [AB[::2], AB[1::2]])
mid = n//2
a = A[mid]
b = B[mid]
if n % 2 == 0:
    a += A[mid-1]
    b += B[mid-1]
print(b-a+1)

Measured memory_bytes: 55252
#!/usr/bin/env python3
from collections import deque

def main():
    N, u, v = map(int, input().split())
    s = u-1
    t = v-1
    adj = [[] for _ in range(N)]
    for _ in range(N-1):
        a, b = map(lambda x: int(x)-1, input().split())
        adj[a].append(b)
        adj[b].append(a)
    
    # aoki BFS
    queue = deque([t])
    visit = [-1] * N
    visit[t] = 0
    
    while queue:
        now = queue.popleft()
        for u in adj[now]:
            if visit[u] < 0:
                queue.append(u)
                visit[u] = visit[now] + 1
                # parent[u] = now

    # takahashi BFS
    queue = deque([s])
    visit2 = [-1] * N
    # parent = [-1] * N
    visit2[s] = 0
    
    
    while queue:
        now = queue.popleft()
        for u in adj[now]:
            if visit2[u] < 0:
                queue.append(u)
                visit2[u] = visit2[now] + 1

    ans = [-1,-1]
    # print(visit, visit2)
    for i in range(N):
        if visit[i] >= visit2[i] and visit[i] > ans[0]:
            ans = [visit[i], i]
    
    print(visit[ans[1]]-1)

if __name__ == "__main__":
    main()

Measured memory_bytes: 33672
#include<iostream>
#include<cmath>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	int d,n;
	cin>>d>>n;
	int t[d],a[n],b[n],c[n],dp[d][n];
	rep(i,d)cin>>t[i];
	rep(i,n)cin>>a[i]>>b[i]>>c[i];
	rep(i,d)rep(j,n)dp[i][j]=-1;
	rep(i,n)dp[0][i]=0;
	rep(i,d-1){
		rep(j,n){
			rep(k,n)if(a[j]<=t[i] && t[i]<=b[j] && a[k]<=t[i+1] && t[i+1]<=b[k])dp[i+1][k]=max(dp[i+1][k],dp[i][j]+(int)abs(c[k]-c[j]));
		}
	}
	int ans=0;
	rep(i,n)ans=max(ans,dp[d-1][i]);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1316
n = int(input())

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

ans = 0
for i in range(n - 2):
  if a[i] > a[i+1] and a[i+1] > a[i+2]:
    ans += 1
  if a[i] < a[i+1] and a[i+1] < a[i+2]:
    ans += 1

print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<cmath>

using namespace std;

int main(){
	string data[7]={
		/*小数7桁*/
		"0078125",
		"0156250",
		"0312500",
		"0625000",
		"1250000",
		"2500000",
		"5000000",
	};
	int bit[16][4]={
		{0,0,0,0},
		{0,0,0,1},
		{0,0,1,0},
		{0,0,1,1},
		{0,1,0,0},
		{0,1,0,1},
		{0,1,1,0},
		{0,1,1,1},
		{1,0,0,0},
		{1,0,0,1},
		{1,0,1,0},
		{1,0,1,1},
		{1,1,0,0},
		{1,1,0,1},
		{1,1,1,0},
		{1,1,1,1}};
	long long n;
	int Q;
	string in;
	int s[8];
	int s2[32];
	int carry;
	int nn;
	string a,b;
	bool f;

	cin>>Q;
	for(int i=0;i<Q;i++){
		cin>>in;
		for(int j=0;j<in.size();j++){
			if(in[j]>='0'&&in[j]<='9') s[j]=in[j]-'0';
			else  s[j]=in[j]-'a'+10;
		}
		for(int j=0;j<8;j++){
			for(int k=0;k<4;k++){
				s2[k+j*4]=bit[s[j]][k];
			}
		}
		n=0;
		for(int j=1;j<=24;j++){
			if(s2[j]==1) n+=pow(2,24-j);
		}
		a="";
		carry=0;
		for(int j=6;j>=0;j--){
			nn=carry;
			for(int k=25;k<32;k++){
				if(s2[k]==1) nn+=data[31-k][j]-'0';
			}
			carry=nn/10;
			b=(nn%10+'0');
			a=b+a;
		}
		if(s2[0]==1) cout<<"-";
		cout<<n;

		cout<<".";

		f=false;
		for(int j=0;j<7;j++){
			if(a[j]!='0') f=true;
		}
		if(f){
			b="";
			f=false;
			for(int j=6;j>=0;j--){
				if(a[j]!='0'||f){
					b=a[j]+b;
					f=true;
				}
			}
			cout<<b;
		}
		else cout<<"0";

		cout<<endl;
	}
	
}

Measured memory_bytes: 1252
#include <iostream>
#include <cstdint>

using namespace std;

int main() {
  const uint64_t mod = 998244353;
  uint64_t n, k;
  cin >> n >> k;
  uint64_t l[10];
  uint64_t r[10];
  for (uint64_t i = 0; i < k; ++i) {
    cin >> l[i] >> r[i];
  }
  uint64_t d[400020] = {0, 1, mod-1};
  uint64_t p = 1;
  for (uint64_t i = 1; i < n; ++i) {
    for (uint64_t j = 0; j < k; ++j) {
      d[i+l[j]] = (d[i+l[j]] + p) % mod;
      d[i+r[j]+1] = (d[i+r[j]+1] + mod - p) % mod;
    }
    p = (p + d[i+1]) % mod;
  }

  cout << p << endl;
}


Measured memory_bytes: 6304
#include "bits/stdc++.h"
using namespace std;
int main(){
  int n,x=0;
  string a,b,c;
  cin >> n >> a >> b >> c;
  for(int i=0;i<n;i++){
    if((a[i] != b[i]) && (b[i] != c[i]) && (a[i] != c[i])){
      x += 2;
    }else if((a[i] == b[i]) && (b[i] == c[i]) && (a[i] == c[i])){
      continue;
    }else{
      x += 1;
    }
  }
  cout << x;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
typedef complex<ld> Point;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
const ld eps = 1e-6;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;

struct uf {
private:
	vector<int> par, ran;
public:
	
	uf(int n) {
		par.resize(n, 0);
		ran.resize(n, 0);
		rep(i, n) {
			par[i] = i;
		}
	}
	int find(int x) {
		if (par[x] == x)return x;
		else return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x), y = find(y);
		if (x == y)return;
		if (ran[x] < ran[y]) {
			par[x] = y;
		}
		else {
			par[y] = x;
			if (ran[x] == ran[y])ran[x]++;
		}
	}
	bool same(int x, int y) {
		return find(x) == find(y);
	}
};

struct edge {
	int u, v, cost;
	bool operator<(const edge &e)const {
		return vector<int>{cost, u, v} < vector<int>{e.cost, e.u, e.v};
	}
};

int n, m;

void solve() {
	vector<int> h(n);
	rep(i, n)cin >> h[i];
	vector<P> v; rep(i, n)v.push_back({ h[i],i });
	sort(v.begin(), v.end());
	vector<edge> u;
	rep(i, m) {
		int a, b, c; cin >> a >> b >> c; a--; b--;
		u.push_back({ a,b,c });
	}
	sort(u.begin(), u.end());
	vector<vector<edge>> key;
	//key.push_back(u);
	rep(i, n) {
		if (i > 0 && v[i].first == v[i - 1].first)continue;
		//while (i + 1 < n&&v[i].first == v[i + 1].first)i++;
		vector<bool> exi(n, true);
		rep(j, i) {
			exi[v[j].second] = false;
		}
		vector<edge> nex;
		uf t(n);
		rep(j, m) {
			if (!exi[u[j].u] || !exi[u[j].v])continue;
			if (!t.same(u[j].u, u[j].v)) {
				nex.push_back(u[j]);
				t.unite(u[j].u, u[j].v);
			}
		}
		bool f = true;
		int root = -1;
		rep(j, n) {
			if (!exi[j])continue;
			if (root < 0) {
				root = j;
			}
			else {
				if (!t.same(root, j))f = false;
			}
		}
		if (!f)break;
		key.push_back(nex);
	}
	ll ans = 0;
	uf t(n);
	per(i, (int)key.size()) {
		rep(j, key[i].size()) {
			edge &e = key[i][j];
			if (!t.same(e.u, e.v)) {
				ans += e.cost;
				t.unite(e.u, e.v);
			}
		}
	}
	//cout << "answer is ";
	cout << ans << endl;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	while (cin >>n>>m,n) {
		solve();
	}
	//stop
	return 0;
}


Measured memory_bytes: 3608
// https://atcoder.jp/contests/abc061/tasks/abc061_b
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector<int> v(n + 1);
    REP(i, m) {
        int a, b;
        cin >> a >> b;
        v[a]++;
        v[b]++;
    }
    FOR(i, 1, n + 1) cout << v[i] << "\n";

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include<cstring>
#include<map>
#include<set>
#include<cstdlib>
#include<bitset> 
using namespace std;
typedef long long ll;
int main(void)
{
	ll n;
	ll a[200];
	scanf("%lld",&n);
	for(ll i=1;i<=n;i++) scanf("%lld",&a[i]);
	ll ans=0;
	for(ll i=1;i<=n;i+=2)
	{
if(a[i]%2==1) ans++;
	}
	printf("%lld",ans);
}

Measured memory_bytes: 3812
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define fir first
#define sec second
#define MOD 1000000007
#define vvi vector<vector<int> >
#define vvs vector<vector<string> >
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
#define pb push_back
#define vi vector<int>
#define test(t) int t; cin>>t; while(t--)
#define vl vector<ll>
#define vb vector<bool>
#define vs vector<string>
#define vvl vector<vl>
#define loopin(i, n) for(int i = 0; i < (n); i++)
#define loopdec(i, n) for(int i = n-1; i >= 0; i--)
const int mod=1e9+7;


void solve(){
int n,x,t;
cin>>n>>x>>t;
int diff=n/x;
if(n%x!=0){
	diff=diff+1;
}
cout<<diff*t<<endl;

}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
cin>>ws;

   solve();

return 0;
}


Measured memory_bytes: 3640
#include <stdio.h>

int main(void) {
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if(a<=b&&b<=c) printf("%d %d %d\n",a,b,c);
    else if(a<=c && c<=b) printf("%d %d %d\n",a,c,b);
    else if(a<=a && a<=c) printf("%d %d %d\n",b,a,c);
    else if(b<=c && c<=a) printf("%d %d %d\n",b,c,a);
    else if(c<=a && a<=b) printf("%d %d %d\n",c,a,b);
    else if(c<=b && b<=a) printf("%d %d %d\n",c,b,a);
    return 0;
}



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

const int MAX = 1000000;
const int MOD = 1000000007;

signed main() {
 string s;
 cin>>s;
 sort(s.begin(),s.end());
 if(s=="abc")cout<<"Yes";
 else cout<<"No";
}


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

using namespace std;

int main()
{
    string S;
    cin>>S;
    if(S[0]=='S')
    {
        cout<<"Cloudy"<<endl;
    }
    else if(S[0]=='C')
    {
        cout<<"Rainy"<<endl;
    }
    else
    {
        cout<<"Sunny"<<endl;
    }
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

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


Measured memory_bytes: 764
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
#define rep(n) for (int i = 0; i < (n); ++i)
typedef long long ll;
int main()
{
    int n;
    cin >> n;
    vector<ll> h(n);
    rep(n) cin >> h[i];
    int cnt = 0, m = 0;
    rep(n - 1)
    {
        if (h[i] >= h[i + 1])
        {
            cnt++;
        }
        else
        {
            m = max(m, cnt);
            cnt = 0;
        }
    }
    m = max(m, cnt);
    cout<<m;
}

Measured memory_bytes: 1024
import java.util.*;

class Main {
   public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      final double PI = 3.141592653589;
      double r = sc.nextDouble();
      System.out.printf("%f %f\n", (r * r * PI), (2 * r * PI));
   }
}

Measured memory_bytes: 18888
n = int(input())
a = [0]*n
for i in range(n):
    a[i] = int(input())
a = sorted(a)
from collections import deque
q = deque([])
q.extend(a)
p = deque([])
i = 0
while len(q) > 1:
    if i%2 == 0:
        y = q.popleft()
        p.appendleft(y)
        
        x = q.pop()
        p.append(x)
            
    else:
        y = q.popleft()
        p.append(y)
        
        x = q.pop()
        p.appendleft(x)
    i += 1
p1 = list(p) + list(q)
p2 = list(q) + list(p)
ans1 = 0
ans2 = 0
for i in range(n-1):
    ans1 += abs(p1[i+1]-p1[i])
    ans2 += abs(p2[i+1]-p2[i])
print(max(ans1,ans2))

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

typedef long long ll;
int main(void){
    int X, Y;
    cin >> X >> Y;
    bool flag = false;
    
    for (int i = 0; i <= X; i++) {
        if (Y == i * 4 + (X-i)*2)
            flag = true;
    }
    if (flag)
        cout << "Yes";
    else
        cout << "No";
}

Measured memory_bytes: 3636