akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>  
using namespace std;
using ll = long long int;
using pii = pair<int, int>;
#define rep(i,n) for(int i=0; i<(int)(n); i++)

int main() {
  ll n; cin>>n;
  vector<ll> v(n);

  rep(i,n){cin>>v[i];}
  if(n%2==0){
    ll m=n/2;
    rep(i,m){cout<<v[2*(m-i)-1]<<" ";}
    rep(i,m){cout<<v[2*i]<<" ";}
  }
  else{
    ll m=(n-1)/2;
    rep(i,m+1){cout<<v[2*(m-i)]<<" ";}
    rep(i,m){cout<<v[2*i+1]<<" ";}
  }
} 

Measured memory_bytes: 3712
#include<iostream>
#include<string>
#include<sstream>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<cmath>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<numeric>
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; }
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};

vector<int> adj[100005]; //adjacency list
int n;
vector<int> dist;

void dfs(int v, int d=0, int p=-1)
{
    dist[v] = d;
    for(int u: adj[v])
    {
        if(u == p) continue;
        dfs(u,d+1,v);
    }
}

vector<int> calcDist(int v)
{
    dist = vector<int>(n);
    dfs(v);
    return dist;
}

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

    int u,v;
    cin >> n >> u >> v;
    --u; --v; //0-indexed
    rep(i,n-1)
    {
        int a,b;
        cin >> a >> b;
        --a; --b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }

    vector<int> distT = calcDist(u);
    vector<int> distA = calcDist(v);

    int mx = 0;
    rep(i,n)
    {
        if(distT[i]<distA[i])
        {
            mx = max(mx,distA[i]);
        }
    }
    int ans = mx - 1;
    cout << ans << endl;
    return 0;
}

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

#ifdef _DEBUG
#define debug(x) cout<<#x<<": "<<x<<endl
#else
#define debug(x)
#endif

using namespace std;

int main() {
    int N; string S;
    cin >> N >> S;
    int cnt = 0;
    for (int i = 0; i + 2 < N; ++i) {
        if (S.substr(i, 3) == "ABC") {
            cnt++;
        }
    }
    cout << cnt << endl;
}

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

int main(){
  while(1){
    string a;
    int b,c,d;
    cin>>a;
    if(a=="#") break;
    cin>>b>>c>>d;
    if(b>31) cout<<"? "<<b-30<<" "<<c<<" "<<d<<endl;
    else if(b==31&&c>=5) cout<<"? "<<b-30<<" "<<c<<" "<<d<<endl;
    else
    cout<<"HEISEI "<<b<<" "<<c<<" "<<d<<endl;
  }
  return 0;
}



Measured memory_bytes: 3200
#include <stdio.h>
#include <string.h>
int main(){
  char s[30][30][10];
  int i,j;
  int h,w;
  scanf("%d %d",&h,&w);
  for(i=1;i<=h;i++){
    for(j=1;j<=w;j++){
      scanf("%s",s[i][j]);
    }
  }
  for(i=1;i<=h;i++){
    for(j=1;j<=w;j++){
      if(strcmp(s[i][j],"snuke")==0){
        switch(j){
          case 1: printf("A%d\n",i); break;
          case 2: printf("B%d\n",i); break;  
          case 3: printf("C%d\n",i); break;  
          case 4: printf("D%d\n",i); break;
          case 5: printf("E%d\n",i); break;
          case 6: printf("F%d\n",i); break;
          case 7: printf("G%d\n",i); break;    
          case 8: printf("H%d\n",i); break;
          case 9: printf("I%d\n",i); break;
          case 10:  printf("J%d\n",i); break;
          case 11: printf("K%d\n",i); break;
          case 12: printf("L%d\n",i); break;
          case 13: printf("M%d\n",i); break;
          case 14: printf("N%d\n",i); break;
          case 15: printf("O%d\n",i); break;
          case 16: printf("P%d\n",i); break;
          case 17: printf("Q%d\n",i); break;
          case 18: printf("R%d\n",i); break;
          case 19: printf("S%d\n",i); break;
          case 20: printf("T%d\n",i); break;
          case 21: printf("U%d\n",i); break;
          case 22: printf("V%d\n",i); break;
          case 23: printf("W%d\n",i); break;
          case 24: printf("X%d\n",i); break;
          case 25: printf("Y%d\n",i); break;
          case 26: printf("Z%d\n",i);  
        }
       goto end;
      }
    }
  }
  end:
  return 0;
}

Measured memory_bytes: 1732
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AAlready2018 solver = new AAlready2018();
        solver.solve(1, in, out);
        out.close();
    }

    static class AAlready2018 {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            out.println("2018" + in.next().substring(4));
        }

    }
}



Measured memory_bytes: 21204
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner can = new Scanner(System.in);
		int n = can.nextInt();
		int m = can.nextInt();
		
		System.out.println((n * (n-1))/2 + (m * (m-1))/2);
		
		
	}
	
}


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

int main() {
  int a, b;
  int digit;
  while(cin >> a >> b) {
    digit =	0;
    a = a + b;
    while(a != 0) {
      a /= 10;
      digit++;
    }
    cout << digit << endl;
  }

  return 0;
}



Measured memory_bytes: 3028
use proconio::*;
use std::cmp::max;
use std::collections::BinaryHeap;

#[fastout]
fn main() {
    input! {
        d: usize,
        c: [i64; 26],
        s: [[i64; 26]; d],
    };

    let mut lasts = [-1; 26];
    let mut t = vec![26; d];
    let depth = 24;
    for i in 0..d {
        let mut max_score = -10000000;
        for j in 0..26 {
            let tmp = search(i, j, &c, &s, &mut lasts, depth, d, 0, 6);
            if tmp > max_score {
                max_score = tmp;
                t[i] = j;
            }
        }
        lasts[t[i]] = i as i64;
    }

    for &a in &t {
        println!("{}", a + 1);
    }
}

fn calc_score(i: usize, j: usize, c: &Vec<i64>, s: &Vec<Vec<i64>>, lasts: &mut [i64; 26]) -> i64 {
    let mut res = s[i][j];
    let tmp = lasts[j];
    lasts[j] = i as i64;

    for j in 0..26 {
        let i = i as i64;
        let last = lasts[j];
        res -= c[j] * (i - last);
    }

    lasts[j] = tmp;
    res
}

fn search(
    i: usize,
    t: usize,
    c: &Vec<i64>,
    s: &Vec<Vec<i64>>,
    lasts: &mut [i64; 26],
    depth: usize,
    d: usize,
    cscore: i64,
    l: usize,
) -> i64 {
    if depth == 0 || i == d - 1 {
        return calc_score(i, t, &c, &s, lasts) + cscore;
    }

    let l = max(1, l - 1);
    let mut max_score = -1000000;
    let tmp_last = lasts[t];
    lasts[t] = i as i64;
    let tmp_score = calc_score(i, t, &c, &s, lasts);
    let mut cands = BinaryHeap::new();
    cands.reserve(26);
    for j in 0..26 {
        let tmp_score = calc_score(i + 1, j, &c, &s, lasts);
        cands.push((tmp_score, j));
    }
    let w = if l > 1 { 2 } else { 1 };
    for &(_, j) in cands.iter().take(w) {
        let tmp = search(i + 1, j, &c, &s, lasts, depth - 1, d, cscore + tmp_score, l);

        if tmp > max_score {
            max_score = tmp;
        }
    }

    lasts[t] = tmp_last;
    max_score + cscore
}


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

int main() {
    int A, B;
    cin >> A >> B;
    int answer;
    for (int i = 0; i < B - A + 1; i++) {
        if ((A + i) /10000 == (A + i) % 10 &&
         (A + i) % 10000 / 1000 == (A + i) % 100 / 10) {
            answer++;
        }
    }
    cout << answer << endl;
}


Measured memory_bytes: 384
def search(X,Y):

 n=len(X)
 m=len(Y)
 p=[i for i in range(m+1)]
 for i in range(n):
  q=list(range(m+1))
  q[0] = i+1
  for j in range(m):
   if X[i]==Y[j]:
    cost=0
   else:
    cost=1
   q[j+1]=min(p[j+1]+1,q[j]+1,p[j]+cost)
  p,q=q,p
 
 return p[m]


X=input()
Y=input()

print(search(X,Y))



Measured memory_bytes: 5596
using System;
using System.Linq;

namespace B___Collecting_Balls__Easy_Version_
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var K = int.Parse(Console.ReadLine());
            var Xi = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int res = 0;

            foreach (var x in Xi)
                res += Math.Min(x * 2, Math.Abs(x - K) * 2);

            Console.WriteLine(res);
        }
    }
}


Measured memory_bytes: 13268
#include <stdio.h>          // printf(), scanf()

int mark[8][8][8][8][8][8][8];
int p[7], q[20160][10];
int v;

void
swap(int *a,int *b)
{
	int t = *a;
	*a = *b;
	*b = t;
}

void
look(int a[], int dir)
{
	for (int i = 0; i < 10; ++i)
		q[v][i] = a[i];

	switch (dir)
	{
	case 0:
		swap(&q[v][q[v][8]], &q[v][q[v][8] - 1]);
		q[v][8]--;
		break;

	case 1:
		swap(&q[v][q[v][8]], &q[v][q[v][8] + 1]);
		q[v][8]++;
		break;

	case 2:
		swap(&q[v][q[v][8]], &q[v][q[v][8] - 4]);
		q[v][8] -= 4;
		break;

	case 3:
		swap(&q[v][q[v][8]], &q[v][q[v][8] + 4]);
		q[v][8] += 4;
		break;
	}

	q[v][9]++;
	if (mark[q[v][0]][q[v][1]][q[v][2]][q[v][3]][q[v][4]][q[v][5]][q[v][6]] == 0)
	{
		mark[q[v][0]][q[v][1]][q[v][2]][q[v][3]][q[v][4]][q[v][5]][q[v][6]] = q[v][9];
		v++;
	}
}

void
inspect(int a[])
{
	if (a[8] % 4 > 0)
		look(a, 0);

	if (a[8] % 4 < 3)
		look(a, 1);

	if (a[8] > 3)
		look(a, 2);

	if (a[8] < 4)
		look(a, 3);
}

int
main(int argc, char **argv)
{
	mark[0][1][2][3][4][5][6] = 1;
	for (int i = 0; i < 8; ++i)
		q[0][i] = i;

	q[0][8] = 0;
	q[0][9] = 1;
	v = 1;
	for (int i = 0; i < v; ++i)
		inspect(q[i]);

	while (scanf("%d %d %d %d %d %d %d %*d", &p[0], &p[1], &p[2], &p[3], &p[4], &p[5], &p[6]) != EOF)
		printf("%d\n", mark[p[0]][p[1]][p[2]][p[3]][p[4]][p[5]][p[6]] - 1);

	return 0;
}

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

using namespace std;

int main(){
  string S;
  cin >> S;
  
  bool hitachi = true;
  for(int i = 0; i < S.size(); i++){
    if(i & 1){
      if(S[i] != 'i') hitachi = false;
    }else{
      if(S[i] != 'h') hitachi = false;
    }
  }
  
  if(hitachi && (int)S.size() % 2 == 0) puts("Yes");
  else puts("No");
  
  return 0;
}

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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"

typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef long double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

const ll maxn=1000001,mod=1e9+7;

int main(){
sync
    string s;
    cin>>s;
    string  t= "keyence";
    string tp;
    int i=0;
    int n=t.size();
    if(s[0]=='k'){
        while(i<n&&s[i]==t[i]){
            tp+=s[i];
            i++;
        }
    if(i==n){
        cout<<"YES";
    }
    else{
       // cout<<tp<<endl;
        string tp1=t.substr(i,n-i+1);
       //wcout<<tp1<<endl;
        int j=tp1.size()-1;
        //cout<<j<<endl;
        if(s.back()!='e'){
            cout<<"NO";
        }
        else{
            i=s.size()-1;
            while(j>=0&&s[i]==tp1[j]){
                i--;
                j--;
            }
            //cout<<j<<endl;
            if(j>=0){
                cout<<"NO";
            }
            else{
                cout<<"YES";
            }
        }
    }
}
else{
    int j=n-1;
    int i=s.size()-1;
    while(j>=0&&i>=0&&s[i]==t[j]){
        i--;
        j--;
    }
    if(j==-1){
        cout<<"YES";
    }
    else{
        cout<<"NO";
    }
}
return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  string s;
  int k;
  cin >> k >> s;
  int n = s.length();
  if(n<=k){
    cout << s;
  }
  else{
    cout << s.substr(0, k) << "...";
  }
  return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <vector>
#include <cmath>

#define rep(i,n) for (int i = 0; i < (n); ++i)

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main() {
  const int MOD = 1000000007;
  int N, M;
  cin >> N >> M;

  int a = std::max(N, M);
  int b = std::min(N, M);

  long long sum = 1;
  if (a - b > 1) cout << 0 << endl;
  else {
    for (int i = 1; i <= a; i++) {
      sum *= i;
      sum %= MOD;
    }

    for (int i = 1; i <= b; i++) {
      sum *= i;
      sum %= MOD;
    }

    if (a == b) {
      sum *= 2;
      sum %= MOD;
    }

    cout << sum << endl;
  }

  return 0;
}


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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>istream &operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
//template <typename T, typename S>ostream &operator<<(ostream &os, pair<T, S> &p) {os << p.first << " " << p.second;return os;}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T, class U>bool chmin(T& a, U b) { if (a > b) { a = b; return true; }return false; }
template <class T, class U>bool chmax(T& a, U b) { if (a < b) { a = b; return true; }return false; }

signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	int N, T; cin >> N >> T;
	vector<int>A(N), B(N); rep(i, 0, N) { cin >> A[i] >> B[i]; }

	vector<pii>v;
	rep(i, 0, N) {
		v.eb(B[i], A[i]);
	}
	sort(all(v));
	rep(i, 0, N) {
		A[i] = v[i].second;
		B[i] = v[i].first;
	}

	dump(A);
	dump(B);

	vector<vector<pii>>dp(N + 1, vector<pii>(T + 1, pii(0, 0)));
	dp[0][0] = pii(0, 0);
	rep(i, 0, N) {
		rep(j, 0, T + 1) {
			dp[i + 1][j] = dp[i][j];
			dp[i + 1][j].second = 0;
			if (j >= A[i]) {
				if (chmax(dp[i + 1][j].first, dp[i][j - A[i]].first + B[i])) {
					dp[i + 1][j].second = 1;
				}
			}
		}
	}

	//rep(i, 0, dp.size()) {
	//	rep(j, 0, dp[i].size()) {
	//		cout << dp[i][j] << (j == dp[i].size() - 1 ? '\n' : ' ');
	//	}
	//}

	int ans = dp[N][T].first;
	int w = T - 1;
	rrep(i, 1, N + 1) {
		dump(w);
		if (dp[i][w].second == 1) {
			w -= A[i - 1];
		}
		else {
			chmax(ans, dp[N][T - 1].first + B[i - 1]);
			break;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 141312
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL, LL> P;

int main(){
    int N;
    cin >> N;
    vector<int> d(N);
    for(int i = 0;i < N;i++)    cin >> d[i];
    LL ans = 0;
    for(int i = 0;i < N-1;i++){
        for(int j = i+1;j < N;j++){
            ans += d[i]*d[j];
        }
    }

    
    cout << ans << endl;
}

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

void swap (char *x, char *y) {
    char temp;    // 値を一時保存する変数
    temp = *x;
    *x = *y;
    *y = temp;
}

int main() {
    int n, ans = 0;
    int piv1 = 0, piv2 = 0;
    int i, j, k;
    char c[200020] = {0};
    //int b[200020] = {0};//1なら消えている
    scanf("%d", &n);
    scanf("%s", c);
    i = -1;
    j = n ;

    do {
        do { i++; } while (c[i] == 'R');
        do { j--; } while (c[j] == 'W');
        if (i < j) {
            swap(&c[i],&c[j]);
            //printf("%s\n",c);
            ans++;
        }
    } while(i<j);

    printf("%d",ans);
}


Measured memory_bytes: 1932
def gcd(a,b):
    if a < b:
        a, b = b, a
    while b >= 1:
        a, b = b, a % b
    return a

def shave(n):
    n_root = int(n**0.5)
    candidate = [i for i in range(3,n+1,2)]
    for i in range(3,n_root+2,2):
        candidate = [ j for j in candidate if j == i or j % i != 0]   
    candidate = [2] + candidate
    return candidate

x, y = [ int(v) for v in input().split() ]

gcd1 = gcd(x, y)
prime_list = shave(int(gcd1**0.5)+1)

ans = 1
for i in prime_list:
    if gcd1 % i == 0:
        ans += 1
        while gcd1 % i == 0:
            gcd1 //= i
if gcd1 != 1:
    ans += 1
print(ans)

Measured memory_bytes: 135260
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Graph vector<vector<ll>>
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000007;

int check(int a, int b, int N){
    int ans = 0;
    if(a == b){
        if(a <= N) ans += 1;
        else return 0;
    }
    N -= a;
    N /= 10;
    int digit_10 = 1;

    while(1){
        int tmp = digit_10 * b;
        bool flag = false;
        for(int i = 0; i < digit_10; i++){
            if((tmp + i) <= N) ans++;
            else{
                flag = true;
                break;
            }
        }
        if(flag) break;
        digit_10 *= 10;
    }

    return ans;

}

int main(){
    int N;
    cin >> N;
    Graph G(10, vector<ll>(10, 0));

    for(int i = 1; i <= 9; i++){
        for(int j = 1; j <= 9; j++){
            G[i][j] = check(j, i, N);
        }
    }

    ll ans = 0;
    for(int i = 1; i <= 9; i++){
        for(int j = 1; j <= 9; j++){
            ans += G[i][j] * G[j][i];
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for (long long i = (a); i < (b); i++)
#define rep2(r, aa, bb) for (long long r = (aa); r >= (bb); r--)
using namespace std;

int main()
{
    string s;
    cin >> s;
    int a = 0, b = 0, it = s.size()-1;
    rep(i,0,s.size()/2){
        if(s[i]!=s[it]){
            a++;
        }
        it--;
    }
    cout << a << endl;
}

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

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

int main() {
	
	int n; cin >>n;
	vector<int> a(n), b(n), c(n);
	for(int i=0; i<n; i++){
		cin >>a.at(i)>>b.at(i)>>c.at(i);
	}
	vector<vector<int>> dp(n,vector<int>(3));
	dp.at(0).at(0) = a.at(0);
	dp.at(0).at(1) = b.at(0);
	dp.at(0).at(2) = c.at(0);
	for(int i=1; i<n; i++){
		for(int j=0; j<3; j++){
			if(j!=0)chmax( dp.at(i).at(0) , dp.at(i-1).at(j)+a.at(i));
			if(j!=1)chmax( dp.at(i).at(1) , dp.at(i-1).at(j)+b.at(i));
			if(j!=2)chmax( dp.at(i).at(2) , dp.at(i-1).at(j)+c.at(i));
		}
	}
	cout << max({dp.at(n-1).at(0), dp.at(n-1).at(1), dp.at(n-1).at(2)}) << endl;
	
}


Measured memory_bytes: 6912
def main():
    s = raw_input()
    d = {}
    for c in s:
        d[c] = d.get(c, 0) + 1
    if len(d) == 2 and list(d.values()) == [2, 2]:
        print 'Yes'
    else:
        print 'No'


if __name__ == '__main__':
    main()


Measured memory_bytes: 27884
n = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
ans = 0
for i in range(n-1):
    ans += B[A[i]-1]
    if A[i+1] - A[i] == 1:
        ans += C[A[i]-1]
ans += B[A[-1]-1]
print(ans)

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

int main() {
  int N;
  cin >> N;
  double A, sum = 0.0;
  for(int i = 0; i < N; i++){
    cin >> A;
    sum += 1.0 / A;
  }
  cout << setprecision(16) << (double)(1.0 /sum) << endl;
}


Measured memory_bytes: 256
//Comparison.cpp (B)
#include <iostream>
#include <string>
using namespace std;

int main(){
  string A,B;
  cin >> A >> B;
  bool flag = true;
  if(A.size() > B.size()) printf("GREATER\n");
  else if(A.size() < B.size()) printf("LESS\n");
  else{
    for(int i = 0; i < A.size(); i++){
      if(A[i] == B[i]) continue;
      if(A[i] > B[i]){
        flag = false;
        printf("GREATER\n");
        return 0;
      }else if(A[i] < B[i]){
        flag = false;
        printf("LESS\n");
        return 0;
      }
    }
    if(flag){
      printf("EQUAL\n");
      return 0;
    }
  }

  return 0;

}


Measured memory_bytes: 256
//https://atcoder.jp/contests/abc162/tasks/abc162_b
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n;
	cin>>n;
	ll sum1=0;
	sum1=(n*(n+1))/2;
	ll n3;
	n3=(n)/3;
	ll n5;
	n5=(n)/5;
	ll n15;
	n15=(n)/15;
	ll a3;
	a3=3+(n3-1)*3;
	ll a5;
	a5=5+(n5-1)*5;
	ll a15;
	a15=15+(n15-1)*15;
	ll sum3=0;
	sum3=((n3)*(3+a3))/2;
	ll sum5=0;
	sum5=((n5)*(5+a5))/2;
	ll sum15=0;
	sum15=((n15)*(15+a15))/2;
	ll sumfin=0;
	sumfin=sum3+sum5-sum15;
	ll ans=0;
	ans=sum1-sumfin;
	cout<<ans<<"\n";
	
	
	return 0;
}

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

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	int n,t,res=0;
	cin>>n>>t;
	vector<int> a(n);
	for(int& x:a) cin>>x;
	for(int i=0;i<n;++i)
		res+=(i==n-1||(a[i+1]-a[i]>=t))?t:a[i+1]-a[i];
	cout<<res<<'\n';
}



Measured memory_bytes: 3968
#include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(),(c).end())

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

using namespace std;
string dir[1024];
vector<int> subd[1024];
void pr(int d,int n){
  if(n!=0){
    REP(i,n-1) cout << '.';
    cout << dir[d] << endl;
  }
  REP(i,subd[d].size()){
    pr(subd[d][i],n+1);
  }
}
int main(void)
{
  int n;
  cin >> n;
  FOR(i,1,n+1){
    int pa;
    cin >> pa >> dir[i];
    subd[pa].push_back(i);
  }
  pr(0,0);
  return 0;
}

Measured memory_bytes: 3424
#include<bits/stdc++.h>
using namespace std;
int main(){
  int  h[2][3],m[2][3],s[2][3];
  int a,i,j,k;
  for(j=0;j<3;j++){
    for(i=0;i<2;i++){
      cin >> h[i][j] >> m[i][j] >> s[i][j];
    }
    int oh=h[1][j]-h[0][j];
    int om=m[1][j]-m[0][j];
    int os=s[1][j]-s[0][j];
    
    if(os<0) {
      os+=60;
      om--;
    }
    if(om<0){
      om+=60;
      oh--;
    }
    cout << oh << " " << om << " " << os << endl; 
  }
  return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>

int main(void)
{
	int cost, num, i=0;
	long long int sumc=0, sumn=0;
	int ave;
	
	while(scanf("%d,%d", &cost, &num)!=EOF) {
		sumc+=cost*num;
		sumn+=num;
		i++;
	}
	ave=(int)((double)sumn/i+0.5);
	printf("%lld\n%d\n", sumc, ave);
	
	return 0;
}


Measured memory_bytes: 588
// (N * (L  + (L + N - 1))) / 2
// (N * (2 * L + N - 1)) / 2
"use strict";
function main(input) {
    const line = input.split("\n");
    let arr = line[0].split(" ");
    const N = parseInt(arr[0]);
    const L = parseInt(arr[1]);
    let ans = (N * (2 * L + N - 1)) / 2;
    if (L + N - 1 < 0) ans -= L + N - 1;
    else if (0 < L) ans -= L;
    console.log(ans);
    return;
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29820
#include<stdio.h>
#define P(type,x) fprintf(stdout,"%"#type"\n",x)
#define S(type,x) fscanf(stdin,"%"#type,&x)

int main() {
	int A,f;
	char s[32],*p;
	S(s, s);
	for (A = f =0, p = s; *p; p++) {
		if (!A&&*p == 'A')A = 1;
		else if (A&&*p == 'Z')A = 0,f=1, printf("AZ");
	}
	f ? puts("") : puts("-1");
	return 0;
}

Measured memory_bytes: 536
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int ans = 1;
  for(int i = 0; i < s.length() / 2 - 1; i++){
    string a = "";
    for(int j = 0; j <= i; j++) a += s[j];
    string b = "";
    for(int j = i + 1; j < 2 * (i + 1); j++) b += s[j];
    if(a == b) ans = 2 * (i + 1);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
inline int read()
{
	int x;char c;
	while((c=getchar())<'0'||c>'9');
	for(x=c-'0';(c=getchar())>='0'&&c<='9';)x=x*10+c-'0';
	return x;
}
#define MN 3000
struct edge{int nx,t;}e[MN*2+5];
int a[MN+5],h[MN+5],en,f[MN+5];
inline void ins(int x,int y)
{
	e[++en]=(edge){h[x],y};h[x]=en;
	e[++en]=(edge){h[y],x};h[y]=en;
}
void dfs(int x)
{
	f[x]=1;
	for(int i=h[x];i;i=e[i].nx)if(a[e[i].t]<a[x])
		dfs(e[i].t),f[e[i].t]>1?0:f[x]=2;
}
int main()
{
	int n=read(),i;
	for(i=1;i<=n;++i)a[i]=read();
	for(i=1;i<n;++i)ins(read(),read());
	for(i=1;i<=n;++i){if(!f[i])dfs(i);if(f[i]>1)printf("%d ",i);}
}

Measured memory_bytes: 256
N = int(input())
X = [int(i) for i in input().split()]

x_max = max(X)
x_min = min(X)
x_mid = (x_max + x_min)//2

def get_dist(X, a):
    ans = 0
    for xi in X:
        ans += (xi - a)**2
    return ans


direction = 1 #1 => right, -1 => left

x = x_mid
dist1 = get_dist(X, x)
dist2 = get_dist(X, x + 1)

if dist1 > dist2:
    direction = 1
else:
    direction = -1


ans = 0
while True:
    dist2 = get_dist(X, x + direction)

    if dist1 <= dist2:
        ans = dist1
        break

    dist1 = dist2
    x = x + direction
print(ans)



Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s, n) for(int i = s; i < (int)(n); i++)
#define co(x) cout<<x<<endl
#define SQvec(i,j) vector<vector<int>> data(i, vector<int>(j))
#define mod 1000000000+7
typedef long long int lint;

int main (){
  lint N,cnt = 0;
  cin >> N;
  vector<lint> A(N);
  rep(i,0,N){cin >> A[i];}
  
  rep(i,0,N){
    while(A[i] % 2 == 0){
      A[i] /= 2;
      cnt++;
    }
  }
  co(cnt);
}

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

long long digitCount(long long x) {
  long long ans = 0;
  do {
    x /= 10;
    ans++;
  } while (0 < x);
  return ans;
}

long long f(long long A, long long B) {
  return max(digitCount(A), digitCount(B));
}

int main() {
  long long N;
  cin >> N;
  long long B, ans = digitCount(N), sN = ceil(sqrt(N));
  for (long long A = 2; A <= sN; A++) {
    if (N % A != 0) {
      continue;
    }
    B = N / A;
    long long tmp = f(A, B);
    if (tmp < ans) {
      ans = tmp;
    }
  }
  cout << ans << endl;
}

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

#define rep(i, n) for (int i = 0; i < (n); ++i)

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main()
{
  char b;
  cin >> b;

  switch (b)
  {
  case 'A':
    cout << "T" << endl;
    break;
  case 'T':
    cout << "A" << endl;
    break;
  case 'G':
    cout << "C" << endl;
    break;
  case 'C':
    cout << "G" << endl;
    break;
  }

  return 0;
}


Measured memory_bytes: 256
n = int(input())
A = [int(i) for i in input().split()]

def gcd(x, y):
    while y > 0:
        x, y = y, x % y
    return x

for i in range(n - 1):
    A[i + 1] = gcd(A[i], A[i + 1])
    
print(A[-1])

Measured memory_bytes: 14252
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){
	
	int R, C;
	
	int senbei[20][20000];
	
	int a[20];
	
	while(true){
		
		cin >> R >> C;
		
		if(R == 0 && C == 0){
			break;
		}
		
		for(int i = 0; i < R; i++){
			for(int j = 0; j < C; j++){
				cin >> senbei[i][j];
			}
		}
		
		int ans, sum, sum2;
		ans = 0;
		
		for(int i = 0; i < (1 << R); i++){
			for(int j = 0; j < R; j++){
				if((i & (1 << (R - j - 1))) != 0){
					a[j] = 1;
				}else{
					a[j] = 0;
				}
			}
			sum = 0;
			for(int j = 0; j < C; j++){
				sum2 = 0;
				for(int k = 0; k < R; k++){
					if(senbei[k][j] == a[k]){
						sum2++;
					}
				}
				sum += max(sum2, R - sum2);
			}
			if(ans < sum){
				ans = sum;
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 1580
import java.sql.SQLOutput;
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double a = sc.nextDouble();
        double b = sc.nextDouble();
        int c = sc.nextInt();
        double area = (a*b*Math.sin(Math.toRadians(c)))/2;
        double height = b*Math.sin(Math.toRadians(c));
        double length = a+b+(Math.sqrt(height*height + (a-b*Math.cos(Math.toRadians(c)))*(a-b*Math.cos(Math.toRadians(c)))));
        System.out.println(area);
        System.out.println(length);
        System.out.println(height);
    }
}



Measured memory_bytes: 27976
a, b, c, d = [int(i) for i in input().split()]


def get_num(i):
    return b // i - (a-1) // i


def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a


def lcm(a, b):
    return a * b // gcd(a, b)


all_num = b - a + 1
c_num = get_num(c)
d_num = get_num(d)
lcm = lcm(c, d)
lcm_num = get_num(lcm)

print(all_num - c_num - d_num + lcm_num)


Measured memory_bytes: 3060
#include <cstdio>
using namespace std;
const int NN = 1e5 + 5, N2N = NN * 2 - 1;
int N, A[N2N], B[N2N];
bool check(int m) {
	for (int i = 1; i <= 2 * N - 1; ++i) B[i] = (A[i] >= m);
	bool type = 0;
	for (int i = 1; i < 2 * N - 1; ++i)
		if (B[i] == B[i + 1]) {
			type = 1;
			break ;
		}
	if (!type) {
		if ((N - 1) % 2 == 0)
			return B[N];
		else return B[N] ^ 1;
	} else {
/*		printf("B : ");
		for (int i = 1; i <= 2 * N - 1; ++i)
			printf("%d ", B[i]);
		printf("\n");*/
		int p1 = 2 * N; //有可能右边没有，所以得有个初始值
		for (int i = N; i < 2 * N - 1; ++i)
			if (B[i] == B[i + 1]) {
				p1 = i;
				break ;
			}
		int p2 = 0;
		for (int i = 1; i < N; ++i)
			if (B[i] == B[i + 1]) {
				p2 = i + 1;
//				break ; //这里不能 break...要找到最靠右的
			}
//		printf("p1 : %d p2 : %d\n", p1, p2);
		return B[((p1 - N) > (N - p2)) ? p2 : p1];
	}
}
int main() {
	scanf("%d", &N);
	for (int i = 1; i <= 2 * N - 1; ++i)
		scanf("%d", &A[i]);
	int L = 1, R = 2 * N - 1, ans = 0;
	while (L <= R) {
		int m = (L + R) >> 1;
		if (check(m)) {
			ans = m;
			L = m + 1;
		} else R = m - 1;
	}
	printf("%d\n", ans);
//	printf("check(6) : %d\n", check(6));
	return 0;
}
/*
5
5 4 8 9 1 6 3 2 7 
*/

Measured memory_bytes: 4764
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define fi first
#define se second
using namespace std;

const int mx = 1e5 + 1;

void solve() {
	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;
}

int main() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t;
	t = 1;
	//cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 3880
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string>

using namespace std;

int main()
{
	int n, q;
	int count = 0;
	int s[10000];
	int t[500];
	
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> s[i];
	}
	cin >> q;
	for (int i = 0; i < q; i++)
	{
		cin >> t[i];
	}

	for (int i = 0; i < q; i++)
	{
		int j = 0;
		while (true)
		{
			if (t[i] == s[j])
			{
				count++;
				break;
			}
			if (j == n)
			{
				break;
			}
			j++;
		}
	}

	cout << count << endl;

	return 0;
}

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

int l[55];

int main() {
	int n, k;
	cin >> n >> k;
	for (int i = 1; i <= n; ++i) cin >> l[i];
	sort(l + 1, l + 1 + n);
	int sum = 0;
	for (int i = n; i >= n - k + 1; --i) sum += l[i];
	cout << sum << endl;
}

Measured memory_bytes: 256
MOD=10**9+7
class Fp(int):
    def __new__(self,x=0):return super().__new__(self,x%MOD)
    def inv(self):return self.__class__(super().__pow__(MOD-2,MOD))
    def __add__(self,value):return self.__class__(super().__add__(value))
    def __sub__(self,value):return self.__class__(super().__sub__(value))
    def __mul__(self,value):return self.__class__(super().__mul__(value))
    def __floordiv__(self,value):return self.__class__(self*self.__class__(value).inv())
    def __pow__(self,value):return self.__class__(super().__pow__(value%(MOD-1), MOD))
    __radd__=__add__
    __rmul__=__mul__
    def __rsub__(self,value):return self.__class__(-super().__sub__(value))
    def __rfloordiv__(self,value):return self.__class__(self.inv()*value)
    def __iadd__(self,value):self=self+value;return self
    def __isub__(self,value):self=self-value;return self
    def __imul__(self,value):self=self*value;return self
    def __ifloordiv__(self,value):self=self //value;return self
    def __ipow__(self,value):self=self**value;return self
    def __neg__(self):return self.__class__(super().__neg__())

from collections import Counter
def main():
    N=int(input())
    S=input()
    C=Counter(S)
    ans=Fp(1)
    for v in C.values():
        ans*=v+1
    print(ans-1)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3572
#include<bits/stdc++.h>
#define fi first
#define se second
#define Mp make_pair
#define pb push_back
#define rep(i, j, k) for (int i = (j); i <= (k); i++)
#define per(i, j, k) for (int i = (j); i >= (k); i--)
using namespace std;

typedef long long ll;
typedef double db;
typedef pair<int, int> PII;
typedef vector<int> VI;

int a,b;

int main(){
    cin>>a>>b;
    if(a>9||b>9) printf("-1\n");
    else printf("%d\n",a*b);
    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def main():
    N = int(input())
    ans = 0
    for i in range(10):
        if 2 ** i <= N:
            ans = 2 ** i
    print(ans)


if __name__ == '__main__':
    main()


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

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define MIN(a,b) ((a)>(b)? (b): (a))
#define MAX(a,b) ((a)<(b)? (b): (a))

const long long INF = 1LL << 60;
typedef long long ll;
const long long MOD = 1000000000 + 7;

int main(){
    int n;
    cin >> n;
    vector<ll> h(n);
    rep(i, n) cin >> h[i];
    ll nm_h = 0;
    ll tot_step = 0;
    rep(i, n)
    {
        if(h[i] > nm_h)
        {
            nm_h = h[i];
        }else if(h[i] < nm_h)
        {
            tot_step += nm_h - h[i];
        }
    }
    cout << tot_step << endl;
    return 0;
}

Measured memory_bytes: 4784
#define MOD 1000000007
#define PI 3.14159265358979323846
#define inf 100000000000000
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define ALL(V) V.begin(), V.end()
#define sz(V) (int)V.size()
//#define int long long
#define _ <<" "<<
#define forn(i, n)             for(int i = 0; i < n; i ++)
#define forn1(i, n)            for(int i = 1; i <= n; i ++)
#include <bits/stdc++.h>
 
 
using namespace std;
 
typedef long long int ll;
typedef vector <int> vi;
typedef vector<vi> vvi;
typedef pair <int, int> ii;
typedef pair<int, pair<int,int> > iii;
typedef vector<ii> vii;
#define int long long


signed main() {
 
   
    
    ios::sync_with_stdio(0); cin.tie(0);
    cout.tie(0);
    //freopen("test.txt" ,"r", stdin);
    int a,b;
    cin>>a>>b;

    vector<int> va,vb;
    for(int i=1;i*i <= a;i++)
    {
        if(a%i == 0){
            va.pb(i);
            va.pb((a/i));
        }
    }

    // forn(i,va.size())cout<<va[i]<<" ";
    // cout<<endl;

    for(int i=0;i<va.size();i++)
    {
        if(b % va[i] == 0)vb.pb(va[i]);
    }
    //cout<<vb.size();
    if(vb.size() == 0){
      cout<<0;return 0;
    }

    sort(ALL(vb));
    vb.erase(unique(ALL(vb)) , vb.end());

    // forn(i,vb.size())cout<<vb[i]<<" ";
    // cout<<endl;
    int imp[vb.size()] = {0};


    for(int i=1;i<vb.size();i++)
    {
        for(int j=i+1;j<vb.size();j++)
        {
            if(vb[j] % vb[i] == 0)imp[j] =1;
        }
    }

    int ans =1;
    for(int i=1;i<vb.size();i++)
        if(imp[i] == 0)ans++;

    cout<<ans;

    
    //cout<<ans;

    // int ans = 0;

    // for(int i=0;i<va.size();i++)
    // {
    //     for(int j=0;j<vb.size();j++)
    //     {
    //         if(__gcd(va[i],vb[j]) == 1)ans++;
    //     }
    // }
    // cout<<ans;



}


Measured memory_bytes: 512
#include <stdio.h>
#include <string.h>
#include <math.h>

int main() {

    int arr[5];

    scanf("%d %d %d %d %d", &arr[0], &arr[1], &arr[2], &arr[3], &arr[4]);

    for (int i = 0; i < 5; i++) {
        if (arr[i] == 0) {
            printf("%d", i + 1);
            break;
        }
    }


    return 0;
}


Measured memory_bytes: 1724
import java.util.*;
class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int k=sc.nextInt();
		int[] v=new int[n];
		for(int i=0;i<n;i++){
			v[i]=sc.nextInt();
		}
		int ans=0;
		for(int i=1;i<=k&&i<=n;i++){
			for(int l=0;l<=i;l++){
				List<Integer>list=new ArrayList<>();
				for(int j=0;j<l;j++) list.add(v[j]);
				for(int j=n-i+l;j<n;j++) list.add(v[j]);
				Collections.sort(list);
				int j=0;
				for(;j<list.size();j++){
					if(i+j==k||n+j==k||list.get(j)>0)break;
				}
				int tmp=0;
				for(;j<list.size();j++){
					tmp+=list.get(j);
				}
				if(tmp>ans) ans=tmp;
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 24916
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> IP;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)

int main() {
	int N;
	cin >> N;
	int cnt = 0;
	for (int i = 1; i < N; i++) {
		if (i != N - i) {
			cnt++;
		}
	}
	cout << cnt/2 << endl;
}


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

using ll =  long long;
using pint =  pair<int,int>;

#define INF 99999999
#define rep(i,n) for(int (i)=0,temp=(int)(n);(i)<temp;++(i)) 
#define repi(i,start,end) for(int (i)=(start),temp=(int)(end);i<(end);++(i))
#define rfor(v,x) for(const auto& (x) : (v)) //xは値を表す
#define all(x) (x).begin(),(x).end()
#define SORT(v, n) sort((v), (v)+(n))
#define vsort(v) sort((v).begin(), (v).end())
#define vfsort(v,lambda) sort(all((v)),(lambda))
#define vint vector<int>
#define vvint vector<vector<int>> //vvint v(n,vint(n))のように宣言できる
#define vin(v) rep(i,(v).size()) {cin >> (v)[i];}
//最終奥義
#define int long long
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int ctoi(char c) {return c-'0';}
//lambda式 -> [&](int x, int y){return x<y;}
//vector内の重複を削除-> v.erase(unique(all(v)),v.end());

signed main(void){
  int a,b;cin >> a >> b;
  if(b>a) swap(a,b);
  int g=gcd(a,b);
  int num=g;

  
  int ans=1;
  
  //自身を除く素因数の数を計測
  for(int i=2;i*i<=g;++i){
    if(num%i)continue;
    ans++;
    while(num%i==0)num/=i;
  }

  //割り切ったあとが1でなければgcdが素数なので1追加
  if(num!=1)ans++;

  printf("%lld\n",ans);
}


Measured memory_bytes: 256
n = int(input())
S = list(map(int, input().split()))
q = int(input())
T = list(map(int, input().split()))

def binary_search(S, t):
    l = 0
    r = len(S)
    mid = (l+r)//2
    if S[l] == t or S[r-1] == t:
        return True
    while r - mid > 0 and l - mid < 0:
        if S[mid] == t:
            return True
        if S[mid] <= t:
            l = mid
            mid = (l+r)//2
        else:
            r = mid
            mid = (l+r)//2

cnt = 0
for t in T:
    if binary_search(S, t):
        cnt += 1

print(cnt)


Measured memory_bytes: 16712
#include <algorithm>
#include <string>
#include <iostream>
#include <vector>
using namespace std;

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

	int size = S.length();
	
	int ans1 = 0;
	for (int i = 0; i < size; i++) {
		if ((i % 2) == 0) {
			if (S[i] == '0') ans1++;
		}
		else {
			if (S[i] == '1') ans1++;
		}
	}

	int ans2 = 0;
	for (int i = 0; i < size; i++) {
		if ((i % 2) == 0) {
			if (S[i] == '1') ans2++;
		}
		else {
			if (S[i] == '0') ans2++;
		}
	}

	if (ans1 > ans2) cout << ans2;
	else cout << ans1;

	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n, a, b, c, d;
	cin >> n >> a >> b >> c >> d;

	string s;
	cin >> s;

	if (c == d) {
		cout << "No\n";
		return 0;
	}

	for (int i = a - 1; i < c; ++i) {
		if (s[i] == s[i + 1] && s[i] == '#') {
			cout << "No\n";
			return 0;
		}
	}

	for (int i = b - 1; i < d; ++i) {
		if (s[i] == s[i + 1] && s[i] == '#') {
			cout << "No\n";
			return 0;
		}
	}

	if (d > c) {
		cout << "Yes\n";
	} else {
		--b;
		while (b < d) {
			if (s[b] != '#' && s[b - 1] != '#' && s[b + 1] != '#') {
				cout << "Yes\n";
				return 0;
			}

			++b;
		}

		cout << "No\n";
	}

	return 0;

}

Measured memory_bytes: 592
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(ll i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
constexpr char ln = '\n';

const int mx=200010;
const ll mod=1e9+7;

int main(){
  int n;
  cin >> n;
  map<string,int> mp;
  rep(i,n){
    string s;
    cin >> s;
    mp[s]++;
  }
  cout << "AC x " << mp["AC"] << ln;
  cout << "WA x " << mp["WA"] << ln;
  cout << "TLE x " << mp["TLE"] << ln;
  cout << "RE x " << mp["RE"] << ln;
  return 0;
}

Measured memory_bytes: 3628
#include<cstdio>

typedef long long LL;

int main(){
	int n, a, x;
	LL ans;
	while(~scanf("%d", &n)){
		ans = 0;
        a = 0;
        for(int i=1; i<=n; i++){
			scanf("%d", &x);
            if(a >= x){
				ans += x;
				a = 0;
            } else {
				ans += a;
				x -= a;

				ans += (x >> 1);
				a = x & 1;
            }
        }
        printf("%lld\n", ans);
	}
	return 0;
}


Measured memory_bytes: 128
def two_int():
    N, K = map(int, input().split())
    return N,K

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))
import sys
input = sys.stdin.readline

N,M = two_int()

inputs =[]

dicts={}

for i in range(M):
    P,S = input().split()
    S=int(S)
    inputs.append([P,S])
    
    if P not in dicts:
        dicts[P]=[]
    
    dicts[P].append(S)
    


#各県でsort
pref_strs={}
for k, v in dicts.items():
    dicts[k]=sorted(dicts[k])
    pref_strs[k]=k.zfill(6)

import bisect

for i in inputs:
    P,S=i
    
    city_index = bisect.bisect_right(dicts[P], S)
    city_str=str(city_index)
    
    print(pref_strs[P]+city_str.zfill(6))

Measured memory_bytes: 111708
#include <iostream>
#include <cmath>
#include <functional>
#include <algorithm>
long long A, B;

long long func_xor(long long a){
  //int max_2_power = std::log2(a);
  if (a == 0){
    return 0;
  }
  else if (a == 1){
    return 1;
  }
  else if (a == 2){
    return 3;
  }
  else{
  long long souwa_xor = 0;
  int mod4_plus1 = ( (a % 4) + 1) % 4;
    //std::cout << mod4_plus1 << "\n";
    for (long long i = (a - mod4_plus1 + 1); i < a+1; i++){
      souwa_xor =  std::bit_xor<long long>()(souwa_xor, i);
      //std::cout << souwa_xor << "\n";
    }
    return souwa_xor;
  }
}

long long sub_xor(long long a, long long b){
  int max_2_power = std::max(int(std::log2(a)), int(std::log2(b)));
  //std::cout << int(int(std::log2(a))) << "\n";
  //std::cout << int(int(std::log2(b))) << "\n";

  long long c = 0;
  for (int i = 0; i < max_2_power+1; i++){
    if (b%2){
      //std::cout << "(int(!a%2), i) = " << "(" << int(!(a%2)) << "," << i << ")" << "\n";
      c += int(!(a%2)) * std::pow(2, i);
      //std::cout << "b%2 = 1" << c << "\n";
    }
    else{
      c += (a%2) * std::pow(2, i);
      //std::cout << "b%2 = 0" << c << "\n";
    }
      a = (a>>1);
      b = (b>>1);
  }
  return c;
}

int main()
{
  std::cin >> A >> B;
  long long AC = func_xor((A==0) ? 0 : (A - 1) );
  long long BC = func_xor(B);
  //std::cout << "AC" << AC << "\n";
  //std::cout << "BC" << BC << "\n";
  long long C = sub_xor(AC, BC);

  std::cout << C;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

signed main(){

	lli n;
	cin>>n;
	vector<lli> a(n);
	REP(i,0,n)cin>>a[i];

	double sum = 0;

	REP(i,0,n){
		sum += 1.0/(double)a[i];
	}

	double ans = 1.0/sum;
	cout<<setprecision(15)<<ans<<endl;

	return 0;
}

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

using namespace std;

int main() {

	int n, x;
	scanf("%d", &n);

	while(n--) {
		scanf("%d", &x);
		if(x % 2 == 0) {
			if(x % 3 != 0 and x % 5 != 0) {
				return printf("DENIED\n"), 0;
			}
		}
	}

	printf("APPROVED\n");
}


Measured memory_bytes: 256