akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
const int maxn = 66;
const long long inf = 1ll<<58;
int arr[maxn];
int main(){
    vector<pair<int,int> > ops;
    int n;
    cin >> n;
    for(int e = 0; e < n; e++) cin >> arr[e];
    bool all_positive = true, all_negative = true;
    for(int e = 0; e < n; e++) all_positive &= arr[e] >= 0;
    for(int e = 0; e < n; e++) all_negative &= arr[e] <= 0;
    if(all_positive){
        for(int e = 1; e < n; e++) if(arr[e] < arr[e-1]){
            arr[e] += arr[e-1];
            ops.push_back({e-1, e});
        }
    } else if(all_negative){
        for(int e = n-2; e >= 0; e--) if(arr[e] > arr[e+1]){
            arr[e] += arr[e+1];
            ops.push_back({e+1, e});
        }
    } else {
        int mi = arr[0], ma = arr[0];
        for(int e = 0; e < n; e++){
            mi = min(mi, arr[e]);
            ma = max(ma, arr[e]);
        }
        int imi = -1, ima = -1;
        for(int e = 0; e < n; e++){
            if(arr[e] == mi) imi = e;
            if(arr[e] == ma) ima = e;
        }
        if(abs(mi) < abs(ma)){
            for(int e = 0; e < n; e++){
                if(arr[e] < 0){
                    arr[e] += arr[ima];
                    ops.push_back({ima, e});
                }
            }
        } else {
            for(int e = 0; e < n; e++){
                if(arr[e] > 0){
                    arr[e] += arr[imi];
                    ops.push_back({imi, e});
                }
            }
        }
        bool positive = true, negative = true;
        for(int e = 0; e < n; e++) positive &= arr[e] >= 0;
        for(int e = 0; e < n; e++) negative &= arr[e] <= 0;
        if(positive){
            for(int e = 1; e < n; e++) if(arr[e] < arr[e-1]){
                arr[e] += arr[e-1];
                ops.push_back({e-1, e});
            }
        } else if(negative){
            for(int e = n-2; e >= 0; e--) if(arr[e] > arr[e+1]){
                arr[e] += arr[e+1];
                ops.push_back({e+1, e});
            }
        } else {
            assert(0);
        }
    }
    cout << ops.size() << endl;
    for(auto e : ops) cout << e.first + 1 << " " << e.second + 1 << endl;
    return 0;
}


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

using i8  = int8_t;   /* -128 ~ 127 */
using u8  = uint8_t;  /* 0 ~ 255 */
using i16 = int16_t;  /* -32,768 ~ 32,767 */
using u16 = uint16_t; /* 0 ~ 65,535 */
using i32 = int32_t;  /* -2,147,483,648 ~ 2,147,483,647 */
using u32 = uint32_t; /* 0 ~ 4,294,967,295 */
using i64 = int64_t;  /* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using u64 = uint64_t; /* 0 ~ 18,446,744,073,709,551,615 */
using f32 = float;    /* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f64 = double;   /* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f80 = __float80;
template <class T> using Vec = vector<T>;
constexpr i64 INF = 1010000000000000017;
constexpr i64 MOD = 1e9 + 7;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define ALL(v) v.begin(), v.end()
#define GCD(a, b) __gcd(a, b) /* 最大公約数 */
#define LCM(a, b) a / __gcd(a, b) * b /* 最小公倍数 */

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

void Main() {
    i32 N;
    cin >> N;
    Vec<pair<f64, f64>> p(N);
    for (i32 i = 0; i < N; i++) {
        f64 x, y;
        cin >> x >> y;
        p[i] = make_pair(x, y);
    }
    f64 sum = 0;
    Vec<i32> r(N);
    for (i32 i = 0; i < N; i++) r[i] = i;
    i32 count = 0;
    do {
        for (i32 i = 1; i < N; i++) {
            f64 x_d = p[r[i - 1]].first - p[r[i]].first;
            f64 y_d = p[r[i - 1]].second - p[r[i]].second;
            sum += sqrt(x_d * x_d + y_d * y_d);
        }
        count++;
    } while (next_permutation(ALL(r)));
    cout << sum / count << endl;
}


Measured memory_bytes: 3812
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = list(map(int, list(input())))
length = len(N)
# 丁度払うか釣りをもらうか
dp = [[10**18]*2 for _ in range(length+1)]
dp[0][0] = 0
for i in range(1, length+1):
    n = N[-i]
    dp[i][1] = min(dp[i-1][1]+(9-n), dp[i-1][0]+(10-n))
    dp[i][0] = min(dp[i-1][0]+n, dp[i-1][1]+n+1)
    if i==length:
        dp[i][1] = dp[i][1]+1
print(min(dp[-1]))

Measured memory_bytes: 237904
#include <iostream>
#include <math.h>
//#include <numeric>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;
#define n_max 100000

#define rep(i,n) for(int i = 0; i < n; i++)
#define in(a) cin >> a
#define out(a) cout << a << endl
typedef long long ll;

int main()
{
    string s;
    cin >> s;
    int cnt = 0;
   
    for(int i = 0; i < s.size(); i++) {
        if(s[i] == '1') { cnt++; }
    }
    int zero = s.size() - cnt; 
    cout << min(zero, cnt) * 2 << endl;

    return 0;
}


Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Text;

namespace Paiza
{
    public class Hello
    {
        // Input data
        private static Queue<Item> gameObj = new Queue<Item>();
        private static int quantum;
        private static int timeSum = 0;

        public static void Main ()
        {
            ConsoleRead ();
            Method ();
        }

        private static void ConsoleRead ()
        {
            var meta = System.Console.ReadLine ().Split ();
            quantum = int.Parse(meta [1]);
            var num = int.Parse (meta [0]);
            for (int i = 0; i < num; i++) {
                var data = System.Console.ReadLine ().Split ();
                gameObj.Enqueue(new Item () { name = data [0], time = int.Parse (data [1]) });
            }
        }

        public static void Method ()
        {
            while (gameObj.Count != 0) {
                var item = gameObj.Dequeue ();
                if (item.time - quantum <= 0) {
                    item.sum = timeSum + item.time;
                    System.Console.WriteLine (item);
                    timeSum += item.time;
                } else {
                    item.time -= quantum;
                    gameObj.Enqueue (item);
                    timeSum += quantum;
                }
            }
        }

        public class Item
        {
            public string name;
            public int time;
            public int sum;

            public override string ToString ()
            {
                return name + " " + sum;
            }
        }
	}
}

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

using namespace std;

string S, T;
int memo[3010][3010];
int tran[3010][3010]; // 0 : n - 1, 1 : m - 1, 2 : both
int dp(int n, int m) {
	if (n < 0 || m < 0) return 0;
	int &ans = memo[n][m];
	if (ans != -1) return ans;
	if (dp(n - 1, m) > dp(n, m - 1)) {
		ans = dp(n - 1, m);
		tran[n][m] = 0;
	} else {
		ans = dp(n, m - 1);
		tran[n][m] = 1;
	}
	if (S[n] == T[m]) {
		int tmp = dp(n - 1, m - 1) + 1;
		if (tmp > ans) {
			ans = tmp;
			tran[n][m] = 2;
		}
	}

	return ans;
}
int main() {
	memset(memo, -1, sizeof memo);
	cin >> S;
	cin >> T;
	
	int n = S.length() - 1, m = T.length() - 1;
	dp(n, m);
	string ans = "";
	while (n > -1 && m > -1) {
		if (tran[n][m] == 2) {
			ans = S[n] + ans;
			n--; m--;
		} else if (tran[n][m] == 1) {
			m--;
		} else {
			n--;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 71552
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>
#define MOD 1000000007
typedef long long ll;
using namespace std;

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

  if(a>b) cout<<0<<endl;
  else if(n==1&&a!=b) cout<<0<<endl;
  else cout<<(n-2)*b-(n-2)*a+1<<endl;

  return 0;
}


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

using namespace std;

#define INF 1000007
#define MOD 1000000007
#define maxn 100
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)

typedef pair<int, int> P;

int gcd(int a, int b)
{
    return b ? gcd(b, a % b) : a;
}

int lcm(int a, int b) { return a / gcd(a, b) * b; }

int mpow(int N, int P, int M) //繰り返し自乗法
{
    if (P == 0)
        return 1;
    if (P % 2 == 0)
    {
        int t = mpow(N, P / 2, M);
        return t * t % M;
    }
    return N * mpow(N, P - 1, M) % M;
}

int counter(int x) //bit計算
{
    if (x == 0)
        return 0;
    return counter(x >> 1) + (x & 1);
}

vector<bool> prime(maxn + 1, true); //素数テーブル
void prime_table(void)
{
    prime[0] = false;
    prime[1] = false;
    for (int i = 2; i * i <= maxn; i++)
    {
        if (!prime[i])
        {
            continue;
        }
        for (int j = i + i; j <= maxn; j += j + i)
        {
            prime[j] = false;
        }
    }
}

bool IsPrime(int num) //素数判定
{
    if (num < 2)
        return false;
    else if (num == 2)
        return true;
    else if (num % 2 == 0)
        return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }

    return true;
}
vector<int> divisor(int n) //約数列挙
{
    vector<int> ret;
    for (int i = 1; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            ret.push_back(i - 1);
            if (i * i != n)
            {
                ret.push_back((n / i) - 1);
            }
        }
    }
    sort(ret.begin(), ret.end());
    return (ret);
}
int numofbits4(int bits)
{
    int num;

    num = (bits >> 1) & 03333333333;
    num = bits - num - ((num >> 1) & 03333333333);
    num = ((num + (num >> 3)) & 0707070707) % 077;

    return num;
}

int N, M, Q, ans;
vector<int> a, b, c, d;
void dfs(vector<int> A)
{
    if (A.size() == N + 1)
    {
        int now = 0;
        rep(i, Q)
        {
            if (A[b[i]] - A[a[i]] == c[i])
                now += d[i];
        }
        ans = max(ans, now);
        return;
    }
    A.push_back(A.back());
    while (A.back() <= M)
    {
        dfs(A);
        A.back()++;
    }
}
vector<tuple<int, int, int>> wh;

int main()
{
    /*
    int N;
    cin >> N;
    rep(i, N)
    {
        int w, h, area;
        cin >> w >> h;
        area = w * h;
        wh.emplace_back(area, max(w, h), min(w, h));
    }
    sort(wh.begin(), wh.end());
    for (auto x : wh)
    {
        cout << get<0>(x) << " " << get<1>(x) << " " << get<2>(x) << endl;
    }
    */
    int K, A, B;
    cin >> K;
    cin >> A >> B;
    bool check = false;
    for (int i = A; i <= B; i++)
    {
        if (i % K == 0)
            check = true;
    }
    if (check)
    {
        cout << "OK" << endl;
    }
    else
    {
        cout << "NG" << endl;
    }
}

Measured memory_bytes: 3544
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define db long double
#define ii pair<int,int>
#define vi vector<int>
#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define FN(i, n) for (int i = 0; i < (int)(n); ++i)
#define FEN(i,n) for (int i = 1;i <= (int)(n); ++i)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(i,a,b) for(int i=b-1;i>=a;i--)
#define SET(A, val) memset(A, val, sizeof(A))
typedef tree<int ,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set ;
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
vi v;
map<int,int> m;
int main()
{
  std::ios::sync_with_stdio(false);
  cin.tie(NULL) ; cout.tie(NULL) ;
  ll n,x;
  cin>>n;
  rep(i,1,n+1)
    {
      cin>>x;
      m[x]++;
      v.pb(x);
    }
  sort(all(v));
  v.erase(unique(all(v)),v.end());
  ll cnt=0,a;
  reverse(all(v));
  for(ll x:v)
    {
      if(m[x]>=4 && cnt==0)
	{
	  cout<<x*x<<endl;
	  return 0;
	}
      else if(m[x]>=2)
	{
	  cnt++;
	  if(cnt==1) a=x;
	  else
	    {
	      cout<<a*x<<endl;
	      return 0;
	    }
	}
    }
  cout<<0<<endl;
  return 0 ;
}


Measured memory_bytes: 5368
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;


int main(){
  ll n; cin >> n; ll b,c; b = 1; c = n;
  ll a = floor(sqrt(n));
  
  for(ll i=a; i>0; i--){
    if(n % i == 0){
      b = i;
      break;
    }
  }
  
  c = n / b;
  
  cout << b+c-2 << endl;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
b=[0]
for i in range(n):
  b.append(b[-1]+a[i])
#print(b)
ans = 0
b.sort()
for i in range(n+1):
  if i == 0:
    x=b[0]
    m=1
  else:
    if x==b[i]:
      m+=1
      if i==n:
        ans += m*(m-1)//2
    else:
      if m!=1:
        ans += m*(m-1)//2
        m=1
      x=b[i]
print(ans)

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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
template <typename T> using vec = vector<T>;
typedef vec<int> vi;
typedef vec<ll> vl;


template <typename T> T id(T b) {return b;};
template <class It> bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It> bool any(It f,It l){return std::any_of(f,l,id<bool>);}
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }

const int MAX_N = 100000;
int n;
int p[MAX_N];
pii idx[MAX_N+2];

int main()
{
  cin >> n;
  forn(i,n) {
    cin >> p[i];
    idx[i] = mp(p[i],i);
  }

  sort(idx,idx+n,greater<pii>());

  multiset<int> s({-1,-1,n,n});

  ll ans = 0;
  for (int i = 0; i < n; i++) {
    ll v,j;
    tie(v,j) = idx[i];
    s.insert(j);
    auto it = s.upper_bound(j);
    ll u1 = *it;
    it++;
    ll u2 = *it;
    it = s.lower_bound(j);
    it--;
    ll l1 = *it;
    it--;
    ll l2 = *it;
    //printf("j=%lld %lld %lld %lld %lld\n",j,l2,l1,u1,u2);
    ans += 1LL*v*((l1-l2)*(u1-j)+(u2-u1)*(j-l1));
  }

  cout << ans << endl;

  return 0;
}


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

using Int = long long;
//(x^k) mod m
Int powMod(Int x, Int k, Int m) {
	if (k == 0)     return 1;
	if (k % 2 == 0) return powMod(x*x % m, k / 2, m);
	else            return x*powMod(x, k - 1, m) % m;

}
int main(void) {
	long long M, N;
	cin >> M >> N;
	cout << powMod(M, N, 1'000'000'007) << endl;
	return 0;
}


Measured memory_bytes: 3092
#include<iostream>
#include<iomanip>
#include<cstdio>

#include<vector>
#include<queue>
#include<set>
#include<map>
#include<string>

#include<algorithm>
#include<cmath>
#include<numeric>

using namespace std;
typedef long long 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;}


/*
始点を記録
(が始まって以降見ていく
)が(の数を上回ったら始点に挿入
始点に対応する)が観測された時点で終了,始点をそこに移す
始点に対応する)が観測されずに(が続いた場合,そこに)を必要なだけ挿入

*/

int main() {

    
    int N; string S;
    cin >> N >> S;
    int i=0,lp = 0, rp = 0;

    while (i < N) {
        
        if (S[i] == '(') lp++;
        else rp++;
        if (rp > lp) {
            S.insert(0,"(");
            lp++;
            i++;
            N++;
        }
        i++;
    }
    for (int i = 0; i < lp-rp; i++) S += ")";

    cout << S << endl;




}


Measured memory_bytes: 256
from collections import deque

def m():
    N, M = map(int, input().split())
    g = [[] for _ in range(N + 1)]
    dp = [10 ** 9] * (N + 1)
    visited = [False] * (N + 1)
    for _ in range(M):
        a, b = map(int, input().split())
        g[a].append(b)
        g[b].append(a)


    def bfs(root):
        visited[root] = True
        dp[root] = 0
        queue = deque([])
        for q in g[root]:
            dp[q] = root
            queue.append(q)
            visited[q] = True
        while queue:
            q = queue.popleft()
            for k in g[q]:
                if not visited[k]:
                    queue.append(k)
                    dp[k] = q
                    visited[k] = True
    bfs(1)

    if not all(visited[2:]):
        print('No')
        return

    print('Yes')
    for j in dp[2:]:
        print(j)
    return

m()


Measured memory_bytes: 35476
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	triplets
# CreatedDate:  2020-07-11 22:09:08 +0900
# LastModified: 2020-07-11 22:31:12 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd
from itertools import combinations_with_replacement as nCr
from collections import Counter


def main():
    S = list(map(list, nCr(range(1, 100), 3)))
    sum_list = []
    cnt = 0
    for s in S:
#        print(s)
        total = s[0]**2+s[1]**2+s[2]**2+s[0]*s[1]+s[1]*s[2]+s[2]*s[0]
        loop_cnt = 1
        if s[0]!=s[1] and s[1]!=s[2] and s[2]!=s[0]:
            loop_cnt = 6
        elif (s[0] == s[1] and s[1] != s[2]) or (s[1] == s[2] and s[2] != s[0]) or (s[2] == s[0] and s[0] != s[1]):
            loop_cnt = 3
        if total < 10001:
            for _ in range(loop_cnt):
                sum_list.append(total)
        cnt+=1
#        print(sum_list)
    #    if cnt==20:
    #        return
    
    c = Counter(sum_list)
    key = c.keys()
    n = int(input())
    for i in range(1, n+1):
        if not i in key:
            print(0)
        else:
            print(c[i])

if __name__ == "__main__":
    main()


Measured memory_bytes: 30068
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
answer=0
m=-50
for i in range(n):
  t=a[i]
  answer+=b[t-1]
  if t-1==m:
    answer+=c[m-1]
  m=t
print(answer)

Measured memory_bytes: 3064
def gcd(a, b):
    if a < b:
        a, b = b, a
    while b != 0:
        a, b = b, a%b
    return a

N, X = map(int, input().split())
x = list(map(int, input().split()))
if N == 1:
    ans = abs(X-x[0])
elif N == 2:
    ans = gcd(abs(X-x[0]), abs(X-x[1]))
else:
    ans = gcd(abs(X-x[0]), abs(X-x[1]))
    for i in range(2, N):
        ans = gcd(ans, abs(X-x[i]))

print(ans)

Measured memory_bytes: 14252
#!/usr/bin/env python3

# input
n = int(input())
a = list(map(int, input().split()))
q = int(input())
b = [-1 for _ in range(q)]
c = [-1 for _ in range(q)]
for i in range(q):
    b[i], c[i] = map(int, input().split())

def innerproduct(d):
    ans = 0
    for key, value in d.items():
        ans += int(key)*int(value)
    return ans

# calc
d = {}
for i in a:
    if i not in d:
        d[i] = 1
    else:
        d[i] += 1

# print(d)
ans = sum(a)
for i in range(q):
    if b[i] in d:
        ans -= b[i]*d[b[i]]
        tmp = d[b[i]]
        if c[i] not in d:
            d[c[i]] = d[b[i]]
        else:
            d[c[i]] += d[b[i]]
        d[b[i]] = 0
        ans += tmp*c[i]

#    print(d)
    print(ans)

Measured memory_bytes: 25872
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
const int N = 1e5 + 5;
#define int long long int

int32_t main() {
    IOS ;
    // int t ; cin >> t ; while(t--) {}
    int x ; cin >> x  ;
    if(x) cout << 0 ; 
    else cout << 1 ;
    
    return 0 ;
}


Measured memory_bytes: 3652
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int c = in.nextInt();
		int[][] d = new int[c][c];
		for(int i=0;i<c;i++) {
			for(int j=0;j<c;j++) {
				d[i][j] = in.nextInt();
			}
		}
		List<Integer> list0 = new ArrayList<>();
		List<Integer> list1 = new ArrayList<>();
		List<Integer> list2 = new ArrayList<>();
		for(int i=0;i<n;i++) {
			for(int j=0;j<n;j++) {
				if((i+j)%3==0) {
					list0.add(in.nextInt()-1);
				}else if((i+j)%3==1) {
					list1.add(in.nextInt()-1);
				}else {
					list2.add(in.nextInt()-1);
				}
			}
		}
		
		int[] cost0 = new int[3];
		cost0[0] = cost0[1] = cost0[2] = Integer.MAX_VALUE;
		int[] idx0 = new int[3];
		for(int i=0;i<c;i++) {
			int sum = 0;
			for(int idx=0;idx<list0.size();idx++) {
				sum += d[list0.get(idx)][i];
			}
			if(sum<cost0[0]) {
				cost0[2] = cost0[1];
				idx0[2] = idx0[1];
				cost0[1] = cost0[0];
				idx0[1] = idx0[0];
				cost0[0] = sum;
				idx0[0] = i;
			}else if(sum<cost0[1]) {
				cost0[2] = cost0[1];
				idx0[2] = idx0[1];
				cost0[1] = sum;
				idx0[1] = i;
			}else if(sum<cost0[2]) {
				cost0[2] = sum;
				idx0[2] = i;
			}
		}
		
		int[] cost1 = new int[3];
		cost1[0] = cost1[1] = cost1[2] = Integer.MAX_VALUE;
		int[] idx1 = new int[3];
		for(int i=0;i<c;i++) {
			int sum = 0;
			for(int idx=0;idx<list1.size();idx++) {
				sum += d[list1.get(idx)][i];
			}
			if(sum<cost1[0]) {
				cost1[2] = cost1[1];
				idx1[2] = idx1[1];
				cost1[1] = cost1[0];
				idx1[1] = idx1[0];
				cost1[0] = sum;
				idx1[0] = i;
			}else if(sum<cost1[1]) {
				cost1[2] = cost1[1];
				idx1[2] = idx1[1];
				cost1[1] = sum;
				idx1[1] = i;
			}else if(sum<cost1[2]) {
				cost1[2] = sum;
				idx1[2] = i;
			}
		}
		
		int[] cost2 = new int[3];
		cost2[0] = cost2[1] = cost2[2] = Integer.MAX_VALUE;
		int[] idx2 = new int[3];
		for(int i=0;i<c;i++) {
			int sum = 0;
			for(int idx=0;idx<list2.size();idx++) {
				sum += d[list2.get(idx)][i];
			}
			if(sum<cost2[0]) {
				cost2[2] = cost2[1];
				idx2[2] = idx2[1];
				cost2[1] = cost2[0];
				idx2[1] = idx2[0];
				cost2[0] = sum;
				idx2[0] = i;
			}else if(sum<cost2[1]) {
				cost2[2] = cost2[1];
				idx2[2] = idx2[1];
				cost2[1] = sum;
				idx2[1] = i;
			}else if(sum<cost2[2]) {
				cost2[2] = sum;
				idx2[2] = i;
			}
		}
		
		List<Integer> kouho = new ArrayList<>();
		
		for(int x=0;x<3;x++) {
			for(int y=0;y<3;y++) {
				for(int z=0;z<3;z++) {
					if(idx0[x]!=idx1[y] && idx1[y]!=idx2[z] && idx2[z]!=idx0[x]) {
						kouho.add(cost0[x]+cost1[y]+cost2[z]);
					}
				}
			}
		}
		
		int min = Integer.MAX_VALUE;
		for(int i:kouho) {
			if(i<min) min=i;
		}
		System.out.println(min);

	}

}


Measured memory_bytes: 80824
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;

int main() {
  int x, y;
  cin >> x >> y;
  cout << x+y/2 << endl;
}

Measured memory_bytes: 256
#include <iostream>

#include <vector>
#include <map>
#include <algorithm>
#include <fstream>
#include<cstdio>
#include<iomanip>
#include<stack>
#include<queue>
#include<string>
#include <cstdlib>
#include <typeinfo>

#define REP(i, n) for(int i=0;i<n;i++)
#define REP2(i, s, n) for(int i=s;i<n;i++)
#define REP_1(i, n) for(int i=1;i<n+1;i++)
#define bitSearch(bit, n) for(int bit = 0; bit < (1 << N); bit++)
using namespace std;

template<class T>
void print(const T &value) {
    std::cout << value << std::endl;
}

void yesno(bool a) { if (a)cout << "Yes" << endl; else cout << "No" << endl; }

void YESNO(bool a) { if (a)cout << "YES" << endl; else cout << "NO" << endl; }

typedef long long ll;
typedef unsigned long ul;
typedef long double ld;

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

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

//ll INF = 10000000;
//ll mod = 1000000007;//10^9+7

//using Graph = vector<vector<pair<int, int>>>;
//Graph G(100100);


//番号ズレ注意！！
int main() {
    int N;
    cin >> N;
    bool can = false;
    REP(i, N / 4+1) {
        if ((N - i * 4) % 7 == 0) { can = true; break;}
    }
    yesno(can);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    string S;
    long long K;
    cin >> S >> K;
    long long cou=0;
    long long ans=0;
    long long N=S.size();
    for(int i=1;i<S.size();i++){
        if(S.at(i)==S.at(i-1)) {
            cou++;
            i++;
        }
    }
    bool z=true;
    rep(i,N){
        if(S[0]!=S[i]) z=false;
    }
    if(z) ans= N*K/2;
    else if(S[0]!=S[N-1]) ans=cou*K;
    else{
        int a=1,b=1;
        for(int i=1;i<N;i++){
            if(S[i]==S[0]) a++;
            else break;
        }
        for(int i=N-2;i>0;i--){
            if(S[i]==S[0]) b++;
            else break;
        }
        int x=(int)a/2+(int)b/2-(int)(a+b)/2;
        ans=cou*K-(K-1)*x;
    }
    
    
    cout << ans << endl;


}


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

using namespace std;

int count75(int prev, const std::vector<int> counts, int const startIdx) {
  int const count = counts[startIdx];
  if (count == 0) {
    return prev == 75 ? 1 : 0;
  }
  int ret = 0;
  for (int i = 1; i <= count + 1; i += 2) {
    if (i % 2 == 0) {
      continue;
    }
    int const current = prev * i;
    if (current % 9 == 0) {
      continue;
    }
    if (current > 75) {
      break;
    }
    ret += count75(current, counts, startIdx + 1);
  }
  return ret;
}

int calc(int n) {
  constexpr int primeCount = 25;
  static std::array<int, primeCount> primes = {
      2,  3,  5,  7,  11, 13, 17, 19, 23, 29, 31, 37, 41,
      43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97};
  if (n <= 1) {
    return 0;
  }
  std::vector<int> primeCounts(primeCount + 1, 0);
  for (int i = 2; i <= n; ++i) {
    int ii = i;
    for (int pIdx = 0; ii > 1 && pIdx < primeCount; ++pIdx) {
      const int prime = primes[pIdx];
      if (ii < prime) {
        break;
      }
      while (true) {
        if ((ii % prime) != 0) {
          break;
        }
        ii /= prime;
        primeCounts[pIdx]++;
      }
    }
  }
  std::sort(primeCounts.rbegin(), primeCounts.rend());
  return count75(1, primeCounts, 0);
}

int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  int n;
  std::cin >> n;
  std::cout << calc(n) << std::endl;
  return 0;
}


Measured memory_bytes: 256
n=int(input())
t=[0]*(n+1)
x=[0]*(n+1)
y=[0]*(n+1)
for i in range(1,n+1):
    t[i],x[i],y[i]=map(int,input().split())
time=0
dist=0
for i in range(n):
    dist=abs(x[i+1]-x[i])+abs(y[i+1]-y[i])
    time=t[i+1]-t[i]
    if time>=dist and time%2 == dist%2:
        continue
    else:
        print('No')
        exit()
print('Yes')

Measured memory_bytes: 11636
n = gets.to_i

if n < 2 
  puts 0
else
  if n % 2 != 0
    puts 0
  else
    limit = 5
    array = []

    while n / limit >= 1
      array.push(limit * 2)
      limit *= 5
    end
    
    sum = 0
    array.each do |number|
      sum += n / number
    end

    puts sum
  end
end


Measured memory_bytes: 1788
import sys
def gcd(c,d):
    a = max(c,d)
    b = min(c,d)
    if b == 0:
        return a
    return gcd(b,a%b)
n = int(input())
a = list(map(int,input().split()))
a.sort()
ans = a[0]
for i in a[1:]:
    ans = gcd(ans,i)
print(ans)


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

#define check cout<<"-------"<<endl
#define debug(x) cout<<x<<endl;
#define loop(i,x,n) for(int i = x; i < n; i++)
#define lop(i,n) repi(i,0,n)
#define fix(x) cout<<fixed<<setprecision(x);

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a, b, c, count = 0;
    
    cin>>a>>b>>c;
    
    for(; a <= b; a++) {
        if(c % a == 0) count++;
    }
    
    cout<<count<<endl;
    
    return 0;
}


Measured memory_bytes: 3224
char S[1<<17],T[1<<17];
a,b,c;
main(d){
	for(scanf("%s%s%*d",S+1,T+1);S[d]|T[d];++d)
		S[d]=(S[d-1]+S[d]%4)%3,
		T[d]=(T[d-1]+T[d]%4)%3;
	for(;~scanf("%d%d%d%d",&a,&b,&c,&d);)
		puts((S[b]-S[a-1]-T[d]+T[c-1])%3?"NO":"YES");
}


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

int main(){
  int c[3][3];rep(i,3){rep(j,3)cin >> c[i][j];}
  int a1,a2,a3,b1,b2,b3;
  a1 = 0;b1 = c[0][0];
  a2 = c[1][0] - b1;b2 = c[1][1] - a2;
  a3 = c[2][0] - b1;b3 = c[2][2] - a3;
  int d[3][3];
  rep(i,3){
    rep(j,3){
      int k,l;
      if(i == 0)k = a1;
      else if(i == 1)k = a2;
      else if(i == 2)k = a3;
      if(j == 0)l = b1;
      else if(j == 1)l = b2;
      else if(j == 2)l = b3;
      d[i][j] = k+l;
    }
  }
  rep(i,3){
    rep(j,3){
      if(c[i][j] != d[i][j]){
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
/*! if g++ -g alds_1_6_b.cpp -o alds_1_6_b.out; then ./alds_1_6_b.out < alds_1_6_b.test; fi
 */

#include <sstream>
#include <cstring>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iterator>
#include <numeric>
#include <functional>
#include <climits>



using namespace std;
typedef unsigned long long ull;
typedef long long ll;

void swap(int& x, int& y){
  if(&x == &y) return;
  x = x^y;
  y = x^y;
  x = x^y;
}

int partition(vector<int>& a, int p, int r){
  int x = a[r];
  int i = p - 1;
  for (int j = p; j < r; j++) {
    if(a[j] <= x){
      i++;
      swap(a[i], a[j]);
    }
  }
  i++;
  swap(a[i], a[r]);
  return i;
}


int main(int argc, char *argv[]){
  size_t n;
  cin >> n;
  vector<int> v(n);
  for (size_t i = 0; i < n; i++) {
    cin >> v[i];
  }
  int ret = partition(v, 0, v.size()-1);
  vector<string> s(n);
  for (size_t i = 0; i < n; i++) {
    stringstream ss;
    if(i == ret){
      ss << "[";
    }
    ss << v[i];
    if(i == ret){
      ss << "]";
    }
    s[i] = ss.str();
  }
  for (size_t i = 0; i < n-1; i++) {
    cout << s[i] << " ";
  }
  cout << s.back() << endl;


  return 0;
}

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

int h_num[300100];
int w_num[300100];

int main(){
    int H, W, M;
    cin >> H >> W >> M;

    set<pair<int, int>> s;
    for(int h=0; h<H; ++h){
        h_num[h] = 0;
    }

    for(int w=0; w<W; ++w){
        w_num[w] = 0;
    }

    for(int i=0; i<M; ++i){
        int h, w;
        cin >> h >> w;
        h--; w--;

        h_num[h]++;
        w_num[w]++;
        s.emplace(h, w);
    }

    int h_max = 0;
    int h_index = -1;
    int w_max = 0;
    int w_index = -1;

    set<int> w_idx_candidate;
    set<int> h_idx_candidate;

    for(int h=0; h<H; ++h){
        if( h_max < h_num[h] ){
            h_max = h_num[h];
            h_index = h;
            h_idx_candidate.clear();
            h_idx_candidate.insert(h_index);
        }else if(h_max == h_num[h]){
            h_idx_candidate.insert(h);
        }
    }

    for(int w=0; w<W; ++w){
        if( w_max < w_num[w] ){
            w_max = w_num[w];
            w_index = w;
            w_idx_candidate.clear();
            w_idx_candidate.insert(w);
        }else if(w_max == w_num[w]){
            w_idx_candidate.insert(w);
        }
    }

    bool flag = false;
    if(h_max > w_max){
        for(int w_idx: w_idx_candidate){
            if(s.count({h_index, w_idx}) == 0){
                flag = true;
            }
        }
    }else{
        for(int h_idx: h_idx_candidate){
            if(s.count({h_idx, w_index}) == 0){
                flag = true;
            }
        }
    }


    int ans = h_max + w_max;
    if(flag == false){
        ans -= 1;
    }

    cout << ans << endl;
}

Measured memory_bytes: 48132
n = int(input())
for i in range(n) :
    max_up = 0
    max_down = 0
    m = int(input())
    dansa = list(map(int, input().split()))
    for j in range(len(dansa)-1) :
        x = dansa[j+1] - dansa[j]
        if x > max_up :
            max_up = x
        if -x > max_down :
            max_down = -x
    print(max_up, max_down)


Measured memory_bytes: 5608
//https://blog.csdn.net/hesorchen
#include <algorithm>
#include <iostream>
#include <cstring>
#include <string>
#include <cstdio>
#include <queue>
#include <cmath>
#include <stack>
#include <map>
#include <set>
using namespace std;
#define ll long long
#define lowbit(a) (a & (-a))
#define mod 1000000007
#define INF 0x3f3f3f3f
#define endl "\n"
#define MAX 100010

int p[5];
int main()
{
    cin >> p[0] >> p[1] >> p[2];
    sort(p, p + 3);
    int ans = 0;
    ans += (p[2] - p[0]) / 2;
    p[0] += ((p[2] - p[0]) / 2) * 2;
    ans += (p[2] - p[1]) / 2;
    p[1] += ((p[2] - p[1]) / 2) * 2;
    // cout << ans << endl;
    sort(p, p + 3);
    if (p[0] == p[2])
        ans += 0;
    else if (p[1] == p[2])
        ans += 2;
    else if (p[1] == p[0])
        ans += 1;
    cout << ans << endl;

    return 0;
}

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

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

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int int_sort( const void * a , const void * b ) {return strcmp(( char * )a , ( char * )b );}
int count_digit(int a){int i=0;while(a!=0){a=a/10;i++;}return i;}
int euclid( int a, int b ){int temp;if(a<b){temp=a;a=b;b=temp;}if(b<1)return -1;if(a%b==0) return b;return euclid(b,a%b);}

int main(void){
 
    int n, cnt[4]={0, 0, 0, 0};
    char s[max][4], ac[3]={"AC"}, wa[3]={"WA"}, tle[4]={"TLE"}, re[3]={"RE"};
    
    scanf("%d", &n);
    rep(i, n){
        scanf("%s", s[i]);
        if (strcmp(s[i], ac)==0) {
            cnt[0]++;
        } else if (strcmp(s[i], wa)==0) {
            cnt[1]++;
        } else if (strcmp(s[i], tle)==0) {
            cnt[2]++;
        } else if (strcmp(s[i], re)==0) {
            cnt[3]++;
        }
    }
    
    printf("AC x %d\n", cnt[0]);
    printf("WA x %d\n", cnt[1]);
    printf("TLE x %d\n", cnt[2]);
    printf("RE x %d\n", cnt[3]);
    
    return 0;
}



Measured memory_bytes: 2124
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
     
int main(){
 int N,A,B;
 std::cin >> A >> B;
 if((A*B)%2==0){
   std::cout << "Even" << std::endl;
 }else{
   std::cout << "Odd" << std::endl;
 }
}

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

using namespace std;

int main(){
	int K,T;
	cin>>K>>T;
	vector<pair<int,int> > a;
	for(int i=0;i<T;i++){
		int b;
		cin>>b;
		a.push_back(make_pair(b,i));
	}
	int prev=-1;
	int res = 0;
	for(int d=0;d<K;d++){
		sort(a.begin(),a.end());
		for(int i=a.size()-1;i>=0;i--){
			if(a[i].second != prev && a[i].first > 0){
				a[i].first--;
				prev = a[i].second;
				break;
			}
			if(i == 0){
				a[prev].first--;
				res++;
			}
		}
	}
	cout<<res<<endl;
}

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

#define rep(i, m, n) for(int(i) = (int)(m); i < (int)(n); ++i)
#define rep2(i, m, n) for(int(i) = (int)(n)-1; i >= (int)(m); --i)
#define REP(i, n) rep(i, 0, n)
#define REP2(i, n) rep2(i, 0, n)
#define all(hoge) (hoge).begin(), (hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T>
using vec = vector<T>;
template <class T>
using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll)1e9 + 7;
//constexpr long long MOD = 998244353LL;
using ld = long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;

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

struct Edge {
    ll to, rev;
    long double cap;
    Edge(ll _to, long double _cap, ll _rev) {
        to = _to;
        cap = _cap;
        rev = _rev;
    }
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph &G, ll from, ll to, long double cap, bool revFlag,
              long double revCap) {
    G[from].push_back(Edge(to, cap, (ll)G[to].size()));
    if(revFlag)
        G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void solve() {
    string s, t;
    cin >> s >> t;
    ll n = s.size();
    ll ans = 0;
    REP(i, n) {
        if(s[i] != t[i])
            ans++;
    }
    cout << ans << en;
}

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

    solve();
    // ll t;cin>>t;REP(i,t) solve();

    return 0;
}


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

using namespace std;
using ll =long long;

#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cout << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
bool coY() {cout <<"Yes"<<endl;}
bool coN(){cout <<"No"<<endl;}

const ll INF = 1LL << 60;

ll n,m;
string s;
//Write From this Line

const int mod = 1e9+7;
int main()
{
	cin >> n;
	vector<int> a(n);//ookisa
	rep(i,n) cin>>a[i];
	SORT(a);
	ll start = 0 ;
	ll ans = 0 ; 
	rep(i,n){
		if(start * 2 >= a[i] ){
			ans ++ ;
		}
		else{
			ans = 0 ;
		}
		start += a[i];
	}
	ans ++ ;
	cout << ans << endl;

}



Measured memory_bytes: 640
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int a;
    string s;
    cin >> a >> s;
    if (a >= 3200) cout << s << endl;
    else cout << "red" << endl;
}

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

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	int n, a[100];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int s = 0; s < n - 1; s++) {
		for (int t = s + 1; t < n; t++) {
			if (a[t] > a[s]) {
				int tmp = a[t];
				a[t] = a[s];
				a[s] = tmp;
			}
		}
	}
	int ans=n;
	for (int s = 0; s < n - 1; s++) {
		if (a[s] == a[s + 1]) {
			ans--;
		}
	}

	
	cout << ans << endl;
	return 0;


}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define N	    100001
#define rep(i,a,b)  for(int i=a;i<b;i++)
int dp[N];
int main() {
	int n, k;
	cin>>n>>k;
	int a[n + 1];
	rep(i, 0, n)
		cin>>a[i];
	a[n] = a[n- 1];
	for(int i = n - 2; i >= 0; i--) {
		dp[i] = INT_MAX;
		for(int j = 1; j <= k; j++) {
			int d = i + j;
			if(d > n - 1)
				break;
			dp[i] = min(abs(a[i] - a[d]) + dp[d], dp[i]);
		}

	}
	cout<<dp[0]<<endl;
}


Measured memory_bytes: 1024
import java.util.*;
class Main
{
    public static void main (String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] t = new long[n];
        long ans = 1;
        for(int i = 0; i < n; i++)
            ans = lcm(ans, sc.nextLong());
        System.out.print(ans);
    }
    static long lcm(long a, long b){
        return a / gcd(a, b) * b;
    }
    static long gcd(long a, long b){
        if(b == 0) return a;
        return gcd(b, a % b);
    }
}

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

#define CEIL(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))
#define X first
#define Y second

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vl = vector<ll>;
using vs = vector<string>;

constexpr int MOD = int(1e9 + 7);
constexpr int INF = int(1e9 + 1);
constexpr ll LLINF = ll(4 * 1e18 + 1);
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

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

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

    int n;
    cin >> n;
    vector<int> h(n);
    for(int i = 0; i < n; ++i){
        cin >> h[i];
    }
    
    int ans = 0;
    for(int i = 1; i <= 100; ++i){
        int cnt = 0;
        for(int j = 0; j < n - 1; ++j){
            if(h[j] >= i && h[j + 1] < i) ++cnt;
        }
        ans += cnt + int(h[n - 1] >= i);
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) *b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};


///////////////////////////


int main() {
	ll N;
	cin >> N;
	vector<ll> A(N + 1);

	repn(i, N) cin >> A[i];

	vector<ll> s(N + 1, 0);

	repn(i, N) s[i] = s[i - 1] + A[i];

	map<ll, ll> mp;

	rep(i, N+1) mp[s[i]]++;

	ll ans = 0;
	for (auto x : mp) {
		ans += x.second*(x.second - 1) / 2;
	}
	
	cout << ans;
	
	system("PAUSE");

}





Measured memory_bytes: 16120
import java.util.*;
class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String[] S = sc.nextLine().split("");
    long K = sc.nextLong();
    String ret = "1";
    for (int i = 0; i < 100; i++) {
      if (!S[i].equals("1")) {
        ret = S[i];
        break;
      }
      if (K == 1+i) {
        break; 
      }
    }
    System.out.println(ret);
  }
}

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

int main() {
  ll n;
  cin >> n;
  ll ans = n;
  for (ll i = 2; i*i <= n; ++i) {
    if (n%i == 0) ans = n/i;
  }
  int k = 0;
  while (ans) {
    ++k;
    ans /= 10;
  }
  cout << k << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;


int main(){
  ll n; cin >> n;
  vl num(n);
  rep(i,n){
    ll x; cin >> x;
    num.at(i) = x;
  }
  
  ll count = 0; ll min = 1000000;
  rep(i,n){
    if(num.at(i) <= min){
      count++;
      min = num.at(i);
    }
  }
  
  cout << count << endl;
}

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

typedef long long ll;

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

    ll h,w;
    cin >> h >> w;
    if(h==1 || w==1){
        cout << 1 << endl;
        return 0;
    } 
    ll ans = (h*w+1)/2;
    cout << ans << endl;
    return 0;
}

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

int main(){

    int x,a,b;
    cin >> x >> a >> b;
    int da = (x-a)*(x-a);
    int db = (x-b)*(x-b);

    cout << ( da < db ? 'A' : 'B' ) << endl;

}


Measured memory_bytes: 256
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>

using namespace std;

int main()
{
    int n,m;
    cin>>n>>m;
    if (m>n){
        cout<<"NO"<<endl;
    }
    else {
        if (n%2==1){
            int k=(n+1)/2;
            if (k>=m){
                cout<<"YES"<<endl;
            }
            else {
                cout<<"NO"<<endl;
            }
            
        }
        else {
            int k=n/2;
            if (k>=m){
                cout<<"YES"<<endl;
            }
            else {
                cout<<"NO"<<endl;
            }
        }
    }
    

    return 0;
}


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

int main(void){
	long a,b,ans;
	cin >> a >> b;
	
	for(int i=1; i<=b; i++){
		if(a*i % b == 0){
			ans= a*i;
			break;
		}
	}
	
	cout << ans << endl;
	
	return 0;
}


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

const int MAXN = (int)2e5 + 1;;
const int P = 998244353;

int fact[MAXN];

void init(int n) {
  fact[0] = 1;
  for (int i = 1; i <= n; ++i) 
    fact[i] = (int64_t)fact[i - 1] * i % P;
}

int64_t pow(int64_t x, int y) {
  x %= P;
  int64_t ans = 1;
  while (y > 0) {
    if (y & 1) ans = ans * x % P;
    x = x * x % P;
    y >>= 1;
  }
  return ans;
}

int64_t comb(int x, int y) {
  return fact[x] * pow((int64_t)fact[y] * fact[x - y], P - 2) % P;
}

// n个格子，m种颜色，最多有k对相邻格子是同一种颜色，求方案数.
// 枚举i = 0 -> k, 对于刚好有i对相邻格子是同一种颜色的情况，推公式.
int solve(int n, int m, int k) {
  init(n);
  int64_t ans = 0;
  for (int i = 0; i <= k; ++i) {
    int64_t cur = m * pow(m - 1, n - 1 - i) % P * comb(n - 1, i) % P;
    ans = (ans + cur) % P;
  }
  return ans;
}

int main() {
  int n, m, k;
  std::cin >> n >> m >> k;
  std::cout << solve(n, m, k) << std::endl;
  return 0;
}


Measured memory_bytes: 4360
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void)
{
	int a,b,c,d;
	int ans = 0;
	scanf("%d%d%d%d", &a, &b, &c, &d);
	ans = min(a,b) + min(c,d);
	printf("%d\n",ans);
	return 0;
 } 

Measured memory_bytes: 128